A beginner's guide - Appendix 3

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search

Appendix Three: NPC Behavior[edit | edit source]

In tutorial 6, when we begin to build our own quest, I am going to look at the main ideas behind NPC creation, and will spend a lot more time looking at this window and its tabs.

For this lesson, however, I want to focus on the AI window. Click on Velwyn's AI Button to open it.

AI Button
This window displays the AI screen for that creature or NPC. It contains a number of flags, boxes and tabs. Along the top are four boxes that are used to set NPC character behaviors.

Aggression
This value controls whether or not a NPC enters combat. If the NPC's disposition toward another actor (or PC) falls below this level, it will initiate combat. So the higher this value is set the more likely the NPC is to fight.

A setting of 5 or below means it will not initiate combat under any circumstance, but will enter combat if directly attacked or to protect a member of the same faction.

A setting of zero means it will refuse combat even if attacked or a fellow faction member is attacked.

Confidence
This as a measure of how likely the NPC is to attack or flee in combat. It is a threshold for a hidden calculation. A setting of 100 guarantees the actor will never flee. A setting of 0 means he will always flee.

Energy Level
This value determines how often the NPC will move to a new location when executing Wander packages. The higher the value the more often he will move.

Responsibility
This value determines how willing the actor is to commit a crime.
Settings below 30 means the actor will commit a crime (i.e. steal food if given an eat package). All fences must have a value below 30 to accept stolen goods.

A setting of 100 means the actor can report crimes directly, adding bounty to the player without a guard being present.

The actor cannot make the actual arrest though.

Below this are sequences of flags that control NPC/merchant behavior.

Buys/Sells.
The NPC will buy or sell these classes of items.

Barter Gold
How much money the NPC has to buy items from the player.

Recharge
Checkbox to allow the NPC to offer recharging magic items as a service.

Repair
Checkbox to allow the NPC to offer repairing items as a service.

Training
Checkbox to allow the NPC to offer skills training as a service. The drop down box is used to select the skill for training and the number field determines the maximum skill value the NPC can train you to.


AI Package List
This is the list of packages this actor will run. See AI Packages for more information.

Packages

Packages are bundles of AI instructions with conditions for when and how to execute them. They are placed on an actor by dragging them to the AI Package List. When an actor needs to pick a new package, the list is examined from the top. The first package that is valid, based on its schedule and conditions, is selected and applied to the actor.

This is very important.

Every hour unless we force an evaluation, the actor's package list is examined from the top to the bottom. The first package that has all its conditions (including a schedule) met, is executed regardless of the other packages. If you place an open ended wander package at the top of the list, the actor will keep using it.


Package Type
Sets the basic behavior type for the package. Each type enables and disables appropriate fields in the tabs. The behavior type determines the animations that the character performs.

Flags
A set of flags that modify the behavior of the package.

Door Flags
Any teleport doors in the cell that are owned by the actor will be locked or unlocked depending on how these flags are set. (eg. This is used to get Merchants to lock their shops at the end of a working day)

Schedule Tab
Sets the time at which the package can run. The schedule cannot be in less than one hour blocks.

Conditions Tab
A full set of conditions that must be true for the package to be selected. Only applies if the schedule is valid. "Run on Target" is only valid if the package has a defined Target.

Location Tab
Defines the location for the package to occur. It is generally recommended that you only use the Near Reference option. If no location is selected then it defaults to the Near Current Location setting.

- Near Reference: Select the reference from the render window or from the lists.
- In Cell: Not recommended. It can produce unexpected behavior.

For example if you set an Eat package for a Tavern Cell, the actor can eat anywhere in that cell, which may not cause any odd problems. However, setting a sleep package to the same Tavern will see the Actor try to sleep in the first bed they can. Most bars have beds behind the bar for the innkeeper to sleep on. The actor may occupy this bed, forcing the Innkeeper to leave the premises to find a bed in other cell.

Near Current Location
Centres the package's location on where the NPC is when the package starts.

