Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Declare Variables Private (To this script only).
- private ["_allowStaminaRegen","_velocity","_weight","_playerTravelled","_dehydrated","_requirement","_playerStamina","_starving","_playerSitting","_playerStaminaMax"];
- _allowStaminaRegen = false;
- _playerSitting = false;
- // If player is ALIVE, then do.
- if (alive player) then
- {
- _playerEnergized = player getVariable "a3c_playerState_Energized";
- _playerStamina = player getVariable "a3c_playerVar_Stamina";
- _starving = player getVariable "a3c_playerState_Starving";
- _dehydrated = player getVariable "a3c_playerState_Dehydrated";
- _playerTravelled = player getVariable "a3c_playerVar_DistanceTravelled";
- _playerStaminaMax = player getVariable "a3c_playerVar_StaminaMax";
- if (animationState player in ["amovpsitmstpsnonwpstdnon_ground","amovpsitmstpslowwrfldnon","amovpsitmstpsnonwnondnon_ground"]) then
- {
- _playerSitting = true;
- }else{
- _playerSitting = false;
- };
- // Handle Functions (While on Foot) ------------------------------- //
- // If player "vehicle" is player entity (non-vehicular) i.e: if player is having to walk/run/sprint.
- if ((vehicle player) == player) then
- {
- // save player velocity/speed to variable of _velocity.
- _velocity = log(abs(speed player));
- _weight = loadAbs player;
- _playerTravelled = _playerTravelled + _velocity;
- // if player is moving at (greater than or equalto) jogging speed.
- if (_velocity >= 0.86) then
- {
- // if player is moving at (less than) sprinting speed.
- if (_velocity < 1.2) then
- {
- // if player is hungry or dehydrated then do.
- if (_starving or _dehydrated) then
- {
- // PLAYER IS JOGGING & HUNGRY / DEHYDRATED: decrease player stamina at 50% degeneration value of Velocity. Math: (Current Stamina, [Set To], (Current Stamina Value), [Minus], (Current Velocity [Divided by] 2), Unless value is Zero).
- if (isOnRoad player) then
- {
- _playerStamina = (_playerStamina - ((_velocity/4) + (_weight / 1000))) max 0;
- }else{
- _playerStamina = (_playerStamina - ((_velocity/3) + (_weight / 1000))) max 0;
- };
- }else{
- // PLAYER IS JOGGING: decrease player stamina at 25% degeneration value of Velocity. Math: (Current Stamina, [Set To], (Current Stamina Value), [Minus], (Current Velocity [Divided by] 4), Unless value is Zero).
- if (isOnRoad player) then
- {
- _playerStamina = (_playerStamina - ((_velocity/8) + (_weight / 1000))) max 0;
- }else{
- _playerStamina = (_playerStamina - ((_velocity/6) + (_weight / 1000))) max 0;
- };
- };
- }else{
- if (_starving or _dehydrated) then
- {
- // PLAYER IS SPRINTING & HUNGRY / DEHYDRATED: decrease player stamina at 125% degeneration value of Velocity. Math: (Current Stamina, [Set To], (Current Stamina Value), [Minus], (Current Velocity[Multiplied by] 1.25), Unless value is Zero).
- if (isOnRoad player) then
- {
- _playerStamina = (_playerStamina - (_velocity + (_weight / 1000))) max 0;
- }else{
- _playerStamina = (_playerStamina - ((_velocity*1.25) + (_weight / 1000))) max 0;
- };
- }else{
- // PLAYER IS SPRINTING: decrease player stamina at 100% degeneration value of Velocity. Math: (Current Stamina, [Set To], (Current Stamina Value), [Minus], (Current Velocity), Unless value is Zero).
- if (isOnRoad player) then
- {
- _playerStamina = (_playerStamina - ((_velocity/6) + (_weight / 1000))) max 0;
- }else{
- _playerStamina = (_playerStamina - ((_velocity/3) + (_weight / 1000))) max 0;
- };
- };
- };
- }else{
- // If player is walking or stationary.
- _allowStaminaRegen = true;
- };
- }else{
- _allowStaminaRegen = true;
- _playerTravelled = 0;
- };
- if (_playerTravelled > 0) then
- {
- player setVariable ["a3c_playerVar_DistanceTravelled", _playerTravelled, false];
- _requirement = (player getVariable "a3c_playerVar_StaminaMax") * 50;
- if (_playerTravelled >= _requirement) then
- {
- if (player getVariable "a3c_playerVar_StaminaMax" < 100) then
- {
- _playerTravelled = 0;
- player setVariable ["a3c_playerVar_DistanceTravelled", 0, false];
- _playerStaminaMax = _playerStaminaMax + 1;
- player setVariable ["a3c_playerVar_StaminaMax", _playerStaminaMax, false];
- };
- };
- };
- // Handle Functions (24/7) ---------------------------------------- //
- // If player Stamina Reserve greater than Zero, then do.
- if (_playerStamina > 0) then
- {
- // Set Vanilla A3 Fatigue to none.
- player setFatigue 0;
- player enableFatigue false;
- }else{
- player enableFatigue true;
- };
- // If player is walking or stationary and has no fatigue, then do.
- if (_allowStaminaRegen && (getFatigue player) == 0) then
- {
- // If player is STARVING or DEHYDRATED then do.
- if (_starving or _dehydrated) then
- {
- // PLAYER IS RESTING or WALKING but STARVING or DEHYDRATED: Increase player stamina value at 25% of normal regeneration Math: (Current Stamina, [Set To], (Current Stamina Value), [Plus], (Stamina Regeneration Rate [Divided By] <int>), Unless value reaches Variable Cap).
- if (_playerSitting) then
- {
- if (_playerEnergized) then
- {
- _playerStamina = (_playerStamina + (0.525 / 2)) min _playerStaminaMax;
- }else{
- _playerStamina = (_playerStamina + (0.35 / 2)) min _playerStaminaMax;
- };
- }else{
- if (_playerEnergized) then
- {
- _playerStamina = (_playerStamina + (0.525 / 4)) min _playerStaminaMax;
- }else{
- _playerStamina = (_playerStamina + (0.35 / 4)) min _playerStaminaMax;
- };
- };
- }else{
- // PLAYER IS RESTING or WALKING: Increase player stamina value Math: (Current Stamina, [Set To], (Current Stamina Value), [Plus], <int>, Unless value reaches Variable Cap).
- if (_playerSitting) then
- {
- if (_playerEnergized) then
- {
- _playerStamina = (_playerStamina + 0.75) min _playerStaminaMax;
- }else{
- _playerStamina = (_playerStamina + 0.5) min _playerStaminaMax;
- };
- }else{
- if (_playerEnergized) then
- {
- _playerStamina = (_playerStamina + 0.525) min _playerStaminaMax;
- }else{
- _playerStamina = (_playerStamina + 0.35) min _playerStaminaMax;
- };
- };
- };
- };
- player setVariable ["a3c_playerVar_Stamina", _playerStamina, false];
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement