Advertisement
Matt34

Untitled

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