Advertisement
Guest User

Untitled

a guest
Jun 3rd, 2013
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.30 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. // Remove Parts from Vehicles - By SilverShot.
  200. if( !_isMan and _canDo and _hasToolbox and (silver_myCursorTarget != cursorTarget) and cursorTarget isKindOf "AllVehicles" and (getDammage cursorTarget < 0.95) ) then {
  201. _vehicle = cursorTarget;
  202. _invalidVehicle = (_vehicle isKindOf "Motorcycle") or (_vehicle isKindOf "Tractor"); //or (_vehicle isKindOf "ATV_US_EP1") or (_vehicle isKindOf "ATV_CZ_EP1");
  203. if( !_invalidVehicle ) then {
  204. {silver_myCursorTarget removeAction _x} forEach s_player_removeActions;
  205. s_player_removeActions = [];
  206. silver_myCursorTarget = _vehicle;
  207.  
  208. _hitpoints = _vehicle call vehicle_getHitpoints;
  209.  
  210. {
  211. _damage = [_vehicle,_x] call object_getHit;
  212.  
  213. if( _damage < 0.15 ) then {
  214.  
  215. //change "HitPart" to " - Part" rather than complicated string replace
  216. _cmpt = toArray (_x);
  217. _cmpt set [0,20];
  218. _cmpt set [1,toArray ("-") select 0];
  219. _cmpt set [2,20];
  220. _cmpt = toString _cmpt;
  221.  
  222. _skip = true;
  223. if( _skip and _x == "HitFuel" ) then { _skip = false; _part = "PartFueltank"; _cmpt = _cmpt + "tank"};
  224. if( _skip and _x == "HitEngine" ) then { _skip = false; _part = "PartEngine"; };
  225. if( _skip and _x == "HitLFWheel" ) then { _skip = false; _part = "PartWheel"; };
  226. if( _skip and _x == "HitRFWheel" ) then { _skip = false; _part = "PartWheel"; };
  227. if( _skip and _x == "HitLBWheel" ) then { _skip = false; _part = "PartWheel"; };
  228. if( _skip and _x == "HitRBWheel" ) then { _skip = false; _part = "PartWheel"; };
  229. if( _skip and _x == "HitGlass1" ) then { _skip = false; _part = "PartGlass"; };
  230. if( _skip and _x == "HitGlass2" ) then { _skip = false; _part = "PartGlass"; };
  231. if( _skip and _x == "HitGlass3" ) then { _skip = false; _part = "PartGlass"; };
  232. if( _skip and _x == "HitGlass4" ) then { _skip = false; _part = "PartGlass"; };
  233. if( _skip and _x == "HitGlass5" ) then { _skip = false; _part = "PartGlass"; };
  234. if( _skip and _x == "HitGlass6" ) then { _skip = false; _part = "PartGlass"; };
  235. if( _skip and _x == "HitHRotor" ) then { _skip = false; _part = "PartVRotor"; };
  236.  
  237. if (!_skip ) then {
  238. _string = format["<t color='#0096ff'>Remove%1</t>",_cmpt,_color]; //Remove - Part
  239. _handle = silver_myCursorTarget addAction [_string, "ss_remove.sqf",[_vehicle,_part,_x], 0, false, true, "",""];
  240. s_player_removeActions set [count s_player_removeActions,_handle];
  241. };
  242. };
  243.  
  244. } forEach _hitpoints;
  245. };
  246. };
  247. //Repairing Vehicles
  248. if ((dayz_myCursorTarget != cursorTarget) and _isVehicle and !_isMan and _hasToolbox and (damage cursorTarget < 1)) then {
  249. _vehicle = cursorTarget;
  250. {dayz_myCursorTarget removeAction _x} forEach s_player_repairActions;s_player_repairActions = [];
  251. dayz_myCursorTarget = _vehicle;
  252.  
  253. _allFixed = true;
  254. _hitpoints = _vehicle call vehicle_getHitpoints;
  255.  
  256. {
  257. _damage = [_vehicle,_x] call object_getHit;
  258. _part = "PartGeneric";
  259.  
  260. //change "HitPart" to " - Part" rather than complicated string replace
  261. _cmpt = toArray (_x);
  262. _cmpt set [0,20];
  263. _cmpt set [1,toArray ("-") select 0];
  264. _cmpt set [2,20];
  265. _cmpt = toString _cmpt;
  266.  
  267. if(["Engine",_x,false] call fnc_inString) then {
  268. _part = "PartEngine";
  269. };
  270.  
  271. if(["HRotor",_x,false] call fnc_inString) then {
  272. _part = "PartVRotor"; //yes you need PartVRotor to fix HRotor LOL
  273. };
  274.  
  275. if(["Fuel",_x,false] call fnc_inString) then {
  276. _part = "PartFueltank";
  277. };
  278.  
  279. if(["Wheel",_x,false] call fnc_inString) then {
  280. _part = "PartWheel";
  281.  
  282. };
  283.  
  284. if(["Glass",_x,false] call fnc_inString) then {
  285. _part = "PartGlass";
  286. };
  287.  
  288. // get every damaged part no matter how tiny damage is!
  289. if (_damage > 0) then {
  290.  
  291. _allFixed = false;
  292. _color = "color='#ffff00'"; //yellow
  293. if (_damage >= 0.5) then {_color = "color='#ff8800'";}; //orange
  294. if (_damage >= 0.9) then {_color = "color='#ff0000'";}; //red
  295.  
  296. _string = format["<t %2>Repair%1</t>",_cmpt,_color]; //Repair - Part
  297. _handle = dayz_myCursorTarget addAction [_string, "\z\addons\dayz_code\actions\repair.sqf",[_vehicle,_part,_x], 0, false, true, "",""];
  298. s_player_repairActions set [count s_player_repairActions,_handle];
  299.  
  300. };
  301.  
  302. } forEach _hitpoints;
  303. if (_allFixed) then {
  304. _vehicle setDamage 0;
  305. };
  306. };
  307.  
  308. if (_isMan and !_isAlive and !_isZombie) then {
  309. if (s_player_studybody < 0) then {
  310. s_player_studybody = player addAction [localize "str_action_studybody", "\z\addons\dayz_code\actions\study_body.sqf",cursorTarget, 0, false, true, "",""];
  311. };
  312. } else {
  313. player removeAction s_player_studybody;
  314. s_player_studybody = -1;
  315. };
  316.  
  317. //Dog
  318. if (_isDog and _isAlive and (_hasRawMeat) and _canDo and _ownerID == "0" and player getVariable ["dogID", 0] == 0) then {
  319. if (s_player_tamedog < 0) then {
  320. s_player_tamedog = player addAction [localize "str_actions_tamedog", "\z\addons\dayz_code\actions\tame_dog.sqf", cursorTarget, 1, false, true, "", ""];
  321. };
  322. } else {
  323. player removeAction s_player_tamedog;
  324. s_player_tamedog = -1;
  325. };
  326.  
  327. if (_isDog and _ownerID == dayz_characterID and _isAlive and _canDo) then {
  328. _dogHandle = player getVariable ["dogID", 0];
  329. if (s_player_feeddog < 0 and _hasRawMeat) then {
  330. s_player_feeddog = player addAction [localize "str_actions_feeddog","\z\addons\dayz_code\actions\dog\feed.sqf",[_dogHandle,0], 0, false, true,"",""];
  331. };
  332. if (s_player_waterdog < 0 and "ItemWaterbottle" in magazines player) then {
  333. s_player_waterdog = player addAction [localize "str_actions_waterdog","\z\addons\dayz_code\actions\dog\feed.sqf",[_dogHandle,1], 0, false, true,"",""];
  334. };
  335. if (s_player_staydog < 0) then {
  336. _lieDown = _dogHandle getFSMVariable "_actionLieDown";
  337. if (_lieDown) then { _text = "str_actions_liedog"; } else { _text = "str_actions_sitdog"; };
  338. s_player_staydog = player addAction [localize _text,"\z\addons\dayz_code\actions\dog\stay.sqf", _dogHandle, 5, false, true,"",""];
  339. };
  340. if (s_player_trackdog < 0) then {
  341. s_player_trackdog = player addAction [localize "str_actions_trackdog","\z\addons\dayz_code\actions\dog\track.sqf", _dogHandle, 4, false, true,"",""];
  342. };
  343. if (s_player_barkdog < 0) then {
  344. s_player_barkdog = player addAction [localize "str_actions_barkdog","\z\addons\dayz_code\actions\dog\speak.sqf", cursorTarget, 3, false, true,"",""];
  345. };
  346. if (s_player_warndog < 0) then {
  347. _warn = _dogHandle getFSMVariable "_watchDog";
  348. if (_warn) then { _text = "Quiet"; _warn = false; } else { _text = "Alert"; _warn = true; };
  349. s_player_warndog = player addAction [format[localize "str_actions_warndog",_text],"\z\addons\dayz_code\actions\dog\warn.sqf",[_dogHandle, _warn], 2, false, true,"",""];
  350. };
  351. if (s_player_followdog < 0) then {
  352. s_player_followdog = player addAction [localize "str_actions_followdog","\z\addons\dayz_code\actions\dog\follow.sqf",[_dogHandle,true], 6, false, true,"",""];
  353. };
  354. } else {
  355. player removeAction s_player_feeddog;
  356. s_player_feeddog = -1;
  357. player removeAction s_player_waterdog;
  358. s_player_waterdog = -1;
  359. player removeAction s_player_staydog;
  360. s_player_staydog = -1;
  361. player removeAction s_player_trackdog;
  362. s_player_trackdog = -1;
  363. player removeAction s_player_barkdog;
  364. s_player_barkdog = -1;
  365. player removeAction s_player_warndog;
  366. s_player_warndog = -1;
  367. player removeAction s_player_followdog;
  368. s_player_followdog = -1;
  369. };
  370. } else {
  371. //Extras
  372. //Remove Parts
  373. {silver_myCursorTarget removeAction _x} forEach s_player_removeActions;s_player_removeActions = [];
  374. silver_myCursorTarget = objNull;
  375. //Engineering
  376. {dayz_myCursorTarget removeAction _x} forEach s_player_repairActions;s_player_repairActions = [];
  377. dayz_myCursorTarget = objNull;
  378. //Others
  379. player removeAction s_player_forceSave;
  380. s_player_forceSave = -1;
  381. player removeAction s_player_flipveh;
  382. s_player_flipveh = -1;
  383. player removeAction s_player_sleep;
  384. s_player_sleep = -1;
  385. player removeAction s_player_deleteBuild;
  386. s_player_deleteBuild = -1;
  387. player removeAction s_player_butcher;
  388. s_player_butcher = -1;
  389. player removeAction s_player_cook;
  390. s_player_cook = -1;
  391. player removeAction s_player_boil;
  392. s_player_boil = -1;
  393. player removeAction s_player_fireout;
  394. s_player_fireout = -1;
  395. player removeAction s_player_packtent;
  396. s_player_packtent = -1;
  397. player removeAction s_player_fillfuel;
  398. s_player_fillfuel = -1;
  399. player removeAction s_player_studybody;
  400. s_player_studybody = -1;
  401. //Dog
  402. player removeAction s_player_tamedog;
  403. s_player_tamedog = -1;
  404. player removeAction s_player_feeddog;
  405. s_player_feeddog = -1;
  406. player removeAction s_player_waterdog;
  407. s_player_waterdog = -1;
  408. player removeAction s_player_staydog;
  409. s_player_staydog = -1;
  410. player removeAction s_player_trackdog;
  411. s_player_trackdog = -1;
  412. player removeAction s_player_barkdog;
  413. s_player_barkdog = -1;
  414. player removeAction s_player_warndog;
  415. s_player_warndog = -1;
  416. player removeAction s_player_followdog;
  417. s_player_followdog = -1;
  418. };
  419.  
  420. //Dog actions on player self
  421. _dogHandle = player getVariable ["dogID", 0];
  422. if (_dogHandle > 0) then {
  423. _dog = _dogHandle getFSMVariable "_dog";
  424. _ownerID = "0";
  425. if (!isNull cursorTarget) then { _ownerID = cursorTarget getVariable ["characterID","0"]; };
  426. if (_canDo and !_inVehicle and alive _dog and _ownerID != dayz_characterID) then {
  427. if (s_player_movedog < 0) then {
  428. s_player_movedog = player addAction [localize "str_actions_movedog", "\z\addons\dayz_code\actions\dog\move.sqf", player getVariable ["dogID", 0], 1, false, true, "", ""];
  429. };
  430. if (s_player_speeddog < 0) then {
  431. _text = "Walk";
  432. _speed = 0;
  433. if (_dog getVariable ["currentSpeed",1] == 0) then { _speed = 1; _text = "Run"; };
  434. 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, "", ""];
  435. };
  436. if (s_player_calldog < 0) then {
  437. 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, "", ""];
  438. };
  439. };
  440. } else {
  441. player removeAction s_player_movedog;
  442. s_player_movedog = -1;
  443. player removeAction s_player_speeddog;
  444. s_player_speeddog = -1;
  445. player removeAction s_player_calldog;
  446. s_player_calldog = -1;
  447. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement