curtcooll 1 Posted March 18, 2013 (edited) Im trying to take code from this script and implement it into other script to allow ai units to re spawn into a vehicle the ups script re spawns vehicle with ai units but is not as good as bottom script. // AIvcl_respawn_UPS.sqf // © JULY 2009 - norrin if (!isServer) exitWith {}; _unit = _this select 0; _lives = _this select 1; _delay = _this select 2; _respawn_point = _this select 3; _marker = _this select 4; _crew = _this select 5; _side = _this select 6; _AI_unitArray = _this select 7; _AI_skillArray = _this select 8; _type = typeOf _unit; _group = group _unit; _unitsGroup = units (group _unit); _dir = getDir _unit; waitUntil {!alive _unit}; deleteGroup _group; if (_lives == 0) exitWith {}; _lives = _lives - 1; _wait = Time + _delay; waitUntil {Time > _wait}; _group = createGroup _side; _vcl_new = _type createVehicle (getMArkerPos _respawn_point); _vcl_new setDir _dir; sleep 1; {_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; _guy setSkill (_AI_skillArray select _loop); if (_loop == 0) then {_guy moveInDriver _vcl_new}; if (_loop == 1) then {_guy moveInGunner _vcl_new}; if (_loop == 2) then {_guy moveInCommander _vcl_new}; sleep 0.1; }; {_x enableAI "MOVE"} forEach _unitsGroup; _leader = leader _group; [_vcl_new, _lives, _delay, _respawn_point, _marker, _crew, _side, _AI_unitArray,_AI_skillArray] execVM "AIvcl_respawn_UPS\AIvcl_respawn_UPS.sqf"; [_leader, _marker] execVM "AIvcl_respawn_UPS\UPSvcl_init.sqf"; if (true) exitWith {}; This script is one im want it to be implemented into. 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; for [{ _loop = 0 },{ _loop < count _unitsGroup},{ _loop = _loop + 1}] do { _unit = _unitsGroup select _loop; _unit setSkill (_AI_skillArray select _loop); if (_loop == 0) then {_unit moveInDriver heli}; if (_loop == 0) then {_unit moveInTurret heli}; sleep 0.1; }; // Check respawn amount if !(_noend) then {_rounds = _rounds + 1}; if ((_rounds == _respawns) and !(_noend)) then {_run = false;}; }; }; Edited March 19, 2013 by curtcooll Share this post Link to post Share on other sites
curtcooll 1 Posted March 18, 2013 anyone know how to do it? Share this post Link to post Share on other sites