Mirek 166 Posted October 28, 2019 HI, I need to force Specific AI Groups to go to help any AI groups that come under fire or spot the players. I tryied to use Guard waypoint ( in arma 2 it used to do exactly what i want), with/without the guarded by trigger, but thats uselless as it only sends one AI group at the time. I searched few topics, and i found something like this: _null = this spawn { Hunt_players_fnc = { _player = ""; { if (isPlayer _x AND alive _x) then {_player = _x}; } foreach (playableUnits + switchAbleUnits); _wp = _this addWaypoint [getPos _player, (50 + (floor(random 200)))]; _wp setWaypointStatements ["true", "_null = (group this) spawn Hunt_players_fnc;"]; _wp setWaypointType "SAD"; _wp setWaypointCombatMode "RED"; _wp setWaypointSpeed "FULL"; }; _null = (group _this) spawn Hunt_players_fnc; }; BUt thats also useless to me as it seems to make the AI allways hunt the player. I looked here: But none of the descriptions of the scripts didnt sound like it does what i want. SO please: 1. AI spots the enemy 2. all groups that are supposed to help go help at once regardles of the type of group that has spotted the enemy. 3. if contact with enemy is lost, the groups go back to theyr starting point. 4. repeat until eternity ,or until there are no AI groups left. Share this post Link to post Share on other sites
wogz187 1086 Posted October 28, 2019 (edited) @Mirek, Quote 1. AI spots the enemy How many AI spotters are there? What happens if two spot the same (or separate) groups at the same time? Quote 2. all groups that are supposed to help go help at once regardles of the type of group that has spotted the enemy. What if they are already engaged when the call for support comes? (ex. helping guard post A while B becomes attacked) Quote 3. if contact with enemy is lost, the groups go back to theyr starting point. How is the starting point determined? Just wherever they land in the editor? Are they spawned groups? Quote 4. repeat until eternity ,or until there are no AI groups left. Eternity, for sure. (How would they know there are no groups left?) My suggestion would be a function which considers the following, ONLY engage if currently NOT engaged* 1. Determine enemy is to be engaged, DUMB: enemy in trigger SMART: guard target count >0 2. Determine "Start point" something like: startPos=position this (record the unit's starting pos) 3. Set Waypoint move to guard's target pos or stalk (moving to pos means they will move to last known pos which is probably more realistic than stalking) 4. Determine threat eliminated (smart/dumb same as above). 5. Return to startPos. If you agree to the logic we can write a function to achieve that. Most importantly, where do all the groups come from: editor or script? Have fun! Edited October 28, 2019 by wogz187 *it could be move to guard point with highest priority (ex. number of targets) 1 Share this post Link to post Share on other sites
pierremgi 4905 Posted October 28, 2019 @wogz187 is right. You need to refine your decision tree. Are the players in the same group? which "specific" groups? "under fire" seems to me already "spotted", right? So, is it a question of AI "knowsAbout" player(s)? 1 Share this post Link to post Share on other sites
Mirek 166 Posted October 28, 2019 Well basically i want the same function as guard waypoint used to have in arma 2. Or simillar as guard waypoint has in arma 3 but sending all units that have guard waypoints assigned at once instead of sending one by one. If i remember correctly in arma 2, if any unit of the same side as the unit with guard waypoint, spotted the enemy, or got under fire the units with guard waypoint just started mowing to the last known possition of enemy, if there were more, they went to the closest one, and then to the next one. I would like to have it like: Response groups [Group r1, group r2, ...]; origin_pos_1=Getpos Group r1; origin_pos_2=GetPos Group r2; . . . Blufor spotted by opfor; // any opfor anwhere on the map. marker 1 GetPos Blufor; // the spotted one Blufor spotted by opfor; // somewhere else on the map marker 2 GetPos Blufor; . . x= Response groups ditance to marker 1 y= response groups distance to marker 2 . . if [x<y && y<whatever] {Group r1 create waypoint getPos x}; // executed for each group separatelly else if [y<x && x<whatever] {Group r1 create waypoint getPos y}; else if . . else {Group r1 create waypoint getPos whatever}; If [no more enemy] {Group r1 create waypoint getPos origin_pos_1}; something like that, have no idea how to make the proper code. Share this post Link to post Share on other sites
Mirek 166 Posted October 28, 2019 From the responses i undertand, there is no easy way to achieve what i want. I will try to come up with some crude script, and will come back here to let the real scripters correct it for me. Share this post Link to post Share on other sites
Mirek 166 Posted October 28, 2019 I have to start with declaring the response groups. I want it to be editor placed groups. So what if i just use any group that has a guard waypoint assigned? I offcourse have no idea how i would do that, but seems a good idea. So first question: How do i find all opfor units that has guard waypoint assigned? Share this post Link to post Share on other sites
wogz187 1086 Posted October 28, 2019 @Mirek, You're subtly uncovering some interesting design topics. Coming from other communities I was initially inclined to design how I always have, "cinematically". Which is to say, nothing is real. Imply through a window sky-box that a whole world exists beyond but really, on the other side of the wall, is nothing. Imply a character left the scene to rendezvous at later point. In reality the character model just disappeared beyond the player's view. Working with the EDEN editor, and scripts, I realized a much more literal approach works well. Since nothing is literally "real" in a game we'll say implicit versus implied. Implicit means the entity will behave autonomously in a contextually accurate way (a patrol helicopter will patrol it's designated area and respond to threats as it sees fit). Implied means the entity's behaviour is scripted to seem like a "patrol helicopter". Often forum topics ask for the "best" answer. Generally the best answer is universal and not mission specific (ex. a repeatable function). So the best answer, whatever we come up with, will be the one which allows your mission to have patrol groups that act on their own accord-- the less scripting the better. As for the priority: do you want players to be able to trick the guards (by attacking one point as a distraction) or do you want the groups to always move to the area with the greatest threat? 1 Share this post Link to post Share on other sites
pierremgi 4905 Posted October 28, 2019 4 hours ago, Mirek said: So first question: How do i find all opfor units that has guard waypoint assigned? This point is simple: _grpsGuarding = allGroups select {side _x == EAST && waypoints _x findIf {waypointType _x == "GUARD"} >-1}; 2 1 Share this post Link to post Share on other sites
GEORGE FLOROS GR 4207 Posted October 28, 2019 Hello there guys ! Here is something simple : add this in the init of the unit that you want to be supported 0=[this] execVM "GF_Support.sqf"; GF_Support.sqf // add this in the init of the unit that you want to be supported // 0=[this] execVM "GF_Support.sqf"; GF_Throw_Smoke = true; GF_Only_White_Smoke = false; _group = _this select 0; { _x addEventHandler ["FiredMan", { params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_vehicle"]; _all = []; _side = side _unit; _groups = allGroups select{ side _x isEqualTo _side && alive leader _x }; _groups apply {_all append units _x}; // copyToClipboard str _all; { If(!isPlayer _x)then{ If(isNull _x)exitWith{}; if(isNil {_x getVariable "Var_GF_doMove"})then{_x setVariable ["Var_GF_doMove",false];}; if(_x getVariable ["Var_GF_doMove",true])exitWith{}; _x setVariable ["Var_GF_doMove",true]; _doMove = true; while{alive _x && _doMove}do{ _x allowFleeing 0; _x stop false; _x doMove (position _unit); if(_x distance _x < 50)exitWith{ if(GF_Throw_Smoke) then{ If(random 2 > 1)then{ _x setDir ([_x, _unit] call BIS_fnc_dirTo); if(GF_Only_White_Smoke) then{ [_x, "SmokeShellMuzzle"] call BIS_fnc_fire; }else{ _smokeArray = magazines _x select {["smokeShell",_x] call bis_fnc_instring}; if(count _smokeArray >0)then{ [_x,(selectRandom _smokeArray)+"Muzzle"] call bis_fnc_fire; }; }; }; }; _x setVariable ["Var_GF_doMove",false]; _doMove = false; }; uisleep 5; }; }; }foreach _all; systemchat "fired"; }]; }forEach units group _group; 1 2 Share this post Link to post Share on other sites
GEORGE FLOROS GR 4207 Posted October 30, 2019 It's just a base to add your code. you could add also these groups to move to the certain unit and after a while to get to the start position again or patrol the area for some time etc. 1 Share this post Link to post Share on other sites
Firecracker048 1 Posted October 31, 2019 Hey george, So for that SQF to function properly, all units would need to be located in the same group? Or would this SQF have all other groups support the one who spots the players/comes under fire? 1 Share this post Link to post Share on other sites
avibird 1 155 Posted October 31, 2019 @Mirek Have you used GAIA it's a AI command system that is integrated with MCC4 mod or you can just use the stand alone script of GAIA. It controls the AI groups set to zones or will even move to other units from other zones to support units underfire. It gives units random patrol waypoints within the zone. It's a very good management of AI groups. The guard waypoint still works if you just put a guard waypoint down for a group. It will sent a group to support it it feels it needs more the one group it will send more. It is a little random but works well because you're never quite sure how many groups will come to support a group under attack. https://forums.bohemia.net/forums/topic/172933-mission-template-stand-alone-gaia-make-missions-fast-by-using-mcc-gaia-engine/ 1 1 Share this post Link to post Share on other sites
Mirek 166 Posted October 31, 2019 On 10/28/2019 at 10:24 PM, pierremgi said: This point is simple: _grpsGuarding = allGroups select {side _x == EAST && waypoints _x findIf {waypointType _x == "GUARD"} >-1}; So now Could i use the _StartPos = getPosATL _grpsGuarding; To find theyr start possitions? Share this post Link to post Share on other sites
pierremgi 4905 Posted October 31, 2019 No. _grpGuardingPos = _grpGuarding apply {getpos leader _x}; (as far as a position of a group is its leader's one). You'll return something like: _grpGuarding = [grp1,grp2,...] and _grpGuardingPos = [[xxx1,yyy1,0],[xxx2,yyy2,0],...] Now if you prefer to couple grps and their positions: _grpAndPos = _grpGuarding apply {[_x,getPos leader _x]}; returning: _grpAndPos = [ [grp1,[xxx1,yyy1,0]], [grp2,[xxx2,yyy2,0]], ...]; 1 1 Share this post Link to post Share on other sites
Mirek 166 Posted October 31, 2019 OK sofar i would try to start with something like this: // Find all groups that have a Guard waypoint assigned _grpsGuarding = allGroups select {side _x == EAST && waypoints _x findIf {waypointType _x == "GUARD"} >-1}; //find starting possitions of the leaders of groups with guard waypoint _grpAndPos = _grpGuarding apply {[_x,getPos leader _x]}; //find all opfor soldiers _sentry= allGroups select {side _x == EAST}; //Find the possition of nearest spotted Blufor _FoePos = findNearestEnemy _sentry ; // maybe use forEach somehow in case there is blufor coming from multiple directions? //Create SAD waypoint for guard units _wp =_grpsGuarding addWaypoint [_FoePos, 0]; _wp setWaypointType "SAD"; _wp setWaypointBehaviour "COMBAT"; _wp setWaypointCombatMode "RED"; _wp setWaypointSpeed "FULL"; //CHeck if there is any blufor left _knowledge = _grpsGuarding knowsAbout ?????; // not sure what to type here //Return units back to starting possitions _sp =_grpsGuarding addWaypoint [_grpAndPos, 0]; _sp setWaypointType "GUARD"; _sp setWaypointBehaviour "GUARD"; _sp setWaypointCombatMode "GREEN"; _sp setWaypointSpeed "LIMITED"; You think it could work? How do i make the script repeat itself when new enemy is spotted? How do i make it that if multiple enemies are spotted, the grpsGuarding will go each to the one closest to them? Share this post Link to post Share on other sites
Mirek 166 Posted October 31, 2019 On 10/29/2019 at 12:27 AM, GEORGE FLOROS GR said: Hello there guys ! Here is something simple : add this in the init of the unit that you want to be supported 0=[this] execVM "GF_Support.sqf"; GF_Support.sqf // add this in the init of the unit that you want to be supported // 0=[this] execVM "GF_Support.sqf"; GF_Throw_Smoke = true; GF_Only_White_Smoke = false; _group = _this select 0; { _x addEventHandler ["FiredMan", { params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_vehicle"]; _all = []; _side = side _unit; _groups = allGroups select{ side _x isEqualTo _side && alive leader _x }; _groups apply {_all append units _x}; // copyToClipboard str _all; { If(!isPlayer _x)then{ If(isNull _x)exitWith{}; if(isNil {_x getVariable "Var_GF_doMove"})then{_x setVariable ["Var_GF_doMove",false];}; if(_x getVariable ["Var_GF_doMove",true])exitWith{}; _x setVariable ["Var_GF_doMove",true]; _doMove = true; while{alive _x && _doMove}do{ _x allowFleeing 0; _x stop false; _x doMove (position _unit); if(_x distance _x < 50)exitWith{ if(GF_Throw_Smoke) then{ If(random 2 > 1)then{ _x setDir ([_x, _unit] call BIS_fnc_dirTo); if(GF_Only_White_Smoke) then{ [_x, "SmokeShellMuzzle"] call BIS_fnc_fire; }else{ _smokeArray = magazines _x select {["smokeShell",_x] call bis_fnc_instring}; if(count _smokeArray >0)then{ [_x,(selectRandom _smokeArray)+"Muzzle"] call bis_fnc_fire; }; }; }; }; _x setVariable ["Var_GF_doMove",false]; _doMove = false; }; uisleep 5; }; }; }foreach _all; systemchat "fired"; }]; }forEach units group _group; Than you wery much, but asi do not understand scripting much i do not understand what exactly is the script doing, and i do not want to use something i dont undertand because then it will be impossible for me to play arouznd with it. Id rather try to put something together myself with help from the people here, wich i will understand, and know what each line does. 1 Share this post Link to post Share on other sites
Mirek 166 Posted October 31, 2019 6 hours ago, avibird 1 said: @Mirek Have you used GAIA it's a AI command system that is integrated with MCC4 mod or you can just use the stand alone script of GAIA. It controls the AI groups set to zones or will even move to other units from other zones to support units underfire. It gives units random patrol waypoints within the zone. It's a very good management of AI groups. The guard waypoint still works if you just put a guard waypoint down for a group. It will sent a group to support it it feels it needs more the one group it will send more. It is a little random but works well because you're never quite sure how many groups will come to support a group under attack. https://forums.bohemia.net/forums/topic/172933-mission-template-stand-alone-gaia-make-missions-fast-by-using-mcc-gaia-engine/ I cannot use mods for this, the players playing the mission would be forced to use that mod too, and the mission allready is too mod heavy, with CBA ACE ACEX all RHS mods, and ACR_army of the Czech republic mod. Share this post Link to post Share on other sites
pierremgi 4905 Posted October 31, 2019 Always mind for syntax! findNearestEnemy, addWaypoint knowsAbout If you want to script something consistent without any experience, start writing light conditions/events for light scenario, in plain language. Then, mind for the parameters and results for each command/function. So make difference between types: string, object, array, group, number, code... You can add a waypoint for a group, not an array. For an array of groups (as _grpsGuarding), you can write {_wp = _x addWaypoint [<some position>,0]; _wp set..... } forEach _grpsGuarding; Here, findNearestEnemy usage is wrong (not saying this command is rotten). I give you the solution for a waypoint back to the initial positions: _grpGuarding = [grp1,grp2,...]; _grpAndPos = _grpGuarding apply {[_x,getPos leader _x]}; { _grp = _x #0; _pos = _x #1; _wp = _grp addWaypoint [_pos,0]; _wp setWaypointType "GUARD"; _wp setWaypointBehaviour "SAFE"; _wp setWaypointCombatMode "GREEN"; _wp setWaypointSpeed "LIMITED"} forEach _grpAndPos; 2 1 Share this post Link to post Share on other sites
Mirek 166 Posted November 1, 2019 Hmm, not sure how exactly to wotk with this, I tryed to change it according to your advice, but still have many blanks there. if isServer { // Find all groups that have a Guard waypoint assigned _grpsGuarding = allGroups select {side _x == EAST && waypoints _x findIf {waypointType _x == "GUARD"} >-1}; _grpGuarding = [grp1,grp2,...]; //Not sure here, i do not know how many groups there will be. //find starting possitions of the leaders of groups with guard waypoint _grpAndPos = _grpGuarding apply {[_x,getPos leader _x]}; //find all opfor soldiers _sentry= allGroups select {side _x == EAST}; //Find the possition of nearest spotted Blufor _FoePos = findNearestEnemy _sentry ; // maybe use forEach somehow in case there is blufor coming from multiple directions? //Create SAD waypoint for guard units { _wp = _x addWaypoint [_FoePos,0]; _wp setWaypointType "SAD"; _wp setWaypointBehaviour "COMBAT"; _wp setWaypointCombatMode "RED"; _wp setWaypointSpeed "FULL"; } forEach _grpsGuarding; //CHeck if there is any blufor left _knowledge = _grpsGuarding knowsAbout ?????; // not sure what to type here //Return units back to starting possitions { _grp = _x #0; _pos = _x #1; _wp = _grp addWaypoint [_pos,0]; _wp setWaypointType "GUARD"; _wp setWaypointBehaviour "SAFE"; _wp setWaypointCombatMode "GREEN"; _wp setWaypointSpeed "LIMITED"; } forEach _grpAndPos; } I do not know any other ways to determine the enemy than KnowsAbout, and findNearestEnemy, becaue theese two are the only solutions i was able to google, and somehow understand. Mybe i could use a trigger with Blufor detectd by Opfor, and put something like _Foepos = {getPos _x} for each _Player in thisList; Into its init, and then put entire above script into its init. If i set the trigger to repeat, then it could maybe work as i want? Share this post Link to post Share on other sites
Mirek 166 Posted November 1, 2019 15 hours ago, avibird 1 said: @Mirek Have you used GAIA it's a AI command system that is integrated with MCC4 mod or you can just use the stand alone script of GAIA. It controls the AI groups set to zones or will even move to other units from other zones to support units underfire. It gives units random patrol waypoints within the zone. It's a very good management of AI groups. The guard waypoint still works if you just put a guard waypoint down for a group. It will sent a group to support it it feels it needs more the one group it will send more. It is a little random but works well because you're never quite sure how many groups will come to support a group under attack. https://forums.bohemia.net/forums/topic/172933-mission-template-stand-alone-gaia-make-missions-fast-by-using-mcc-gaia-engine/ Oh! I didnt read carefully enough earlier. So it is a script not a MOD? I will try it, to see if i understand how it works. Thank you! 1 Share this post Link to post Share on other sites
Mirek 166 Posted November 1, 2019 On 10/29/2019 at 12:27 AM, GEORGE FLOROS GR said: Hello there guys ! Here is something simple : add this in the init of the unit that you want to be supported GF_Support.sqf Hmm, maybe ia am able to understand something, i will try this. 1 Share this post Link to post Share on other sites
GEORGE FLOROS GR 4207 Posted November 1, 2019 On 10/31/2019 at 2:13 PM, Firecracker048 said: Hey george, So for that SQF to function properly, all units would need to be located in the same group? Or would this SQF have all other groups support the one who spots the players/comes under fire? On 11/1/2019 at 8:46 AM, Mirek said: Hmm, maybe ia am able to understand something, i will try this. This is the very basic stuff: Spoiler On 10/31/2019 at 11:02 PM, Mirek said: add this in the init of the unit that you want to be supported 0=[this] execVM "GF_Support.sqf"; GF_Support.sqf // add this in the init of the unit that you want to be supported // 0=[this] execVM "GF_Support.sqf"; GF_Support.sqf _group = _this select 0; { _x addEventHandler ["FiredMan", { params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_vehicle"]; // https://forums.bohemia.net/forums/topic/192831-detection-script/?page=2&tab=comments#comment-3068816 _all = []; _side = side _unit; _groups = allGroups select{ side _x isEqualTo _side && alive leader _x }; _groups apply {_all append units _x}; // copyToClipboard str _all; { If(!isPlayer _x)then{ If(isNull _x)exitWith{}; if(isNil {_x getVariable "Var_GF_doMove"})then{_x setVariable ["Var_GF_doMove",false];}; if(_x getVariable ["Var_GF_doMove",true])exitWith{}; _x setVariable ["Var_GF_doMove",true]; _x allowFleeing 0; _x stop false; _x doMove (position _unit); }; }foreach _all; systemchat "fired"; }]; }forEach units group _group; How this works : It will work with the "EventHandler" every time that a member of the group is firing. The groups that we want to support this groups can be edited here : _groups = allGroups select{ side _x isEqualTo _side && alive leader _x }; _groups apply {_all append units _x}; // copyToClipboard str _all; so you can change this according to your desire as the examples given from the above posts etc. 1 Share this post Link to post Share on other sites