Author: special Ed
Author Website:

Requirements: No addons required

Version: 1.1

Short description: The system primarily works with 1 man AI Opfor groups, and overall aims towards providing good quality combat environments for Special Ops type scenarios.

Date: 2016-08-01 10:13


Comments: (6)
Rating:



 







AI Modify -Ai Script System

by
special ed

Important:
This is outdated now. Please refer to the Operation Rising Tide website for current AI Modify version download, information, and support forums : mrpibb53.com


Description:
It would be difficult to describe everything the system does in a short generic description, so here is the best I can do.

The system primarily works with 1 man AI Opfor groups, and overall aims towards providing good quality combat environments for Special Ops type scenarios. On the flip side, the system certainly does not lend itself to large scale combat scenarios where such scenarios should simply not use this system. The system can be cpu demanding depending on how many Ai units are placed and of course the operating system performance. I use a laptop that barely meets the requirements for Arma 3 and have found that I only get reasonable in game performance in general by using ported Arma 2 maps and units, and while using Arma 2 content I am able to run the AI_Modify on roughly 40 Ai units that are in actual combat at a time before script lag is threatened, while out of combat ai unit total allowed on my system may actually be over 100 - they must be split up. So in knowing this, it is likely that anyone that can run Arma 3 well on their system can probably afford roughly the same numbers in Arma 3 vanilla content.

The AI_Modify is an AI system that a mission is built around, it is not an AI replacement mod. It is also fairly easy to use, where most of the usage involves simply inputting certain values into arrays in various Ai units Initialization fields and placing markers and unit waypoints down.

The system enables Opfor AI units in one man groups (primarily) to be able to effectively and independently engage/advance upon enemies and react to what other allied Opfor group units are doing. The system does a lot more too - unitSeenUnit scripts work at checking true valid combat mode of Ai units by checking LOS,FOV and distance between units, and will keep units in safe mode if they do not pass the checks even when the Arma 3 engine tries to put them into combat mode usually due to nearby units being hit when there is no true FOV nor LOS to those units. The same UnitSeenUnit code also works at putting Ai units into combat mode depending on LOS,FOV and distance between units in combat mode and also allows communication of discovered enemy positions and move positions set so efforts are coordinated between units that have valid Fov,Los and distance between each other. Anti cluster code keeps units from clumping up on a particular move position - which only works within reason provided the mission maker does not try to put like 100 units within a small radius area which would be unmanageable. The scripts also control the stance of the units,where crouch stance is often used and prone stance is seldom seen and normally only allowed at long distance to an enemy target and not used when the unit is in the process of advancing, 'up' stance is often used intermittently when units are advancing to an enemy position at moderate to long range. Most of the stance system can be controlled by inputting certain settings in a units Init field which allows one to get a greater level of detailed control over the units actions during combat and also allows one to mix things up so different units do different things, speed control during certain combat scenarios is also there.

The scripts have a Machine Gunner system as well, where ai units designated as Mg gunners can be placed nearby their static mg,s in safe mode, and when they go into aware/combat mode will run to the Mg and man it. The awesome Polpox's Calm Animation scripts are incorporated and usage is uber simplified so that it's a snap to run an animation on any unit through their init field. A base alarm system is included, it is very easy to use and put into a mission which works when a non-silenced shot is detected by an Opfor unit within a specified range thereby activating the alarm and alerting all Opfor units within a certain radius area. And there are some other things as well, also there is a good volume of detailed control over various aspects of what the Ai units do when engaging/advancing upon enemies. System also detects detonated explosives placed by west players and any player group ai and will alert enemies within 250 meters of the explosion.

In the end, using the AI_MODIFY system effectively can create combat environments that involve quite a bit of consistent movement by enemy ai units and certainly can provide scenarios where one does not just seek out the enemy, but the enemy will seek the player out and therefore compromised positions are potentially dangerous, leaving the question as to where and when the enemy may show up around a nearby corner. Effective suppressed weapon use has quite a bit of value, along with players paying attention to what other enemies may be in view of a particular target before engaging in order to eliminate enemies quietly. The stealth mission style support can also help encourage coordinated efforts between players in coop missions in order to eliminated multiple enemies without alerting other enemies in the area and without triggering an alarm.

