Advertisement
Guest User

Untitled

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