Page 1 of 2

basic scripting / trigger problem

Posted: Mon May 05, 2003 7:37 pm
by wacko
I was trying to make a swaying bridge as bodybagger thought off, but I'm just too stupid: Here's what I did:
Image
Trigger A is: targetname/bridge_off and setthread/bridge_sway_off
Trigger B is: targetname/bridge_on and setthread/bridge_sway_on
The bridge is a script_object with targetname/bridge

Then I have a script:
main:
level waittill spawn
thread bridge_prep
end

bridge_sway_on:
$bridge_on nottriggerable
$bridge_off triggerable
thread bridge_swing
end

bridge_sway_off:
$bridge_off nottriggerable
thread bridge_stop
$bridge_on triggerable
end

bridge_swing:
$bridge rotateXup 2
$bridge waitmove
$bridge rotateXdown 4
$bridge waitmove
$bridge rotateXup 2
$bridge waitmove
goto bridge_swing
end

bridge_stop:
$bridge rotateXdown 2
$bridge waitmove
$bridge rotateXdown 0
end

bridge_prep:
$bridge_off nottriggerable
$bridge time 0.2
end


Now, the bridge starts rotating when I enter Trigger B but just in one direction(until I fall down), when I enter Trigger A, the bridge stops, and when I jump from the bridge into the river, it starts to sway :shock:

As you can see, this a not very difficult, and the problem isn't one for probably everybody but me. So please help me in my 1st scripting steps.
Ty!

Posted: Mon May 05, 2003 8:06 pm
by jv_map
rotateXup 2 means rotate this thing with 2 degrees per second.

I guess you didn't mean this, but 'rotate 2 degrees in total'. Use rotateXupto 2 instead.

Posted: Mon May 05, 2003 9:19 pm
by wacko
Thanks, jv! That helped a good piece!
I now have
main:
level waittill spawn
thread bridge_prep
end
bridge_sway_on:
$bridge_on nottriggerable
$bridge_off triggerable
thread bridge_swing
end
bridge_sway_off:
$bridge_off nottriggerable
thread bridge_stop
$bridge_on triggerable
end
bridge_swing:
$bridge rotateXupto 10
$bridge waitmove
$bridge rotateXdownto 350
$bridge waitmove
goto bridge_swing
end
bridge_stop:
$bridge rotateXdownto 0
end
bridge_prep:
$bridge_off nottriggerable
$bridge time 2
end


And atleast the bridge is swaying now. But it is just swaying when I enter Trigger B and then leave it again. If I stay in Trigger B, the bridge comes to standing still after one 'move'. And Trigger A seems to not work at all...

There is still the master question :oops: : When does a trigger_multiple call (activate?) a thread? In the moment when it's entered? The whole time the player is touching it? Again, when he's leaving? Is there some tut especially about triggers and their usage?

And: Trigger A is two brushes, so am I triggering it when I stand between them?

P.S.: You know, this is rather embarassing, asking so simple questions. So if you had a source, that you think is helpful, would you please tell me? I would prefer to not bother you with 'swaying bridges', but I have no idea where to get such information elsewhere.

Posted: Tue May 06, 2003 1:17 am
by lazyboy
:idea: yea... what he said....

Posted: Tue May 06, 2003 1:47 am
by _Snake_
lazyboy, what you did there is called spam. It's when you post something that doesn't need to be posted. Please keep the forums clean.

Posted: Tue May 06, 2003 2:12 am
by lazyboy
sorry. is this spam?

Posted: Tue May 06, 2003 2:17 am
by nihilo
yes, and this is turning into a spam thread.

I like the swinging bridge idea, but does it swing side to side, rotate, or just bounce up and down? As well, how do you stop the entire bridge from moving? It would look odd if board that is supposed to be attached to the bank moved.

Posted: Tue May 06, 2003 2:25 am
by lazyboy
from what i hear, it swings from side to side

Posted: Tue May 06, 2003 5:59 am
by wacko
I'm planning to let the bridge swing from side to side. Cutting it into pieces and letting swing the outer parts more than the inner parts might look not that bad. A scripted brush deformation would be better, but I don't think, that's possible.

Nevertheless, as long as nobody knows (or wants to tell) how I get working what I already have, I'll have to wait.

stop

Posted: Tue May 06, 2003 8:39 am
by tltrude
"$bridge stop" will stop it from moving. What you need is the command "istouching". If you use that, the action will only take place while a player is in contact with the trigger. You would have to set up somthing that will return the bridge to level when a player leaves or falls/jumps off. Here is a good sound for it:

$bridge loopsound wood_creak2

but, it will need an ubersound alias to work.

Posted: Tue May 06, 2003 10:20 am
by jv_map
A trigger_multiple activates whenever any player is touching any brush of the trigger entity. Then the trigger waits as defined with the wait key, and can fire again if someone is inside it. By default, the trigger wait time is 0.05 seconds which is mostly equal to the duration of a server frame. This means a setthread thread will be launched 20 times a second.

In your script, you wrote:
bridge_swing:
$bridge rotateXup 2
$bridge waitmove
$bridge rotateXdown 4
$bridge waitmove
$bridge rotateXup 2
$bridge waitmove
goto bridge_swing
end

Thus this piece of code will loop forever, sending new rotate commands regardless if a player is in the trigger. Also, every second a player is within the trigger 20 new processes like this are started :?

Posted: Tue May 06, 2003 12:41 pm
by wacko
tltrude, thanks! :D The stop command was s/th I was missing and the sound surely will be nice, but this is far future itm...

jv, thank you, too! This info about the trigger is what I needed! :D

But the trigger_B bridge_on launches not the thread bridge_swing but the thread

Code: Select all

bridge_sway_on: 
$bridge_on nottriggerable 
$bridge_off triggerable 
thread bridge_swing 
end 
and I thought the command nottriggerable stops the trigger to launch further threads until made triggerable again!? If I'm right with this, the thread

Code: Select all

bridge_sway_off: 
$bridge_off nottriggerable 
thread bridge_stop 
$bridge_on triggerable 
end 
must be launched by trigger_A bridge_off, and this by just standing between the two brushes?!

Posted: Tue May 06, 2003 1:17 pm
by jv_map
Oops you're right about that :oops:

But still the bridge_swing thread will never end :(

Posted: Tue May 06, 2003 1:28 pm
by wacko
so, I will have to make it completely different: one thread for one phase of movement, and activate this thread again and again as soon as it's finished and as long as I'm inside trigger_B.

Thanks, jv! This will keep me busy for some time :wink:

Posted: Tue May 06, 2003 1:33 pm
by jv_map
Well you could also have bridge_stop: set a variable that prevents bridge_swing: from looping.

Example:

Code: Select all

bridge_swing:
  $bridge rotateXupto 10
  $bridge waitmove
  $bridge rotateXdownto 350
  $bridge waitmove
  if(level.stopbridgeswing != 1)
    goto bridge_swing
  else
    level.stopbridgeswing = 0 // so we can do it again
end

bridge_stop:
  $bridge rotateXdownto 0
  level.stopbridgeswing = 1
end 
or (better):

Code: Select all

bridge_swing:
  while(level.stopbridgeswing != 1)
  {
    $bridge rotateXupto 10
    $bridge waitmove
    $bridge rotateXdownto 350
    $bridge waitmove
  }
  level.stopbridgeswing = 0
end

bridge_stop:
  $bridge rotateXdownto 0
  level.stopbridgeswing = 1
end 
Well that's just one of the many possible ways to go.