fnc_stitchAllWoundsNearbyCCP.sqf 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * Author: M3ales
  3. *
  4. * Arguments:
  5. * Healer
  6. * Origin To Search from
  7. * Radius To Search Around for People
  8. * Return Value:
  9. * Nothing
  10. *
  11. * Example:
  12. * [player, cursorTarget] call rd501_fnc_stitchAllNearbyCCP
  13. *
  14. * Public: No
  15. */
  16. /*
  17. * Author: M3ales
  18. *
  19. * Arguments:
  20. * Healer
  21. * Origin To Search from
  22. * Radius To Search Around for People
  23. * Return Value:
  24. * Nothing
  25. *
  26. * Example:
  27. * [player, cursorTarget] call rd501_fnc_stitchAllNearbyCCP
  28. *
  29. * Public: No
  30. */
  31. params["_healer", "_origin", "_radius"];
  32. private _nearbyPatients = _origin nearEntities ["CAManBase", _radius] select {
  33. [_x] call rd501_fnc_checkInsideCCP &&
  34. {
  35. count (_x getVariable ["ace_medical_openWounds", []]) > 0
  36. }
  37. };
  38. private _args = [_healer, _nearbyPatients, _origin];
  39. if(count _nearbyPatients == 0) exitWith {
  40. ["Nobody to Stitch Inside CCP", true, 2, 0] call ace_common_fnc_displayText;
  41. };
  42. [format["Bandaging %1 Patient(s)", count _nearbyPatients], false, 10, 0] call ace_common_fnc_displayText;
  43. private _onFinish = {
  44. (_this select 0) params ["_player", "_patients", "_building"];
  45. {
  46. if([_x] call rd501_fnc_checkInsideCCP) then {
  47. [_player, _x] call rd501_fnc_stitchAllWounds;
  48. };
  49. } forEach (_patients);
  50. _building setVariable ["rd501_medical_ccp_stitchProgress", -1, true];
  51. _building setVariable["rd501_medical_ccp_stitchMembers", [], true];
  52. [_player, "", 1] call ace_common_fnc_doAnimation;
  53. };
  54. private _onFailure = {
  55. params["_args", "_progress", "_errorCode"];
  56. _args params["_healer","_nearbyPatients", "_building"];
  57. [_healer, "AmovPknlMstpSrasWrflDnon", 1] call ace_common_fnc_doAnimation;
  58. _stitchers = _building getVariable ["rd501_medical_ccp_stitchMembers", []];
  59. systemChat format["_stitchers %1", _stitchers];
  60. if(count _stitchers <= 1) then {
  61. _building setVariable ["rd501_medical_ccp_stitchProgress", -1, true];
  62. _building setVariable["rd501_medical_ccp_stitchMembers", [], true];
  63. }
  64. else
  65. {
  66. _newArr = _stitchers deleteAt (_stitchers findIf { _x isEqualTo ([] call CBA_fnc_currentUnit)}) select 1;
  67. _building setVariable["rd501_medical_ccp_stitchMembers", _newArr, true];
  68. }
  69. };
  70. private _condition = {
  71. params["_args", "_progress", "_errorCode"];
  72. _args params["_healer","_nearbyPatients", "_building"];
  73. if(_progress == -1) exitWith {false};
  74. if(_healer getVariable ["ACE_Unconscious", false]) exitWith {false};
  75. alive _healer && alive _building
  76. };
  77. if(_origin getVariable ["rd501_medical_ccp_stitchProgress", -1] == -1) then {
  78. _origin setVariable ["rd501_medical_ccp_stitchProgress", 0, true];
  79. _origin setVariable ["rd501_medical_ccp_stitchMembers", [player], true];
  80. }
  81. else
  82. {
  83. _stitchMembers = _origin getVariable ["rd501_medical_ccp_stitchMembers", []];
  84. _stitchMembers append [player];
  85. _origin setVariable ["rd501_medical_ccp_stitchMembers", _stitchMembers, true];
  86. };
  87. [
  88. {
  89. params ["_args", "_handle"];
  90. _args params ["_healer", "_nearbyPatients", "_origin"];
  91. _progress = _origin getVariable ["rd501_medical_ccp_stitchProgress", -1];
  92. if(_progress > 100 || _progress < 0) exitWith {
  93. systemChat "EH Exit";
  94. [_handle] call CBA_fnc_removePerFrameHandler;
  95. };
  96. if!(_healer getVariable ["ACE_Unconscious", false]) exitWith {
  97. systemChat "EH Increment";
  98. [_origin, _healer] call rd501_fnc_incrementStitchProgress;
  99. };
  100. },
  101. 0.5,
  102. _args
  103. ] call CBA_fnc_addPerFrameHandler;
  104. [_healer, "AinvPknlMstpSnonWnonDr_medic5", 0] call ace_common_fnc_doAnimation;
  105. [_origin, _args, _onFinish, _onFailure, "Bandaging All Patients Inside CCP", _condition] call rd501_fnc_valueProgressBar;