NPC Perception Design: Difference between revisions

From PSwiki
Jump to navigation Jump to search
Magodra (talk | contribs)
Magodra (talk | contribs)
 
(2 intermediate revisions by the same user not shown)
Line 109: Line 109:


=== Perceptions used from locate operation ===
=== Perceptions used from locate operation ===
The locate operation can locate objects of type perception. For this to make sence the perception need to implement the GetTarget.
The [[Behavior_Operations#Locate_Operation|Locate Operation]] can locate objects of type perception. This only make sense for perceptions that has an actual position. Either a physical position that can be provided through the GetLocate or an target that the default implementation of the GetLocate could use to get the position of the target. In this case the perception need to implement the GetTarget.


<uml>
<uml>
participant Reaction
participant LocateOperation
participant LocateOperation
participant NPC
participant NPC
Line 119: Line 118:
== During Perception Handling ==
== During Perception Handling ==


Reaction --> NPC : SetLastPerception
[-> NPC : SetLastPerception
 
activate NPC
[<-- NPC
deactivate NPC


== During Script Execution ==
== During Script Execution ==
Line 133: Line 134:
Deactivate NPC
Deactivate NPC


LocateOperation -> Perception : GetLocation
alt Perception == NULL
Activate Perception
  [<-- LocateOperation : OPERATION_FAILED
else Perception <> NULL
  LocateOperation -> Perception : GetLocation
  Activate Perception


Perception -> Perception : GetTarget
  Perception -> Perception : GetTarget
note right: Default behavior get location from target if there is one.
  note right: Default behavior get location from target if there is one.
activate Perception
  activate Perception
deactivate Perception
  deactivate Perception
Perception --> LocateOperation
  Perception --> LocateOperation
Deactivate Perception
  Deactivate Perception


LocateOperation -> NPC : SetLocate
  LocateOperation -> NPC : SetLocate
Activate NPC
  Activate NPC
LocateOperation <-- NPC
  LocateOperation <-- NPC
Deactivate NPC
  Deactivate NPC


alt destination == "Active"
  alt destination == "Active"
  LocateOperation -> NPC : SetTarget
    LocateOperation -> NPC : SetTarget
  Activate NPC
    Activate NPC
  LocateOperation <-- NPC
    LocateOperation <-- NPC
  Deactivate NPC
    Deactivate NPC
  end
end
end


[<-- LocateOperation
[<-- LocateOperation : OPERATION_COMPLETED
Deactivate LocateOperation
Deactivate LocateOperation



Latest revision as of 13:30, 7 April 2013

See Behaviors_and_Reactions for User details about how to use Perceptions in the behavior.xml file.


This embodies any perception an NPC might have, or any game event of interest. Reaction objects below will subscribe to these events, and the networking system will publish them. Examples would be "attacked", "collided", "talked to", "hear cry".

NPC Perceptions

Class Hierarchy

The Perception class is used for simple perception and as the Base Class for a number of special perceptions.

Special Perceptions:

  • TimePerception
  • FactionPerception
  • ItemPerception
  • LocationPerception
  • PositionPerception
  • AttackPerception
  • GroupAttackPerception
  • DamagePerception
  • SpellPerception
  • DeathPerception
  • InventoryPerception
  • OwnerCmdPerception
  • OwnerActionPerception
  • NPCCmdPerception

Sequences

Personal NPC Perceptions Sequence

Show the typical sequence for a Perception fired for a NPC, might be perceptions like Damage Perception.

Broadcast NPC Perceptions Sequence

Show the typical sequence for a broadcasted Perception. Examples of broadcasted perceptions is the SpellPerception.

Special cases

Perceptions used from locate operation

The Locate Operation can locate objects of type perception. This only make sense for perceptions that has an actual position. Either a physical position that can be provided through the GetLocate or an target that the default implementation of the GetLocate could use to get the position of the target. In this case the perception need to implement the GetTarget.