Jump to content
Sign in to follow this  
Doolittle

Basic vehicle respawn

Recommended Posts

Hi guys!  I really liked DeaDMeaT's respawn code.  I was looking for something simpler though and couldn't find it.  So I wrote one.  Here's the code, and there's no need to name the vehicles, make and name a respawn pad, or make a trigger!  This is as easy as it gets!  Just set the Init of the vehicle you want to respawn as [this] exec "respawn.sqs".

respawn.sqs

;Basic Vehicle Respawn

;By Doolittle

;Thanks to DeaDMeaT

;Set a vehicle's Initialization to

;[this] exec "respawn.sqs"

;That's it!

_delay = 50

_vehicle = _this select 0

_dir = getDir _vehicle

_pos = getPos _vehicle

_weapons = weapons _vehicle

_count = count _weapons

#alive

@!alive _vehicle

~_delay

_i = 0

#rearm

_weaponname = _weapons select _i

_vehicle removeMagazine _weaponname

_vehicle addMagazine _weaponname

_i = _i + 1

? _i < _count : goto "rearm"

_vehicle setDir _dir

_vehicle setPos _pos

_vehicle setDammage 0.5

~0.1

_vehicle setDammage 0

_vehicle setFuel 1

goto "alive"

Share this post


Link to post
Share on other sites

doolittle,

have you already tested it?

I remember, telling you that adding the weapon names

as magazines could cause problems, because weapon name

and magazine name is a different thing.

_vehicle addmagazine "G36A"

wouldn't add a magazine to the unit, because the correct

magazine name is: "G36Amag"

:edit - OK, i've just taken a look at the comref, and i think

your script should work with official vehicles, because vehicle's

weapon and ammo names are equal

Problem could occur, if somebody's using your script with

unofficial vehicles, where those two names (in some cases)

aren't equal.

~S~ CD

Share this post


Link to post
Share on other sites

It doesn't work.  I made a vehicle and did not name it, put [this] exec respawn.sqs in the init field, made a file called respawn.sqs and put your code into it, and when I start the level it says on the top left of the screen

'_weapons = weapons |#|_vehicle':  error unknown operator _vehicle

EDIT: Oh, it does work. But how do I keep it from putting that annoying text up there?

Share this post


Link to post
Share on other sites

You have it as >> [this] exec "respawn.sqs" << right?  Try and retype that _weapons = weapons _vehicle line by hand.  Maybe some character is in there that came over from the cut & paste that we can't see.  Actually I haven't a clue!  Make sure _vehicle = _this select 0 is actually working.  Try

~5

hint format ["%1", _this]

at the very top and make sure the vehicle object is being passed in. No actually that wouldn't work. You'd be hit will a whole bunch of stuff when the level loaded.

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  

×