271
edits
m (Filling in cross-links to sections) |
(Altered Alarm and added Combat part 1) |
||
Line 197: | Line 197: | ||
In order to make A.I. look more humane, it is a good idea to grant it ability to interact with the world the same way player does. In Oni that means for example to give A.I. option to use consoles. | In order to make A.I. look more humane, it is a good idea to grant it ability to interact with the world the same way player does. In Oni that means for example to give A.I. option to use consoles. | ||
::[http://www.youtube.com/watch?v=jnsGuZxqW9I Watch this YouTube video.] | |||
:BSL scripting provides a command to make A.I. go and use a console - '''ai2_doalarm''' ''ai_name/index'' '''number of console'''. This way A.I. can be told to use any console. But there is a method to make A.I. character use a console completely on it own. | :BSL scripting provides a command to make A.I. go and use a console - '''ai2_doalarm''' ''ai_name/index'' '''number of console'''. This way A.I. can be told to use any console. But there is a method to make A.I. character use a console completely on it own. | ||
:In order to utilize those mechanics, there is a need for a console which has ALARM CONSOLE flag set (see [[OBD:BINA/OBJC/CONS]]). In XML this flag has a string '''IsAlarm'''. Such a console then can be used by A.I. characters without scripting. | :In order to utilize those mechanics, there is a need for a console which has ALARM CONSOLE flag set (see [[OBD:BINA/OBJC/CONS]]). In XML this flag has a string '''IsAlarm'''. Such a console then can be used by A.I. characters without scripting. | ||
Line 207: | Line 208: | ||
:*Fight timer - in xml called <FightTimer>, duh. Numer of frames for which A.I. character should fight with the enemy before it attempts to resume its run for alarm. | :*Fight timer - in xml called <FightTimer>, duh. Numer of frames for which A.I. character should fight with the enemy before it attempts to resume its run for alarm. | ||
:Logic for alarm running is set, now how to trip it? There are three ways how to make character run and use a console without BSL. the console must have ALARM CONSOLE flag set and ust lie within Search distance perimeter: | |||
:*in [[CMBT]]: If no gun behavior set to "Run for Alarm". In xml it is RunForAlarm string inside <NoGunBehavior>. By setting this parameter, A.I. character will attempt to run and use a console when it does not have a loaded weapon or spare clips in inventory (then it reload and continues shooting). If there is no alarm console nearby, A.I. will switch to Melee. | |||
:*in [[CMBT]]: Behaviors (Long, Medium, Short, MediumRetreat, LongRetreat) can be set to be "Run for Alarm". DO NOT confuse with "Run for alarm If no gun" behavior! This behavior is never used in retail Oni, the reason probably being the fact if there is no useable console within Alarm search distance radius, then A.I. character simply stands and stares even when enemy is visible with central vision field. | |||
:*In [[CHAR]]: Lost behavior "FindAlarm" - When A.I. character makes definite contact with enemy and then enemy manages to escape, A.I. executes "Lost" behavior (see "Pursuit of enemy" section). This behavior is typically set as ReturnToJob, but FindAlarm works well with no known issues. If alarm console is not found within search distance, A.I. returns to its job. | |||
:A couple of notes regarding A.I. character: | |||
:*in order to register enemy and attack her/him pre-emptively, A.I. character must have "HostileThreatDefinite" timer set in ONCC file to some value over 60 (Oni runs 60 frames per second). | |||
:*"If no gun" behavior "Run for Alarm" can get glitched. "Alarm enemy attack distance" is set to some value, let's say 100. Now when A.I. character runs for alarm and enemy attacks it, then if in this [[CMBT]] profile there is not set melee override for range at least 100 (via melee override or by heving "Melee" set in corresponding combat ranges, see section [[Tricks behind Oni A.I.#Combat behavior part 1 : "Hokey religions and ancient weapons..."|Combat behavior]]), chances are A.I. will get stuck in a loop trying to reach both enemy and console at the same time. | |||
:*Similar issue can happen with combat behavior Run For Alarm as well, but this time problems rise when this combat behavior Run For Alarm is set as Short range behavior. | |||
:A couple of notes regarding target console: | :A couple of notes regarding target console: | ||
Line 212: | Line 224: | ||
:*Console must be directly accessible. Oni A.I. cannot use consoles in order to open path to get to the point of interest (target console in this case). Target console must be directly accessible. Still, it can be directly accessible across the whole level ^_^. | :*Console must be directly accessible. Oni A.I. cannot use consoles in order to open path to get to the point of interest (target console in this case). Target console must be directly accessible. Still, it can be directly accessible across the whole level ^_^. | ||
:As already mentioned, Alarm behavior can be tripped by BSL command ai2_doalarm. In that case alarm behavior is executed but this time console is set by command instead of being looked for via Search distance. Also, by ai2_doalarm A.I. can be made to use any console, not only those with ALARM CONSOLE flag. | :As already mentioned, Alarm behavior can be tripped by BSL command ai2_doalarm. In that case alarm behavior is executed but this time console is set by command instead of being looked for via Search distance. Also, by ai2_doalarm A.I. can be made to use any console, not only those with ALARM CONSOLE flag. | ||
Line 223: | Line 230: | ||
Modding hints: ability of A.I. to use consoles is an excellent tool for increasing a challenge. | Modding hints: ability of A.I. to use consoles is an excellent tool for increasing a challenge. | ||
:* | :*Beware of setting Run For Alarm combat behavior as close range one. Such a setup causes glitches. | ||
:*On the other side, combat behavior Run For Alarm can be deliberately used to add element of surprise to fights. In [[CMBT]] profile, set Run For Alarm as either Medium or MediumRetreat behavoir, then shorten interval between <MediumRange> and <ShortRange> values (for example set "Medium Range" to 60 and "Short Range" to 59). Thanks to this setup, A.I. can attempt to find an alarm console while still being capable of fighting even when no alarm is nearby. | |||
:*In [[BSL]] a modder can easily distinguish if console was used by player or A.I. thanks to '''chr_is_player('''ai_name''')''' function. All what is required is a BSL function being triggered when console is used. Here is example where console triggers a function called '''console1_used''': | :*In [[BSL]] a modder can easily distinguish if console was used by player or A.I. thanks to '''chr_is_player('''ai_name''')''' function. All what is required is a BSL function being triggered when console is used. Here is example where console triggers a function called '''console1_used''': | ||
func void console1_used(string ai_name) | func void console1_used(string ai_name) | ||
Line 236: | Line 244: | ||
} | } | ||
} | } | ||
:*Other way of using alarm mechanics is to create a feeling of cooperation - player has to achieve something and in order to do so, an A.I. driven sidekick who goes after needed console and uses it is required. | |||
:*In extreme case, A.I. character can be even made to though the level on it own, moving from one console to another. That can be used to create chasing levels - A.I. character has to activate a certain number of consoles while player is required to stop this A.I. character from doing so. Thanks to Alarm behavior the task of tripping consoles can be fully completed by A.I., no scripting needed. such a setup is on the one side prone to possible A.I. glitches, but on the other side can add element of randomness and increase replayability. | |||
==Combat behavior part 1 : "Hokey religions and ancient weapons..."== | |||
[[File:combatRanges.PNG|thumb|right|alt=Example of combat ranges.|Combat ranges of an A.I. character.]] | |||
Of course an action game like Oni is not complete without guns blazing and fists flying through the air. But combat in real life is usually very fickle and everything has to be considered. How can Oni A.I. possibly deal with such a complex task? | |||
:Oni A.I. character has to have definite awareness of the enemy in order to actively attack him. Alert level of the A.I. character when in combat mode is Combat (duh). Definite awareness can be achieved by these ways: | |||
:*Enemy was seen by this A.I. character's central vision field. | |||
:*A.I. character is made to attack the enemy by [[BSL]] function '''ai2_attack'''. | |||
:*A.I. character was hurt by the enemy, be it melee or gun damage. | |||
Once combat mode is entered, then as long as HostileThreatDefinite timer for this enemy does not reach zero, A.I. character will always know exact location of this enemy and will attempt to attack it. The moment HostileThreatDefinite timer is depleted, A.I. character loses the privilege of knowing exact location, awareness decerases from definite to strong and A.I. character either switches from combat mode with this enemy to pursuit mode with this enemy (see section [[Tricks behind Oni A.I.#Pursuit of enemy alias "I will find you..."|Pursuit of enemy]]) or, in case of other enemy being present in central vision field, picks this new enemy as a target to attack and keeps old enemy in strong (and later weak and later forgotten) awareness. | |||
:Since generally method of combat depends on distance between participants, some sort of spacing is needed. Oni uses system of three ranges around A.I., called combat ranges. See picture on right. Perimeters of these ranges can be set in [[CMBT]] profile. | |||
:These ranges work as "triggers" to make the A.I. character execute various behaviors, based on enemy's position. Moreover, Oni can distinguish between states when enemy entered specified range or exited specified range. So all range possibilities in Oni which can be assigned some combat behavior are: | |||
:*Short - enemy is closest to the A.I. character | |||
:*Medium - enemy is approaching the A.I. character and crossed from Long Range into Medium Range. | |||
:*Long - enemy is approaching the A.I. character and starts from the Long Range. | |||
:*Medium Retreat - enemy is retreating from Short Range into Medium Range. | |||
:*Long Retreat - enemy is retreating from Medium Range into Short Range. | |||
:Well of course nothing is perfect and in Oni there is a bit of an issue with proper switching between combat ranges, so Long and Medium ranges are used only once at the beginning of enemy approach. Only Short, Medium Retreat and Long Retreat ranges are used on regular basis in a combat. Even when enemy runs into Long Retreat and goes back to to medium range, engine does not switch A.I. behavior range to Medium, but (contrary to its name) to Medium Retreat. | |||
OK, we have positioning, now for actual behaviors A.I. character can be set to execute within these ranges. There are fourteen possible combat behaviors (in brackets are xml strings): | |||
:*None (None) - simply nothing | |||
:*Stare (Stare) - A.I. character stands and stares, does not even rotate to face enemy | |||
:*Hold and fire (HoldAndFire) - A.I. character stands still and fires a weapon. If this character does not have a weapon, then he switches to melee. | |||
:*Firing charge (FiringCharge) - A.I. character runs towards the enemy and fires a weapon. If this character does not have a weapon, then he switches to melee. | |||
:*Melee (Melee) - A.I. character always uses melee, even when he holds loaded weapon. | |||
:*Barabbas shoot (BarabasShoot) - A.I. character stands still and fires a weapon with hardcoded three seconds pause between shots. If this character does not have a weapon, then he switches to melee. If this character meets certain conditions, she/he can start health regeneration. More detailed info about regeneration mechanics [[Barabus's regeneration| can be read HERE.]] | |||
:*Barabbas advance (BarabasAdvance) - A.I. character runs towards the enemy and fires a weapon with '''secondary fire mode''' (as if player pressed right button). If this character does not have a weapon, then he switches to melee. If this character meets certain conditions, she/he can start health regeneration. More detailed info about regeneration mechanics [[Barabus's regeneration| can be read HERE.]] | |||
:*Barabbas melee (BarabasMelee) - A.I. character uses melee, even with loaded weapon in hand. If this character meets certain conditions, she/he can start health regeneration. More detailed info about regeneration mechanics [[Barabus's regeneration| can be read HERE.]] | |||
:*Superninja fireball (SuperNinjaFireball) - Mukade's long range behavior. With this behavior A.I. cannot shoot weapons and cannot use melee, simply runs towards the enemy. However, if weapon is held, character can use melee (probably something from weapon melee override). A.I. character is occasionally teleported into the back of the enemy (AnimType 222 - Teleport In) if distance to enemy is greater than 100. It seems like it should work regularly once distance to enemy exceeds 100, but in reality something screws this teleport mechanics ^_^. Anyway, to add more to this behavior A.I. executes two special TRAM animations: | |||
:**AnimType 224 - Ninja Fireball, after the use there is 20 seconds pause before then this [[TRAM]] is used again. | |||
:**AnimType 225 - Ninja Invisible, grants 10 second cloak, after the use there is 20 seconds pause before this TRAM is used again. | |||
::'''IMPORTANT''' There is an annoying problem with this behavior. When it is called, it checks character's position height-wise from the origin of the game world (coordinates 0,0,0) and if the height is below 550, this character is automatically moved to height 550 (which in almost all cases means death by falling). | |||
:*Superninja advance (SuperNinjaAdvance) - Mukade's medium range behavior. With this behavior A.I. cannot shoot weapons and cannot use melee, simply runs towards the enemy. However, if weapon is held, character can use melee (probably something from weapon melee override). This behavior gives ability to use AnimType 225 - Ninja Invisible which grants 10 seconds invisibility. In order to be able to use this ability, A.I. has to be at least 50 (or 40?) units far from its enemy. Cooldown for this special technique is 20 seconds. Again, annoying '''over 550 height check''' is present. | |||
:*Superninja melee (SuperNinjaMelee) - Mukade's short range behavior. With this behavior A.I. cannot shoot weapons but can use melee. This behavior gives ability to use AnimType 225 - Ninja Invisible which grants 10 seconds invisibility. In order to be able to use this ability, A.I. has to be at least 50 (or 40?) units far from its enemy. Cooldown for this special technique is 20 seconds. This behavior also grants ability to teleport away from enemy to certain distance (around 100 units) if certain conditions are met: | |||
:**About 35 points of damage dealt to this character in a short time (exact amount of damage and exact timing not known). | |||
:**This character get thrown by any throw. | |||
::Again, annoying '''over 550 height check''' is present. | |||
:*Run for alarm (RunForAlarm) - see section [[Tricks behind Oni A.I.#Alarm behavior - "She's everywhere!"|Alarm behavior]]. | |||
:*Mutant Muro melee (MutantMuroMelee) - A.I. character is only allowed to melee, will not fire weapons. This behavior casts chenille (overpower effect) on the user. Of course in order to see visible effect character has to have needed requirements set in [[ONCC]]. This chenille mode does not grant damage overpower effect, melee attacks deal their usual damage. If ONCC is set correctly, this chenille mode can grant super shield. | |||
::Chenille mode lasts forever if it is not terminated either via BSL or by A.I. character performing a [[TRAM]] which has a DisableShield flag. After 10 seconds interval, chenille is turned back on. Also when about 35 points of damage or a throw are dealt to this A.I. character, the A.I. character automatically performs backwards evasion move. Also, chenille effect is turned off if this A.I. character starts using some other combat behavior (due to change of ranges). | |||
:*Mutant Muro thunderbolt (MuroThunderbolt) - A.I. character goes into AnimState 69 (Thunderbolt) and loops special TRAM animation of AnimType 231 (Muro_Thunderbolt) and AnimState 69 (Thunderbolt). That lasts for 10 seconds. Then A.I. makes 5 seconds pause during which it runs towards enemy. If after those 5 seconds A.I. character is still executing Mutant Muro thunderbolt behavior, A.I. character starts again looping the TRAM animation which has AnimType 231 and AnimState 69. | |||
::This behavior's special (looping TRAM animation) lasts even when enemy enters some other combat range with the exception of Short range. If enemy enters Short range while the looped Animation is running, the loop is forced to stop and A.I. character starts using Short range behavior. | |||
:*In | Modding hints: Combat behaviors can have severe impact on A.I. performance in a fight but can as well hinder the A.I. | ||
:*Remember: due to a glitch, crucial behaviors for combat are Short, MediumRetreat and LongRetreat. Long And Medium are used only at the beginning of an ecounter. | |||
:*In general, use common sense. There is little use in setting Firing Charge as Short range behavior. | |||
:*Barabbas Shoot and Barabbas Melee behaviors have access to heal ability which can be a great asset for introducing mutants or stronger enemy units. However, remember that Barabbas Shoot limits rate of fire to one shot per three seconds. | |||
:*Barabbas Advance is the only behavior which allows A.I. to fire a weapon with secondary fire mode. However the behavior is quite glitched (A.I. character often looks away and fires stray shots). Still, with proper gun and proper setup it can be useable for boss fights. | |||
:*Superninja's behaviors sound excellent for cunning enemy units, however annoying check for character's minimal allowed height from world origin and subsequent forced repositions severely impact these behaviors' usefulness. Despite the height limit, with deliberately designed level which is uplifted enough on purpose the behavior will not cause random A.I. character repositioning. Then it can be used to its fullest. | |||
::One other important thing about these behaviors - if A.I. character does not have required [[TRAM]]s in her/his [[TRAC]], the A.I. character can get stuck if she/he uses these behaviors. | |||
:*If there is no console with ALARM CONOSLE flag within Alarm sarch distance, then behavior "Run For Alarm" will make A.I. enemy just stand and stare. Set this behavior with caution and consider using a workaround where medium and short combat ranges have very close diameters with Run For Alarm being MediumRetreat behavior, so Run For Alarm behavior is executed only for a brief amount of time as A.I. practically immediately switches to LongRetreat. However even one frame is enough because if alarm is found, A.I. character is requested to perform alarm run which can override combat (see section [[Tricks behind Oni A.I.#Alarm behavior - "She's everywhere!"|Alarm behavior]] for more info). | |||
:*MutantMuro melee can be used to create tricky foes which have to be eliminated from distance because if player comes up close, these enemies will turn on their (super)shield and won't put it away (they don't have any TRAM with DisableShield flag). That means player has to put some distance between him and these A.I. characters in order to make them disable the shield. | |||
:*MutantMuro thunderbolt should NEVER be assigned to Short range behavior as that will negatively affect its special attack. Set it as LongRetreat or MediumRetreat. This kind of behavior (with proper [[TRAM]]s) can be used to create foes who will start with special long range attack if player tries to keep a distance. This ranged attack does not have to be the same as Muro's tractor thunderbolt. For quick example, A.I. character can be made to fire a sort of aggressive plasma beam. | |||
==Combat behavior : " | ==Combat behavior part 2 : "Guns or not, my fists are hot."== |
edits