Near Editor Location: Centres the package's location on the default location of the NPC. (i.e. where you place them in the CS)

Radius
The distance from the package's centre that is considered valid. Units are inches.

Target Tab
Some packages types have a target (reference) that is independent of the location. This takes the actor to a precise point or supplies an additional argument object for the AI function.

Specific Reference
Select the reference from the render window or the lists.

Any Object
Select a particular object ID or a class of objects.

Value
The number of these items that the package will interact with - if it is a Generic Target. It is the distance to the target - if it is a Specific Target.

The Package types available are all context sensitive. Each has its own rules for what location means and what target means. The following is a re-jig of the instructions in the Wiki for the packages.


Accompany Package

- Target: Who or what to accompany.
A target is required for an accompany package. The accompanying actor will always move to within Radius of its Target and then head where ever its Target is heading. You can limit this by time. A Duration of 0 means this package will not end until a package of higher precedence needs to start.

- Location : Not applicable...


Ambush Package
Note. The name Ambush can be misleading in that it is not an attack package. It has much in common with the find package.

- Location: Actor moves to the location and waits for the target to enter the radius
- Target: Actor finds this target once he has entered the radius on the Location Tab.

The actor's action depends on other game settings.
The actor travels to the specified target and "activates" it.

The meaning of activate depends on the target -

Target Meaning
NPC Talk to him, or fight if you don't like him.
Creature Attack it.
Object Pick it up.
Container Open it.
Chair Sit in it.
Door Open it. Go through for load doors.


Cast Magic Package
It can be a specific spell which they will cast even if it is not in their spell list. If you pick an object type to cast, it will only use their spell list.

Location: Target of the spell (only valid if casting a touch or target spell). The location is where you want the spell cast. This means if the location is a reference and the spell to cast is a touch or target then that is the intended target.

- Target: Spell to cast.

NOTE: The Target of the package is the spell you want to cast - not who or what you want it cast it on.


Eat Package
In order to eat the actor must have an ingredient that restores fatigue in his container. If he/she does not have the food item, they will attempt to gain the object by buying, killing, stealing or finding it. No actor with a responsibility above 30 will steal or kill for food unless it is a creature. If they can not find food they can use, they will go into a wander state (acts just like wander behavior) and search for food again periodically. Remember there is no physical reason for an Actor to eat. He will not die. This is used to add life-like behavior to actors, not as an essential part of the game mechanics.

- Location: Where to sit, which can be as specific as a particular chair in the tavern or as general as the town tavern cell. In general, NPCs will attempt to find somewhere to sit while eating.

- Target: If the eat package has a target, the actor must have or find that target to eat it. This must be an ingredient.


Escort Package
The NPC acts as the lead in moving to a location. If the follower falls behind by a specified distance, the escorting actor will stop and wait, doing a "come along" animation or travelling to the actor to get back within range. The wait distance is determined by two game settings, one for indoors and one for outdoors. Also, the wait distance is set on the Target tab. It is recommended that the wait distance be a value greater than 400.

(If the Player is being escorted, he does not get a follow package forced onto him.)

- Target: Who/what to escort. An escort package will add a follow package onto the target if the target is an actor.

- Location: is the destination of the escort package. A location is required to make an escort package.


Find Package
This is similar to the Ambush package. It differs because Find expects the target to be at the location, while Ambush waits for the target.

The Actor travels to within the specified Radius of the Location, then finds the target and "activates" it. The meaning of activate depends on the target.

Target Meaning
NPC Talk to him, or fight if you don't like him.
Creature Attack it.
Object Pick it up.
Container Open it.
Chair Sit in it.
Door Open it. Go through for load doors.

- Location: Optional (if none specified, default is Current Location).


When the actor reaches the location, it does a search (within radius = fAIAcquireObjectDistance) and builds a list of targets up to the specified Count. It then activates each of them.

If it runs out of targets before it has reached Count, it will wander within Radius of the Location for the duration of the package, periodically rechecking the area for suitable targets.

- Target: The NPC will Travel towards the target until it gets within Target Radius, then it activates the target. The count setting determines how many of these the actor will attempt to find.


Flee Package
This will cause an actor to run to a location or from a target. If you don't put a target on the package then the actor will flee to a location and remain there running the cower animation. If you put a target on it, then the actor will run away from a target keeping the distance that is specified in the target data. If he is the right distance from the target he will stand and cower. This package will not end until a new package evaluates.

- Location: Where to flee to. Ignored if target is specified.

- Target: Who or what to flee from. Distance is the distance the actor will try to stay away from his flee target.


Follow Package
This sets up the opposite relationship to escort (ie NPC follows target).

- Target: Who/what to follow. A target is required for a follow package.

- Location: The destination of the follow is not required, but can be applied. A follow can end by reaching the destination or if the duration runs out. A Duration of 0 means this package will not end until a package of higher precedence needs to start.


Sleep Package

- Target: Not used.

- Location: Where to sleep. It can be as specific as the third bed from the left in the mages guild or as general as Tom's house (bed must be a persistent reference). If it is a general location then the actor will sleep in any bed in that location that is not owned by another NPC (unless they have a low responsibility) and is not occupied.

- If they can not find a bed they will go into a wander state, periodically checking for a bed.


Travel Package

- Target: Not used.

- Location: Go to specified location. If the quest conditions force the actor to use this package again, he will just stand there.

If a furniture object (such as a bed or chair) is selected then the actor will lay in the bed or sit in the chair. The Duration and Flags affect the outcome of this package.

--- Duration = 0: No Flag. Travel until you reach location, but could be overtaken by a higher priority package before getting there.

--- Duration = 0: Must Complete. Travel until you reach location. Will not give way to any other package until location is reached.

--- Duration = 0: Must Reach Location. Same as Must Complete, but will evaluate immediately, when at location, instead of waiting for normal time interval.

--- Duration > 0: No Flag: Travel until you reach location, but could be overtaken by a higher priority package before getting there.

If NPC reaches the location before end of duration, he will stay there (but could give way to a higher priority package and leave again).

If they don't reach location before end of duration, they will re-evaluate and could change to new package.

--- Duration > 0: Must Complete Flagged. Travel until you reach location. Will not re-evaluate to any other package until location is reached AND duration expires.

--- Duration > 0: Must Reach Location. Travel until you reach location. Will not re-evaluate to any other package until location is reached. If the NPC reaches the location before end of duration, it may re-evaluate to higher priority package if applicable.


UseItemAt Package

- Target: The item to be used. It can be in the actor's inventory or in the world near that location.

- Location: The location to travel to, before attempting to use the target object.

If the idle animation is set up properly, the actor will play the idle associated with the item. (See Later for an example in this quest)


Wander Package

- Target: Not Used.

- Location: Go to specified location and wander near it, within specified radius. Radius must be greater than zero. Recommended radius is greater than 100.

Actors in wander packages are also trying to find people to talk to within their social radius. If you do not want an actor to engage in dialogue in a wander they must have skipfallout behavior checked.

Also the energy level of an actor determines how often they move in a wander. If they find a chair in their wander radius they will likely sit down for a while.

Again Duration can affect behavior .

--- Duration = 0: No Flag
Wander until something higher evaluates.

--- Duration = 0: Must Complete. Meaningless.

--- Duration = 0: Must Reach Location. Will not re-evaluate to any other package until location is reached. When at location, wander until something higher evaluates.

--- Duration > 0: No Flag.. Wander at location until duration expires, unless something higher priority evaluates earlier.

---- Duration > 0: Must Complete. Wander at location until duration expires. Will not re-evaluate to any other package until location is reached AND duration expires.

---- Duration > 0: Must Reach Location. Will not re-evaluate to any other package until location is reached. When at location, wander for remaining duration unless something higher evaluates first.

Additional Notes: For the NPC to not run into walls, you must first create a "priority" path. To do this click on the path mode button then while holding both CTRL and ALT, lay out a path that you want the NPC to follow.