kerbo_

squadMedic.sqf

Jun 26th, 2024 (edited)
2,286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 2.32 KB | None | 0 0
  1. // Have the medic do medic things
  2.  
  3. // _medicClass needs to match the current class of your medic
  4. //
  5. // KP Liberation
  6. // _medicClass = "rhsusf_army_ocp_medic";
  7. //
  8. // Antistasi
  9. _medicClass = "a3a_unit_reb_medic";
  10.  
  11. _medic = objNull;
  12. _injured = objNull;
  13. _medicPos = objNull;
  14. _injuredUnits = [];
  15.  
  16. {
  17.     if ((typeOf _x == _medicClass) && (alive _x)) exitWith {
  18.         _medic = _x;
  19.     };
  20. } forEach units group player;
  21.  
  22. if (isNull _medic) exitWith {
  23.     hint "No medic found";
  24. };
  25.  
  26. player sideChat format["Found squad medic %1", (name _medic)];
  27. _medicPos = position _medic;
  28.  
  29. {
  30.     if (damage _x > 0.1) then {
  31.         _injuredUnits pushBack _x;
  32.     };
  33. } forEach units group player;
  34.  
  35. if (count _injuredUnits == 0) exitWith {
  36.     _medic sideChat "No injured found"
  37. };
  38. _medic sideChat format["Found %1 injured", (count _injuredUnits)];
  39.  
  40. _injuredUnitsClosest = [_injuredUnits, [_medic], {
  41.     _input0 = objNull;
  42.     _input0 distance _x
  43. }, "ASCEND", {
  44.     canMove _x
  45. }] call BIS_fnc_sortBy;
  46.  
  47. {
  48.     _injured = _x;
  49.     if (_medic == _injured) then {
  50.         _medic sideChat "Healing myself";
  51.         _medic action["HealSoldierSelf", _injured];
  52.         waitUntil {
  53.             (damage _injured < 0.1) or (!alive _injured)
  54.         };
  55.     } else {
  56.         if (!isPlayer _injured) then {
  57.             _injured disableAI "MOVE";
  58.             _injured setUnitPos "down";
  59.         };
  60.         _medic sideChat format["Moving to %1", (name _injured)];
  61.         _medic doMove (position _injured);
  62.         while { (_medic distance _injured > 3) and (canMove _medic) and (alive _injured) and (alive _medic) } do {
  63.             sleep 1;
  64.             _medic doMove (position _injured);
  65.         };
  66.         if (!alive _medic) exitWith {
  67.             player sideChat format["Medic %1 is down!", (name _medic)]
  68.         };
  69.         if (alive _injured) then {
  70.             _medic sideChat format["Healing %1", (name _injured)];
  71.             _medic disableAI "MOVE";
  72.             _medic setUnitPos "middle";
  73.             _medic action ["HealSoldier", _injured];
  74.             waitUntil {
  75.                 (damage _injured < 0.1) or (!alive _injured)
  76.             };
  77.             sleep 1;
  78.             _medic sideChat format["OK %1, you are good to go", (name _injured)];
  79.             if (!isPlayer _injured) then {
  80.                 _injured enableAI "MOVE";
  81.                 _injured setUnitPos "auto";
  82.             };
  83.             _medic enableAI "MOVE";
  84.             _medic setUnitPos "auto";
  85.         } else {
  86.             _medic sideChat format["We lost %1!", (name _injured)];
  87.         };
  88.     };
  89. } forEach _injuredUnitsClosest;
  90.  
  91. _medic sideChat "All good now";
  92. _medic doFollow player;
Advertisement
Add Comment
Please, Sign In to add comment