Jump to content
Sign in to follow this  
Gorgi Knootewoot

Respawning vehicles

Recommended Posts

xmas.gifxmas.gifxmas.gif

I found a nice script which makes vehicles respawn when destroyed, and left behind vehicles will return to their starting point. I like it, i like it a lot.

Problem; when A10 or Su25 respawns, they respawn with gear up. A10 can still take off, but Su25 explodes when respawned. So i want them to respawn with the gear down.

Can anybody help me with this confused.gif

Please help me, you are my only hope

Share this post


Link to post
Share on other sites

I've fixed that script, but you need OFP 1.91, the newest version.

vehicle.sqs

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">;Script by Doolittle, dbircsak@earthlink.net

_obj = _this select 0

? not local Server : exit

_pos = getPos _obj

_dir = getDir _obj

;_type = "UAZ"

_type = typeOf _obj

#clear

_t = 0

#alive

~3

? not alive _obj : _delay = 150; goto "notalive"

? fuel _obj == 1 : goto "clear"

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

? _t == 0 : _t = _time + 150

? _t > _time : goto "alive"

"_obj removeMagazine _x" forEach magazines _obj

_obj setFuel 0

_obj setDamage 1

_delay = 10

#notalive

~_delay

deleteVehicle _obj

~1

_obj = _type createVehicle _pos

_obj setDir _dir

goto "clear"

<span id='postcolor'>

For each vehicle you want to respawn put [this] exec "vehicle.sqs" as its init.  Make a Game Logic and call it Server so that only the server will run this code.

This will respawn dead vehicles in _delay = 150 seconds or if they are left alone/empty for 150 seconds straight then they will respawn.  I am using createVehicle now since 1.91 includes the awesome typeOf command.  This also fixes the landing gear issue.

Doolittle

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (Gorgi Knootewoot @ Dec. 18 2002,11:31)</td></tr><tr><td id="QUOTE">How do i make a game logic, and how do i call it server.

Maybe a dumb question, but i don't know how sad.gif<span id='postcolor'>

tounge.gif

In the editor go to place a Unit, select Game Logic from type, type in Server in the Name: field.

Share this post


Link to post
Share on other sites

I redid the above script so that it will work with the earlier versions of OFP.

To get this to work, put a Game Logic on your map, anywhere, and name it Server.  Then for each vehicle you want to respawn put this exec "vehicle.sqs" in its Initialization.  And finally, you need this file in your mission's directory:

vehicle.sqs

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">;by Doolittle

_obj = _this

?not local Server : exit

vdelay = 150

_air = ["Cobra", "Cessna", "A10LGB", "A10", "AH64", "Kamov", "Mi17", "Mi24", "OH58", "Su25", "UH60", "UH60MG"]

_armored = ["BMPRes", "BMP2", "BMP", "BoatE", "BRDM", "CarrierW", "M2StaticMGE", "M2StaticMG", "M113", "M1Abrams", "Bradley", "M60", "BoatW", "ZSU", "T55G", "T72Res", "T72", "T80Res", "T80", "Vulcan"]

_car = ["Truck5tOpen", "Truck5t", "Kolo", "Bus", "SkodaBlue", "SkodaGreen", "SkodaRed", "Skoda", "Mini", "HMMWV", "GJeep", "JeepPolice", "JeepMG", "Jeep", "Jawa", "TruckV3SCivil", "TruckV3SG", "Scud", "RapidY", "Rapid", "Trabant", "Tractor", "UAZG", "UAZ", "Ural"]

_support = ["Truck5tReammo", "BMPAmbul", "M113Ambul", "TruckV3SGReammo", "TruckV3SGRefuel", "TruckV3SGRepair", "Truck5tRefuel", "Truck5tRepair", "SGUAZG", "UralReammo", "UralRefuel", "UralRepair"]

_vehicle = _air + _support + _armored + _car

_pos = getPos _obj

_dir = getDir _obj

_i = 0

_c = count _vehicle

_type = 0

#count

?_vehicle select _i countType [_obj] != 0 : _type = _i; _i = count _vehicle

_i = _i + 1

?_i < _c : goto "count"

#init

_t = 0

#alive

~1

?not alive _obj : _delay = vdelay; goto "notalive"

?fuel _obj == 1 : goto "init"

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

?_t == 0 : _t = _time + vdelay

?_t > _time : goto "alive"

#notalive

~_delay

deleteVehicle _obj

~1

_obj = _vehicle select _type createVehicle _pos

_obj setDir _dir

goto "init"

<span id='postcolor'>

Note I needed to list all the vehicle types AND since, for example, A10LGB is a sub-class of A10, you need to list A10LGB first!!!

Note also that vehicles will respawn if they are left alone & empty somewhere!!  (This was the reason I even bothered trying to do vehicle respawn, because vehicle respawn had been done before, but not the "abandoned vehicle" part.)

Doolittle

Share this post


Link to post
Share on other sites

wow.gif Oops.

I should read whole thread more thoroughly.

Sorry. It was just little late night scripting inspiration.

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  

×