mikey74 167 Posted May 7, 2015 (edited) Hello my Arma maniac friends. Here is a few of my amaturely written scripts. My newest and still in need of some tweaking but for the most part it works. I learned some things from http://forums.bistudio.com/showthread.php?121814-Single-Player-respawn-script This script is incompatible with arma 3. but I picked up a few things from this great script. Took what I learned and combined it with my Respawn with load out script and now I came up with this : /* Instructions Call this in units init or trigger so long as you have unit defined right! :P example: Rsp = [this,3,7,"markername"] execVM "MikesSP_Respawn.sqf; this = unit you want to respawn 3 = how many times to respawn 7 = delay in respawn.... Havent quite worked this one out yet "markername" = name of marker you put on map. or just use units name without quotes. or something else. */ if (!isDedicated && (player != player)) then { waitUntil {player == player}; waitUntil {time > 3}; }; //private "_ALLPU"; //_ALLPU = if (isMultiplayer) then {playableUnits} else {switchableUnits}; private ["_dplayer","_type","_group","_times","_delay","_respPos"]; _dplayer = _this select 0; _times = (_dplayer getVariable "times"); if (isNil "_times") then {_times = _this select 1}; if (isNil "_times") then {_times = 3}; _delay = _this select 2; if (isNil "_delay") then {_delay = 1}; _respPos = (_dplayer getVariable "Respawnplace"); if (isNil "_respPos") then {_respPos = _this select 3;}; if (isNil "_respPos") then {_respPos = getpos _dplayer;}; if (typeName _respPos == "STRING") then {_respPos = getMarkerPos _respPos}; if (typeName _respPos == "objNull") then {_respPos = getPos _respPos}; _type = typeOf _dplayer; _group = group _dplayer; _isLeader = (_dplayer == leader _group); _dplayer removeAllEventHandlers "killed"; _dplayer setVariable ["isSPlayer", isPlayer _dplayer, true]; _dplayer setVariable ["isLeader", _isLeader, true]; _dplayer setVariable ["times", _times, true]; _dplayer setVariable ["delayS", _delay, true]; _dplayer setVariable ["Respawnplace", _respPos, true]; /////weapons and junk\\\\\ _dplayer setVariable ["MYweapons", weapons _dplayer, true]; _dplayer setVariable ["MYprimw", primaryWeapon _dplayer, true]; _dplayer setVariable ["MYprimaryammo", primaryWeaponMagazine _dplayer + magazines _dplayer, true]; _dplayer setVariable ["Myweaponacc", primaryWeaponItems _dplayer, true]; ///2ndary\\\\ _dplayer setVariable ["MYsecond", secondaryWeapon _dplayer, true]; _dplayer setVariable ["MYsecondacc", secondaryWeaponItems _dplayer, true]; _dplayer setVariable ["MYsecondammo", secondaryWeaponMagazine _dplayer, true]; ////handgun _dplayer setVariable ["Myhgun", handgunWeapon _dplayer, true]; _dplayer setVariable ["Myhgunacc", handgunItems _dplayer, true]; _dplayer setVariable ["Myhgunammo", handgunMagazine _dplayer, true]; ///// mags and ammo \\\ _dplayer setVariable ["MYitemsplayer", itemsWithMagazines _dplayer, true]; _dplayer setVariable ["ALLMYmagazines", (_dplayer getVariable "MYprimaryammo") + (_dplayer getVariable "Myhgunammo") + (_dplayer getVariable "MYsecondammo"), true]; /// uniform and extra \\\ _dplayer setVariable ["MYuniform", uniform _dplayer, true]; _dplayer setVariable ["MYbackpack", backpack _dplayer, true]; _dplayer setVariable ["MYvest", vest _dplayer, true]; _dplayer setVariable ["MYhead", headgear _dplayer, true]; _dplayer setVariable ["MYeyes", goggles _dplayer, true]; _dplayer setVariable ["MYacc", assignedItems _dplayer, true]; _dplayer setVariable ["MyAEI", (_dplayer getVariable "MYitemsplayer") - (_dplayer getVariable "ALLMYmagazines"), true]; Mis_respawn = { _Tgroup = createGroup Civilian; _temp = _Tgroup createUnit ["C_man_polo_6_F", getPos (_this select 0), [], 0, "NONE"]; _temp allowDammage false; hideObject _temp; addSwitchableUnit _temp; _temp enableSimulation false; if (_this select 0 getVariable "isSPlayer") then { cutText ["Respawning","BLACK IN",3.5]; RSP_hndl = ppEffectCreate ["colorCorrections", 1501]; RSP_hndl ppEffectEnable true; RSP_hndl ppEffectAdjust [0, 0, 0, [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]; RSP_hndl ppEffectCommit 0; selectPlayer _temp; }; [_this select 0,_this select 1,_this select 2,_temp] spawn { //sleep 2; private ["_dplayer","_type","_group","_temp","_delay","_time","_times","_respawnplace"]; _dplayer = _this select 0; _type = _this select 1; _group = _this select 2; _temp = _this select 3; _delay = (_dplayer getVariable "delayS");//_this select 3; _time = time + _delay; _times = (_dplayer getVariable "times");// _this select 4; _respawnplace = (_dplayer getVariable "Respawnplace"); _safeResp = _respawnplace findEmptyPosition [0,7]; _isplayer = (_dplayer getVariable "isSPlayer"); _isLeader = (_dplayer getVariable "isLeader"); if (_times == 0) exitWith { if (_isplayer) then {["epicFail",false,1] call BIS_fnc_endMission;}; }; //sleep 1; if (_isplayer) then {waitUntil {player == _temp};}; private "_player"; _player = _group createUnit [_type, _respawnplace, [], 0, "NONE"]; _player setVariable ["delayS", _time, true]; _player setVariable ["delayT", _delay, true]; _player setVariable ["times",_times - 1, true]; _player setVariable ["isSPlayer", _isplayer, true]; _player setVariable ["Respawnplace", _respawnplace, true]; _player allowDamage false; addSwitchableUnit _player; if (_isLeader) then {_group selectLeader _player}; [_dplayer] join grpNull; removeAllWeapons _player; {_player removeMagazine _x} forEach (_dplayer getVariable "ALLMYmagazines"); removeAllItemsWithMagazines _player; removeUniform _player; removeVest _player; removeBackpack _player; removeGoggles _player; removeAllAssignedItems _player; removeHeadgear _player; _p = _player; _p addBackpack (_dplayer getVariable "MYbackpack"); _p addUniform (_dplayer getVariable "MYuniform"); _p addVest (_dplayer getVariable "MYvest"); _p addHeadgear (_dplayer getVariable "MYhead"); _p addGoggles (_dplayer getVariable "MYeyes"); {_p addWeapon _x} forEach (_dplayer getVariable "MYweapons"); _primw = primaryWeapon _p; {_p addPrimaryWeaponItem _x} forEach (_dplayer getVariable "Myweaponacc"); {_p addSecondaryWeaponItem _x} forEach (_dplayer getVariable "MYsecondacc"); {_p addHandgunItem _x} forEach (_dplayer getVariable "Myhgunacc"); {_p addItem _x; _p assignItem _x;} forEach (_dplayer getVariable "MYacc"); {if (_p canAddItemToUniform _x ) then {(uniformContainer _p) addItemCargo [_x, 1]}} forEach (_dplayer getVariable "MyAEI"); _hmag = (_dplayer getVariable "Myhgunammo") select 0; if !(isNil "_hmag") then { if (_p canAddItemToVest _hmag) then {(vestContainer _p) addMagazineCargo [_hmag, 6]}; }; _Mcount = count (_dplayer getVariable "ALLMYmagazines"); if (count (_dplayer getVariable "ALLMYmagazines") > 0 ) then { _mags = (_dplayer getVariable "MYprimaryammo"); /*hint str _mags; copytoclipboard (str _mags); sleep 10;*/ _a = 0; while {_a < count _mags} do { // select 0; try select a instead of 0 below _mag = _mags select _a; _a = _a + 1; //_mags deleteAt _a; hint str _mag; //////////////////////////////////////////////some where in here its deleting all mages _mags = _mags - [_mag];_array deleteAt 0 if (_p canAddItemToUniform _mag ) then {(uniformContainer _p) addMagazineCargo [_mag, count _mag];} else { if (_p canAddItemToVest _mag) then {(vestContainer _p) addMagazineCargo [_mag, 1];} else { if (_p canAddItemToBackpack _mag) then {(backpackContainer _p) addMagazineCargo [_mag, 1];}; }; };//}; }; }; _time = (_player getVariable "delayT"); _times = (_player getVariable "times"); if (isNil "_time") then {_time = time + 1;}; sleep (_time - 1); _player allowDamage true; reload _player; if (_isplayer) then {selectPlayer _player;waitUntil {player == _player};}; deleteVehicle _temp; //_player removeEventHandler ["killed", 0]; //if ((_player getVariable "times") > 0) then { [_player,(_player getVariable "times"),(_player getVariable "delayT"),(_player getVariable "Respawnplace")] execVM "MikesSP_Respawn.sqf"; if (_isplayer) then {ppEffectDestroy RSP_hndl;}; //} else {if (_isplayer) then {["epicFail",false,7] call BIS_fnc_endMission;};}; };//}]; true }; //{ _dplayer addEventHandler ["killed", {[_this select 0,typeOf (_this select 0),group (_this select 0)] call Mis_respawn}]; //} forEach _ALLPU; My newest find cover script: /* File: FOA_find_cover.sqf Author: Mikey74 Description: Function to find good cover positions exluding insects,footprints,men,feathers,pavement, leaflets, and roads. Yes nearestObjects will get those! Parameter(s): _this select 0: unit called for Note: you need a unit _this select 1: seperate position or unit needed if you dont want to search around units position. Use a position or another unit or vehicle. Note: you need a position or a unit this is optional Returns: Array of positions around objects near unit or position thats called the script. How to call: example 1: _cover_positions = [player, getPos nameoftarget(optional)] execVM "FOA_find_cover.sqf"; //if you put this in a sqf file. example 2: _cover_positions = [player, getPos nameoftarget(optional)] spawn FOA_find_cover; //if already precompile or your using FOA. TODO: add building positions. Should be easy enough. */ private ["_obj_positions","_unitpos","_pos","_towns"]; _obj_positions = []; _unit = _this select 0; _pos = _this select 1; if (isNil "_pos") then {_pos = getPos _unit};/// lets make sure we have some kind of position here. if (typeName _pos != "ARRAY") then {_pos = getPos _pos};/// lets make sure _pos is really a position. if not you will get an error or it just wont work. _radius = count units group _unit * 21;/// lets set a radius based on group size. _towns = nearestLocations [_pos, ["NameVillage","NameCity","NameCityCapital"], 200]; // finding towns close by if (count _towns > 0) then {_radius = count units group _unit * 7};/// you want a smaller radius for towns. ;) if (_radius < 21) then {_radius = 21};// minimum 21 _Roads = _unit nearRoads _radius;// find roads near _unit //_c = 0; { if ( !(_x iskindof "Insect") and // lets not use bugs for cover Animals !(_x iskindof "Animals") and // lets not use Animals for cover !(_x iskindof "Man") and // nor live men !(_x iskindof "EmptyDetector") and // nor triggers !((str _x) find "NOID " > -1) and //nor footprints or anything without an ID !((str _x) find ": cl_" > -1) and // nor any type of freather or leaves !((str _x) find ": pavement_" > -1) and // get rid of pavement type's !((str _x) find ": garbage_" > -1) and // cant hind behind leaflets on ground !(_x in _Roads) ) then { /// oh yeh lets not forget to exclude roads //_c = _c + 1; private "_obj"; _obj = _x; //////////////////////////////////////////// Addd if _obj is a building then get building positions\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ ******************************************************************************************************************************************************** { //_n = FORMAT ["%1_%2",_obj,_c]; _CPos = ((getPos _Obj) findEmptyPosition [0,3]); if (count _CPos == 3) then { _obj_positions pushBack _CPos; //_n = "Sign_Arrow_Large_Green_F" createVehicle _CPos; }; } forEach units group _unit; }; } forEach nearestObjects [_pos, [], _radius]; _obj_positions; This is an edit from original respawn script in that you will respawn with weapons and load outs that you have at death. I'll edit my MP version tonight. These two respawns are for single player. may work in multiplayer but Id prefer the other one when I'm done. ;) /* Instructions Call this in units init or trigger so long as you have unit defined right! :P example: Rsp = [this,3,7,"markername"] execVM "MikesSP_Respawn.sqf; this = unit you want to respawn 3 = how many times to respawn 7 = delay in respawn.... Havent quite worked this one out yet "markername" = name of marker you put on map. or just use units name without quotes. or something else. */ if (!isDedicated && (player != player)) then { waitUntil {player == player}; waitUntil {time > 3}; }; //private "_ALLPU"; //_ALLPU = if (isMultiplayer) then {playableUnits} else {switchableUnits}; private ["_dplayer","_type","_group","_times","_delay","_respPos"]; _dplayer = _this select 0; _times = (_dplayer getVariable "times"); if (isNil "_times") then {_times = _this select 1}; if (isNil "_times") then {_times = 3}; _delay = _this select 2; if (isNil "_delay") then {_delay = 1}; _respPos = (_dplayer getVariable "Respawnplace"); if (isNil "_respPos") then {_respPos = _this select 3;}; if (isNil "_respPos") then {_respPos = getpos _dplayer;}; if (typeName _respPos == "STRING") then {_respPos = getMarkerPos _respPos}; if (typeName _respPos == "objNull") then {_respPos = getPos _respPos}; _type = typeOf _dplayer; _group = group _dplayer; _isLeader = (_dplayer == leader _group); _dplayer removeAllEventHandlers "killed"; _dplayer setVariable ["isSPlayer", isPlayer _dplayer, true]; _dplayer setVariable ["isLeader", _isLeader, true]; _dplayer setVariable ["times", _times, true]; _dplayer setVariable ["delayS", _delay, true]; _dplayer setVariable ["Respawnplace", _respPos, true]; Mis_respawn = { _Tgroup = createGroup Civilian; _temp = _Tgroup createUnit ["C_man_polo_6_F", getPos (_this select 0), [], 0, "NONE"]; _temp allowDammage false; hideObject _temp; addSwitchableUnit _temp; _temp enableSimulation false; if (_this select 0 getVariable "isSPlayer") then { cutText ["Respawning","BLACK IN",3.5]; RSP_hndl = ppEffectCreate ["colorCorrections", 1501]; RSP_hndl ppEffectEnable true; RSP_hndl ppEffectAdjust [0, 0, 0, [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]; RSP_hndl ppEffectCommit 0; selectPlayer _temp; }; [_this select 0,_this select 1,_this select 2,_temp] spawn { //sleep 2; private ["_dplayer","_type","_group","_temp","_delay","_time","_times","_respawnplace"]; _dplayer = _this select 0; _type = _this select 1; _group = _this select 2; _temp = _this select 3; /////weapons and junk\\\\\ _dplayer setVariable ["MYweapons", weapons _dplayer, true]; _dplayer setVariable ["MYprimw", primaryWeapon _dplayer, true]; _prim = (_dplayer getVariable "MYprimw"); if (isNil "_prim" or (!(_prim isKindOf "MGun") and !(_prim iskindOf "Rifle"))) then { _primW = []; { if (_x isKindOf "MGun" or _x iskindOf "Rifle") then { _primW pushBack _x; }; } forEach nearestObjects [_dplayer, ["GroundWeaponHolder"], 10]; _dplayer setVariable ["MYprimw", _primW select 0, true]; }; _dplayer setVariable ["MYprimaryammo", primaryWeaponMagazine _dplayer + magazines _dplayer, true]; _dplayer setVariable ["Myweaponacc", primaryWeaponItems _dplayer, true]; ///2ndary\\\\ _dplayer setVariable ["MYsecond", secondaryWeapon _dplayer, true]; _dplayer setVariable ["MYsecondacc", secondaryWeaponItems _dplayer, true]; _dplayer setVariable ["MYsecondammo", secondaryWeaponMagazine _dplayer, true]; ////handgun _dplayer setVariable ["Myhgun", handgunWeapon _dplayer, true]; _dplayer setVariable ["Myhgunacc", handgunItems _dplayer, true]; _dplayer setVariable ["Myhgunammo", handgunMagazine _dplayer, true]; ///// mags and ammo \\\ _dplayer setVariable ["MYitemsplayer", itemsWithMagazines _dplayer, true]; _dplayer setVariable ["ALLMYmagazines", (_dplayer getVariable "MYprimaryammo") + (_dplayer getVariable "Myhgunammo") + (_dplayer getVariable "MYsecondammo"), true]; /// uniform and extra \\\ _dplayer setVariable ["MYuniform", uniform _dplayer, true]; _dplayer setVariable ["MYbackpack", backpack _dplayer, true]; _dplayer setVariable ["MYvest", vest _dplayer, true]; _dplayer setVariable ["MYhead", headgear _dplayer, true]; _dplayer setVariable ["MYeyes", goggles _dplayer, true]; _dplayer setVariable ["MYacc", assignedItems _dplayer, true]; _dplayer setVariable ["MyAEI", (_dplayer getVariable "MYitemsplayer") - (_dplayer getVariable "ALLMYmagazines"), true]; _delay = (_dplayer getVariable "delayS");//_this select 3; _time = time + _delay; _times = (_dplayer getVariable "times");// _this select 4; _respawnplace = (_dplayer getVariable "Respawnplace"); _safeResp = _respawnplace findEmptyPosition [0,7]; _isplayer = (_dplayer getVariable "isSPlayer"); _isLeader = (_dplayer getVariable "isLeader"); if (_times == 0) exitWith { if (_isplayer) then {["epicFail",false,1] call BIS_fnc_endMission;}; }; //sleep 1; if (_isplayer) then {waitUntil {player == _temp};}; private "_player"; _player = _group createUnit [_type, _respawnplace, [], 0, "NONE"]; _player setVariable ["delayS", _time, true]; _player setVariable ["delayT", _delay, true]; _player setVariable ["times",_times - 1, true]; _player setVariable ["isSPlayer", _isplayer, true]; _player setVariable ["Respawnplace", _respawnplace, true]; _player allowDamage false; addSwitchableUnit _player; if (_isLeader) then {_group selectLeader _player}; [_dplayer] join grpNull; removeAllWeapons _player; {_player removeMagazine _x} forEach (_dplayer getVariable "ALLMYmagazines"); removeAllItemsWithMagazines _player; removeUniform _player; removeVest _player; removeBackpack _player; removeGoggles _player; removeAllAssignedItems _player; removeHeadgear _player; _p = _player; _p addBackpack (_dplayer getVariable "MYbackpack"); _p addUniform (_dplayer getVariable "MYuniform"); _p addVest (_dplayer getVariable "MYvest"); _p addHeadgear (_dplayer getVariable "MYhead"); _p addGoggles (_dplayer getVariable "MYeyes"); {_p addWeapon _x} forEach (_dplayer getVariable "MYweapons"); //_primw = primaryWeapon _p; {_p addPrimaryWeaponItem _x} forEach (_dplayer getVariable "Myweaponacc"); {_p addSecondaryWeaponItem _x} forEach (_dplayer getVariable "MYsecondacc"); {_p addHandgunItem _x} forEach (_dplayer getVariable "Myhgunacc"); {_p addItem _x; _p assignItem _x;} forEach (_dplayer getVariable "MYacc"); {if (_p canAddItemToUniform _x ) then {(uniformContainer _p) addItemCargo [_x, 1]}} forEach (_dplayer getVariable "MyAEI"); _hmag = (_dplayer getVariable "Myhgunammo") select 0; if !(isNil "_hmag") then { if (_p canAddItemToVest _hmag) then {(vestContainer _p) addMagazineCargo [_hmag, 6]}; }; _Mcount = count (_dplayer getVariable "ALLMYmagazines"); if (count (_dplayer getVariable "ALLMYmagazines") > 0 ) then { _mags = (_dplayer getVariable "MYprimaryammo"); /*hint str _mags; copytoclipboard (str _mags); sleep 10;*/ private "_a"; _a = 0; while {_a < count _mags} do { // select 0; try select a instead of 0 below _mag = _mags select _a; _a = _a + 1; //_mags deleteAt _a; hint str _mag; //////////////////////////////////////////////some where in here its deleting all mages _mags = _mags - [_mag];_array deleteAt 0 if (_p canAddItemToUniform _mag ) then {(uniformContainer _p) addMagazineCargo [_mag, count _mag];} else { if (_p canAddItemToVest _mag) then {(vestContainer _p) addMagazineCargo [_mag, 1];} else { if (_p canAddItemToBackpack _mag) then {(backpackContainer _p) addMagazineCargo [_mag, 1];}; }; };//}; }; }; _time = (_player getVariable "delayT"); _times = (_player getVariable "times"); if (isNil "_time") then {_time = time + 1;}; sleep (_time - 1); _player allowDamage true; //_player action ["WeaponInHand", _player]; reload _player; if (_isplayer) then {selectPlayer _player;waitUntil {player == _player};}; deleteVehicle _temp; //_player removeEventHandler ["killed", 0]; //if ((_player getVariable "times") > 0) then { [_player,(_player getVariable "times"),(_player getVariable "delayT"),(_player getVariable "Respawnplace")] execVM "MikesSP_Respawn.sqf"; if (_isplayer) then {ppEffectDestroy RSP_hndl;}; //} else {if (_isplayer) then {["epicFail",false,7] call BIS_fnc_endMission;};}; };//}]; true }; //{ _dplayer addEventHandler ["killed", {[_this select 0,typeOf (_this select 0),group (_this select 0)] call Mis_respawn}]; //} forEach _ALLPU; I want to tweak up the others and add instructions to them then if enough interest is in this thread I'll release them too. Hope this can help my fellow modders. I am by no means an expert coder. If anyone wants to re write these and explain what they did. Me and others learning to code would love it. ;) Edited May 8, 2015 by Mikey74 1 Share this post Link to post Share on other sites
twisted 127 Posted May 8, 2015 Thanks man, these will be very useful. Cheers! Share this post Link to post Share on other sites
breeze 0 Posted May 16, 2015 I would love them...especially respawn in sp mode as far as I know it can not be done without a mod..so the take cover works in Arma 3? Share this post Link to post Share on other sites
das attorney 854 Posted May 16, 2015 so the take cover works in Arma 3? Looks like find cover script, not take cover. Share this post Link to post Share on other sites
breeze 0 Posted May 17, 2015 Well I tried the bottom script in arma 3 as it did not say that it didn't work and my screen did say I was respawning which I was happy but screen went black....Do I still need to configure spawn in the description.ext when doing this? Share this post Link to post Share on other sites
redarmy 372 Posted May 18, 2015 Lovely work Mikey Iv been itching for a respawn for SP and closest i got to it was needing to use norrins revive(which included sp respawn but revive was buggy for me) This will serve well until BIS introduce a medical system Share this post Link to post Share on other sites
breeze 0 Posted May 18, 2015 You know when you get down to it couldn't one just create a coop game of four people then intor it as a single plaer and call it a single then when the guy dies it would just respawn him? just make the four not in a group Share this post Link to post Share on other sites
mikey74 167 Posted May 18, 2015 yeh its a find cover script. Not takecover, but I use it for my take cover type script in FOA's next release (not released yet). I'll make a few sample missions in the next few days after FOA beta release to demonstrate how you can use them. ;) Share this post Link to post Share on other sites
redarmy 372 Posted May 18, 2015 (edited) Mikey im entering your example command line in trigger/unit init and getting a syntax error Rsp = [this,3,7,"markername"] execVM "MikesSP_Respawn.sqf; says missing "" edit : Rsp = [this,3,7,"markername"] execVM "MikesSP_Respawn.sqf"; works,was missing quotations at the end of respawn.sqf(") EDIT2: The second respawn script does not respawn me with gear Edited May 18, 2015 by redarmy Share this post Link to post Share on other sites
mikey74 167 Posted May 18, 2015 (edited) OK here is an example mission using find cover script for spawning instead of a marker. You can add a marker to map and name it and use it in this script but try what i have 1st. When you start, there is a radio trigger. if you hit 0 0 1 your man will find a cover position for approx 5 seconds then return to formation. After you do that there are mines up the road as you enter the town. Run and get killed. You should respawn with what weapons and ammo you had at death. The exact number. ;) Script is called for respawn with this Rsp = [this,3,7] execVM "MikesSP_Respawn.sqf"; if you decide on a marker to respawn on use this to call it. Do not use objects only nothing or a marker. Rsp = [this,3,7,"yourmarkernamehere"] execVM "MikesSP_Respawn.sqf"; Trigger calling for cover is called with this {cover_now = [_x] execVM "Movetocover.sqf";} forEach units (group player); Spawning N cover example mission Put this in you mission folder in your documents arma 3. Try both but I think the 1 below is a bit better on respawning. Edit had to tweak some things in script the other one works, but I like this one better. Edited May 18, 2015 by Mikey74 Share this post Link to post Share on other sites
mikey74 167 Posted May 24, 2015 sp_respawn /* Instructions Call this in units init or trigger so long as you have unit defined right! :P example: Rsp = [this,3,7,"markername"] execVM "MikesSP_Respawn.sqf"; this = unit you want to respawn 3 = how many times to respawn Optional 7 = delay in respawn.... Havent quite worked this one out yet Optional "markername" = name of marker you put on map. or just use units name without quotes. or something else. Optional */ if (!isDedicated && (player != player)) then { waitUntil {player == player}; waitUntil {time > 3}; }; private ["_dplayer","_type","_group","_times","_delay","_respPos"]; _dplayer = _this select 0; _times = (_dplayer getVariable "times"); _respawn = _this select 3; //missionNamespace setVariable ["IsswitchableUnit",switchableUnits]; if (isNil "_times") then {_times = _this select 1}; if (isNil "_times") then {_times = 3}; _delay = _this select 2; if (isNil "_delay") then {_delay = 1}; _type = typeOf _dplayer; _group = group _dplayer; _isLeader = (_dplayer == leader _group); _dplayer removeAllEventHandlers "killed"; _dplayer setVariable ["isLeader", _isLeader, true]; _dplayer setVariable ["times", _times, true]; _dplayer setVariable ["delayS", _delay, true]; Mis_respawn = { _dplayer = _this select 0; _respawn = _this select 3; _respPos = _respawn;//_this select 3;//(_dplayer getVariable "Respawnplace"); //if (typeName _respPos == "STRING") then {_respPos = getMarkerPos _respPos}; //if (typeName _respPos == "objNull") then {_respPos = getPos _respPos}; if (isNil "_respPos") then {_respPos = _respawn;}; if (isNil "_respPos") then { _cover_positions = [_dplayer] call Find_CVR; _respPos = _cover_positions call BIS_fnc_selectRandom; //hint str _respPos; }; _dplayer setVariable ["Respawnplace", _respPos, true]; _dplayer setVariable ["MYprimw", primaryWeapon _dplayer, true]; _prim = (_dplayer getVariable "MYprimw"); if (isNil "_prim" or (!(_prim isKindOf "MGun") and !(_prim iskindOf "Rifle"))) then { _primW = []; { if (_x isKindOf "MGun" or _x iskindOf "Rifle") then { _primW pushBack _x; }; } forEach nearestObjects [_dplayer, ["GroundWeaponHolder"], 7]; _dplayer setVariable ["MYprimw", _primW select 0, true]; }; /////weapons and junk\\\\\ _dplayer setVariable ["MYweapons", weapons _dplayer, true]; _dplayer setVariable ["MYprimaryammo", primaryWeaponMagazine _dplayer + magazines _dplayer, true]; _dplayer setVariable ["Myweaponacc", primaryWeaponItems _dplayer, true]; ///2ndary\\\\ _dplayer setVariable ["MYsecond", secondaryWeapon _dplayer, true]; _dplayer setVariable ["MYsecondacc", secondaryWeaponItems _dplayer, true]; _dplayer setVariable ["MYsecondammo", secondaryWeaponMagazine _dplayer, true]; ////handgun _dplayer setVariable ["Myhgun", handgunWeapon _dplayer, true]; _dplayer setVariable ["Myhgunacc", handgunItems _dplayer, true]; _dplayer setVariable ["Myhgunammo", handgunMagazine _dplayer, true]; ///// mags and ammo \\\ _dplayer setVariable ["MYitemsplayer", itemsWithMagazines _dplayer, true]; _dplayer setVariable ["ALLMYmagazines", (_dplayer getVariable "MYprimaryammo") + (_dplayer getVariable "Myhgunammo") + (_dplayer getVariable "MYsecondammo"), true]; /// uniform and extra \\\ _dplayer setVariable ["MYuniform", uniform _dplayer, true]; _dplayer setVariable ["MYbackpack", backpack _dplayer, true]; _dplayer setVariable ["MYvest", vest _dplayer, true]; _dplayer setVariable ["MYhead", headgear _dplayer, true]; _dplayer setVariable ["MYeyes", goggles _dplayer, true]; _dplayer setVariable ["MYacc", assignedItems _dplayer, true]; _dplayer setVariable ["MyAEI", (_dplayer getVariable "MYitemsplayer") - (_dplayer getVariable "ALLMYmagazines"), true]; _dplayer setVariable ["isSPlayer", isPlayer _dplayer, true]; _Tgroup = createGroup Civilian; _temp = _Tgroup createUnit ["C_man_polo_6_F", getPos (_this select 0), [], 0, "NONE"]; _temp allowDammage false; hideObject _temp; addSwitchableUnit _temp; _temp enableSimulation false; if (_this select 0 getVariable "isSPlayer") then { cutText ["Respawning","BLACK IN",3.5]; RSP_hndl = ppEffectCreate ["colorCorrections", 1501]; RSP_hndl ppEffectEnable true; RSP_hndl ppEffectAdjust [0, 0, 0, [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]; RSP_hndl ppEffectCommit 0; selectPlayer _temp; }; [_this select 0,_this select 1,_this select 2,_temp,_respawn] spawn { private ["_dplayer","_type","_group","_temp","_delay","_time","_times","_respawnplace"]; _dplayer = _this select 0; _type = _this select 1; _group = _this select 2; _temp = _this select 3; _Respawn = _this select 4; _delay = (_dplayer getVariable "delayS");//_this select 3; _time = time + _delay; _times = (_dplayer getVariable "times");// _this select 4; _respawnplace = (_dplayer getVariable "Respawnplace"); _safeResp = _respawnplace findEmptyPosition [0,7]; _isplayer = (_dplayer getVariable "isSPlayer"); _isLeader = (_dplayer getVariable "isLeader"); if (_times == 0) exitWith { if (_isplayer) then {["epicFail",false,1] call BIS_fnc_endMission;} else {deleteVehicle _temp;}; }; if (isNil "_delay") then {_delay = time + 1;}; sleep (_delay); //sleep 1; if (_isplayer) then {waitUntil {player == _temp};}; private "_player"; _player = _group createUnit [_type, _respawnplace, [], 0, "NONE"]; _player setVariable ["delayS", _delay, true]; _player setVariable ["delayT", _time, true]; _player setVariable ["times",_times - 1, true]; _player setVariable ["isSPlayer", _isplayer, true]; _player setVariable ["Respawnplace", _respawnplace, true]; _player allowDamage false; addSwitchableUnit _player; removeAllWeapons _player; {_player removeMagazine _x} forEach (_dplayer getVariable "ALLMYmagazines"); removeAllItemsWithMagazines _player; removeUniform _player; removeVest _player; removeBackpack _player; removeGoggles _player; removeAllAssignedItems _player; removeHeadgear _player; _p = _player; _p addBackpack (_dplayer getVariable "MYbackpack"); _p addUniform (_dplayer getVariable "MYuniform"); _p addVest (_dplayer getVariable "MYvest"); _p addHeadgear (_dplayer getVariable "MYhead"); _p addGoggles (_dplayer getVariable "MYeyes"); {_p addWeapon _x} forEach (_dplayer getVariable "MYweapons"); //_primw = primaryWeapon _p; {_p addPrimaryWeaponItem _x} forEach (_dplayer getVariable "Myweaponacc"); {_p addSecondaryWeaponItem _x} forEach (_dplayer getVariable "MYsecondacc"); {_p addHandgunItem _x} forEach (_dplayer getVariable "Myhgunacc"); {_p addItem _x; _p assignItem _x;} forEach (_dplayer getVariable "MYacc"); {if (_p canAddItemToUniform _x ) then {(uniformContainer _p) addItemCargo [_x, 1]}} forEach (_dplayer getVariable "MyAEI"); _Mcount = count (_dplayer getVariable "ALLMYmagazines"); if (count (_dplayer getVariable "ALLMYmagazines") > 0 ) then { _mags = (_dplayer getVariable "ALLMYmagazines"); private "_a"; _a = 0; while {count _mags > _a} do { _mag = _mags select _a; _a = _a + 1; if (_p canAddItemToUniform _mag ) then {(uniformContainer _p) addMagazineCargo [_mag, 1];} else { if (_p canAddItemToVest _mag) then {(vestContainer _p) addMagazineCargo [_mag, 1];} else { if (_p canAddItemToBackpack _mag) then {(backpackContainer _p) addMagazineCargo [_mag, 1];}; }; }; }; }; reload _player; _player allowDamage true; if (_isplayer) then {selectPlayer _player;waitUntil {player == _player};}; if (_isLeader) then {_group selectLeader _player}; [_dplayer] join grpNull; deleteVehicle _temp; _respPos = nil; if (isNil "_Respawn") then {_Respawn = _player}; [_player,(_player getVariable "times"),(_player getVariable "delayS"),_Respawn] execVM "MikesSP_Respawn.sqf"; if (_isplayer) then {ppEffectDestroy RSP_hndl;}; //hint str (_player getVariable "delayS"); }; true }; _dplayer addEventHandler ["killed", {[_this select 0,typeOf (_this select 0),group (_this select 0)] call Mis_respawn}]; Share this post Link to post Share on other sites
breeze 0 Posted May 24, 2015 I am very happy to see this script, Thank you is the marker that we put on the map the location of the re-spawn?? Share this post Link to post Share on other sites
mikey74 167 Posted May 24, 2015 lol actually sense my last edit of the script I didnt test that. When I have some time I will. but yess theoreticly if you put a marker on the map and put the Name you gave the marker in the script call it should work. Other wise It will spawn him in random cover positions. You will need this script with it for that. /* File: FOA_find_cover.sqf Author: Mikey74 Description: Function to find good cover positions exluding insects,footprints,men,feathers,pavement, leaflets, and roads. Yes nearestObjects will get those! Parameter(s): _this select 0: unit called for Note: you need a unit _this select 1: seperate position or unit needed if you dont want to search around units position. Use a position or another unit or vehicle. Note: you need a position or a unit this is optional Returns: Array of positions around objects near unit or position thats called the script. How to call: example 1: _cover_positions = [unitname, getPos nameoftarget(optional)] execVM "FOA_find_cover.sqf"; //if you put this in a sqf file. example 2: _cover_positions = [unitname, getPos nameoftarget(optional)] spawn FOA_find_cover; //if already precompile or your using FOA. TODO: add building positions. Should be easy enough. */ private ["_obj_positions","_unitpos","_pos","_towns"]; _obj_positions = []; _unit = _this select 0; _pos = _this select 1; if (isNil "_pos") then {_pos = getPos _unit};/// lets make sure we have some kind of position here. if (typeName _pos != "ARRAY") then {_pos = getPos _pos};/// lets make sure _pos is really a position. if not you will get an error or it just wont work. _radius = count units group _unit * 21;/// lets set a radius based on group size. _towns = nearestLocations [_pos, ["NameVillage","NameCity","NameCityCapital"], 200]; // finding towns close by if (count _towns > 0) then {_radius = count units group _unit * 7};/// you want a smaller radius for towns. ;) if (_radius < 21) then {_radius = 21};// minimum 21 if (_radius > 42) then {_radius = 42};// minimum 21 _Roads = _unit nearRoads _radius;// find roads near _unit //_c = 0; { if ( !(_x iskindof "Insect") and // lets not use bugs for cover Animals !(_x iskindof "Animals") and // lets not use Animals for cover !(_x iskindof "Man") and // nor live men !(_x iskindof "EmptyDetector") and // nor triggers !((str _x) find "NOID " > -1) and //nor footprints or anything without an ID !((str _x) find ": cl_" > -1) and // nor any type of freather or leaves !((str _x) find ": pavement_" > -1) and // get rid of pavement type's !((str _x) find ": garbage_" > -1) and // cant hind behind leaflets on ground !(_x in _Roads) ) then { /// oh yeh lets not forget to exclude roads //_c = _c + 1; private "_obj"; _obj = _x; //////////////////////////////////////////// Addd if _obj is a building then get building positions\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ ******************************************************************************************************************************************************** { //_n = FORMAT ["%1_%2",_obj,_c]; _CPos = ((getPos _Obj) findEmptyPosition [0,3]); if (count _CPos == 3) then { _obj_positions pushBack _CPos; //_n = "Sign_Arrow_Large_Green_F" createVehicle _CPos; }; } forEach units group _unit; }; } forEach nearestObjects [_pos, [], _radius]; _obj_positions Here is a sample mission with that. Share this post Link to post Share on other sites
mikey74 167 Posted July 4, 2015 Found a few errors in sp_respawn script. Here is newer version /* Instructions Call this in units init or trigger so long as you have unit defined right! :P example: Rsp = [this,3,7,"markername"] execVM "MikesSP_Respawn.sqf"; this = unit you want to respawn 3 = how many times to respawn 7 = delay in respawn.... Havent quite worked this one out yet "markername" = name of marker you put on map. or just use units name without quotes. or something else. */ if (!isDedicated && (player != player)) then { waitUntil {player == player}; waitUntil {time > 3}; }; private ["_dplayer","_type","_group","_times","_delay","_respPos"]; _dplayer = _this select 0; _times = (_dplayer getVariable "times"); //_respawn = _this select 3; _dplayer setVariable ["Respawnplace1", (_this select 3), true]; //missionNamespace setVariable ["IsswitchableUnit",switchableUnits]; if (isNil "_times") then {_times = _this select 1}; if (isNil "_times") then {_times = 3}; _delay = _this select 2; if (isNil "_delay") then {_delay = 1}; _type = typeOf _dplayer; _group = group _dplayer; _isLeader = (_dplayer == leader _group); _dplayer removeAllEventHandlers "killed"; _dplayer setVariable ["isLeader", _isLeader, true]; _dplayer setVariable ["times", _times, true]; _dplayer setVariable ["delayS", _delay, true]; Mis_respawn = { _dplayer = _this select 0; _respawn = (_dplayer getVariable "Respawnplace1");//_this select 3;// _respPos = _respawn;//_this select 3;//(_dplayer getVariable "Respawnplace"); if !(isNil "_respPos") then { if (typeName _respPos == "STRING") then {_respPos = getMarkerPos _respawn} else {_respPos = getPos _respawn}; //if (typeName _respawn == "objNull") then {getPos _respawn}; } else { _cover_positions = [_dplayer] call Find_CVR; _RPos = _cover_positions call BIS_fnc_selectRandom; _respPos = _RPos findEmptyPosition [0,7]; }; hint str _respPos; /*if (isNil "_respPos") then { _cover_positions = [_dplayer] call Find_CVR; _respPos = _cover_positions call BIS_fnc_selectRandom; //hint str _respPos; };// else {}; if (isNil "_respPos") then {_respPos = _respawn;};*/ _dplayer setVariable ["Respawnplace", _respPos, true]; _dplayer setVariable ["MYprimw", primaryWeapon _dplayer, true]; _prim = (_dplayer getVariable "MYprimw"); if (isNil "_prim" or (!(_prim isKindOf "MGun") and !(_prim iskindOf "Rifle"))) then { _primW = []; { if (_x isKindOf "MGun" or _x iskindOf "Rifle") then { _primW pushBack _x; }; } forEach nearestObjects [_dplayer, ["GroundWeaponHolder"], 7]; _dplayer setVariable ["MYprimw", _primW select 0, true]; }; /////weapons and junk\\\\\ _dplayer setVariable ["MYweapons", weapons _dplayer, true]; _dplayer setVariable ["MYprimaryammo", primaryWeaponMagazine _dplayer + magazines _dplayer, true]; _dplayer setVariable ["Myweaponacc", primaryWeaponItems _dplayer, true]; ///2ndary\\\\ _dplayer setVariable ["MYsecond", secondaryWeapon _dplayer, true]; _dplayer setVariable ["MYsecondacc", secondaryWeaponItems _dplayer, true]; _dplayer setVariable ["MYsecondammo", secondaryWeaponMagazine _dplayer, true]; ////handgun _dplayer setVariable ["Myhgun", handgunWeapon _dplayer, true]; _dplayer setVariable ["Myhgunacc", handgunItems _dplayer, true]; _dplayer setVariable ["Myhgunammo", handgunMagazine _dplayer, true]; ///// mags and ammo \\\ _dplayer setVariable ["MYitemsplayer", itemsWithMagazines _dplayer, true]; _dplayer setVariable ["ALLMYmagazines", (_dplayer getVariable "MYprimaryammo") + (_dplayer getVariable "Myhgunammo") + (_dplayer getVariable "MYsecondammo"), true]; /// uniform and extra \\\ _dplayer setVariable ["MYuniform", uniform _dplayer, true]; _dplayer setVariable ["MYbackpack", backpack _dplayer, true]; _dplayer setVariable ["MYvest", vest _dplayer, true]; _dplayer setVariable ["MYhead", headgear _dplayer, true]; _dplayer setVariable ["MYeyes", goggles _dplayer, true]; _dplayer setVariable ["MYacc", assignedItems _dplayer, true]; _dplayer setVariable ["MyAEI", (_dplayer getVariable "MYitemsplayer") - (_dplayer getVariable "ALLMYmagazines"), true]; _dplayer setVariable ["isSPlayer", isPlayer _dplayer, true]; _Tgroup = createGroup Civilian; _temp = _Tgroup createUnit ["C_man_polo_6_F", getPos (_this select 0), [], 0, "NONE"]; _temp allowDammage false; hideObject _temp; addSwitchableUnit _temp; _temp enableSimulation false; if (_this select 0 getVariable "isSPlayer") then { cutText ["Respawning","BLACK IN",3.5]; RSP_hndl = ppEffectCreate ["colorCorrections", 1501]; RSP_hndl ppEffectEnable true; RSP_hndl ppEffectAdjust [0, 0, 0, [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]; RSP_hndl ppEffectCommit 0; selectPlayer _temp; }; [_this select 0,_this select 1,_this select 2,_temp,_respPos] spawn { private ["_dplayer","_type","_group","_temp","_Respawn","_delay","_time","_times","_respawnplace"]; _dplayer = _this select 0; _type = _this select 1; _group = _this select 2; _temp = _this select 3; _Respawn = _this select 4; _delay = (_dplayer getVariable "delayS");//_this select 3; _time = time + _delay; _times = (_dplayer getVariable "times");// _this select 4; _respawnplace = _Respawn;//(_dplayer getVariable "Respawnplace"); //_safeResp = _respawnplace findEmptyPosition [0,7]; _isplayer = (_dplayer getVariable "isSPlayer"); _isLeader = (_dplayer getVariable "isLeader"); if (_times == 0) exitWith { if (_isplayer) then {["epicFail",false,1] call BIS_fnc_endMission;} else {deleteVehicle _temp;}; }; if (isNil "_delay") then {_delay = time + 1;}; sleep (_delay); //sleep 1; if (_isplayer) then {waitUntil {player == _temp};}; private "_player"; _player = _group createUnit [_type, _respawnplace, [], 0, "NONE"]; _player setVariable ["delayS", _delay, true]; _player setVariable ["delayT", _time, true]; _player setVariable ["times",_times - 1, true]; _player setVariable ["isSPlayer", _isplayer, true]; _player setVariable ["Respawnplace", _respawnplace, true]; _player allowDamage false; addSwitchableUnit _player; removeAllWeapons _player; {_player removeMagazine _x} forEach (_dplayer getVariable "ALLMYmagazines"); removeAllItemsWithMagazines _player; removeUniform _player; removeVest _player; removeBackpack _player; removeGoggles _player; removeAllAssignedItems _player; removeHeadgear _player; _p = _player; _p addBackpack (_dplayer getVariable "MYbackpack"); _p addUniform (_dplayer getVariable "MYuniform"); _p addVest (_dplayer getVariable "MYvest"); _p addHeadgear (_dplayer getVariable "MYhead"); _p addGoggles (_dplayer getVariable "MYeyes"); {_p addWeapon _x} forEach (_dplayer getVariable "MYweapons"); //_primw = primaryWeapon _p; {_p addPrimaryWeaponItem _x} forEach (_dplayer getVariable "Myweaponacc"); {_p addSecondaryWeaponItem _x} forEach (_dplayer getVariable "MYsecondacc"); {_p addHandgunItem _x} forEach (_dplayer getVariable "Myhgunacc"); {_p addItem _x; _p assignItem _x;} forEach (_dplayer getVariable "MYacc"); {if (_p canAddItemToUniform _x ) then {(uniformContainer _p) addItemCargo [_x, 1]}} forEach (_dplayer getVariable "MyAEI"); _Mcount = count (_dplayer getVariable "ALLMYmagazines"); if (count (_dplayer getVariable "ALLMYmagazines") > 0 ) then { _mags = (_dplayer getVariable "ALLMYmagazines"); private "_a"; _a = 0; while {count _mags > _a} do { _mag = _mags select _a; _a = _a + 1; if (_p canAddItemToUniform _mag ) then {(uniformContainer _p) addMagazineCargo [_mag, 1];} else { if (_p canAddItemToVest _mag) then {(vestContainer _p) addMagazineCargo [_mag, 1];} else { if (_p canAddItemToBackpack _mag) then {(backpackContainer _p) addMagazineCargo [_mag, 1];}; }; }; }; }; reload _player; _player allowDamage true; if (_isplayer) then {selectPlayer _player;waitUntil {player == _player};}; if (_isLeader) then {_group selectLeader _player}; [_dplayer] join grpNull; deleteVehicle _temp; _respPos = nil; if (isNil "_Respawn") then {_Respawn = _player}; [_player,(_player getVariable "times"),(_player getVariable "delayS"),(_dplayer getVariable "Respawnplace1")] execVM "MikesSP_Respawn.sqf"; if (_isplayer) then {ppEffectDestroy RSP_hndl;}; //hint str (_player getVariable "delayS"); }; true }; _dplayer addEventHandler ["killed", {[_this select 0,typeOf (_this select 0),group (_this select 0),_respawn] call Mis_respawn}]; Share this post Link to post Share on other sites
thelegendarykhan 15 Posted July 27, 2015 (edited) Very handy scripts indeed. However, mikey, I am trying to achieve a wasteland like mission in SP. So: 1. When the Ai and even my player unit if killed, the script should scan the entire map and then randomly choose a cover point far off. To maintain the Search and Destroy element. Can you please send me the edited script for this? 2. If I use your markername approach to determine more than one respawn location, how do you put the array of different markernames in unit init so that a random spot is chosen? take for instance markers named "m1" and "m2". I tried altering your init script but to no avail. Thank you.^^ Edited July 27, 2015 by TheLegendaryKhan Share this post Link to post Share on other sites
mikey74 167 Posted January 11, 2020 On 7/27/2015 at 2:33 PM, thelegendarykhan said: Very handy scripts indeed. However, mikey, I am trying to achieve a wasteland like mission in SP. So: 1. When the Ai and even my player unit if killed, the script should scan the entire map and then randomly choose a cover point far off. To maintain the Search and Destroy element. Can you please send me the edited script for this? 2. If I use your markername approach to determine more than one respawn location, how do you put the array of different markernames in unit init so that a random spot is chosen? take for instance markers named "m1" and "m2". I tried altering your init script but to no avail. Thank you.^^ Wow sorry man I must have missed this. I've forgotten about this script...… That said. I've edited it that may be what youre looking for if youre still looking.... Here are my edits. Got a sample mission https://steamcommunity.com/sharedfiles/filedetails/?id=1965523583 MikesSP_Respawn.sqf Spoiler /* Instructions Call this in units init, groups init, trigger, or init.sqf so long as you have unit defined right! :P Rsp = [Unitsname,3,7, markername or object] execVM "MikesSP_Respawn.sqf"; Unitsname = unit you want to respawn 3 = how many times to respawn 7 = delay in respawn.... 5 is the least you can go it defaults to 5 seconds do to my cheasy effects. "markername" OBJECTNAME OR LEAVE BLANK = name of marker or object you put on map. or just use an Objects name without quotes. or leave blank. ***(THIS IS OPTINAL)*** example: .. unit init Rsp = [this,3,7,"markername"] execVM "MikesSP_Respawn.sqf"; .. groups init {Rsp = [_x,14,5] execVM "MikesSP_Respawn.sqf";} forEach (units this); <---- POSITION IS NOT NEEDED IF YOU WANT TO GO RANDOM ..... init.sqf if you want all Units {Rsp = [_x,30,15, MAYBE_A_SECTORS_NAME_OBJECTSNAME_MARKERSNAME_TRIGGERSNAME.....] execVM "MikesSP_Respawn.sqf";} forEach AllUnits */ if (!isDedicated && (player != player)) then { waitUntil {player == player}; waitUntil {time > 3}; }; private ["_dplayer","_type","_group","_times","_delay","_respPos"]; _dplayer = _this select 0; _dplayer setVariable ["MYloadout", (getUnitLoadout [_dplayer, true]), true]; _times = (_dplayer getVariable "times"); _dplayer setVariable ["Respawnplace1", (_this select 3), true]; if (isNil "_times") then {_times = _this select 1}; if (isNil "_times") then {_times = 3}; _delay = _this select 2; if (isNil "_delay") then {_delay = 5}; _type = typeOf _dplayer; _group = group _dplayer; _isLeader = (_dplayer getVariable "isLeader"); if (isNil "_isLeader") then {_isLeader = (_dplayer == (leader _group));}; _dplayer setVariable ["isLeader", _isLeader, true]; _dplayer setVariable ["times", _times, true]; _dplayer setVariable ["delayS", _delay, true]; Mis_respawn = { _dplayer = _this select 0; _isLeader = _this select 4; _killer = _this select 5; _respawn = (_dplayer getVariable "Respawnplace1"); _respPos = _respawn; if !(isNil "_respPos") then { if (typeName _respPos == "STRING") then {_respPos = getMarkerPos _respawn} else {_respPos = getPos _respawn}; } else { _distance = if ((_dplayer distance _killer) < 100) then {100} else {(_dplayer distance _killer)}; if (_distance > 200) then {_distance = 200}; _OtherUnit = if ({alive _x} count (units (group _dplayer)) >= 1) then { selectRandom (units (group _dplayer)) } else { _ortypos = _dplayer getPos [_distance,(_killer getDir _dplayer)]; [[[_ortypos, _distance]],["water"]] call BIS_fnc_randomPos; }; _trypos = _OtherUnit getPos [_distance,(_killer getDir _OtherUnit)]; _respPos1 = selectRandom ([_dplayer,_trypos] call compile preprocessFileLineNumbers "FOA_find_cover.sqf"); _respPos = if (isNil "_respPos1") then { _ortypos = _dplayer getPos [_distance,(_killer getDir _dplayer)]; [[[_ortypos, _distance]],["water"]] call BIS_fnc_randomPos; } else {_respPos1}; }; _dplayer setVariable ["Respawnplace", _respPos, true]; _dplayer setVariable ["isSPlayer", isPlayer _dplayer, true]; _Tgroup = createGroup Civilian; _temp = _Tgroup createUnit ["C_man_polo_6_F", getPos (_this select 0), [], 0, "NONE"]; _temp allowDammage false; hideObject _temp; addSwitchableUnit _temp; temp setpos _respawnplace; _temp enableSimulation false; if (_dplayer getVariable "isSPlayer") then { selectPlayer _temp; cutText ["Respawning","BLACK IN",3.5]; RSP_hndl = ppEffectCreate ["colorCorrections", 1501]; RSP_hndl ppEffectEnable true; RSP_hndl ppEffectAdjust [0, 0, 0, [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]; RSP_hndl ppEffectCommit 0; 0 fadeSound 0; 0 fadeRadio 0; 0 fadeSpeech 0; }; [_this select 0,_this select 1,_this select 2,_temp,_respPos,_respawn,_isLeader] spawn { params ["_dplayer","_type","_group","_temp","_respawnplace","_Respawn","_isLeader"]; [_dplayer] joinsilent grpNull; _delay = (_dplayer getVariable "delayS"); if (_delay < 5) then {_delay = 5}; _time = time + _delay; _times = (_dplayer getVariable "times"); _isplayer = (_dplayer getVariable "isSPlayer"); _isLeader = (_dplayer getVariable "isLeader"); if (_times == 0) exitWith { if (_isplayer) then {["epicFail",false,1] call BIS_fnc_endMission;} else {deleteVehicle _temp;}; }; if (isNil "_delay") then {_delay = time + 5;}; if (_isplayer) then {waitUntil {player == _temp};}; private "_player"; _player = _group createUnit [_type, (_dplayer getVariable "Respawnplace"), [], 0, "NONE"]; _player hideObject true; _player setVariable ["delayS", _delay, true]; _player setVariable ["delayT", _time, true]; _player setVariable ["times",_times - 1, true]; _player setVariable ["isSPlayer", _isplayer, true]; _player setVariable ["Respawnplace", _respawnplace, true]; _player allowDamage false; addSwitchableUnit _player; _player setUnconscious true; sleep (_delay); _player setUnitLoadout [(_dplayer getVariable "MYloadout"), true]; reload _player; _player allowDamage true; if (_isplayer) then {selectPlayer _player;waitUntil {player == _player};}; if (_isLeader) then { _player setVariable ["isLeader", _isLeader, true]; [_group,_player] spawn { params ["_group", "_player"]; [_player] joinsilent _group; _timer = time + ((_player distance (leader _group))/2); waitUntil {_player distance (leader _group) <= 15 || !alive _player || _timer <= time}; if (alive _player) then {_group selectLeader _player;}; }; }; deleteVehicle _temp; if (_this select 0 getVariable "isSPlayer") then { _lay1 = cutText ["gaining conscious", "BLACK IN", 15, true, false]; 25 fadeSound 1; 25 fadeRadio 1; 25 fadeSpeech 1; }; _player setUnconscious false; _player hideObject false; _respPos = nil; if (_isplayer) then {ppEffectDestroy RSP_hndl;}; [_player,(_player getVariable "times"),(_player getVariable "delayS"),(_dplayer getVariable "Respawnplace1")] execVM "MikesSP_Respawn.sqf"; }; true }; _dplayer removeAllEventHandlers "killed"; _dplayer addEventHandler ["killed", {[_this select 0,typeOf (_this select 0),group (_this select 0),_respawn,(_dplayer getVariable "isLeader"),(vehicle(_this select 1))] call Mis_respawn}]; FOA_find_cover.sqf Spoiler /* File: FOA_find_cover.sqf Author: Mikey74 Description: Function to find good cover positions exluding insects,footprints,men,feathers,pavement, leaflets, and roads. Yes nearestObjects will get those! Parameter(s): _this select 0: unit called for Note: you need a unit _this select 1: seperate position or unit needed if you dont want to search around units position. Use a position or another unit or vehicle. Note: you need a position or a unit this is optional Returns: Array of positions around objects near unit or position thats called the script. How to call: example 1: _cover_positions = [player, getPos nameoftarget(optional)] execVM "FOA_find_cover.sqf"; //if you put this in a sqf file. example 2: _cover_positions = [player, getPos nameoftarget(optional)] spawn FOA_find_cover; //if already precompile or your using FOA. TODO: add building positions. Should be easy enough. */ private ["_obj_positions","_unitpos","_pos","_towns"]; _obj_positions = []; _unit = _this select 0; _pos = _this select 1; if (isNil "_pos") then {_pos = getPos _unit};/// lets make sure we have some kind of position here. if (typeName _pos != "ARRAY") then {_pos = getPos _pos};/// lets make sure _pos is really a position. if not you will get an error or it just wont work. _radius = count units group _unit * 21;/// lets set a radius based on group size. _towns = nearestLocations [_pos, ["NameVillage","NameCity","NameCityCapital"], 200]; // finding towns close by if (count _towns > 0) then {_radius = count units group _unit * 7};/// you want a smaller radius for towns. ;) if (_radius < 21) then {_radius = 21};// minimum 21 _Roads = _unit nearRoads _radius;// find roads near _unit //_c = 0; { if ( !(_x iskindof "Insect") and // lets not use bugs for cover Animals !(_x iskindof "Animals") and // lets not use Animals for cover !(_x iskindof "Man") and // nor live men !(_x iskindof "EmptyDetector") and // nor triggers !((str _x) find "NOID " > -1) and //nor footprints or anything without an ID !((str _x) find ": cl_" > -1) and // nor any type of freather or leaves !((str _x) find ": pavement_" > -1) and // get rid of pavement type's !((str _x) find ": garbage_" > -1) and // cant hind behind leaflets on ground !(_x in _Roads) ) then { /// oh yeh lets not forget to exclude roads //_c = _c + 1; private "_obj"; _obj = _x; if (_obj isKindOf "Building") then { _posarray = [_obj] call BIS_fnc_buildingPositions; _obj_positions append _posarray } else { { _CPos = ((getPos _Obj) findEmptyPosition [0,3]); if (count _CPos == 3) then { _obj_positions pushBack _CPos; //_n = "Sign_Arrow_Large_Green_F" createVehicle _CPos; }; } forEach units group _unit; }; }; } forEach ((nearestTerrainObjects [_pos, ["bush","tree","wall","rock","SmallTree","Building","House","Church","Chapel","Bunker","Fortress","Fountain", "View-Tower","Lighthouse","Quay","Fuelstation","Hospital","Wall","Hide","BusStop","Transmitter", "Stack", "Ruin", "Watertower","Rocks"], _radius]) + (nearestObjects [_pos, ["Wreck","LANDVEHICLE"], _radius]));//nearestObjects [_pos, [], _radius]; /*{ _n = "Sign_Arrow_Large_Green_F" createVehicle _x; } forEach _obj_positions;*/ _obj_positions; https://www.youtube.com/watch?v=42qCaSH_FsI Enjoy 1 Share this post Link to post Share on other sites