From 7919d7d6cae9c239cb2b7c38518aa8ae6bbdbb33 Mon Sep 17 00:00:00 2001 From: A Man Date: Thu, 2 Apr 2020 18:06:00 +0200 Subject: [PATCH] Add weight for backpacks --- .../R3F_Realism/R3F_Tired/R3F_DoTired.sqf | 52 +++++++++---------- .../R3F_Realism/R3F_Tired/R3F_Tired_Fnct.sqf | 8 +-- .../R3F_Weight/R3F_Weight_Fnct.sqf | 43 +++++++++------ 3 files changed, 57 insertions(+), 46 deletions(-) diff --git a/SQF/dayz_code/external/R3F_Realism/R3F_Tired/R3F_DoTired.sqf b/SQF/dayz_code/external/R3F_Realism/R3F_Tired/R3F_DoTired.sqf index 7e2ad2519..4b1026631 100644 --- a/SQF/dayz_code/external/R3F_Realism/R3F_Tired/R3F_DoTired.sqf +++ b/SQF/dayz_code/external/R3F_Realism/R3F_Tired/R3F_DoTired.sqf @@ -38,15 +38,15 @@ while {true} do { R3F_TIRED_Ratio_Overweight = R3F_TIRED_WEIGHT_RATIO1; } else { R3F_TIRED_Ratio_Overweight = R3F_TIRED_WEIGHT_RATIO2; - }; + }; } else { R3F_TIRED_Ratio_Overweight = R3F_TIRED_WEIGHT_RATIO3; - }; - } else { + }; + } else { R3F_TIRED_Ratio_Overweight = R3F_TIRED_WEIGHT_RATIO4; - }; - - if (alive player) then { + }; + + if (alive player) then { switch (toArray (animationState player) select 5) do { case 112: { R3F_TIRED_Ratio_Position = R3F_TIRED_DOWN_LEVEL; @@ -58,25 +58,24 @@ while {true} do { R3F_TIRED_Ratio_Position = R3F_TIRED_UP_LEVEL; }; }; - - R3F_TIRED_vitesse_de_mon_joueur = [0,0,0] distance velocity player; + + R3F_TIRED_vitesse_de_mon_joueur = [0,0,0] distance velocity player; R3F_TIRED_coeff_mon_elevation_en_z = 0 max ((velocity player select 2) / R3F_TIRED_WEIGHT_CLIMB_FACTOR); - + _posATL = (getPosATL player) select 2; - - - if((vehicle player == player) && (_posATL < 100)) then { - R3F_TIRED_Accumulator = R3F_TIRED_Accumulator - + (R3F_TIRED_POIDS_TOTAL_PLAYER * R3F_TIRED_vitesse_de_mon_joueur * R3F_TIRED_Ratio_Position * R3F_TIRED_WEIGHT_SPEED_RATIO*R3F_TIRED_Ratio_Overweight) + + if ((vehicle player == player) && {_posATL < 100}) then { + R3F_TIRED_Accumulator = R3F_TIRED_Accumulator + + (R3F_TIRED_POIDS_TOTAL_PLAYER * R3F_TIRED_vitesse_de_mon_joueur * R3F_TIRED_Ratio_Position * R3F_TIRED_WEIGHT_SPEED_RATIO*R3F_TIRED_Ratio_Overweight) + (R3F_TIRED_POIDS_TOTAL_PLAYER * R3F_TIRED_coeff_mon_elevation_en_z * R3F_TIRED_WEIGHT_LEVEL2); - + }; - + R3F_TIRED_Accumulator = 0 max (R3F_TIRED_Accumulator - R3F_TIRED_Ratio_Recovery); - + _level = ((R3F_TIRED_Accumulator / R3F_TIRED_BLACKOUT_LEVEL) * 100); _level = 0 max (1 - (_level / 100)); - + #ifdef R3F_TIRED_DEBUG /*hintsilent format["Fatique : %1/%2\nBlack level : %3\nPoids total : %4\n Poids armement : %5", R3F_TIRED_Accumulator, @@ -85,17 +84,17 @@ while {true} do { R3F_TIRED_POIDS_TOTAL_PLAYER, R3F_Weight];*/ #endif - + [_level] call R3F_TIRED_FNCT_Voile_Noir; if (R3F_Weight < 150) then {R3F_TIRED_Accumulator = 0;}; // Reset if player drops most of their gear, so overburden doesn't get stuck on for several minutes after carrying way too much weight. if (R3F_TIRED_Accumulator > R3F_TIRED_BLACKOUT_LEVEL) then { call R3F_TIRED_FNCT_Overburdened; }; - } else { + } else { R3F_TIRED_Accumulator = 0; }; - if (R3F_TIRED_GLOBAL_TIRING - && R3F_TIRED_vitesse_de_mon_joueur > 4 - && R3F_TIRED_Ratio_Recovery > R3F_TIRED_RATIO_RECOVERING + if (R3F_TIRED_GLOBAL_TIRING + && {R3F_TIRED_vitesse_de_mon_joueur > 4} + && {R3F_TIRED_Ratio_Recovery > R3F_TIRED_RATIO_RECOVERING} ) then { R3F_TIRED_Counter_Time= R3F_TIRED_Counter_Time + 1; }; @@ -111,11 +110,11 @@ while {true} do { _level, R3F_Weight, R3F_TIRED_Counter_Time]; - - + + _s call FNC_PrintToRPT; #endif - + if ((R3F_TIRED_Counter_Time > R3F_TIRED_TIME_RECOVERING)) then { R3F_TIRED_Ratio_Recovery = R3F_TIRED_Ratio_Recovery - 1; R3F_TIRED_Counter_Time = 0; @@ -126,4 +125,3 @@ while {true} do { }; //[_voil] call R3F_TIRED_FNCT_Effect_Off; - diff --git a/SQF/dayz_code/external/R3F_Realism/R3F_Tired/R3F_Tired_Fnct.sqf b/SQF/dayz_code/external/R3F_Realism/R3F_Tired/R3F_Tired_Fnct.sqf index e2cd11d29..0fc0110b4 100644 --- a/SQF/dayz_code/external/R3F_Realism/R3F_Tired/R3F_Tired_Fnct.sqf +++ b/SQF/dayz_code/external/R3F_Realism/R3F_Tired/R3F_Tired_Fnct.sqf @@ -15,6 +15,8 @@ FNC_PrintToRPT = { }; R3F_TIRED_FNCT_Voile_Noir = { + private "_level"; + _level = _this select 0; if(_level < R3F_TIRED_SHORTNESS_THRESHOLD ) then{ playSound "heartbeat_1"; @@ -26,7 +28,7 @@ R3F_TIRED_ForceWalk = false; R3F_TIRED_FNCT_Overburdened = { [localize "STR_R3F_WEIGHT_Overburdened",1] call dayz_rollingMessages; - + if (!R3F_TIRED_ForceWalk) then { R3F_TIRED_ForceWalk = true; [] spawn { @@ -37,7 +39,7 @@ R3F_TIRED_FNCT_Overburdened = { if ((abs(_vel select 0)) > 2 || (abs(_vel select 1)) > 2) then { player setVelocity [-(_vel select 0),-(_vel select 1),_vel select 2]; player forceWalk true; - + }; }; uiSleep 0.001; @@ -47,4 +49,4 @@ R3F_TIRED_FNCT_Overburdened = { ["",1] call dayz_rollingMessages; // Clear overburdened message }; }; -}; \ No newline at end of file +}; diff --git a/SQF/dayz_code/external/R3F_Realism/R3F_Weight/R3F_Weight_Fnct.sqf b/SQF/dayz_code/external/R3F_Realism/R3F_Weight/R3F_Weight_Fnct.sqf index e24de68f1..267ae283d 100644 --- a/SQF/dayz_code/external/R3F_Realism/R3F_Weight/R3F_Weight_Fnct.sqf +++ b/SQF/dayz_code/external/R3F_Realism/R3F_Weight/R3F_Weight_Fnct.sqf @@ -9,29 +9,31 @@ along with this program. If not, see . *****************************************************************************/ #include "R3F_WEIGHT_Configuration.sqf" R3F_WEIGHT_FNCT_MakeSingleArray = { - private ["_arr_i","_arr_n", "_arr", "_n", "_nb", "_x"]; + private ["_arr_i","_arr_n", "_arr", "_n", "_nb"]; + _arr_i = (_this select 0) select 0; _arr_n = (_this select 0) select 1; - _arr = []; - + _n = 0; { _nb = _arr_n select _n; - for [{_i = 0}, {_i < _nb}, {_i = _i + 1}] do{ - _arr = _arr + [_x]; + + for "_i" from 1 to _nb do{ + _arr set [count _arr,_x]; }; _n = _n + 1; - - }count _arr_i; - + + } count _arr_i; + _arr; }; R3F_WEIGHT_FNCT_GetItemWeight = { - private ["_arr_class", "_total_weight", "_weight"]; + private ["_arr_class", "_total_weight", "_weight","_bagpack","_type"]; + _arr_class = (_this select 0) + (_this select 1); - if (dayz_onBack != "" && count _this > 2) then { + if (dayz_onBack != "" && {count _this > 2}) then { _arr_class set [count _arr_class, dayz_onBack]; }; _total_weight = 0; @@ -46,21 +48,31 @@ R3F_WEIGHT_FNCT_GetItemWeight = { _weight = getNumber(CfgWeight >> "Magazines" >> _x >> "weight"); _total_weight = _total_weight + _weight; }else{ - + _weight = 0; if(isNumber (configFile >> "cfgMagazines" >> _x >> "weight")) then { _weight = getNumber(configFile >> "cfgMagazines" >> _x >> "weight"); }; - + if(_weight > 0) then { _total_weight = _total_weight + _weight; } else { - // log only if not found - //diag_log format["No R3F weight config for: %1", _x]; - }; + // log only if not found + diag_log format["No R3F weight config for: %1", _x]; + }; }; }; }count _arr_class; + + _bagpack = unitBackpack player; + if (!isNull _bagpack) then { + _type = typeof _bagpack; + if (isclass(CfgWeight >> "Backpacks" >> _type)) then { + _weight = getNumber(CfgWeight >> "Backpacks" >> _type >> "weight"); + _total_weight = _total_weight + _weight; + }; + }; + _total_weight; }; @@ -81,4 +93,3 @@ R3F_WEIGHT_FNCT_GetWeight = { }; _return; }; -