From a3ae1e6aad696f584d138d9363c05dedff136a65 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Sun, 21 Jun 2026 22:19:17 -0400 Subject: feat: safespot system implemented --- .gitignore | 1 + AGENTS.md | 6 +- cmd/mud/main.go | 1 + data/help/automap.yaml | 4 +- data/help/hide.yaml | 15 ++ data/help/map.yaml | 6 +- data/help/map_height.yaml | 10 ++ data/help/map_padding.yaml | 13 ++ data/help/map_width.yaml | 10 ++ data/help/mapheight.yaml | 10 -- data/help/mappadding.yaml | 13 -- data/help/mapwidth.yaml | 10 -- data/help/option.yaml | 2 +- data/help/safespot.yaml | 38 ++++ data/items/ammo/adamant_arrow.yaml | 1 + data/items/ammo/bronze_arrow.yaml | 1 + data/items/ammo/iron_arrow.yaml | 1 + data/items/ammo/mithril_arrow.yaml | 1 + data/items/ammo/rune_arrow.yaml | 1 + data/items/ammo/steel_arrow.yaml | 1 + data/objects/fence_post.yaml | 18 ++ data/objects/rock_outcrop.yaml | 22 +++ data/objects/simple_rock.yaml | 18 ++ data/objects/tutorial_lever.yaml | 22 +++ data/rooms/town/4.yaml | 10 +- internal/combat/formulas.go | 26 +-- internal/game/action.go | 1 + internal/game/action_state.go | 3 + internal/game/cmd_attack.go | 88 ++++++--- internal/game/cmd_hide.go | 171 ++++++++++++++++++ internal/game/cmd_look.go | 46 ++++- internal/game/cmd_map.go | 6 +- internal/game/cmd_move.go | 8 + internal/game/cmd_option.go | 8 + internal/game/cmd_registry.go | 4 + internal/game/cmd_score.go | 2 +- internal/game/cmd_stats.go | 6 +- internal/game/core_login_account.go | 29 ++- internal/game/game.go | 18 ++ internal/game/sys_combat.go | 3 + internal/game/sys_safespot.go | 330 ++++++++++++++++++++++++++++++++++ internal/object/item.go | 1 + internal/object/object.go | 29 ++- internal/player/player.go | 8 +- internal/player/store.go | 4 - internal/world/mob.go | 85 +++++---- internal/world/objects.go | 4 + worldbuilding_guide/behaviors.md | 2 +- worldbuilding_guide/hidden_objects.md | 12 ++ worldbuilding_guide/mobs.md | 1 + worldbuilding_guide/objects.md | 109 +++++++++++ 51 files changed, 1082 insertions(+), 157 deletions(-) create mode 100644 data/help/hide.yaml create mode 100644 data/help/map_height.yaml create mode 100644 data/help/map_padding.yaml create mode 100644 data/help/map_width.yaml delete mode 100644 data/help/mapheight.yaml delete mode 100644 data/help/mappadding.yaml delete mode 100644 data/help/mapwidth.yaml create mode 100644 data/help/safespot.yaml create mode 100644 data/objects/fence_post.yaml create mode 100644 data/objects/rock_outcrop.yaml create mode 100644 data/objects/simple_rock.yaml create mode 100644 data/objects/tutorial_lever.yaml create mode 100644 internal/game/cmd_hide.go create mode 100644 internal/game/sys_safespot.go diff --git a/.gitignore b/.gitignore index 38c7192..1cb07df 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ thoi .npm/ .local/ .config/ +.opencode/ node_modules/ diff --git a/AGENTS.md b/AGENTS.md index 00ae2cc..8b65314 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -405,9 +405,9 @@ Account-wide options set via `option `. Stored in account YAML, sh | `depletion` | bool | false | Show depletion timers | | `despawn` | bool | false | Show ground item despawn timers | | `color` | string | "xterm256" | none/ansi/xterm256 — color output mode | -| `mapwidth` | int | 30 | Map viewport width | -| `mapheight` | int | 20 | Map viewport height | -| `mappadding` | string | "none" | none/x/y/xy — blank-row stripping | +| `map_width` | int | 30 | Map viewport width | +| `map_height` | int | 20 | Map viewport height | +| `map_padding` | string | "none" | none/x/y/xy — blank-row stripping | | `automap` | bool | false | Auto-show map after moving | | `queue_silently` | bool | true | Suppress queue messages | | `room_desc_width` | int | 70 | Room desc line wrap width | diff --git a/cmd/mud/main.go b/cmd/mud/main.go index c51cc6e..e9d0aed 100644 --- a/cmd/mud/main.go +++ b/cmd/mud/main.go @@ -57,6 +57,7 @@ func main() { g.SneakTick() g.FarmTick() g.BuffTick() + g.SafespotTick() return true }) diff --git a/data/help/automap.yaml b/data/help/automap.yaml index 32b84cb..3cd1a2f 100644 --- a/data/help/automap.yaml +++ b/data/help/automap.yaml @@ -9,5 +9,5 @@ description: | When enabled, the map command output is printed after each room movement, so you always know where you are. - Map size and padding are controlled by the mapwidth, - mapheight, and mappadding options. + Map size and padding are controlled by the map_width, + map_height, and map_padding options. diff --git a/data/help/hide.yaml b/data/help/hide.yaml new file mode 100644 index 0000000..eb2d27a --- /dev/null +++ b/data/help/hide.yaml @@ -0,0 +1,15 @@ +name: "hide" +category: "Skills" +description: | + Hide behind a safespot object to block melee attacks. + + Usage: hide + hide behind + safespot + + Hiding takes 1 tick out of combat or 4 ticks while fighting. If a mob + hits you during repositioning in combat, the hide attempt fails. + + Leave cover with: unhide (or unsafespot) + + See also: help safespot, help combat diff --git a/data/help/map.yaml b/data/help/map.yaml index 3b4917a..7ca03a2 100644 --- a/data/help/map.yaml +++ b/data/help/map.yaml @@ -9,11 +9,11 @@ description: | centered on your current location. You are shown as @. Map size is controlled by: - option mapwidth (default 30) - option mapheight (default 20) + option map_width (default 30) + option map_height (default 20) Padding/trimming is controlled by: - option mappadding + option map_padding none - strip blank lines + left-trim (default) x - strip blank lines only y - left-trim only diff --git a/data/help/map_height.yaml b/data/help/map_height.yaml new file mode 100644 index 0000000..32daf0a --- /dev/null +++ b/data/help/map_height.yaml @@ -0,0 +1,10 @@ +name: "map_height" +category: "Options" +description: | + Height of the full map display in characters. + + Type: integer + Default: 20 + + Controls how many rows tall the map command + output is. Must be at least 5. diff --git a/data/help/map_padding.yaml b/data/help/map_padding.yaml new file mode 100644 index 0000000..7772226 --- /dev/null +++ b/data/help/map_padding.yaml @@ -0,0 +1,13 @@ +name: "map_padding" +category: "Options" +description: | + Controls how the map command trims its output. + + Type: string + Default: none + Values: none, x, y, xy + + none - Strip blank rows and left-trim whitespace + x - Strip blank rows only (horizontal trim) + y - Left-trim whitespace only (vertical trim) + xy - No trimming (raw output) diff --git a/data/help/map_width.yaml b/data/help/map_width.yaml new file mode 100644 index 0000000..3957bed --- /dev/null +++ b/data/help/map_width.yaml @@ -0,0 +1,10 @@ +name: "map_width" +category: "Options" +description: | + Width of the full map display in characters. + + Type: integer + Default: 30 + + Controls how many columns wide the map command + output is. Must be at least 5. diff --git a/data/help/mapheight.yaml b/data/help/mapheight.yaml deleted file mode 100644 index ee3920b..0000000 --- a/data/help/mapheight.yaml +++ /dev/null @@ -1,10 +0,0 @@ -name: "mapheight" -category: "Options" -description: | - Height of the full map display in characters. - - Type: integer - Default: 20 - - Controls how many rows tall the map command - output is. Must be at least 5. diff --git a/data/help/mappadding.yaml b/data/help/mappadding.yaml deleted file mode 100644 index 201ef53..0000000 --- a/data/help/mappadding.yaml +++ /dev/null @@ -1,13 +0,0 @@ -name: "mappadding" -category: "Options" -description: | - Controls how the map command trims its output. - - Type: string - Default: none - Values: none, x, y, xy - - none - Strip blank rows and left-trim whitespace - x - Strip blank rows only (horizontal trim) - y - Left-trim whitespace only (vertical trim) - xy - No trimming (raw output) diff --git a/data/help/mapwidth.yaml b/data/help/mapwidth.yaml deleted file mode 100644 index 7e372ef..0000000 --- a/data/help/mapwidth.yaml +++ /dev/null @@ -1,10 +0,0 @@ -name: "mapwidth" -category: "Options" -description: | - Width of the full map display in characters. - - Type: integer - Default: 30 - - Controls how many columns wide the map command - output is. Must be at least 5. diff --git a/data/help/option.yaml b/data/help/option.yaml index 9fdcf7f..75b1794 100644 --- a/data/help/option.yaml +++ b/data/help/option.yaml @@ -15,7 +15,7 @@ description: | Examples: option tinymap off option color ansi - option mapwidth 50 + option map_width 50 Use help