Advertisement
Guest User

fnactions.sqf

a guest
Jan 28th, 2013
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.01 KB | None | 0 0
  1. scriptName "Functions\misc\fn_selfActions.sqf";
  2. /***********************************************************
  3. ADD ACTIONS FOR SELF
  4. - Function
  5. - [] call fnc_usec_selfActions;
  6. ************************************************************/
  7. private["_menClose","_hasBandage","_hasEpi","_hasMorphine","_hasBlood","_vehicle","_inVehicle","_color","_part"];
  8.  
  9. _vehicle = vehicle player;
  10. _inVehicle = (_vehicle != player);
  11. _bag = unitBackpack player;
  12. _classbag = typeOf _bag;
  13. _isWater = (surfaceIsWater (position player)) or dayz_isSwimming;
  14. _hasAntiB = "ItemAntibiotic" in magazines player;
  15. _hasFuelE = "ItemJerrycanEmpty" in magazines player;
  16. _hasRawMeat = "FoodSteakRaw" in magazines player;
  17. _hasKnife = "ItemKnife" in items player;
  18. _hasToolbox = "ItemToolbox" in items player;
  19. _onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1;
  20. _nearLight = nearestObject [player,"LitObject"];
  21. _canPickLight = false;
  22.  
  23. if (!isNull _nearLight) then {
  24. if (_nearLight distance player < 4) then {
  25. _canPickLight = isNull (_nearLight getVariable ["owner",objNull]);
  26. };
  27. };
  28. _canDo = (!r_drag_sqf and !r_player_unconscious and !_onLadder);
  29.  
  30. //Grab Flare
  31. if (_canPickLight and !dayz_hasLight) then {
  32. if (s_player_grabflare < 0) then {
  33. _text = getText (configFile >> "CfgAmmo" >> (typeOf _nearLight) >> "displayName");
  34. s_player_grabflare = player addAction [format[localize "str_actions_medical_15",_text], "\z\addons\dayz_code\actions\flare_pickup.sqf",_nearLight, 1, false, true, "", ""];
  35. s_player_removeflare = player addAction [format[localize "str_actions_medical_17",_text], "\z\addons\dayz_code\actions\flare_remove.sqf",_nearLight, 1, false, true, "", ""];
  36. };
  37. } else {
  38. player removeAction s_player_grabflare;
  39. player removeAction s_player_removeflare;
  40. s_player_grabflare = -1;
  41. s_player_removeflare = -1;
  42. };
  43.  
  44. s_action_blood = -1;
  45.  
  46. if(r_player_blood < 12000 and "ItemBloodbag" in magazines player and s_action_blood < 0) then {
  47. s_action_blood = player addAction ["Use Bloodbag", "fixes\bloodbag.sqf",[player], 0, true, true, "", "'ItemBloodbag' in magazines player"];
  48. a_action_blood = 1;
  49. };
  50. if(s_action_blood > 0) then {
  51. player removeAction s_action_blood;
  52. s_action_blood = -1;
  53. };
  54.  
  55. if (!isNull cursorTarget and !_inVehicle and (player distance cursorTarget < 3)) then { //Has some kind of target
  56. _isHarvested = cursorTarget getVariable["meatHarvested",false];
  57. _isVehicle = cursorTarget isKindOf "AllVehicles";
  58. _isMan = cursorTarget isKindOf "Man";
  59. _ownerID = cursorTarget getVariable ["characterID","0"];
  60. _isAnimal = cursorTarget isKindOf "Animal";
  61. _isZombie = cursorTarget isKindOf "zZombie_base";
  62. _isDestructable = cursorTarget isKindOf "BuiltItems";
  63. _isTent = cursorTarget isKindOf "TentStorage";
  64. _isFuel = false;
  65. _isAlive = alive cursorTarget;
  66. _text = getText (configFile >> "CfgVehicles" >> typeOf cursorTarget >> "displayName");
  67. if (_hasFuelE) then {
  68. _isFuel = (cursorTarget isKindOf "Land_Ind_TankSmall") or (cursorTarget isKindOf "Land_fuel_tank_big") or (cursorTarget isKindOf "Land_fuel_tank_stairs") or (cursorTarget isKindOf "Land_wagon_tanker");
  69. };
  70. //diag_log ("OWNERID = " + _ownerID + " CHARID = " + dayz_characterID + " " + str(_ownerID == dayz_characterID));
  71.  
  72. //Allow player to delete objects
  73. if(_isDestructable and _hasToolbox and _canDo) then {
  74. if (s_player_deleteBuild < 0) then {
  75. s_player_deleteBuild = player addAction [format[localize "str_actions_delete",_text], "\z\addons\dayz_code\actions\remove.sqf",cursorTarget, 1, true, true, "", ""];
  76. };
  77. } else {
  78. player removeAction s_player_deleteBuild;
  79. s_player_deleteBuild = -1;
  80. };
  81.  
  82. //Allow player to force save
  83. if((_isVehicle or _isTent) and _canDo and !_isMan) then {
  84. if (s_player_forceSave < 0) then {
  85. s_player_forceSave = player addAction [format[localize "str_actions_save",_text], "\z\addons\dayz_code\actions\forcesave.sqf",cursorTarget, 1, true, true, "", ""];
  86. };
  87. } else {
  88. player removeAction s_player_forceSave;
  89. s_player_forceSave = -1;
  90. };
  91.  
  92. //Allow player to fill jerrycan
  93. if(_hasFuelE and _isFuel and _canDo) then {
  94. if (s_player_fillfuel < 0) then {
  95. s_player_fillfuel = player addAction [localize "str_actions_self_10", "\z\addons\dayz_code\actions\jerry_fill.sqf",[], 1, false, true, "", ""];
  96. };
  97. } else {
  98. player removeAction s_player_fillfuel;
  99. s_player_fillfuel = -1;
  100. };
  101.  
  102. if (!alive cursorTarget and _isAnimal and _hasKnife and !_isHarvested and _canDo) then {
  103. if (s_player_butcher < 0) then {
  104. s_player_butcher = player addAction [localize "str_actions_self_04", "\z\addons\dayz_code\actions\gather_meat.sqf",cursorTarget, 3, true, true, "", ""];
  105. };
  106. } else {
  107. player removeAction s_player_butcher;
  108. s_player_butcher = -1;
  109. };
  110.  
  111. //Fireplace Actions check
  112. if(inflamed cursorTarget and _hasRawMeat and _canDo) then {
  113. if (s_player_cook < 0) then {
  114. s_player_cook = player addAction [localize "str_actions_self_05", "\z\addons\dayz_code\actions\cook.sqf",cursorTarget, 3, true, true, "", ""];
  115. };
  116. } else {
  117. player removeAction s_player_cook;
  118. s_player_cook = -1;
  119. };
  120. if(cursorTarget == dayz_hasFire and _canDo) then {
  121. if ((s_player_fireout < 0) and !(inflamed cursorTarget) and (player distance cursorTarget < 3)) then {
  122. s_player_fireout = player addAction [localize "str_actions_self_06", "\z\addons\dayz_code\actions\fire_pack.sqf",cursorTarget, 0, false, true, "",""];
  123. };
  124. } else {
  125. player removeAction s_player_fireout;
  126. s_player_fireout = -1;
  127. };
  128.  
  129. //Packing my tent
  130. if(cursorTarget isKindOf "TentStorage" and _canDo and _ownerID == dayz_characterID) then {
  131. if ((s_player_packtent < 0) and (player distance cursorTarget < 3)) then {
  132. s_player_packtent = player addAction [localize "str_actions_self_07", "\z\addons\dayz_code\actions\tent_pack.sqf",cursorTarget, 0, false, true, "",""];
  133. };
  134. } else {
  135. player removeAction s_player_packtent;
  136. s_player_packtent = -1;
  137. };
  138.  
  139. //Repairing Vehicles
  140. if ((dayz_myCursorTarget != cursorTarget) and !_isMan) then {
  141. _vehicle = cursorTarget;
  142. {dayz_myCursorTarget removeAction _x} forEach s_player_repairActions;s_player_repairActions = [];
  143. dayz_myCursorTarget = _vehicle;
  144. _hitpoints = _vehicle call vehicle_getHitpoints;
  145. _allFixed = true;
  146. {
  147. _damage = [_vehicle,_x] call object_getHit;
  148. //if (_damage > 0) then {
  149. _color = "";
  150. _part = "PartGeneric";
  151. _cmpt = _x;
  152. _damagePercent = round((1 - _damage) * 100);
  153. if(["Body",_x,false] call fnc_inString) then {
  154. _part = "PartGeneric";
  155. _cmpt = "Body";
  156. if (_damagePercent < 95) then {_allFixed = false};
  157. };
  158. if(["Engine",_x,false] call fnc_inString) then {
  159. _part = "PartEngine";
  160. _cmpt = "Engine";
  161. if (_damagePercent < 95) then {_allFixed = false};
  162. };
  163. if(["HRotor",_x,false] call fnc_inString) then {
  164. _part = "PartVRotor";
  165. _cmpt = "Main Rotor Assembly";
  166. if (_damagePercent < 95) then {_allFixed = false};
  167. };
  168. if(["Fuel",_x,false] call fnc_inString) then {
  169. _part = "PartFueltank";
  170. _cmpt = "Fuel Tank";
  171. if (_damagePercent < 95) then {_allFixed = false};
  172. };
  173. if(["Wheel",_x,false] call fnc_inString) then {
  174. _part = "PartWheel";
  175. _cmpt = "Wheel";
  176. _array = toArray _x;
  177. _newArray = [];
  178. for "_i" from 3 to ((count _array) - 1) do {_newArray set [count _newArray,(_array select _i)]};
  179. _array = _newArray;
  180. _newArray = [];
  181. for "_i" from 0 to ((count _array) - 6) do {_newArray set [count _newArray,(_array select _i)]};
  182. _toStr = toString _newArray;
  183. _toStr = switch (_toStr) do {
  184. default {_toStr};
  185. case "LF": {"Left Front"};
  186. case "RF": {"Right Front"};
  187. case "LB": {"Left Back"};
  188. case "RB": {"Right Back"};
  189. case "LM": {"Left Middle"};
  190. case "RM": {"Right Middle"};
  191. };
  192. _cmpt = _cmpt + " " + _toStr;
  193. if (_damagePercent < 95) then {_allFixed = false};
  194. };
  195. if(["Glass",_x,false] call fnc_inString) then {
  196. _part = "PartGlass";
  197. _cmpt = "Glass";
  198. if (_damagePercent < 95) then {_allFixed = false};
  199. };
  200. if (_part in magazines player) then {
  201. if (_damage >= 0.5) then {_color = "color='#ffff00'"};
  202. if (_damage >= 0.9) then {_color = "color='#ff0000'";};
  203. _string = format[localize "str_actions_medical_09",_cmpt,_color];
  204. _handle = dayz_myCursorTarget addAction [_string, "\z\addons\dayz_code\actions\repair.sqf",[_vehicle,_part,_x], 0, false, true, "",""];
  205. s_player_repairActions set [count s_player_repairActions,_handle];
  206. };
  207. //};
  208. } forEach _hitpoints;
  209. if (_allFixed) then {
  210. _vehicle setDamage 0;
  211. };
  212. };
  213.  
  214. if (_isMan and !_isAlive and !_isZombie) then {
  215. if (s_player_studybody < 0) then {
  216. s_player_studybody = player addAction [localize "str_action_studybody", "\z\addons\dayz_code\actions\study_body.sqf",cursorTarget, 0, false, true, "",""];
  217. };
  218. } else {
  219. player removeAction s_player_studybody;
  220. s_player_studybody = -1;
  221. };
  222. } else {
  223. //Engineering
  224. {dayz_myCursorTarget removeAction _x} forEach s_player_repairActions;s_player_repairActions = [];
  225. dayz_myCursorTarget = objNull;
  226. //Others
  227. player removeAction s_player_forceSave;
  228. s_player_forceSave = -1;
  229. player removeAction s_player_deleteBuild;
  230. s_player_deleteBuild = -1;
  231. player removeAction s_player_butcher;
  232. s_player_butcher = -1;
  233. player removeAction s_player_cook;
  234. s_player_cook = -1;
  235. player removeAction s_player_fireout;
  236. s_player_fireout = -1;
  237. player removeAction s_player_packtent;
  238. s_player_packtent = -1;
  239. player removeAction s_player_fillfuel;
  240. s_player_fillfuel = -1;
  241. player removeAction s_player_studybody;
  242. s_player_studybody = -1;
  243. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement