Add bleedout timer recovery - #78
Conversation
| }, | ||
| [DIK_T, [false, false, false]], false] call CBA_fnc_addKeybind; | ||
|
|
||
| player call FUNC(regenBleedout) |
There was a problem hiding this comment.
Needs to check if it's enabled. The setting needs to be marked as needing restart if this is only called from postInit.
It could be possibly be moved to an event handler, but then would need a handle for checking if it's already active.
There was a problem hiding this comment.
That's probably the smart way to do it. Will do shortly.
The way I set it up is (intended) to have it always run, but do nothing if not enabled, to not require a restart to toggle it. But toggling it on-line isn't really important. Changing the coefficient should still be dynamic, right?
There was a problem hiding this comment.
Agreed, as the function it self is lacking a stop. Either add a check here, or one at the top of the function itself.
| }, | ||
| [DIK_T, [false, false, false]], false] call CBA_fnc_addKeybind; | ||
|
|
||
| player call FUNC(regenBleedout) |
There was a problem hiding this comment.
Agreed, as the function it self is lacking a stop. Either add a check here, or one at the top of the function itself.
| [ | ||
| { | ||
| !isNil {malus} && {!(_unit getVariable [QGVAR(unconscious),false])} | ||
| }, | ||
| FUNC(regenBleedout), [_unit] | ||
| ] call CBA_fnc_waitUntilAndExecute; |
There was a problem hiding this comment.
Not really a fan of this, potentially a player never goes down, so this runs all the time. I think a better solution would be introductions for the event when going uncon and getting revived out of uncon.
meaning a new event to listen to, and from there we can start the regeneration. So you do not need to constantly run the regeneration itself in a loop as well. You can just stop it once the regeneration is fully done and wait for the new event to be raised.
There was a problem hiding this comment.
The loop should only be running while their down timer is below the maximum. If a player never goes down or their timer fully recovers, it will stay stuck behind the waitUntilAndExecute. Should that still be avoided, having a potentially endless waitUntilAndExecute?
There's probably a slick way to directly incorporate this in the malus calculation in setUnconscious, so the regen is only calculated when needed.
There was a problem hiding this comment.
There's probably a slick way to directly incorporate this in the malus calculation in setUnconscious, so the regen is only calculated when needed.
Yes. usually it is well to avoid loops if possible. The proposed idea of mine was to add a new CBA event when ever a local unit enters or leaves unconsciousness.
When leaving uncon you either died from bleed out or otherwise, or you were revived and have suffered a malus. When that happens you call the regen function which loops itself until the malus has been removed, the unit was knocked uncon again, or the unit died.
With that the only loop is the lowering of the malus itself and it stops itself under conditions.
Co-authored-by: diwako <diwako@gmail.com>
8e646e2 to
51a0a66
Compare
|
I'm currently reworking this whole thing to calculate the total regen at the same place the malus is calculated. This would undo a lot of the changes made here, including removing the new function and the stuff that comes with it. It boils down to a couple of new lines in _restBleedout = (GVAR(bleedoutTime) - GVAR(bleedOutTimeMalus)) max GVAR(minBleedoutTime);
// new:
private _regen = round(sqrt(2*GVAR(bleedoutRegenCoeff)*(cba_missionTime - _downTime) + _restBleedout^2) - _restBleedout);
_restBleedout = (_restBleedout + _regen) min GVAR(bleedoutTime);(Edit: This is referencing the older Should I just make a new PR at that point? |
|
My implementation is actually wrong anyway. I misinterpreted what |
No description provided.