Skip to content

Add bleedout timer recovery - #78

Draft
amsteadrayle wants to merge 10 commits into
diwako:masterfrom
amsteadrayle:timer-regen
Draft

Add bleedout timer recovery#78
amsteadrayle wants to merge 10 commits into
diwako:masterfrom
amsteadrayle:timer-regen

Conversation

@amsteadrayle

Copy link
Copy Markdown
Contributor

No description provided.

Comment thread addons/main/XEH_PREP.hpp Outdated
Comment thread addons/main/XEH_postInit.sqf Outdated
},
[DIK_T, [false, false, false]], false] call CBA_fnc_addKeybind;

player call FUNC(regenBleedout)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, as the function it self is lacking a stop. Either add a check here, or one at the top of the function itself.

Comment thread addons/main/functions/fnc_regenBleedout.sqf Outdated
Comment thread addons/main/functions/fnc_regenBleedout.sqf Outdated
Comment thread addons/main/XEH_postInit.sqf Outdated
},
[DIK_T, [false, false, false]], false] call CBA_fnc_addKeybind;

player call FUNC(regenBleedout)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, as the function it self is lacking a stop. Either add a check here, or one at the top of the function itself.

Comment on lines +18 to +23
[
{
!isNil {malus} && {!(_unit getVariable [QGVAR(unconscious),false])}
},
FUNC(regenBleedout), [_unit]
] call CBA_fnc_waitUntilAndExecute;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@diwako diwako May 28, 2022

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@diwako diwako added this to the 0.7.0 milestone May 28, 2022
@diwako diwako modified the milestones: 0.7.0, ongoing, 0.8.0 May 29, 2022
Comment thread addons/main/XEH_postInit.sqf Outdated
@amsteadrayle

amsteadrayle commented Jun 11, 2022

Copy link
Copy Markdown
Contributor Author

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 setUnconscious. (As far as I can tell)

_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 setUnconscious)

Should I just make a new PR at that point?

@amsteadrayle

Copy link
Copy Markdown
Contributor Author

My implementation is actually wrong anyway. I misinterpreted what _downTime was supposed to be. I need to add a timeLastDowned variable to the player. Side note: The *Time naming convention makes it very confusing to distinguish times and durations, or points in time and lengths of time.

@diwako
diwako marked this pull request as draft May 23, 2025 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants