Jump to content

AI: Difference between revisions

228 bytes added ,  20 December 2015
continuing rewrite; correcting statement that gunfire dodging was only fixed for particles -- I am pretty confident it was fixed for firing spreads too
(continuing rewrite)
(continuing rewrite; correcting statement that gunfire dodging was only fixed for particles -- I am pretty confident it was fixed for firing spreads too)
Line 399: Line 399:




==Combat behavior part 3: "They see me shootin', they hatin'..."==
==Weapon combat behaviors==
Back in 2001 Oni was highly praised for its mixture of shooting and hand to hand combat. Now what could AI designers of Oni possibly do to make AI characters aim, pull a trigger or to make them avoid being hit by enemy? In this section, [[ONWC]], together with [[ONCC]] and [[PAR3]] will tell the story.
Back in 2001, Oni was highly praised for its mixture of shooting and hand-to-hand combat. Now what could the AI designers for Oni possibly do to make AI characters aim a gun, pull a trigger or avoid being hit by enemy gunfire? In this section, settings found in [[ONWC]], together with [[ONCC]] and [[PAR3]], will tell the story.


:First let's look into [[ONCC]] file. In XML file, under <AIConstants>, there's a tag named <Flags>. In binary file it is a bitset, so more than one flag can be written into it. XML strings for flags are:
:First let's look into the ONCC file. In an XML export of this file, under <AIConstants>, there's a tag named <Flags>. In the original binary data it is a bitset, meaning that more than one flag can be active at a time. The XML strings for the flags are:
:*noStartleAnim - Disables startle animation when AI sees the enemy for the first time.
:*noStartleAnim: disables the startle animation that can occur when the AI sees the enemy for the first time.
:*EnableMeleeDodge - Enables firingspread/projectile dodging when AI is in pathfinding mode or combat melee mode
:*EnableMeleeDodge: enables firing spread/projectile dodging while the AI is in pathfinding mode or melee combat mode.
:*RunAwayDodge - Enables firingspread/projectile dodging even when AI itself is shooting a gun. AI character stops shooting and tries to move away from the danger area.  
:*RunAwayDodge: enables firing spread/projectile dodging even while the AI itself is shooting a gun. The AI will stop shooting and try to move away from the danger area.  
:*ShootDodge -  Enables firingspread/projectile dodging even when AI itself is shooting a gun. AI character keeps shooting its enemy while at the same time attempts to move away from the danger area.  
:*ShootDodge: enables firing spread/projectile dodging even while the AI itself is shooting a gun. The AI will keep shooting at its enemy while at the same time attempting to move away from the danger area.  
:*NotUsed - Some ONCC character have this bit set, however it looks like it does nothing.
:*NotUsed: Some characters have this bit turned on, however it looks like it does nothing.


