Skip to content

Conversation

@wjt
Copy link
Member

@wjt wjt commented Jan 6, 2026

Since 494fec1 ("Player Hook: Shatter string when player is defeated"), the player's mode changing to DEFEATED causes a call to PlayerHook.shatter_string(). If the player was not currently throwing a string - for example, if they were caught by a guard or by the void while not grappling - this would crash:

SCRIPT ERROR: Invalid access to property or key 'points' on a base object of type 'Nil'.
      at: PlayerHook.tessellate_string (res://scenes/game_elements/characters/player/components/player_hook.gd:213)
      GDScript backtrace (most recent call first):
          [0] tessellate_string (res://scenes/game_elements/characters/player/components/player_hook.gd:213)
          [1] shatter_string (res://scenes/game_elements/characters/player/components/player_hook.gd:220)
          [2] _on_player_mode_changed (res://scenes/game_elements/characters/player/components/player_hook.gd:109)
          [3] _set_mode (res://scenes/game_elements/characters/player/components/player.gd:111)
          [4] defeat (res://scenes/game_elements/characters/player/components/player.gd:242)
          [5] _on_player_detected (res://scenes/game_logic/stealth_game_logic.gd:16)
          [6] _update_player_awareness (res://scenes/game_elements/characters/enemies/guard/components/guard.gd:204)
          [7] _process (res://scenes/game_elements/characters/enemies/guard/components/guard.gd:165)

Add a check in the mode_changed callback: only call shatter_string() if there is a string to shatter.

Fixes #1798

Since 494fec1 ("Player Hook: Shatter string
when player is defeated"), the player's mode changing to DEFEATED causes a call
to PlayerHook.shatter_string(). If the player was not currently throwing a
string - for example, if they were caught by a guard or by the void while not
grappling - this would crash:

    SCRIPT ERROR: Invalid access to property or key 'points' on a base object of type 'Nil'.
          at: PlayerHook.tessellate_string (res://scenes/game_elements/characters/player/components/player_hook.gd:213)
          GDScript backtrace (most recent call first):
              [0] tessellate_string (res://scenes/game_elements/characters/player/components/player_hook.gd:213)
              [1] shatter_string (res://scenes/game_elements/characters/player/components/player_hook.gd:220)
              [2] _on_player_mode_changed (res://scenes/game_elements/characters/player/components/player_hook.gd:109)
              [3] _set_mode (res://scenes/game_elements/characters/player/components/player.gd:111)
              [4] defeat (res://scenes/game_elements/characters/player/components/player.gd:242)
              [5] _on_player_detected (res://scenes/game_logic/stealth_game_logic.gd:16)
              [6] _update_player_awareness (res://scenes/game_elements/characters/enemies/guard/components/guard.gd:204)
              [7] _process (res://scenes/game_elements/characters/enemies/guard/components/guard.gd:165)

Add a check in the mode_changed callback: only call shatter_string() if there is
a string to shatter.

Fixes #1798
@wjt wjt requested a review from a team as a code owner January 6, 2026 14:10
@wjt wjt merged commit bdf1790 into main Jan 6, 2026
5 checks passed
@wjt wjt deleted the wjt/don-t-shatter-non-existent-string-when-defeated branch January 6, 2026 14:12
@github-actions
Copy link

github-actions bot commented Jan 6, 2026

Play this branch at https://play.threadbare.game/branches/endlessm/wjt/don-t-shatter-non-existent-string-when-defeated.

(This launches the game from the start, not directly at the change(s) in this pull request.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crash when caught in stealth challenges: player.hook_string.points is null

2 participants