Module: Lich::Common::CreatureBase
- Included in:
- DragonRealms::CreatureInstance, Gemstone::CreatureInstance
- Defined in:
- documented/common/creature/creature_base.rb
Overview
Shared creature behaviour mixed into each game's CreatureInstance.
Include this into a concrete creature-instance class. The included hook
extends the class with ClassMethods (registry/roster/target queries) and
includes InstanceMethods (status/flag tracking). The class must define a
new(id, noun, name) constructor, call InstanceMethods#initialize_status_tracking
from its own initialize, and expose a valid_target? predicate (used by
ClassMethods#targets) plus a created_at reader (used by
ClassMethods#cleanup_old).
Defined Under Namespace
Modules: ClassMethods, InstanceMethods
Constant Summary collapse
- STATUS_DURATIONS =
Status-effect lifetimes, in seconds, used for automatic cleanup.
A
nilvalue means the status has a reliable server-sent removal message and therefore must not be auto-expired on a timer. { 'breeze' => 6, # 6 seconds roundtime 'bind' => 10, # 10 seconds typical 'web' => 8, # 8 seconds typical 'entangle' => 10, # 10 seconds typical 'hypnotism' => 12, # 12 seconds typical 'calm' => 15, # 15 seconds typical 'mass_calm' => 15, # 15 seconds typical 'sleep' => 8, # 8 seconds typical (can wake early) # Statuses with reliable removal messages - no duration needed. 'stunned' => nil, 'immobilized' => nil, 'prone' => nil, 'blind' => nil, 'sunburst' => nil, 'webbed' => nil, 'poisoned' => nil, 'hidden' => nil }.freeze
- CRTR_STATUS_FLAGS =
Maps
<crtrStatus>transient XML flags to canonical status names.The XML feed and the message parser use slightly different terms for the same state (e.g. "immobile" versus "immobilized"). Keeping this mapping explicit lets XML- and message-based detection reconcile into the same status entries.
{ 'immobile' => 'immobilized', 'webbed' => 'webbed', 'sleeping' => 'sleeping', 'disoriented' => 'disoriented', 'stunned' => 'stunned', 'rooted' => 'rooted', 'calmed' => 'calm', 'kneeling' => 'kneeling', 'prone' => 'prone', 'sitting' => 'sitting', 'flying' => 'flying', 'hovering' => 'hovering', 'hidden' => 'hidden' }.freeze
- CRTR_CLASSIFICATION_FLAGS =
Maps
<crtrStatus>classification XML flags to predicate keys.These are relationship or classification facts rather than transient combat statuses, so they are stored separately and read via InstanceMethods#crtr_flag?.
{ 'hostile' => :hostile, 'disengaged' => :disengaged, 'dead' => :dead, 'sympathetic' => :sympathetic, 'ascended' => :ascended, 'inferior' => :inferior, 'AscensionBoss' => :ascension_boss, 'MiniBoss' => :mini_boss, 'challenging' => :challenging, 'rider' => :rider, 'mount' => :mount }.freeze
- ALL_CRTR_FLAGS =
All known
<crtrStatus>attributes keyed by XML name, for debug snapshots. CRTR_STATUS_FLAGS.merge(CRTR_CLASSIFICATION_FLAGS).freeze
- KNOWN_FLAG_NAMES =
Every filter name ClassMethods#targets and ClassMethods#in_room can match: the canonical status vocabulary (both the
<crtrStatus>status spellings and the timer-based message statuses in STATUS_DURATIONS) plus the classification keys. A filter outside this set is "unknown" and, per the query contract, matches no candidates - even when negated with anot_prefix. ( CRTR_STATUS_FLAGS.values + STATUS_DURATIONS.keys + CRTR_CLASSIFICATION_FLAGS.values.map(&:to_s) ).uniq.freeze
Class Method Summary collapse
-
.included(base) ⇒ void
Wires the shared behaviour into the including class, matching the MapBase convention.
Class Method Details
.included(base) ⇒ void
This method returns an undefined value.
Wires the shared behaviour into the including class, matching the MapBase convention.
62 63 64 65 |
# File 'documented/common/creature/creature_base.rb', line 62 def self.included(base) base.extend(ClassMethods) base.include(InstanceMethods) end |