Jump to content

AI: Difference between revisions

1,340 bytes added ,  20 September 2011
(Another section about combat behavior)
Line 318: Line 318:
'''"Melee override" ([[CMBT]] profile)''' - similar to [[BSL]] command '''chr_dontaim''', this behavior bids the A.I. character to use hand to hand animation varient (see [[TRAM]]) and to switch from whatsoever other behavior to melee combat. This field was probably added to deal with conflicts when multiple A.I. behaviors are applied on character. Possible values are (xml strings in brackets):
'''"Melee override" ([[CMBT]] profile)''' - similar to [[BSL]] command '''chr_dontaim''', this behavior bids the A.I. character to use hand to hand animation varient (see [[TRAM]]) and to switch from whatsoever other behavior to melee combat. This field was probably added to deal with conflicts when multiple A.I. behaviors are applied on character. Possible values are (xml strings in brackets):
:*None (None) - no override is used.
:*None (None) - no override is used.
:*If Punched (IfPunched) - melee override applied when A.I. character is melee attacked by its enemy.
:*If Punched (IfPunched) - melee override applied when A.I. character is melee attacked by its enemy. Does not work when the  character is invincible (cheat).
:*Cancelled - unfinished stuff, does nothing. Remains only the question what it was meant to be...
:*Cancelled - unfinished stuff, does nothing. Remains only the question what it was meant to be...
:*Short (ShortRange) - Melee override is applied when enemy is within Short range.
:*Short (ShortRange) - Melee override is applied when enemy is within Short range.
Line 368: Line 368:


Modding hints - behaviors enlisted in this section can be combined to achieve quite impressive results.
Modding hints - behaviors enlisted in this section can be combined to achieve quite impressive results.
:*Unfortuantely, Oni does not provide (code-wise) any A.I. behavior which deals with dynamic holstering and unholstering of possessed weapons, so melee overrides are the only way how make armed A.I. character somehow defend itself when enemy gets too close. Nevertheless, [[BSL]] provides function to make character holster or unholster a weapon - '''chr_forceholster'''. In order to make a character holster the held weapon, this character has to be using pistol or rifle animation variant (see [[TRAM]]). Since A.I. characters can use walk_noaim and run_noaim movmement modes (which disable weapon variant i.e. aiming with weapon), the weapon variant should be explicitly coerced via BSL function '''chr_dontaim'''. Unholster is easier, character just must be playing some overlay-comaptible animation at the moment when chr_forceholster is executed. That mean standing/running/crouching/walking/jumping is OK and function will succeed, but attack animations or animations of getting hit are not OK and function will fail.
:*Unfortuantely, Oni does not provide (code-wise) any A.I. routines to deal with dynamic holstering and unholstering of possessed weapons. Thus, melee overrides are the only way how make armed A.I. character somehow defend itself when enemy gets too close.  
::Nevertheless, [[BSL]] provides function to make character holster or unholster a weapon - '''chr_forceholster'''. In order to make a character holster the held weapon, this character has to be using pistol or rifle animation variant (see [[TRAM]]). Since A.I. characters can use walk_noaim and run_noaim movmement modes (which disable weapon variant i.e. aiming with weapon), the weapon variant should be explicitly coerced via BSL function '''chr_dontaim'''. Unholster is easier, simply character has to be be executign some overlay-comaptible animation at the moment when chr_forceholster is executed. That means standing/running/crouching/walking/jumping is OK and function will succeed, but attack animations or animations of getting hit are not OK and function will fail.
::*IMPORTANT NOTE: The A.I. character must be "active" all the time in order to perform BSL animation checks ('''chr_wait_'''''animation/animtype/animstate'' checks). Remember that Oni was made back in years 2000/2001, so various tricks were used to save memory and enhance performance. One of these feints is making invisible characters (behind wall, behind closed doors etc) go into INACTIVE mode, which means they are only stored in a RAM memory as a structure, but no physics, no checks for collisions and no drawing functions are applied on them in order to save system resources (BTW yes, that means inactive characters can walk in air and pass through walls). On the contrary when character is ACTIVE, it is fully operational, physics working, collisions being checked and character being ready in graphics memory to be drawn anytime. To make sure character stays active means either applying individually "'''chr_lock_active''' ''ai_name''", or (since now is year 2011 ^_^) simply applying "'''chr_all_active=1'''" to make all characters be ready to be drawn anytime.
::*IMPORTANT NOTE: The A.I. character must be "active" all the time in order to perform BSL animation checks ('''chr_wait_'''''animation/animtype/animstate'' checks). Remember that Oni was made back in years 2000/2001, so various tricks were used to save memory and enhance performance. One of these feints is making invisible characters (behind wall, behind closed doors etc) go into INACTIVE mode, which means they are only stored in a RAM memory as a structure, but no physics, no checks for collisions and no drawing functions are applied on them in order to save system resources (BTW yes, that means inactive characters can walk in air and pass through walls). On the contrary when character is ACTIVE, it is fully operational, physics working, collisions being checked and character being ready in graphics memory to be drawn anytime. To make sure character stays active means either applying individually "'''chr_lock_active''' ''ai_name''", or (since now is year 2011 ^_^) simply applying "'''chr_all_active=1'''" to make all characters be ready to be drawn anytime.
::Here is a simple example of a BSL scripted holster behavior. Character is given a gun, then weapon is holstered. When this A.I. character notices enemy and plays startle animation, then unholster is called. [http://www.youtube.com/watch?v=2WNMh8u5wBI THIS YouTube video] shows the script in action.
::Here is a simple example of a BSL scripted holster behavior. Character is given a gun, then weapon is holstered. When this A.I. character notices enemy and plays startle animation, then unholster is called. [http://www.youtube.com/watch?v=2WNMh8u5wBI THIS YouTube video] shows the script in action.
Line 388: Line 389:
   chr_forceholster A_t48 1
   chr_forceholster A_t48 1


:*
 
 
:*Melee override can be used together with "Go For Gun" behavior and properly sized Short combat range to create A.I. characters who jump the gun each time they have a chance yet they are not allowing enemy to land free hits in the process (If enemy gets too close, Short range melee override kicks in).
 
:*"If No Gun" behavior "Retreat" works in a rather simple manner - if unarmed, A.I. character is given a desire to run as far away 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 yet lightweight (on game engine) results. [http://www.youtube.com/watch?v=BTGQTAoU_1E See this YouTube video.]
 
:*Setting short getup times is a good way to make A.I. driven character formidable opponent in hand to hand combat. However, too short getup times can introduce problems. It is a good idea to experiment with getup parameters till the character feels "natural".
 
:* Don't overextend "Check body" and "Dead make sure" timers. It looks silly and on top of that it makes A.I. characters easy targets of a surprise rear throw.
271

edits