Advertisement
Guest User

fn_AelfActions

a guest
Apr 15th, 2014
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.81 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. //boiled Water
  17. _hasbottleitem = "ItemWaterbottle" in magazines player;
  18. _hastinitem = false;
  19. {
  20. if (_x in magazines player) then {
  21. _hastinitem = true;
  22. };
  23.  
  24. } forEach boil_tin_cans;
  25.  
  26.  
  27. _hasKnife = "ItemKnife" in items player;
  28. _hasToolbox = "ItemToolbox" in items player;
  29. //_hasTent = "ItemTent" in items player;
  30. _onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1;
  31. _nearLight = nearestObject [player,"LitObject"];
  32. _canPickLight = false;
  33.  
  34. if (!isNull _nearLight) then {
  35. if (_nearLight distance player < 4) then {
  36. _canPickLight = isNull (_nearLight getVariable ["owner",objNull]);
  37. };
  38. };
  39. _canDo = (!r_drag_sqf and !r_player_unconscious and !_onLadder);
  40.  
  41. // ------------------------------------------------------------------------Krixes Self Bloodbag Start------------------------------------------------------------------------
  42. _mags = magazines player;
  43.  
  44. // Krixes Self Bloodbag
  45. if ("ItemBloodbag" in _mags) then {
  46. hasBagItem = true;
  47. } else { hasBagItem = false;};
  48. if((speed player <= 1) && hasBagItem && _canDo) then {
  49. if (s_player_selfBloodbag < 0) then {
  50. s_player_selfBloodbag = player addaction[("<t color=""#c70000"">" + ("Self Bloodbag") +"</t>"),"custom\player_selfbloodbag.sqf","",5,false,true,"", ""];
  51. };
  52. } else {
  53. player removeAction s_player_selfBloodbag;
  54. s_player_selfBloodbag = -1;
  55. };
  56. // -------------------------------------------------------------------------Krixes Self Bloodbag End--------------------------------------------------------------------------
  57.  
  58. //Grab Flare
  59. if (_canPickLight and !dayz_hasLight) then {
  60. if (s_player_grabflare < 0) then {
  61. _text = getText (configFile >> "CfgAmmo" >> (typeOf _nearLight) >> "displayName");
  62. s_player_grabflare = player addAction [format[localize "str_actions_medical_15",_text], "\z\addons\dayz_code\actions\flare_pickup.sqf",_nearLight, 1, false, true, "", ""];
  63. s_player_removeflare = player addAction [format[localize "str_actions_medical_17",_text], "\z\addons\dayz_code\actions\flare_remove.sqf",_nearLight, 1, false, true, "", ""];
  64. };
  65. } else {
  66. player removeAction s_player_grabflare;
  67. player removeAction s_player_removeflare;
  68. s_player_grabflare = -1;
  69. s_player_removeflare = -1;
  70. };
  71.  
  72. if (!isNull cursorTarget and !_inVehicle and (player distance cursorTarget < 4)) then { //Has some kind of target
  73. _isHarvested = cursorTarget getVariable["meatHarvested",false];
  74. _isVehicle = cursorTarget isKindOf "AllVehicles";
  75. _isVehicletype = typeOf cursorTarget in ["ATV_US_EP1","ATV_CZ_EP1"];
  76. _isMan = cursorTarget isKindOf "Man";
  77. _ownerID = cursorTarget getVariable ["characterID","0"];
  78. _isAnimal = cursorTarget isKindOf "Animal";
  79. _isDog = (cursorTarget isKindOf "DZ_Pastor" || cursorTarget isKindOf "DZ_Fin");
  80. _isZombie = cursorTarget isKindOf "zZombie_base";
  81. _isDestructable = cursorTarget isKindOf "BuiltItems";
  82. _isTent = cursorTarget isKindOf "TentStorage";
  83. _isFuel = false;
  84. _isAlive = alive cursorTarget;
  85. _canmove = canmove cursorTarget;
  86. _text = getText (configFile >> "CfgVehicles" >> typeOf cursorTarget >> "displayName");
  87.  
  88.  
  89. _rawmeat = meatraw;
  90. _hasRawMeat = false;
  91. {
  92. if (_x in magazines player) then {
  93. _hasRawMeat = true;
  94. };
  95. } forEach _rawmeat;
  96.  
  97.  
  98. if (_hasFuelE) then {
  99. _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");
  100. };
  101. //diag_log ("OWNERID = " + _ownerID + " CHARID = " + dayz_characterID + " " + str(_ownerID == dayz_characterID));
  102.  
  103. //Allow player to delete objects
  104. if(_isDestructable and _hasToolbox and _canDo) then {
  105. if (s_player_deleteBuild < 0) then {
  106. s_player_deleteBuild = player addAction [format[localize "str_actions_delete",_text], "\z\addons\dayz_code\actions\remove.sqf",cursorTarget, 1, true, true, "", ""];
  107. };
  108. } else {
  109. player removeAction s_player_deleteBuild;
  110. s_player_deleteBuild = -1;
  111. };
  112.  
  113. /*
  114. //Allow player to force save
  115. if((_isVehicle or _isTent) and _canDo and !_isMan) then {
  116. if (s_player_forceSave < 0) then {
  117. s_player_forceSave = player addAction [format[localize "str_actions_save",_text], "\z\addons\dayz_code\actions\forcesave.sqf",cursorTarget, 1, true, true, "", ""];
  118. };
  119. } else {
  120. player removeAction s_player_forceSave;
  121. s_player_forceSave = -1;
  122. };
  123. */
  124. //flip vehicle
  125. if ((_isVehicletype) and !_canmove and _isAlive and (player distance cursorTarget >= 2) and (count (crew cursorTarget))== 0 and ((vectorUp cursorTarget) select 2) < 0.5) then {
  126. if (s_player_flipveh < 0) then {
  127. s_player_flipveh = player addAction [format[localize "str_actions_flipveh",_text], "\z\addons\dayz_code\actions\player_flipvehicle.sqf",cursorTarget, 1, true, true, "", ""];
  128. };
  129. } else {
  130. player removeAction s_player_flipveh;
  131. s_player_flipveh = -1;
  132. };
  133.  
  134. //Allow player to fill jerrycan
  135. if(_hasFuelE and _isFuel and _canDo) then {
  136. if (s_player_fillfuel < 0) then {
  137. s_player_fillfuel = player addAction [localize "str_actions_self_10", "\z\addons\dayz_code\actions\jerry_fill.sqf",[], 1, false, true, "", ""];
  138. };
  139. } else {
  140. player removeAction s_player_fillfuel;
  141. s_player_fillfuel = -1;
  142. };
  143.  
  144. if (!alive cursorTarget and _isAnimal and _hasKnife and !_isHarvested and _canDo) then {
  145. if (s_player_butcher < 0) then {
  146. s_player_butcher = player addAction [localize "str_actions_self_04", "\z\addons\dayz_code\actions\gather_meat.sqf",cursorTarget, 3, true, true, "", ""];
  147. };
  148. } else {
  149. player removeAction s_player_butcher;
  150. s_player_butcher = -1;
  151. };
  152.  
  153. //Fireplace Actions check
  154. if (inflamed cursorTarget and _hasRawMeat and _canDo) then {
  155. if (s_player_cook < 0) then {
  156. s_player_cook = player addAction [localize "str_actions_self_05", "\z\addons\dayz_code\actions\cook.sqf",cursorTarget, 3, true, true, "", ""];
  157. };
  158. } else {
  159. player removeAction s_player_cook;
  160. s_player_cook = -1;
  161. };
  162. if (inflamed cursorTarget and (_hasbottleitem and _hastinitem) and _canDo) then {
  163. if (s_player_boil < 0) then {
  164. s_player_boil = player addAction [localize "str_actions_boilwater", "\z\addons\dayz_code\actions\boil.sqf",cursorTarget, 3, true, true, "", ""];
  165. };
  166. } else {
  167. player removeAction s_player_boil;
  168. s_player_boil = -1;
  169. };
  170.  
  171. if(cursorTarget == dayz_hasFire and _canDo) then {
  172. if ((s_player_fireout < 0) and !(inflamed cursorTarget) and (player distance cursorTarget < 3)) then {
  173. s_player_fireout = player addAction [localize "str_actions_self_06", "\z\addons\dayz_code\actions\fire_pack.sqf",cursorTarget, 0, false, true, "",""];
  174. };
  175. } else {
  176. player removeAction s_player_fireout;
  177. s_player_fireout = -1;
  178. };
  179.  
  180. //Packing my tent
  181. if(cursorTarget isKindOf "TentStorage" and _canDo and _ownerID == dayz_characterID) then {
  182. if ((s_player_packtent < 0) and (player distance cursorTarget < 3)) then {
  183. s_player_packtent = player addAction [localize "str_actions_self_07", "\z\addons\dayz_code\actions\tent_pack.sqf",cursorTarget, 0, false, true, "",""];
  184. };
  185. } else {
  186. player removeAction s_player_packtent;
  187. s_player_packtent = -1;
  188. };
  189.  
  190. //Sleep
  191. if(cursorTarget isKindOf "TentStorage" and _canDo and _ownerID == dayz_characterID) then {
  192. if ((s_player_sleep < 0) and (player distance cursorTarget < 3)) then {
  193. s_player_sleep = player addAction [localize "str_actions_self_sleep", "\z\addons\dayz_code\actions\player_sleep.sqf",cursorTarget, 0, false, true, "",""];
  194. };
  195. } else {
  196. player removeAction s_player_sleep;
  197. s_player_sleep = -1;
  198. };
  199.  
  200. //Repairing Vehicles
  201. if ((dayz_myCursorTarget != cursorTarget) and _isVehicle and !_isMan and _hasToolbox and (damage cursorTarget < 1)) then {
  202. _vehicle = cursorTarget;
  203. {dayz_myCursorTarget removeAction _x} forEach s_player_repairActions;s_player_repairActions = [];
  204. dayz_myCursorTarget = _vehicle;
  205.  
  206. _allFixed = true;
  207. _hitpoints = _vehicle call vehicle_getHitpoints;
  208.  
  209. {
  210. _damage = [_vehicle,_x] call object_getHit;
  211. _part = "PartGeneric";
  212.  
  213. //change "HitPart" to " - Part" rather than complicated string replace
  214. _cmpt = toArray (_x);
  215. _cmpt set [0,20];
  216. _cmpt set [1,toArray ("-") select 0];
  217. _cmpt set [2,20];
  218. _cmpt = toString _cmpt;
  219.  
  220. if(["Engine",_x,false] call fnc_inString) then {
  221. _part = "PartEngine";
  222. };
  223.  
  224. if(["HRotor",_x,false] call fnc_inString) then {
  225. _part = "PartVRotor"; //yes you need PartVRotor to fix HRotor LOL
  226. };
  227.  
  228. if(["Fuel",_x,false] call fnc_inString) then {
  229. _part = "PartFueltank";
  230. };
  231.  
  232. if(["Wheel",_x,false] call fnc_inString) then {
  233. _part = "PartWheel";
  234.  
  235. };
  236.  
  237. if(["Glass",_x,false] call fnc_inString) then {
  238. _part = "PartGlass";
  239. };
  240.  
  241. // get every damaged part no matter how tiny damage is!
  242. if (_damage > 0) then {
  243.  
  244. _allFixed = false;
  245. _color = "color='#ffff00'"; //yellow
  246. if (_damage >= 0.5) then {_color = "color='#ff8800'";}; //orange
  247. if (_damage >= 0.9) then {_color = "color='#ff0000'";}; //red
  248.  
  249. _string = format["<t %2>Repair%1</t>",_cmpt,_color]; //Repair - Part
  250. _handle = dayz_myCursorTarget addAction [_string, "\z\addons\dayz_code\actions\repair.sqf",[_vehicle,_part,_x], 0, false, true, "",""];
  251. s_player_repairActions set [count s_player_repairActions,_handle];
  252.  
  253. };
  254.  
  255. } forEach _hitpoints;
  256. if (_allFixed) then {
  257. _vehicle setDamage 0;
  258. };
  259. };
  260.  
  261. if (_isMan and !_isAlive and !_isZombie) then {
  262. if (s_player_studybody < 0) then {
  263. s_player_studybody = player addAction [localize "str_action_studybody", "\z\addons\dayz_code\actions\study_body.sqf",cursorTarget, 0, false, true, "",""];
  264. };
  265. } else {
  266. player removeAction s_player_studybody;
  267. s_player_studybody = -1;
  268. };
  269.  
  270. //Dog
  271. if (_isDog and _isAlive and (_hasRawMeat) and _canDo and _ownerID == "0" and player getVariable ["dogID", 0] == 0) then {
  272. if (s_player_tamedog < 0) then {
  273. s_player_tamedog = player addAction [localize "str_actions_tamedog", "\z\addons\dayz_code\actions\tame_dog.sqf", cursorTarget, 1, false, true, "", ""];
  274. };
  275. } else {
  276. player removeAction s_player_tamedog;
  277. s_player_tamedog = -1;
  278. };
  279.  
  280. if (_isDog and _ownerID == dayz_characterID and _isAlive and _canDo) then {
  281. _dogHandle = player getVariable ["dogID", 0];
  282. if (s_player_feeddog < 0 and _hasRawMeat) then {
  283. s_player_feeddog = player addAction [localize "str_actions_feeddog","\z\addons\dayz_code\actions\dog\feed.sqf",[_dogHandle,0], 0, false, true,"",""];
  284. };
  285. if (s_player_waterdog < 0 and "ItemWaterbottle" in magazines player) then {
  286. s_player_waterdog = player addAction [localize "str_actions_waterdog","\z\addons\dayz_code\actions\dog\feed.sqf",[_dogHandle,1], 0, false, true,"",""];
  287. };
  288. if (s_player_staydog < 0) then {
  289. _lieDown = _dogHandle getFSMVariable "_actionLieDown";
  290. if (_lieDown) then { _text = "str_actions_liedog"; } else { _text = "str_actions_sitdog"; };
  291. s_player_staydog = player addAction [localize _text,"\z\addons\dayz_code\actions\dog\stay.sqf", _dogHandle, 5, false, true,"",""];
  292. };
  293. if (s_player_trackdog < 0) then {
  294. s_player_trackdog = player addAction [localize "str_actions_trackdog","\z\addons\dayz_code\actions\dog\track.sqf", _dogHandle, 4, false, true,"",""];
  295. };
  296. if (s_player_barkdog < 0) then {
  297. s_player_barkdog = player addAction [localize "str_actions_barkdog","\z\addons\dayz_code\actions\dog\speak.sqf", cursorTarget, 3, false, true,"",""];
  298. };
  299. if (s_player_warndog < 0) then {
  300. _warn = _dogHandle getFSMVariable "_watchDog";
  301. if (_warn) then { _text = "Quiet"; _warn = false; } else { _text = "Alert"; _warn = true; };
  302. s_player_warndog = player addAction [format[localize "str_actions_warndog",_text],"\z\addons\dayz_code\actions\dog\warn.sqf",[_dogHandle, _warn], 2, false, true,"",""];
  303. };
  304. if (s_player_followdog < 0) then {
  305. s_player_followdog = player addAction [localize "str_actions_followdog","\z\addons\dayz_code\actions\dog\follow.sqf",[_dogHandle,true], 6, false, true,"",""];
  306. };
  307. } else {
  308. player removeAction s_player_feeddog;
  309. s_player_feeddog = -1;
  310. player removeAction s_player_waterdog;
  311. s_player_waterdog = -1;
  312. player removeAction s_player_staydog;
  313. s_player_staydog = -1;
  314. player removeAction s_player_trackdog;
  315. s_player_trackdog = -1;
  316. player removeAction s_player_barkdog;
  317. s_player_barkdog = -1;
  318. player removeAction s_player_warndog;
  319. s_player_warndog = -1;
  320. player removeAction s_player_followdog;
  321. s_player_followdog = -1;
  322. };
  323. } else {
  324. //Engineering
  325. {dayz_myCursorTarget removeAction _x} forEach s_player_repairActions;s_player_repairActions = [];
  326. dayz_myCursorTarget = objNull;
  327. //Others
  328. player removeAction s_player_forceSave;
  329. s_player_forceSave = -1;
  330. player removeAction s_player_flipveh;
  331. s_player_flipveh = -1;
  332. player removeAction s_player_sleep;
  333. s_player_sleep = -1;
  334. player removeAction s_player_deleteBuild;
  335. s_player_deleteBuild = -1;
  336. player removeAction s_player_butcher;
  337. s_player_butcher = -1;
  338. player removeAction s_player_cook;
  339. s_player_cook = -1;
  340. player removeAction s_player_boil;
  341. s_player_boil = -1;
  342. player removeAction s_player_fireout;
  343. s_player_fireout = -1;
  344. player removeAction s_player_packtent;
  345. s_player_packtent = -1;
  346. player removeAction s_player_fillfuel;
  347. s_player_fillfuel = -1;
  348. player removeAction s_player_studybody;
  349. s_player_studybody = -1;
  350. //Dog
  351. player removeAction s_player_tamedog;
  352. s_player_tamedog = -1;
  353. player removeAction s_player_feeddog;
  354. s_player_feeddog = -1;
  355. player removeAction s_player_waterdog;
  356. s_player_waterdog = -1;
  357. player removeAction s_player_staydog;
  358. s_player_staydog = -1;
  359. player removeAction s_player_trackdog;
  360. s_player_trackdog = -1;
  361. player removeAction s_player_barkdog;
  362. s_player_barkdog = -1;
  363. player removeAction s_player_warndog;
  364. s_player_warndog = -1;
  365. player removeAction s_player_followdog;
  366. s_player_followdog = -1;
  367. };
  368.  
  369. //Dog actions on player self
  370. _dogHandle = player getVariable ["dogID", 0];
  371. if (_dogHandle > 0) then {
  372. _dog = _dogHandle getFSMVariable "_dog";
  373. _ownerID = "0";
  374. if (!isNull cursorTarget) then { _ownerID = cursorTarget getVariable ["characterID","0"]; };
  375. if (_canDo and !_inVehicle and alive _dog and _ownerID != dayz_characterID) then {
  376. if (s_player_movedog < 0) then {
  377. s_player_movedog = player addAction [localize "str_actions_movedog", "\z\addons\dayz_code\actions\dog\move.sqf", player getVariable ["dogID", 0], 1, false, true, "", ""];
  378. };
  379. if (s_player_speeddog < 0) then {
  380. _text = "Walk";
  381. _speed = 0;
  382. if (_dog getVariable ["currentSpeed",1] == 0) then { _speed = 1; _text = "Run"; };
  383. s_player_speeddog = player addAction [format[localize "str_actions_speeddog", _text], "\z\addons\dayz_code\actions\dog\speed.sqf",[player getVariable ["dogID", 0],_speed], 0, false, true, "", ""];
  384. };
  385. if (s_player_calldog < 0) then {
  386. s_player_calldog = player addAction [localize "str_actions_calldog", "\z\addons\dayz_code\actions\dog\follow.sqf", [player getVariable ["dogID", 0], true], 2, false, true, "", ""];
  387. };
  388. };
  389. } else {
  390. player removeAction s_player_movedog;
  391. s_player_movedog = -1;
  392. player removeAction s_player_speeddog;
  393. s_player_speeddog = -1;
  394. player removeAction s_player_calldog;
  395. s_player_calldog = -1;
  396. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement