Jump to content
Sign in to follow this  
curtcooll

Vehicle re-spawn & group respawn

Recommended Posts

Im making a game mode that ive got a helicopter that can take your group anywhere and u have to do sort of king of the hill now when u die i can get the group leader to re spawn but how do u get the ai to re spawn once all the group is dead, also i got vehicle to re spawn but the pilot and copilot are not included which means i cant call in helicopter if im stranded.

Script not made by me.

/*  
==================================================================================================================
 Simple Vehicle Respawn Script v1.8 for Arma 3
 by Tophe of Östgöta Ops [OOPS]

 Put this in the vehicles init line:
 veh = [this] execVM "vehicle.sqf"


 Options:
 There are some optional settings. The format for these are:
 veh = [object, Delay, Deserted timer, Respawns, Effect, Dynamic] execVM "vehicle.sqf"

 Default respawn delay is 30 seconds, to set a custom respawn delay time, put that in the init as well. 
 Like this:
 veh = [this, 15] execVM "vehicle.sqf"

 Default respawn time when vehicle is deserted, but not destroyed is 120 seconds. To set a custom timer for this 
 first set respawn delay, then the deserted vehicle timer. (0 = disabled) 
 Like this:  
 veh = [this, 15, 10] execVM "vehicle.sqf"

 By default the number of respawns is infinite. To set a limit first set preceding values then the number of respawns you want (0 = infinite).
 Like this:
 veh = [this, 15, 10, 5] execVM "vehicle.sqf"

 Set this value to TRUE to add a special explosion effect to the wreck when respawning.
 Default value is FALSE, which will simply have the wreck disappear.
 Like this:
 veh = [this, 15, 10, 5, TRUE] execVM "vehicle.sqf"

 By default the vehicle will respawn to the point where it first was when the mission started (static). 
 This can be changed to dynamic. Then the vehicle will respawn to the position where it was destroyed. 
 First set all preceding values then set TRUE for dynamic or FALSE for static.
 Like this:
 veh = [this, 15, 10, 5, TRUE, TRUE] execVM "vehicle.sqf"

 If you you want to set the INIT field of the respawned vehicle, first set all other values, then set init commands. 
 Those must be inside quotations.
 Like this:
 veh = [this, 15, 10, 5, TRUE, FALSE, "this setDammage 0.5"] execVM "vehicle.sqf"

 Default values of all settings are:
 veh = [this, 30, 120, 0, FALSE, FALSE] execVM "vehicle.sqf"


Contact & Bugreport: [email]cwadensten@gmail.com[/email]
================================================================================================================== */

if (!isServer) exitWith {};

// Define variables
_unit = _this select 0;
_delay = if (count _this > 1) then {_this select 1} else {30};
_deserted = if (count _this > 2) then {_this select 2} else {120};
_respawns = if (count _this > 3) then {_this select 3} else {0};
_explode = if (count _this > 4) then {_this select 4} else {false};
_dynamic = if (count _this > 5) then {_this select 5} else {false};
_unitinit = if (count _this > 6) then {_this select 6} else {};
_haveinit = if (count _this > 6) then {true} else {false};

_hasname = false;
_unitname = vehicleVarName _unit;
if (isNil _unitname) then {_hasname = false;} else {_hasname = true;};
_noend = true;
_run = true;
_rounds = 0;

if (_delay < 0) then {_delay = 0};
if (_deserted < 0) then {_deserted = 0};
if (_respawns <= 0) then {_respawns= 0; _noend = true;};
if (_respawns > 0) then {_noend = false};

_dir = getDir _unit;
_position = getPosASL _unit;
_type = typeOf _unit;
_dead = false;
_nodelay = false;


