Browse Source

Tick progress 1 per second, duration gvar, variable progress size

m3ales 4 years ago
parent
commit
919a07ce69

+ 2 - 0
addons - Copy/RD501_Main/XEH_postinit.sqf

@@ -50,6 +50,8 @@ rd501_medical_ccp_building = "Land_Medevac_house_V1_F";
 rd501_medical_ccp_bandage_treatmentTime = 1;
 rd501_medical_ccp_stitch_treatmentTime = 1;
 rd501_medical_ccp_classes = ["Land_Medevac_house_V1_F"];
+rd501_medical_ccp_stitchDurationSeconds = 10;
+rd501_medical_ccp_bandageDurationSeconds = 10;
 
 ["rd501_medical_ccp_deployCCPLocal", {
 	_this call rd501_fnc_deployCCPLocal;

+ 6 - 3
addons - Copy/RD501_Main/functions/medical_ccp/fnc_bandageAllNearbyCCP.sqf

@@ -68,8 +68,10 @@ private _condition = {
 };
 
 if(_origin getVariable ["rd501_medical_ccp_bandageProgress", -1] == -1) then {
+    private _bandageDuration = ((count _nearbyPatients) * rd501_medical_ccp_bandageDurationSeconds);
     _origin setVariable ["rd501_medical_ccp_bandageProgress", 0, true];
     _origin setVariable ["rd501_medical_ccp_bandageMembers", [player], true];
+    _origin setVariable ["rd501_medical_ccp_stitchProgressComplete", _bandageDuration, true];
 }
 else
 {
@@ -83,17 +85,18 @@ else
         params ["_args", "_handle"];
         _args params ["_healer", "_nearbyPatients", "_origin"];
         _progress = _origin getVariable ["rd501_medical_ccp_bandageProgress", -1];
-        if(_progress > 100 || _progress < 0) exitWith {
+        _progressComplete = _origin getVariable ["rd501_medical_ccp_bandageProgressComplete", 100];
+        if(_progress >= _progressComplete || _progress < 0) exitWith {
             [_handle] call CBA_fnc_removePerFrameHandler;
         };
         if!(_healer getVariable ["ACE_Unconscious", false]) exitWith {
             ["rd501_medical_ccp_incrementBandage",[_origin, _healer]] call CBA_fnc_serverEvent;
         };
     }, 
-    0.5,
+    1,
     _args
 ] call CBA_fnc_addPerFrameHandler;
 
 [_healer, "AinvPknlMstpSnonWnonDr_medic5", 0] call ace_common_fnc_doAnimation;
 
-["rd501_medical_ccp_bandageProgress", _origin, _args, _onFinish, _onFailure, "Bandaging All Patients Inside CCP", _condition] call rd501_fnc_valueProgressBar;
+["rd501_medical_ccp_bandageProgress", "rd501_medical_ccp_bandageProgressComplete", _origin, _args, _onFinish, _onFailure, "Bandaging All Patients Inside CCP", _condition] call rd501_fnc_valueProgressBar;

+ 1 - 1
addons - Copy/RD501_Main/functions/medical_ccp/fnc_incrementBandageProgress.sqf

@@ -16,5 +16,5 @@
 params["_origin", "_healer"];
 _progress = _origin getVariable["rd501_medical_ccp_bandageProgress", -1];
 if(_progress >= 0) then {
-	_origin setVariable["rd501_medical_ccp_bandageProgress", _progress + 2.5, true];
+	_origin setVariable["rd501_medical_ccp_bandageProgress", _progress + 1, true];
 };

+ 1 - 1
addons - Copy/RD501_Main/functions/medical_ccp/fnc_incrementStitchProgress.sqf

@@ -16,5 +16,5 @@
 params["_origin", "_healer"];
 _progress = _origin getVariable["rd501_medical_ccp_stitchProgress", -1];
 if(_progress >= 0) then {
-	_origin setVariable["rd501_medical_ccp_stitchProgress", _progress + 2.5, true];
+	_origin setVariable["rd501_medical_ccp_stitchProgress", _progress + 1, true];
 };

+ 6 - 17
addons - Copy/RD501_Main/functions/medical_ccp/fnc_stitchAllWoundsNearbyCCP.sqf

@@ -13,21 +13,6 @@
  *
  * Public: No
  */
-/*
- * Author: M3ales
- *
- * Arguments:
- * Healer
- * Origin To Search from
- * Radius To Search Around for People
- * Return Value:
- * Nothing
- *
- * Example:
- * [player, cursorTarget] call rd501_fnc_stitchAllNearbyCCP
- *
- * Public: No
- */
 
 params["_healer", "_origin", "_radius"];
 
@@ -67,6 +52,7 @@ private _onFailure = {
     if(count _stitchers <= 1) then {
         _building setVariable ["rd501_medical_ccp_stitchProgress", -1, true];
         _building setVariable["rd501_medical_ccp_stitchMembers", [], true];
+        _progressComplete = _building setVariable ["rd501_medical_ccp_stitchProgressComplete", 100];
     }
     else
     {
@@ -84,8 +70,10 @@ private _condition = {
 };
 
 if(_origin getVariable ["rd501_medical_ccp_stitchProgress", -1] == -1) then {
+    private _stitchDuration = ((count _nearbyPatients) * rd501_medical_ccp_stitchDurationSeconds);
     _origin setVariable ["rd501_medical_ccp_stitchProgress", 0, true];
     _origin setVariable ["rd501_medical_ccp_stitchMembers", [player], true];
+    _origin setVariable ["rd501_medical_ccp_stitchProgressComplete", _stitchDuration, true];
 }
 else
 {
@@ -99,7 +87,8 @@ else
         params ["_args", "_handle"];
         _args params ["_healer", "_nearbyPatients", "_origin"];
         _progress = _origin getVariable ["rd501_medical_ccp_stitchProgress", -1];
-        if(_progress > 100 || _progress < 0) exitWith {
+        _progressComplete = _origin getVariable ["rd501_medical_ccp_stitchProgressComplete", 100];
+        if(_progress >= _progressComplete || _progress < 0) exitWith {
             [_handle] call CBA_fnc_removePerFrameHandler;
         };
         if!(_healer getVariable ["ACE_Unconscious", false]) exitWith {
@@ -112,4 +101,4 @@ else
 
 [_healer, "AinvPknlMstpSnonWnonDr_medic5", 0] call ace_common_fnc_doAnimation;
 
-["rd501_medical_ccp_stitchProgress", _origin, _args, _onFinish, _onFailure, "Stitching All Patients Inside CCP", _condition] call rd501_fnc_valueProgressBar;
+["rd501_medical_ccp_stitchProgress", "rd501_medical_ccp_stitchProgressComplete",_origin, _args, _onFinish, _onFailure, "Stitching All Patients Inside CCP", _condition] call rd501_fnc_valueProgressBar;

+ 6 - 4
addons - Copy/RD501_Main/functions/medical_ccp/fnc_valueProgressBar.sqf

@@ -5,7 +5,8 @@
  * Finish/Failure/Conditional are all passed [_args, _elapsedTime, _totalTime, _errorCode]
  *
  * Arguments:
- * 0: Progress Variable Func: 0-100 representation of how complete the bar should be.
+ * 0: Progress Variable: representation of how complete the bar should be.
+ * 0: Progress Complete Variable: representation of when the bar should be considered 'complete', must be larger than progressVar value.
  * 1: Arguments, passed to condition, fail and finish <ARRAY>
  * 2: On Finish: Code called or STRING raised as event. <CODE, STRING>
  * 3: On Failure: Code called or STRING raised as event. <CODE, STRING>
@@ -17,7 +18,7 @@
  * None
  *
  * Example:
- * ["rd501_medical_ccp_stitchProgress", [], {Hint "Finished!"}, {hint "Failure!"}, "My Title"] call rd501_fnc_valueProgressBar
+ * ["rd501_medical_ccp_stitchProgress", "rd501_medical_ccp_stitchProgressComplete", [], {Hint "Finished!"}, {hint "Failure!"}, "My Title"] call rd501_fnc_valueProgressBar
  *
  * Public: Yes
  */
@@ -47,6 +48,7 @@ _ctrlPos set [1, ((0 + 29 * ace_common_settingProgressBarLocation) * ((((safezon
     (_this select 0) params ["_progressVar", "_progressCompleteVar", "_args", "_onFinish", "_onFail", "_condition", "_player", "_building", "_exceptions"];
 
     private _progress = _building getVariable[_progressVar, -1];
+    private _progressComplete = _building getVariable[_progressCompleteVar, 100];
     private _errorCode = -1;
 
     // this does not check: target fell unconscious, target died, target moved inside vehicle / left vehicle, target moved outside of players range, target moves at all.
@@ -62,7 +64,7 @@ _ctrlPos set [1, ((0 + 29 * ace_common_settingProgressBarLocation) * ((((safezon
                 if !([_player, objNull, _exceptions] call ace_common_fnc_canInteractWith) then {
                     _errorCode = 4;
                 } else {
-                    if (_progress >= 100) then {
+                    if (_progress >= _progressComplete) then {
                         _errorCode = 0;
                     };
                 };
@@ -94,6 +96,6 @@ _ctrlPos set [1, ((0 + 29 * ace_common_settingProgressBarLocation) * ((((safezon
             };
         };
     } else {
-        (uiNamespace getVariable "ace_common_ctrlProgressBar") progressSetPosition _progress / 100;
+        (uiNamespace getVariable "ace_common_ctrlProgressBar") progressSetPosition _progress / _progressComplete;
     };
 }, 0, [_progressVar, _args, _onFinish, _onFail, _condition, _player, _building, _exceptions]] call CBA_fnc_addPerFrameHandler;