Fixed voice line and randomised Hazard Damage interval#860
Fixed voice line and randomised Hazard Damage interval#860jimsworld wants to merge 47 commits intoprofezzorn:masterfrom
Conversation
First commit. This file is the most up to date version since our last PM.
Removed unnecessary lowbattery function.
- reduced indentation and increased readability
- Added a list of instance variables to track timers. The remaining timers will be implemented properly next. - Added a new method to HEVTimer, expired(), to check if a timer has expired. - Redone the Clash logic to utilise the new HEVTimer class and respect the Debounce period. - Removed logs and cleaned up Clash function. - Removed CLASH_DEBOUNCE_MS from hev.h to hev_config.h. Renamed to HEV_CLASH_DEBOUNCE_MS. Default is 300ms.
- Removed expired() method and reworked check() - Cleaned up the Clash function to account for the newer check() method
- Added a new method in HEVTimer to account for the hazarddecrease() function - The new HEVTimer method is called hazard_sequence() - It adheres and controls the timing for the delay before hazard damage then how frequent damage is applied - By default, the delay is set to 6s to allow for the voice line to finish then damage is applied every 1s - Damage per second will improved in a future update with random values per per damage tick
- Added new method called ready() to check if a specified time interval has elapsed since the timer started. - Added checks on button presses to ensure the health_increase_timer and armor_increase_timer are started and reset correctly.
- When health and armor was at 100, increasing briefly allowed to go up to 101 before capping to 100. - This was fixed by reordering to check if capped before increasing. - Made the HEVTimer code more consise and added comments.
- Made ammendments based on latests reviews. - Added more comments for clarity. - Updated HEVTimer to be more consise and easier to use.
- Renamed all timers by prefixing with timer_ for clarity.
- Renamed HEVTimer to HEVTimerBase.
- Created new HEVTimerHazard subclass for hazard-specific timing:
1. HEVTimerBase - Handles basic interval timing with:
- Tracking active state
- Start time
- Simple interval checking
- Basic configuration
2. HEVTimerHazard - Extends HEVTimerBase for the specific hazard timing needs:
- Adds next_tick_ for drift-free recurring events
- Adds delay_ for initial grace periods
- The specialized hazard_sequence() method
- This fixed the persistent stun02.wav issue used by hazards. - Also removed comment bloat in Clash function.
- This class is no longer used, as the hazard delay logic has been refactored into HazardDecrease().
- Now provides a comprehensive overview of the HEV suit's functionality.
- Made terminlogy more consistent. - Added new EFFECTS. - Updated top comment detailing how Minor and Major voice feedback works.
- added #ifndef and #endif to top defines. - made else statements more readable. - removed redundant .done() function and calls, it was only used once in HazardDecrease. - replaced with if (!timer_hazard_delay_.running()).
- Rejigged DoDamage() to accept a damage type parameter. - Added DAMAGE_HAZARD and DAMAGE_PHYSICAL constants for clarity. - Updated calls to DoDamage() to specify the damage type. - Added previous_health and previous_armor to help track death sound and armor compromised so they play reliably.
- Removed the 'health at 0' condition preventing armor_readout from playing.
- Hazard Damage no longer limited to 1s intervals.
|
|
||
| void configure(uint32_t interval) { interval_ = interval; } | ||
| void configure_random(uint32_t min_ms, uint32_t max_ms) { | ||
| interval_ = min_ms + random(max_ms - min_ms + 1); |
There was a problem hiding this comment.
This selects an interval during startup, that's probably not what you want.
There was a problem hiding this comment.
I thought it was best to keep timing related stuff in the HEVTimer.
Is it not randomising in the HazardDecrease method? I've made a change there by adding 2 new parameters. I've tested it and it seems to trigger damage randomly between 1 - 4s, which is what I have min and max ms set as currently.
It was never limited to 1s intervals. |
You're right, this was always configurable. |
armor_compromised**.wav was not playing due to a tiny oversight which checked if Health == 0 before playing. I've removed this check so that it fires correctly now.
(Commit message incorrectly addresses issue as "armor_readout". Ignore this.)
Hazard Damage no longer limited to 1s intervals. Can be customised between min & max milliseconds.