// Start monitoring the vehicle
while {_run} do 
{	
sleep (2 + random 10);
     if ((getDammage _unit > 0.8) and ({alive _x} count crew _unit == 0)) then {_dead = true};

// Check if the vehicle is deserted.
if (_deserted > 0) then
{
	if ((getPosASL _unit distance _position > 10) and ({alive _x} count crew _unit == 0) and (getDammage _unit < 0.8)) then 
	{
		_timeout = time + _deserted;
		sleep 0.1;
	 	waitUntil {_timeout < time or !alive _unit or {alive _x} count crew _unit > 0};
		if ({alive _x} count crew _unit > 0) then {_dead = false}; 
		if ({alive _x} count crew _unit == 0) then {_dead = true; _nodelay =true}; 
		if !(alive _unit) then {_dead = true; _nodelay = false}; 
	};
};

// Respawn vehicle
     if (_dead) then 
{	
	if (_nodelay) then {sleep 0.1; _nodelay = false;} else {sleep _delay;};
	if (_dynamic) then {_position = getPosASL _unit; _dir = getDir _unit;};
	if (_explode) then {_effect = "M_AT" createVehicle getPosASL _unit; _effect setPosASL getPosASL _unit; hint "dude";};
	sleep 0.1;

	deleteVehicle _unit;
	sleep 2;
	_unit = _type createVehicle _position;
	_unit setPosASL _position;
	_unit setDir _dir;

	if (_haveinit) then 
				{_unit setVehicleInit format ["%1;", _unitinit];
				processInitCommands;};
	if (_hasname) then 
				{_unit setVehicleInit format ["%1 = this; this setVehicleVarName ""%1""",_unitname];
				processInitCommands;};
	_dead = false;

	// Check respawn amount
	if !(_noend) then {_rounds = _rounds + 1};
	if ((_rounds == _respawns) and !(_noend)) then {_run = false;};
};
};

Edited by curtcooll

Share this post


Link to post
Share on other sites

Hi when you place a code in the forum use the advanced part of the post, and put the code into a code,

just highlight and press # and it will put the code into a scroll.

As for your script I have use that before many times, but that script will not respawn vehicles with Ai in them, its mainly for empty vehicles.

you want something like this:

AI vehicle respawn patrol area using UPS

http://www.armaholic.com/page.php?id=6543

now there is a new UPS for Arma3 get it here:

[ALPHA] Urban Patrol Script

http://www.armaholic.com/page.php?id=18802

take that script and just move into your mission folder in replace of the one that comes

with the vehicle respawn patrol area using UPS script.

Share this post


Link to post
Share on other sites

that ai vehicle respawn dont work it cant find the script no matter what i do i know how to follow the instructions etc but it cant find it lol.

---------- Post added at 09:13 ---------- Previous post was at 09:05 ----------

ok i got script to load but it dont re spawn vehicle i get a thing pop up say ai respawn but nothing happens.

Edited by curtcooll

Share this post


Link to post
Share on other sites

Off the top of my head if a vehicle dont respawn then you either forgot the marker for the vehicle to spawn at and a marker for the vehicle

to move to when it does spawn, or you are using an empty vehicle to respawn.

Explain what you did do in the editor to set it up so I have a better idea what the problem may be.

Share this post


Link to post
Share on other sites

ok i tried putting marker in and when u mean a marker to move to the heli i got to spawn is stationary so where you are on map you can call on heli

---------- Post added at 10:00 ---------- Previous post was at 09:50 ----------

oh it respawns but i could not tell coz it does not retain the sync of modules how would i make it so it keeps that coz i want it for gamemode ive done king hill and when u die u re spawn with your ai units and if heli gets shot down it re spawns so u can recall it? and also the script respawns all the ai i want it to spawn just the heli and also spawn ai units once all the group is dead could i mabye add some script to player respawn or summit.

Edited by curtcooll

Share this post


Link to post
Share on other sites

Your first post and your previous post here is somewhat confusing, are you not from the USA?, or are you forgetting

what you learned in elementry school about proper English punctuation and spelling?

This is a forum and if no one can understand what your trying to say then you will not get help.

So lets start over, heres what im getting from you from your first post, tell me if Im correct.

1. you want to be able to call a helicopter on demand to come and pick upi up and take you where you want to go, and then drop you off, and fly away,

and if its shot down to respawn, correct?

2. For the AI infantry if they are all killed then you want them to be able to respawn but be able to command them correct?

Share this post


Link to post
Share on other sites

that's bang on buddie yes i want heli to re spawn but still be able to call for extraction so it re sync with module apon re spawn, for the infantry i want them to re spawn but only once group is dead so i re spawn as the group leader and able to command them. i started scritpting a few days ago and have done some good scripts but im not that great so cant do it myself i know i dont really make sense from what i say half time but u seem to have understood what im asking :)

