Advertisement
DeTrix

fn_damageActions.sqf

Apr 20th, 2014
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.89 KB | None | 0 0
  1. scriptName "Functions\misc\fn_damageActions.sqf";
  2. /***********************************************************
  3. ADD ACTIONS FOR A CASUALTY
  4. - Function
  5. - [] call fnc_usec_damageActions;
  6. ************************************************************/
  7. private ["_found","_weaponName","_action","_turret","_weapons","_assignedRole","_action1","_action2","_x","_vehicle","_unit","_vehType","_displayName","_ammoQty","_ammoSerial","_weapon","_magTypes","_type","_typeVeh","_index","_inventory","_unitTo","_isEngineer","_vehClose","_hasVehicle","_unconscious","_lowBlood","_injured","_inPain","_legsBroke","_armsBroke","_charID","_friendlies","_playerMagazines","_hasBandage","_hasEpi","_hasMorphine","_hasBlood","_hasToolbox","_hasJerry","_hasJerryE","_hasWire","_hasPainkillers","_unconscious_crew","_patients","_crew","_menClose","_hasPatient","_inVehicle","_isClose","_bag","_classbag","_isDisallowRefuel","_hasBarrel","_hasBarrelE"];
  8.  
  9. disableSerialization;
  10.  
  11. if (DZE_ActionInProgress) exitWith {}; // Do not allow if any script is running.
  12.  
  13. _menClose = cursorTarget;
  14. _hasPatient = alive _menClose;
  15. _vehicle = vehicle player;
  16. _inVehicle = (_vehicle != player);
  17. _isClose = ((player distance _menClose) < ((sizeOf typeOf _menClose) / 2));
  18. _bag = unitBackpack player;
  19. _classbag = typeOf _bag;
  20.  
  21. if (_inVehicle) then {
  22. r_player_lastVehicle = _vehicle;
  23. _assignedRole = assignedVehicleRole player;
  24. if (str (_assignedRole) != str (r_player_lastSeat)) then {
  25. call r_player_removeActions2;
  26. };
  27. if (!r_player_unconscious && !r_action2) then {
  28. r_player_lastSeat = _assignedRole;
  29. if (count _assignedRole > 1) then {
  30. _turret = _assignedRole select 1;
  31. _weapons = _vehicle weaponsTurret _turret;
  32. {
  33. _weaponName = getText (configFile >> "cfgWeapons" >> _x >> "displayName");
  34. _action = _vehicle addAction [format["Add AMMO to %1",_weaponName], "\z\addons\dayz_code\actions\ammo.sqf",[_vehicle,_x,_turret], 0, false, true];
  35. r_player_actions2 set [count r_player_actions2,_action];
  36. r_action2 = true;
  37. } forEach _weapons;
  38. };
  39. };
  40. } else {
  41. call r_player_removeActions2;
  42. r_player_lastVehicle = objNull;
  43. r_player_lastSeat = [];
  44. };
  45.  
  46. if (!isNull _menClose and _hasPatient and !r_drag_sqf and !r_action and !_inVehicle and !r_player_unconscious and _isClose) then {
  47. _unit = cursorTarget;
  48. _isDisallowRefuel = typeOf _unit in ["M240Nest_DZ"];
  49. // player reveal _unit;
  50. _vehClose = (getPosATL player) nearEntities [["Car","Tank","Helicopter","Plane","StaticWeapon","Ship"],5]; //nearestObjects [player, ["Car","Tank","Helicopter","Plane","StaticWeapon","Ship"], 5];
  51. _hasVehicle = ({alive _x} count _vehClose > 0);
  52. _unconscious = _unit getVariable ["NORRN_unconscious", false];
  53. _lowBlood = _unit getVariable ["USEC_lowBlood", false];
  54. _injured = _unit getVariable ["USEC_injured", false];
  55. _inPain = _unit getVariable ["USEC_inPain", false];
  56. _legsBroke = _unit getVariable ["hit_legs", 0] >= 1;
  57. _armsBroke = _unit getVariable ["hit_hands", 0] >= 1;
  58. _charID = getPlayerUID _unit;
  59. _found=[_charID,"AX"] call KRON_StrInStr;
  60. if (_found) then {
  61. _charID=[_charID] call KRON_convertPlayerUID;
  62. };
  63. _friendlies = player getVariable ["friendlies", []];
  64. _playerMagazines = magazines player;
  65. _hasBandage = "ItemBandage" in _playerMagazines;
  66. _hasEpi = "ItemEpinephrine" in _playerMagazines;
  67. _hasMorphine = "ItemMorphine" in _playerMagazines;
  68. _hasBlood = "ItemBloodbag" in _playerMagazines;
  69. _hasToolbox = "ItemToolbox" in items player;
  70. _hasJerry = "ItemJerrycan" in _playerMagazines;
  71. _hasBarrel = "ItemFuelBarrel" in _playerMagazines;
  72. _hasJerryE = "ItemJerrycanEmpty" in _playerMagazines;
  73. _hasBarrelE = "ItemFuelBarrelEmpty" in _playerMagazines;
  74. //_hasEtool = "ItemEtool" in weapons player;
  75. _hasWire = "ItemWire" in _playerMagazines;
  76. _hasPainkillers = "ItemPainkiller" in _playerMagazines;
  77.  
  78. //Allow player to drag
  79. if(_unconscious) then {
  80. r_action = true;
  81. _action1 = _unit addAction [localize "str_actions_medical_01", "\z\addons\dayz_code\medical\drag.sqf",_unit, 0, true, true];
  82. _action2 = _unit addAction [localize "str_actions_medical_02", "\z\addons\dayz_code\medical\pulse.sqf",_unit, 0, true, true];
  83. r_player_actions = r_player_actions + [_action1,_action2];
  84. };
  85. //Load Vehicle
  86. if (_hasVehicle and _unconscious) then {
  87. _x = 0;
  88. r_action = true;
  89. _unit = _unit;
  90. _vehicle = (_vehClose select _x);
  91. while{((!alive _vehicle) and (_x < (count _vehClose)))} do {
  92. _x = _x + 1;
  93. _vehicle = (_vehClose select _x);
  94. };
  95. _vehType = typeOf _vehicle;
  96. _action = _unit addAction [format[localize "str_actions_medical_03",_vehType], "\z\addons\dayz_code\medical\load\load_act.sqf",[player,_vehicle,_unit], 0, true, true];
  97. r_player_actions set [count r_player_actions,_action];
  98. };
  99. //Allow player to bandage
  100. if(_injured and _hasBandage) then {
  101. r_action = true;
  102. _action = _unit addAction [localize "str_actions_medical_04", "\z\addons\dayz_code\medical\bandage.sqf",[_unit], 0, true, true, "", ""];
  103. r_player_actions set [count r_player_actions,_action];
  104. };
  105. //Allow player to give Epinephrine
  106. if(_unconscious and _hasEpi) then {
  107. r_action = true;
  108. _action = _unit addAction [localize "str_actions_medical_05", "\z\addons\dayz_code\medical\epinephrine.sqf",[_unit], 0, true, true];
  109. r_player_actions set [count r_player_actions,_action];
  110. };
  111. //Allow player to give Morphine
  112. if((_legsBroke or _armsBroke) and _hasMorphine) then {
  113. r_action = true;
  114. _action = _unit addAction [localize "str_actions_medical_06", "\z\addons\dayz_code\medical\morphine.sqf",[_unit], 0, true, true, "", ""];
  115. r_player_actions set [count r_player_actions,_action];
  116. };
  117. //Allow player to give Painkillers
  118. if(_inPain and _hasPainkillers) then {
  119. r_action = true;
  120. _action = _unit addAction [localize "str_actions_medical_07", "\z\addons\dayz_code\medical\painkiller.sqf",[_unit], 0, true, true, "", ""];
  121. r_player_actions set [count r_player_actions,_action];
  122. };
  123. //Allow player to transfuse blood
  124. if(_lowBlood and _hasBlood) then {
  125. r_action = true;
  126. _action = _unit addAction [localize "str_actions_medical_08", "\z\addons\dayz_code\medical\transfusion.sqf",[_unit], 0, true, true, "", ""];
  127. r_player_actions set [count r_player_actions,_action];
  128. };
  129.  
  130. //Repairs
  131. if ((_unit isKindOf "AllVehicles") and !(_unit isKindOf "Man") and !_isDisallowRefuel) then {
  132. _type = TypeOf(_unit);
  133. _typeVeh = getText(configFile >> "cfgVehicles" >> _type >> "displayName");
  134.  
  135. //CAN WE REFUEL THE OBJECT?
  136. if ((fuel _unit < 1) and (_hasJerry or _hasBarrel)) then {
  137. r_action = true;
  138. _action = _unit addAction [format[localize "str_actions_medical_10",_typeVeh], "\z\addons\dayz_code\actions\refuel.sqf",[], 0, true, true, "", ""];
  139. r_player_actions set [count r_player_actions,_action];
  140. };
  141. //CAN WE siphon fuel from THE OBJECT?
  142. if ((fuel _unit > 0) and (_hasJerryE or _hasBarrelE)) then {
  143. r_action = true;
  144. _action = _unit addAction [format["Siphon fuel from %1",_typeVeh], "\z\addons\dayz_code\actions\siphonFuel.sqf",[], 0, true, true, "", ""];
  145. r_player_actions set [count r_player_actions,_action];
  146. };
  147.  
  148. } else {
  149.  
  150. // should only fire if cursor target is man and not vehicle
  151. if ((isPlayer _unit) and !(_charID in _friendlies)) then {
  152. r_action = true;
  153. _action = _unit addAction ["Tag as friendly", "custom\player_tagFriendly.sqf", [], 0, false, true, "", ""];
  154. r_player_actions set [count r_player_actions,_action];
  155. };
  156.  
  157. };
  158. if (r_action) then {
  159. r_action_targets = r_action_targets + [_unit];
  160. };
  161. };
  162.  
  163. /*
  164. if ((r_player_vehicle != _vehicle) and r_action) then {
  165. //Player is in a new vehicle
  166. r_action = false;
  167. call fnc_usec_medic_removeActions;
  168. };
  169. */
  170.  
  171. if (_inVehicle) then {
  172. //Check if patients
  173. _crew = crew _vehicle;
  174. if (count _crew > 0) then {
  175. _unconscious_crew = [];
  176. {
  177. if (_x getVariable "NORRN_unconscious") then {
  178. _unconscious_crew = _unconscious_crew + [_x]
  179. };
  180. } forEach _crew;
  181. _patients = (count _unconscious_crew);
  182. if (_patients > 0) then {
  183. if (!r_action_unload) then {
  184. r_action_unload = true;
  185. _vehType = typeOf _vehicle;
  186. _action = _vehicle addAction [format[localize "str_actions_medical_14",_vehType], "\z\addons\dayz_code\medical\load\unLoad_act.sqf",[player,_vehicle], 0, false, true];
  187. r_player_actions set [count r_player_actions,_action];
  188. };
  189. } else {
  190. if (r_action_unload) then {
  191. call fnc_usec_medic_removeActions;
  192. r_action_unload = false;
  193. };
  194. };
  195. };
  196. //hintSilent format["Crew: %1\nPatients: %2\nAction: %3",(count _crew),_patients,r_action_unload];
  197. } else {
  198. if (r_action_unload) then {
  199. r_action_unload = false;
  200. call fnc_usec_medic_removeActions;
  201. };
  202. };
  203.  
  204. //Remove Actions
  205. if ((!_isClose or !_hasPatient) and r_action) then {
  206. call fnc_usec_medic_removeActions;
  207. r_action = false;
  208. };
  209.  
  210. //Pain Effects
  211. //if (r_player_inpain and !r_player_unconscious) then {
  212. // playSound "breath_1";
  213. // addCamShake [2, 1, 25];
  214. //};
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement