AgendaItem class | actor.t[6428]

An "agenda item." Each actor can have its own "agenda," which is a list of these items. Each item represents an action that the actor wants to perform - this is usually a goal the actor wants to achieve, or a conversational topic the actor wants to pursue.

On any given turn, an actor can carry out only one agenda item.

Agenda items are a convenient way of controlling complex behavior. Each agenda item defines its own condition for when the actor can pursue the item, and each item defines what the actor does when pursuing the item. Agenda items can improve the code structure for an NPC's behavior, since they nicely isolate a single background action and group it with the conditions that trigger it. But the main benefit of agenda items is the one-per-turn pacing - by executing at most one agenda item per turn, we ensure that the NPC will carry out its self-initiated actions at a measured pace, rather than as a jumble of random actions on a single turn.

Note that NPC-initiated conversation messages override agendas. If an actor has an active ConvNode, AND the ConvNode displays a "continuation message" on a given turn, then the actor will not pursue its agenda on that turn. In this way, ConvNode continuation messages act rather like high-priority agenda items.

`class AgendaItem : object`

Superclass Tree (in declaration order)

`AgendaItem`
`object`

Subclass Tree

`AgendaItem`
`BoredomAgendaItem`
`ConvAgendaItem`
`FactAgendaItem`
`DelayedAgendaItem`
`FollowAgendaItem`

Global Objects

(none)

Summary of Properties

`agendaOrder calledBy endCondition executeOnce initiallyActive invokedByActor isDone isReady name`

Summary of Methods

`actorSay getActor invokeItem invokeItemBase registerItem report resetItem`

Properties

`agendaOrder` | `actor.t[6489]`

The ordering of the item relative to other agenda items. When we choose an agenda item to execute, we always choose the lowest numbered item that's ready to run. You can leave this with the default value if you don't care about the order.

`calledBy` | `actor.t[6546]`

The object from whose agendaList this AgendaItem was invoked

`endCondition` | `actor.t[6478]`

If specified, an expression or method that evaluates to true when this AgendaItem has oompleted its task and wants to set isDone to true. This is checked both immediately before and immediately after invokeItem() is called (since calling invokeItem might change the game state). This is provided as a conveniant alteranative to handling isDone from with invokeItem(), which may still be necessary in some cases, such as when you want an AgendaItem simply to execute once (although you can also use the executeOnce property for that).

`executeOnce` | `actor.t[6481]`

Flag: do we want this AgendaItem to execute once and once only?

`initiallyActive` | `actor.t[6442]`

Is this item active at the start of the game? Override this to true to make the item initially active; we'll add it to the actor's agenda during the game's initialization.

`invokedByActor` | `actor.t[6543]`

invokeItem can test the invokedByActor property to decide whether what the actor says should be a conversational gambit started on the actor's own initiative or as a (default) response to something the pc has just

`isDone` | `actor.t[6467]`

Is this item done? On each turn, we'll remove any items marked as done from the actor's agenda list. We remove items marked as done before executing any items, so done-ness overrides readiness; in other words, if an item is both 'done' and 'ready', it'll simply be removed from the list and will not be executed.

By default, we simply return nil. Items can override this to provide a declarative condition of done-ness, or they can simply set the property to true when they finish their work. For example, an item that only needs to execute once can simply set isDone to true in its invokeItem() method; an item that's to be repeated until some success condition obtains can override isDone to return the success condition.

In some cases, it may be more convenient to set the endCondirion property to define when isDone should be set to true.

`isReady` | `actor.t[6450]`

Is this item ready to execute? The actor will only execute an agenda item when this condition is met. By default, we're ready to execute. Items can override this to provide a declarative condition of readiness if desired.

`name` | `actor.t[6577]`

An optional tag, specified as a single-quoted string.

Methods

`actorSay (msg)` | `actor.t[6591]`

Another convensence method; calling actorSay() on an AgendaItem calls actorSay() on its associated Actor.

`getActor ( )` | `actor.t[6435]`

My actor - agenda items should be nested within the actor using '+' so that we can find our actor. Note that this doesn't add the item to the actor's agenda - that has to be done explicitly with actor.addToAgenda().

`invokeItem ( )` | `actor.t[6554]`

Execute this item. This is invoked during the actor's turn when the item is the first item that's ready to execute in the actor's agenda list. We do nothing by default.

`invokeItemBase (caller)` | `actor.t[6497]`

The caller is passed as a parameter so we can tell whether we're being called from an Actor or from a DefaultAgendaTopic, which may affect what we want to do -- for example the wording of what the actor says at this point.

`registerItem ( )` | `actor.t[6574]`

Carry out any additional registration when we're added to our actor's agenda. We do nothing here, but this is needed on FollowAgendaItem.

`report (msg, prop, =, &, canSee)` | `actor.t[6585]`

A convenience method that can be used from within our invokeItem to display some text only if the player character can see us (or, if the optional second parameter is supplied, sense us through some other sense, e.g. &canHear or &canSmell).

`resetItem ( )` | `actor.t[6563]`

Reset the item. This is invoked whenever the item is added to an actor's agenda. By default, we'll set isDone to nil as long as isDone isn't a method; this makes it easier to reuse agenda items, since we don't have to worry about clearing out the isDone flag when reusing an item.

Adv3Lite Library Reference Manual
Generated on 03/07/2024 from adv3Lite version 2.1