The system is not perfect, I, like many that have created mods and missions do not work for a company to do this, so this is basically as far as things are going to go apart from possibly fixing any major outstanding bugs that may come up. Even in a company environment, an Ai system like this would still likely never be perfect when involving this level of movement - the ai will be seen both doing some cool stuff and doing some dumb stuff too, this is just the price paid for very mobile and potentially aggressive behavior. There is code to that attempts to prevent units from watching nearby walls/etc by drawing lines to watch positions, the possibility is not completely removed and they may on occasion still look in directions that may seem undesirable. The only game I ever have played that I personally feel has very mobile,detailed and potentially aggressive ai behavior is Hidden And Dangerous 2, and ironically, as cool as it can be to see the ai sometimes track you down and move about to various positions there is also the occasional presence of the ai doing dumb and even ridiculous stuff sometimes - but still, Imo better the AI does a lot and a small portion of it is goofy rather than play it safe and the Ai does very little and can end up providing boring and repetitive behavior.

As a final note, this ai system was originally started for the sake of making a good quality special ops style coop mission which is on the verge of release. As time went on, the 'ai changes' became more and more of a system, and roughly a year later it was finished.. that is finished well enough anyhow. The scripting and work involved in making this is normally not the type of thing I prefer to do, mission making of a less complicated sort is more my thing personally, this was really just a one time shot to enhance mission quality, no interest in expanding this nor ever attempting such a thing again lol.

MultiPlayer :
The Ai Modify system has been tested over many hours in Multiplayer, and is working without any oustanding issues, this includes dedicated server use and Jip.

Sinlge Player :
The system fully supports single player mode and has been heavily tested without issue.

Example usage content:
One can refer to how Operation Rising Tide uses the AI system in the editor as an example. I suggest the Kamenyy town area, as the base area may be confusing.

Note that the sample missions are no longer provided due to the fact that BIS has partially broken the SetUnitPos "UP" command, where a workaround had to be installed to get Patrols to work - and I am simply not going to attempt to update sample missions constantly as game functions and commands are broken through Arma 3 updates.

The AI_Modify Raw (for mission making) form shows a text message after a sleep 20 indicating all initial processes complete, this message can be disabled by accessing the Init.sqf (it is a second init.sqf) in the AiModify folder itself and changing the line : Debug = True to Debug = False. A normal mission must not allow opfor Ai units to be engaged until this initial time has passed.

Major things the AI_MODIFY does not support:
Zeus.
Spawning Opfor units during mission.
Supporting Opfor/Independant sided players.
Group names for Opfor Ai units cannot be relied upon because the script system changes groups constantly to get units moving - the easiest workaround is just to use the unit names or make arrays that contain grouped units. It was attempted to preserve original group names early on with no success.
Opfor units running the system only have limited support for multi-level interior buildings, and it is best to avoid such buildings as much as possible in major
mission areas to avoid seeing an occasional unit going into the building while staring up at the ceiling while trying to move to a 2nd story or higher position. There
should normally be no problem with guard towers and such though. <- May look into fixing this at some point (not really a simple fix).

Arma 3 military cargo buildings can only be reliably used if they are lowered so the floor is near the ground level to avoid units trying to go under the buildings.
Note that the system does set move positions for Ai at proper heights (using ATL for everything), but for whatever reason buildings that have significantly raised first floors (especially if there is a space underneath) still can cause the Ai to sometimes try to path underneath the buildings even when the move position is truly at the floor height.


Installation / Usage:
Copy the files that are *inside* of the AI_MODIFY_FILES folder (not the folder itself) and then paste them directly into your mission name folder (i.e. - MyMission.Stratis). Then in the mission editor, put a civilian named Georgee down at some distant hidden area on the map and put into his init field :This AllowDamage False; . And then from there, add Opfor units for your mission and refer to either the documentation or just copy and paste the Init field code provided below. Important: If a mission is going to use the Ai System, then ALL opfor units MUST have at least the essential init field code, or else they may cause faults in the scripts - at very least the AddUnitToVar.Sqf script must be ran on each unit -

