Jump to content

Need help making a quick script


ABVXYzackattack

Recommended Posts

I'm having some difficulties making a script capable of coordinating a vertibird's fire rotation to making a marker fire a projectile. Here's what my script looks like right now:

 

;------------------------------------------------------------------------------

scn ZTestVertibirdFireScript

 

float timer

 

Begin OnActivate

 

if timer < 13

 

ZTESTGunShip.playgroup fastleft 1

 

set timer to (timer + GetSecondsPassed)

 

else

 

ZMissileLauncher2.fireweapon WeapMissileLauncher

 

set timer to 0

 

endif

 

end

;--------------------------------------------------------------------------

 

I've timed the vertibird to 13 seconds when it gets at the perfect position to aim and fire the rockets from the second it begins its animation.

 

I know that it is on activate. I was using this script on an object first to test it before putting it in a trigger zone.

What do I need to fix?

Link to comment
Share on other sites

OnActivate blocks will only run once when it's activated (per activation). Something like what you're trying to do would be better suited to using a gamemode block to manage the timer, and then the OnActivate (or OnTriggerEnter?) to start the timer.

 

scn...  

short RunTimer  
float TimerVar  

Begin OnActivate  
GetSecondsPassed ;This may be redundant (Would just ensure it is run at least once to establish a 1st time before attempting to get sensible values out of it)  
set TimerVar to 0  
set RunTimer to 1  
;Do other once off stuff, like playgroup
end  

Begin GameMode  
if RunTimer<1  
 return  
endif   
set TimerVar to TimerVar + GetSecondsPassed  
if TimerVar>=13  
 ;Do Stuff..IE, Fire missile  
 set RunTimer to 0  
endif  
end

Something like that will start the timer when the OnActivate block is triggered, and then the gamemode block will manage the timer. Once the 13s has passed "set RunTimer to 0" will halt everything until the OnActivate block is triggered again.

Edited by Skevitj
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...