also i code the script sorry about that.

Edited by curtcooll

Share this post


Link to post
Share on other sites

Ok good.

Heres what i have, two scripts:

1. A script where you can call air support, script gives you many options to also call air strikes but those may not work because

the script uses classnames from Arma2CO, so i will show you how to set it up where you get the helicopter for transport option only.

2. i have a better Idea for Ai to respawn, what you can do is recruit Ai and they will automatically go under your command.

heres the two scripts:

Air Support

Ai recruitment

Now just download the two scripts and lets start with getting one script working and then go to the next after we do, lets start with the Air support.

let me know when you have downloaded it and are ready, i will explain to you on how to set it up in the editor, i have used both scripts many times,

but they are for Arma2Co so theres a possibility they may not work but i think they will.

Share this post


Link to post
Share on other sites

ok downloaded air support script. wait there is there a way to make heli indestructible that way itl make it easier? i tried taht script could not seem to get any sort of support when u go via communication menu.

Edited by curtcooll

Share this post


Link to post
Share on other sites

curtcooll, let me lay it out for you for this script step by step that way you can get it running,

its not tricky but there's a few things you need to setup:

Files

1. you should have the following files in the same folder as your mission:

a folder titled airSup

a script titled init

a file titled stringtable

In the editor

2. on the map place an H marker H stands for helicopter and name it Aspad

place the marker on the airfield

3. player, name your player m1

Init.sqf script

4. open this script with notepad and add(copy n paste) this code:

ASfirstrun = true;
if(player == m1)then{nul = [m1,"trans"] execVM "airSup\airSupInit.sqf"};
if(true)exitWith{};

note: you see m1 in the code?

you can change that to what you want, but make sure your player unit's name is the same.

===============

Thats basically it.

What happens when you call the chopper ingame?

When ingame you should see in your action menu an option to call transport, once you call transport it will ask you

to open your map and then click on your map where you want the LZ (landing Zone) which is where the helicopter will land to pick you up.

then it will ask you again after that is placed where you want the 2nd LZ which is where you will be dropped off, once that is done

then exit the map and wait for the chopper.

once the chopper arrives, it will land at the LZ you indicated, he will not take off til you give him the ok, in your action menu it will

say ok pilot good to go!, click on that and the chopper will go to the next LZ, just make sure your on the chopper when he takes off, or he'll leave without you.

Once he lands at the 2nd LZ he wont leave til you get off the chopper, once you get off, he will then fly back where he came from and delete.

If the chopper gets destroyed or shot down then a new one will respawn when you call for transport again.

You cannot call a chopper again if the chopper is flying back, you have to wait til you get the message chopper RTB'd' (returned to base).

You can also see where the chopper is at on the map, its a square with an x in it.

If the files are correct, and you did everything right then it should work, the only concern i have is that this is untested in Arma3,

and im not sure if it will work as for Arma2CO the chopper that spawns is a blackhawk, i don't own Arma3 Alpha yet, prob not til summer,

or earlier so i cannot test and see but lets test and see if it works.

I'll be back later, hope to read some good news.

Share this post


Link to post
Share on other sites

ok cool what ill do for now is leave it but will try it at some point as i want it to be as real as it can be i played my map king of the base and shot me mates pilot and they all died which was awsome but heli didnt come back, i have however for now set it so the heli cannot be destroyed just temporary ill try what you said later tonight as far as the ai spawning go i solved that by setting the ai to playable which means they respawn once they die at base which means im still in control however i want them once they respawn to be loaded in the chopper i have intill i get the script working you mentioned, is there a way i can reint this apon respawn.

this moveincargo heli;

.

Share this post


Link to post
Share on other sites
shot me mates pilot and they all died which was awsome but heli didnt come back

So the script did work then correct?

If you kill the pilots then the helicopter wont come back as the whole helicopter has to be destroyed.

What chopper gets used when it does come?

is there a way i can reint this apon respawn.

through script, and i have no idea.

The AI recruitment script I will list the steps on how to set that up, but I have no time atm, so ill be back later.

Share this post


Link to post
Share on other sites

yes lol im stupid what i done is create a trigger for each unit and if that unit is alive each time the unit dies and respawns it will end up in heli all i do is set the activation of trigger to move ai into heli, this resolves the ai spawning at base when im alive and running all the way to where i am as the ai will just sit in heli till either i get in and out of heli they will follow, so all thats left is to get the heli to be able to get damaged and then re-spawn with the ai OMFG thats it light bulb just sparked all i need do is create a empty chopper with a pilot do the same trigger with the pilot respawn and move in and assign as driver and link module to the driver that way i should be able to call for heli i will try this fingers crossed without script, one more thing if this does work is how would i lock the playble units as the game can be played with either 2 people or 8 people 4 each team so if i wanna play like 1v1 with ai how would i lock those playable units? sorry for the shitty punctuation never did to good with grammer and such.

Share this post


Link to post
Share on other sites
curtcooll, let me lay it out for you for this script step by step that way you can get it running,

its not tricky but there's a few things you need to setup:

Files

1. you should have the following files in the same folder as your mission:

a folder titled airSup

a script titled init

a file titled stringtable

In the editor

2. on the map place an H marker H stands for helicopter and name it Aspad

place the marker on the airfield

3. player, name your player m1

Init.sqf script

4. open this script with notepad and add(copy n paste) this code:

ASfirstrun = true;
if(player == m1)then{nul = [m1,"trans"] execVM "airSup\airSupInit.sqf"};
if(true)exitWith{};

note: you see m1 in the code?

you can change that to what you want, but make sure your player unit's name is the same.

===============

Thats basically it.

What happens when you call the chopper ingame?

When ingame you should see in your action menu an option to call transport, once you call transport it will ask you

to open your map and then click on your map where you want the LZ (landing Zone) which is where the helicopter will land to pick you up.

then it will ask you again after that is placed where you want the 2nd LZ which is where you will be dropped off, once that is done

then exit the map and wait for the chopper.

once the chopper arrives, it will land at the LZ you indicated, he will not take off til you give him the ok, in your action menu it will

say ok pilot good to go!, click on that and the chopper will go to the next LZ, just make sure your on the chopper when he takes off, or he'll leave without you.

Once he lands at the 2nd LZ he wont leave til you get off the chopper, once you get off, he will then fly back where he came from and delete.

If the chopper gets destroyed or shot down then a new one will respawn when you call for transport again.

You cannot call a chopper again if the chopper is flying back, you have to wait til you get the message chopper RTB'd' (returned to base).

You can also see where the chopper is at on the map, its a square with an x in it.

If the files are correct, and you did everything right then it should work, the only concern i have is that this is untested in Arma3,

and im not sure if it will work as for Arma2CO the chopper that spawns is a blackhawk, i don't own Arma3 Alpha yet, prob not til summer,

or earlier so i cannot test and see but lets test and see if it works.

I'll be back later, hope to read some good news.

Can this work for multiplayer?

I have not downloaded this yet. Just now reading it and was wondering if this is only of SP or not.

I would imagine somewhere in the script, I can change the helicopter from a Blackhawk to MH9 or what ever the classname for the the chopper in A3.

My idea in using this would be to have a air support/transport feature available to all the squad leaders instead of every single player who connected.

Share this post


Link to post
Share on other sites

just got back from gym ill have a look i should be able to get it to work ive ported some scripts not yet working over to arma 3 by changing certain bits code it would be better overall to have heli not on map but being able to use the above script would be nuts also can include the mortar strikes as well.

Share this post


Link to post
Share on other sites
Can this work for multiplayer?

Works both in sp and mp.

I would imagine somewhere in the script, I can change the helicopter from a Blackhawk to MH9 or what ever the classname for the the chopper in A3.

i would like to think so but I have never done it, as the script was built for Arma2CO when it released.

My idea in using this would be to have a air support/transport feature available to all the squad leaders instead of every single player who connected.

That can work all you need to do copy the line in the init script and is give each squad leader a name.

it would be better overall to have heli not on map but being able to use the above script would be nuts

Heli wont be on the map til you respawn it, then once respawned, and it picks whomever up,a dn drops whomever off, it will respawn and then delete til called again.

Let me know when you want to try the Ai recruitment.

Share this post


Link to post
Share on other sites

Let me know when you want to try the Ai recruitment.

i dont need ai recruitment i made ai respawn makes it easier. ive still yet to try script having issue with getting steam to work atm lol.