Exmaple of the essential Init field code is (the actual settings below passed can be changed):
if (isServer) then {null = [This,1,1,150,0,0,0] ExecVM "AI_Modify\AddUnitToVar.Sqf";this SetUnitPos "UP";this SetBehaviour "SAFE";};

There is a LOT that can be done by modifying and adding further Init field code to Opfor units, along with town/base alarms that the scripts support that can be added into a mission, and a few other things as well. One can open Operation Rising Tide in the editor and refer to Ai Modify usage around the town of Kamenny for having a direct reference to usage - (Base area can be confusing due to object volume).

The AI_Modify shows a text message after a sleep 20 indicating all initial processes complete, this message can be disabled by accessing the Init.sqf (it is a second init.sqf) in the AiModify folder itself and changing the line : Debug = True to Debug = False. A normal mission must not allow opfor Ai units to be engaged until this initial time has passed.

At this time it is suggested to avoid using the independent side. The AI_Modify script CANNOT be ran on west nor Independent units, and when using West Ai units in a mission, they should only be player group units.


Known issues:
Do not expect precisely predictable behavior/action by the AI at times, some things work as intended and some things don't as much as desired, it's good enough.

The Ai_Modify system does indeed at times do some battling with the Arma 3 Ai behavior to pull off some of what it does, an occasional ai glitch may happen.

Rarely the line drawing between units fails, usually the unitSeenBackup script deals with this, although it is remotely possible it can fail altogether sometimes.

The line drawing involving untis in vehicles seems to be generally failing so ground units in combat mode may very well Not affect nearby crewed vehicles, so when involving crewed vehicles in a mission one will have to just improvise depending on the situation manually. Same is likely for manned vehicles in combat mode affecting nearby ground units, the line drawing will likely fail due to the vehicle object, again, one will just have to improvise. Base alarms, and likely all loud guns fired from anyone will put units in a vehicle potentially in Aware or Combat mode properly (because line drawing is not involved).

Units sometimes take quite a bit longer than desired to move to specified defensive positions even when ordered to move at the highest priority - units sent to man static Mg's usually do fine (they do not use wp's). This is because these move orders are waypoint based rather than using the DoMove command. The AttackEnemy function that sends units out after enemy positions *does* use the DoMove command, and it was a complicated endeavor. I was not then, nor am I going to get into dealing with the DoMove command usage again for the defensive positions due to complexities, so the waypoint plan is how it stays.

(Not really an 'issue' but..)
Units that are alerted by either a base alarm or by one of their own side firing a loud weapon will go from safe mode into Aware instead of combat mode and most of these units except for patrols will go into crouch stance. They do not go into combat mode in this instance becasue combat mode behavior is more/less "saved" so that the UnitSeenUnit scripts can continue to run on these Aware mode units until either true enemy contact happens or they react to other nearby allies that are in combat mode. So the weapon rasied look only happens for the moving patrols in Aware mode, but the crouch stance certainly reflects the units in general 'at the ready', and this is just the way the system worked out.

SetUnitPos "UP" partially broken :
BIS broke part of the 'SetUnitPos' command a few Arma 3 updates ago , and right now if it is set to "UP" in a units init field in the usual fashion that is on a waypoint plan (like a patrol), it will cause the unit to walk around with their weapon raised (even though they are still in safe behavior). Fortunately, a workaround has been found that is working so far which can still be put into each Patrol units Init field. This should only be done for units on patrol plans. Unfortunately, even with this workaround, the patrols can still bug out due to this Arma 3 issue where they may not respond properly to combat conditions in a variety of fashions.
Init field :
Instead of : SetUnitPos "UP";
Replace with this :
null = [this] Spawn {Sleep 2.0; (_this Select 0) setUnitPos "UP";};

