aboutsummaryrefslogtreecommitdiff
path: root/worldbuilding_guide/objects.md
blob: 38eaeeb3dfe77b0db9b42f2063d530a623bfff2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
## Objects

Objects interact with the world through **inline behavior configs** under
`gather:`, `talk:`, or `use:` keys. There is no separate behavior
directory — everything goes directly in the object's YAML.

Gathering object (mining):
```yaml
id: copper_rock
name: copper rock
color: "178"                   # xterm-256 color index (0-255)
gather:
    skill: mining
    level: 1
    xp: 17
    base_wait: 8
    tools:
        - pickaxe
    success:
        base: 0.40
        per_level: 0.01
        cap: 0.95
    gather_message: "You swing your pickaxe at the rock..."
    fail_message: "You chip away but get nothing useful."
    drops:
        - item_id: copper_ore
          weight: 90
          depletes: true
          message: "You manage to mine some {178}copper ore{/}."
        - table: gem_table
          weight: 10
          depletes: false
          message: "You spot a glint of something valuable!"
    respawn_timer: 50
    respawn_broadcast: "A glint of copper catches your eye from some {name}."
```

Tree object (woodcutting with shared depletion):
```yaml
id: oak_tree
name: oak tree
color: "113"
gather:
    skill: woodcutting
    level: 15
    xp: 37
    base_wait: 6
    tools:
        - axe
    success:
        base: 0.40
        per_level: 0.01
        cap: 0.90
    gather_message: "You swing your axe at the oak tree..."
    fail_message: "You swing but get no logs."
    drops:
        - item_id: oak_logs
          weight: 100
          depletes: false
          message: "You get some {113}oak logs{/}."
    respawn_timer: 14
    deplete_timer: 45
    nest_chance: 256
    respawn_broadcast: "An {name} grows back."
```

Color accepts xterm-256 indices with optional modifiers (`bold`, `dim`, `underline`)
and gradients (`g:196,82`). In ANSI mode, extended colors downgrade to the nearest
ANSI color.

Object interaction (gate, lever — uses `use_interactions:` key):
```yaml
id: iron_gate
name: iron gate
hidden: true
description: "A heavy iron gate set into the north wall."
use_interactions:
  - condition:
      flag: gate_open
      value: true
      not: true
    message: "You push the heavy iron gate open."
    action:
      set_flags:
        gate_open: true
```

Decorative object (no behavior keys — just a name/description):
```yaml
id: lumby_fountain
name: town fountain
description: "Clear water sparkles in the sunlight."
```

Talk object (NPC conversations — uses `talk:` key):
```yaml
id: tool_shed
name: Tool Shed
description: "A small shed with an open window."
talk:
    nodes:
        start:
            message: "\"Welcome to the tool shed!\""
            options:
                - text: "\"What do you have?\""
                  goto: shop
                - text: "\"Goodbye.\""
                  end: true
```

See the [Talk section of behaviors](behaviors.md#talk-dialog-trees) for the full
dialog tree format. See [Stealable Objects](#stealable-objects) for theft mechanics.

---

## Use Interactions

Objects can define `use_interactions` to handle when a player uses a specific item on the object. Each interaction can check conditions, show a message, and execute actions — using the same condition and action primitives as the talk system.

Entries are checked top-to-bottom; the first match with a passing condition wins.

Simple message (no action):
```yaml
id: anvil
name: anvil
use_interactions:
  - item_id: silver_bar
    message: "You should use this with a mold at a furnace."
  - item_id: gold_bar
    message: "You should use this with a mold at a furnace."
```

Puzzle interaction (take item, set flag):
```yaml
id: crystal_slot
name: crystal slot
use_interactions:
  - item_id: crystal_key
    condition:
      flag: crystal_inserted
    message: "The crystal key is already in the slot."
  - item_id: crystal_key
    message: "You insert the crystal key into the slot. It clicks into place."
    action:
      take_item: crystal_key
      set_flags:
        crystal_inserted: true
```

Quest item exchange:
```yaml
use_interactions:
  - item_id: ancient_scroll
    condition:
      player_flag: quest_started
    message: "You place the scroll on the pedestal. The door rumbles open!"
    action:
      take_item: ancient_scroll
      set_player_flags:
        quest_complete: true
      set_flags:
        temple_door_open: true
```

### UseInteraction Fields

| Field       | Type       | Description                                      |
| ----------- | ---------- | ------------------------------------------------ |
| `item_id`   | string     | Item ID that triggers this interaction            |
| `condition` | Condition  | Optional condition (same as exits/talk/use_interactions)    |
| `message`   | string     | Message shown to the player                       |
| `action`    | NodeAction | Optional actions (same as talk node actions)      |

### Available Actions (same as talk)

| Field              | Type           | Description                        |
| ------------------ | -------------- | ---------------------------------- |
| `set_flags`        | map[string]any | Set world flags (shared)           |
| `set_player_flags` | map[string]any | Set player flags (per-character)   |
| `give_item`        | string         | Give an item to inventory          |
| `take_item`        | string         | Remove an item from inventory      |
| `teleport`         | int            | Move player to a room ID           |
| `heal`             | int            | Restore hitpoints                  |

### Available Conditions (same as exits/talk)

| Field         | Description                      |
| ------------- | -------------------------------- |
| `flag`        | World flag check                 |
| `player_flag` | Per-character flag check         |
| `has_item`    | Inventory item check             |
| `value`       | Expected value for flag checks   |
| `not`         | Invert the condition             |
| `all_of`      | All sub-conditions must pass     |
| `any_of`      | Any sub-condition must pass      |

---

## Stealable Objects

Objects can be stealable via the `steal` command. These use the same drop table system as mobs and searches.

```yaml
id: market_stall
name: Market Stall
description: "A wooden stall piled with food and sundries."
steal_table: market_stall_steal
steal_level: 5
steal_xp: 12
steal_speed: 5
guard_mob: guard
```

| Field         | Description                                      |
| ------------- | ------------------------------------------------ |
| `steal_table` | Drop table ID for loot when stealing             |
| `steal_level` | Required thieving level                          |
| `steal_xp`    | XP awarded per successful steal                  |
| `steal_speed` | Ticks per steal attempt (base wait)              |
| `guard_mob`   | Mob def ID that guards this object (watches it)  |

When `guard_mob` is set, a mob with that def ID in the same room watches the object
on a tick-based cycle (8 ticks watching, 4 ticks looking away). While the guard is
watching, steal success chance is halved and failures trigger a confrontation dialog.

Use the `sneak` command to see guard watch state changes in real time.

---