dlegion 98 Posted July 9, 2018 (edited) hello guys, i've run into a strange problem and really have no idea where start to look for a solution! i've my big function container (its a big read, i post it just for the records...): Spoiler ///////////////////////////////////////////////////////////////////////////////////////////////////// // call compile preprocessFileLineNumbers "DdualWeapon.sqf"; >> in initSERVER.sqf to compile functions // can be useful...ADDACTION with all useful options: //this addAction ["<t color='#FD9006'>SAVE LOADOUT</t>", {[player, [missionNamespace, "inventory_var"]] call BIS_fnc_saveInventory; hintSilent "Loadout saved";}, "", 12, false, false, "", "",2,false]; ///////////////////////////////////////////////////////// DFN_dakka = { private _Dveh = _this select 0; while {(count crew _Dveh > 0) && !isPlayer (driver _Dveh)} do {uiSleep 60;_Dveh setVehicleAmmo 1}; // while {faction (driver _Dveh) == "IND_F"} do {uiSleep 60;_Dveh setVehicleAmmo 1}; }; //////////////////////////////////////////////////////// D_empty = { private _veh = _this select 0; waituntil {!alive driver _veh }; uiSleep 3; deletevehicle _veh; }; //////////////////////////////////////////////////////// DFN_occupy = { _Dpos = _this select 0; _Dgroup = _this select 1; _HhouseSok = []; _HhouseS = nearestObjects [_Dpos, ["house"], 250, TRUE]; {_nearBp = _x buildingPos -1;_nearBpp = count _nearBp;if (_nearBpp > 2) then {_HhouseSok pushBack _x};} forEach (_HhouseS - [GMO]); _HHn = count _HhouseSok; if (_HHn > 0) then { _nearB = selectRandom _HhouseSok; // {_x disableAI "PATH"} forEach _Dgroup; (_Dgroup select 0) setPosATL (_nearB buildingPos 0); (_Dgroup select 1) setPosATL (_nearB buildingPos 1); }; }; ///////////////////////////////////////////////////////// DFN_Patrol = { private _grp = _this select 0; private _pos = _this select 1; private _maxDist = _this select 2; private _Dry = _this select 3; private _Dspeed = _this select 4; //uiSleep 1; _grp setBehaviour "AWARE"; //Create a string of randomly placed waypoints. private ["_prevPos"]; _prevPos = _pos; for "_i" from 0 to (1 + (floor (random 3))) do //was for "_i" from 0 to (2 + (floor (random 3))) do { private ["_wp", "_newPos"]; _newPos = [_prevPos, 150, _maxDist, 0.5, _Dry, 0.3, 0] call BIS_fnc_findSafePos; //D 2 = must be in water (0 = land) private _prevPos = _newPos; _wp = _grp addWaypoint [_newPos, 0]; _wp setWaypointType "MOVE"; _wp setWaypointCompletionRadius 200; //Set the group's speed and formation at the first waypoint. if (_i == 0) then { _wp setWaypointSpeed _Dspeed; //or LIMITED or FULL _wp setWaypointFormation "COLUMN"; }; _grp setBehaviour "SAFE"; }; //Cycle back to the first position. private ["_wp"]; _wp = _grp addWaypoint [_pos, 0]; _wp setWaypointType "CYCLE"; _wp setWaypointCompletionRadius 200; _grp = nil; _pos = nil; _maxDist = nil; _Dry = nil; _Dspeed = nil; _i = nil; _newPos = nil; _prevPos = nil; _wp = nil; true }; ///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// Drandomizer = { // send me an object and I will randomise its texture and global it params ["_obj"]; private ["_textures","_mytexturelist","_texturesources"]; switch (true) do { default// everything else, grab all the available texs and choose one at random { _mytexturelist = (getArray (configFile/"CfgVehicles"/typeOf _obj/"texturelist")) select {typeName _x isEqualTo "STRING"};// array also contains numbers, remove them _texturesources = []; if (not (_mytexturelist isEqualTo [])) then { { _texturesources pushback ((getArray (configFile/"CfgVehicles"/typeOf _obj/"texturesources"/_x/"textures")) select 0); }foreach _mytexturelist; if (not (isnil "_texturesources")) then { _obj setObjectTextureGlobal [0,selectRandom _texturesources]; }; }; }; }; }; /////////////////////////////////////////////////////////////////// allahBOOM = { // null = [this] spawn allahBOOM; // in unit init run script , and obviously the music file in the MUSIC folder! if (isServer) then { //So far, this is my favourite. MISSION_ROOT can be defined in description.ext. missionConfigFile just doesn’t work this early, but __FILE__ does! //description.ext //__EXEC (MISSION_ROOT = __FILE__ select [0, count __FILE__ - 15]) //from any script //_root = parsingNamespace getVariable "MISSION_ROOT"; _activDistance = 70; // 100m , can be manually adjusted _Tside = west; // first side of enemy to blowup _Tside2 = east; // second side of enemy to blowup _Tside3 = east; // third side of enemy to blowup (if less sides are wanted,just repeat the same side once or twice) uiSleep 2; _S1 = (_this select 0); _S1 setbehaviour "CARELESS"; _S1 setSpeedMode "FULL"; _S1 disableAI "FSM"; _S1 setSkill 1; _S1 setAnimSpeedCoef 2; _BLUpos = (getpos _S1); _BOOM = FALSE; _BLUnear = []; _root = parsingNamespace getVariable "MISSION_ROOT"; _S1 addVest "V_TacChestRig_grn_F"; //_soundPath = [(str missionConfigFile), 0, -15] call BIS_fnc_trimString; _soundToPlay = _root + "music\allah.ogg"; while {alive _S1} do { uiSleep 2; _BLUnear = []; {if ((_x distance2D _S1) < _activDistance && alive _x && ((side _x == _Tside) || (side _x == _Tside2) || (side _x == _Tside3))) then {_BLUnear pushBack _x}} foreach allUnits; if ((count _BLUnear) > 0) then {_BLUpos = getpos (selectRandom _BLUnear);{_S1 reveal [_x,4]} foreach _BLUnear;_S1 domove _BLUpos;_S1 setSpeedMode "FULL";playSound3D [_soundTOplay,_S1, false,(getpos _S1), 10, 1, 150]}; {if ((_S1 distance _x) < 12 || !alive _S1) then {_BOOM = TRUE}} forEach _BLUnear; if (_BOOM) then {_Dbomb1 = "DemoCharge_Remote_Ammo_Scripted" createVehicle (getPos _S1);_Dbomb1 setDamage 1;playMusic ["02",15];}; }; }; }; //////////////////////////////////////////////////////////////////////// freeH = { if (isServer) then { _H1 = (_this select 0); // hostage with action _hero = (_this select 1); // player who use action to rescue _H1 setVariable ["Hrescued",TRUE,false]; _H1 enableAI "ANIM"; _H1 switchMove "Acts_ExecutionVictim_Unbow"; [_H1] joinsilent (group _hero); _H1 setCaptive FALSE; doStop _H1; format ["HOSTAGES are being rescued! If they reach HQ they will be safe!"] remoteExecCall ["hint"]; if (!alive _H1) then {format ["This HOSTAGE is DEAD!"] remoteExecCall ["hint"];}; Hsafe = TRUE; }; }; ///////////////////////////////////////////////////////////////////////// _Dveh = cursorObject; _Dman = (_this select 1); _Dcrew = crew _Dveh; _DcrewALIVE = []; _SIDEcrew = side _Dman; if ((_Dveh distance _Dman) < 8) then { {if (alive _x) then {_DcrewALIVE pushBack _x};} foreach _Dcrew; if ((count _DcrewALIVE) > 0) then {_crew = selectrandom _DcrewALIVE;_SIDEcrew = (side _crew)}; if ((count _DcrewALIVE) < 1 || _SIDEcrew == (side _Dman)) then {_Dman moveInAny _Dveh}; }; }; ////////////////////////////////////////////////////////////////////////// Gwave = { if (isServer) then { uiSleep 1; if (!((Dsector getVariable "owner") == INDEPENDENT)) then { {if ((side _x) == independent) then {_x move (getpos GMO);_x setSpeedMode "FULL";_x setBehaviour "AWARE"}} forEach allUnits; format ["DEFEND MAIN OBJECTIVE FROM A GREEN WAVE!(5 min left)"] remoteExecCall ["hint"]; // fa muovere AI (tutti) verso Darea uiSleep 1; {if ((side _x) == independent && _x isKindOf "CAManBase" ) then {_x domove (GMO buildingPos (selectRandom [0,2,3,4,5]));_x setSpeedMode "FULL";_x setBehaviour "AWARE"}} forEach allUnits; }; uiSLeep 60; uiSleep 1; if (!((Dsector getVariable "owner") == INDEPENDENT)) then { {if ((side _x) == independent) then {_x move (getpos GMO);_x setSpeedMode "FULL";_x setBehaviour "AWARE"}} forEach allUnits; format ["DEFEND MAIN OBJECTIVE FROM A GREEN WAVE!(4 min left)"] remoteExecCall ["hint"]; // fa muovere AI (tutti) verso Darea uiSleep 1; {if ((side _x) == independent && _x isKindOf "CAManBase" ) then {_x domove (GMO buildingPos (selectRandom [0,2,3,4,5]));_x setSpeedMode "FULL";_x setBehaviour "AWARE"}} forEach allUnits; }; uiSLeep 60; uiSleep 1; if (!((Dsector getVariable "owner") == INDEPENDENT)) then { {if ((side _x) == independent) then {_x move (getpos GMO);_x setSpeedMode "FULL";_x setBehaviour "AWARE"}} forEach allUnits; format ["DEFEND MAIN OBJECTIVE FROM A GREEN WAVE!(3 min left)"] remoteExecCall ["hint"]; // fa muovere AI (tutti) verso Darea uiSleep 1; {if ((side _x) == independent && _x isKindOf "CAManBase" ) then {_x domove (GMO buildingPos (selectRandom [0,2,3,4,5]));_x setSpeedMode "FULL";_x setBehaviour "AWARE"}} forEach allUnits; }; }; }; ////////////////////////////////////////////////////////////////////////////// HALOjump = { if (isServer) then { _unit = _this select 1; hint "Click on map to perform a Halo Insertion"; openMap true; clicked = 0; onMapSingleClick "player setpos [_pos select 0, _pos select 1, 9000]; clicked = 1; openMap false;; openmap false;onMapSingleClick ''; true;"; waitUntil {sleep 1;clicked == 1}; "H.A.L.O. jump detected!" remoteExecCall ["hint"]; _backpackItems = backpackItems _unit; {_unit removeItemFromBackpack _x} forEach _backpackItems; _currentBackpack = backpack _unit; removeBackpack _unit; _unit addBackpack "B_Parachute"; waitUntil {sleep 2;(isTouchingGround _unit)}; //if (isNil _currentBackpack) then { // These three lines check to see if the unit had a backpack or not at the beginning of the jump // removeBackpack _unit; // If they had a backpack it is restored in the code below these 3 lines //}; // If they had no backpack then these 3 lines remove the parachute so you are back to no backpack uiSleep 1; removeBackpack _unit; uiSleep 1; _unit addBackpack _currentBackpack; _newBackpackItems = backpackItems _unit; {_unit removeItemFromBackpack _x} forEach _newBackpackItems; uiSleep 1; {_unit addItemToBackpack _x} forEach _backpackItems; sleep 2; ///////////////below here enable if want also AI in player squad use HALO /* { if (!isPlayer _x) then { _x setPos (getPos _unit); }; } forEach units group _unit; */ }; }; /////////////////////////////////////////////////////////////////////////////// reSPAWNER = { //null = [this] spawn reSPAWNER; in vehicle init (maybe works with units too) if (isServer) then { ///// MANUAL SETTINGS//////////////////////// //_Dtype = ["B_plane_CAS_01_dynamicLoadout_F"]; // sets the kind of unit to respawn "B_Heli_Transport_01_F","B_plane_CAS_01_dynamicLoadout_F" _Dtype = (getDescription (_this select 0)) select 0; _Darea = airport; // set the object to patrol around _delayS = 30; // sets delay from vehicle death and next vehicle respawn, suggested 30 secs, 5 minutes to punish aircraft loss _delayC = 15; // sets the delay between death checks of vehicle, for performance use higher numbers, suggested 30 //////////////////////////////////// _Dunit = (_this select 0); _Dpilot = driver _Dunit; _Dcrew = crew _Dunit; _Dpos = (getpos _Dunit); _Ddir = (getDir _Dunit); _Dside = side _Dunit; _CREWdead = FALSE; while {alive _Dunit} do { uiSleep _delayC; _DcrewALIVE = []; {if (alive _x && (vehicle _x) != _Dunit) then {_DcrewALIVE pushback _x}} foreach _Dcrew; if ((count _DcrewALIVE) > 0) then {uiSleep _delayC;_Dunit setDamage 1;{null = [_x] spawn SIDErescue; };} foreach _DcrewALIVE; uiSleep 1; }; //hint "REspawning!"; uiSleep _delayS; _grpDveh = [_Dpos,_Dside,[_Dtype],[],[],[],[],[],_Ddir] call BIS_fnc_spawnGroup; _pilot = leader _grpDveh; _Dunit = vehicle _pilot; null = [_Dunit] spawn reSPAWNER; [_grpDveh,(getpos _Darea), 9000,1,"NORMAL"] call DFN_Patrol; _grpDveh move (getpos _Darea); }; }; ///////////////////////////////////////////////////// SIDEhostages = { // nul = [] spawn SIDEhostages; // to activate the script. must be present 2 markers named "hostages1" and "hostages2" , a game logic named "NOplace" and an object named "GMO", and uses a script named "freeH.sqf" if (isServer) then { _Drange = 50; {if !(isNil {_x getVariable "Hdelete"}) then {deleteVehicle _x;}} foreach allUnits; {if !(isNil {_x getVariable "Hdelete"}) then {deleteVehicle _x;}} foreach vehicles; "hostages1" setmarkerpos getpos NOplace; "hostages2" setmarkerpos getpos NOplace; format ["HOSTAGES are being used as human shields at main OBJECTIVE! Bring them alive to main HQ to save them!(50min)"] remoteExecCall ["hint"]; ["TaskAssigned",["","HOSTAGES are being used as human shields at main OBJECTIVE! Bring them alive to main HQ to save them!(50min to save them from execution, unlimited time to bring them to HQ)"]] remoteExec ["bis_fnc_showNotification"]; _RGveh = selectRandom ["I_APC_wheeled_03_cannon_F","I_APC_tracked_03_cannon_F","I_MRAP_03_hmg_F","I_MBT_03_cannon_F","O_T_APC_Tracked_02_AA_ghex_F"]; // types of vehicles _Ga3 = [[GMO, 20, _Drange, 15, 0, 0.3, 0] call BIS_fnc_findSafePos,INDEPENDENT,[_RGveh]] call BIS_fnc_spawnGroup; {_x setVariable ["Hdelete",TRUE,false];} forEach (units _ga3); {(vehicle _x) setVariable ["Hdelete",TRUE,false];} forEach (units _Ga3); _Ga3 deleteGroupWhenEmpty true; _Gveh3 = vehicle leader _Ga3; _crewGveh3 = crew _Gveh3; [_Ga3, getPos GMO,200,0,"FULL"] call DFN_Patrol; _victim = [[GMO, 20, _Drange, 15, 0, 0.3, 0] call BIS_fnc_findSafePos, EAST, ["I_Fighter_Pilot_F","I_Fighter_Pilot_F"]] call BIS_fnc_spawnGroup; _victim deleteGroupWhenEmpty true; _victimS = (units _victim); _H1 = (_victimS select 0); _H2 = (_victimS select 1); {_x setVariable ["Hdelete",TRUE,false];} forEach (units _victim); {_x setCaptive TRUE;_x setVariable ["Hrescued",FALSE,false];_x switchMove "Acts_ExecutionVictim_Loop"; sleep 0.1;_x disableAI "ANIM";_x allowFleeing 0;removeallweapons _x;removeHeadgear _x;} forEach _victimS; {_x addAction ["<t color='#ffff00'>FREE HOSTAGE</t> ","DDscripts\freeH.sqf", "", 12, false, false, "", "",2.3];} forEach _victimS; _troops = "(getNumber (_x >> 'scope') == 2) and {(getNumber (_x >> 'side') == 2)} and {configName _x isKindOf 'CAManBase'}" configClasses (configFile >> "CfgVehicles"); _troop1 = selectrandom _troops;_Dtype1 = configName _troop1; _troop2 = selectrandom _troops;_Dtype2 = configName _troop2; _troop3 = selectrandom _troops;_Dtype3 = configName _troop3; _troop4 = selectrandom _troops;_Dtype4 = configName _troop4; _Guards = [(getpos _H1),INDEPENDENT,[_Dtype1,_Dtype2,_Dtype3,_Dtype4]] call BIS_fnc_spawnGroup; {_x setVariable ["Hdelete",TRUE,false];} forEach (units _Guards); _GuardsA = (units _Guards); _Guards deleteGroupWhenEmpty true; _HhouseSok = []; _HhouseS = nearestObjects [GMO, ["house"], _Drange, TRUE]; {_nearBp = _x buildingPos -1;_nearBpp = count _nearBp;if (_nearBpp > 4) then {_HhouseSok pushBack _x};} forEach (_HhouseS - [GMO]); _HHn = count _HhouseSok; if (_HHn > 0) then { _nearB = selectRandom _HhouseSok; {_x disableAI "PATH"} forEach _GuardsA; (_GuardsA select 0) setPosATL (_nearB buildingPos 0); (_GuardsA select 1) setPosATL (_nearB buildingPos 1); (_GuardsA select 2) setPosATL (_nearB buildingPos 2); (_GuardsA select 3) setPosATL (_nearB buildingPos 3); _H1 setPosATL (_nearB buildingPos (selectRandom [0,1])); _H2 setPosATL (_nearB buildingPos (selectRandom [2,3])); }; _timeOver = diag_tickTime +60; // +3060 = 51 minutes Hsafe = FALSE; waitUntil {uiSleep 5;Hsafe || (!alive _H1 && !alive _H2) || diag_tickTime >= _timeOver}; if ((_H1 getVariable "Hrescued") || (_H2 getVariable "Hrescued")) then {_Hsafe = TRUE;_H1 setCaptive FALSE;_H2 setCaptive FALSE;}; if (diag_tickTime >= _timeOver) then { format ["Too late...HOSTAGES declared K.I.A."] remoteExecCall ["hint"]; ["TaskAssigned",["","Too late...HOSTAGES declared K.I.A."]] remoteExec ["bis_fnc_showNotification"]; {if !(isNil {_x getVariable "Hdelete"}) then {deleteVehicle _x;}} foreach allUnits; {if !(isNil {_x getVariable "Hdelete"}) then {deleteVehicle _x;}} foreach vehicles; }; if (!alive _H1 && !alive _H2) then { format ["HOSTAGES DIED! RESCUE FAILED!"] remoteExecCall ["hint"]; ["TaskAssigned",["","HOSTAGES DIED! RESCUE FAILED!"]] remoteExec ["bis_fnc_showNotification"]; {if !(isNil {_x getVariable "Hdelete"}) then {deleteVehicle _x;}} foreach allUnits; {if !(isNil {_x getVariable "Hdelete"}) then {deleteVehicle _x;}} foreach vehicles; }; null = [_H1] spawn {while {alive (_this select 0)} do {"hostages1" setmarkerpos getpos (_this select 0); sleep 9;};}; null = [_H2] spawn {while {alive (_this select 0)} do {"hostages2" setmarkerpos getpos (_this select 0); sleep 11;};}; waitUntil {uiSleep 12;(_H1 distance REDhq) < 100 || (_H2 distance REDhq) < 100 || (_H1 distance BLUhq) < 100 || (_H2 distance BLUhq) < 100 || (!alive _H1 && !alive _H2)}; if ((_H1 distance REDhq) < 100) then {format ["HOSTAGE SAVED BY RED!"] remoteExecCall ["hint"];}; if ((_H2 distance REDhq) < 100) then {format ["HOSTAGE SAVED BY RED!"] remoteExecCall ["hint"];}; if ((_H1 distance BLUhq) < 100) then {format ["HOSTAGE SAVED BY BLU!"] remoteExecCall ["hint"];}; if ((_H1 distance BLUhq) < 100) then {format ["HOSTAGE SAVED BY BLU!"] remoteExecCall ["hint"];}; if (!alive _H1 && !alive _H2) then {format ["HOSTAGES DIED!"] remoteExecCall ["hint"];["TaskAssigned",["","HOSTAGES DIED! RESCUE FAILED!"]] remoteExec ["bis_fnc_showNotification"];}; {if !(isNil {_x getVariable "Hdelete"}) then {deleteVehicle _x;}} foreach allUnits; {if !(isNil {_x getVariable "Hdelete"}) then {deleteVehicle _x;}} foreach vehicles; "hostages1" setmarkerpos getpos NOplace; "hostages2" setmarkerpos getpos NOplace; }; }; //////////////////////////////////////////////////////////////////////////// SIDErescue = { // script used by reSPAWNER.sqf, to add side quests of rescue pilots, can be used by itself if needed if (isServer) then { _BLUp = FALSE; _REDp = FALSE; _check = TRUE; while {_check} do { uiSleep 9; _isOnFoot = isNull objectParent (_this select 0); if (_isOnFoot) then {if ((isTouchingGround (_this select 0)) && (alive (_this select 0))) then { format ["S.O.S. from downed pilot at %1",mapGridPosition (_this select 0)] remoteExecCall ["hint"]; ["TaskAssigned",["",format ["S.O.S. from downed pilot at %1",mapGridPosition (_this select 0)]]] remoteExec ["bis_fnc_showNotification"]; if (faction (_this select 0) == "BLU_F") then {(_this select 0) move (getpos BLUhq);(_this select 0) setSpeedMode "NORMAL";(_this select 0) setBehaviour "AWARE";_BLUp = true;}; if (faction (_this select 0) == "OPF_F") then {(_this select 0) move (getpos REDhq);(_this select 0) setSpeedMode "NORMAL";(_this select 0) setBehaviour "AWARE";_REDp = true;}; while {(count (waypoints (group (_this select 0)))) > 0} do {deleteWaypoint ((waypoints _group) select 0);}; _check = FALSE; }; }; (_this select 0) addaction ["<t color='#FF0000'>CAPTURE</t>", {[(_this select 0)] joinsilent (group (_this select 1))},"",6,FALSE,FALSE,"","TRUE",9]; waituntil {sleep 20;(alive (_this select 0) && (_this select 0) distance BLUhq < 100 ) || (alive (_this select 0) && (_this select 0) distance REDhq < 100) || !alive (_this select 0)}; uiSleep 20; if (_BLUp && !(alive (_this select 0))) then {format ["BLU pilot DIED!"] remoteExecCall ["hint"];["TaskAssigned",["",format ["BLU pilot DIED!"]]] remoteExec ["bis_fnc_showNotification"];deletevehicle (_this select 0);}; if (_REDp && !(alive (_this select 0))) then {format ["RED pilot DIED!"] remoteExecCall ["hint"];["TaskAssigned",["",format ["RED pilot DIED!"]]] remoteExec ["bis_fnc_showNotification"];deletevehicle (_this select 0);}; if (_BLUp && ((_this select 0) distance REDhq < 100)) then {format ["BLU pilot captured by RED!"] remoteExecCall ["hint"];["TaskAssigned",["",format ["BLU pilot captured by RED!"]]] remoteExec ["bis_fnc_showNotification"];deletevehicle (_this select 0);nul = [] spawn SIDEhostages;}; if (_BLUp && ((_this select 0) distance BLUhq < 100)) then {format ["BLU pilot saved by BLU!"] remoteExecCall ["hint"];["TaskAssigned",["",format ["BLU pilot saved by BLU!"]]] remoteExec ["bis_fnc_showNotification"];deletevehicle (_this select 0);}; if (_REDp && ((_this select 0) distance BLUhq < 100)) then {format ["RED pilot captured by BLU!"] remoteExecCall ["hint"];["TaskAssigned",["",format ["RED pilot captured by BLU!"]]] remoteExec ["bis_fnc_showNotification"];deletevehicle (_this select 0);nul = []spawn SIDEhostages;}; if (_REDp && ((_this select 0) distance REDhq < 100)) then {format ["RED pilot saved by RED!"] remoteExecCall ["hint"];["TaskAssigned",["",format ["RED pilot saved by RED!"]]] remoteExec ["bis_fnc_showNotification"];deletevehicle (_this select 0);}; uiSLeep 1; deletevehicle (_this select 0); }; }; }; ////////////////////////////////////////////////////////////////////////////// SNIPE = { // null = [this] spawn SNIPE; // in unit init to run script. for best result, use a sniper with M320 LRR .408 rifle and LRPS optic //(yes, even at night and in a rainstorm...it should hit 1 man in 1 minute of shooting at 2000m) if (isServer) then { /* Parameter(s): 0: [OBJECT] - Object who is 'looking' 1: [OBJECT] - Object to look for 2: [NUMBER] - Looker's FOV (OPTIONAL) DEFAULT (70) Returns: [BOOLEAN] */ Dlos = { params [["_looker",objNull,[objNull]],["_target",objNull,[objNull]],["_FOV",70,[0]]]; if ([position _looker, getdir _looker, _FOV, position _target] call BIS_fnc_inAngleSector) then { if (count (lineIntersectsSurfaces [(AGLtoASL (_looker modelToWorldVisual (_looker selectionPosition "pilot"))), getPosASL _target, _target, _looker, true, 1,"GEOM","NONE"]) > 0) exitWith {false}; true } else { false }; }; _Tside = west; // manually define ENEMY side to shoot at _Tside2 = east; // manually define ENEMY side to shoot at (if just 1 enemy side needed, place the same side on both _Tside and _Tside2 _S1 = (_this select 0); _S1 disableAI "PATH"; _S1 setUnitPos "DOWN"; _S1 disableAI "AIMINGERROR"; //_S1 disableAI "FSM"; _S1 setSkill 1; while {true} do { _Dtargets = []; {if ((_x distance2D _S1) < 2000 && ((side _x == _Tside) || (side _x == _Tside2)) && (alive _x)) then {_S1 reveal [_x,4];_Dtargets pushBack _x}} forEach allunits; _Tcount = count _Dtargets; if (_Tcount > 0) then {_Target = (selectRandom _Dtargets);_S1 doTarget _Target;_S1 doSuppressiveFire _Target;uiSleep 0;if ([_S1, _Target] call Dlos) then {_S1 forceWeaponFire [(currentWeapon _S1), "Single"];};}; _S1 setVehicleAmmo 1; uiSleep 5; }; }; }; ///////////////////////////////////////////////////////////////////////// SPAWNERciv = { //nul = [] spawn SPAWNERciv; >> in initSERVER.sqf to run script. it include a "delete if too far" code, shared with other side factions, like SPAWNERind.sqf if (isServer) then { //////// MANUAL SETTINGS //////// uiSleep 1; // to not overlap SPAWNERind.sqf _MaxUnits = 30; // number of units to spawn _loop = 2; // time between 1 spawn and next one, for more performance use higher number _allahBOOM = TRUE; // spawn also random civilian kamikaze, 1 out 12 infantry civilians, it need the script "allahBOOM.sqf" in the main mission folder _MinDistMEN = 300; // minimum distance to players for MEN, number in meters _MaxDistMEN = 500; // maximum distance to players for MEN, number in meters //_MinDistDIVER = 20; // minimum distance to players for MEN, number in meters //_MaxDistDIVER = 40; // maximum distance to players for MEN, number in meters _MinDistLAND = 1000; // minimum distance to players for LAND VEHICLES, number in meters _MaxDistLAND = 3000; // maximum distance to players for LAND VEHICLES, number in meters _MinDistAIR = 3000; // minimum distance to players for AIR, number in meters _MaxDistAIR = 9000; // maximum distance to players for AIR, number in meters _MinDistSHIP = 2000; // minimum distance to players for BOATs, number in meters _MaxDistSHIP = 4000; // maximum distance to players for BOATs, number in meters _Dside = civilian; // the side faction of spawned unit, can be WEST, EAST, INDEPENDENT, CIVILIAN //////////////////END OF MANUAL SETTINGS, DO NOT EDIT UNDER THIS LINE//////////////////////////////////////// _MinDist = 300; _MaxDist = 800; _OnWater = 0; // spawn on land OR water, 0 on land, 2 on water , 1 water or land _DtypeA =[]; //_Dtype = "I_MRAP_03_hmg_F"; // the type of unit to spawn, can be more than 1, for example: "I_MRAP_03_hmg_F","I_MRAP_03_hmg_F" , AIR, SHIP, LAND (subType CAManBase), _allcivs = "(getNumber (_x >> 'scope') == 2) and {(getNumber (_x >> 'side') == 3)} and {configName _x isKindOf 'allVehicles'}" configClasses (configFile >> "CfgVehicles"); while {true} do { uiSleep _loop; // for more performance use higher number _ALLspawned = []; _allahCALL = FALSE; {if (!isNil {_x getVariable "FARdelete"} && side _x == _Dside) then {_ALLspawned pushBack _x};} forEach allUnits; _activeUnits = count _ALLspawned; if (_activeUnits < _MaxUnits && (count playableUnits) > 0) then { _DtypeN = selectRandom _allcivs;_Dtype = configName _DtypeN;_DtypeA = [_Dtype]; // if (_Dtype isKindOf "I_diver_F" || _Dtype isKindOf "I_diver_TL_F" || _Dtype isKindOf "I_diver_exp_F") then {_MinDist = _MinDistDIVER;_MaxDist = _MaxDistDIVER;_DtypeA = [_Dtype];_Gs2 = selectRandom ["I_diver_F","I_diver_exp_F"];_DtypeA append [_Gs2];_Dtype = "I_boat_armed_01_minigun_F";}; if (_Dtype isKindOf "LAND") then {_OnWater = 0;_MinDist = _MinDistLAND;_MaxDist = _MaxDistLAND;if (_Dtype isKindOf "CAManBase") then {if ((selectRandom [1,2,3,4,5,6,7,8,9,10,11,12]) == 1) then {_allahCALL = TRUE};_MinDist = _MinDistMEN;_MaxDist = _MaxDistMEN;_DtypeA = [_Dtype];_Gs2 = selectRandom ["C_man_1_1_F","C_man_polo_1_F","C_man_polo_6_F" ];_DtypeA append [_Gs2];};}; if (_Dtype isKindOf "AIR") then {_OnWater = 1;_MinDist = _MinDistAIR;_MaxDist = _MaxDistAIR;}; if (_Dtype isKindOf "SHIP") then {_OnWater = 2;_MinDist = _MinDistSHIP;_MaxDist = _MaxDistSHIP;}; randomplayer = selectRandom playableUnits; randomplayerpos = getPos randomplayer; _posBlacklist = playableUnits apply {[_x,_MinDist]}; _grpDveh = [[randomplayerpos, _MinDist, _MaxDist, 10, _OnWater, 0.3, 0,_posBlacklist] call BIS_fnc_findSafePos,_Dside,_DtypeA] call BIS_fnc_spawnGroup; // SPAWNER _grpDveh deleteGroupWhenEmpty true; {_x setVariable ["FARdelete",_MaxDist,false];} forEach (units _grpDveh); {(vehicle _X) setVariable ["FARdelete",_MaxDist,false];} forEach (units _grpDveh); _UnitLeader = leader _grpDveh; _Rn = selectRandom [1,2,3,4,5]; // to decide if move or stay and if garrison building or not if (_Dtype isKindOf "CAManBase" && _Rn > 3) then {[(getpos _unitLeader),(units _grpDveh)] call DFN_occupy;{_x disableAI "PATH"} forEach (units _grpDveh);}; if (_Rn > 1) then {[_grpDveh,(getpos _unitLeader), 9000,_OnWater,(selectRandom ["FULL","LIMITED"])] call DFN_Patrol;}; if (_allahCALL && _allahBOOM) then {_suicider = leader _grpDveh;null = [_suicider] spawn allahBOOM;}; }; {uiSleep 0.1;if !(isNil {_x getVariable "FARdelete"}) then {if (_x distance ({_x} foreach allplayers) > (_x getVariable "FARdelete")) then {deleteVehicle _x;}}} foreach allUnits; {uiSleep 0.1;if !(isNil {_x getVariable "FARdelete"}) then {if (_x distance ({_x} foreach allplayers) > (_x getVariable "FARdelete")) then {deleteVehicle _x;}}} foreach vehicles; }; }; }; ///////////////////////////////////////////////////////////////////////////////////////////// SPAWNERconvoyB = { //nul = [] spawn SPAWNERconvoyB; >> in initSERVER.sqf to run script, MUST place in 3D editor 2 objects: Darea and bluH if (isServer) then { //////// MANUAL SETTINGS //////// _loop = 30; // time between 1 spawn and next one, for more performance use higher number _Dside = west; // the side faction of spawned unit, can be WEST, EAST, INDEPENDENT, CIVILIAN _Destination = Darea; // first destination of the spawned convoy _SPAWNplace = getpos bluH; // place where convoy will spawn //////////////////END OF MANUAL SETTINGS, DO NOT EDIT UNDER THIS LINE//////////////////////////////////////// _spawnCONVOY = TRUE; _DvehS = []; _DcrewS = []; //_allWEST = "(getNumber (_x >> 'scope') == 2) and {(getNumber (_x >> 'side') == 0)}" configClasses (configFile >> "CfgVehicles"); _allWEST = "getNumber (_x >> 'side') isEqualTo 1 AND (configName _x isKindOf 'tank' || configName _x isKindOf 'car') AND getNumber (_x >> 'scope') == 2" configClasses (configFile >> "CfgVehicles"); // _allWEST = "getNumber (_x >> 'side') isEqualTo 1 AND {getText (_x >> 'vehicleClass') in ['Armored', 'Car'] AND getNumber (_x >> 'scope') == 2" configClasses (configFile >> "CfgVehicles"); while {true} do { uiSleep _loop; // for more performance use higher number if (_spawnCONVOY) then { _DtypeN = selectRandom _allWEST;_Dtype1 = configName _DtypeN;_DtypeA = ["B_APC_tracked_01_AA_F"]; // can be random _Dtype1 or manually selected like "B_APC_tracked_01_AA_F" OR "O_APC_tracked_02_AA_F" ecc.. _DtypeN = selectRandom _allWEST;_Dtype2 = configName _DtypeN;_DtypeA append [_Dtype2]; _DtypeN = selectRandom _allWEST;_Dtype3 = configName _DtypeN;_DtypeA append [_Dtype3]; _grpDveh = [[_SPAWNplace, 0, 20, 10, 0, 0.3, 0] call BIS_fnc_findSafePos,_Dside,_DtypeA,[[0,0,0],[0,20,0],[20,0,0]],[],[],[],[],180] call BIS_fnc_spawnGroup; // SPAWNER _spawnCONVOY = FALSE; {_Dveh = vehicle _x;_inArray = _Dveh in _Dvehs;if (not _inArray and {_Dveh != _x}) then {_Dvehs set [count _Dvehs, _Dveh];};} forEach (units _grpDveh); // re-define _DvehS _DcrewS = units _grpDveh; _grpDveh deleteGroupWhenEmpty true; {_x setVariable ["BconvoyDEL",true,false];} forEach (units _grpDveh); {(vehicle _X) setVariable ["BconvoyDEL",true,false];} forEach (units _grpDveh); [_grpDveh,(getpos _Destination), 9000,0,"FULL"] call DFN_Patrol; // PATROL {_x DoMove (getpos _Destination)} forEach (units _grpDveh); _grpDveh setFormation "COLUMN"; }; _DN = count _DvehS; _ALLvehDEAD = TRUE; _ALLcrewDEAD = TRUE; {if (alive _x) then {_ALLcrewDEAD = FALSE}} forEach _DcrewS; {if (alive _x) then {_ALLvehDEAD = FALSE}} forEach _Dvehs; if (_ALLvehDEAD || _ALLcrewDEAD) then {{if !(isNil {_x getVariable "BconvoyDEL"}) then {deleteVehicle _x}} foreach allunits;{if !(isNil {_x getVariable "BconvoyDEL"}) then {deleteVehicle _x}} foreach vehicles;_DvehS = [];_spawnCONVOY = TRUE; str (_Dn) + " vehicles in BLU convoy moving to AIRPORT!" remoteExecCall ["hint"];["TaskAssigned",["","BLU convoy moving to AIRPORT!"]] remoteExec ["bis_fnc_showNotification"];}; // format ["BLUE convoy moving to AIRPORT!"] remoteExecCall ["hint"]; }; }; }; //////////////////////////////////////////////////////////////////////////////////////// SPAWNERconvoyR = { //nul = [] spawn SPAWNERconvoyR; >> in initSERVER.sqf to run script, MUST place in 3D editor 2 objects: Darea and redH if (isServer) then { //////// MANUAL SETTINGS //////// _loop = 29; // time between 1 spawn and next one, for more performance use higher number _Dside = east; // the side faction of spawned unit, can be WEST, EAST, INDEPENDENT, CIVILIAN _Destination = Darea; // first destination of the spawned convoy _SPAWNplace = getpos redH; // place where convoy will spawn //////////////////END OF MANUAL SETTINGS, DO NOT EDIT UNDER THIS LINE//////////////////////////////////////// _spawnCONVOY = TRUE; _DvehS = []; _DcrewS = []; //_allWEST = "(getNumber (_x >> 'scope') == 2) and {(getNumber (_x >> 'side') == 0)}" configClasses (configFile >> "CfgVehicles"); _allWEST = "getNumber (_x >> 'side') isEqualTo 0 AND (configName _x isKindOf 'tank' || configName _x isKindOf 'car') AND getNumber (_x >> 'scope') == 2" configClasses (configFile >> "CfgVehicles"); // _allWEST = "getNumber (_x >> 'side') isEqualTo 1 AND {getText (_x >> 'vehicleClass') in ['Armored', 'Car'] AND getNumber (_x >> 'scope') == 2" configClasses (configFile >> "CfgVehicles"); while {true} do { uiSleep _loop; // for more performance use higher number if (_spawnCONVOY) then { _DtypeN = selectRandom _allWEST;_Dtype1 = configName _DtypeN;_DtypeA = ["O_APC_tracked_02_AA_F"]; // can be random _Dtype1 or manually selected like "B_APC_tracked_01_AA_F" OR "O_APC_tracked_02_AA_F" ecc.. _DtypeN = selectRandom _allWEST;_Dtype2 = configName _DtypeN;_DtypeA append [_Dtype2]; _DtypeN = selectRandom _allWEST;_Dtype3 = configName _DtypeN;_DtypeA append [_Dtype3]; _grpDveh = [[_spawnPlace, 0, 20, 10, 0, 0.3, 0] call BIS_fnc_findSafePos,_Dside,_DtypeA,[[0,0,0],[0,20,0],[20,0,0]],[],[],[],[],180] call BIS_fnc_spawnGroup; // SPAWNER _spawnCONVOY = FALSE; {_Dveh = vehicle _x;_inArray = _Dveh in _Dvehs;if (not _inArray and {_Dveh != _x}) then {_Dvehs set [count _Dvehs, _Dveh];};} forEach (units _grpDveh); // re-define _DvehS _DcrewS = units _grpDveh; _grpDveh deleteGroupWhenEmpty true; {_x setVariable ["RconvoyDEL",true,false];} forEach (units _grpDveh); {(vehicle _X) setVariable ["RconvoyDEL",true,false];} forEach (units _grpDveh); [_grpDveh,(getpos _Destination), 9000,0,"FULL"] call DFN_Patrol; // PATROL {_x DoMove (getpos _Destination)} forEach (units _grpDveh); _grpDveh setFormation "COLUMN"; }; _DN = count _DvehS; _ALLvehDEAD = TRUE; _ALLcrewDEAD = TRUE; {if (alive _x) then {_ALLcrewDEAD = FALSE}} forEach _DcrewS; {if (alive _x) then {_ALLvehDEAD = FALSE}} forEach _Dvehs; if (_ALLvehDEAD || _ALLcrewDEAD) then {{if !(isNil {_x getVariable "RconvoyDEL"}) then {deleteVehicle _x}} foreach allunits;{if !(isNil {_x getVariable "RconvoyDEL"}) then {deleteVehicle _x}} foreach vehicles;_DvehS = [];_spawnCONVOY = TRUE; str (_Dn) + " vehicles in RED convoy moving to AIRPORT!" remoteExecCall ["hint"];["TaskAssigned",["","RED convoy moving to AIRPORT!"]] remoteExec ["bis_fnc_showNotification"];}; // format ["RED convoy moving to AIRPORT!"] remoteExecCall ["hint"]; }; }; }; ////////////////////////////////////////////////////////////////////////////////////////////////////---------------------------------------------------------- SPAWNERind = { if (isServer) then { //////// MANUAL SETTINGS //////// _MaxUnits = 30; // number of units to spawn _loop = 2; // time between 1 spawn and next one, for more performance use higher number _SUPERsnipers = TRUE; // set to TRUE if you want scripted snipers able to hit targets at 2000m in a rainstorm! _MinDistMEN = 1000; // minimum distance to players for MEN, number in meters _MaxDistMEN = 1500; // maximum distance to players for MEN, number in meters _MinDistDIVER = 200; // minimum distance to players for MEN, number in meters _MaxDistDIVER = 400; // maximum distance to players for MEN, number in meters _MinDistLAND = 1500; // minimum distance to players for LAND VEHICLES, number in meters _MaxDistLAND = 3000; // maximum distance to players for LAND VEHICLES, number in meters _MinDistAIR = 3000; // minimum distance to players for AIR, number in meters _MaxDistAIR = 9000; // maximum distance to players for AIR, number in meters _MinDistSHIP = 2000; // minimum distance to players for BOATs, number in meters _MaxDistSHIP = 4000; // maximum distance to players for BOATs, number in meters _Dside = independent; // the side faction of spawned unit, can be WEST, EAST, INDEPENDENT, CIVILIAN //////////////////END OF MANUAL SETTINGS, DO NOT EDIT UNDER THIS LINE//////////////////////////////////////// _MinDist = 0; _MaxDist = 100; _OnWater = 0; // spawn on land OR water, 0 on land, 2 on water , 1 water or land _DtypeA =[]; //_Dtype = "I_MRAP_03_hmg_F"; // the type of unit to spawn, can be more than 1, for example: "I_MRAP_03_hmg_F","I_MRAP_03_hmg_F" , AIR, SHIP, LAND (subType CAManBase), _allINDEP = "(getNumber (_x >> 'scope') == 2) and {(getNumber (_x >> 'side') == 2)}" configClasses (configFile >> "CfgVehicles"); while {true} do { _REALsniper = FALSE; uiSleep _loop; // for more performance use higher number _ALLspawned = []; {if (!isNil {_x getVariable "FARdelete"} && side _x == _Dside) then {_ALLspawned pushBack _x};} forEach allUnits; _activeUnits = count _ALLspawned; if (_activeUnits < _MaxUnits && (count playableUnits) > 0) then { _DtypeN = selectRandom _allINDEP;_Dtype = configName _DtypeN;_DtypeA = [_Dtype]; if (_Dtype isKindOf "SHIP") then {_OnWater = 2;_MinDist = _MinDistSHIP;_MaxDist = _MaxDistSHIP;}; if (_Dtype isKindOf "I_diver_F" || _Dtype isKindOf "I_diver_TL_F" || _Dtype isKindOf "I_diver_exp_F") then {_OnWater = 2;_MinDist = _MinDistDIVER;_MaxDist = _MaxDistDIVER;_DtypeA = [_Dtype];_Gs2 = selectRandom ["I_diver_F","I_diver_exp_F"];_DtypeA append [_Gs2];_Dtype = "I_boat_armed_01_minigun_F";}; if (_Dtype isKindOf "LAND") then {_OnWater = 0;_MinDist = _MinDistLAND;_MaxDist = _MaxDistLAND;if (_Dtype isKindOf "CAManBase") then {if (_Dtype isKindOf "I_ghillie_ard_F" || _Dtype isKindOf "I_ghillie_lsh_F" || _Dtype isKindOf "I_ghillie_sard_F") then {_REALsniper = TRUE};_MinDist = _MinDistMEN;_MaxDist = _MaxDistMEN;_DtypeA = [_Dtype];_Gs2 = selectRandom ["O_G_Soldier_LAT_F","I_ghillie_sard_F","I_soldier_AA_F" ];_DtypeA append [_Gs2];};}; if (_Dtype isKindOf "AIR") then {_OnWater = 1;_MinDist = _MinDistAIR;_MaxDist = _MaxDistAIR;}; randomplayer = selectRandom playableUnits; randomplayerpos = getPos randomplayer; _posBlacklist = playableUnits apply {[_x,_MinDist]}; _grpDveh = [[randomplayerpos, _MinDist, _MaxDist, 10, _OnWater, 0.3, 0,_posBlacklist] call BIS_fnc_findSafePos,_Dside,_DtypeA] call BIS_fnc_spawnGroup; // SPAWNER _grpDveh deleteGroupWhenEmpty true; {_x setVariable ["FARdelete",_MaxDist,false];} forEach (units _grpDveh); {(vehicle _X) setVariable ["FARdelete",_MaxDist,false];} forEach (units _grpDveh); _UnitLeader = leader _grpDveh; _Rn = selectRandom [1,2,3,4,5]; // to decide if move or stay and if garrison building or not if (_Dtype isKindOf "CAManBase" && _Rn > 3) then {[(getpos _unitLeader),(units _grpDveh)] call DFN_occupy;{_x disableAI "PATH"} forEach (units _grpDveh);}; if (_Rn > 1) then {[_grpDveh,(getpos _unitLeader), 9000,_OnWater,(selectRandom ["FULL","LIMITED"])] call DFN_Patrol;}; if (_REALsniper && _SUPERsnipers) then {_sniper = leader _grpDveh;null = [_sniper] spawn "snipe;}; }; // {uiSleep 0.1;if !(isNil {_x getVariable "FARdelete"}) then {if (_x distance ({_x} foreach allplayers) > (_x getVariable "FARdelete")) then {deleteVehicle _x;}}} foreach allUnits; // {uiSleep 0.1;if !(isNil {_x getVariable "FARdelete"}) then {if (_x distance ({_x} foreach allplayers) > (_x getVariable "FARdelete")) then {deleteVehicle _x;}}} foreach vehicles; // UN-COMMENT IF USED ALONE , WITHOUT CIVILIAN SPAWNER (SPAWNERciv.sqf) }; }; }; //////////////////////////////////////////////////////////////////////////////////////////--------------------------------------------------------- SPAWNERmine = { //nul = [] spawn SPAWNERmine; >> in initSERVER.sqf to run script if (isServer) then { //////// MANUAL SETTINGS //////// _loop = 30; // time between 1 spawn and next one, for more performance use higher number _MinDistMINE = 300; // minimum distance to players for MINEs, number in meters 200 , to have "more mines" use lower numbers! _MaxDistMINE = 500; // maximum distance to players for MINEs, number in meters 500 , to have "more mines" use lower numbers! //////////////////END OF MANUAL SETTINGS, DO NOT EDIT UNDER THIS LINE//////////////////////////////////////// _allmines = ["ATMine","APERSMine","underWaterMine"]; _Dmine = createMine ["apersmine",[0000.00, 0000.00, -1000], [], 0]; uiSLeep 0.5; _Dmine setdamage 1; while {true} do { uiSleep _loop; // for more performance use higher number _OnWater = 0; // spawn on land OR water, 0 on land, 2 on water , 1 water or land _Wmine = FALSE; if (!(alive _Dmine) && (count playableUnits) > 0) then { _Dtype = selectRandom _allmines; if (_Dtype isKindOf "underWaterMine") then {_OnWater = 2;_Wmine = true;}; randomplayer = selectRandom playableUnits; randomplayerpos = getPos randomplayer; _posBlacklist = playableUnits apply {[_x,_MinDistMINE]}; _minePOS = [randomplayerpos, _MinDistMINE, _MaxDistMINE, 5, _OnWater, 0.3, 0,_posBlacklist] call BIS_fnc_findSafePos; _Dmine = createMine [_Dtype, _minepos, [], 0]; if (_Wmine) then {_Dmine setpos [getpos _Dmine select 0,getpos _Dmine select 1,(getpos _Dmine select 2)-0.5]}; }; _farFromAll = true; {if (_Dmine distance2D _x < _MaxDistMINE) then {_farFromAll = false;};} forEach playableUnits; if (_farFromALL) then {deleteVehicle _Dmine;}; }; }; }; ////////////////////////////////////////////////////////////////////////////////////////////------------------------------------ SPAWNERobj = { // null = [this] spawn SPAWNERobj; exec this to delete old units, and spawn new ones! if (isServer) then { //////// MANUAL SETTINGS //////// _MaxUnits = 60; // number of units to spawn _loop = 0.2; // time between 1 spawn and next one, for more performance use higher number _SUPERsnipers = TRUE; // set to TRUE if you want scripted snipers able to hit targets at 2000m in a rainstorm! _Dside = independent; // the side faction of spawned unit, can be WEST, EAST, INDEPENDENT, CIVILIAN //////////////////END OF MANUAL SETTINGS, DO NOT EDIT UNDER THIS LINE//////////////////////////////////////// _NEWpos = [GMO, 5000, 30000, 15, 0, 0.3, 0,["REDarea","BLUarea"]] call BIS_fnc_findSafePos; GMO setpos _NEWpos; GMarea setpos _NEWpos; //["TaskSucceeded",["","SECTOR CONQUERED!"]] remoteExec ["bis_fnc_showNotification"]; [Dsector,independent] call BIS_fnc_moduleSector; // resetta il settore a non conquistato [Dsector,sideunknown] call BIS_fnc_moduleSector; uiSleep 1; _MinDist = 20; _MaxDist = 1000; _OnWater = 0; // spawn on land OR water, 0 on land, 2 on water , 1 water or land _DtypeA =[]; _KEEPspawning = TRUE; //_Dtype = "I_MRAP_03_hmg_F"; // the type of unit to spawn, can be more than 1, for example: "I_MRAP_03_hmg_F","I_MRAP_03_hmg_F" , AIR, SHIP, LAND (subType CAManBase), _allINDEP = "(getNumber (_x >> 'scope') == 2) and {(getNumber (_x >> 'side') == 2)}" configClasses (configFile >> "CfgVehicles"); {uiSleep 0;if !(isNil {_x getVariable "OBJdelete"}) then {deleteVehicle _x;}} foreach allUnits; // delete previous round AI and vehicles {uiSleep 0;if !(isNil {_x getVariable "OBJdelete"}) then {deleteVehicle _x;}} foreach vehicles; private _Ga13 = [getPos GMO, INDEPENDENT, [selectRandom ["O_G_Soldier_LAT_F","I_ghillie_sard_F","I_soldier_AA_F" ],selectRandom ["O_G_Soldier_LAT_F","I_ghillie_sard_F","I_soldier_AA_F" ],selectRandom ["O_G_Soldier_LAT_F","I_ghillie_sard_F","I_soldier_AA_F" ],selectRandom ["O_G_Soldier_LAT_F","I_ghillie_sard_F","I_soldier_AA_F" ]]] call BIS_fnc_spawnGroup; //4 _Ga13 deleteGroupWhenEmpty true; {_x setVariable ["OBJdelete",_MaxDist,false];} forEach (units _ga13); _Ga13a = units _Ga13; {_x disableAI "PATH"} forEach _Ga13a; _rp = selectRandom [0,4]; (_Ga13a select 0) setPosATL (GMO buildingPos 2); (_Ga13a select 1) setPosATL (GMO buildingPos 3); (_Ga13a select 2) setPosATL (GMO buildingPos _rp); (_Ga13a select 3) setPosATL (GMO buildingPos 5); private _RGveh = selectRandom ["O_T_APC_Tracked_02_AA_ghex_F" ]; private _Ga5aa = [[GMO, 20, 500, 15, 0, 0.3, 0] call BIS_fnc_findSafePos,INDEPENDENT,[_RGveh]] call BIS_fnc_spawnGroup; //3 _Ga5aa deleteGroupWhenEmpty true; {_x setVariable ["OBJdelete",_MaxDist,false];} forEach (units _Ga5aa); {(vehicle _X) setVariable ["OBJdelete",_MaxDist,false];} forEach (units _Ga5aa); private _Gveh5aa = vehicle leader _Ga5aa; [_Gveh5aa] spawn DFN_dakka; private _crewGveh5aa = crew _Gveh5aa; // [_Ga5aa, getPos GMO,300,0,"FULL"] call DFN_Patrol; //////////////////////////////////////////////////////////////////////////////// L O O P ///////////////////////////////////////////////// while {_KEEPspawning} do { _REALsniper = FALSE; uiSleep _loop; // for more performance use higher number _ALLspawned = []; {if (!isNil {_x getVariable "OBJdelete"} && side _x == _Dside) then {_ALLspawned pushBack _x};} forEach allUnits; _activeUnits = count _ALLspawned; if (_activeUnits < _MaxUnits && (count playableUnits) > 0) then { _DtypeN = selectRandom _allINDEP;_Dtype = configName _DtypeN;_DtypeA = [_Dtype]; if (_Dtype isKindOf "SHIP") then {_OnWater = 2;}; if (_Dtype isKindOf "I_diver_F" || _Dtype isKindOf "I_diver_TL_F" || _Dtype isKindOf "I_diver_exp_F") then {_OnWater = 2;_DtypeA = [_Dtype];_Gs2 = selectRandom ["I_diver_F","I_diver_exp_F"];_DtypeA append [_Gs2];_Dtype = "I_boat_armed_01_minigun_F";}; if (_Dtype isKindOf "LAND") then {_OnWater = 0;if (_Dtype isKindOf "CAManBase") then {if (_Dtype isKindOf "I_ghillie_ard_F" || _Dtype isKindOf "I_ghillie_lsh_F" || _Dtype isKindOf "I_ghillie_sard_F") then {_REALsniper = TRUE};_DtypeA = [_Dtype];_Gs2 = selectRandom ["O_G_Soldier_LAT_F","I_ghillie_sard_F","I_soldier_AA_F" ];_DtypeA append [_Gs2];};}; if (_Dtype isKindOf "AIR") then {_OnWater = 1;}; _grpDveh = [[(getpos GMO), _MinDist, _MaxDist, 30, _OnWater, 0.4, 0] call BIS_fnc_findSafePos,_Dside,_DtypeA] call BIS_fnc_spawnGroup; // SPAWNER _grpDveh deleteGroupWhenEmpty true; {_x setVariable ["OBJdelete",_MaxDist,false];} forEach (units _grpDveh); {(vehicle _X) setVariable ["OBJdelete",_MaxDist,false];} forEach (units _grpDveh); _UnitLeader = leader _grpDveh; _Rn = selectRandom [1,2,3,4,5]; // to decide if move or stay and if garrison building or not if (_Dtype isKindOf "CAManBase" && _Rn > 3) then {[(getpos _unitLeader),(units _grpDveh)] call DFN_occupy;{_x disableAI "PATH"} forEach (units _grpDveh);}; if (_Rn > 1) then {[_grpDveh,(getpos _unitLeader), 500,_OnWater,(selectRandom ["FULL","LIMITED"])] call DFN_Patrol;}; if (_REALsniper && _SUPERsnipers) then {_sniper = leader _grpDveh;null = [_sniper] spawn snipe;}; } else {_KEEPspawning = FALSE}; }; }; }; ///////////////////////////////////////////////////////////////////////////////////--------------------------------------------------------- ...it contains all my functions for this mission, but...when i launch mission, it start say that FUNCTION_NAME is not defined (where "FUNCTION_NAME" is the name of one of my functions, that as you can see are defined. i pre-load the file containing the functions in my initServer.sqf : call compile preprocessFile "DDscripts\DWARfunctions.sqf"; null = [] spawn SPAWNERconvoyB; null = [] spawn SPAWNERconvoyR; null = [] spawn SPAWNERciv; null = [] spawn SPAWNERind; null = [] spawn SPAWNERmine; even more strange, i noticed adding >> uiSleep 10; between a function spawn and another, some start to work!! i even started to think its like the functions are not pre-loaded, and server dont recognize them ! but isnt supposed to do this the >> calling compile preProcessFile ... ?? i'm seriously confused....any light on this? thanks ! Edited July 15, 2018 by FallujahMedic -FM- Edited by Moderator Share this post Link to post Share on other sites
Grumpy Old Man 3546 Posted July 10, 2018 8 hours ago, dlegion said: ...it contains all my functions for this mission, but...when i launch mission, it start say that FUNCTION_NAME is not defined (where "FUNCTION_NAME" is the name of one of my functions, that as you can see are defined. i pre-load the file containing the functions in my initServer.sqf : Are you by any chance calling some of those functions from object init fields inside the editor? Object init fields are handled before init.sqf/initServer.sqf, so that might be causing your issue. Have a read. Cheers 1 Share this post Link to post Share on other sites
squeeze 22 Posted July 10, 2018 I don't think I've used "call compile preprocessFile "DDscripts\DWARfunctions.sqf";" since Arma 1 I might be wrong but this is all i use now, can't even remember why. SQU_ActionVehLock = compileFinal preprocessFileLineNumbers "Common\SQU_ActionVehLock.sqf"; do you use a "waituntil{DWARfunctions};" DWARfunctions = true; placed at the end of DWARfunctions.sqf edit. oh i see, i only write functions like that for local scripts, never saw the reason for gloabal when i find it easy to give them there own file. 1 Share this post Link to post Share on other sites
dlegion 98 Posted July 10, 2018 4 hours ago, Grumpy Old Man said: Are you by any chance calling some of those functions from object init fields inside the editor? Object init fields are handled before init.sqf/initServer.sqf, so that might be causing your issue. no, i start all them from scripts, the nearest thing i have to start from init is a vehicle init calling a script *.sqf that will spawn a function. 1 hour ago, squeeze said: do you use a "waituntil{DWARfunctions};" i tried as you say, with this in initServer.sqf: DWARfunctions = FALSE; waituntil {DWARfunctions}; ...and this at the end of DWARfunctions.sqf : DWARfunctions = TRUE; ...tested, game starts, no error, nothing spawns, waited 7 minutes (game running at 78 fps) and still no sign of passed "waituntil" ...whats wrong here ?? thanks guys! Share this post Link to post Share on other sites
pierremgi 4900 Posted July 10, 2018 As Squeeze said, do not call compile the sqf (imbricated functions, while true loop!). Just compile or compileFinal , then spawn the functions. Nothing more. 1 Share this post Link to post Share on other sites
TeTeT 1523 Posted July 10, 2018 Is there any distinct advantage in this method of using compile/compileFinal rather than using the CfgFunctions functions split into files? 1 Share this post Link to post Share on other sites
dlegion 98 Posted July 10, 2018 1 hour ago, pierremgi said: As Squeeze said, do not call compile the sqf (imbricated functions, while true loop!). Just compile or compileFinal , then spawn the functions. Nothing more. i tried....i dont know...it still gives the same "undefined variable in expression" error Share this post Link to post Share on other sites
Dedmen 2714 Posted July 10, 2018 1 hour ago, TeTeT said: Is there any distinct advantage in this method of using compile/compileFinal rather than using the CfgFunctions functions split into files? Not exactly sure what he meant. But I think he was trying to say that "call compile" is bad if you call the code more than once. Because you are compiling the code. And then throwing it away. And then later compiling it again and throwing it away again. With CfgFunctions you only compile once. Share this post Link to post Share on other sites
pierremgi 4900 Posted July 10, 2018 1 hour ago, Dedmen said: Not exactly sure what he meant. But I think he was trying to say that "call compile" is bad if you call the code more than once. Because you are compiling the code. And then throwing it away. And then later compiling it again and throwing it away again. With CfgFunctions you only compile once. That's sure, no need to call and spawn after. But more than this calling some scheduled code or infinite loops is not a good idea. And, if you call compile this big sqf, not sure you will run the functions in the good order, some variables could stay undefined. 3 hours ago, TeTeT said: Is there any distinct advantage in this method of using compile/compileFinal rather than using the CfgFunctions functions split into files? None. It's just easier, trying to make it work from this situation, rather than rewriting all the stuff. But for sure, some separate functions would imply to warn for parameters! 1 Share this post Link to post Share on other sites
pierremgi 4900 Posted July 10, 2018 2 hours ago, dlegion said: i tried....i dont know...it still gives the same "undefined variable in expression" error Just replace: call compile preprocessFile "DDscripts\DWARfunctions.sqf"; by: compileFinal preprocessFileLineNumbers "DDscripts\DWARfunctions.sqf"; Error will not disappear but at least, you'll have more details about it, in rpt file. You can have many problems with your parameters... and other stuff like playableUnits returning [ ] before any player defined in lobby if you disable AI in that lobby. (just an example). As easy test, just add: waitUntil {count allPlayers > 0}; before spawning any function (between you compile and your spawn). 1 Share this post Link to post Share on other sites
dlegion 98 Posted July 10, 2018 ok done, it keeps saying that its undefined variable, but i've tried to name each function one by one, precompile each function one by one, and for now it seems to work! SconvoyB = compileFinal preprocessFileLineNumbers "DDscripts\SPAWNERconvoyB.sqf"; SconvoyR = compileFinal preprocessFileLineNumbers "DDscripts\SPAWNERconvoyR.sqf"; Sciv = compileFinal preprocessFileLineNumbers "DDscripts\SPAWNERciv.sqf"; Sind = compileFinal preprocessFileLineNumbers "DDscripts\SPAWNERind.sqf"; Smine = compileFinal preprocessFileLineNumbers "DDscripts\SPAWNERmine.sqf"; null = [] spawn SconvoyB; null = [] spawn SconvoyR; null = [] spawn Sciv; null = [] spawn Sind; null = [] spawn Smine; ...pretty no-sense to me....anyway for now it seems to work. Share this post Link to post Share on other sites
dlegion 98 Posted July 10, 2018 thanks to you all guys for helping me ! :) Share this post Link to post Share on other sites