Advertisement
Guest User

Untitled

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