NPC Perception Design: Difference between revisions

From PSwiki
Jump to navigation Jump to search
m Reverted edits by Luca (Talk) to last revision by Ethryn
Magodra (talk | contribs)
No edit summary
Line 1: Line 1:
See [[Behaviors_and_Reactions]] for most up to date description of perceptions.
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".
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 ==
== NPC Perceptions ==


=== RangePerception ===
<uml>
 
class Reaction
=== TimePerception ===
class Perception
The Game Server sends a Time perception once per game hour to all
superclients, with a number from 0 to 23 indicating the hour. If a superclient needs more fine-grained time reactions, the superclient can generate time perceptions of its own in between and react accordingly.
 
This perception allows npcs to change behaviors or state depending on the time of day. For example, you could have nocturnal hunting creatures who sleep during the day, or npc city merchants who are in their shops during the day and at home at night.
 
 
Example:
  <react event="time" value="8,0,,,"  behavior="go_other_sector1" delta="20" />
 
=== FactionPerception ===
=== ItemPerception ===
Whenever an NPC is close to an item, this perception is passed to the npc.
 
=== LocationPerception ===
Whenever an NPC is close to an location, this perception is passed to the npc.
 
=== AttackPerception ===
Whenever an NPC is attacked by a player, this perception is passed to the attacked npc.  The npc should use this to build an initial hate list for the player and his group (if any). If the designer wants to cheat, he can start attacking back on this event instead of on first damage, and save a few seconds in response time.
 
Example:
  <react event="attack"  behavior="fight" delta="150" />
 
=== GroupAttackPerception ===
Whenever an NPC is attacked by a grouop, this perception is passed to the attacked npc.  The npc should use this to build an initial hate list for the player group. If the designer wants to cheat, he can start attacking back on this event instead of on first damage, and save a few seconds in response time.
 
=== DamagePerception ===
Whenever an NPC is hit for damage by a melee hit or a spell, this perception is passed to the damaged npc.  Right now, it affects his/her hate list according to the weight supplied.
 
=== SpellPerception ===
Whenever a player casts a spell on himself, another player, or any npc, this perception is passed to npc's in the vicinity. We cannot only use targeted NPCs because an npc in combat may want to react to a player healing his group mate, which helps his team and hurts the NPC indirectly.  Right now, reactions are allowed by type of spell, and depending on the severity, it affects his/her hate list according to the weight supplied.
 
=== DeathPerception ===
The network layer is notified of any deaths from players or NPCs on the server.  This perception is passed to all NPCs so they can react, by removing the player from hate lists, stopping their combat or whatever.
 
=== InventoryPerception ===
This perception is used when a item is added or removed from inventory.


=== OwnerCmdPerception ===
Perception <|-- RangePerception
Whenever an NPCPet is told by it's owner to stay, this perception is passed to the NPCPet.  Right now, it changes the current behavior of the NPCPet.
Perception <|-- TimePerception
Perception <|-- FactionPerception
Perception <|-- ItemPerception
Perception <|-- LocationPerception
Perception <|-- PositionPerception
Perception <|-- AttackPerception
Perception <|-- GroupAttackPerception
Perception <|-- DamagePerception
Perception <|-- SpellPerception
Perception <|-- DeathPerception
Perception <|-- InventoryPerception
Perception <|-- OwnerCmdPerception
Perception <|-- OwnerActionPerception
Perception <|-- NPCCmdPerception
</uml>


=== OwnerActionPerception ===
== Personal NPC Perceptions ==
Whenever an NPCPet is told by it's owner to stay, this perception is passed to the NPCPet.  Right now, it changes the current behavior of the NPCPet.
<uml>
-> NPC : TriggerEvent
NPC -> NPCType : FirePerception
loop "For all Reactions"
  NPCType -> Reaction : React
  Reaction -> Perception : ShouldReact
  Reaction -> Reaction : CheckDeath
  Reaction -> Reaction : Check DoNotInterrupt
  Reaction -> Reaction : Check OnlyInterrupt
  loop "For all Affected"
    Reaction -> Reaction : Check only active affected
    Reaction -> Reaction : Check only inactive affected
    Reaction -> Reaction : Adjust Needs
    Reaction -> Perception : ExecutePerception
  end loop
  NPC <- Reaction : SetLastPerception
end loop


=== NPCCmdPerception ===
 
Whenever an NPC Cmd is received this perception is fired. This is most typicaly from a response script like: <npccmd cmd="test_cmd"/>
</uml>




[[Category:Engine documents]]
[[Category:Engine documents]]

Revision as of 18:39, 30 April 2011

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

Personal NPC Perceptions