Page 1 of 1

Anti Grav mod

Posted: Fri Sep 03, 2004 3:03 pm
by Grassy
G'day all,
I have made an all round mod for Brest that allows you to play FFA, TDM, Roundbased and TOW. I think it works pretty well except in FFA mode. I have a hidden trigger to give players a bit of fun for 30 seconds but am having trouble tagging the local.player on a trigger_multiple, here is my routine.

Code: Select all

gravity:
$gravity_hotspot waittill trigger
local.player = parm.other
waitframe

if(local.player isTouching $gravity_hotspot  && isAlive local.player) 
{ 
  local.player iprint "You will have reduced gravity for 30 seconds"
  local.player stopwatch 30
  local.player loopsound bombtick1
   
  local.player gravity 0.2
  for ( local.i = 0 ; local.i < 30 ; local.i++ )
    {
      wait 1
    }

  local.player gravity 1
  local.player stoploopsound bombtick1
  local.player iprint "Anti grav will be available again in 1 minute." ; wait 60
  thread gravity
}
end
Any hints on what I am missing please ? I just can't spot it :-(
Gassy
Edit: I should have said, it works fine in all game modes, but not Free For all...

Posted: Sat Sep 04, 2004 9:31 am
by Angex
I'm not sure why it works in some game modes and not others, but you should probably change the for loop used to make the script wait to: wait 30 (Unless you're planning to expand the script to do something else within the loop).

Code: Select all

gravity: 
$gravity_hotspot waittill trigger 
local.player = parm.other 
waitframe 

if(local.player isTouching $gravity_hotspot  && isAlive local.player) 
{ 
  local.player iprint "You will have reduced gravity for 30 seconds" 
  local.player stopwatch 30 
  local.player loopsound bombtick1 
    
  local.player gravity 0.2 

  wait 30

  local.player gravity 1 
  local.player stoploopsound bombtick1 
  local.player iprint "Anti grav will be available again in 1 minute." ; wait 60 
  thread gravity 
} 
end

Posted: Sat Sep 04, 2004 2:08 pm
by Grassy
Thanks Angex, I have revised it a little. Your solution is simpler but I found that if the player who had the stopwatch active died, no one else could use it for 60 seconds. I still have to find what the player.dmteam designation is for Free For All yet... Here is the new version with a check on the players condition.

Code: Select all

gravity:
$gravity_hotspot waittill trigger
local.player = parm.other
waitframe

if(local.player isTouching $gravity_hotspot && local.player.dmteam != "spectator" && isAlive local.player) 
{ 
  local.player iprint "You will have reduced gravity for 30 seconds"
  local.player stopwatch 30
   
  local.player gravity 0.2
  for ( local.i = 0 ; local.i < 30 ; local.i++ )
    {
      wait 1
      if !( isalive local.player )
      {
        	waitframe
        	thread gravity
      }        
    }

  local.player gravity 1
  local.player iprint "Anti grav will be available again in 1 minute."
  wait 60
  thread gravity
}
end

Posted: Sat Sep 04, 2004 2:54 pm
by Shuriken1
Where you have:

waitframe
thread gravity

You may want to change that to:

waitframe
goto gravity

That will goto that thread immediately, cease current operation and run the new thread on its own. Thread starts a thread but will not stop the current thread, if you only want to restart the thread, that may be your problem. :)

Posted: Sat Sep 04, 2004 3:23 pm
by Grassy
Hey thanks Shuriken1, you are right. I keep thinking that a call to a thread is the same as a goto. I try to avoid goto's but in this case I want to keep the thread running but needed a way out of the loop.
Thanks again for the tip. :)

Posted: Sat Sep 04, 2004 4:51 pm
by Shuriken1
If you want to get out of the loop just do:

local.i = 31

Then, when the loop starts its next iteration, it will not meet the < 30 criteria and move to the next bit of the thread.

Posted: Sun Sep 05, 2004 12:39 am
by Grassy
Yeah.... but wouldn't it then try to print a message to a dead player? :-) And not free up the switch for another player for 60 seconds?