18,700
edits
(continuing rewrite) |
(continuing rewrite) |
||
Line 269: | Line 269: | ||
OK, we have positioning down; now for the actual behaviors that an AI can be set to execute within these ranges. There are fourteen possible combat behaviors (in | OK, we have positioning down; now for the actual behaviors that an AI can be set to execute within these ranges. There are fourteen possible combat behaviors (in parentheses are the XML strings): | ||
:*None (None): simply nothing. | :*None (None): simply nothing. | ||
:*Stare (Stare): the AI stands and stares; it does not even rotate to face the enemy. | :*Stare (Stare): the AI stands and stares; it does not even rotate to face the enemy. | ||
Line 311: | Line 311: | ||
==Extra combat behaviors== | ==Extra combat behaviors== | ||
Combat ranges and various AI combat | Combat ranges and various AI combat behaviors were discussed in the previous section. Even in terms of combat ranges, there are still other aspects of combat to cover: picking up weapons from the ground, melee overrides of weapons, behaviors if the character is unarmed, and, of course, firing weapons or using hand-to-hand combat. | ||
'''"Melee override" ([[CMBT]] profile)''' | '''"Melee override" ([[CMBT]] profile)''': Similar to the BSL command [[chr_dontaim]], this behavior urges the AI to use its hand-to-hand animation variant (see [[TRAM]]) and to switch from some other behavior to melee combat. This field was probably added to deal with conflicts when multiple AI behaviors are applied on a character. The possible values are (XML strings in parentheses): | ||
:*None (None) | :*None (None): no override is used. | ||
:*If Punched (IfPunched) | :*If Punched (IfPunched): melee override is applied when the AI is melee-attacked by its enemy. Does not work when the character is invincible. | ||
:*Cancelled | :*Cancelled: unfinished feature; does nothing. There remains only the question of what it was meant to be.... | ||
:*Short (ShortRange) | :*Short (ShortRange): Melee override is applied when the enemy is within Short range. | ||
:*Medium (MediumRange) | :*Medium (MediumRange): Melee override is applied when the enemy is within Medium or Short range. | ||
:*Always | :*Always Melee (AlwaysMelee): Melee override is applied within all combat ranges. | ||
:This override can affect: | :This override can affect: | ||
:*Alarm running | :*Alarm running: It is actually required if an alarm run is called via the no-gun alarm run behavior, otherwise glitches will appear. | ||
:*Retreating behavior - When | :*Retreating behavior - When the no-gun behavior is set as "Retreat", an unarmed AI will try to run away from its enemy. However, if enemy meets the Melee override parameter (for example getting into the Short range while the melee override is set to ShortRange), then this AI stops running away and starts attacking the enemy. | ||
:*Weapon firing | :*Weapon firing: If the distance between the AI and its enemy is smaller than the minimal shooting distance, the AI tries to backpedal away from its enemy till the distance between characters is greater than the minimal shooting distance. However, this backpedal behavior can be overridden by the melee override if all conditions are met; the AI then starts using melee (even with a loaded weapon in hand) for at least 10 seconds (hardcoded timer). After ten seconds, the AI tries to resume its previous behavior. If the enemy is still too close, the melee override is immediately applied again. | ||
:*Weapon pickup | :*Weapon pickup: if the AI is trying to pick up a weapon and an enemy crosses the range specified in MeleeOverride, then the weapon pickup behavior is overridden by melee. | ||
:*Maybe some other aspects of AI behavior? | :*Maybe some other aspects of AI behavior? | ||
''' | '''No-gun behavior ([[CMBT]] profile)''': This parameter tells the AI what kind of action it should take if it is unarmed or has an empty weapon and no spare clips. Possibilities are (XML strings in parentheses): | ||
:*Melee (Melee) | :*Melee (Melee): The AI attacks the enemy with hand-to-hand combat. | ||
:*Retreat (Retreat) | :*Retreat (Retreat): The AI runs away from its enemy (a bit glitchy, but works). | ||
:*Run For Alarm (RunForAlarm) | :*Run For Alarm (RunForAlarm): see section [[#Alarm behavior|Alarm behavior]]. Reminder: this alarm-running behavior requires the melee override to be set in ShortRange, MediumRange or AlwaysMelee, otherwise the alarm behavior gets glitched and the AI gets stuck. If no alarm console is found within the alarm search distance, the AI resorts to melee. | ||
[[File:GoForGun.JPG|thumb|right|alt=Picture showing AI moving to a weapon.|AI | [[File:GoForGun.JPG|thumb|right|alt=Picture showing AI moving to a weapon.|AI moving towards a weapon.]] | ||
'''Weapon pickup behavior ([[ONCC]] file)''' | '''Weapon pickup behavior ([[ONCC]] file)''': When in combat mode, an unarmed AI can be told to move to a loaded weapon and pick it up or to swap a held, empty gun for a loaded gun which is lying on the floor. Overall, AIs can only register pickup-able weapons up to a distance of 60 world units (hardcoded). In the ONCC file, these parameters can be set to alter the gun pickup behavior (XML tags in parentheses): | ||
:*Chance for pickup (GoForGunChance) | :*Chance for pickup (GoForGunChance): percent chance of AI deciding to go and pick up a weapon. It seems that the weapon closest to the AI character is always chosen to be picked up. | ||
:*Running pickup (RunPickupChance) | :*Running pickup (RunPickupChance): percent chance of AI picking up the weapon by performing an evasion (melee dodge) move. | ||
'''Getting up after being knocked down ( | '''Getting up after being knocked down (ONCC file)''': If an AI is knocked to the ground, it stays on the ground for a while (a simulation of being stunned), then gets up. In the ONCC file there are two parameters regarding getting up (XML tags in parentheses): | ||
:*Knockdown minimal number of frames (DazedMinFrames) | :*Knockdown minimal number of frames (DazedMinFrames): minimal number of frames that AI stays on the ground. | ||
:*Knockdown maximal number of frames (DazedmaxFrames) | :*Knockdown maximal number of frames (DazedmaxFrames): maximum number of frames that AI stays on the ground. | ||
:If | :If a knocked-down AI gets hit by melee, it gets up immediately after the hit. Being hit by weapons does not make AI character instantly get up. Standard get-ups are simple ones (the same result as if the knocked-down player hits a directional key). If the AI is in melee combat mode, its [[MELE]] profile has get-up attacks listed, and the enemy is within the required range, there is a chance that this AI will use a get-up attack instead of a simple get-up animation. | ||
'''Making sure enemy is dead ( | '''Making sure enemy is dead (ONCC file)''': Yes, even this is a part of Oni's combat AI. | ||
:When enemy is defeated in hand to hand fighting, AI | :When the enemy is defeated in hand-to-hand fighting, the AI stands over them for a while to decide if the enemy is dead. During this interval, the AI can utter a short victory speech if the corresponding sound slot in its ONCC is filled and the percent chance roll is successful. Also during the "check body" time interval, the AI can perform a taunt animation if that roll is successful. Here are listed all the related fields from the ONCC file (XML tags in parentheses): | ||
:*Investigate body (InvestigateBodyDelay) | :*Investigate body (InvestigateBodyDelay): Time period for which AI stands over its defeated enemy and stares at him/her. | ||
:*Dead taunt chance (DeadTauntChance) | :*Dead taunt chance (DeadTauntChance): Percent chance of performing a taunt animation. | ||
:*Check body sound probability (CheckBodyProbability) | :*Check body sound probability (CheckBodyProbability): Percent chance of playing a victory speech. | ||
:*Check body sound (CheckBodySound) | :*Check body sound (CheckBodySound): A link to an Oni ambient sound file ([[OBD:OSBD/OSAm|OSAm]]). | ||
:If the enemy is defeated by weapon, then AI | :If the enemy is defeated by weapon, then the AI keeps shooting this dead enemy for some extra time to make sure the enemy is dead, then comes close to investigate the body. No taunts, no win phrases. The parameters of this behavior are: | ||
:*Dead make sure (DeadMakeSureDelay) | :*Dead make sure (DeadMakeSureDelay): Time period for which the AI keeps shooting the dead enemy. | ||
:*Investigate body (InvestigateBodyDelay) | :*Investigate body (InvestigateBodyDelay): Same as the one listed above for melee. | ||
Modding hints - behaviors | Modding hints - the behaviors listed in this section can be combined to achieve quite impressive results. | ||
:* | :*Unfortunately, Oni does not provide any AI settings that deal with intelligent holstering and unholstering of weapons in their possession. Thus, melee overrides are the only way to make an armed AI somehow defend itself when the enemy gets too close to use its weapon. | ||
::Nevertheless, | ::Nevertheless, BSL does provide a function to make a character holster or unholster a weapon: [[chr_forceholster]]. In order to make a character holster a held weapon, this character has to be using a pistol or rifle animation variant (see [[TRAM]]). Since AI can use "walk_noaim" and "run_noaim" movement modes (which disable weapon variants, i.e., aiming with weapons), the weapon variant should be explicitly forced on via the BSL function [[chr_dontaim]]. Unholstering is easier: the character simply has to be be executing some aiming overlay-compatible animation at the moment when chr_forceholster is executed. That means standing, running, crouching, walking, and jumping are OK -- the function will succeed -- but attack animations or animations of getting hit are not OK and the function will fail. | ||
::*IMPORTANT NOTE: The AI | ::*IMPORTANT NOTE: The AI must be "active" all the time in order to perform BSL animation checks ([[chr_wait_animation]]/[[chr_wait_animtype|animtype]]/[[chr_wait_animstate|animstate]] checks). Remember that Oni was developed mostly in the '90s, so various tricks were used to save memory and enhance performance. One technique was to make unseen characters (behind a wall, closed doors, etc.) go into an "inactive" mode, which means they are only stored in RAM as a structure, but no physics, collision checks, or drawing functions are performed on them in order to save system resources (and yes, that means inactive characters can [https://www.youtube.com/watch?v=GC4HLDekxQI walk in mid-air and pass through walls]). On the other hand, when a character is active, it is fully operational, with physics working, collisions being checked, and character being ready in graphics memory to be drawn any time. To make sure a character stays active requires either applying [[chr_lock_active]] to each AI, or (since computers have a lot more memory these days) simply setting [[chr_all_active]] to 1 to force all characters active. | ||
::Here is a simple example of a | ::Here is a simple example of a holster behavior scripted in BSL. A character is given a gun, then the weapon is holstered. When this AI notices an enemy and plays its startle animation, then an unholster is called for. [http://www.youtube.com/watch?v=2WNMh8u5wBI This YouTube video] shows the script in action. | ||
#Setup of AI - gets spawned, forced to be always active, weapon gets holstered. | #Setup of AI - gets spawned, forced to be always active, weapon gets holstered. | ||
Line 388: | Line 388: | ||
:* | :*A melee override can be used together with the "Go For Gun" behavior and a properly-set Short combat range to create AIs who go for a gun any time they have a chance, yet they are not allowing an enemy to land free hits in the process (if the enemy gets too close, the Short range melee override kicks in). | ||
:* | :*The no-gun behavior "Retreat" works in a rather simple manner: if unarmed, an AI is given a desire to run as far from the enemy as possible. This behavior can look a bit awkward, but is useful for making more life-like civilians. Combined with Melee override at "Short range" or "If punched", and a bit of BSL scripting to deliberately switch between "combatant" and "non-combatant", a modder can achieve impressive results without only a light load on the game engine. [http://www.youtube.com/watch?v=BTGQTAoU_1E See this YouTube video.] | ||
:*Setting short | :*Setting short get-up times is a good way to make an AI-driven character a formidable opponent in hand-to-hand combat. However, too-short get-up times can introduce problems. It is a good idea to experiment with get-up parameters till the character feels "natural". | ||
:* Don't | :*Don't over-extend the "Check body" and "Dead make sure" timers. It looks silly, and on top of that it makes AIs easy targets for a rear throw. | ||
Line 416: | Line 416: | ||
:AI parameters regarding gunfire dodging are set in [[ONCC]] (xml tags in | :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 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 timescale (DodgeTimeScale) - how long should the AI character's gunfire dodge reaction last. | ||
Line 447: | Line 447: | ||
:For each one of these weapons, there are in ONCC defined these parameters (xml tag in | :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. | :*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. | :*Best aiming angle (BestAimingAngle) - In radians, but question is whether it really affects aiming. | ||
Line 460: | Line 460: | ||
'''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. | '''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 | :[[ONCC]] parameters for targeting and prediction (xml tags in parentheses): | ||
:*Predict amount (PredictAmount)- Some sort of multiplier for prediction mechanics. | :*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 position delay (PredictPositionDelay) - In frames, delay before prediction is applied, so AI characters always uses a bit outdated prediction result. | ||
Line 467: | Line 467: | ||
:*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. | :*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 | :[[ONWC]] parameters for targeting and prediction (xml tags in parentheses): | ||
:*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). | :*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). | ||
:*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. | :*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. | ||
Line 483: | Line 483: | ||
'''Miscellaneous [[ONWC]] AI setup''' - there are a few more parameters in ONWC which affect AI behavior with the weapon. They are (xml tags in | '''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): | ||
:*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. | :*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. | ||
::'''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, 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. | ||
Line 490: | Line 490: | ||
:*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 | :*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): | ||
:**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 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. | ||
:**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 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. | ||
Line 538: | Line 538: | ||
Fistfighting AI mode is handled via [[MELE]] profiles. MELE profile is assigned to the spawnable character in its [[CHAR]] profile. When in melee mode, AI character uses vector type of movement. Unless specified otherwise, AI character is made to run towards its enemy. | Fistfighting AI mode is handled via [[MELE]] profiles. MELE profile is assigned to the spawnable character in its [[CHAR]] profile. When in melee mode, AI character uses vector type of movement. Unless specified otherwise, AI character is made to run towards its enemy. | ||
:[[MELE]] profile always contains these parameters (xml tags in | :[[MELE]] profile always contains these parameters (xml tags in parentheses): | ||
:*Character class (CharacterClass) - Link to an [[ONCC]] class. Level of importance of this parameter not known, but maybe it is neccessary in order to allow for performance of some attack moves (engine checks referenced [[ONCC]] class and its [[TRAC]]). | :*Character class (CharacterClass) - Link to an [[ONCC]] class. Level of importance of this parameter not known, but maybe it is neccessary in order to allow for performance of some attack moves (engine checks referenced [[ONCC]] class and its [[TRAC]]). | ||
:*Notice (Notice) - percentual chance that AI will register incoming attack. In retail profiles it is always set 100. | :*Notice (Notice) - percentual chance that AI will register incoming attack. In retail profiles it is always set 100. |