-
Notifications
You must be signed in to change notification settings - Fork 97
Add damage source info to Lua apply damage hook #4510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add damage source info to Lua apply damage hook #4510
Conversation
Propagates damage source info through spells, shots, and powers.
There was a problem hiding this 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_thingand related functions with source Thing and source string parameters - Added
caster_thing_idxfield toCastedSpellDatastructure to track spell casters - Implemented
default_src_stringhelper function to generate fallback source descriptions - Updated Lua integration to pass source information to
OnApplyDamagecallback - 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.
|
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 |
There was a problem hiding this 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.
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)