Skip to content
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

Load sound-triggered traps with more safety #74198

Merged
merged 1 commit into from
Jun 2, 2024

Conversation

RenechCDDA
Copy link
Member

Summary

None

Purpose of change

An enterprising modder was trying to use the character_triggers_trap event for eoc scripting and found out that sound_detect traps didn't actually require a sound threshold to trigger.

Further investigation found that sound_detect is a (rather confusingly named!) vestigial trapfunc used only for initial testing sound-triggered traps. Sound-triggered traps definitely work, and we have an existing trap type (tr_dormant_zombie) which uses them.

Describe the solution

-Delete sound_detect trapfunc and associated trap. These were not encounterable outside of the debug menu and the trapfunc itself did nothing besides verify its function, so this shouldn't impact mods. No migration or save handling was provided (if a save does have them it will delete the trap on load after throwing an error about being unable to find it).

-Add some safety to our loading by throwing errors when invalid sound_thresholds are detected.

-Add dummy_trap function which always counts as triggering when called (thus calling the event bus) for our enterprising modder.
--I had originally added a dummy trap to traps.json as a sort of in-json documentation, but on reflection I found it hypocritical to be adding an unused trap in the same PR I was removing one. Maybe we should separate out the traps documentation from json_info.md and list(just list, not describe) the hardcoded trapfuncs so people can reasonably know they exist?

Describe alternatives you've considered

Actual documentation for traps?

Unit test for sound-triggered traps?

Testing

Game loads, dummy trap calls event bus when stepped on

Additional context

  {
    "type": "trap",
    "id": "tr_dummy_always_triggers",
    "name": "noise test trap",
    "color": "light_cyan",
    "symbol": "_",
    "visibility": 0,
    "avoidance": 99,
    "difficulty": 99,
    "action": "dummy_trap"
  },

@github-actions github-actions bot added [JSON] Changes (can be) made in JSON [C++] Changes (can be) made in C++. Previously named `Code` Fields / Furniture / Terrain / Traps Objects that are part of the map or its features. astyled astyled PR, label is assigned by github actions json-styled JSON lint passed, label assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions labels May 30, 2024
Delete test-only trap function "sound_detect"
Add dummy trap
@RenechCDDA RenechCDDA force-pushed the safer_trap_loading branch from 46a80c5 to 58f5446 Compare May 30, 2024 23:18
src/trap.cpp Show resolved Hide resolved
@dseguin dseguin merged commit c4c9f26 into CleverRaven:master Jun 2, 2024
27 checks passed
@RenechCDDA RenechCDDA deleted the safer_trap_loading branch June 2, 2024 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions [C++] Changes (can be) made in C++. Previously named `Code` Fields / Furniture / Terrain / Traps Objects that are part of the map or its features. [JSON] Changes (can be) made in JSON json-styled JSON lint passed, label assigned by github actions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants