aboutsummaryrefslogtreecommitdiff
path: root/internal/behavior/behavior.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/behavior/behavior.go')
-rw-r--r--internal/behavior/behavior.go29
1 files changed, 19 insertions, 10 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 ||