There is another problem that the SetUnitPos "UP" bug is causing - it is affecting saved game loads along with the mission start issue.
The below is an example of usage in my mission for fixing the raised weapon animation bug during a saved game load when units in safe mode have SetUnitPos "UP"
(The Initialization field code for Opfor units that is described previous here is still required for the mission start issue itself)
//Place a static object on the map away from the mission area, name it, I suggest setting it to not allow damage in the object editor settings and it should be a somewhat small object that would not have mass greater than 300 (the rowboat I picked actually has 0 mass, so possibly many static objects have no true mass)
//RowBoatD is the name I used for the object I placed on a distant beach
//It could be probably almost any static object and any desired variable name
//In the chosen object Initialization field :if (IsServer) then {This SetMass [300,0];};
//PatrolGuy1, PatrolGuy2, etc are the names I gave my patrol men, they must be named so they can be referenced in script directly
//SetUnitPosBugFix.sqf
//Can run this from the Init.sqf or can execute this script from anywhere desired as long as it runs on server side for Mp
//[] ExecVm "SetUnitPosBugFix.sqf";
if (IsServer) then
{
Private ["_RunsScriptB"];
_RunsScriptB = 1;
Sleep 2.0;
While {(_RunsScriptB == 1)} Do
{
//If mass resets to original on the object, then a saved game has been loaded
if ((GetMass RowBoatD) != 300) then
{
RowBoatD SetMass [300,0];
//This area addresses the issue with patrols in safe mode that have unitpos set to up that end up with weapons raised after loading a saved game
if ((Behaviour PatrolGuy1 == "SAFE") && (UnitPos PatrolGuy1 == "UP")) then {[] Spawn {PatrolGuy1 SetUnitPos "AUTO";Sleep 1.5;PatrolGuy1 SetUnitPos "UP";};};
if ((Behaviour PatrolGuy2 == "SAFE") && (UnitPos PatrolGuy2 == "UP")) then {[] Spawn {PatrolGuy2 SetUnitPos "AUTO";Sleep 1.5;PatrolGuy2 SetUnitPos "UP";};};
if ((Behaviour PatrolGuy3 == "SAFE") && (UnitPos PatrolGuy3 == "UP")) then {[] Spawn {PatrolGuy3 SetUnitPos "AUTO";Sleep 1.5;PatrolGuy3 SetUnitPos "UP";};};
if ((Behaviour PatrolGuy4 == "SAFE") && (UnitPos PatrolGuy4 == "UP")) then {[] Spawn {PatrolGuy4 SetUnitPos "AUTO";Sleep 1.5;PatrolGuy4 SetUnitPos "UP";};};
if ((Behaviour PatrolGuy5 == "SAFE") && (UnitPos PatrolGuy5 == "UP")) then {[] Spawn {PatrolGuy5 SetUnitPos "AUTO";Sleep 1.5;PatrolGuy5 SetUnitPos "UP";};};
if ((Behaviour PatrolGuy6 == "SAFE") && (UnitPos PatrolGuy6 == "UP")) then {[] Spawn {PatrolGuy6 SetUnitPos "AUTO";Sleep 1.5;PatrolGuy6 SetUnitPos "UP";};};
if ((Behaviour PatrolGuy7 == "SAFE") && (UnitPos PatrolGuy7 == "UP")) then {[] Spawn {PatrolGuy7 SetUnitPos "AUTO";Sleep 1.5;PatrolGuy7 SetUnitPos "UP";};};
if ((Behaviour PatrolGuy8 == "SAFE") && (UnitPos PatrolGuy8 == "UP")) then {[] Spawn {PatrolGuy8 SetUnitPos "AUTO";Sleep 1.5;PatrolGuy8 SetUnitPos "UP";};};
if ((Behaviour PatrolGuy9 == "SAFE") && (UnitPos PatrolGuy9 == "UP")) then {[] Spawn {PatrolGuy9 SetUnitPos "AUTO";Sleep 1.5;PatrolGuy9 SetUnitPos "UP";};};
if ((Behaviour PatrolGuy10 == "SAFE") && (UnitPos PatrolGuy10 == "UP")) then {[] Spawn {PatrolGuy10 SetUnitPos "AUTO";Sleep 1.5;
PatrolGuy10 SetUnitPos "UP";};};
if ((Behaviour PatrolGuy11 == "SAFE") && (UnitPos PatrolGuy11 == "UP")) then {[] Spawn {PatrolGuy11 SetUnitPos "AUTO";Sleep 1.5;
PatrolGuy11 SetUnitPos "UP";};};
if ((Behaviour PatrolGuy12 == "SAFE") && (UnitPos PatrolGuy12 == "UP")) then {[] Spawn {PatrolGuy12 SetUnitPos "AUTO";Sleep 1.5;
PatrolGuy12 SetUnitPos "UP";};};
if ((Behaviour PatrolGuy13 == "SAFE") && (UnitPos PatrolGuy13 == "UP")) then {[] Spawn {PatrolGuy13 SetUnitPos "AUTO";Sleep 1.5;
PatrolGuy13 SetUnitPos "UP";};};
};
Sleep 1.0;
};
};

