Page 1 of 1

trigger with animated subvalve?

Posted: Mon Jan 24, 2005 10:26 pm
by wacko
I want to launch a thread by a subvalve (animate/redvalve_nopulse) and I want the player to have to use it until it turned for e.g 360? (it shall rotate of course), then launch the thread. As soon as the player interrupts using the valve, it shall turn back.
What's the easiest way to do so? Anyone done this or similar before? I might be able to do it, but I have the slight feeling i'd do it too complicate :wink:

Posted: Mon Jan 24, 2005 10:30 pm
by Elgan
ust do while useheld==1 then when it snot turn bk

Posted: Mon Jan 24, 2005 10:38 pm
by wacko
yes, that's what I will have to do. There's no predefined animations for the valve like for the alarmswitch?! :(

Posted: Mon Jan 24, 2005 10:49 pm
by wacko
Ooops, useheld?! :oops:
who's useheld? a trigger_use? the valve? the player? could u explain this for a noob? :wink:

Posted: Mon Jan 24, 2005 11:51 pm
by lizardkid
trigger_use, setthread to a thread like this

Code: Select all

while($player useheld)
{
// rotate the thing and whatever else
}
that's useheld, as long as use is held, the loop keeps going, so make it very small increments, or use wait 1 or something to smooth it out.

Posted: Tue Jan 25, 2005 2:31 pm
by wacko
lizardkid wrote:

Code: Select all

while($player useheld)
{
// rotate the thing and whatever else
}
thanks so far! u are using $player. In another script I saw something similar which used parm.other instead. What would be the difference?

Posted: Tue Jan 25, 2005 2:49 pm
by MPowell1944
In the tiki file, it only has the idle anim. You need to find one that has other anim states.

Regarding parm.other. That is used with a trigger. In your case, it would be local.player = parm.other, which says that only the person touching the trigger can rotate it.

Posted: Tue Jan 25, 2005 3:04 pm
by wacko
I have a trigger to start the thread, so parm.other should be fine!?
Her'es what I have so far

Code: Select all

main:
...
level waitTill prespawn
	thread water_prep
	...

level waittill spawn
	...
end


water_prep:
	level.wheelrot = 0		//wheel is in startposition
	level.waterrun = 0		//water is not in action
end


water_on:
while(1)
{
	if ((parm.other.useheld) && (isalive parm.other) && (parm.other cansee $water_wheel 45 96))
	{
		if (level.wheelrot <= 360)
		{
			$water_wheel rotateZ 1
			level.wheelrot++
		}
		
		if (level.wheelrot > 360 && level.waterrun == 0)
		{
			level.waterrun = 1  //water is moving
			thread water_rise	//thread to let water go up and down
			wait .5
		}
	}
	if ((!(parm.other.useheld) || !(isalive parm.other) || !(parm.other cansee $water_wheel 45 96)) && (level.wheelrot > 0))
	{
		$water_wheel rotateZ -1
		level.wheelrot--
	}
	if (level.wheelrot <= 0)
	{
		level.wheelrot = 0
	}	
}
end

		
water_rise:
		...
		level.waterrun = 0 
end
but with this I get a
if ((!(parm.other.useheld) || !(isalive parm.other) || !(parm.other cansee $water_wheel 45 96)) && (level.wheelrot > 0))
if ((!(parm.other.useheld) || !(isalive parm.other) || !(parm.other ^
^~^~^ Script Error: NULL entity in parameter 1
several times and then a command overflow :cry:

Could u tell me what to do, plz?

Posted: Tue Jan 25, 2005 3:11 pm
by wacko
:oops: :oops: wait a sec... I didn't have a $water_wheel, omg, is this embarrassing, there was just the static_model (not even with a targetname)

Posted: Tue Jan 25, 2005 3:46 pm
by lizardkid
ok, but ime (in my experience) having a lot of NOT operators can be extremely confusing. but it's confusing to me all the NOTs you were going through,
if ((!(parm.other.useheld) || !(isalive parm.other) || !(parm.other cansee $water_wheel 45 96)) && (level.wheelrot > 0))
if ((!(parm.other.useheld) || !(isalive parm.other) ||
so if he's not holding USE, he's not alive, he can't see the water wheel, and the wheel rotation variable is at 0....

it didn't make much sense to me :S

Posted: Tue Jan 25, 2005 8:28 pm
by wacko
the NOT operators are for the case that
(the player does NOT press use-key OR is dead OR does NOT look to the wheel) AND the wheel is not in it's start position, the wheel shall rotate back to it's start position.

here's the status quo, which gives me a command overflow after having used the trigger

Code: Select all

water_on:
self nottriggerable
while(1)
{
	if ((parm.other.useheld) && (isalive parm.other) && (parm.other cansee $water_wheel 45 96))
	{
		if (level.wheelrot <= 360)
		{
			$water_wheel rotateZ 1
			level.wheelrot++
			$water_wheel playsound wheel_move
		}
		
		if (level.wheelrot > 360 && level.waterrun == 0)
		{
			level.waterrun = 1  //water is moving
			$water_wheel playsound wheel_stop
			thread water_rise	//thread to let water go up and down
			wait .5
		}
		self triggerable
	}
	if ((!(parm.other.useheld) || !(isalive parm.other) || !(parm.other cansee $water_wheel 45 96)) && (level.wheelrot > 0))
	{
		$water_wheel rotateZ -1
		level.wheelrot--
		$water_wheel playsound wheel_move		
	}
	if (level.wheelrot < 0)
	{
		level.wheelrot = 0
	}	
}
end
This is with 3 if-clauses, in descending order:
3rd: if the wheel's rotation variable is negative, it is set to 0
2nd: if the player releases the wheel (the trigger), the wheel shall rotate back
1st: if the player uses the trigger in a proper way, the wheel shall either rotate to it's end position or as soon as it has reached that, it shall stop and call the thread to let the water rise.

But, as stated, I get a possible infinite loop (command overflow) after a single move of the wheel. Unfortunately, I don't have any idea why or how to fix this. :cry:

Posted: Tue Jan 25, 2005 8:47 pm
by lizardkid
i.. honestly don't know what to do :S

try making a more artificial way, but it might work better.

like;

once the player hits and holds the wheel, use the bomb script used on stock maps to determine if he's hodling it and pop hte stopwatch etc. once the player lets go of the USE key, send a message (i guess that's impossible,so set a variable) and use a while loop based on that variable to make the wheel spin away.

i suppose you'll want to set it back to normal for looks, so maybe havea var at 0 at the beginning and increment it when the useheld thing is donw.. set it to rotateZ 1 and wait until it returns to original position.


anyway, you'll have to adjust the script somehow... only way i see to do it is use something that works already. *shrug*

Posted: Tue Jan 25, 2005 9:28 pm
by wacko
lizardkid wrote:i.. honestly don't know what to do :S
me neither :cry: , but tvm nevertheless :)
lizardkid wrote:anyway, you'll have to adjust the script somehow... *
hehe, that's obvious :wink:
lizardkid wrote:only way i see to do it is use something that works already. *shrug*
that's what i was asking for in the 1st post :cry:

let's see, maybe someone else finds a way or I'll do a (boring) alarmswitch :roll:

Posted: Wed Jan 26, 2005 10:06 am
by wacko
command overflow is gone:
i added a
...
}
wait .5
}
end

and it's fine :D

Timing and wheel speed is still crap but this will be sorted out soooon 8-)

Posted: Wed Jan 26, 2005 12:19 pm
by wacko
in fact, i also needed a 'break' to let the script find it's peace again after all that action :wink:
So, thanks for ur help and maybe take a look at the pk3 with bsp or the pk3 with map file in the recycling bin