
|
Artificial Intelligence is simply a game's attempt to mimic intelligence and behaviour, typically associated with a creature or thing. It is important to remember that convincing AI can help define the feel of the game almost as much as the visual aspects. In JK and MotS, AI files are what helps each interactive "thing" behave realistically (or as "realistic" as the game engine allows for), by defining a base set of 'instincts' which, when various conditions are met, will trigger the AI character (usually a 3do model) to respond.
For both JK and MotS, there are three possible types of AI file, identifiable by the file's extension. The extension itself relates to the intended difficulty level of the game.
Typically, the AI should react quicker/fire more frequently, etc, as the difficulty levels increase, but this does not necessarily have to be the case and is left to the discretion of the editor.
Ideally, whilst there should be an AI file for each corresponding difficulty level, this may not always be the case. When this situation arises, the game engine defaults to an ".ai" file type, when no other AI file is provided. Similarly, if, for example, only an ".ai2" file exists (with no ".ai0" or ".ai" equivalents found in the resource), that same ".ai2" file is used for all difficulty levels.
All AI file types should be placed under the misc/ai directory of your project or GOB/GOO. Please note that you do not need separate "AI0" or "AI2" directories.
JK and MotS's AI files control the behavioural "instincts" that a character should possess. Without an AI file attached, the character just stands there in your level, completely oblivious to its surroundings; it will still register damage if it is hurt and play a damaged/recoil keyframe, but it will only move if you bump or "push" the character. There is therefore no sort of interaction and the purpose of having the character in the level to begin with is questionable.
There are three different approaches for setting an actor's AI class:
Direct Template Modification
jk_actor 3dmodel=actor3DO.3do puppet=actor.pup aiclass=AIFileForActorHere.ai
This technique is good for applying a global AI class to a particular type of actor (eg: all stormtroopers should have the same behavioural instincts).
JED "AICLASS" Attribute
''Key'' | Value ------------------------------- AICLASS | AIFileForActorHere.ai
This technique makes it possible to set level-specific AI for an individual actor. In JED (the following method has not been tested in JKEdit), by clicking on the "add property" and typing in "aiclass" (NB: not case sensitive), allows the associated attribute value to be a valid/existing AI file, which is loaded either from the current project directory's misc/ai subdirectory or from pre-exisiting JK/MotS GOB/GOO files.
COG Verbs
##
# JK and MotS compliant Cog Script
#
# Set 4 "things"' AI classes upon startup and modify
# the AI class, upon entering a sector.
#
##
symbols
message startup
message entered
sector triggerSector linkid=1
int i=0 local
int numActors=4 local
thing theAIActor0
thing theAIActor1
thing theAIActor2
thing theAIActor3
ai initialAI
ai alteredAI
end
#=============================================================================
#=============================================================================
code
startup:
for (i=0 ; i<numActors ; i=i+1)
AISetClass (theAIActor0[i], initialAI);
return;
#=====================================================================
entered:
if (GetSenderID() == 1) { // match the linkid
for (i=0 ; i<numActors ; i=i+1)
AISetClass (theAIActor0[i], alteredAI);
}
return;
#=====================================================================
end
This technique provides the potential for swopping AI files for characters dynamically, depending on their surroundings and current environment. However, this aspect borders more on the realm of cogging and not explicity AI files.
Each AI file you write should include a comment header, for example:
##
# JK/MotS AI File
#
# FILENAME.AI
#
# Header Text
# All "comment" code is prefixed with the "#" symbol
#
##
Although these headers are not compulsory, it makes life easier for editors to follow, as well as helping to "jog your memory" if you can't remember the specific nature of the AI File.
The line below is the AI Setup Line. It is the first line in the AI file (the first "real" line that the game engine processes) and details what the basic AI attribute values should be. Each attribute and its accompanying value are comma delimited. All instinct lines (described in the next section) are listed after the setup line. Only one instance of this line is allowed per AI file. The order of each attribute does not seem to matter; the game engine appears to process the setup line as a complete entity (although alignment and rank are usually the first attributes).
Attributes in square brackets "[ ]" are not used by all AI files, as addressed below:
alignment= , rank=0.5, fov= , [maxstep= ], sightdist= , heardist= , [accuracy= ]
Other Related Notes
"There are 3 types of AI files for 3 difficulty levels. If a level is played on Easy, JK automatically uses files with the ".AI0" extension. On Hard, the ".AI2" files are used. On Medium (and if there are no extra AI0 & AI2 files), the .AI files are used. The AI files do not influence the outward appearence of an enemy, nor [do] they define which weapons a character has. They only specify the character of the character (and his weapons)."
The following is a list of all available instincts. MotS supports an extended number of instincts, which are not parsed by the JK game engine, and so are marked accordingly. Note that whilst the following list is not case sensitive, it is highly recommended that editors adhere to the "CamelCase" style of coding (capitalisation for each new word).
In alphebetical order, these instincts are:
JK Specs