diff options
Diffstat (limited to 'internal/world/mob.go')
| -rw-r--r-- | internal/world/mob.go | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/internal/world/mob.go b/internal/world/mob.go index 6780c45..a9e2f7e 100644 --- a/internal/world/mob.go +++ b/internal/world/mob.go @@ -78,13 +78,13 @@ type MobCombat struct { } type MobDef struct { - ID string `yaml:"id"` - Name string `yaml:"name"` - Description string `yaml:"description"` - IdleDescriptions []string `yaml:"idle_descriptions"` - Protected bool `yaml:"protected"` - Unique bool `yaml:"unique"` - Drops MobDropTable `yaml:"drops"` + ID string `yaml:"id"` + Name string `yaml:"name"` + Description string `yaml:"description"` + IdleDescriptions []string `yaml:"idle_descriptions"` + Protected bool `yaml:"protected"` + Unique bool `yaml:"unique"` + Drops MobDropTable `yaml:"drops"` Steal *MobSteal `yaml:"steal,omitempty"` Task *MobTask `yaml:"task,omitempty"` @@ -93,6 +93,8 @@ type MobDef struct { Talk *behavior.TalkConfig `yaml:"talk,omitempty"` Shop *behavior.ShopConfig `yaml:"shop,omitempty"` + + OnKill []behavior.Interaction `yaml:"on_kill,omitempty"` } func (d *MobDef) IsTalkable() bool { return d.Talk != nil } @@ -165,6 +167,13 @@ type MobInstance struct { TalkConfig *behavior.TalkConfig + // OnKill is copied from the def at spawn time and fires from endCombat + // when this mob is defeated — either by a combat kill or by a task mob's + // HP draining to zero (the "completion" of the work). The first entry + // whose item filter, Condition, and the first-match-wins rule all pass + // fires. + OnKill []behavior.Interaction + // Shop is the (shared, read-only) shop config from the def. Per-instance // live stock is tracked in ShopStock; ShopRestock holds per-item countdown // timers. All three are only mutated under MobStore.mu. @@ -332,6 +341,7 @@ func NewMobInstance(def *MobDef, instanceID string, roomID int, wanderRooms []in CompleteMessage: completeMessage, CombatDescriptions: combatDescriptions, TalkConfig: def.Talk, + OnKill: def.OnKill, } if def.Shop != nil { inst.Shop = def.Shop |
