-
Notifications
You must be signed in to change notification settings - Fork 277
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
feat: JSONize some trap features #3941
Conversation
The Autofix app has automatically formatted this Pull Request. If you edit your PR on web UI, you can ignore this message.
If you don't do this, your following work will be based on the old commit, and cause MERGE CONFLICT. |
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.
Looks good, but could we document the JSON changes?
Oh yeah I knew I was forgetting something. Do we even have documentation for trap data...? |
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.
well, if the JSON docs for traps are missing then it'd be better as a separate PR.
Purpose of change
The continues the work started with #3939 to improve trap-related code and add some more eventually. WIP for now.
Describe the solution
C++ changes:
trigger_items
JSON intrap::load
. Uses the same format asdrops
, instead being items that spawn when the trap is triggered (as opposed to disarmed likedrops
).trap::trigger_aftermath
. This is used to provide final cleanup for traps, in particular dropping any items on trigger defined in the trap JSON'strigger_items
section.true
to usetrigger_aftermath
in them, and removed most hardcoded instances of spawning items or callingremove_trap
in them. The random chance of dropping ammo intrapfunc::crossbow
, and chance of spears breaking intrapfunc::pit_spikes
andtrapfunc::pit_glass
were also kept special-cased in the function since not yet added totrigger_items
. Meanwhile,trapfunc::beartrap
,trapfunc::snare_light
, andtrapfunc::snare_heavy
still use the whole "trap is removed early and item is only spawned when the victim is freed" thing, but they still have support for trap cleanup effects if desired.remove_on_trigger
bool. If present in a trap's JSON, it will remove the trap whentrigger_aftermath
applies, so whether any given trap effect is single-use or reusable is fully JSONized (barring stuff like pits turning into other pits, sinkholes converting into pits, and other interactions with trap-conversion or terrain alteration).trapfunc::sinkhole
so that successfully grappling out of it returns without converting the trap into a pit or other standard cleanup, so that it doesn't spawn a pit in a different tile without leaving the sinkhole still intact.JSON changes:
trigger_items
, with comments pointing out any case where something is still hardcoded in.remove_on_trigger
to all relevant traps.Describe alternatives you've considered
trigger_items
, on the basis that it already does this 90% of the time anyway.drops
todisarm_items
for clarity?Testing
Additional context
Support for pipe shotgun traps to be added eventually.
Checklist