---------- Post added at 23:33 ---------- Previous post was at 23:26 ----------

awsome got game working i wanted to ask before i move onto the script for the respawn at the moment ive got everything as i want only issue is when the pilot respawns the coordinates i gave him in which we died before we got there the heli re-spawnd with all the ai plus myself but the heli started taking of in which case rembered the coords i gave him but i dont want that i want to give him fresh coords is there anyway i can make it so upod death of the pilot it reset the support module using a trigger.

Share this post


Link to post
Share on other sites

No, you can only call the chopper once he returns to base, i already explained how the chopper works.

Share this post


Link to post
Share on other sites

im not using the script u said about because when you start at your base u need helicopter there using the script allows u to call helicopter which gets spawned in what ive done is i got the pilot to respawn using ai_respawn script and then a vehicle respawn script but using the ai respawn script it seems to desync from the support module which means i cannot recall the heli support once the heli gets destroyed is there a way i can resync the trigger/module to the pilot to recall heli.

at start of mission the ai spawns inside the heli and i can use the support feature but once the pilot dies and respawns with using ai respawn it does not use the trigger and module is there a way i can resync the module and trigger by changing summit in this script.

// AI_respawn.sqf
// © JULY 2009 - norrin

if (!isServer) exitWith {};

_unit 			= _this select 0;
_lives			= _this select 1;
_delay 			= _this select 2;
_respawn_point	= _this select 3;
_move_script	= _this select 4;
_group			= _this select 5;
_side 			= _this select 6;
_AI_unitArray	= _this select 7;
_AI_magArray	= _this select 8;
_AI_wepArray	= _this select 9; 

_unitsGroup = units (group _unit);

while {(count _unitsGroup) > 0} do
{	
_remainingUnits = [];
{if (alive _x) then {_remainingUnits = _remainingUnits + [_x]}} forEach _unitsGroup;
_unitsGroup = _remainingUnits;
sleep 1;
};
deleteGroup _group;
if (_lives == 0) exitWith {};
_lives = _lives - 1;
_wait = Time + _delay;
waitUntil {Time > _wait};
_group = createGroup _side; 

{_x createUnit [(getMarkerPos _respawn_point), _group];} forEach _AI_unitArray;
sleep 2;
hint "AI respawn";
_unitsGroup = units _group;
{_x disableAI "MOVE"} forEach _unitsGroup;

for [{ _loop = 0 },{ _loop < count  _unitsGroup},{ _loop = _loop + 1}] do
{
_guy = _unitsGroup select _loop;
removeAllWeapons _guy;
if (_loop == 0) then {_guy moveInDriver _vcl_new};
{_guy removeMagazine _x} forEach magazines _guy;
removeAllItems _guy;
{_guy addMagazine _x} forEach (_AI_magArray select _loop);
{_guy addWeapon _x}   forEach (_AI_wepArray select _loop);
_guy selectWeapon (primaryWeapon _guy);
_guy setSkill (_AI_skillArray select _loop);
sleep 0.1;
};
{_x enableAI "MOVE"} forEach _unitsGroup;
_leader = leader _group;
[_leader, _lives, _delay, _respawn_point, _move_script, _group, _side, _AI_unitArray,_AI_magArray, _AI_wepArray] execVM "AI_respawn\AI_respawn.sqf"; 	
[_leader] execVM _move_script;

if (true) exitWith {};

Edited by curtcooll

Share this post


Link to post
Share on other sites

Have no idea, you really need to slow down and be more specific in how you explain something,

you jog around into different points without stopping your sentence.

All I'm getting is that you have a heli that once it gets destroyed you want to be able to call it?

So basically the idea is to have a heli at the base start there, and then when it gets destroyed be able to call it right?

Whats wrong with the script, i walked you through on how to set up?

You wont use the scripts i suggested and walked you through using and you change you mind or cant explain simply and clearly

what your doing.

At this point i feel im wasting my time. I'm done i need to go to bed i just got done with a 3rd shift.

Share this post


Link to post
Share on other sites

ok i used it works now as i changed the class names only issue is there not only pilot in heli but a guy in cargo also the heli when it spawns and picks u up to drop if it flys to drop off but does not stop it just then heads back to LZ i get out and it disappears.

Edited by curtcooll

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  

×