Advertisement
Guest User

MPMissions/instance_11.Chernarus/scripts/fn_SelfActions

a guest
Mar 19th, 2015
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.75 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 ["_mags","_hastinitem","_canPickLight","_text","_driver","_hasRawMeat","_isFuel","_menu","_isHarvested","_isVehicle","_isVehicletype","_isMan","_ownerID","_isAnimal","_isZombie","_isDestructable","_isTent","_isStash","_isMediumStash","_hasFuel20","_hasFuel5","_isAlive","_canmove","_isPlant","_rawmeat","_vehicle","_inVehicle","_hasFuelE20","_hasFuelE5","_cursorTarget","_hasbottleitem","_primaryWeapon","_currentWeapon","_hasKnife","_hasToolbox","_onLadder","_nearLight","_canDo"];
  8.  
  9. _vehicle = vehicle player;
  10. _inVehicle = (_vehicle != player);
  11. //_bag = unitBackpack player;
  12. //_classbag = typeOf _bag;
  13. //_isWater = (surfaceIsWater (getPosATL player)) or dayz_isSwimming;
  14. //_hasAntiB = "ItemAntibiotic" in magazines player;
  15. _hasFuelE20 = "ItemJerrycanEmpty" in magazines player;
  16. _hasFuelE5 = "ItemFuelcanEmpty" in magazines player;
  17. _cursorTarget = cursorTarget;
  18. //boiled Water
  19. _hasbottleitem = "ItemWaterbottle" in magazines player;
  20. _hastinitem = false;
  21. _primaryWeapon = primaryWeapon player;
  22. _currentWeapon = currentWeapon player;
  23. {
  24. if (_x in magazines player) then {
  25. _hastinitem = true;
  26. };
  27.  
  28. } forEach boil_tin_cans;
  29.  
  30. _hasKnife = "ItemKnife" in items player;
  31. _hasToolbox = "ItemToolbox" in items player;
  32. //_hasTent = "ItemTent" in items player;
  33. _onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1;
  34. _nearLight = nearestObject [player,"LitObject"];
  35. _canPickLight = false;
  36.  
  37. if (!isNull _nearLight) then {
  38. if (_nearLight distance player < 4) then {
  39. _canPickLight = isNull (_nearLight getVariable ["owner",objNull]);
  40. };
  41. };
  42. _canDo = (!r_drag_sqf and !r_player_unconscious and !_onLadder);
  43.  
  44. // ---------------------------------------Maintain Area Start------------------------------------
  45. if (_canDo && (speed player <= 1) && (cursorTarget isKindOf "Plastic_Pole_EP1_DZ")) then {
  46. if (s_player_maintain_area < 0) then {
  47. s_player_maintain_area = player addAction ["<t color=""#ffffff"">Maintain Area</t>", "scripts\maintain_area.sqf", "maintain", 5, false];
  48. s_player_maintain_area_preview = player addAction ["<t color=""#ccffffff"">Maintain Area Preview</t>", "scripts\maintain_area.sqf", "preview", 5, false];
  49. };
  50. } else {
  51. player removeAction s_player_maintain_area;
  52. s_player_maintain_area = -1;
  53. player removeAction s_player_maintain_area_preview;
  54. s_player_maintain_area_preview = -1;
  55. };
  56. // ---------------------------------------Maintain Area End------------------------------------
  57. //Grab Flare
  58. if (_canPickLight and !dayz_hasLight) then {
  59. if (s_player_grabflare < 0) then {
  60. _text = getText (configFile >> "CfgAmmo" >> (typeOf _nearLight) >> "displayName");
  61. s_player_grabflare = player addAction [format[localize "str_actions_medical_15",_text], "\z\addons\dayz_code\actions\flare_pickup.sqf",_nearLight, 1, false, true, "", ""];
  62. s_player_removeflare = player addAction [format[localize "str_actions_medical_17",_text], "\z\addons\dayz_code\actions\flare_remove.sqf",_nearLight, 1, false, true, "", ""];
  63. };
  64. } else {
  65. player removeAction s_player_grabflare;
  66. player removeAction s_player_removeflare;
  67. s_player_grabflare = -1;
  68. s_player_removeflare = -1;
  69. };
  70.  
  71. if (dayz_onBack != "" && !dayz_onBackActive && !_inVehicle && !_onLadder && !r_player_unconscious) then {
  72. if (s_player_equip_carry < 0) then {
  73. _text = getText (configFile >> "CfgWeapons" >> dayz_onBack >> "displayName");
  74. s_player_equip_carry = player addAction [format[localize "STR_ACTIONS_WEAPON", _text], "\z\addons\dayz_code\actions\player_switchWeapon.sqf", "action", 0.5, false, true];
  75. };
  76. } else {
  77. player removeAction s_player_equip_carry;
  78. s_player_equip_carry = -1;
  79. };
  80.  
  81. //fishing
  82. if ((_currentWeapon in Dayz_fishingItems) && !dayz_fishingInprogress && !_inVehicle) then {
  83. if (s_player_fishing < 0) then {
  84. s_player_fishing = player addAction [localize "STR_ACTION_CAST", "\z\addons\dayz_code\actions\player_goFishing.sqf","action", 0.5, false, true];
  85. };
  86. } else {
  87. player removeAction s_player_fishing;
  88. s_player_fishing = -1;
  89. };
  90.  
  91. if (_inVehicle) then {
  92. //_assignedRole = assignedVehicleRole player;
  93. _driver = driver (vehicle player);
  94. if ((_primaryWeapon in Dayz_fishingItems) && !dayz_fishingInprogress && (_vehicle isKindOf "Ship") && (_driver != player)) then {
  95. if (s_player_fishing_veh < 0) then {
  96. s_player_fishing_veh = _vehicle addAction [localize "STR_ACTION_CAST", "\z\addons\dayz_code\actions\player_goFishing.sqf","action", 0.5, false, true];
  97. };
  98. } else {
  99. player removeAction s_player_fishing_veh;
  100. s_player_fishing_veh = -1;
  101. };
  102. } else {
  103. player removeAction s_player_fishing_veh;
  104. s_player_fishing_veh = -1;
  105. };
  106.  
  107. if (!isNull _cursorTarget and !_inVehicle and (player distance _cursorTarget < 4)) then { //Has some kind of target
  108. _isHarvested = _cursorTarget getVariable["meatHarvested",false];
  109. _isVehicle = _cursorTarget isKindOf "AllVehicles";
  110. _isVehicletype = typeOf _cursorTarget in ["ATV_US_EP1","ATV_CZ_EP1"];
  111. _isMan = _cursorTarget isKindOf "Man";
  112. _ownerID = _cursorTarget getVariable ["characterID","0"];
  113. _isAnimal = _cursorTarget isKindOf "Animal";
  114. _isZombie = _cursorTarget isKindOf "zZombie_base";
  115. _isDestructable = _cursorTarget isKindOf "BuiltItems";
  116. _isTent = _cursorTarget isKindOf "TentStorage";
  117. _isStash = _cursorTarget isKindOf "StashSmall";
  118. _isMediumStash = _cursorTarget isKindOf "StashMedium";
  119. _isFuel = false;
  120. _hasFuel20 = "ItemJerrycan" in magazines player;
  121. _hasFuel5 = "ItemFuelcan" in magazines player;
  122. _isAlive = alive _cursorTarget;
  123. _canmove = canmove _cursorTarget;
  124. _text = getText (configFile >> "CfgVehicles" >> typeOf _cursorTarget >> "displayName");
  125. _isPlant = typeOf _cursorTarget in Dayz_plants;
  126.  
  127. _rawmeat = meatraw;
  128. _hasRawMeat = false;
  129. {
  130. if (_x in magazines player) then {
  131. _hasRawMeat = true;
  132. };
  133. } forEach _rawmeat;
  134.  
  135. //gather
  136. if(_isPlant and _canDo) then {
  137. if (s_player_gather < 0) then {
  138. _text = getText (configFile >> "CfgVehicles" >> typeOf _cursorTarget >> "displayName");
  139. s_player_gather = player addAction [format[localize "str_actions_gather",_text], "\z\addons\dayz_code\actions\player_gather.sqf",_cursorTarget, 1, true, true, "", ""];
  140. };
  141. } else {
  142. player removeAction s_player_gather;
  143. s_player_gather = -1;
  144. };
  145. if (_hasFuelE20 or _hasFuelE5) then {
  146. _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");
  147. };
  148. //diag_log ("OWNERID = " + _ownerID + " CHARID = " + dayz_characterID + " " + str(_ownerID == dayz_characterID));
  149.  
  150. //Allow player to delete objects
  151. if(_isDestructable and _hasToolbox and _canDo) then {
  152. if (s_player_deleteBuild < 0) then {
  153. s_player_deleteBuild = player addAction [format[localize "str_actions_delete",_text], "\z\addons\dayz_code\actions\remove.sqf",_cursorTarget, 1, true, true, "", ""];
  154. };
  155. } else {
  156. player removeAction s_player_deleteBuild;
  157. s_player_deleteBuild = -1;
  158. };
  159.  
  160. //Allow player to force save
  161. if((_isVehicle or _isTent or _isStash or _isMediumStash) and _canDo and !_isMan and (damage _cursorTarget < 1)) then {
  162. if (s_player_forceSave < 0) then {
  163. s_player_forceSave = player addAction [format[localize "str_actions_save",_text], "\z\addons\dayz_code\actions\forcesave.sqf",_cursorTarget, 1, true, true, "", ""];
  164. };
  165. } else {
  166. player removeAction s_player_forceSave;
  167. s_player_forceSave = -1;
  168. };
  169.  
  170. //flip vehicle
  171. if ((_isVehicletype) and !_canmove and _isAlive and (player distance _cursorTarget >= 2) and (count (crew _cursorTarget))== 0 and ((vectorUp _cursorTarget) select 2) < 0.5) then {
  172. if (s_player_flipveh < 0) then {
  173. s_player_flipveh = player addAction [format[localize "str_actions_flipveh",_text], "\z\addons\dayz_code\actions\player_flipvehicle.sqf",_cursorTarget, 1, true, true, "", ""];
  174. };
  175. } else {
  176. player removeAction s_player_flipveh;
  177. s_player_flipveh = -1;
  178. };
  179.  
  180. //Allow player to fill Fuel can
  181. if((_hasFuelE20 or _hasFuelE5) and _isFuel and _canDo and !a_player_jerryfilling) then {
  182. if (s_player_fillfuel < 0) then {
  183. s_player_fillfuel = player addAction [localize "str_actions_self_10", "\z\addons\dayz_code\actions\jerry_fill.sqf",[], 1, false, true, "", ""];
  184. };
  185. } else {
  186. player removeAction s_player_fillfuel;
  187. s_player_fillfuel = -1;
  188. };
  189.  
  190. //Allow player to fill vehilce 20L
  191. if(_hasFuel20 and _canDo and _isVehicle and (fuel _cursorTarget < 1)) then {
  192. if (s_player_fillfuel20 < 0) then {
  193. s_player_fillfuel20 = player addAction [format[localize "str_actions_medical_10",_text,"20"], "\z\addons\dayz_code\actions\refuel.sqf",["ItemJerrycan"], 0, true, true, "", "'ItemJerrycan' in magazines player"];
  194. };
  195. } else {
  196. player removeAction s_player_fillfuel20;
  197. s_player_fillfuel20 = -1;
  198. };
  199.  
  200. //Allow player to fill vehilce 5L
  201. if(_hasFuel5 and _canDo and _isVehicle and (fuel _cursorTarget < 1)) then {
  202. if (s_player_fillfuel5 < 0) then {
  203. s_player_fillfuel5 = player addAction [format[localize "str_actions_medical_10",_text,"5"], "\z\addons\dayz_code\actions\refuel.sqf",["ItemFuelcan"], 0, true, true, "", "'ItemFuelcan' in magazines player"];
  204. };
  205. } else {
  206. player removeAction s_player_fillfuel5;
  207. s_player_fillfuel5 = -1;
  208. };
  209.  
  210. //Allow player to spihon vehicles
  211. if ((_hasFuelE20 or _hasFuelE5) and _isVehicle and _canDo and !a_player_jerryfilling and (fuel _cursorTarget > 0)) then {
  212. if (s_player_siphonfuel < 0) then {
  213. s_player_siphonfuel = player addAction [format[localize "str_siphon_start"], "\z\addons\dayz_code\actions\siphonFuel.sqf",_cursorTarget, 0, true, true, "", ""];
  214. };
  215. } else {
  216. player removeAction s_player_siphonfuel;
  217. s_player_siphonfuel = -1;
  218. };
  219.  
  220. //Harvested
  221. if (!alive _cursorTarget and _isAnimal and _hasKnife and !_isHarvested and _canDo) then {
  222. if (s_player_butcher < 0) then {
  223. s_player_butcher = player addAction [localize "str_actions_self_04", "\z\addons\dayz_code\actions\gather_meat.sqf",_cursorTarget, 3, true, true, "", ""];
  224. };
  225. } else {
  226. player removeAction s_player_butcher;
  227. s_player_butcher = -1;
  228. };
  229.  
  230. //Fireplace Actions check
  231. if (inflamed _cursorTarget and _hasRawMeat and _canDo and !a_player_cooking) then {
  232. if (s_player_cook < 0) then {
  233. s_player_cook = player addAction [localize "str_actions_self_05", "\z\addons\dayz_code\actions\cook.sqf",_cursorTarget, 3, true, true, "", ""];
  234. };
  235. } else {
  236. player removeAction s_player_cook;
  237. s_player_cook = -1;
  238. };
  239. if (inflamed _cursorTarget and (_hasbottleitem and _hastinitem) and _canDo and !a_player_boil) then {
  240. if (s_player_boil < 0) then {
  241. s_player_boil = player addAction [localize "str_actions_boilwater", "\z\addons\dayz_code\actions\boil.sqf",_cursorTarget, 3, true, true, "", ""];
  242. };
  243. } else {
  244. player removeAction s_player_boil;
  245. s_player_boil = -1;
  246. };
  247.  
  248. if(_cursorTarget == dayz_hasFire and _canDo) then {
  249. if ((s_player_fireout < 0) and !(inflamed _cursorTarget) and (player distance _cursorTarget < 3)) then {
  250. s_player_fireout = player addAction [localize "str_actions_self_06", "\z\addons\dayz_code\actions\fire_pack.sqf",_cursorTarget, 0, false, true, "",""];
  251. };
  252. } else {
  253. player removeAction s_player_fireout;
  254. s_player_fireout = -1;
  255. };
  256.  
  257. //Packing my tent
  258. if(_cursorTarget isKindOf "TentStorage" and _canDo and _ownerID == dayz_characterID) then {
  259. if ((s_player_packtent < 0) and (player distance _cursorTarget < 3)) then {
  260. s_player_packtent = player addAction [localize "str_actions_self_07", "\z\addons\dayz_code\actions\tent_pack.sqf",_cursorTarget, 0, false, true, "",""];
  261. };
  262. } else {
  263. player removeAction s_player_packtent;
  264. s_player_packtent = -1;
  265. };
  266. //Sleep
  267. if(_cursorTarget isKindOf "TentStorage" and _canDo and _ownerID == dayz_characterID) then {
  268. if ((s_player_sleep < 0) and (player distance _cursorTarget < 3)) then {
  269. s_player_sleep = player addAction [localize "str_actions_self_sleep", "\z\addons\dayz_code\actions\player_sleep.sqf",_cursorTarget, 0, false, true, "",""];
  270. };
  271. } else {
  272. player removeAction s_player_sleep;
  273. s_player_sleep = -1;
  274. };
  275. _clothesTaken = _cursorTarget getVariable["clothesTaken",false];
  276.  
  277. // Take clothes by Zabn
  278. if (_isMan and !_isAlive and !_isZombie and !_clothesTaken) then {
  279. if (s_player_clothes < 0) then {
  280. s_player_clothes = player addAction [("<t color='#0096ff'>")+("Take Clothes")+("</t>"), "scripts\player_takeClothes_v2.sqf",[_cursorTarget], -10, false, true, "",""];
  281. };
  282. } else {
  283. player removeAction s_player_clothes;
  284. s_player_clothes = -1;
  285. };
  286. //Repairing Vehicles
  287. if ((dayz_myCursorTarget != _cursorTarget) and _isVehicle and !_isMan and _hasToolbox and (damage _cursorTarget < 1)) then {
  288. if (s_player_repair_crtl < 0) then {
  289. dayz_myCursorTarget = _cursorTarget;
  290. _menu = dayz_myCursorTarget addAction [localize "str_actions_rapairveh", "\z\addons\dayz_code\actions\repair_vehicle.sqf",_cursorTarget, 0, true, false, "",""];
  291. //_menu1 = dayz_myCursorTarget addAction [localize "str_actions_salvageveh", "\z\addons\dayz_code\actions\salvage_vehicle.sqf",_cursorTarget, 0, true, false, "",""];
  292. s_player_repairActions set [count s_player_repairActions,_menu];
  293. //s_player_repairActions set [count s_player_repairActions,_menu1];
  294. s_player_repair_crtl = 1;
  295. } else {
  296. {dayz_myCursorTarget removeAction _x} forEach s_player_repairActions;s_player_repairActions = [];
  297. s_player_repair_crtl = -1;
  298. };
  299. };
  300. /*
  301. if (_isMan and !_isAlive) then {
  302. if (s_player_dragbody < 0) then {
  303. s_player_dragbody = player addAction [localize "str_action_studybody", "\z\addons\dayz_code\actions\drag_body.sqf",_cursorTarget, 0, false, true, "",""];
  304. };
  305. } else {
  306. player removeAction s_player_dragbody;
  307. s_player_dragbody = -1;
  308. };
  309. */
  310. if (_isMan and !_isAlive and !_isZombie) then {
  311. if (s_player_studybody < 0) then {
  312. s_player_studybody = player addAction [localize "str_action_studybody", "\z\addons\dayz_code\actions\study_body.sqf",_cursorTarget, 0, false, true, "",""];
  313. };
  314. } else {
  315. player removeAction s_player_studybody;
  316. s_player_studybody = -1;
  317. };
  318. } else {
  319. //Engineering
  320. {dayz_myCursorTarget removeAction _x} forEach s_player_repairActions;s_player_repairActions = [];
  321. player removeAction s_player_repair_crtl;
  322. s_player_repair_crtl = -1;
  323. dayz_myCursorTarget = objNull;
  324. //Others
  325. player removeAction s_player_forceSave;
  326. s_player_forceSave = -1;
  327. player removeAction s_player_flipveh;
  328. s_player_flipveh = -1;
  329. player removeAction s_player_sleep;
  330. s_player_sleep = -1;
  331. player removeAction s_player_deleteBuild;
  332. s_player_deleteBuild = -1;
  333. player removeAction s_player_butcher;
  334. s_player_butcher = -1;
  335. player removeAction s_player_cook;
  336. s_player_cook = -1;
  337. player removeAction s_player_boil;
  338. s_player_boil = -1;
  339. player removeAction s_player_fireout;
  340. s_player_fireout = -1;
  341. player removeAction s_player_packtent;
  342. s_player_packtent = -1;
  343. player removeAction s_player_fillfuel;
  344. s_player_fillfuel = -1;
  345. player removeAction s_player_studybody;
  346. s_player_studybody = -1;
  347. // Take Clothes by Zabn
  348. player removeAction s_player_clothes;
  349. s_player_clothes = -1;
  350. /*
  351. //Drag Body
  352. player removeAction s_player_dragbody;
  353. s_player_dragbody = -1;
  354. */
  355. //fuel
  356. player removeAction s_player_fillfuel20;
  357. s_player_fillfuel20 = -1;
  358. player removeAction s_player_fillfuel5;
  359. s_player_fillfuel5 = -1;
  360.  
  361. //Allow player to spihon vehicle fuel
  362. player removeAction s_player_siphonfuel;
  363. s_player_siphonfuel = -1;
  364.  
  365. //Allow player to gather
  366. player removeAction s_player_gather;
  367. s_player_gather = -1;
  368.  
  369. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement