Jump to content
Sign in to follow this  
Worleman313

Vehicle Respawn

Recommended Posts

Hey All biggrin_o.gif ,

Im a newbie at Arma Map editing and is needing a little help on setting up the VR. If anyone can Help, i would realy apreaciate. Oh And if theres anything else that would help me out let me know TY smile_o.gif

Share this post


Link to post
Share on other sites

In future please use the 'Search' function as this has been brought up a few times...

but heres the script i use:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">// *****************************************************

//** Operation Flashpoint Script File

//*****************************************************

//BEGIN vrs_AI.sqf

//Original script by KaRRiLLioN modified by norrin for AI units 7th Feb 2007

//IMPORTANT: ADD A GAMELOGIC NAMED Server

//to the mission to prevent multispawn

private ["_vcl","_respawndelay","_vclemptydelay","_dir","_pos","_type","_unit","_run","_wait","_delay"];

if (!local Server) exitWith {};

_vcl = _this;

//specify the respawn wait times for empty vehicles and destroyed vehicles in the following 2 lines

_vclemptydelay = 120;

_respawndelay = 120;

_dir = Getdir _vcl;

_pos = Getpos _vcl;

_type = typeOf _vcl;

_unit = driver _vcl;

_run = TRUE;

sleep 5;

for [{}, {_run}, {_run}] do

{

while {_vcl distance _pos < 5 && canMove _vcl} do

 {

sleep 1;

 };

while {canMove _vcl && count crew _vcl > 0 && ({damage _x}forEach crew _vcl)!= 1} do  

 {

_wait = Time + _vclemptydelay;

sleep 1;

 };

while {canMove _vcl && count crew _vcl < 1 && Time < _wait} do

 {

sleep 1;

 };

while {canMove _vcl && {damage _x} forEach crew _vcl >= 1 && Time < _wait} do

 {

sleep 1;

 };

_delay = Time + _respawndelay;

while {!canMove _vcl && Time < _delay} do

 {

sleep 1;

 };

if (count crew _vcl < 1) then

 {

 deleteVehicle _vcl;

       _vcl = _type createVehicle _pos;

 _vcl setdir _dir;

       sleep 1;

       _vcl setvelocity [0,0,0];

       _vcl setpos _pos;

       sleep 1;

       _vcl setvelocity [0,0,0];

 sleep 2;

  };

if ({damage _x} forEach crew _vcl >= 1)then

 {

 deleteVehicle _vcl;

       _vcl = _type createVehicle _pos;

 _vcl setdir _dir;

       sleep 1;

       _vcl setvelocity [0,0,0];

       _vcl setpos _pos;

      sleep 1;

       _vcl setvelocity [0,0,0];

 sleep 1;

  };

sleep 2;

};

And in the init line of each empty vehicle put:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this exec "vrs.sqf"

Hope it helps

EDIT: im not sure how new u are to editing so incase u dont know what to do, copy that script file into a notepad document and save the file as: vrs.sqf (dont save it as a text file, save it as an .sqf file) smile_o.gif

Share this post


Link to post
Share on other sites

Thx biggrin_o.gif , and would you have any idea why it wont let me creat my own Weapon Crate?? Keeps coming up (No Entry "Bin\config.bin/cfgWeapons.kozlice'.

Share this post


Link to post
Share on other sites
In future please use the 'Search' function as this has been brought up a few times...

but heres the script i use:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">// *****************************************************

//** Operation Flashpoint Script File

//*****************************************************

//BEGIN vrs_AI.sqf

//Original script by KaRRiLLioN modified by norrin for AI units 7th Feb 2007

//IMPORTANT: ADD A GAMELOGIC NAMED Server

//to the mission to prevent multispawn

private ["_vcl","_respawndelay","_vclemptydelay","_dir","_pos","_type","_unit","_run","_wait","_delay"];

if (!local Server) exitWith {};

_vcl = _this;

//specify the respawn wait times for empty vehicles and destroyed vehicles in the following 2 lines

_vclemptydelay = 120;

_respawndelay = 120;

_dir = Getdir _vcl;

_pos = Getpos _vcl;

_type = typeOf _vcl;

_unit = driver _vcl;

_run = TRUE;

sleep 5;

for [{}, {_run}, {_run}] do

{

while {_vcl distance _pos < 5 && canMove _vcl} do

 {

sleep 1;

 };

while {canMove _vcl && count crew _vcl > 0 && ({damage _x}forEach crew _vcl)!= 1} do  

 {

_wait = Time + _vclemptydelay;

sleep 1;

 };

while {canMove _vcl && count crew _vcl < 1 && Time < _wait} do

 {

sleep 1;

 };

while {canMove _vcl && {damage _x} forEach crew _vcl >= 1 && Time < _wait} do

 {

sleep 1;

 };

_delay = Time + _respawndelay;

while {!canMove _vcl && Time < _delay} do

 {

sleep 1;

 };

if (count crew _vcl < 1) then

 {

 deleteVehicle _vcl;

       _vcl = _type createVehicle _pos;

 _vcl setdir _dir;

       sleep 1;

       _vcl setvelocity [0,0,0];

       _vcl setpos _pos;

       sleep 1;

       _vcl setvelocity [0,0,0];

 sleep 2;

  };

if ({damage _x} forEach crew _vcl >= 1)then

 {

 deleteVehicle _vcl;

       _vcl = _type createVehicle _pos;

 _vcl setdir _dir;

       sleep 1;

       _vcl setvelocity [0,0,0];

       _vcl setpos _pos;

      sleep 1;

       _vcl setvelocity [0,0,0];

 sleep 1;

  };

sleep 2;

};

And in the init line of each empty vehicle put:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this exec "vrs.sqf"

Hope it helps

EDIT: im not sure how new u are to editing so incase u dont know what to do, copy that script file into a notepad document and save the file as: vrs.sqf (dont save it as a text file, save it as an .sqf file) smile_o.gif

There seems to be a problem with this script, I get an error whenever I try it. It's saved just how you instructed.

Share this post


Link to post
Share on other sites

My apologies, put this in the init field of all respawning vehicles:

s = this execVM "vrs.sqf"

smile_o.gif

if it still fails make sure you have a game logic named 'Server' not sure if its necessary or not tho...

Share this post


Link to post
Share on other sites
Got it working, thanks!

Well I could not find a suetable script for this on the BIS forum either .....So many thanks for this post, very helpfull indeed biggrin_o.gif

Share this post


Link to post
Share on other sites
thats all
Quote[/b] ]car respawnVehicle [5.0, 3]

