Jump to content
Sign in to follow this  
Doolittle

Ultimate vehicle respawn

Recommended Posts

Re: http://www.flashpoint1985.com/cgi-bin....t=20861

BF1942 is great, but OFP is supreme!  But BF1942 had some nice ideas.  Like vehicle respawning and where, if a vehicle was left unattended for too long it would respawn.  Of course, since OFP rules, we can add that into OFP too.  Here's a script I wrote.  For each vehicle you want to respawn or respawn when left by itself (great for times when people drive their jeeps over to enemy base and just leave them there) add [this] exec "respawn.sqs" to that vehicle's Initialization line!

respawn.sqs

;Ultimate Vehicle Respawn

;by Doolittle

;This script will respawn any vehicle if it has been dead for a while

;It will also respawn a vehicle if it has been abandoned somewhere for too long!

;Set the Initialization for whatever vehicles you want to respawn to

;[this] exec "respawn.sqs"

;That's it!

_obj = _this select 0

_pos = getPos _obj

_dir = getDir _obj

_magazines = magazines _obj

_j = count _magazines

#begin

? "m2staticmg" counttype [_obj] == 1 : goto "alive"

@count crew _obj != 0 || !alive _obj

? !alive _obj : goto "alive"

@count crew _obj == 0 || !alive _obj

? !alive _obj : goto "alive"

_oldtime = _time + 55

@_time > _oldtime || count crew _obj != 0 || !alive _obj

? !alive _obj : goto "alive"

? count crew _obj != 0 : goto "begin"

_obj setFuel 0

_obj setDammage 1

#alive

@!alive _obj

~40

_i = 0

#rearm

_mag = _magazines select _i

_obj removeMagazine _mag

_obj addMagazine _mag

_i = _i + 1

? _i < _j : goto "rearm"

_obj setPos _pos

_obj setDir _dir

_obj setDammage 0.3

~0.1

_obj setDammage 0.1

~0.1

_obj setDammage 0

_obj setFuel 1

goto "begin"

Thanks to DV Chris Death suggesting I use magazines instead of weapons, and to DeaDMeaT for his original rearming code.

Doolittle

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×