Jump to content

Health Regen for Epoch


webbie

Recommended Posts

Hi all,

All credits due to @He-Man for his usual brilliant scripting and  community support.

Here is a bit of code you can add to epoch to allow for Health Regen when your Thirst and Hunger at at a certain level.
Add this to epoch_code/compile/setup/masterLoop/Event3.sqf at the bottom and dont remove the code above.

But setdamage will need a BE-Filter for sure!

Quote

_ReduceHealth = 0; if (EPOCH_playerThirst > 250) then { _ReduceHealth = _ReduceHealth + EPOCH_playerThirst*0.00001; }; if (EPOCH_playerHunger > 500) then { _ReduceHealth = _ReduceHealth + EPOCH_playerHunger*0.00001; }; _highestDMG = damage player; _alldmg = ((getAllHitPointsDamage player) param [2,[]]); { _currentDMG = _x; if (_currentDMG > _highestDMG) then{ _highestDMG = _currentDMG; }; } forEach _alldmg; if (_highestDMG > 0) then { _MaxNewDmg = (_highestDMG - _ReduceHealth) max 0; player setdamage ((damage player) min _MaxNewDmg); { player setHitIndex [_foreachindex,_x min _MaxNewDmg]; } foreach _alldmg; };

My values are set to 80% and this is how it looks in mine.
 

Quote

// runs every 15 seconds
if !(_prevEquippedItem isEqualTo EPOCH_equippedItem_PVS) then {
    _prevEquippedItem = EPOCH_equippedItem_PVS;
    EPOCH_equippedItem_PVS remoteExec ["EPOCH_server_equippedItem",2];
};
// force update
if (_forceUpdate || EPOCH_forceUpdate) then {
    _forceUpdate = false;
    EPOCH_forceUpdate = false;
    EPOCH_forceUpdateNow = false;
    call _fnc_forceUpdate;
};

//HeMan health regen values are for 90%
_ReduceHealth = 0;
if (EPOCH_playerThirst > 1800) then {
    _ReduceHealth = _ReduceHealth + EPOCH_playerThirst*0.00001;
};
if (EPOCH_playerHunger > 3600) then {
    _ReduceHealth = _ReduceHealth + EPOCH_playerHunger*0.00001;
};
_highestDMG = damage player;
_alldmg = ((getAllHitPointsDamage player) param [2,[]]);
{
    _currentDMG = _x;
    if (_currentDMG > _highestDMG) then{
        _highestDMG = _currentDMG;
    };
} forEach _alldmg;
if (_highestDMG > 0) then {
    _MaxNewDmg = (_highestDMG - _ReduceHealth) max 0;
    player setdamage ((damage player) min _MaxNewDmg);
    {
        player setHitIndex [_foreachindex,_x min _MaxNewDmg];
    } foreach _alldmg;
};
 

Ive tested this and it works very well.
Also see below for a table reflecting values I calculated to work out the hunger and thirst values.
image.png.d9babaf95bbbeed3cd59b20c2c71f6e3.png

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Discord

×
×
  • Create New...