Advertisement
kerbo_

squadMedic.sqf

Jun 26th, 2024
978
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 = "I_G_medic_F";
  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 { hint "No medic found"; };
  23.  
  24. player sideChat format["Found squad medic %1", (name _medic)];
  25. _medicPos = position _medic;
  26.  
  27. {
  28.  if(getDammage _x > 0.1) then {
  29.   _injuredUnits pushBack _x;
  30.  };
  31. } forEach units group player;
  32.  
  33. if (count _injuredUnits == 0) exitWith {_medic sideChat "No injured found"};
  34. _medic sideChat format["Found %1 injured", (count _injuredUnits)];
  35.  
  36. _injuredUnitsClosest = [_injuredUnits, [_medic], { _input0 = objNull; _input0 distance _x}, "ASCEND", {canMove _x}] call BIS_fnc_sortBy;
  37.  
  38. {
  39.  _injured = _x;
  40.  if(_medic == _injured) then {
  41.   _medic sideChat "Healing myself";
  42.   _medic action["HealSoldierSelf", _injured];
  43.   waitUntil { (getDammage _injured < 0.1) or (!alive _injured)};
  44.  } else {
  45.   if(!isPlayer _injured) then {
  46.    _injured disableAI "MOVE";
  47.    _injured setUnitPos "down";
  48.   };
  49.   _medic sideChat format["Moving to %1", (name _injured)];
  50.   _medic doMove (position _injured);
  51.   while {(_medic distance _injured > 3) and (canMove _medic) and (alive _injured) and (alive _medic)} do {
  52.    sleep 1;
  53.    _medic doMove (position _injured);
  54.   };
  55.   if(!alive _medic) exitWith {player sideChat format["Medic %1 is down!", (name _medic)]};
  56.   if(alive _injured) then {
  57.    _medic sideChat format["Healing %1", (name _injured)];
  58.    _medic disableAI "MOVE";
  59.    _medic setUnitPos "middle";
  60.    _medic action ["HealSoldier", _injured];
  61.    waitUntil { (getDammage _injured < 0.1) or (!alive _injured)};
  62.    sleep 1;
  63.    _medic sideChat format["OK %1, you are good to go", (name _injured)];
  64.    if(!isPlayer _injured) then {
  65.     _injured enableAI "MOVE";
  66.     _injured setUnitPos "auto";
  67.    };
  68.    _medic enableAI "MOVE";
  69.    _medic setUnitPos "auto";
  70.   } else {
  71.    _medic sideChat format["We lost %1!", (name _injured)];
  72.   };
  73.  };
  74. } forEach _injuredUnitsClosest;
  75.  
  76. _medic sideChat "All good now";
  77. _medic doMove _medicPos;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement