Skip to content

Conversation

@Shinthoras0815
Copy link
Contributor

pass both a source Thing and a source_string because some damage sources are not backed by a valid Thing (e.g., environment, script/command, power effects)

Propagates damage source info through spells, shots, and powers.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds damage source tracking to the Lua OnApplyDamage hook by introducing two new parameters: a source Thing and a source string. This enables Lua scripts to identify what caused damage, whether it's another thing (like a creature, trap, or object) or an environmental/system source (like lava, powers, or commands).

Changes:

  • Extended apply_damage_to_thing and related functions with source Thing and source string parameters
  • Added caster_thing_idx field to CastedSpellData structure to track spell casters
  • Implemented default_src_string helper function to generate fallback source descriptions
  • Updated Lua integration to pass source information to OnApplyDamage callback
  • Updated all call sites across the codebase to provide source information

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
src/thing_stats.h Added source parameters to apply_damage_to_thing function signature
src/thing_stats.c Implemented default_src_string helper and updated apply_damage_to_thing to track source
src/thing_shots.c Updated shot damage calls to pass damage source (parent thing)
src/thing_list.c Updated electricity damage to pass source thing
src/thing_effects.c Updated explosion and poison cloud damage to pass source thing
src/thing_creature.h Added source parameters to damage and spell effect function signatures
src/thing_creature.c Updated spell system to track caster thing in spell slots and pass source through damage chains
src/power_process.c Updated power-based damage to use descriptive source strings
src/main.cpp Updated physical force damage to include source string (with minor whitespace cleanup)
src/magic_powers.c Updated slap and spell power damage to include source information
src/lua_triggers.h Updated Lua trigger signature to include source parameters
src/lua_triggers.c Implemented passing of source thing and string to Lua OnApplyDamage callback
src/console_cmd.c Updated console command spells to include descriptive source strings
src/creature_states_pray.c Updated prayer spell application to pass INVALID_THING as source
src/creature_control.h Added caster_thing_idx field to CastedSpellData structure
config/fxdata/lua/triggers/Builtins.lua Updated Lua OnApplyDamage signature and documentation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@PieterVdc
Copy link
Member

for the string maybe go with an enum instead so it's a fixed list of possible values, that way said values can also be documented in the lua files

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@Shinthoras0815 Shinthoras0815 marked this pull request as ready for review January 27, 2026 17:04
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.

2 participants