Anti Grav mod

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
Grassy
First Lieutenant
Posts: 221
Joined: Sun Aug 22, 2004 11:36 am

Anti Grav mod

Post 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...
Angex
Major
Posts: 293
Joined: Mon Dec 30, 2002 1:23 pm
Contact:

Post 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
Grassy
First Lieutenant
Posts: 221
Joined: Sun Aug 22, 2004 11:36 am

Post 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
Shuriken1
Corporal
Posts: 28
Joined: Thu Sep 02, 2004 3:05 pm
Contact:

Post 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. :)
Shuriken1
Grassy
First Lieutenant
Posts: 221
Joined: Sun Aug 22, 2004 11:36 am

Post 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. :)
Shuriken1
Corporal
Posts: 28
Joined: Thu Sep 02, 2004 3:05 pm
Contact:

Post 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.
Shuriken1
Grassy
First Lieutenant
Posts: 221
Joined: Sun Aug 22, 2004 11:36 am

Post 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?
Post Reply