http://community.bistudio.com/wiki/respawnVehicle

that doesnt seem to work.

Not all examples in the wiki works, nor are they explained what exactly the scripts/triggers are up to.

like the wiki explanation for the "seized by"-triggers :/

And "commandMove"...

hey btw what folder do I put this vrs.sqf file in?

<documents and settings>\ArmA Other Profiles\<your profile>\missions\SectorTest.Intro

Share this post


Link to post
Share on other sites
_unit RespawnVehicle [_delay, _count];

This does work... I just updated the biki...vehicleRespawn

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">respawn_vehicle_querilla

Is this line right or is it a Typo ??

Share this post


Link to post
Share on other sites

hmm, it might?

Shouldn't it be _resistance?

Share this post


Link to post
Share on other sites

nope... resistance in ArmA is Guerilla... Respawn_Vehicle_Guerilla is correct.

Share this post


Link to post
Share on other sites

I am using this script, and i got it to work, but it only works if there if a AI starts out in it. then you gotta kill the AIs inside the vehicles to use them. then i got a bunch of AIs running around and its very annoying. I tried everything, turned of AI, start the map, vehicles wont respawn. idk what to do. any help would be great.

Share this post


Link to post
Share on other sites

Use this, you'll love me for it.

vehirespawn.sqs

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">; Call in initline with (120 for 120 seconds, 2 minutes) :

;

;   [this, 120] exec "vehirespawn.sqs"

;

; Note - This script needs a "GameLogic" trigger named "SERVER" or else spawning will be nuts

;

?! (local server): exit

~3

_vehicle = _this select 0

_delay = _this select 1

_empty = true

_disabled = false

_moved = false

_startpos = getpos _vehicle

_startdir = getdir _vehicle

_type = typeof _vehicle

#waiting

~2

_newpos = getpos _vehicle

?! (_newpos select 0 in _startpos) or not (_newpos select 1 in _startpos): _moved = true

?! (isnull driver _vehicle) or not (isnull gunner _vehicle) or not (isnull commander _vehicle): _empty = false

? (isnull driver _vehicle) and (isnull gunner _vehicle) and (isnull commander _vehicle): _empty = true

?! (canmove _vehicle) or (canfire _vehicle): _disabled = true

? (canmove _vehicle) and (canfire _vehicle): _disabled = false

? (_disabled) and (_empty): goto "spawn"

? (_moved) and (_empty): goto "spawn"

goto "waiting"

#spawn

~_delay

?! (isnull driver _vehicle) or not (isnull gunner _vehicle) or not(isnull commander _vehicle): _empty = false

?! (_empty): goto "waiting"

deletevehicle _vehicle

~0.5

_newveh = _type createvehicle _startpos

_newveh setpos _startpos

_newveh setdir _startdir

[_newveh, _delay] exec "vehirespawn.sqs"

exit

Share this post


Link to post
Share on other sites

Do i add this init with Karrillions script? or do i just use this one?

*edit* ok well, i took out karrillions Script, and put yours in, and it doesn't work.

Share this post


Link to post
Share on other sites
_unit RespawnVehicle [_delay, _count];

-Where exactly do I need to put this line (and why isn't that mentioned in the Biki)?

-Do I need to add that line for each vehicle I want to respawn? Say I have a vehicled named: Truck5tOpen. What should the line read?

_Truck5tOpen RespawnVehicle [_delay, _count];

What if I have more than one of those trucks still need to make one for each, sorry but this all all very unclear to me, so if anyone can help it would be much appreciated.

EDIT: Ok Synide explained it to me, you just have to put this (example):

Quote[/b] ]this respawnVehicle [300, 4];

in the initialization field of each vehicle in the editor itself AND, you had a marker on the map at your base called 'respawn_vehicle_west' AND have

Quote[/b] ]respawn=BASE;
in the description.ext

Share this post


Link to post
Share on other sites

Just thought of something. Wouldn't it be nice if there was a for instance a present_vehicle_west marker. What this marker would do is check what vehicles are present inside this marker at mission start and during the mission. If a vehicle leaves the marker it will respawn after the delay set with respawnVehicleDelay. So if someone respawns there will always be a vehicle at respawn.

The problem I'm having now is that people are not always having a vehicle when they respawn because the vehicle isn't destroyed, but abandoned or damaged and I would like to keep those vehicles in the field.

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  

×