18,700
edits
(continuing rewrite; if only Czech had a definite article ^_^) |
(continuing rewrite) |
||
Line 182: | Line 182: | ||
==Alarm behavior | ==Alarm behavior== | ||
{|align=right | {|align=right | ||
|[[Image:CONTROL CONSOLE.png|58px|right]] | |[[Image:CONTROL CONSOLE.png|58px|right]] | ||
Line 192: | Line 192: | ||
!Data | !Data | ||
|} | |} | ||
In order to make AI look more | In order to make the AI look more human, it is a good idea to grant it the ability to interact with the world the same way that the player does. In Oni, for example, that means giving the AI the ability to use consoles. | ||
::[http://www.youtube.com/watch?v=jnsGuZxqW9I Watch this YouTube video.] | ::[http://www.youtube.com/watch?v=jnsGuZxqW9I Watch this YouTube video.] | ||
:BSL scripting provides a command to make AI go and use a console | :BSL scripting provides a command to make an AI go and use a console: [[ai2_doalarm]]. This way, an AI can be told to use any console. But there is a method to make an AI use a console completely on it own. | ||
:In order to utilize | :In order to utilize this mechanic, there is a need for a console which has the ALARM CONSOLE flag set (see [[OBD:BINA/OBJC/CONS]]). In XML this flag is called '''IsAlarm'''. Such a console then can be used by AI characters without scripting. | ||
:Next, there are Alarm parameters in [[CMBT]] profiles which define AI | :Next, there are Alarm parameters in [[CMBT]] profiles which define an AI's alarm behavior: | ||
:*Search distance | :*Search distance: a radius around the AI where the engine checks for any console with the ALARM CONSOLE flag. In XML it is named <SearchDistance>. | ||
:*Ignore distance | :*Ignore distance: a radius around the AI where this AI character (which is currently executing alarm behavior) acknowledges enemies. Enemies outside of this radius are ignored by the AI character. In XML it is named <EnemyIgnoreDistance>. | ||
:*Attack distance | :*Attack distance: a range within which the AI (which is currently executing alarm behavior) will temporarily stop its run for the console and attack enemies if the AI sees them with its central vision field. In XML it is named <EnemyAttackDistance>. | ||
:*Damage threshold | :*Damage threshold: The time interval for which an AI stays aware of an enemy who attacked it. If this enemy enters the Attack distance, the AI temporarily stops its run for alarm and immediately attacks this enemy (it does not have to see him with central vision field). In XML it is named <DamageThreshold>. | ||
:*Fight timer | :*Fight timer: The number of frames for which the AI should fight with the enemy before it attempts to resume its run for the alarm. In XML it is called <FightTimer>. | ||
: | :So the settings for alarm-running behavior are set; now how to trip it? There are three ways to make a character run and use a console without BSL (but the console must have the ALARM CONSOLE flag set and must lie within Search distance): | ||
:* | :*using CMBT profile: Set the no-gun behavior to "Run For Alarm" (in XML, use the string "RunForAlarm" inside <NoGunBehavior>). By setting this parameter, an AI will attempt to run and use a console when it does not have a loaded weapon or any spare clips in its inventory. If there is no alarm console nearby, the AI will switch to Melee. | ||
:*in | :*also in CMBT: The Behaviors (Long, Medium, Short, MediumRetreat, LongRetreat) can be set to "Run for Alarm". DO NOT confuse this with the "Run For Alarm" no-gun behavior! This behavior is never used in retail Oni, the reason probably being that if there is no useable console within Alarm search distance radius, then the AI simply stands and stares even when an enemy is visible within its central vision field. | ||
:*In [[CHAR]]: Lost behavior "FindAlarm" | :*In [[CHAR]]: Use the "Lost" behavior "FindAlarm". When an AI makes definite contact with an enemy and then the enemy manages to escape, the AI executes this "Lost" behavior (see [[#Pursuit|Pursuit of enemy]] section). This behavior is typically set as ReturnToJob, but FindAlarm works well with no known issues. If an alarm console is not found within Search distance, the AI simply returns to its job. | ||
:A couple of notes regarding | :A couple of notes regarding AIs: | ||
:*in order to register enemy and attack her/him pre-emptively, AI | :*in order to register an enemy and attack her/him pre-emptively, the AI must have the "HostileThreatDefinite" timer in its ONCC file set to some value over 60 (Oni internal clock runs at 60 frames per second). | ||
:* | :*The no-gun behavior "Run For Alarm" can get glitchy. Say that "Alarm enemy attack distance" is set to 100; now when an AI runs for an alarm and an enemy attacks it, then if in the AI's CMBT profile the melee override is not set to a range of at least 100 (via melee override or by having "Melee" set in its corresponding combat ranges, see section [[#Basic combat behaviors|Basic combat behaviors]]), chances are that the AI will get stuck in a loop trying to reach both the enemy and the console at the same time. | ||
:* | :*A similar issue can happen with the combat behavior "Run For Alarm" as well, but this time problems arise when this combat behavior "Run For Alarm" is set as the Short-range behavior. | ||
:A couple of notes regarding target console: | :A couple of notes regarding the target console: | ||
:* | :*It must be in "activated" mode. If the console is in a deactivated or "used" mode, the alarm behavior will not be executed. | ||
:* | :*It must be directly accessible. Oni's AI cannot use consoles in order to open up a path to get to the point of interest (a target console in this case). But the target console can be across the whole level as long as it is not behind any locked doors. | ||
: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 | :As already mentioned, Alarm behavior can be tripped by the BSL command "ai2_doalarm". In that case, alarm behavior is executed but this time the console is being set by a command instead of being looked for within the Search distance. Also, with "ai2_doalarm" the AI can be made to use any console, not just those with the ALARM CONSOLE flag. | ||
Modding hints: ability of AI to use consoles is an excellent tool for increasing | Modding hints: the ability of the AI to use consoles is an excellent tool for increasing the challenge. | ||
:*Beware of setting Run For Alarm combat behavior as close range one. Such a setup causes glitches. | :*Beware of setting the "Run For Alarm" combat behavior as the close-range one. Such a setup causes glitches. | ||
:*On the other | :*On the other hand, "Run For Alarm" can be deliberately used to add an element of surprise to fights. In the CMBT profile, set "Run For Alarm" as either the Medium or MediumRetreat behavior, then shorten the interval between the <MediumRange> and <ShortRange> values (for example, set "Medium Range" to 60 and "Short Range" to 59). Thanks to this setup, an AI can attempt to find an alarm console while still being capable of fighting when no alarm is nearby. | ||
:*In | :*In BSL, a modder can easily determine if a console was used by the player or an AI thanks to the [[chr_is_player]] function. All that's required is a BSL function being triggered when the console is used. Here is an example where a console triggers a function called "console1_used": | ||
func void console1_used(string ai_name) | func void console1_used(string ai_name) | ||
{ | { | ||
if (chr_is_player(ai_name)) | |||
{ | |||
*Some code in case player used the console* | |||
} | |||
else | |||
{ | |||
*Some code in case AI used the console* | |||
} | |||
} | } | ||
:* | :*Another way of using alarm mechanics is to create a feeling of cooperation -- in order for the player to achieve something, an AI-driven sidekick must use a console. | ||
:*In extreme | :*In extreme cases, an AI can be even made to move through the level on it own, from one console to another. That can be used to create "chase" missions -- an AI wants to activate a certain number of consoles, while the player is required to stop it from doing so. Thanks to Alarm behaviors, the task of tripping consoles can be fully completed by the AI, no scripting needed. Such a setup is on the one hand prone to possible AI glitches, but on the other hand can add an element of randomness and increase replayability. | ||