Probably other stuff I forgot too.


Credits & Thanks:
jus61 : Providing the Ai Modify system on his dedicated server for testing.
genesis92x : All code inside the VCOMAI folder which includes - Take Cover function, Hit Near function and additional supporting code for those functions (permission was gained).
POLPOX : POLPOX's calm animations.
Tpw : Integrated LOS and FOV supporting code from Tpw_Los script
KillZone_Kid : KK_fnc_inString function.
Heeeere's johnny! : For getting doors names for buildings from A2 by going through his Auto Open Doors script, although this is used actually in the upcoming mission.

Bis Forums Members that have helped significantly with questions about a vast variety of scripting issues:
mdcclxxvi
jshock
tyger
larrow
das attorney
Heeeere's johnny!
davidoss
R3vo
zriel
naizarak
silentspike
killzone_kid
chrisnic
Grumpy Old Man


License / Disclaimer:
A mission that uses the AI_Modify system needs to have the entire system installed into the mission, so a public release in this manner is normal and fine. Credit provided for the usage of the Ai_Modify system in ones mission would be appreciated.
One may extract portions of the code in this Ai system to be integrated into their own scripts/missions, including entire scripts - if so, please provide credit towards the author of the extracted code in your mission/mod.
If one wishes to modify the Ai_Modify itself and release the modified ai system as a new/different version of the Ai_Modify they *Must* contact me first. I do support and welcome any possible future modified/updated forms of the Ai_Modify system for the sake of improving the mission play quality overall, but again I need to be contacted before such a re-release of both mine and others work is approved.


Changelog:
v1.2
Units using the Calm Animations when being reset to safe mode by the scripts now face correct directions.
Defensive waypoint plans now use a DoWatch command in their last waypoint to improve watch pos reliability in combat behavior.

v1.1
Defensive waypoint plan usage reliability by Ai significantly increased - particularly while Ai units are in Combat behavior.
Sample missions converted to 3D editor form.

v1.0
Small improvement to the animations scripts for multiplayer.
Lag tested on a dedicated server with no outstanding issues.

v0.8
Numerous Multiplayer fixes applied to animation scripts, working on a dedicated server as well.
Explosives detonating that were placed by player units are now being detected by the scripts in Multiplayer, working on a dedicated server also.
Waypoints fixed for short distance patrol in the Ai_Modify_Vanilla_TestBed mission - the waypoint heights were at crazy values, reset now to 0.
A number of other fixes and tweaks for Multiplayer usage.

V0.7
Initial delay added to PlayerJoinsBackup.sqf so it does not run too many times early on.

v0.5
Polpox's animations working in Multiplayer on a dedicated server.
Polpox's animations working with Jip on a dediated server.
Base alarms working in Multiplayer on a dedicated server.
Ai System delay message uses RemoteExec for Mp.

v0.2
Sample and TestBed missions included that do not require addons.
Ai System delay message switched to using globalchat for Mp.
Updated included documentation with a few additional potentially helpful bits of information

v0.1
- first release


Forum topic:
- BI forums


Important:
This is outdated now. Please refer to the Operation Rising Tide website for current AI Modify version download, information, and support forums : mrpibb53.com





Enable javascript to be able to download from Armaholic please!



Tags: No tags