[[File:Firingspread.PNG|thumb|right|alt=Example of a firingspread.|Example of a firingspread.]]
[[File:Firingspread.PNG|thumb|right|alt=Example of a firing spread.|Example of a firing spread.]]
[[File:Projectile.PNG|thumb|right|alt=Example of a particle with AI projectile dodge radius.|Example of a projectile with AI dodge radius (blue sphere).]]
[[File:Projectile.PNG|thumb|right|alt=Example of a particle with an AI projectile-dodge radius.|Example of a projectile with AI dodge radius (blue sphere).]]
'''Gunfire dodging mechanics'''. Gunfire dodging mechanics is a quite interesting part of Oni AI system. Interesting because the retail version features little to no such a behavior displayed which is sad because it gives a feeling of challenge to a gunplay. In order to make AI character perform dodge mechanics, this AI must be in combat mode with some enemy. Without combat mode and some enemy, AI character won't dodge. Next, AI characters perform dodge when the character intersects with:
'''Gunfire dodging mechanics'''. Gunfire dodging mechanics are quite an interesting part of Oni's AI system -- interesting because the retail version displays little to no such behavior, which is sad because it adds challenge to the gunplay. In order to make an AI perform gunfire dodging, this AI must be in combat mode with an enemy. Without combat mode and some enemy, AI character won't dodge. Additionally, an AI will only perform a dodge when the character senses one of these two things:
:*Firingspread - can be seen by '''ai2_showfiringspreads=1'''. Firing spread is an invisible prism (dimensions set in [[ONWC]]) which can be created when a weapon is fired. Not every gun has a firingspread as for some guns firingspread is useless (SCRAM cannon, SuperBall gun). If AI character can dodge gunfire and intersects with a firingspread, this AI character starts gunfire dodging mechanics.
:*Firing spread. This can be seen by using [[ai2_showfiringspreads]]. The firing spread has the shape of a prism (its dimensions set in ONWC) which can be created when a weapon is fired. Not every gun has a firing spread, as for some guns a firing spread is useless (e.g. the Scram Cannon and Super Ball Gun). If an AI can dodge gunfire and intersects with a firing spread, this AI character starts its gunfire dodging behavior.
:*Projectile - epic win of Oni modders, can be seen with '''ai2_showprojectiles=1'''. In retail version of Oni, projectile dodging '''is defunct''' due to a couple of bugs in a projectile dodging code. Since the engine hackers/modders '''fixed this issue''', AI characters can execute gunfire dodge mechanics versus [[PAR3]] particle, if these AIs are in combat mode with some enemy and the particle has set <AIDodgeRadius> to a positive non-zero value.
:*Projectile. Visualize this feature with [[ai2_showprojectiles]]. AIs will dodge particles themselves if they are in combat mode with some enemy and the particle (e.g. the Screaming Cell Cannon's projectile) has <AIDodgeRadius> set to a positive non-zero value.


Projectile dodging is the epic win of Oni modders. In the retail version of Oni, projectile dodging is mostly broken due to a couple of bugs in the code. Since the engine hackers/modders fixed this issue, AIs can now [https://www.youtube.com/watch?v=aEuAu7jLQQI execute proper gunfire dodging].


:AI parameters regarding gunfire dodging are set in [[ONCC]] (xml tags in parentheses):
:*Dodge reaction delay (DodgeReactFrames) - a delay in number of frames. This delay makes A.I character wait a bit inside danger zone before this AI character starts its reaction on firingspred/projectile.
:*Dodge timescale (DodgeTimeScale) - how long should the AI character's gunfire dodge reaction last.
:*Dodge weight (DodgeWeightScale) - how strong is the desire (???length of vector???) of this AI character to dodge a gunfire. Dodge can add together with other "vector" movements and a sum of all vectors is the direction in which AI character will try to move.


:AI parameters regarding gunfire dodging are set in ONCC (XML tags in parentheses):
:*Dodge reaction delay (DodgeReactFrames): a delay, in number of frames, which makes an AI wait a bit inside a danger zone before starting its reaction to the firing spread/projectile.
:*Dodge timescale (DodgeTimeScale): how long the AI's gunfire dodging behavior should last.
:*Dodge weight (DodgeWeightScale): how strong the desire (as a length of vector???) is for this AI character to dodge gunfire. The dodge weight can add together with other "vector" movements, and a sum of all vectors is the direction in which the AI will try to move.


:Parameters of firingspread in [[ONWC]] are (xml tags in brakets):
:*Firingspread length (FireSpreadLength)
:*Firingspread width (FireSpreadWidth)
:*Firingspread skew (FireSpreadSkew)


:Parameter of projectile dodging in particle system [[PAR3]] is AI dodge radius (AIDodgeRadius).
:Parameters of firing spread in ONWC are (XML tags in brakets):
:*Firing spread length (FireSpreadLength)
:*Firing spread width (FireSpreadWidth)
:*Firing spread skew (FireSpreadSkew)


:The parameter for projectile dodging in the particle system (PAR3) is the AI dodge radius (AIDodgeRadius).




'''AI character's prowess with guns'''. Still in [[ONCC]], there are data how "skillful" this AI character should be with each weapon in the game. Weapons are indexed (starting from zero) as follows:
:*w0_sec (0) - Only Bungie West empl-yees know what this weapon was supposed to be.
:*w1_tap (1) - TCTF automatic pistol
:*w2_sap (2) - Syndicate sub-machine gun
:*w3_phr (3) - plasma rifle
:*w4_psm (4) - phase stream projector
:*w5_sbg (5) - grenade launcher alias SuperBall Gun
:*w6_vdg (6) - stun gun ('''V'''an '''D'''e '''G'''raaf gun)
:*w7_scc (7) - scram cannon (swarm of small homing rockets)
:*w8_mbo (8) - mercury bow
:*w9_scr (9) - screaming cannon
:*w10_sni (10) - Mukade's Devil star (annoying red ball) as a holdable weapon; probably a relic from game development
:*w10_ba1 (11) - Barabas' gun
:*w11_ba2 (12) - Barabas' gun; this one cannot be shot and is probably just a development relic.


'''AI character's prowess with guns'''. Still in the ONCC, there are settings for how skillful this AI should be with [[Quotes/Weapons|each weapon in the game]]. Weapons are indexed (starting from zero) as follows:
:*0: w0_sec - only Bungie West employees know what this weapon was supposed to be.
:*1: w1_tap - TCTF Automatic Pistol
:*2: w2_sap - Syndicate Automatic Pistol (the SMG)
:*3: w3_phr - Plasma Rifle
:*4: w4_psm - Phase Stream Projector
:*5: w5_sbg - Super Ball Gun
:*6: w6_vdg - Van de Graaff Gun
:*7: w7_scc - Scram Cannon
:*8: w8_mbo - Mercury Bow
:*9: w9_scr - Screaming Cell Cannon
:*10: w10_sni - Mukade's Devil Star (heat-seeking red ball) as an invisible weapon; probably a relic from game development.
:*11: w10_ba1 - Barabas' gun, the Wave Motion Cannon.
:*12: w11_ba2 - Barabas' gun; this one cannot be shot and is probably a development relic.


:For each one of these weapons, there are in ONCC defined these parameters (xml tag in parentheses):
:*Recoil compensation (RecoilCompensation) - How much the AI cahracter compensates the recoil of the weapon. Setting this to 0.0 mean no compensation, setting this to 1.0 means full compensation.
:*Best aiming angle (BestAimingAngle) - In radians, but question is whether it really affects aiming.
:*Shoot group error (ShotGroupError) - Random deviation of AI's aim within the target spot. Incorporated to simulate human inaccuracy. Can be set more than 1.0.
:*Shoot droup decay (ShotGroupDecay) - Random deviation of the target spot. Target spot is always loosely based on enemy's position. Can be set more than 1.0.
:*Shooting inaccuracy multiplier (ShootingInaccuracyMultiplier) - How much can AI stray with its aim from the target. Not clear how much it really affects aiming.
:*Minimal shooting delay (MinShotDelay) - Minimal pause between reload and the beginning of a gunfire for this AI character.
:*Maximal hooting delay (MaxShotDelay)- Minimal pause between reload and the beginning of a gunfire for this AI character.


:For each weapon, the ONCC defines these parameters (XML tag in parentheses):
:*Recoil compensation (RecoilCompensation): how much the AI character compensates for the recoil (vertical stray) of the weapon. Setting this to 0.0 means no compensation, and setting this to 1.0 means full compensation.
:*Best aiming angle (BestAimingAngle): in radians, but the question is whether it really affects aiming.
:*Shoot group error (ShotGroupError): the random deviation of the AI's aim from the target spot. Incorporated to simulate human inaccuracy. Can be set higher than 1.0.
:*Shoot group decay (ShotGroupDecay): the random deviation of the target spot itself. The target spot is naturally based on the enemy's position. Can be set higher than 1.0.
:*Shooting inaccuracy multiplier (ShootingInaccuracyMultiplier): also controls the degree that the AI's aim strays from the target, but it's not clear how much it really affects aiming.
:*Minimal shooting delay (MinShotDelay): minimum pause between reloading and resuming firing.
:*Maximal shooting delay (MaxShotDelay): maximum pause between reloading and resuming firing.






'''Targeting and prediction''' of enemy's movement. Apart from majority of other games, Oni AI does not "cheat" by being 100% accurate and then having some kind of additive error (even tough additive error is present in Oni, see above). It is a bit inverse - there's a bit of a problem making AI being a reasonably precise marksman ^_^. AI character is given input parameters such as distance between characters, present velocity of its enemy (vector) and velocity of held gun's projectile (number, not a vector). From this data, AI logic computes a prediction of enemy's location and ideal aiming direction in order to hit the enemy.
:[[ONCC]] parameters for targeting and prediction (xml tags in parentheses):
:*Predict amount (PredictAmount)- Some sort of multiplier for prediction mechanics.
:*Predict position delay (PredictPositionDelay) - In frames, delay before prediction is applied, so AI characters always uses a bit outdated prediction result.
:*Predict delay frames (PredictDelayFrames) - In frames, delay before prediction is computed. Must be set at least to 1.0.
:*Predict velocity frames (PredictVelocityFrames) - Number of frames interval but meaning not 100% sure. Maybe enemy's velocity data are obtained and used for prediction algorithm during the interval? Must be set at least to 2.0.
:*Predict trend frames (PredictTrendFrames) - Number of frames interval but meaning not 100% sure. Maybe a trend (sort of extrapolation of enemy's movement) is computed with data from this interval? Must be set at least to 2.0.


:[[ONWC]] parameters for targeting and prediction (xml tags in parentheses):
'''Targeting and prediction''' of the enemy's movement. Unlike the majority of other games, Oni's AI does not "cheat" by starting from 100% accuracy and then adding some degree of error (even though additive error is also present in Oni; see above). To the contrary, there's a bit of a problem making the AI a precise marksman ^_^. The AI is given input parameters such as the distance between itself and the enemy, the present velocity of its enemy (as a vector), and the velocity of their gun's projectile (as a number, not a vector). From this data, the AI logic computes a prediction of the enemy's location and the ideal aiming vector for hitting the enemy.
:*Prediction speed (PredictionSpeed) - More precisely "projectile prediction speed". This value is taken by prediction algorithm as a speed of a projectile fired with the corresponding fire mode of the [[ONWC]] weapon. Thus when actual [[PAR3]] projectile's speed is changed, prediction behavior produces misleading values (AI is unable to hit moving targets).
:The ONCC parameters for targeting and prediction are (XML tags in parentheses):
:*Maximal inaccuracy angle (MaxInaccuracyAngle) - Maximal allowed deviation of aim from the enemy's character pelvis in order to keep firing the weapon. If exceeded, AI ceases fire and corrects aiming, the resumes fire. Pelvis is taken as a root point of the character, so without any extra chages done to targeting origin and targeting vector (see [[ONWC]]) AI characters always target pelvis of the enemy.
:*Predict amount (PredictAmount): some sort of multiplier for prediction mechanics.  
:*Aim radius (AimRadius) - no idea what it does.
:*Predict position delay (PredictPositionDelay): in frames, the delay before prediction is applied, so that the AI always somewhat-outdated prediction.
:*Ballistic projectile speed (ProjectileSpeed) - special prediction can be used if weapon is meant to fire relatively slow but gravity affected projectiles (grenades). AI then adjusts aiming in order to hit enemy with the projectile according to the ideal (parabolic) ballistic curve. This is a horizontal speed component.
:*Predict delay frames (PredictDelayFrames): in frames, the delay before prediction is computed. Must be set to at least 1.0.
:*Ballistic projectile gravity (ProjectileGravity) - vertical gravity attraction for the projectile.
:*Predict velocity frames (PredictVelocityFrames): this is a period of time in number of frames, but the meaning is not 100% clear. Maybe the enemy's velocity data is obtained and used for prediction algorithm during this period of time? Must be set to at least 2.0.
:*Predict trend frames (PredictTrendFrames): another period of time in number of frames that is not 100% clear. Maybe the distance ahead that extrapolation of the enemy's movement takes place? Must be set to at least 2.0.


:*Targeting direction (Direction) - Vector with three components (x, y, z) which gives orientation of a firingspread. When set to wrong values, firingspread will not cover area where the weapon shoots, but will be pointing in some other direction ( can even point backwards ^_^). Friendly advice: do not alter unless needed.
:The ONWC parameters for targeting and prediction are (XML tags in parentheses):
:*Prediction speed (PredictionSpeed): more precisely "projectile prediction speed". This value is taken by the prediction algorithm as the speed of a projectile fired with the corresponding fire mode of the ONWC weapon. Thus, when the actual PAR3 projectile's speed is changed, this prediction behavior produces misleading results (i.e., the AI is unable to hit moving targets).
:*Maximum inaccuracy angle (MaxInaccuracyAngle): maximum allowed deviation of aim from the enemy's pelvis while firing the weapon. If exceeded, the AI ceases fire and corrects its aiming, then resumes fire. The pelvis is considered to be the root point of the character, so without any modifications made to the targeting origin and vector (see ONWC), AIs always target the pelvis of the enemy.
:*Aim radius (AimRadius): no idea what this does.
:*Ballistic projectile speed (ProjectileSpeed): a separate prediction method can be used if the weapon fires gravity-affected projectiles (e.g. grenades). The AI then adjusts its aiming in order to hit the enemy using the ideal (parabolic) ballistic curve. This is a horizontal speed component.
:*Ballistic projectile gravity (ProjectileGravity): the vertical gravity component of the same projectile.


:*Targeting origin (Origin) - Vector with three components (x, y, z) which tells AI where to fire according to enemy's pelvis position. When armed AI is in combat mode with the enemy and shoots him, the AI searches for pelvis (see [[TRIA]]) as the pelvis is the only bone recognized by AI system. For AI, pelvis is a representation of a whole character. Now when AI fires at its enemy, the AI aims for pelvis. The vector described in this parameter tells AI where and how much to deviate from enemy's pelvis position.
:*Targeting direction (Direction): a vector with three components (x, y, z) which gives the orientation of a firing spread. When set to wrong values, the firing spread will not cover the area where the weapon actually shoots (it can even point backwards ^_^). Friendly advice: do not alter unless needed.
::So when the vector is set as (0, 0, -2), AI will aim and fire at enemy's pelvis position + two units above. That means AI will fire ABOVE the pelvis position. Here is described effect of setting "x,y,z" from SHOOTER's point of view. First to positive, then to neative value:
 
::*x - deviate forward/backward (does not have much of an effect)
:*Targeting origin (Origin): a vector with three components (x, y, z) which tells the AI where to fire in relation to the enemy's pelvis. When an armed AI is firing at an enemy, the AI searches for his/her pelvis (see [[TRIA]]), as the pelvis is the representation of the whole character in the AI system. The vector described in this parameter tells the AI how much and in which direction to deviate from the enemy's pelvis position.
::So when the vector is set as (0, 0, -2), the AI will aim two world units above the enemy's pelvis position. Here is the effect of setting each component positive and then negative, from the shooter's point of view:
::*x - deviate forward/backward (does not have much of an effect when firing at someone on the same floor, as you would expect)
::*y - deviate right/left
::*y - deviate right/left
::*z - deviate down/up (headshots, anyone?)
::*z - deviate down/up (headshots, anyone?)




'''Miscellaneous [[ONWC]] AI setup''' - there are a few more parameters in ONWC which affect AI behavior with the weapon. They are (xml tags in parentheses):
'''Miscellaneous ONWC AI setup''' - there are a few more parameters in ONWC which affect AI behavior with a weapon. They are (XML tags in parentheses):
:*Minimal shooting distance (MinShootingDistance) - defines how close can enemy be to the armed shooting AI character. If enemy comes closer than this distance, AI stops shooting and tends to move back a bit (vector type of movement, see [[#Pathfinding and movement|HERE]]) until the distance is again equal or greater than Minimal shooting distance. Then AI opens fire again. To witness the effect, see some AI operating an SBG when its enemy is close to it.
:*Minimum shooting distance (MinShootingDistance): defines how close the enemy can be to the AI that is firing. If the enemy comes closer than this distance, the AI stops shooting and tends to move backward (a vector-based movement; see [[#Pathfinding and movement|HERE]]) until the distance is again equal to or greater than the minimum shooting distance. Then the AI opens fire again. To witness this effect, watch an AI operating an SBG when its enemy is close to it.
::'''IMPORTANT''' - for some unknown reason, value from this field is '''divided by 2'''. So when 100 is set, ingame AI starts backing when its enemy is 50 units close to it.
::'''IMPORTANT''': for some unknown reason, the value from this field is '''divided by 2'''. So when set to 100, the AI starts backing up when its enemy is 50 units away.
:*Maximal shooting distance (MaxShootingDistance) - contrary to the parameter described above, this limits how far can enemy be till the AI stops shooting and tends to come closer. See some AI character shooting with w2_sap at distant enemy.
:*Maximum shooting distance (MaxShootingDistance): The opposite of the parameter described above, this limits how far away an enemy can be before the AI stops shooting and starts moving closer. Watch an AI shooting with the SMG at a distant enemy.
:*Fight timer (FightTimer) - a bit similar to timer-based BSL command '''chr_dontaim'''. Defines in frames for how long should AI switch from a weapon varient (shooting) to a melee varient (hand to hand combat) if this firing mode was used (don't forget, weapon can has two firing modes) and certain conditions were met. See below for ''KnockdownSwitcher'' and ''StunSwitcher'' flags explanations.
:*Fight timer (FightTimer): a bit similar to thetimer-based BSL command chr_dontaim. Defines in frames for how long should AI switch from a weapon variant (shooting) to a melee variant (hand-to-hand combat) if this firing mode was used (don't forget, a weapon can have two firing modes) and certain conditions were met. See below for ''KnockdownSwitcher'' and ''StunSwitcher'' flag explanations.




:*basic parameters of a weapon (pistol or rifle type, type of ammunition etc.) can be set as a various flags in [[ONWC]] flags field (<Flags> in xml). These three flags from them affect AI behavior (xml tags in parentheses):
:*The basic parameters of a weapon (pistol or rifle, type of ammunition, etc.) can be set using various flags in the ONWC (<Flags> in XML). These three flags from among those affect AI behavior (XML tags in parentheses):
:**NoHolster - apart from holster disabled, this flag also makes AI character ignore this weapon on the ground. One exception is w10_ba1 when AI character has set Superammo flag (InfiniteAmmo in xml) in its [[CHAR]] profile, then this AI character can pick up WMC cannon. If AI character is given the weapon it will fire it, but if the weapon is lying on the ground and AI character does not have superammo flag, this AI character will never pick it up.
:**NoHolster: apart from disabling the ability to holster the weapon, this flag also makes the AI ignore this weapon when lying on the ground. One exception is w10_ba1 when the AI has the Superammo flag (InfiniteAmmo in XML) set in its CHAR profile; then this AI character can pick up the WMC cannon. If an AI is given the weapon, it will still fire it.
:**Stun switcher (StunSwitcher) - if the enemy is within armed AI character's shooting distance and was knockdowned, stunned or blownupped, the AI character switches to a melee for a time specified in the weapon's Fight timer (see above). The flag was designed specially for w6_vdg weapon.
:**Stun switcher (StunSwitcher): If the enemy is within an armed AI's shooting range and was knocked down, stunned or blown up, the AI switches to melee for a time specified in the weapon's Fight timer (see above). This flag was designed specially for w6_vdg.
:**Knockdown switcher (KnockdownSwitcher) - Similar to Stun switcher, but only knockdown or blownup makes AI switch to melee. Tailored for w4_psm, probably to avoid AI abuse of an unfair advantage the w4_psm weapon grants (enemy cannot get up as long as she/he is shot).
:**Knockdown switcher (KnockdownSwitcher): Similar to Stun switcher, but only a knockdown or a blownup makes the AI switch to melee. Tailored for w4_psm, probably to avoid AI abuse of an unfair advantage that the PSP grants (the enemy cannot get up as long as she/he is being shot).








Modding hints: Phew, what a long section. Described material has plenty of modding possiblities. Still, modders should be aware of a few things:
Modding hints: Phew, what a long section. The described material has plenty of modding possibilities. Still, modders should be aware of a few things:
:*Don't set too strong dodge vector (DodgeWeightScale) and don't overdo it with dodge timer (DodgeTimeScale, the smallest possible value is 0.4; lower is not registered). Delay before gunfire dodging (DodgeReactFrames) should be minimal, otherwise it can happen AI won't start dodging till shooter's weapon is empty.
:*Don't set too high of a dodge vector (DodgeWeightScale), and don't overdo it with the dodge timer (DodgeTimeScale) -- the smallest possible value is 0.4; lower is not registered. The delay before gunfire dodging (DodgeReactFrames) should be minimal, otherwise it can happen that the AI won't start dodging till the shooter's weapon is empty.
::As a side note, there is a glitch in gunfire dodging. It is not a coding bug, but simple limitation of a "vector" type of movement. When AI starts gunfire dodge, it tries to get away from the source of danger (be it firingspread or projectile). And because vector movement works as a "desire" to go to some direction, it can happen AI will express a "desire" to go into wall. In such a case, character stops until the desire to move into a wall stops (in other words, until enemy stops shooting the AI character). When AI character is unarmed, she/he will try to switch between pathfinding movement (to go to enemy and attack him with melee) and vector projectile dodge movement, so it kind of looks like the AI still tries to dodge the gunfire. If weight of a gunfire dodge is set to be smaller than standard vector movement type weight, then AI even does not have to get stuck as it will run in zig-zag pattern towards the armed enemy.
::As a side note, there is a glitch in gunfire dodging. It is not a coding bug, but a limitation of the simple vector-based movement. When the AI starts its gunfire dodge, it tries to get away from the source of danger (be it a firing spread or projectile). And because vector-based movement works as a "desire" to go in some direction, it can happen that the AI will express a "desire" to go into a wall. In such a case, the character stops until the desire to move into a wall stops -- in other words, until the enemy stops shooting at the AI. When an AI character is unarmed, it will try to switch between pathfinding movement (go towards the enemy and attacking him with melee) and vector-based projectile dodging movement, so it kind of looks like the AI is still trying to dodge the gunfire. If the weight of gunfire dodging is set to be smaller than the standard vector-based movement weight, then the AI does not even have to get stuck, as it will run in a zigzag pattern towards the armed enemy.
::In case AI is armed with a loaded weapon, there is no point in AI running towards enemy. That means if the AI character starts dodging and meets a wall, this AI character gets "stuck" until enemy's gunfire stops. In case this character has set "ShootDodge" in [[ONCC]], it will at least fire back at the enemy shooter. But in case the character has set "RunAwayDodge", then it simply stands near the wall and stares and waits till enemy's gunfire ceases.
::If the AI is armed with a loaded weapon, there is no point in the AI running towards enemy. That means if the AI starts dodging and meets a wall, this AI gets "stuck" until the enemy's gunfire stops. If this character has "ShootDodge" set in their ONCC, it will at least fire back at the enemy shooter. But in case the character has "RunAwayDodge" set, then it simply stands near the wall and stares and waits till the enemy's gunfire ceases.


::From the text above it can be seen that gunfire dodge parameters should be set to make AI dodge but to not make dodge vector outweight the vector for moving towards the enemy.
::From this explanation, it can be seen that the gunfire dodge parameters should be set to make the AI dodge, but to not make the dodge vector outweigh the vector for moving towards the enemy.


:*AI's skills with weapons (in [[ONCC]]) can be used greatly to create sharpshooters or rookies who cannot hold a gun properly. For example by setting "ShootGroupError = 10.0" for w1_tap, we create a total amateur who's hand shakes all over the place when he fires Campbell equalizer.
:*An AI's skills with weapons (in ONCC) can be used to create anything from sharpshooters to rookies who cannot hold a gun properly. For example, by setting "ShootGroupError" to 10.0 for w1_tap, we create a total amateur whose hand shakes all over the place when he fires the Campbell Equalizer.


:*Unless really needed, do NOT alter [[ONCC]] prediction parameters. Bungie set them quite reasonably and if they are messed, AI character loses the ability of prediction.
:*Unless really necessary, do NOT alter the ONCC prediction parameters. Bungie set them quite reasonably, and if they are messed with, the AI loses accurate predictive abilities.


:*In [[ONWC]], Prediction speed is used for a calculation of AI's aim. The value should be exactly the same as the value of this weapon's projectile. Projectile's velocity is usually set in a emitter of a projectile particle ([[PAR3]]). That means Prediction speed and actual speed of a particle used as weapon's projectile may differ, the most significant case being w3_phr (plasma balls accelerate rapidly).
:*In ONWC, Prediction speed is used for a calculation of the AI's aim. This speed should be exactly the same as the speed of this weapon's projectile. A projectile's velocity is usually set in the emitter of the projectile particle (PAR3). The separate values means that the predicted speed and actual speed of a weapon's projectile may differ, the most significant case being w3_phr (plasma balls accelerate rapidly).
::If Prediction speed is set lower than the speed of a projectile is, AI will tend to shoot too much in front of the moving enemy since it will assume projectile is slower than it really is. On the other side, setting this value higher means AI will shoot more directly at the moving enemy (and probably miss) as the AI will assume projectiles are fast enough to hit the target.  
::If Prediction speed is set lower than the speed of a projectile, the AI will tend to shoot too far in front of an enemy moving left/right since it will assume the projectile is slower than it really is. On the other hand, setting this value higher means that the AI will shoot too directly at the moving enemy (probably missing), as the AI will think the projectiles are fast enough to hit the target.


:*Similar to Prediction speed, there are Ballistic projectile speed and Ballistic projectile gravity. When these two are set non-zero, AI assumes ballistic projectiles (grenades) and tries to shoot projectiles according to an ideal parabole (the solution with shorter fly time is always chosen). In order to make AI sucesfully hit enemy's pelvis, these two must again corespond with [[PAR3]] particles's speed and particles's gravity attraction, but they can be used for modding purposes as well. For example if projectiles's gravity attaction is 0.5 but in [[ONWC]] Ballistic projectile gravity is set as 0.3, AI will shoot projectiles at enemy's feet as it will assume that gravity attraction of the projectile is lower thus it does not have to aim so high in order to hit the pelvis (credits to [[user:Gumby|Gumby]]). Remember: for AI system, pelvis is a representation of a whole character.
:*Similar to Prediction speed, there are Ballistic projectile speed and Ballistic projectile gravity. When these two fields are set to non-zero values, the AI assumes that the projectiles are ballistic (e.g. grenades), and tries to shoot along a parabolic arc (the solution with shortest travel time is always chosen). In order to make AI successfully hit an enemy's pelvis, these values again must correspond with the particle's (PAR3) speed and gravity attraction, but they can be used for modding purposes as well. For example, if a projectile's gravity attraction is 0.5, but in the ONWC, the Ballistic projectile gravity is set as 0.3, the AI will shoot projectiles at the enemy's feet as it will assume that the gravity attraction of the projectile is lower and it does not have to aim so high in order to hit the pelvis (credit to [[User:Gumby|Gumby]]). Remember: for the AI system, the pelvis is a representation of a whole character.


:*Targeting origin vector ([[ONWC]]) can be utilized to make AI fire not directly at pelvis, but for example higher (negative "z" component), so AI can score headshots. So far such a change does not have any purpose as characters don't have damage multipliers for bodyparts. But maybe in future...or with Paradox's headshot mod / material dependent damage mod ideas (see [[XML:BINA/ONIE#Extra_damage_for_head_hits|HERE]]).
:*The targeting origin vector (ONWC) can be utilized to make the AI fire higher than the pelvis (with a negative "z" component), so the AI can score headshots. Currently, such a change does not have any purpose, as characters don't have separate damage coefficients for different body parts. But maybe in the future... or with Paradox's headshot mod... (see [[XML:BINA/ONIE#Extra_damage_for_head_hits|HERE]] for his material-dependent damage mod ideas).


:*One thing purposefully left out in main talk about weapons is that there is an option for AI chracters to make "startle" misses - when startled, AI fires at some random direction. Parameters for this behavior are in [[ONCC]] and [[ONWC]], but overall this feature is so subtle it does not need any special modding attention.
:*One thing purposely left out in our main discussion of weapons is that there is an option for AIs to perform "startle" misses -- when startled, the AI can fire in some random direction. The parameters for this behavior are in ONCC and ONWC, but overall this feature is so minor that it does not need any special modding attention.


:*Remember: in [[ONWC]], Minimal shooting distance is '''divided by 2'''. Reason is unknown, maybe some bug in a code.
:*Remember: in the ONWC, Minimum shooting distance is '''divided by 2'''. The reason is unknown (maybe some bug in the code).


:*Through modification of Minimal shooting distance in conjunction with BSL scripting, a modder can achieve pseudo-dynamic holster behavior. If enemy gets too close, AI start moving away, facing the enemy. Since simply backing away is almost never used by armed AI (it usually move to the side), it can be detected via BSL function '''chr_wait_animation''' and subsequent script makes AI character holster held weapon. To unholster, different animation check has to be used, for example a check for a taunt animation. In [[MELE]], modder can set up approppriate melee profile which makes AI character taunt only at safe distance.  
:*Through modification of Minimum shooting distance in conjunction with BSL scripting, a modder can achieve pseudo-intelligent holstering behavior. If an enemy gets too close, the AI will start backing away. Since this backing away motion is almost never used by an armed AI (it usually moves side-to-side), it can be watched for using the BSL function chr_wait_animation, and used as a trigger for scripting code to make the AI holster his weapon. To unholster, a different animation has to be watched for, such as a taunt animation. In [[MELE]], a modder can set up a melee profile which makes the AI taunt only at a safe distance.  
::Drawback of this modification is is that enemy ''will not fire the weapon at point blank range'' and also it limits Melee override in [[CMBT]] to be only None or IfPunched, otherwise instead of backing away, AI character goes directly into melee.
::A drawback of this modification is that the enemy ''will not fire his weapon at point blank range'', and also it limits the Melee override in [[CMBT]] to be only None or IfPunched; otherwise, instead of backing away, the AI goes directly into melee.