diff options
| author | historia <[not public]> | 2026-07-09 19:29:17 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-07-09 19:29:17 -0400 |
| commit | b3d4c616f59ad2519f3a0b77e3b47d6571cd2486 (patch) | |
| tree | 6f1f6a314e0550da68264a79381fc269db803312 /internal/behavior | |
| parent | 18c7af94b30c2767b6633d050324c1db34074ce2 (diff) | |
| download | thehouseoficarus-b3d4c616f59ad2519f3a0b77e3b47d6571cd2486.tar.gz | |
feat: message actions are now sequences of messages with settable delays
Diffstat (limited to 'internal/behavior')
| -rw-r--r-- | internal/behavior/behavior.go | 29 | ||||
| -rw-r--r-- | internal/behavior/types.go | 8 |
2 files changed, 20 insertions, 17 deletions
diff --git a/internal/behavior/behavior.go b/internal/behavior/behavior.go index 58b5e6b..12eef0b 100644 --- a/internal/behavior/behavior.go +++ b/internal/behavior/behavior.go @@ -58,6 +58,16 @@ type NodeAction struct { ApsNode bool `yaml:"aps_node,omitempty"` } +// DelayedMessage is a single message with a delay (in ticks) to wait before +// showing it. Used by the interaction sequencer (on_use / on_look / on_kill / +// on_traverse); on_enter and trigger steps emit their Messages list +// immediately when the step fires (use the step's own Delay for inter-step +// spacing). +type DelayedMessage struct { + Message string `yaml:"message,omitempty"` + Delay int `yaml:"delay,omitempty"` +} + // Interaction is one conditional trigger entry shared by on_use, on_look // (objects) and on_kill (mobs). Item filters by the appropriate held/weapon // item depending on the interaction kind (see itemMatch on applyInteraction). @@ -70,7 +80,6 @@ type NodeAction struct { type Interaction struct { Item string `yaml:"item_id,omitempty"` Condition *Condition `yaml:"condition,omitempty"` - Message string `yaml:"message,omitempty"` Action *StepAction `yaml:"action,omitempty"` } @@ -78,25 +87,25 @@ type Interaction struct { // across all effect executors (on_enter steps, room/global triggers, talk // nodes, use/look/kill interactions, exit traversal). The embedded // NodeAction holds the inline-only effects (flags/items/teleport/heal/credits/ -// aps_node); the additional fields are the sequence-only effects (message, +// aps_node); the additional fields are the sequence-only effects (messages, // broadcasts, mob spawn/despawn, delay). Condition is evaluated per-step by // the on_enter / trigger schedulers; inline callers ignore it (the gating // happens at the parent Interaction.ExitDef level instead). type StepAction struct { NodeAction `yaml:",inline"` - Condition *Condition `yaml:"condition,omitempty"` - Message string `yaml:"message,omitempty"` - Broadcast string `yaml:"broadcast,omitempty"` - BroadcastGlobal string `yaml:"broadcast_global,omitempty"` - SpawnMob *SpawnMobConfig `yaml:"spawn_mob,omitempty"` - DespawnMob string `yaml:"despawn_mob,omitempty"` - Delay int `yaml:"delay,omitempty"` + Condition *Condition `yaml:"condition,omitempty"` + Messages []DelayedMessage `yaml:"messages,omitempty"` + Broadcast string `yaml:"broadcast,omitempty"` + BroadcastGlobal string `yaml:"broadcast_global,omitempty"` + SpawnMob *SpawnMobConfig `yaml:"spawn_mob,omitempty"` + DespawnMob string `yaml:"despawn_mob,omitempty"` + Delay int `yaml:"delay,omitempty"` } // IsTimed reports whether the step carries sequence semantics (any non-zero // field means it needs per-tick scheduling rather than synchronous printing). func (s StepAction) IsTimed() bool { - return s.Delay > 0 || s.Message != "" || s.Broadcast != "" || s.BroadcastGlobal != "" || + return s.Delay > 0 || len(s.Messages) > 0 || s.Broadcast != "" || s.BroadcastGlobal != "" || s.SpawnMob != nil || s.DespawnMob != "" || len(s.SetGlobalFlags) > 0 || len(s.SetPlayerFlags) > 0 || s.GiveItem != "" || s.TakeItem != "" || s.Teleport != 0 || s.Heal != 0 || diff --git a/internal/behavior/types.go b/internal/behavior/types.go index 521867a..f451400 100644 --- a/internal/behavior/types.go +++ b/internal/behavior/types.go @@ -51,7 +51,7 @@ const ( TypeMix ActionType = "mix" TypeConstruct ActionType = "construct" TypeTriggerModule ActionType = "trigger_module" - TypeUseInteraction ActionType = "use_interaction" + TypeInteractionSeq ActionType = "interaction_seq" ) type Action struct { @@ -117,12 +117,6 @@ type TalkData struct { PendingChosen bool } -type UseInteractionData struct { - Message string - Action *StepAction - ObjName string -} - type BurnData struct { ItemID string ToolSpeed float64 |
