WAI AI Behavior Modding

Karmafied

Member
Hi all,

I have just installed WAI in addition to DZAI and I love it. I am trying to find a way to have different types of behavior per AI group, and although I am not sure this is even possible, I wanted to ask this:

(I am not a coder, so bear with me if this is a stupid thought)

In the file 'Spawngroup.sqf' I found:

_unit setCombatMode ai_combatmode;
_unit setBehaviour ai_behaviour;


And this info is found in the config.sqf file:

ai_bandit_combatmode = "YELLOW"; // combatmode of bandit AI
ai_bandit_behaviour = "COMBAT"; // behaviour of bandit AI


Per the WAI information, here are the options for these modes and behaviors:
Safe
Aware
Combat
Stealth

And here are the Combat Modes:
  • "BLUE" (Never fire)
    • When hostile units are detected, they will track them, but will never fire back, even when fired upon.
  • "GREEN" (Hold fire - defend only)
  • "WHITE" (Hold fire, engage at will)
  • "YELLOW" (Fire at will)
    • If AI spots a target and decides it is in effective range, he will open fire.
  • "RED" (Fire at will, engage at will)
    • The AI does not keep formation and each member moves individually. The leader command Disengage will set the units back to fire at will (YELLOW)
    • If Attack and Engage is called, the unit will break formation to find the best place to attack from (combat mode RED).
So here is my thought:

If I change the config file, I am changing ALL of the AI's combat mode and behavior. I don't want to do that. I want to be able to set EACH group to have their own behavior. My idea was to create FOUR different spawngroup.sqf files (spawngroup2.sqf, spawngroup3.sqf) and change the combat mode in each to represent one of the four options: I.E.:

ai_bandit_combatmode = "BLUE"; // combatmode of bandit AI
ai_bandit_behaviour = "SAFE"; // behaviour of bandit AI


and then in the file CustomSpawns.sqf, change the line:

[[16426.3,18332.6,0.0],
2, //Number Of units
"Random", //Skill level 0-1 or skill array number if using custom skills "Random" for random Skill array.
"Random", //Primary gun set number. "Random" for random weapon set.
6, //Number of magazines
"", //Backpack "" for random or classname here.
"BanditW2_DZ", //Skin "" for random or classname here.
"Random" //Gearset number. "Random" for random gear set.

] call spawn_group;

to

] call spawn_group2;


Would this work?

I am afraid of altering ANYTHING on my server for fear of screwing things up when it has taken me so long to get things right. Anyone that is smarter than I and could chime in here would be so very appreciated. Hell, maybe the concept is right, but someone has already figured out how?
 
Or what if, instead, I changed the config file to:

/// Sets behavior of AI groups
ai_combatmode = "RED";
ai_behaviour = "COMBAT";

ai_combatmode2 = "YELLOW";
ai_behaviour2 = "COMBAT";

/// Sets behavior of AI groups
ai_combatmode3 = "BLUE";
ai_behaviour3 = "SAFE";

/// Sets behavior of AI groups
ai_combatmode4 = "WHITE";
ai_behaviour4 = "STEALTH";


and then altered each SpawnGroup.sqf file to:

_unit setCombatMode ai_combatmode2;
_unit setBehaviour ai_behaviour2;
 
Or you simply pass the combatmode and behavior to the spawn_group script along with the other information.
example in customspawns.sqf ...
Code:
[[953.237,4486.48,0.001], //position
4,                         //Number Of units
1,                         //Skill level 0-1 or skill array number if using custom skills "Random" for random Skill array.
"Random",                 //Primary gun set number. "Random" for random weapon set.
4,                         //Number of magazines
"",                         //Backpack "" for random or classname here.
"Bandit2_DZ",             //Skin "" for random or classname here.
"Random",                  //Gearset number. "Random" for random gear set.
"RED",  // <----------------------combatmode
"SAFE" //<-----------------------behavior
] call spawn_group;

and it spawngroup.sqf assign those values to local variables just like this
Code:
...
_skin = _this select 6;
_gear = _this select 7;
_mode = _this select 8;
_behavior = _this select 9;
...

and look for this farther down on the script
_unit setCombatMode ai_combatmode;
_unit setBehaviour ai_behaviour;
change it into
Code:
    _unit setCombatMode _mode;
    _unit setBehaviour _behavior;
 
Last edited:
I am afraid of altering ANYTHING on my server for fear of screwing things up when it has taken me so long to get things right. Anyone that is smarter than I and could chime in here would be so very appreciated. Hell, maybe the concept is right, but someone has already figured out how?
Its called BACKUP. You copy the working file to a different folder.:p
 
Thanks for the reply, ShootingBlanks; very helpful. As soon as I try it and verify it, I will post my results.

Also, by that logic, does that mean that I can add a NEW item for 'standstill guards' in the config file?

Current Example:
/// Sets radius for AI patrols (call spawn_group)
ai_patrol_radius = 300;

My Idea:

/// Standing Guards
ai_patrol_radius_2 = 1;

But then where would I add the new line? What would it be connected to? Or is there an much easier way as you demonstrated before?
 
First attempt: No AI present. Report Log shows:

Code:
Error in expression <eAI "ANIM";
_unit enableAI "FSM";
_unit setCombatMode _mode;
_unit setBehaviour >
23:56:10 Error position: <setCombatMode _mode;
_unit setBehaviour >
23:56:10 Error setcombatmode: Type Bool, expected String
23:56:10 File z\addons\dayz_server\WAI\compile\SpawnGroup.sqf, line 67

And my SpawnGroup.sqf file looks like this at that spot:

Code:
    _unit enableAI "FSM";
    _unit setCombatMode _mode;
    _unit setBehaviour _behavior;

And the top of that same file is:

Code:
_gear = _this select 7;
_mode = _this select 8;
_behavior = _this select 9;
if (count _this > 10) then {
    _mission = _this select 10;
} else {
    _mission = False;

I then added the "BLUE" and "SAFE" modes into the CustomSpawns.sqf file (for testing):
Code:
[[15661.6,19812.1,0.6],
2,                          //Number Of units
"Random",                          //Skill level 0-1 or skill array number if using custom skills "Random" for random Skill array.
"Random",                  //Primary gun set number. "Random" for random weapon set.
6,                          //Number of magazines
"",                          //Backpack "" for random or classname here.
"Bandit2_DZ",              //Skin "" for random or classname here.
"Random"                  //Gearset number. "Random" for random gear set.
"BLUE",                    //Combat Mode.
"SAFE"                    //Behavior.
] call spawn_group;
 
I feel like there's something missing. I know the author of WAI listed the modes of 'awareness', but where do these "_behavior"-types of code link to? How does the program know how to make the AI act? I can't find anything in the WAI folders. Just because I put "SAFE" doesn't mean anything if it doesn't know what "SAFE" should look like.

Am I making ANY sense? LOL, sorry if this is nonsense.
 
Back
Top