Casio91Fin 31 Posted March 11 (edited) How would I get the AI to spawn around an area if the sector is owned by "Blufor"/"IND"/"Opfor" and attack those sectors? And if the AI has taken over the sector and the AI should then be ordered to defend the sector after it has taken over the sector. Or to go inside houses. Spoiler (I found Zen_Occupyhouse.sqf which I would like to use) 0 = [getPosATL player, units group X, -1, true, false] execVM "Zen_OccupyHouse.sqf"; SectorA, SectorB, SectorC this is just an example: while {_TotalSpawned < _MaxAiTeams} do { while {count units west <= _MaxActiveAI - 1 && _TotalSpawned < _MaxAiTeams} do { //Infantry 1. if (_MaxActiveAI - count units west >= 10) then { for "_x" from 1 to 1 do { private ["_Team_Leader", "_New_Soldier"]; New_AI_Team = createGroup [west, true]; AI_Team_Spawn_Pos = [AttackCenterPoint, 1000, 2000, 4.5, 0, 1] call BIS_fnc_findSafePos; _Team_Leader = New_AI_Team createUnit [TeamLeadersClass select floor (random count TeamLeadersClass), AI_Team_Spawn_Pos, [], 0, "NONE"]; _Team_Leader setRank "SERGEANT"; _Team_Leader allowFleeing 0; _Team_Leader setSkill (0.62 + random 0.18); {_Team_Leader disableAI _x} count ["MINEDETECTION","LIGHTS"]; {_Team_Leader enableAI _x} count ["COVER","AIMINGERROR","SUPPRESSION"]; sleep 1; for "_x" from 2 to (2 + (round random 3 + 5)) do { _New_Soldier = New_AI_Team createUnit [InfantryClass select floor (random count InfantryClass), AI_Team_Spawn_Pos, [], 0 ,"NONE"]; _AI_Random_Rank = selectRandom ["PRIVATE","PRIVATE","PRIVATE","CORPORAL"]; _New_Soldier setRank _AI_Random_Rank; _New_Soldier allowFleeing 0; _New_Soldier setSkill (0.55 + random 0.15); {_New_Soldier disableAI _x} count ["MINEDETECTION","LIGHTS"]; {_New_Soldier enableAI _x} count ["COVER","AIMINGERROR","SUPPRESSION"]; }; New_AI_Team deleteGroupWhenEmpty true; { _x addEventHandler [ "Fired", {_magType = "MRAWS_HE_F"; if ((_this select 1) == "MRAWS_HE_F") then {(_this select 0) addMagazine _magType;} else {(_this select 0) setvehicleammo 1;}}]; //When unit gets killed it goes into ragdoll state for a short while. _x addEventHandler ["Explosion", { params ["_unit", "_damage"]; if (_damage < 0.01) exitWith {}; _unit awake true; _unit awake false; }]; _Infantry = _Infantry + 1; } forEach units New_AI_Team; New_AI_Team setVariable ["canMerge", false, true]; 0 = [New_AI_Team] spawn {_grp = _this select 0; {_x enablegunlights "forceOn";} forEach (units _grp); _grp setSpeedMode "FULL"; while {{alive _x} count (units _grp) > 0} do {waitUntil {sleep 5; count (allPlayers - entities "HeadlessClient_F") > 0}; _justPlayers = allPlayers - entities "HeadlessClient_F"; _player = ([_justPlayers,[],{(leader _Grp) distance _x},"ASCEND"] call BIS_fnc_sortBy) select 0; _pos = getPosATL _player; if ((_grp knowsAbout _player) isEqualTo 0 && {random 10 > 1}) then { _pos = [getposASL _player, (15000/(_player distance2D (leader _grp))) max 1, (20000/(_player distance2D (leader _grp))) max 5, 1, 0, 35, 0] call BIS_fnc_findSafePos;}; _grp move _pos; sleep ((random (((leader _grp) distance2D _player)/4)) max 60);}; deleteGroup _grp;}; _TotalSpawned = _TotalSpawned + 1; format ["Enemy Team Spawned: %1 / %2 \n More Info: \n Infantry: %3 \n Land Vehicles: %4 \n Aircrafts: %5", _TotalSpawned, _MaxAiTeams, _Infantry, _LandVehicles, _Aircrafts] remoteExec ["hint"]; }; }; }; sleep 10; }; update: I found something similar, but only based on the color of the marker they attack the target. progress: I could get it working, but a new problem arose. The sector takeover notification didn't appear and the sector remained dark even though I was able to take over completely and the enemies spawned as they were supposed to. Spoiler { [_x, "ownerChanged", { params["_sector", "_owner", "_ownerOld"]; if (_owner isEqualTo independent) then { _TotalSpawned = 0; _MaxAiTeams = 70; _MaxActiveAI = 28; while {_TotalSpawned < _MaxAiTeams} do { while {count units east <= _MaxActiveAI - 1 && _TotalSpawned < _MaxAiTeams} do { //Infantry 1. if (_MaxActiveAI - count units east >= 20) then { for "_x" from 1 to 1 do { private ["_Team_Leader", "_New_Soldier"]; New_AI_Team = createGroup [east, true]; AI_Team_Spawn_Pos = [_sector, 400, 500, 4.5, 0, 1] call BIS_fnc_findSafePos; _Team_Leader = New_AI_Team createUnit [TeamLeadersClass select floor (random count TeamLeadersClass), AI_Team_Spawn_Pos, [], 0, "NONE"]; _Team_Leader setRank "SERGEANT"; _Team_Leader allowFleeing 0; _Team_Leader setSkill (0.62 + random 0.18); {_Team_Leader disableAI _x} count ["MINEDETECTION","LIGHTS"]; {_Team_Leader enableAI _x} count ["COVER","AIMINGERROR","SUPPRESSION"]; sleep 1; for "_x" from 2 to (2 + (round random 3 + 5)) do { _New_Soldier = New_AI_Team createUnit [InfantryClass select floor (random count InfantryClass), AI_Team_Spawn_Pos, [], 0 ,"NONE"]; _AI_Random_Rank = selectRandom ["PRIVATE","PRIVATE","PRIVATE","CORPORAL"]; _New_Soldier setRank _AI_Random_Rank; _New_Soldier allowFleeing 0; _New_Soldier setSkill (0.55 + random 0.15); {_New_Soldier disableAI _x} count ["MINEDETECTION","LIGHTS"]; {_New_Soldier enableAI _x} count ["COVER","AIMINGERROR","SUPPRESSION"]; }; New_AI_Team deleteGroupWhenEmpty true; { _x addEventHandler [ "Fired", {_magType = "MRAWS_HE_F"; if ((_this select 1) == "MRAWS_HE_F") then {(_this select 0) addMagazine _magType;} else {(_this select 0) setvehicleammo 1;}}]; //When unit gets killed it goes into ragdoll state for a short while. _x addEventHandler ["Explosion", { params ["_unit", "_damage"]; if (_damage < 0.01) exitWith {}; _unit awake true; _unit awake false; }]; //_Infantry = _Infantry + 1; } forEach units New_AI_Team; New_AI_Team addWaypoint [getPosATL _sector, 0]; //New_AI_Team setVariable ["canMerge", false, true]; 0 = [New_AI_Team] spawn {_grp = _this select 0; {_x enablegunlights "forceOn";} forEach (units _grp); _grp setSpeedMode "FULL"; while {{alive _x} count (units _grp) > 0} do {waitUntil {sleep 5; count (allPlayers - entities "HeadlessClient_F") > 0}; _justPlayers = allPlayers - entities "HeadlessClient_F"; _player = ([_justPlayers,[],{(leader _Grp) distance _x},"ASCEND"] call BIS_fnc_sortBy) select 0; _pos = getPosATL _player; if ((_grp knowsAbout _player) isEqualTo 0 && {random 10 > 1}) then { _pos = [getposASL _player, (15000/(_player distance2D (leader _grp))) max 1, (20000/(_player distance2D (leader _grp))) max 5, 1, 0, 35, 0] call BIS_fnc_findSafePos;}; _grp move _pos; sleep ((random (((leader _grp) distance2D _player)/4)) max 60);}; deleteGroup _grp;}; _TotalSpawned = _TotalSpawned + 1; format ["Enemy Team Spawned: %1 / %2 ", _TotalSpawned, _MaxAiTeams] remoteExec ["hint"]; }; }; }; //sleep 10; }; }; }] call BIS_fnc_addScriptedEventHandler; } forEach (true call BIS_fnc_moduleSector); progress 2: working version received, has been tested on SP but not on MP and server. initServer.sqf Spoiler { //Add the SEH to each sector [ _x, "ownerChanged", { params[ "_sector", "_owner", "_ownerOld" ]; if ( _owner isEqualTo EAST ) then { some other once-probe script event, e.g. an artillery strike }; if ( _owner isEqualTo west ) then { some other once-probe script event, e.g. an artillery strike }; if ( _owner isEqualTo independent ) then { some other once-probe script event, e.g. an artillery strike }; if (_owner isEqualTo sideUnknown) then { some other once-probe script event, e.g. an artillery strike }; SP_fnc_getUnit = compile preprocessFileLineNumbers "MissionFile\UnitClass.sqf"; _SwitchTeam = "SwitchTeam" call BIS_fnc_getParamValue; publicVariable "SwitchTeam"; null = [_SwitchTeam,_sector] execVM "MissionFile\MissionInit.sqf"; }] call BIS_fnc_addScriptedEventHandler; } forEach ( true call BIS_fnc_moduleSector ); Mission.sqf Spoiler params ["_FactionGroup","_sector"]; {your own scripts with which you create an artificial intelligence to attack or defend.} but use _sector e.g [opforGroup, getPosATL _sector] call BIS_fnc_taskAttack; Edited March 23 by Casio91Fin progress 2 Share this post Link to post Share on other sites