Jump to content
Sign in to follow this  
mikey74

respawn script using BIS spawn functions.

Recommended Posts

Hi I spent probably longer working on this than should have been. idk why. I guess I wanted to find out if its possible using the spawn function BIS provided for us. SO I took a look at a few scripts. NORRIN's MURK's and a few I did a while LONG while back. I think Cobra II and ArmaholicII helped me on. If you see something that looks familiar please post a reply so you can get recognized if you'd like. :) I'm not a script smith, but I do dabble. It was a lot of work on my end figuring this out for something so small. lol . THOUGH I haven't found it Im sure someone already has did this. lol OR you can point out why we normally don't do this. :) Use as you will if ya want. Ive been using it with I44 and HAC. BTW it does work with Big boss. OHH one more thing, I did this to work with HAC. SOOO they will just respawn and sync to the LEADERHQ you provide in units init. Other wise they never move. I haven't tested it with forward observer on I44 yet so that may not work.

Put this is units init.

nul = [this, 5, 1, "ws3",LeaderHQA,ARTY] execVM "Init_respawn.sqf"; 

Init_respawn.sqf

if (!isServer) exitWith {};

_unit 			= _this select 0;
_rspawns		= _this select 1;
_delay		= _this select 2;
_spawn		= _this select 3;
_HQ			= _this select 4;
_FO			= _this select 5;

[_unit, _rspawns, _delay, _spawn, _HQ, _FO] execVM "AI_respawn.sqf";

if (true)exitWith {};

AI_respawn.sqf

if (!isServer) exitWith {};
_countThis 		= count _this;
_unit 			= _this select 0;
_type 			= typeOf _unit;
_rspawns		= _this select 1;
_delay			= _this select 2;
_spawn			= _this select 3;
_HQ			= if (_countThis >= 5) then { _this select 4; } else { "" }; // Optional;
_FO			= if (_countThis >= 6) then { _this select 5; } else { "" }; // Optional;
_dir			= getdir _unit;
_group			= group _unit;
_unitsGroup		= units group _unit;
_side 			= side _unit;
_pos 			= getMarkerPos _spawn;
sleep 5;

if (_type isKindOf "Man") then
	{
while{ ({(alive _x) && (canStand _x)} count _unitsGroup) > 0 } do { 
sleep 2; };
_wait = Time + _delay;
waitUntil {Time > _wait};
if (_rspawns == 0) exitWith {};
_rspawns = _rspawns - 1;
_AI_unitArray  = [];
{_AI_unitArray = _AI_unitArray + [typeOf _x];}forEach _unitsGroup;
_group = [_pos, _side, _AI_unitArray ,[],[],[],[],[],_dir] call BIS_fnc_spawnGroup;
_leader = leader _group;
_HQ synchronizeObjectsAdd [_leader];
_Leader synchronizeObjectsAdd [_Fo];
[_leader, _rspawns, _delay, _spawn, _HQ] execVM "Init_respawn.sqf";

} 

else 		{ 
while{ ({(alive _x) && (canMove _x)} count _unitsGroup) > 0 } do { 
sleep 2; };
_wait = Time + _delay;
waitUntil {Time > _wait};
if (_rspawns == 0) exitWith {};
_rspawns = _rspawns - 1;

deleteGroup _group;
if (_type isKindOf "Air") then 
       { _pos 		= [(getmarkerpos _spawn select 0), (getmarkerpos _spawn select 1), 100];};
if (_type isKindOf "Land") then
       {_pos 		= getMarkerPos _spawn;};
_group = CreateGroup _side;
_veh = [_pos, _dir, (_type), _group] call BIS_fnc_spawnVehicle;
_leader = leader _group;
_HQ synchronizeObjectsAdd [_leader];
_Leader synchronizeObjectsAdd [_Fo];
_NV = _veh select 0;
[_NV, _rspawns, _delay, _spawn, _HQ] execVM "Init_respawn.sqf";};

if (true) exitWith {};
///end script

If there is a simpler way please by all means post. I was hoping it would simplify this kind of things for people who dont really know much about scripting. and as a tool to learn.

PS LeaderHQ and FO are optional.

Edited by Mikey74

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  

×