Jump to content

sabot10.5mm

Member
  • Content Count

    125
  • Joined

  • Last visited

  • Medals

Posts posted by sabot10.5mm


  1. once revealed maybe place a LaserTargetW on the pos of current target so ai have additional opportunities to fire missiles, bombs. 

    _lasers = missionnamespace getvariable ["SAVEDLASERS",[]]; 
    { _target = _x; 
     _laser = "LaserTargetW" createVehicle position _target; 
     _laser attachto [_target, [0,0,1]]; 
     _lasers pushback [_laser,_target]; }foreach (allunits select {(side _x) == east}); 
    missionnamespace setvariable ["SAVEDLASERS",_lasers]; 
    //to delete 
    { _laser=_x select 0; _unit=_x select 1; if(!alive _unit)then{deletevehicle _laser;}; }foreach _lasers
    • Like 1

  2. 15 hours ago, beako said:

    HI ALl,

     

    I have a script for a UAV (Sentinel) that targets enemy units (tanks and soldiers)...

     

    The problem is, as part of the script their is a JTAC soldier that uses laserTarget to target the same object as the UAV.

     

    The UAV is armed with PylonMissile_1Rnd_BombCluster_01_F and PylonMissile_Missile_AGM_02_x2, but I only want the UAV to fire the AT munition (PylonMissile_Missile_AGM_02_x2) on the tank, but because the laserTarget is on the tank from the JTAC, it fires the bombcluster munition instead.

     

    How should I script for the UAV to use weapon_AGM_65Launcher on Tanks only?

     

    I've tried the following with [0] and [-1] as a turretPath for selectWeaponTurret, but has no effect...I even tried using selectWeapon with no luck.

     

    I want to avoid forceFire, since it misses the target.

     

    
    // laserTarget from JTAC soldier
    	_laserTarget = laserTarget _JTACUnit; 
    
    
    // AT Ammo Count 
    	_getPylMagArray = getPylonMagazines _airTransport; 	
    	_ammoCountATArray = [0,0];	
    	for "_i" from 1 to 2 do {
    		if (((_getPylMagArray select (_i - 1)) find "PylonMissile_Missile_AGM_02_x2") > -1) then {
    			_ammoCountATArray set [(_i - 1), (_airTransport ammoOnPylon ("pylon" + str _i))];
    		} else {
    			_ammoCountATArray set [(_i - 1), 0];
    		};
    	};
    	_ammoCountAT = 0;	
    	{_ammoCountAT = _ammoCountAT + _x} forEach _ammoCountATArray;	
    
    // do not user clusterbomb on tanks
    	if !(isNull _laserTarget) then  {
    		if (_ammoCountAT > 0) then {
    			_sentinelUAV selectWeaponTurret ["weapon_AGM_65Launcher", []];	//"BombCluster_01_F"
    			_sentinelUAV selectWeapon "weapon_AGM_65Launcher";
    		};
    	};

     

    firstly "weapon_AGM_65Launcher" are infrared-guided hence will not lock onto laser nor guide toward target. scalpel, dagr are the only vanilla laser guided missiles. possibly doTarget _laserTarget object


  3. A scheduled script has an execution time limit of 3 ms before being suspended to the benefit of another script until its turn comes back. here 

    maybe to avoid suspension use a non-schedule? just an idea.

    _Timer SetVariable ["TimerTime", (time + 5)];
    
    [...] call {
    _timer = _this select 0;
    while {true} do {
    	if (time > (_timer getVariable ["TimerTime", -1])) exitwith {//misc stuff that doesnt run until timer is finished
        };
    };
    };

     

    • Like 1
    • Thanks 1

  4. once revealed maybe place a LaserTargetW on the pos of current target so ai have additional opportunities to fire missiles, bombs. never tried this but should work. hint macer missles are infrared. scalpel, dagr and GBU12 are laser guilded.

    _lasers = missionnamespace getvariable ["SAVEDLASERS",[]]; 
    { 
    _target = _x; 
    _laser = "LaserTargetW" createVehicle position _target; 
    _laser attachto [_target, [0,0,1]]; 
    _lasers pushback [_laser,_target]; 
    }foreach (allunits select {(side _x) == east});  
    missionnamespace setvariable ["SAVEDLASERS",_lasers];
    
    
    //to delete
    {
    _laser=_x select 0;
    _unit=_x select 1;
    if(!alive _unit)then{deletevehicle _laser;};
    }foreach _lasers

     

    • Like 1

  5. Spoiler
    
    fn_instring={
     params ["_fstr","_instr"];
    
     _fstr = toArray (_fstr);
     _instr = toArray (_instr);
     _idx = 0;
     _m = false;
     _d = count(_fstr);
    
     for "_i" from 0 to count(_instr)-1 do
     {
      if !((_instr select _i) isEqualTo (_fstr select _idx)) then {_idx=0;
      }else{
      _idx=_idx+1; 
      if (_idx isEqualTo _d) exitwith {_m = true; };
      };
      
      
     };
    _m;
    }; ["hi","1hi1"] call fn_instring;

     

    my slow instring fnc

    Result:
    0.0126 ms
    
    Cycles:
    10000/10000
    
    ["hi","1hi1"] call fn_instring; //returns true

     

     


  6. On 8/11/2019 at 5:18 PM, JD Wang said:

    So if you have 10 players on the server you'll see more enemies than if you only had 2 on the server. I suppose you could use the same principal but instead of adjusting via marker size, adjust via count of allplayers?

    something like this

    Spoiler
    
    EOS_Spawn = compile preprocessfilelinenumbers "eos\core\eos_launch.sqf";Bastion_Spawn=compile preprocessfilelinenumbers "eos\core\b_launch.sqf";null=[] execVM "eos\core\spawn_fnc.sqf";onplayerConnected {[] execVM "eos\Functions\EOS_Markers.sqf";}; 
    VictoryColor="colorGreen"; // Colour of marker after completion 
    hostileColor="colorRed"; // Default colour when enemies active 
    bastionColor="colorOrange"; // Colour for bastion marker 
    EOS_DAMAGE_MULTIPLIER=1; // 1 is default 
    EOS_KILLCOUNTER=true;  // Counts killed units 
    /* 
    UNIT SIZE PER GROUP
     0 = 1
     1 = 2,4
     2 = 4,8
     3 = 8,12
     4 = 12,16
     5 = 16,20
     */
     _pcnt = {isPlayer _x} count playableUnits;
    { 
    if (_x find "EOS_MARKER" > -1) then  
    { 
    _actd = 0;
    _mrkx = getMarkerSize _x#0;
    _mrky = getMarkerSize _x#1;
    _mkrSz=(_mrkx) + (_mrky);
    if ((_mrkx)>(_mrky)) then [{_actd = _mrkx;},{_actd = _mrky;}];
    _xcargo=3; //max units in cargo
    _maxVh=3;  //max amount of vehicles
    _maxGp=10; //max amount of groups //if multiplayer _maxGp is min (# of groups) _mxSz is max
    _maxUt=2;  //max amount of units per group 
    _minUt=0;  //min amount of units per group
    _mxPl=32;  //max player server slots
    _mxSz=30;  //max amount of groups in server. triggers bigger then 500m+500m will increase this number unless (_grps) clipping is set to true 
    if (_pcnt > 1) then {_maxGp = round(linearConversion [0,_mxPl,_pcnt,_maxGp,_mxSz,true])};
    _grps =  round(linearConversion [0,1000,_mkrSz,1,_maxGp,false]); // clipping=false. _grpS will increase proportionally to size of marker, even when exceeding 500+500 _mkrSz 
    _vehs =  round(linearConversion [0,1000,_mkrSz,0,_maxVh,false]); // clipping=false. _vehs will increase proportionally to size of marker, even when exceeding 500+500 _mkrSz  
    _vcarg = round(linearConversion [0,1000,_mkrSz,0,_xcargo,true]); // clipping=true. //units in cargo.
    _grpSz = round(linearConversion [0,1000,_mkrSz,_minUt,_maxUt,true]); // clipping=true. //amount of units per group 
    _prob =  round(linearConversion [0,1000,_mkrSz,0,100,true]); // clipping=true. //probability ratio for vehicle spawning
    [[_x],[_grps,_grpSz],[_grps,_grpSz],[_vehs,_vcarg,_prob],[_vehs,_prob],[_vehs],[_vehs,_vcarg,_prob],[0,0,_actd,EAST,FALSE]] call EOS_Spawn; 
    }; 
    }foreach allmapmarkers;

     

     

    • Thanks 1

  7. On 8/10/2019 at 1:31 PM, sabot10.5mm said:
      Reveal hidden contents

    eos/functions DynSimEnab.sqf

      Reveal hidden contents
    
    
    
    params["_grp","_mkrX","_mkrY"];
    _mkrSz = _mkrX + _mkrY;
    if (_mkrSz > 1000) then {
    	if !(_grp isEqualtype grpNull) then {
    		(_grp select 0) enableDynamicSimulation true;
    		(_grp select 2) enableDynamicSimulation true;
    						
    	} else {
    		_grp enableDynamicSimulation true;
    	};
    };

     

    eos/core spawn_fnc.sqf

      Reveal hidden contents
    
    
    
    
    IF (isnil "server")then{hint "YOU MUST PLACE A GAME LOGIC NAMED SERVER!";};
    eos_fnc_spawnvehicle=compile preprocessfilelinenumbers "eos\functions\eos_SpawnVehicle.sqf";
    eos_fnc_grouphandlers=compile preprocessfilelinenumbers "eos\functions\setSkill.sqf";
    eos_fnc_findsafepos=compile preprocessfilelinenumbers "eos\functions\findSafePos.sqf";
    eos_fnc_spawngroup= compile preprocessfile "eos\functions\infantry_fnc.sqf";
    eos_fnc_setcargo = compile preprocessfile "eos\functions\cargo_fnc.sqf";
    eos_fnc_taskpatrol= compile preprocessfile "eos\functions\shk_patrol.sqf";
    SHK_pos= compile preprocessfile "eos\functions\shk_pos.sqf";
    shk_fnc_fillhouse = compile preprocessFileLineNumbers "eos\Functions\SHK_buildingpos.sqf";
    fnc_enabledynamicsim = compile preprocessFileLineNumbers "eos\Functions\DynSimEnab.sqf";
    eos_fnc_getunitpool= compile preprocessfilelinenumbers "eos\UnitPools.sqf";
    call compile preprocessfilelinenumbers "eos\AI_Skill.sqf";
    
    EOS_Deactivate = {
    	private ["_mkr"];
    		_mkr=(_this select 0);		
    	{
    		_x setmarkercolor "colorblack";
    		_x setmarkerAlpha 0;
    	}foreach _mkr;
    };
    
    EOS_debug = {
    private ["_note"];
    _mkr=(_this select 0);
    _n=(_this select 1);
    _note=(_this select 2);
    _pos=(_this select 3);
    
    _mkrID=format ["%3:%1,%2",_mkr,_n,_note];
    deletemarker _mkrID;
    _debugMkr = createMarker[_mkrID,_pos];
    _mkrID setMarkerType "Mil_dot";
    _mkrID setMarkercolor "colorBlue";
    _mkrID setMarkerText _mkrID;
    _mkrID setMarkerAlpha 0.5;
    };

     

     

    eos/core/eos_core.sqf

      Reveal hidden contents
    
    
    
    if (!isServer) exitWith {};
    private ["_newpos","_cargoType","_vehType","_dGrp","_mkrAgl","_side","_bGroup","_civZone","_fGrp","_fSize","_fGrps","_eGrp","_eGrps","_dGrps","_aMin","_aSize","_aGrps","_aGrp","_bMin","_units","_bSize","_bGrps","_bGrp","_trig","_cache","_grp","_crew","_vehicle","_actCond","_mAN","_mAH","_distance","_mA","_settings","_cGrp","_cSize","_cGrps","_taken","_clear","_enemyFaction","_faction","_n","_eosAct","_eosActivated","_debug","_mkr","_mPos","_mkrX","_mkrY"];
    
    _mkr=(_this select 0);_mPos=markerpos(_this select 0);
    _mkrX=getMarkerSize _mkr select 0;
    _mkrY=getMarkerSize _mkr select 1;
    _mkrAgl=markerDir _mkr;
    _a=(_this select 1);_aGrps=_a select 0;_aSize=_a select 1;_aMin=_aSize select 0;
    _b=(_this select 2);_bGrps=_b select 0;_bSize=_b select 1;_bMin=_bSize select 0;
    _c=(_this select 3);_cGrps=_c select 0;_cSize=_c select 1;
    _d=(_this select 4);_dGrps=_d select 0;_eGrps=_d select 1;_fGrps=_d select 2;_fSize=_d select 3;
    _settings=(_this select 5);_faction=_settings select 0;_mA=_settings select 1;_distance=_settings select 2;_side=_settings select 3;
    _heightLimit=if (count _settings > 4) then {_settings select 4} else {false};
    _debug=if (count _settings > 5) then {_settings select 5} else {false};
    _cache= if (count _this > 6) then {_this select 6} else {false};
    
    
    	if (_side==EAST) then {_enemyFaction="east";_civZone=false;};
    	if (_side==WEST) then {_enemyFaction="west";_civZone=false;};
    	if (_side==INDEPENDENT) then {_enemyFaction="guer";_civZone=false;};
    	if (_side==CIVILIAN) then {_enemyFaction="civ";_civZone=true;};
    
    	if (_mA==0) then {_mAH = 1;_mAN = 0.5;};
    	if (_mA==1) then {_mAH = 0;_mAN = 0;};
    	if (_mA==2) then {_mAH = 0.5;_mAN = 0.5;};
    
    // INITIATE ZONE
    _trig=format ["EOSTrigger%1",_mkr];
    
    
    if (!_cache) then {
    	if ismultiplayer then {
    			if (_heightLimit) then 
    			{_actCond="{vehicle _x in thisList && isplayer _x && ((getPosATL _x) select 2) < 5} count playableunits > 0";
    							}else 
    							{_actCond="{vehicle _x in thisList && isplayer _x} count playableunits > 0";
    		};}else{
    			if (_heightLimit) then 
    						{_actCond="{vehicle _x in thisList && isplayer _x && ((getPosATL _x) select 2) < 5  } count allUnits > 0";
    								}else
    	
    									  {_actCond="{vehicle _x in thisList && isplayer _x || ({_player = _x; {getConnectedUAV _player == _x} count [uav, uav1, uav2, uav3] > 0} count allPlayers > 0 && ({_x in thislist} count [uav, uav1, uav2, uav3] > 0))} count allUnits > 0"; };};
    		_eosActivated = createTrigger ["EmptyDetector",_mPos]; 
    		_eosActivated = createTrigger ["EmptyDetector",_mPos]; 
    		_eosActivated setTriggerArea [(_distance+_mkrX),(_distance+_mkrY),_mkrAgl,FALSE]; 
    		_eosActivated setTriggerActivation ["ANY","PRESENT",true];
    		_eosActivated setTriggerTimeout [1, 1, 1, true];
    		_eosActivated setTriggerStatements [_actCond,"",""];
    		
    			server setvariable [_trig,_eosActivated];	
    					}else{
    				_eosActivated=server getvariable _trig;	
    					};
    		
    					_mkr setmarkerAlpha _mAN;
    						if (!(getmarkercolor _mkr == VictoryColor)) then 	//IF MARKER IS GREEN DO NOT CHANGE COLOUR
    							{
    						_mkr setmarkercolor hostileColor;
    							};
    
    
    
    waituntil {triggeractivated _eosActivated};	//WAIT UNTIL PLAYERS IN ZONE
    if (!(getmarkercolor _mkr == "colorblack"))then {
    	if (!(getmarkercolor _mkr == VictoryColor)) then {_mkr setmarkerAlpha _mAH;};
    
    // SPAWN HOUSE PATROLS
    	for "_counter" from 1 to _aGrps do {
    	if (isnil "_aGrp") then {_aGrp=[];};
    		if (_cache) then {
    				_cacheGrp=format ["HP%1",_counter];
    				_units=_eosActivated getvariable _cacheGrp;	
    						_aSize=[_units,_units];
    						_aMin=_aSize select 0;
    							if (_debug)then{player sidechat format ["ID:%1,restore - %2",_cacheGrp,_units];};
    							};
    								if (_aMin > 0) then {
    										_aGroup=[_mPos,_aSize,_faction,_side] call EOS_fnc_spawngroup;	
    				
    										if (!surfaceiswater _mPos) then {
    											0=[_mPos,(units _aGroup),_mkrX,true,false,true,false] call shk_fnc_fillhouse;
    												}else{
    												0 = [_aGroup,_mkr] call EOS_fnc_taskpatrol;
    													};
    												_aGrp set [count _aGrp,_aGroup];
    												0=[_aGroup,"INFskill"] call eos_fnc_grouphandlers;
    												[_aGroup,_mkrX,_mkrY] call fnc_enabledynamicsim;
    if (_debug) then {PLAYER SIDECHAT (format ["Spawned House Patrol: %1",_counter]);0= [_mkr,_counter,"House Patrol",getpos (leader _aGroup)] call EOS_debug};
    												};
    		};
    		
    // SPAWN PATROLS
    	for "_counter" from 1 to _bGrps do {
    	if (isnil "_bGrp") then {_bGrp=[];};
    		if (_cache) then {
    				_cacheGrp=format ["PA%1",_counter];
    				_units=_eosActivated getvariable _cacheGrp;	
    					_bSize=[_units,_units];
    					_bMin=_bSize select 0;
    					if (_debug)then{player sidechat format ["ID:%1,restore - %2",_cacheGrp,_units];};
    						};
    							if (_bMin > 0) then {	
    									_pos = [_mkr,true] call SHK_pos;			
    									_bGroup=[_pos,_bSize,_faction,_side] call EOS_fnc_spawngroup;
    										0 = [_bGroup,_mkr] call EOS_fnc_taskpatrol;
    										_bGrp set [count _bGrp,_bGroup];
    										0=[_bGroup,"INFskill"] call eos_fnc_grouphandlers;
    										[_bGroup,_mkrX,_mkrY] call fnc_enabledynamicsim;
    if (_debug) then {PLAYER SIDECHAT (format ["Spawned Patrol: %1",_counter]);0= [_mkr,_counter,"patrol",getpos (leader _bGroup)] call EOS_debug};
    												};
    		};	
    	
    //SPAWN LIGHT VEHICLES
    	for "_counter" from 1 to _cGrps do {	
    	if (isnil "_cGrp") then {_cGrp=[];};	
    	
    		_newpos=[_mkr,50] call EOS_fnc_findSafePos;
    			if (surfaceiswater _newpos) then {_vehType=8;_cargoType=10;}else{_vehType=7;_cargoType=9;};
    	
    					_cGroup=[_newpos,_side,_faction,_vehType]call EOS_fnc_spawnvehicle;
    				if ((_cSize select 0) > 0) then{
    						0=[(_cGroup select 0),_cSize,(_cGroup select 2),_faction,_cargoType] call eos_fnc_setcargo;
    						};
    						
    							0=[(_cGroup select 2),"LIGskill"] call eos_fnc_grouphandlers;
    								0 = [(_cGroup select 2),_mkr] call EOS_fnc_taskpatrol;
    								_cGrp set [count _cGrp,_cGroup];	
    								[_cGroup,_mkrX,_mkrY] call fnc_enabledynamicsim;
    								
    if (_debug) then {player sidechat format ["Light Vehicle:%1 - r%2",_counter,_cGrps];0= [_mkr,_counter,"Light Veh",(getpos leader (_cGroup select 2))] call EOS_debug};
    		};	
    		
    //SPAWN ARMOURED VEHICLES
    	for "_counter" from 1 to _dGrps do {
    	if (isnil "_dGrp") then {_dGrp=[];};
    	
    		_newpos=[_mkr,50] call EOS_fnc_findSafePos;
    			if (surfaceiswater _newpos) then {_vehType=8;}else{_vehType=2;};
    			
    					_dGroup=[_newpos,_side,_faction,_vehType]call EOS_fnc_spawnvehicle;
    					
    						0=[(_dGroup select 2),"ARMskill"] call eos_fnc_grouphandlers;
    						0 = [(_dGroup select 2),_mkr] call EOS_fnc_taskpatrol;
    							_dGrp set [count _dGrp,_dGroup];
    							[_dGroup,_mkrX,_mkrY] call fnc_enabledynamicsim;
    							
    if (_debug) then {player sidechat format ["Armoured:%1 - r%2",_counter,_dGrps];0= [_mkr,_counter,"Armour",(getpos leader (_dGroup select 2))] call EOS_debug};
    		};
    		
    //SPAWN STATIC PLACEMENTS
    	for "_counter" from 1 to _eGrps do {
    		if (surfaceiswater _mPos) exitwith {};
    		if (isnil "_eGrp") then {_eGrp=[];};
    				
    		_newpos=[_mkr,50] call EOS_fnc_findSafePos;
    			
    					_eGroup=[_newpos,_side,_faction,5]call EOS_fnc_spawnvehicle;
    		
    						0=[(_eGroup select 2),"STAskill"] call eos_fnc_grouphandlers;
    							_eGrp set [count _eGrp,_eGroup];
    							[_eGroup,_mkrX,_mkrY] call fnc_enabledynamicsim;
    							
    if (_debug) then {player sidechat format ["Static:%1",_counter];0= [_mkr,_counter,"Static",(getpos leader (_eGroup select 2))] call EOS_debug};
    		};	
    		
    //SPAWN CHOPPER
    	for "_counter" from 1 to _fGrps do {
    	if (isnil "_fGrp") then {_fGrp=[];};	
    		if ((_fSize select 0) > 0) then {_vehType=4}else{_vehType=3};
    				_newpos = [(markerpos _mkr), 1500, random 360] call BIS_fnc_relPos;	
    						_fGroup=[_newpos,_side,_faction,_vehType,"fly"]call EOS_fnc_spawnvehicle;	
    						_fGrp set [count _fGrp,_fGroup];
    
    						
    						
    						
    if ((_fSize select 0) > 0) then {
    	_cargoGrp = createGroup _side;
    		0=[(_fGroup select 0),_fSize,_cargoGrp,_faction,9] call eos_fnc_setcargo;
    			0=[_cargoGrp,"INFskill"] call eos_fnc_grouphandlers;
    		_fGroup set [count _fGroup,_cargoGrp];
    			null = [_mkr,_fGroup,_counter] execvm "eos\functions\TransportUnload_fnc.sqf";
    				}else{
    					_wp1 = (_fGroup select 2) addWaypoint [(markerpos _mkr), 0];  
    					_wp1 setWaypointSpeed "FULL";  
    					_wp1 setWaypointType "SAD";};
    			
    						0=[(_fGroup select 2),"AIRskill"] call eos_fnc_grouphandlers;
    			
    if (_debug) then {player sidechat format ["Chopper:%1",_counter];0= [_mkr,_counter,"Chopper",(getpos leader (_fGroup select 2))] call EOS_debug};
    			};	
    
    
    			
    //SPAWN ALT TRIGGERS	
    			_clear = createTrigger ["EmptyDetector",_mPos]; 
    			_clear setTriggerArea [_mkrX,_mkrY,_mkrAgl,FALSE]; 
    			_clear setTriggerActivation [_enemyFaction,"NOT PRESENT",true]; 
    			_clear setTriggerStatements ["this","",""]; 
    				_taken = createTrigger ["EmptyDetector",_mPos]; 
    				_taken setTriggerArea [_mkrX,_mkrY,_mkrAgl,FALSE];
    				_taken setTriggerActivation ["ANY","PRESENT",true]; 
    				_taken setTriggerStatements ["{vehicle _x in thisList && isplayer _x && ((getPosATL _x) select 2) < 5} count allUnits > 0","",""]; 
    _eosAct=true;	
    while {_eosAct} do
    	{
    	// IF PLAYER LEAVES THE AREA OR ZONE DEACTIVATED
    	if (!triggeractivated _eosActivated || getmarkercolor _mkr == "colorblack") exitwith 
    		{
    		if (_debug) then {if (!(getmarkercolor _mkr == "colorblack")) then {hint "Restarting Zone AND deleting units";}else{hint "EOS zone deactivated";};};		
    //CACHE LIGHT VEHICLES
    	if (!isnil "_cGrp") then 
    				{				
    						{	_vehicle = _x select 0;_crew = _x select 1;_grp = _x select 2;
    									if (!alive _vehicle || {!alive _x} foreach _crew) then { _cGrps= _cGrps - 1;};	
    												{deleteVehicle _x} forEach (_crew);		
    														if (!(vehicle player == _vehicle)) then {{deleteVehicle _x} forEach[_vehicle];};												
    																			{deleteVehicle _x} foreach units _grp;deleteGroup _grp;
    						}foreach _cGrp;
    if (_debug) then {player sidechat format ["ID:c%1",_cGrps];};};
    											
    // CACHE ARMOURED VEHICLES
    		if (!isnil "_dGrp") then 
    				{				
    						{	_vehicle = _x select 0;_crew = _x select 1;_grp = _x select 2;
    									if (!alive _vehicle || {!alive _x} foreach _crew) then {_dGrps= _dGrps - 1;};	
    												{deleteVehicle _x} forEach (_crew);		
    														if (!(vehicle player == _vehicle)) then {{deleteVehicle _x} forEach[_vehicle];};												
    																			{deleteVehicle _x} foreach units _grp;deleteGroup _grp;
    						}foreach _dGrp;
    if (_debug) then {player sidechat format ["ID:c%1",_dGrps];};};
    
    // CACHE PATROL INFANTRY					
    	if (!isnil "_bGrp") then 
    				{		_n=0;					
    						{	_n=_n+1;_units={alive _x} count units _x;_cacheGrp=format ["PA%1",_n];
    	if (_debug) then{player sidechat format ["ID:%1,cache - %2",_cacheGrp,_units];};
    						_eosActivated setvariable [_cacheGrp,_units];		
    						{deleteVehicle _x} foreach units _x;deleteGroup _x;
    						}foreach _bGrp;
    				};
    						
    // CACHE HOUSE INFANTRY
    	if (!isnil "_aGrp") then 
    				{		_n=0;					
    						{	_n=_n+1;_units={alive _x} count units _x;_cacheGrp=format ["HP%1",_n];
    	if (_debug) then{player sidechat format ["ID:%1,cache - %2",_cacheGrp,_units];};
    						_eosActivated setvariable [_cacheGrp,_units];		
    						{deleteVehicle _x} foreach units _x;deleteGroup _x;
    						}foreach _aGrp;
    				};
    					
    // CACHE MORTARS			
    	if (!isnil "_eGrp") then 
    				{			
    						{	_vehicle = _x select 0;_crew = _x select 1;_grp = _x select 2;
    									if (!alive _vehicle || {!alive _x} foreach _crew) then {_eGrps= _eGrps - 1;};			
    														{deleteVehicle _x} forEach (_crew);
    															if (!(vehicle player == _vehicle)) then {{deleteVehicle _x} forEach[_vehicle];};													
    																	{deleteVehicle _x} foreach units _grp;deleteGroup _grp;
    						}foreach _eGrp;};	
    						
    // CACHE HELICOPTER TRANSPORT
    	if (!isnil "_fGrp") then 
    				{			
    						{	_vehicle = _x select 0;_crew = _x select 1;_grp = _x select 2; _cargoGrp = _x select 3;
    									if (!alive _vehicle || {!alive _x} foreach _crew) then {_fGrps= _fGrps - 1;};			
    														{deleteVehicle _x} forEach (_crew);
    															if (!(vehicle player == _vehicle)) then {{deleteVehicle _x} forEach[_vehicle];};													
    																	{deleteVehicle _x} foreach units _grp;deleteGroup _grp;
    																	if (!isnil "_cargoGrp") then {
    																	{deleteVehicle _x} foreach units _cargoGrp;deleteGroup _cargoGrp;};
    																	
    						}foreach _fGrp;};	
    						
    _eosAct=false;
    if (_debug) then {hint "Zone Cached";};
    };
    	if (triggeractivated _clear and triggeractivated _taken and !_civZone)exitwith 
    			{// IF ZONE CAPTURED BEGIN CHECKING FOR ENEMIES
    				_cGrps=0;_aGrps=0;_bGrps=0;_dGrps=0;_eGrps=0;_fGrps=0;		
    				while {triggeractivated _eosActivated AND !(getmarkercolor _mkr == "colorblack")} do 
    						{
    							if (!triggeractivated _clear) then
    							{
    								_mkr setmarkercolor hostileColor;
    								_mkr setmarkerAlpha _mAH;
    								if (_debug) then {hint "Zone Lost";};
    										}else{
    											_mkr setmarkercolor VictoryColor;
    											_mkr setmarkerAlpha _mAN;
    											if (_debug) then {hint "Zone Captured";};
    											};
    				sleep 1;};
    // PLAYER LEFT ZONE				
    _eosAct=false;		
    			};sleep 0.5;};
    
    deletevehicle _clear;deletevehicle _taken;	
    	
    if (!(getmarkercolor _mkr == "colorblack")) then {	
    	null = [_mkr,[_aGrps,_aSize],[_bGrps,_bSize],[_cGrps,_cSize],[_dGrps,_eGrps,_fGrps,_fSize],_settings,true] execVM "eos\core\eos_core.sqf";
    	}else{_Mkr setmarkeralpha 0;};
    	};

     

    eos/functions SHK_buildingpos.sqf

      Reveal hidden contents
    
    
    
    // Infantry Occupy House
    // by Zenophon
    // Released under Creative Commons Attribution-NonCommercial 4.0 International (CC BY-NC 4.0)
    // http://creativecommons.org/licenses/by-nc/4.0/
    
    // Teleports the units to random windows of the building(s) within the distance
    // Faces units in the right direction and orders them to stand up or crouch on a roof
    // Units will only fill the building to as many positions as there are windows
    // Multiple buildings can be filled either evenly or to the limit of each sequentially
    // Usage : Call, execVM
    // Params: 1. Array, the building(s) nearest this position is used
    //         2. Array of objects, the units that will garrison the building(s)
    //  (opt.) 3. Scalar, radius in which to fill building(s), -1 for only nearest building, (default: -1)
    //  (opt.) 4. Boolean, true to put units on the roof, false for only inside, (default: false)
    //  (opt.) 5. Boolean, true to fill all buildings in radius evenly, false for one by one, (default: false)
    //  (opt.) 6. Boolean, true to fill from the top of the building down, (default: false)
    //  (opt.) 7. Boolean, true to order AI units to move to the position instead of teleporting, (default: false)
    // Return: Array of objects, the units that were not garrisoned
    
    #define I(X) X = X + 1;
    #define EVAL(X) (X call _comparator)
    #define EYE_HEIGHT 1.53
    #define CHECK_DISTANCE 5
    #define FOV_ANGLE 10
    #define ROOF_CHECK 4
    #define ROOF_EDGE 2
    
    private ["_center", "_units", "_buildingRadius", "_putOnRoof", "_fillEvenly", "_Zen_ExtendPosition", "_buildingsArray", "_buildingPosArray", "_buildingPositions", "_posArray", "_unitIndex", "_j", "_building", "_posArray", "_randomIndex", "_housePos", "_startAngle", "_i", "_checkPos", "_hitCount", "_isRoof", "_edge", "_k", "_unUsedUnits", "_array", "_sortHeight", "_Zen_InsertionSort", "_Zen_ArrayShuffle", "_doMove"];
    
    _center = _this param [0, [0,0,0], [[]], 3];
    _units = _this param [1, [objNull], [[]]];
    _buildingRadius = _this param [2, -1, [0]];
    _putOnRoof = _this param [3, false, [true]];
    _fillEvenly = _this param [4, false, [true]];
    _sortHeight = _this param [5, false, [true]];
    _doMove = _this param [6, false, [true]];
    
    if (_center isEqualTo [0,0,0]) exitWith {
        player sideChat str "Zen_Occupy House Error : Invalid position given.";
        diag_log "Zen_Occupy House Error : Invalid position given.";
        ([])
    };
    
    if ((count _units == 0) || {isNull (_units select 0)}) exitWith {
        player sideChat str "Zen_Occupy House Error : No units given.";
        diag_log "Zen_Occupy House Error : No units given.";
        ([])
    };
    
    _Zen_ExtendPosition = {
        private ["_center", "_dist", "_phi"];
    
        _center = _this select 0;
        _dist = _this select 1;
        _phi = _this select 2;
    
        ([(_center select 0) + (_dist * (cos _phi)),(_center select 1) + (_dist * (sin _phi)), (_this select 3)])
    };
    
    _Zen_InsertionSort = {
        private ["_i", "_j", "_count", "_array", "_element", "_value", "_comparator"];
    
        _array = _this select 0;
        _comparator = _this select 1;
        _count = count _array - 1;
    
        if (count _array == 0) exitWith {};
        for "_i" from 1 to _count step 1 do {
            scopeName "forI";
            _element = _array select _i;
            _value = EVAL(_element);
    
            for [{_j = _i}, {_j >= 1}, {_j = _j - 1}] do {
                if (_value > EVAL(_array select (_j - 1))) then {
                    breakTo "forI";
                };
                _array set [_j, _array select (_j - 1)];
            };
    
            _array set [_j, _element];
        };
        if (true) exitWith {};
    };
    
    _Zen_ArrayShuffle = {
        private ["_array", "_j", "_i", "_temp"];
        _array = _this select 0;
    
        if (count _array > 1) then {
            for "_i" from 0 to (count _array - 1) do {
                    _j = _i + floor random ((count _array) - _i);
                    _temp = _array select _i;
                    _array set [_i, (_array select _j)];
                    _array set [_j, _temp];
            };
        };
        if (true) exitWith {};
    };
    
    if (_buildingRadius < 0) then {
        _buildingsArray = [nearestBuilding _center];
    } else {
        _buildingsArray0 = nearestObjects [_center, ["house"], _buildingRadius];
        _buildingsArray1 = nearestObjects [_center, ["building"], _buildingRadius];
        _buildingsArray = _buildingsArray0 arrayIntersect _buildingsArray1;
    };
    
    if (count _buildingsArray == 0) exitWith {
        player sideChat str "Zen_Occupy House Error : No buildings found.";
        diag_log "Zen_Occupy House Error : No buildings found.";
        ([])
    };
    
    _buildingPosArray = [];
    0 = [_buildingsArray] call _Zen_ArrayShuffle;
    {
        _posArray = [];
        for "_i" from 0 to 1000 do {
            if ((_x buildingPos _i) isEqualTo [0,0,0]) exitWith {};
            _posArray pushBack (_x buildingPos _i);
        };
    
        _buildingPosArray pushBack _posArray;
    } forEach _buildingsArray;
    
    if (_sortHeight) then {
        {
            0 = [_x, {-1 * (_this select 2)}] call _Zen_InsertionSort;
        } forEach _buildingPosArray;
    } else {
        {
            0 = [_x] call _Zen_ArrayShuffle;
        } forEach _buildingPosArray;
    };
    
    _unitIndex = 0;
    for [{_j = 0}, {(_unitIndex < count _units) && {(count _buildingPosArray > 0)}}, {I(_j)}] do {
        scopeName "for";
    
        _building = _buildingsArray select (_j % (count _buildingsArray));
        _posArray = _buildingPosArray select (_j % (count _buildingPosArray));
    
        if (count _posArray == 0) then {
            _buildingsArray deleteAt (_j % (count _buildingsArray));
            _buildingPosArray deleteAt (_j % (count _buildingPosArray));
        };
    
        while {(count _posArray) > 0} do {
            scopeName "while";
            if (_unitIndex >= count _units) exitWith {};
    
            _housePos = _posArray select 0;
            _posArray deleteAt 0;
            _housePos = [(_housePos select 0), (_housePos select 1), (_housePos select 2) + (getTerrainHeightASL _housePos) + EYE_HEIGHT];
    
            _startAngle = (round random 10) * (round random 36);
            for "_i" from _startAngle to (_startAngle + 350) step 10 do {
                _checkPos = [_housePos, CHECK_DISTANCE, (90 - _i), (_housePos select 2)] call _Zen_ExtendPosition;
                if !(lineIntersects [_checkPos, [_checkPos select 0, _checkPos select 1, (_checkPos select 2) + 25], objNull, objNull]) then {
                    if !(lineIntersects [_housePos, _checkPos, objNull, objNull]) then {
                        _checkPos = [_housePos, CHECK_DISTANCE, (90 - _i), (_housePos select 2) + (CHECK_DISTANCE * tan FOV_ANGLE)] call _Zen_ExtendPosition;
                        if !(lineIntersects [_housePos, _checkPos, objNull, objNull]) then {
                            _hitCount = 0;
                            for "_k" from 30 to 360 step 30 do {
                                _checkPos = [_housePos, 20, (90 - _k), (_housePos select 2)] call _Zen_ExtendPosition;
                                if (lineIntersects [_housePos, _checkPos, objNull, objNull]) then {
                                    I(_hitCount)
                                };
    
                                if (_hitCount >= ROOF_CHECK) exitWith {};
                            };
    
                            _isRoof = (_hitCount < ROOF_CHECK) && {!(lineIntersects [_housePos, [_housePos select 0, _housePos select 1, (_housePos select 2) + 25], objNull, objNull])};
                            if (!(_isRoof) || {((_isRoof) && {(_putOnRoof)})}) then {
                                if (_isRoof) then {
                                    _edge = false;
                                    for "_k" from 30 to 360 step 30 do {
                                        _checkPos = [_housePos, ROOF_EDGE, (90 - _k), (_housePos select 2)] call _Zen_ExtendPosition;
                                        _edge = !(lineIntersects [_checkPos, [(_checkPos select 0), (_checkPos select 1), (_checkPos select 2) - EYE_HEIGHT - 1], objNull, objNull]);
    
                                        if (_edge) exitWith {
                                            _i = _k;
                                        };
                                    };
                                };
    
                                if (!(_isRoof) || {_edge}) then {
                                    (_units select _unitIndex) doWatch ([_housePos, CHECK_DISTANCE, (90 - _i), (_housePos select 2) - (getTerrainHeightASL _housePos)] call _Zen_ExtendPosition);
    
                                    (_units select _unitIndex) disableAI "TARGET";
                                    if (_doMove) then {
                                        (_units select _unitIndex) doMove ASLToATL ([(_housePos select 0), (_housePos select 1), (_housePos select 2) - EYE_HEIGHT]);
                                    } else {
                                        (_units select _unitIndex) setPosASL [(_housePos select 0), (_housePos select 1), (_housePos select 2) - EYE_HEIGHT];
                                        (_units select _unitIndex) setDir _i;
    
                                        doStop (_units select _unitIndex);
                                        (_units select _unitIndex) forceSpeed 0;
                                    };
    
                                   //** JBOY_UpDown by JohnnyBoy //*/
                                    #define JBOY_UpDown \
                                        if ((_this select 0) getVariable ["FIREDLOCKOUT", false]) exitWith {}; \
                                        if (!isServer)  exitWith {}; \
                                        _dude = _this select 0; \
                                        _stances = _this select 1; \
                                        _ehid = (_dude getVariable "EHID"); \
                                        _dude setVariable ["FIREDLOCKOUT", true]; \
                                        while {alive _dude} do { \
                                            if ((unitPos _dude) == (_stances select 0)) then { \
                                                _dude setUnitPos (_stances select 1); \
                                            } else { \
                                                _dude setUnitPos (_stances select 0); \
                                            }; \
                                            sleep 5 + (random 2); \
                                        }; \
    									_dude removeEventHandler ["FiredNear",_ehid]; 
    								
                                        if (_isRoof) then {
                                        	(_units select _unitIndex) setUnitPos "MIDDLE";
                                           _eh = (_units select _unitIndex) addEventHandler ["FiredNear",{[(_this select 0),["DOWN","MIDDLE"]] spawn {JBOY_UpDown};}];
                                        	(_units select _unitIndex) setVariable ["EHID", _eh];
                                           
                                        } else {
                                        	(_units select _unitIndex) setUnitPos "UP";
                                           _eh = (_units select _unitIndex) addEventHandler ["FiredNear",{[(_this select 0),["UP","MIDDLE"]] spawn {JBOY_UpDown};}];
                                           (_units select _unitIndex) setVariable ["EHID", _eh];
                                          
                                        }; 
    								
    
                                    I(_unitIndex)
                                    if (_fillEvenly) then {
                                        breakTo "for";
                                    } else {
                                        breakTo "while";
                                    };
                                };
                            };
                        };
                    };
                };
            };
        };
    };
    
    if (_doMove) then {
        0 = [_units, _unitIndex] spawn {
            _units = _this select 0;
            _unitIndex = _this select 1;
    
            _usedUnits = [];
            for "_i" from 0 to (_unitIndex - 1) do {
                _usedUnits pushBack (_units select _i);
            };
    
            while {count _usedUnits > 0} do {
                sleep 1;
                _toRemove =  [];
                {
                    if (unitReady _x) then {
                        doStop _x;
                        _x forceSpeed 0;
                        _toRemove pushBack _forEachIndex;
                    };
                } forEach _usedUnits;
    
                {
                    _usedUnits deleteAt (_x - _forEachIndex);
                } forEach _toRemove;
            };
            if (true) exitWith {};
        };
    };
    
    _unUsedUnits = [];
    for "_i" from _unitIndex to (count _units - 1) step 1 do {
        _unUsedUnits pushBack (_units select _i);
    };
    
    (_unUsedUnits)
    
    // Changelog
    // 7/21/15
        // 1. Added: Error reporting for invalid position and unit array arguments
        // 1. Added: Check and error report if no buildings are found
        // 3. Improved: Parameters 3, 4, and 5 are now optional and check for the correct type
        // 4. Improved: Parameters 6 and 7 check for the correct type
        // 5. Improved: AI should now stay in place better (thanks to JohnnyBoy)
    
    // 7/6/15
        // 1. Added: AI now take cover when fired upon (credit to JohnnyBoy)
        // 2. Added: Parameter to order the AI to move to their position
        // 3. Improved: The order of buildings filled is now random
        // 4. Improved: A few minor optimizations
    
    // 6/30/15
        // 1. Added: Parameter to fill buildings from top to bottom
        // 2. Improved: Optimized
    
    // 7/31/14
        // 1. Added: Parameter to cycle through each building in the radius, giving units to each one
        // 2. Improved: Units on roof are only placed at the edge, and face the edge
        // 3. Improved: Optimized roof check
        // 4. Improved: General script cleanup
    
    // 7/28/14
        // 1. Fixed: Units facing the wrong window
        // 2. Added: Parameter for distance to select multiple buildings
        // 3. Added: Parameter for units being on a roof
        // 4. Improved: Now checks that unit has a good FOV from the windows
        // 5. Improved: Units can no longer face a windows greater than 5 meters away
        // 6. Improved: Units on a roof now crouch
        // 7. Tweaked: Height of human eye to the exact value in ArmA
    
    // 7/24/14
        // Initial Release
    
    // Known Issues
        // None

     

     

    enable dynamic simulation for markers more then 500m by 500m. I like this fillhouse script a little better

    This one? i added a call to a script to see if marker is bigger then 500m by 500m than enable dynamic simulation for each unit. i also switched out the fillhouse to a much better IMHO, each file must be replaced for it to work


  8. On 2/18/2018 at 9:28 AM, Grumpy Old Man said:

     

    Well of course there is!

     

    ZHf2jjf.jpg

     

     

    Weird practice of adding and removing the EH constantly, you could simply make a lockout like this, added simple speed of sound formula, reveal value depending on distance and some comments:

     

    
    _ID = player addEventHandler ["Fired",{
    
    	params ["_firer","_weapon","_muzzle","_mode","_ammo","_magazine","_projectile","_gunner"];
    
    	//check for lockout
    	if (time < _firer getVariable ["GOM_fnc_revealLockout",-1]) exitWith {hintSilent "Locked out!"};
    	//we're not locked out, so we set a lock
    	_firer setVariable ["GOM_fnc_revealLockout", time + 5,true];//makes the reveal be available in 5s from now
    
    	//at first eliminate everything that should not happen
    	//we assume you don't want to reveal to a unit 50km away, decide for 800m maximum
    
    	_debugText = ""; //always good to have
    
    	allUnits select {_x distance2d _firer <= 800} apply {
    
    	//now we calculate speed of sound, basic formula without temperature or air pressure shenanigans, assuming 343m/s
    		_distance = _x distance _firer;
    		_travelTime = _distance / 343;//not using distance2d since that would be odd
    
    		//we also don't want to reveal a fixed value to every unit, linearConversion is ace here
    		//read the wiki on it, quite a handy command
    		//we already have a max distance, so we say maximum reveal of 4 happens under 100m, at 800m we reveal 0
    		//anything inbetween will be a linear value
    		//this will reveal 4 at 100m, 2.28571 at 400m and 0.00571418 at 799m
    		_revealValue = linearConversion [100,800,_distance,4,0];
    
    		//since we also want to know what's going on a simple hint comes into play:
    		_debugText = _debugText + format ["%1 got revealed to %2\n%3m, %4 seconds, %5 reveal value.\n\n",_firer,_x,_distance,_travelTime,_revealValue];
    
    		//now we need to spawn a new function so the delay works:
    		_delayedReveal = [_firer,_x,_distance,_travelTime,_revealValue] spawn {
    
    			params ["_firer","_unit","_travelTime","_revealValue"];
    			sleep _travelTime;
    			_unit reveal [_firer,_revealValue];
    			true
    
    		}
    
    	};
    hintsilent str _debugText;
    
    
    }];
    player setVariable ["GOM_fnc_firedRevealID",_ID];//store the EH ID on the object to keep things tidy

     

    Also:

    
    _1=0;

    Never do that, that's nasty.

     

    Cheers

    now I remember what I wanted to say.

    _delayedReveal = [_firer,_x,_distance,_travelTime,_revealValue] spawn {
    
    params ["_firer","_unit","_travelTime","_revealValue"];

    take out (_distance). params is looking for 4 variables

    • Like 2

  9. made a small change to JBOY UpDown script.  added a logic statement that lockouts further while loops from exec if one is already running. then removes EH based on eventhandler index id for the unit 

    Spoiler
    
    // Infantry Occupy House
    // by Zenophon
    // Released under Creative Commons Attribution-NonCommercial 4.0 International (CC BY-NC 4.0)
    // http://creativecommons.org/licenses/by-nc/4.0/
    
    // Teleports the units to random windows of the building(s) within the distance
    // Faces units in the right direction and orders them to stand up or crouch on a roof
    // Units will only fill the building to as many positions as there are windows
    // Multiple buildings can be filled either evenly or to the limit of each sequentially
    // Usage : Call, execVM
    // Params: 1. Array, the building(s) nearest this position is used
    //         2. Array of objects, the units that will garrison the building(s)
    //  (opt.) 3. Scalar, radius in which to fill building(s), -1 for only nearest building, (default: -1)
    //  (opt.) 4. Boolean, true to put units on the roof, false for only inside, (default: false)
    //  (opt.) 5. Boolean, true to fill all buildings in radius evenly, false for one by one, (default: false)
    //  (opt.) 6. Boolean, true to fill from the top of the building down, (default: false)
    //  (opt.) 7. Boolean, true to order AI units to move to the position instead of teleporting, (default: false)
    // Return: Array of objects, the units that were not garrisoned
    
    #define I(X) X = X + 1;
    #define EVAL(X) (X call _comparator)
    #define EYE_HEIGHT 1.53
    #define CHECK_DISTANCE 5
    #define FOV_ANGLE 10
    #define ROOF_CHECK 4
    #define ROOF_EDGE 2
    
    private ["_center", "_units", "_buildingRadius", "_putOnRoof", "_fillEvenly", "_Zen_ExtendPosition", "_buildingsArray", "_buildingPosArray", "_buildingPositions", "_posArray", "_unitIndex", "_j", "_building", "_posArray", "_randomIndex", "_housePos", "_startAngle", "_i", "_checkPos", "_hitCount", "_isRoof", "_edge", "_k", "_unUsedUnits", "_array", "_sortHeight", "_Zen_InsertionSort", "_Zen_ArrayShuffle", "_doMove"];
    
    _center = _this param [0, [0,0,0], [[]], 3];
    _units = _this param [1, [objNull], [[]]];
    _buildingRadius = _this param [2, -1, [0]];
    _putOnRoof = _this param [3, false, [true]];
    _fillEvenly = _this param [4, false, [true]];
    _sortHeight = _this param [5, false, [true]];
    _doMove = _this param [6, false, [true]];
    
    if (_center isEqualTo [0,0,0]) exitWith {
        player sideChat str "Zen_Occupy House Error : Invalid position given.";
        diag_log "Zen_Occupy House Error : Invalid position given.";
        ([])
    };
    
    if ((count _units == 0) || {isNull (_units select 0)}) exitWith {
        player sideChat str "Zen_Occupy House Error : No units given.";
        diag_log "Zen_Occupy House Error : No units given.";
        ([])
    };
    
    _Zen_ExtendPosition = {
        private ["_center", "_dist", "_phi"];
    
        _center = _this select 0;
        _dist = _this select 1;
        _phi = _this select 2;
    
        ([(_center select 0) + (_dist * (cos _phi)),(_center select 1) + (_dist * (sin _phi)), (_this select 3)])
    };
    
    _Zen_InsertionSort = {
        private ["_i", "_j", "_count", "_array", "_element", "_value", "_comparator"];
    
        _array = _this select 0;
        _comparator = _this select 1;
        _count = count _array - 1;
    
        if (count _array == 0) exitWith {};
        for "_i" from 1 to _count step 1 do {
            scopeName "forI";
            _element = _array select _i;
            _value = EVAL(_element);
    
            for [{_j = _i}, {_j >= 1}, {_j = _j - 1}] do {
                if (_value > EVAL(_array select (_j - 1))) then {
                    breakTo "forI";
                };
                _array set [_j, _array select (_j - 1)];
            };
    
            _array set [_j, _element];
        };
        if (true) exitWith {};
    };
    
    _Zen_ArrayShuffle = {
        private ["_array", "_j", "_i", "_temp"];
        _array = _this select 0;
    
        if (count _array > 1) then {
            for "_i" from 0 to (count _array - 1) do {
                    _j = _i + floor random ((count _array) - _i);
                    _temp = _array select _i;
                    _array set [_i, (_array select _j)];
                    _array set [_j, _temp];
            };
        };
        if (true) exitWith {};
    };
    
    if (_buildingRadius < 0) then {
        _buildingsArray = [nearestBuilding _center];
    } else {
        _buildingsArray0 = nearestObjects [_center, ["house"], _buildingRadius];
        _buildingsArray1 = nearestObjects [_center, ["building"], _buildingRadius];
        _buildingsArray = _buildingsArray0 arrayIntersect _buildingsArray1;
    };
    
    if (count _buildingsArray == 0) exitWith {
        player sideChat str "Zen_Occupy House Error : No buildings found.";
        diag_log "Zen_Occupy House Error : No buildings found.";
        ([])
    };
    
    _buildingPosArray = [];
    0 = [_buildingsArray] call _Zen_ArrayShuffle;
    {
        _posArray = [];
        for "_i" from 0 to 1000 do {
            if ((_x buildingPos _i) isEqualTo [0,0,0]) exitWith {};
            _posArray pushBack (_x buildingPos _i);
        };
    
        _buildingPosArray pushBack _posArray;
    } forEach _buildingsArray;
    
    if (_sortHeight) then {
        {
            0 = [_x, {-1 * (_this select 2)}] call _Zen_InsertionSort;
        } forEach _buildingPosArray;
    } else {
        {
            0 = [_x] call _Zen_ArrayShuffle;
        } forEach _buildingPosArray;
    };
    
    _unitIndex = 0;
    for [{_j = 0}, {(_unitIndex < count _units) && {(count _buildingPosArray > 0)}}, {I(_j)}] do {
        scopeName "for";
    
        _building = _buildingsArray select (_j % (count _buildingsArray));
        _posArray = _buildingPosArray select (_j % (count _buildingPosArray));
    
        if (count _posArray == 0) then {
            _buildingsArray deleteAt (_j % (count _buildingsArray));
            _buildingPosArray deleteAt (_j % (count _buildingPosArray));
        };
    
        while {(count _posArray) > 0} do {
            scopeName "while";
            if (_unitIndex >= count _units) exitWith {};
    
            _housePos = _posArray select 0;
            _posArray deleteAt 0;
            _housePos = [(_housePos select 0), (_housePos select 1), (_housePos select 2) + (getTerrainHeightASL _housePos) + EYE_HEIGHT];
    
            _startAngle = (round random 10) * (round random 36);
            for "_i" from _startAngle to (_startAngle + 350) step 10 do {
                _checkPos = [_housePos, CHECK_DISTANCE, (90 - _i), (_housePos select 2)] call _Zen_ExtendPosition;
                if !(lineIntersects [_checkPos, [_checkPos select 0, _checkPos select 1, (_checkPos select 2) + 25], objNull, objNull]) then {
                    if !(lineIntersects [_housePos, _checkPos, objNull, objNull]) then {
                        _checkPos = [_housePos, CHECK_DISTANCE, (90 - _i), (_housePos select 2) + (CHECK_DISTANCE * tan FOV_ANGLE)] call _Zen_ExtendPosition;
                        if !(lineIntersects [_housePos, _checkPos, objNull, objNull]) then {
                            _hitCount = 0;
                            for "_k" from 30 to 360 step 30 do {
                                _checkPos = [_housePos, 20, (90 - _k), (_housePos select 2)] call _Zen_ExtendPosition;
                                if (lineIntersects [_housePos, _checkPos, objNull, objNull]) then {
                                    I(_hitCount)
                                };
    
                                if (_hitCount >= ROOF_CHECK) exitWith {};
                            };
    
                            _isRoof = (_hitCount < ROOF_CHECK) && {!(lineIntersects [_housePos, [_housePos select 0, _housePos select 1, (_housePos select 2) + 25], objNull, objNull])};
                            if (!(_isRoof) || {((_isRoof) && {(_putOnRoof)})}) then {
                                if (_isRoof) then {
                                    _edge = false;
                                    for "_k" from 30 to 360 step 30 do {
                                        _checkPos = [_housePos, ROOF_EDGE, (90 - _k), (_housePos select 2)] call _Zen_ExtendPosition;
                                        _edge = !(lineIntersects [_checkPos, [(_checkPos select 0), (_checkPos select 1), (_checkPos select 2) - EYE_HEIGHT - 1], objNull, objNull]);
    
                                        if (_edge) exitWith {
                                            _i = _k;
                                        };
                                    };
                                };
    
                                if (!(_isRoof) || {_edge}) then {
                                    (_units select _unitIndex) doWatch ([_housePos, CHECK_DISTANCE, (90 - _i), (_housePos select 2) - (getTerrainHeightASL _housePos)] call _Zen_ExtendPosition);
    
                                    (_units select _unitIndex) disableAI "TARGET";
                                    if (_doMove) then {
                                        (_units select _unitIndex) doMove ASLToATL ([(_housePos select 0), (_housePos select 1), (_housePos select 2) - EYE_HEIGHT]);
                                    } else {
                                        (_units select _unitIndex) setPosASL [(_housePos select 0), (_housePos select 1), (_housePos select 2) - EYE_HEIGHT];
                                        (_units select _unitIndex) setDir _i;
    
                                        doStop (_units select _unitIndex);
                                        (_units select _unitIndex) forceSpeed 0;
                                    };
    
                                   //** JBOY_UpDown by JohnnyBoy //*/
                                    #define JBOY_UpDown \
                                        if ((_this select 0) getVariable ["FIREDLOCKOUT", false]) exitWith {}; \
                                        (_this select 0) setVariable ["FIREDLOCKOUT", true]; \
                                        if (!isServer)  exitWith {}; \
                                        _dude = _this select 0; \
                                        _stances = _this select 1; \
                                        _ehid = (_dude getVariable "EHID"); \
                                        _dude removeEventHandler ["FiredNear",_ehid]; \
                                        while {alive _dude} do { \
                                            if ((unitPos _dude) == (_stances select 0)) then { \
                                                _dude setUnitPos (_stances select 1); \
                                            } else { \
                                                _dude setUnitPos (_stances select 0); \
                                            }; \
                                            sleep 5 + (random 2); \
                                        };  
                                        
                                        if (_isRoof) then {
                                        	(_units select _unitIndex) setUnitPos "MIDDLE";
                                           _eh = (_units select _unitIndex) addEventHandler ["FiredNear",{[(_this select 0),["DOWN","MIDDLE"]] spawn {JBOY_UpDown};}];
                                        	(_units select _unitIndex) setVariable ["EHID", _eh];
                                           
                                        } else {
                                        	(_units select _unitIndex) setUnitPos "UP";
                                           _eh = (_units select _unitIndex) addEventHandler ["FiredNear",{[(_this select 0),["UP","MIDDLE"]] spawn {JBOY_UpDown};}];
                                           (_units select _unitIndex) setVariable ["EHID", _eh];
                                          
                                        }; 
    								
    
                                    I(_unitIndex)
                                    if (_fillEvenly) then {
                                        breakTo "for";
                                    } else {
                                        breakTo "while";
                                    };
                                };
                            };
                        };
                    };
                };
            };
        };
    };
    
    if (_doMove) then {
        0 = [_units, _unitIndex] spawn {
            _units = _this select 0;
            _unitIndex = _this select 1;
    
            _usedUnits = [];
            for "_i" from 0 to (_unitIndex - 1) do {
                _usedUnits pushBack (_units select _i);
            };
    
            while {count _usedUnits > 0} do {
                sleep 1;
                _toRemove =  [];
                {
                    if (unitReady _x) then {
                        doStop _x;
                        _x forceSpeed 0;
                        _toRemove pushBack _forEachIndex;
                    };
                } forEach _usedUnits;
    
                {
                    _usedUnits deleteAt (_x - _forEachIndex);
                } forEach _toRemove;
            };
            if (true) exitWith {};
        };
    };
    
    _unUsedUnits = [];
    for "_i" from _unitIndex to (count _units - 1) step 1 do {
        _unUsedUnits pushBack (_units select _i);
    };
    
    (_unUsedUnits)
    
    // Changelog
    // 7/21/15
        // 1. Added: Error reporting for invalid position and unit array arguments
        // 1. Added: Check and error report if no buildings are found
        // 3. Improved: Parameters 3, 4, and 5 are now optional and check for the correct type
        // 4. Improved: Parameters 6 and 7 check for the correct type
        // 5. Improved: AI should now stay in place better (thanks to JohnnyBoy)
    
    // 7/6/15
        // 1. Added: AI now take cover when fired upon (credit to JohnnyBoy)
        // 2. Added: Parameter to order the AI to move to their position
        // 3. Improved: The order of buildings filled is now random
        // 4. Improved: A few minor optimizations
    
    // 6/30/15
        // 1. Added: Parameter to fill buildings from top to bottom
        // 2. Improved: Optimized
    
    // 7/31/14
        // 1. Added: Parameter to cycle through each building in the radius, giving units to each one
        // 2. Improved: Units on roof are only placed at the edge, and face the edge
        // 3. Improved: Optimized roof check
        // 4. Improved: General script cleanup
    
    // 7/28/14
        // 1. Fixed: Units facing the wrong window
        // 2. Added: Parameter for distance to select multiple buildings
        // 3. Added: Parameter for units being on a roof
        // 4. Improved: Now checks that unit has a good FOV from the windows
        // 5. Improved: Units can no longer face a windows greater than 5 meters away
        // 6. Improved: Units on a roof now crouch
        // 7. Tweaked: Height of human eye to the exact value in ArmA
    
    // 7/24/14
        // Initial Release
    
    // Known Issues
        // None

     

     

    • Like 1
    • Thanks 2

  10. Spoiler

    eos/functions DynSimEnab.sqf

    Spoiler
    
    
    params["_grp","_mkrX","_mkrY"];
    _mkrSz = _mkrX + _mkrY;
    if (_mkrSz > 1000) then {
    	if !(_grp isEqualtype grpNull) then {
    		(_grp select 0) enableDynamicSimulation true;
    		(_grp select 2) enableDynamicSimulation true;
    						
    	} else {
    		_grp enableDynamicSimulation true;
    	};
    };

     

    eos/core spawn_fnc.sqf

    Spoiler
    
    
    
    IF (isnil "server")then{hint "YOU MUST PLACE A GAME LOGIC NAMED SERVER!";};
    eos_fnc_spawnvehicle=compile preprocessfilelinenumbers "eos\functions\eos_SpawnVehicle.sqf";
    eos_fnc_grouphandlers=compile preprocessfilelinenumbers "eos\functions\setSkill.sqf";
    eos_fnc_findsafepos=compile preprocessfilelinenumbers "eos\functions\findSafePos.sqf";
    eos_fnc_spawngroup= compile preprocessfile "eos\functions\infantry_fnc.sqf";
    eos_fnc_setcargo = compile preprocessfile "eos\functions\cargo_fnc.sqf";
    eos_fnc_taskpatrol= compile preprocessfile "eos\functions\shk_patrol.sqf";
    SHK_pos= compile preprocessfile "eos\functions\shk_pos.sqf";
    shk_fnc_fillhouse = compile preprocessFileLineNumbers "eos\Functions\SHK_buildingpos.sqf";
    fnc_enabledynamicsim = compile preprocessFileLineNumbers "eos\Functions\DynSimEnab.sqf";
    eos_fnc_getunitpool= compile preprocessfilelinenumbers "eos\UnitPools.sqf";
    call compile preprocessfilelinenumbers "eos\AI_Skill.sqf";
    
    EOS_Deactivate = {
    	private ["_mkr"];
    		_mkr=(_this select 0);		
    	{
    		_x setmarkercolor "colorblack";
    		_x setmarkerAlpha 0;
    	}foreach _mkr;
    };
    
    EOS_debug = {
    private ["_note"];
    _mkr=(_this select 0);
    _n=(_this select 1);
    _note=(_this select 2);
    _pos=(_this select 3);
    
    _mkrID=format ["%3:%1,%2",_mkr,_n,_note];
    deletemarker _mkrID;
    _debugMkr = createMarker[_mkrID,_pos];
    _mkrID setMarkerType "Mil_dot";
    _mkrID setMarkercolor "colorBlue";
    _mkrID setMarkerText _mkrID;
    _mkrID setMarkerAlpha 0.5;
    };

     

     

    eos/core/eos_core.sqf

    Spoiler
    
    
    if (!isServer) exitWith {};
    private ["_newpos","_cargoType","_vehType","_dGrp","_mkrAgl","_side","_bGroup","_civZone","_fGrp","_fSize","_fGrps","_eGrp","_eGrps","_dGrps","_aMin","_aSize","_aGrps","_aGrp","_bMin","_units","_bSize","_bGrps","_bGrp","_trig","_cache","_grp","_crew","_vehicle","_actCond","_mAN","_mAH","_distance","_mA","_settings","_cGrp","_cSize","_cGrps","_taken","_clear","_enemyFaction","_faction","_n","_eosAct","_eosActivated","_debug","_mkr","_mPos","_mkrX","_mkrY"];
    
    _mkr=(_this select 0);_mPos=markerpos(_this select 0);
    _mkrX=getMarkerSize _mkr select 0;
    _mkrY=getMarkerSize _mkr select 1;
    _mkrAgl=markerDir _mkr;
    _a=(_this select 1);_aGrps=_a select 0;_aSize=_a select 1;_aMin=_aSize select 0;
    _b=(_this select 2);_bGrps=_b select 0;_bSize=_b select 1;_bMin=_bSize select 0;
    _c=(_this select 3);_cGrps=_c select 0;_cSize=_c select 1;
    _d=(_this select 4);_dGrps=_d select 0;_eGrps=_d select 1;_fGrps=_d select 2;_fSize=_d select 3;
    _settings=(_this select 5);_faction=_settings select 0;_mA=_settings select 1;_distance=_settings select 2;_side=_settings select 3;
    _heightLimit=if (count _settings > 4) then {_settings select 4} else {false};
    _debug=if (count _settings > 5) then {_settings select 5} else {false};
    _cache= if (count _this > 6) then {_this select 6} else {false};
    
    
    	if (_side==EAST) then {_enemyFaction="east";_civZone=false;};
    	if (_side==WEST) then {_enemyFaction="west";_civZone=false;};
    	if (_side==INDEPENDENT) then {_enemyFaction="guer";_civZone=false;};
    	if (_side==CIVILIAN) then {_enemyFaction="civ";_civZone=true;};
    
    	if (_mA==0) then {_mAH = 1;_mAN = 0.5;};
    	if (_mA==1) then {_mAH = 0;_mAN = 0;};
    	if (_mA==2) then {_mAH = 0.5;_mAN = 0.5;};
    
    // INITIATE ZONE
    _trig=format ["EOSTrigger%1",_mkr];
    
    
    if (!_cache) then {
    	if ismultiplayer then {
    			if (_heightLimit) then 
    			{_actCond="{vehicle _x in thisList && isplayer _x && ((getPosATL _x) select 2) < 5} count playableunits > 0";
    							}else 
    							{_actCond="{vehicle _x in thisList && isplayer _x} count playableunits > 0";
    		};}else{
    			if (_heightLimit) then 
    						{_actCond="{vehicle _x in thisList && isplayer _x && ((getPosATL _x) select 2) < 5  } count allUnits > 0";
    								}else
    	
    									  {_actCond="{vehicle _x in thisList && isplayer _x || ({_player = _x; {getConnectedUAV _player == _x} count [uav, uav1, uav2, uav3] > 0} count allPlayers > 0 && ({_x in thislist} count [uav, uav1, uav2, uav3] > 0))} count allUnits > 0"; };};
    		_eosActivated = createTrigger ["EmptyDetector",_mPos]; 
    		_eosActivated = createTrigger ["EmptyDetector",_mPos]; 
    		_eosActivated setTriggerArea [(_distance+_mkrX),(_distance+_mkrY),_mkrAgl,FALSE]; 
    		_eosActivated setTriggerActivation ["ANY","PRESENT",true];
    		_eosActivated setTriggerTimeout [1, 1, 1, true];
    		_eosActivated setTriggerStatements [_actCond,"",""];
    		
    			server setvariable [_trig,_eosActivated];	
    					}else{
    				_eosActivated=server getvariable _trig;	
    					};
    		
    					_mkr setmarkerAlpha _mAN;
    						if (!(getmarkercolor _mkr == VictoryColor)) then 	//IF MARKER IS GREEN DO NOT CHANGE COLOUR
    							{
    						_mkr setmarkercolor hostileColor;
    							};
    
    
    
    waituntil {triggeractivated _eosActivated};	//WAIT UNTIL PLAYERS IN ZONE
    if (!(getmarkercolor _mkr == "colorblack"))then {
    	if (!(getmarkercolor _mkr == VictoryColor)) then {_mkr setmarkerAlpha _mAH;};
    
    // SPAWN HOUSE PATROLS
    	for "_counter" from 1 to _aGrps do {
    	if (isnil "_aGrp") then {_aGrp=[];};
    		if (_cache) then {
    				_cacheGrp=format ["HP%1",_counter];
    				_units=_eosActivated getvariable _cacheGrp;	
    						_aSize=[_units,_units];
    						_aMin=_aSize select 0;
    							if (_debug)then{player sidechat format ["ID:%1,restore - %2",_cacheGrp,_units];};
    							};
    								if (_aMin > 0) then {
    										_aGroup=[_mPos,_aSize,_faction,_side] call EOS_fnc_spawngroup;	
    				
    										if (!surfaceiswater _mPos) then {
    											0=[_mPos,(units _aGroup),_mkrX,true,false,true,false] call shk_fnc_fillhouse;
    												}else{
    												0 = [_aGroup,_mkr] call EOS_fnc_taskpatrol;
    													};
    												_aGrp set [count _aGrp,_aGroup];
    												0=[_aGroup,"INFskill"] call eos_fnc_grouphandlers;
    												[_aGroup,_mkrX,_mkrY] call fnc_enabledynamicsim;
    if (_debug) then {PLAYER SIDECHAT (format ["Spawned House Patrol: %1",_counter]);0= [_mkr,_counter,"House Patrol",getpos (leader _aGroup)] call EOS_debug};
    												};
    		};
    		
    // SPAWN PATROLS
    	for "_counter" from 1 to _bGrps do {
    	if (isnil "_bGrp") then {_bGrp=[];};
    		if (_cache) then {
    				_cacheGrp=format ["PA%1",_counter];
    				_units=_eosActivated getvariable _cacheGrp;	
    					_bSize=[_units,_units];
    					_bMin=_bSize select 0;
    					if (_debug)then{player sidechat format ["ID:%1,restore - %2",_cacheGrp,_units];};
    						};
    							if (_bMin > 0) then {	
    									_pos = [_mkr,true] call SHK_pos;			
    									_bGroup=[_pos,_bSize,_faction,_side] call EOS_fnc_spawngroup;
    										0 = [_bGroup,_mkr] call EOS_fnc_taskpatrol;
    										_bGrp set [count _bGrp,_bGroup];
    										0=[_bGroup,"INFskill"] call eos_fnc_grouphandlers;
    										[_bGroup,_mkrX,_mkrY] call fnc_enabledynamicsim;
    if (_debug) then {PLAYER SIDECHAT (format ["Spawned Patrol: %1",_counter]);0= [_mkr,_counter,"patrol",getpos (leader _bGroup)] call EOS_debug};
    												};
    		};	
    	
    //SPAWN LIGHT VEHICLES
    	for "_counter" from 1 to _cGrps do {	
    	if (isnil "_cGrp") then {_cGrp=[];};	
    	
    		_newpos=[_mkr,50] call EOS_fnc_findSafePos;
    			if (surfaceiswater _newpos) then {_vehType=8;_cargoType=10;}else{_vehType=7;_cargoType=9;};
    	
    					_cGroup=[_newpos,_side,_faction,_vehType]call EOS_fnc_spawnvehicle;
    				if ((_cSize select 0) > 0) then{
    						0=[(_cGroup select 0),_cSize,(_cGroup select 2),_faction,_cargoType] call eos_fnc_setcargo;
    						};
    						
    							0=[(_cGroup select 2),"LIGskill"] call eos_fnc_grouphandlers;
    								0 = [(_cGroup select 2),_mkr] call EOS_fnc_taskpatrol;
    								_cGrp set [count _cGrp,_cGroup];	
    								[_cGroup,_mkrX,_mkrY] call fnc_enabledynamicsim;
    								
    if (_debug) then {player sidechat format ["Light Vehicle:%1 - r%2",_counter,_cGrps];0= [_mkr,_counter,"Light Veh",(getpos leader (_cGroup select 2))] call EOS_debug};
    		};	
    		
    //SPAWN ARMOURED VEHICLES
    	for "_counter" from 1 to _dGrps do {
    	if (isnil "_dGrp") then {_dGrp=[];};
    	
    		_newpos=[_mkr,50] call EOS_fnc_findSafePos;
    			if (surfaceiswater _newpos) then {_vehType=8;}else{_vehType=2;};
    			
    					_dGroup=[_newpos,_side,_faction,_vehType]call EOS_fnc_spawnvehicle;
    					
    						0=[(_dGroup select 2),"ARMskill"] call eos_fnc_grouphandlers;
    						0 = [(_dGroup select 2),_mkr] call EOS_fnc_taskpatrol;
    							_dGrp set [count _dGrp,_dGroup];
    							[_dGroup,_mkrX,_mkrY] call fnc_enabledynamicsim;
    							
    if (_debug) then {player sidechat format ["Armoured:%1 - r%2",_counter,_dGrps];0= [_mkr,_counter,"Armour",(getpos leader (_dGroup select 2))] call EOS_debug};
    		};
    		
    //SPAWN STATIC PLACEMENTS
    	for "_counter" from 1 to _eGrps do {
    		if (surfaceiswater _mPos) exitwith {};
    		if (isnil "_eGrp") then {_eGrp=[];};
    				
    		_newpos=[_mkr,50] call EOS_fnc_findSafePos;
    			
    					_eGroup=[_newpos,_side,_faction,5]call EOS_fnc_spawnvehicle;
    		
    						0=[(_eGroup select 2),"STAskill"] call eos_fnc_grouphandlers;
    							_eGrp set [count _eGrp,_eGroup];
    							[_eGroup,_mkrX,_mkrY] call fnc_enabledynamicsim;
    							
    if (_debug) then {player sidechat format ["Static:%1",_counter];0= [_mkr,_counter,"Static",(getpos leader (_eGroup select 2))] call EOS_debug};
    		};	
    		
    //SPAWN CHOPPER
    	for "_counter" from 1 to _fGrps do {
    	if (isnil "_fGrp") then {_fGrp=[];};	
    		if ((_fSize select 0) > 0) then {_vehType=4}else{_vehType=3};
    				_newpos = [(markerpos _mkr), 1500, random 360] call BIS_fnc_relPos;	
    						_fGroup=[_newpos,_side,_faction,_vehType,"fly"]call EOS_fnc_spawnvehicle;	
    						_fGrp set [count _fGrp,_fGroup];
    
    						
    						
    						
    if ((_fSize select 0) > 0) then {
    	_cargoGrp = createGroup _side;
    		0=[(_fGroup select 0),_fSize,_cargoGrp,_faction,9] call eos_fnc_setcargo;
    			0=[_cargoGrp,"INFskill"] call eos_fnc_grouphandlers;
    		_fGroup set [count _fGroup,_cargoGrp];
    			null = [_mkr,_fGroup,_counter] execvm "eos\functions\TransportUnload_fnc.sqf";
    				}else{
    					_wp1 = (_fGroup select 2) addWaypoint [(markerpos _mkr), 0];  
    					_wp1 setWaypointSpeed "FULL";  
    					_wp1 setWaypointType "SAD";};
    			
    						0=[(_fGroup select 2),"AIRskill"] call eos_fnc_grouphandlers;
    			
    if (_debug) then {player sidechat format ["Chopper:%1",_counter];0= [_mkr,_counter,"Chopper",(getpos leader (_fGroup select 2))] call EOS_debug};
    			};	
    
    
    			
    //SPAWN ALT TRIGGERS	
    			_clear = createTrigger ["EmptyDetector",_mPos]; 
    			_clear setTriggerArea [_mkrX,_mkrY,_mkrAgl,FALSE]; 
    			_clear setTriggerActivation [_enemyFaction,"NOT PRESENT",true]; 
    			_clear setTriggerStatements ["this","",""]; 
    				_taken = createTrigger ["EmptyDetector",_mPos]; 
    				_taken setTriggerArea [_mkrX,_mkrY,_mkrAgl,FALSE];
    				_taken setTriggerActivation ["ANY","PRESENT",true]; 
    				_taken setTriggerStatements ["{vehicle _x in thisList && isplayer _x && ((getPosATL _x) select 2) < 5} count allUnits > 0","",""]; 
    _eosAct=true;	
    while {_eosAct} do
    	{
    	// IF PLAYER LEAVES THE AREA OR ZONE DEACTIVATED
    	if (!triggeractivated _eosActivated || getmarkercolor _mkr == "colorblack") exitwith 
    		{
    		if (_debug) then {if (!(getmarkercolor _mkr == "colorblack")) then {hint "Restarting Zone AND deleting units";}else{hint "EOS zone deactivated";};};		
    //CACHE LIGHT VEHICLES
    	if (!isnil "_cGrp") then 
    				{				
    						{	_vehicle = _x select 0;_crew = _x select 1;_grp = _x select 2;
    									if (!alive _vehicle || {!alive _x} foreach _crew) then { _cGrps= _cGrps - 1;};	
    												{deleteVehicle _x} forEach (_crew);		
    														if (!(vehicle player == _vehicle)) then {{deleteVehicle _x} forEach[_vehicle];};												
    																			{deleteVehicle _x} foreach units _grp;deleteGroup _grp;
    						}foreach _cGrp;
    if (_debug) then {player sidechat format ["ID:c%1",_cGrps];};};
    											
    // CACHE ARMOURED VEHICLES
    		if (!isnil "_dGrp") then 
    				{				
    						{	_vehicle = _x select 0;_crew = _x select 1;_grp = _x select 2;
    									if (!alive _vehicle || {!alive _x} foreach _crew) then {_dGrps= _dGrps - 1;};	
    												{deleteVehicle _x} forEach (_crew);		
    														if (!(vehicle player == _vehicle)) then {{deleteVehicle _x} forEach[_vehicle];};												
    																			{deleteVehicle _x} foreach units _grp;deleteGroup _grp;
    						}foreach _dGrp;
    if (_debug) then {player sidechat format ["ID:c%1",_dGrps];};};
    
    // CACHE PATROL INFANTRY					
    	if (!isnil "_bGrp") then 
    				{		_n=0;					
    						{	_n=_n+1;_units={alive _x} count units _x;_cacheGrp=format ["PA%1",_n];
    	if (_debug) then{player sidechat format ["ID:%1,cache - %2",_cacheGrp,_units];};
    						_eosActivated setvariable [_cacheGrp,_units];		
    						{deleteVehicle _x} foreach units _x;deleteGroup _x;
    						}foreach _bGrp;
    				};
    						
    // CACHE HOUSE INFANTRY
    	if (!isnil "_aGrp") then 
    				{		_n=0;					
    						{	_n=_n+1;_units={alive _x} count units _x;_cacheGrp=format ["HP%1",_n];
    	if (_debug) then{player sidechat format ["ID:%1,cache - %2",_cacheGrp,_units];};
    						_eosActivated setvariable [_cacheGrp,_units];		
    						{deleteVehicle _x} foreach units _x;deleteGroup _x;
    						}foreach _aGrp;
    				};
    					
    // CACHE MORTARS			
    	if (!isnil "_eGrp") then 
    				{			
    						{	_vehicle = _x select 0;_crew = _x select 1;_grp = _x select 2;
    									if (!alive _vehicle || {!alive _x} foreach _crew) then {_eGrps= _eGrps - 1;};			
    														{deleteVehicle _x} forEach (_crew);
    															if (!(vehicle player == _vehicle)) then {{deleteVehicle _x} forEach[_vehicle];};													
    																	{deleteVehicle _x} foreach units _grp;deleteGroup _grp;
    						}foreach _eGrp;};	
    						
    // CACHE HELICOPTER TRANSPORT
    	if (!isnil "_fGrp") then 
    				{			
    						{	_vehicle = _x select 0;_crew = _x select 1;_grp = _x select 2; _cargoGrp = _x select 3;
    									if (!alive _vehicle || {!alive _x} foreach _crew) then {_fGrps= _fGrps - 1;};			
    														{deleteVehicle _x} forEach (_crew);
    															if (!(vehicle player == _vehicle)) then {{deleteVehicle _x} forEach[_vehicle];};													
    																	{deleteVehicle _x} foreach units _grp;deleteGroup _grp;
    																	if (!isnil "_cargoGrp") then {
    																	{deleteVehicle _x} foreach units _cargoGrp;deleteGroup _cargoGrp;};
    																	
    						}foreach _fGrp;};	
    						
    _eosAct=false;
    if (_debug) then {hint "Zone Cached";};
    };
    	if (triggeractivated _clear and triggeractivated _taken and !_civZone)exitwith 
    			{// IF ZONE CAPTURED BEGIN CHECKING FOR ENEMIES
    				_cGrps=0;_aGrps=0;_bGrps=0;_dGrps=0;_eGrps=0;_fGrps=0;		
    				while {triggeractivated _eosActivated AND !(getmarkercolor _mkr == "colorblack")} do 
    						{
    							if (!triggeractivated _clear) then
    							{
    								_mkr setmarkercolor hostileColor;
    								_mkr setmarkerAlpha _mAH;
    								if (_debug) then {hint "Zone Lost";};
    										}else{
    											_mkr setmarkercolor VictoryColor;
    											_mkr setmarkerAlpha _mAN;
    											if (_debug) then {hint "Zone Captured";};
    											};
    				sleep 1;};
    // PLAYER LEFT ZONE				
    _eosAct=false;		
    			};sleep 0.5;};
    
    deletevehicle _clear;deletevehicle _taken;	
    	
    if (!(getmarkercolor _mkr == "colorblack")) then {	
    	null = [_mkr,[_aGrps,_aSize],[_bGrps,_bSize],[_cGrps,_cSize],[_dGrps,_eGrps,_fGrps,_fSize],_settings,true] execVM "eos\core\eos_core.sqf";
    	}else{_Mkr setmarkeralpha 0;};
    	};

     

    eos/functions SHK_buildingpos.sqf

    Spoiler
    
    
    // Infantry Occupy House
    // by Zenophon
    // Released under Creative Commons Attribution-NonCommercial 4.0 International (CC BY-NC 4.0)
    // http://creativecommons.org/licenses/by-nc/4.0/
    
    // Teleports the units to random windows of the building(s) within the distance
    // Faces units in the right direction and orders them to stand up or crouch on a roof
    // Units will only fill the building to as many positions as there are windows
    // Multiple buildings can be filled either evenly or to the limit of each sequentially
    // Usage : Call, execVM
    // Params: 1. Array, the building(s) nearest this position is used
    //         2. Array of objects, the units that will garrison the building(s)
    //  (opt.) 3. Scalar, radius in which to fill building(s), -1 for only nearest building, (default: -1)
    //  (opt.) 4. Boolean, true to put units on the roof, false for only inside, (default: false)
    //  (opt.) 5. Boolean, true to fill all buildings in radius evenly, false for one by one, (default: false)
    //  (opt.) 6. Boolean, true to fill from the top of the building down, (default: false)
    //  (opt.) 7. Boolean, true to order AI units to move to the position instead of teleporting, (default: false)
    // Return: Array of objects, the units that were not garrisoned
    
    #define I(X) X = X + 1;
    #define EVAL(X) (X call _comparator)
    #define EYE_HEIGHT 1.53
    #define CHECK_DISTANCE 5
    #define FOV_ANGLE 10
    #define ROOF_CHECK 4
    #define ROOF_EDGE 2
    
    private ["_center", "_units", "_buildingRadius", "_putOnRoof", "_fillEvenly", "_Zen_ExtendPosition", "_buildingsArray", "_buildingPosArray", "_buildingPositions", "_posArray", "_unitIndex", "_j", "_building", "_posArray", "_randomIndex", "_housePos", "_startAngle", "_i", "_checkPos", "_hitCount", "_isRoof", "_edge", "_k", "_unUsedUnits", "_array", "_sortHeight", "_Zen_InsertionSort", "_Zen_ArrayShuffle", "_doMove"];
    
    _center = _this param [0, [0,0,0], [[]], 3];
    _units = _this param [1, [objNull], [[]]];
    _buildingRadius = _this param [2, -1, [0]];
    _putOnRoof = _this param [3, false, [true]];
    _fillEvenly = _this param [4, false, [true]];
    _sortHeight = _this param [5, false, [true]];
    _doMove = _this param [6, false, [true]];
    
    if (_center isEqualTo [0,0,0]) exitWith {
        player sideChat str "Zen_Occupy House Error : Invalid position given.";
        diag_log "Zen_Occupy House Error : Invalid position given.";
        ([])
    };
    
    if ((count _units == 0) || {isNull (_units select 0)}) exitWith {
        player sideChat str "Zen_Occupy House Error : No units given.";
        diag_log "Zen_Occupy House Error : No units given.";
        ([])
    };
    
    _Zen_ExtendPosition = {
        private ["_center", "_dist", "_phi"];
    
        _center = _this select 0;
        _dist = _this select 1;
        _phi = _this select 2;
    
        ([(_center select 0) + (_dist * (cos _phi)),(_center select 1) + (_dist * (sin _phi)), (_this select 3)])
    };
    
    _Zen_InsertionSort = {
        private ["_i", "_j", "_count", "_array", "_element", "_value", "_comparator"];
    
        _array = _this select 0;
        _comparator = _this select 1;
        _count = count _array - 1;
    
        if (count _array == 0) exitWith {};
        for "_i" from 1 to _count step 1 do {
            scopeName "forI";
            _element = _array select _i;
            _value = EVAL(_element);
    
            for [{_j = _i}, {_j >= 1}, {_j = _j - 1}] do {
                if (_value > EVAL(_array select (_j - 1))) then {
                    breakTo "forI";
                };
                _array set [_j, _array select (_j - 1)];
            };
    
            _array set [_j, _element];
        };
        if (true) exitWith {};
    };
    
    _Zen_ArrayShuffle = {
        private ["_array", "_j", "_i", "_temp"];
        _array = _this select 0;
    
        if (count _array > 1) then {
            for "_i" from 0 to (count _array - 1) do {
                    _j = _i + floor random ((count _array) - _i);
                    _temp = _array select _i;
                    _array set [_i, (_array select _j)];
                    _array set [_j, _temp];
            };
        };
        if (true) exitWith {};
    };
    
    if (_buildingRadius < 0) then {
        _buildingsArray = [nearestBuilding _center];
    } else {
        _buildingsArray0 = nearestObjects [_center, ["house"], _buildingRadius];
        _buildingsArray1 = nearestObjects [_center, ["building"], _buildingRadius];
        _buildingsArray = _buildingsArray0 arrayIntersect _buildingsArray1;
    };
    
    if (count _buildingsArray == 0) exitWith {
        player sideChat str "Zen_Occupy House Error : No buildings found.";
        diag_log "Zen_Occupy House Error : No buildings found.";
        ([])
    };
    
    _buildingPosArray = [];
    0 = [_buildingsArray] call _Zen_ArrayShuffle;
    {
        _posArray = [];
        for "_i" from 0 to 1000 do {
            if ((_x buildingPos _i) isEqualTo [0,0,0]) exitWith {};
            _posArray pushBack (_x buildingPos _i);
        };
    
        _buildingPosArray pushBack _posArray;
    } forEach _buildingsArray;
    
    if (_sortHeight) then {
        {
            0 = [_x, {-1 * (_this select 2)}] call _Zen_InsertionSort;
        } forEach _buildingPosArray;
    } else {
        {
            0 = [_x] call _Zen_ArrayShuffle;
        } forEach _buildingPosArray;
    };
    
    _unitIndex = 0;
    for [{_j = 0}, {(_unitIndex < count _units) && {(count _buildingPosArray > 0)}}, {I(_j)}] do {
        scopeName "for";
    
        _building = _buildingsArray select (_j % (count _buildingsArray));
        _posArray = _buildingPosArray select (_j % (count _buildingPosArray));
    
        if (count _posArray == 0) then {
            _buildingsArray deleteAt (_j % (count _buildingsArray));
            _buildingPosArray deleteAt (_j % (count _buildingPosArray));
        };
    
        while {(count _posArray) > 0} do {
            scopeName "while";
            if (_unitIndex >= count _units) exitWith {};
    
            _housePos = _posArray select 0;
            _posArray deleteAt 0;
            _housePos = [(_housePos select 0), (_housePos select 1), (_housePos select 2) + (getTerrainHeightASL _housePos) + EYE_HEIGHT];
    
            _startAngle = (round random 10) * (round random 36);
            for "_i" from _startAngle to (_startAngle + 350) step 10 do {
                _checkPos = [_housePos, CHECK_DISTANCE, (90 - _i), (_housePos select 2)] call _Zen_ExtendPosition;
                if !(lineIntersects [_checkPos, [_checkPos select 0, _checkPos select 1, (_checkPos select 2) + 25], objNull, objNull]) then {
                    if !(lineIntersects [_housePos, _checkPos, objNull, objNull]) then {
                        _checkPos = [_housePos, CHECK_DISTANCE, (90 - _i), (_housePos select 2) + (CHECK_DISTANCE * tan FOV_ANGLE)] call _Zen_ExtendPosition;
                        if !(lineIntersects [_housePos, _checkPos, objNull, objNull]) then {
                            _hitCount = 0;
                            for "_k" from 30 to 360 step 30 do {
                                _checkPos = [_housePos, 20, (90 - _k), (_housePos select 2)] call _Zen_ExtendPosition;
                                if (lineIntersects [_housePos, _checkPos, objNull, objNull]) then {
                                    I(_hitCount)
                                };
    
                                if (_hitCount >= ROOF_CHECK) exitWith {};
                            };
    
                            _isRoof = (_hitCount < ROOF_CHECK) && {!(lineIntersects [_housePos, [_housePos select 0, _housePos select 1, (_housePos select 2) + 25], objNull, objNull])};
                            if (!(_isRoof) || {((_isRoof) && {(_putOnRoof)})}) then {
                                if (_isRoof) then {
                                    _edge = false;
                                    for "_k" from 30 to 360 step 30 do {
                                        _checkPos = [_housePos, ROOF_EDGE, (90 - _k), (_housePos select 2)] call _Zen_ExtendPosition;
                                        _edge = !(lineIntersects [_checkPos, [(_checkPos select 0), (_checkPos select 1), (_checkPos select 2) - EYE_HEIGHT - 1], objNull, objNull]);
    
                                        if (_edge) exitWith {
                                            _i = _k;
                                        };
                                    };
                                };
    
                                if (!(_isRoof) || {_edge}) then {
                                    (_units select _unitIndex) doWatch ([_housePos, CHECK_DISTANCE, (90 - _i), (_housePos select 2) - (getTerrainHeightASL _housePos)] call _Zen_ExtendPosition);
    
                                    (_units select _unitIndex) disableAI "TARGET";
                                    if (_doMove) then {
                                        (_units select _unitIndex) doMove ASLToATL ([(_housePos select 0), (_housePos select 1), (_housePos select 2) - EYE_HEIGHT]);
                                    } else {
                                        (_units select _unitIndex) setPosASL [(_housePos select 0), (_housePos select 1), (_housePos select 2) - EYE_HEIGHT];
                                        (_units select _unitIndex) setDir _i;
    
                                        doStop (_units select _unitIndex);
                                        (_units select _unitIndex) forceSpeed 0;
                                    };
    
                                   //** JBOY_UpDown by JohnnyBoy //*/
                                    #define JBOY_UpDown \
                                        if ((_this select 0) getVariable ["FIREDLOCKOUT", false]) exitWith {}; \
                                        if (!isServer)  exitWith {}; \
                                        _dude = _this select 0; \
                                        _stances = _this select 1; \
                                        _ehid = (_dude getVariable "EHID"); \
                                        _dude setVariable ["FIREDLOCKOUT", true]; \
                                        while {alive _dude} do { \
                                            if ((unitPos _dude) == (_stances select 0)) then { \
                                                _dude setUnitPos (_stances select 1); \
                                            } else { \
                                                _dude setUnitPos (_stances select 0); \
                                            }; \
                                            sleep 5 + (random 2); \
                                        }; \
    									_dude removeEventHandler ["FiredNear",_ehid]; 
    								
                                        if (_isRoof) then {
                                        	(_units select _unitIndex) setUnitPos "MIDDLE";
                                           _eh = (_units select _unitIndex) addEventHandler ["FiredNear",{[(_this select 0),["DOWN","MIDDLE"]] spawn {JBOY_UpDown};}];
                                        	(_units select _unitIndex) setVariable ["EHID", _eh];
                                           
                                        } else {
                                        	(_units select _unitIndex) setUnitPos "UP";
                                           _eh = (_units select _unitIndex) addEventHandler ["FiredNear",{[(_this select 0),["UP","MIDDLE"]] spawn {JBOY_UpDown};}];
                                           (_units select _unitIndex) setVariable ["EHID", _eh];
                                          
                                        }; 
    								
    
                                    I(_unitIndex)
                                    if (_fillEvenly) then {
                                        breakTo "for";
                                    } else {
                                        breakTo "while";
                                    };
                                };
                            };
                        };
                    };
                };
            };
        };
    };
    
    if (_doMove) then {
        0 = [_units, _unitIndex] spawn {
            _units = _this select 0;
            _unitIndex = _this select 1;
    
            _usedUnits = [];
            for "_i" from 0 to (_unitIndex - 1) do {
                _usedUnits pushBack (_units select _i);
            };
    
            while {count _usedUnits > 0} do {
                sleep 1;
                _toRemove =  [];
                {
                    if (unitReady _x) then {
                        doStop _x;
                        _x forceSpeed 0;
                        _toRemove pushBack _forEachIndex;
                    };
                } forEach _usedUnits;
    
                {
                    _usedUnits deleteAt (_x - _forEachIndex);
                } forEach _toRemove;
            };
            if (true) exitWith {};
        };
    };
    
    _unUsedUnits = [];
    for "_i" from _unitIndex to (count _units - 1) step 1 do {
        _unUsedUnits pushBack (_units select _i);
    };
    
    (_unUsedUnits)
    
    // Changelog
    // 7/21/15
        // 1. Added: Error reporting for invalid position and unit array arguments
        // 1. Added: Check and error report if no buildings are found
        // 3. Improved: Parameters 3, 4, and 5 are now optional and check for the correct type
        // 4. Improved: Parameters 6 and 7 check for the correct type
        // 5. Improved: AI should now stay in place better (thanks to JohnnyBoy)
    
    // 7/6/15
        // 1. Added: AI now take cover when fired upon (credit to JohnnyBoy)
        // 2. Added: Parameter to order the AI to move to their position
        // 3. Improved: The order of buildings filled is now random
        // 4. Improved: A few minor optimizations
    
    // 6/30/15
        // 1. Added: Parameter to fill buildings from top to bottom
        // 2. Improved: Optimized
    
    // 7/31/14
        // 1. Added: Parameter to cycle through each building in the radius, giving units to each one
        // 2. Improved: Units on roof are only placed at the edge, and face the edge
        // 3. Improved: Optimized roof check
        // 4. Improved: General script cleanup
    
    // 7/28/14
        // 1. Fixed: Units facing the wrong window
        // 2. Added: Parameter for distance to select multiple buildings
        // 3. Added: Parameter for units being on a roof
        // 4. Improved: Now checks that unit has a good FOV from the windows
        // 5. Improved: Units can no longer face a windows greater than 5 meters away
        // 6. Improved: Units on a roof now crouch
        // 7. Tweaked: Height of human eye to the exact value in ArmA
    
    // 7/24/14
        // Initial Release
    
    // Known Issues
        // None

     

     

    enable dynamic simulation for markers more then 500m by 500m. I like this fillhouse script a little better

    • Like 2

  11. 6 hours ago, target_practice said:

    Still doesn't explain what it is beyond being the primary display; what does it contain? I would check myself but as I said, I can't find it anywhere in the configs.

    configfile >> "RscDisplayMission"

     

    access = 0;
    idd = 46;
    movingEnable = 0;
    onLoad = "[""onLoad"",_this,""RscDisplayMission"",'GUI'] call 	(uinamespace getvariable 'BIS_fnc_initDisplay')";
    onUnload = "[""onUnload"",_this,""RscDisplayMission"",'GUI'] call 	(uinamespace getvariable 'BIS_fnc_initDisplay')";
    scriptName = "RscDisplayMission";
    scriptPath = "GUI";

     

    • Thanks 1

  12. Spoiler
    
    TAG_fnc_getVehiclePosition = {
    private ["_vehicle","_roles","_cfgVehicle"];
    
    _vehicle = _this param [0,objnull,[objnull,""]];
    _roles = [];
    
    if (typename _vehicle == typename objnull) then {_vehicle = typeof _vehicle;};
    
    _cfgVehicle = configfile >> "cfgvehicles" >> _vehicle;
    
    
    private _path = []; 
    _fnc_getTurretindex = {    
    params[ "_cfg" ];    
    	{  
    		
    		if !(call _condition) then   
    		{   
    			_path append [_forEachIndex]; 
    			_roles pushBack ["Turret",+_path]; 
    
    		} else { 
    			_path append [_forEachIndex]; 
    			_roles pushBack ["CargoTurret",+_path]; 
    		}; 
    	   
    		if (isclass (_x >> "turrets")) then   
    			{
    			_x call _fnc_getTurretindex;  
    			_path deleteAt (count _path - 1); 
    			};  
    	}forEach ( "true" configClasses( _cfg >> "turrets" ));
    	    
    _roles;  
        
    };
    private _condition = {getNumber (_x >> "showAsCargo") isEqualto 1};
    _cfgVehicle call _fnc_getTurretindex;
    
    
    for "_t" from 0 to (getnumber (_cfgVehicle >> "transportsoldier") - 1) do { 
    	_roles pushBack ["Cargo",[_t]];  
    };
    
    if (getnumber (_cfgVehicle >> "hasdriver") isEqualTo 1) then {
    	_roles pushBack ["Driver",[]]; 
    };
    
    _roles
    };

     

    ["CUP_O_T72_TKA"] call TAG_fnc_getTurretIndex;
    //[["Turret",[0]],["Turret",[0,0]],["CargoTurret",[1]],["CargoTurret",[2]],["CargoTurret",[3]],["CargoTurret",[4]],["CargoTurret",[5]],["CargoTurret",[6]],["Driver",[]]]
    
    ["B_T_Truck_01_transport_F"] call TAG_fnc_getTurretIndex;
    //[["CargoTurret",[0]],["CargoTurret",[1]],["Driver",[]],["Cargo",[0]],["Cargo",[1]],["Cargo",[2]],["Cargo",[3]],["Cargo",[4]],["Cargo",[5]],["Cargo",[6]],["Cargo",[7]],["Cargo",[8]],["Cargo",[9]],["Cargo",[10]],["Cargo",[11]],["Cargo",[12]],["Cargo",[13]],["Cargo",[14]]]
    
    ["B_MBT_01_cannon_f"] call TAG_fnc_getTurretIndex;
    //[["Turret",[0]],["Turret",[0,0]],["Driver",[]],["Cargo",[0]],["Cargo",[1]],["Cargo",[2]],["Cargo",[3]],["Cargo",[4]],["Cargo",[5]]]

    cargoturrets are considered turrets so use moveinturret.  moveindriver, moveincargo for the respective array names.

     

    Spoiler
    
    _grp = createGroup west;
    	_vehPositions=["B_T_Truck_01_transport_F"] call TAG_fnc_getVehiclePosition;
    	_vehicle = createVehicle ["B_T_Truck_01_transport_F", getpos player, [], 0, "CAN_COLLIDE"];
    
    _vehCrew=[];
    
    		{
    	_currentPosition=_x;
    	if (_currentPosition select 0 == "driver")then {
    			_unit = _grp createUnit ["b_crew_f", (getpos player), [], 0, "CAN_COLLIDE"];					
    			_unit moveInDriver _vehicle;
    			_vehCrew set [count _vehCrew,_unit];
    			};
    	
    	if (_currentPosition select 0 == "CargoTurret")then {
    			_unit = _grp createUnit ["b_soldier_AR_f", (getpos player), [], 0, "CAN_COLLIDE"];
    			_unit MoveInTurret [_vehicle,_currentPosition select 1];
    			_vehCrew set [count _vehCrew,_unit];
    			};
    	
    		if (_currentPosition select 0 == "Cargo")then {
    			_unit = _grp createUnit ["b_soldier_f", (getpos player), [], 0, "CAN_COLLIDE"];
    			_unit moveInCargo [_vehicle,(_currentPosition select 1)select 0];
    			};
    			
    		}foreach _vehPositions;

     

     


  13.  

     

    _cfgVehicle = configfile >> "cfgvehicles" >> "B_MBT_01_cannon_F";
    
    private _turrets = []; 
    private _path = []; 
    _fnc_getTurretindex = {    
    params[ "_cfg" ];    
    for "_i" from 0 to count (_cfg >> "Turrets") -1 do  
     {    
     _cfg1 = (_cfg >> "Turrets") select _i;  
      if !(getText( _cfg1 >> "proxyType" ) isEqualTo "CPCargo") then   
      {   
        _path append [_i]; 
     _turrets pushBack ["turret",+_path]; 
     
      };  
     _class = _cfg1 >> "turrets";  
     if (isClass _class) then   
     {  
     _cfg1 call _fnc_getTurretindex;  
     _path deleteAt (count _path - 1); 
     };  
    };    
    _turrets;  
        
    };_cfgVehicle call _fnc_getTurretindex;

    made this with the intention to separate turrets, cargo and turretcargo. maybe even include turretcargo into the cargo array


  14. Spoiler
    
    EOS_Spawn = compile preprocessfilelinenumbers "eos\core\eos_launch.sqf";Bastion_Spawn=compile preprocessfilelinenumbers "eos\core\b_launch.sqf";null=[] execVM "eos\core\spawn_fnc.sqf";onplayerConnected {[] execVM "eos\Functions\EOS_Markers.sqf";}; 
    VictoryColor="colorGreen"; // Colour of marker after completion 
    hostileColor="colorRed"; // Default colour when enemies active 
    bastionColor="colorOrange"; // Colour for bastion marker 
    EOS_DAMAGE_MULTIPLIER=1; // 1 is default 
    EOS_KILLCOUNTER=true;  // Counts killed units 
    /* 
    UNIT SIZE PER GROUP
     0 = 1
     1 = 2,4
     2 = 4,8
     3 = 8,12
     4 = 12,16
     5 = 16,20
     */
    { 
    if (_x find "EOS_MARKER" > -1) then  
    { 
    _xcargo=3; //max units in cargo
    _maxVh=3;  //max amount of vehicles
    _maxGp=8;  //max amount of groups
    _maxUt=2;  //max amount of units per group 
    _minUt=0;  //min amount of units per group
    _mkrSz=(getMarkerSize _x#0) + (getMarkerSize _x#1); 
    _grps =  round(linearConversion [0,1000,_mkrSz,1,_maxGp,false]); 
    _vehs =  round(linearConversion [0,1000,_mkrSz,0,_maxVh,false]); 
    _vcarg = round(linearConversion [0,1000,_mkrSz,0,_xcargo,true]); 
    _grpSz = round(linearConversion [0,1000,_mkrSz,_minUt,_maxUt,true]); 
    _prob =  round(linearConversion [0,1000,_mkrSz,0,100,true]); 
    [[_x],[_grps,_grpSz],[_grps,_grpSz],[_vehs,_vcarg,_prob],[_vehs,_prob],[_vehs],[_vehs,_vcarg,_prob],[0,0,400,EAST,FALSE]] call EOS_Spawn; 
    }; 
    }foreach allmapmarkers;

     

    OpenMe.sqf

    this script gets all markers named "eos_marker", and changes the groupsize. unitsize, vehiclesize and cargosize based on the size of the marker; then it calls eos_spawn for each marker.

     

     

     

    • Like 1
    • Thanks 1

  15. 1 hour ago, Jem777 said:

    G’Day All

    can someone tell if and where i can find attributes for each class, my terminology may be wrong. What im looking for is an equivalent to  C/C++ Struct or classes, ill explain further. A soldier can have setcaptive, “salute”, “killed” and im sure may other attributes. Is the a list for each class? Im getting into scripting and i thought it may be a good way test out the attributes/commands to see how they work. 

    Thanks

    https://community.bistudio.com/wiki/Category:Arma_3:_New_Scripting_Commands_List


  16. 22 minutes ago, da12thMonkey said:

    Planes, helicopters etc. generally don't use the weapons[] array any more for missiles and bombs - only for the gun turrets, laser designators and countermeasures.

    Apart from a couple of exceptions, missiles and bombs have been handled by the Dynamic Loadouts system since the Jets DLC was released. This is configured for each vehicle under class Components>>class TransportPylonsComponent>>class pylons where each pylon has an attachment = parameter that defines the default magazine class loaded on to that pylon.

    But it's easier to use the getPylonMagazines command on the aircraft rather than dicking around in the configs.

    The weapon/launcher for that magazine is assigned by the pylonWeapon parameter in the magazine classname.

    To change the munitions assigned to the vehicle's pylons, you use the setPylonLoadout command and use a magazine name - it will automatically add the assigned pylonWeapon to the vehicle when the magazine is added to the pylon this way so you don't need to do separate addWeapon+addMagazine commands for these.

     

    So I guess if getPylonMagazines returns nothing for a vehicle, it is probably not armed with anything more than a few gun turrets.

    ah99 has weapons listed in the non dynamicloadout baseclass


  17. 3 hours ago, Larrow said:

    What vehicle? I tested a whole bunch before posting without problems.

     

    You do not recurse turrets. Any vehicle that has a turret with any child turrets will not be processed via your code.

    test the nato helicopters. nato ah99  "turrets" is empty, weapons is in "mainturret"

    as for the recurse turrets part. what if i test isclass(_cfg1 >> "turrets") and call _fnc_turrets again?


  18. TAG_fnc_getVehicleWeapons = {
    	params[ "_vehicle" ];
    	
    	_baseCfg = configFile >> "CfgVehicles" >> _vehicle >> "turrets";
    
    	_availableWeapons = [];
    	
    	_fnc_turrets = {
    		params[ "_cfg" ];
    		for "_i" from 0 to count _cfg -1 do {
    		_cfg1 = _cfg select _i;
    		{
    			_availableWeapons pushback _x;
    		}forEach getArray (_cfg1 >> "weapons");
    
    		};
    	};
    	
    	_baseCfg call _fnc_turrets;
    	_availableWeapons;	
    };
    		

    some reason it was only returning flares.. this works for me.

×