Advertisement
Guest User

my fn_selfActions.sqf

a guest
Dec 7th, 2013
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 36.42 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 ["_isWreckBuilding","_temp_keys","_magazinesPlayer","_isPZombie","_vehicle","_inVehicle","_hasFuelE","_hasRawMeat","_hasKnife","_hasToolbox","_onLadder","_nearLight","_canPickLight","_canDo","_text","_isHarvested","_isVehicle","_isVehicletype","_isMan","_traderType","_ownerID","_isAnimal","_isDog","_isZombie","_isDestructable","_isTent","_isFuel","_isAlive","_Unlock","_lock","_buy","_dogHandle","_lieDown","_warn","_hastinitem","_allowedDistance","_menu","_menu1","_humanity_logic","_low_high","_cancel","_metals_trader","_traderMenu","_isWreck","_isRemovable","_isDisallowRepair","_rawmeat","_humanity","_speed","_dog","_hasbottleitem","_isAir","_isShip","_playersNear","_findNearestGens","_findNearestGen","_IsNearRunningGen","_cursorTarget","_isnewstorage","_itemsPlayer","_ownerKeyId","_typeOfCursorTarget","_hasKey","_oldOwner","_combi","_key_colors","_player_deleteBuild","_player_flipveh","_player_lockUnlock_crtl","_player_butcher","_player_studybody","_player_cook","_player_boil","_hasFuelBarrelE","_hasHotwireKit","_player_SurrenderedGear","_isSurrendered","_isModular","_ownerKeyName","_temp_keys_names"];
  8.  
  9. if (DZE_ActionInProgress) exitWith {}; // Do not allow if any script is running.
  10.  
  11. _vehicle = vehicle player;
  12. _isPZombie = player isKindOf "PZombie_VB";
  13. _inVehicle = (_vehicle != player);
  14.  
  15. _onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1;
  16. _canDo = (!r_drag_sqf and !r_player_unconscious and !_onLadder);
  17. // ---------------------------------------Krixes Self Bloodbag Start------------------------------------
  18. _mags = magazines player;
  19.  
  20. // Krixes Self Bloodbag
  21. if ("ItemBloodbag" in _mags) then {
  22. hasBagItem = true;
  23. } else { hasBagItem = false;};
  24. if((speed player <= 1) && hasBagItem && _canDo) then {
  25. if (s_player_selfBloodbag < 0) then {
  26. s_player_selfBloodbag = player addaction[("<t color=""#c70000"">" + ("Self Bloodbag") +"</t>"),"Scripts\player_selfbloodbag.sqf","",5,false,true,"", ""];
  27. };
  28. } else {
  29. player removeAction s_player_selfBloodbag;
  30. s_player_selfBloodbag = -1;
  31. };
  32. // ---------------------------------------Krixes Self Bloodbag End------------------------------------
  33.  
  34. // ---------------------------------------Maintain Area Start------------------------------------
  35. if (_canDo && (speed player <= 1) && (cursorTarget isKindOf "Plastic_Pole_EP1_DZ")) then {
  36. if (s_player_maintain_area < 0) then {
  37. s_player_maintain_area = player addAction ["<t color=""#ffffff"">Maintain Area</t>", "\z\addons\dayz_code\actions\maintain_area.sqf", "maintain", 5, false];
  38. s_player_maintain_area_preview = player addAction ["<t color=""#ccffffff"">Maintain Area Preview</t>", "\z\addons\dayz_code\actions\maintain_area.sqf", "preview", 5, false];
  39. };
  40. } else {
  41. player removeAction s_player_maintain_area;
  42. s_player_maintain_area = -1;
  43. player removeAction s_player_maintain_area_preview;
  44. s_player_maintain_area_preview = -1;
  45. };
  46. // ---------------------------------------Maintain Area End------------------------------------
  47.  
  48. _nearLight = nearestObject [player,"LitObject"];
  49. _canPickLight = false;
  50. if (!isNull _nearLight) then {
  51. if (_nearLight distance player < 4) then {
  52. _canPickLight = isNull (_nearLight getVariable ["owner",objNull]);
  53. };
  54. };
  55.  
  56. //Grab Flare
  57. if (_canPickLight and !dayz_hasLight and !_isPZombie) then {
  58. if (s_player_grabflare < 0) then {
  59. _text = getText (configFile >> "CfgAmmo" >> (typeOf _nearLight) >> "displayName");
  60. s_player_grabflare = player addAction [format[localize "str_actions_medical_15",_text], "\z\addons\dayz_code\actions\flare_pickup.sqf",_nearLight, 1, false, true, "", ""];
  61. s_player_removeflare = player addAction [format[localize "str_actions_medical_17",_text], "\z\addons\dayz_code\actions\flare_remove.sqf",_nearLight, 1, false, true, "", ""];
  62. };
  63. } else {
  64. player removeAction s_player_grabflare;
  65. player removeAction s_player_removeflare;
  66. s_player_grabflare = -1;
  67. s_player_removeflare = -1;
  68. };
  69.  
  70. if(DZE_HaloJump) then {
  71. if(_inVehicle and (_vehicle isKindOf "Air") and ((getPos _vehicle select 2) > 400)) then {
  72. if (s_halo_action < 0) then {
  73. DZE_myHaloVehicle = _vehicle;
  74. s_halo_action = DZE_myHaloVehicle addAction ["HALO Jump","\z\addons\dayz_code\actions\halo_jump.sqf",[],2,false,true,"",""];
  75. };
  76. } else {
  77. DZE_myHaloVehicle removeAction s_halo_action;
  78. s_halo_action = -1;
  79. };
  80. };
  81.  
  82. if (!DZE_ForceNameTagsOff) then {
  83. if (s_player_showname < 0 and !_isPZombie) then {
  84. if (DZE_ForceNameTags) then {
  85. s_player_showname = 1;
  86. player setVariable["DZE_display_name",true,true];
  87. } else {
  88. s_player_showname = player addAction ["Display Name (Yes)", "\z\addons\dayz_code\actions\display_name.sqf",true, 0, true, false, "",""];
  89. s_player_showname1 = player addAction ["Display Name (No)", "\z\addons\dayz_code\actions\display_name.sqf",false, 0, true, false, "",""];
  90. };
  91. };
  92. };
  93.  
  94. if(_isPZombie) then {
  95. if (s_player_callzombies < 0) then {
  96. s_player_callzombies = player addAction ["Raise Horde", "\z\addons\dayz_code\actions\call_zombies.sqf",player, 5, true, false, "",""];
  97. };
  98. if (DZE_PZATTACK) then {
  99. call pz_attack;
  100. DZE_PZATTACK = false;
  101. };
  102. if (s_player_pzombiesvision < 0) then {
  103. s_player_pzombiesvision = player addAction ["Night Vision", "\z\addons\dayz_code\actions\pzombie\pz_vision.sqf", [], 4, false, true, "nightVision", "_this == _target"];
  104. };
  105. if (!isNull cursorTarget and (player distance cursorTarget < 3)) then { //Has some kind of target
  106. _isAnimal = cursorTarget isKindOf "Animal";
  107. _isZombie = cursorTarget isKindOf "zZombie_base";
  108. _isHarvested = cursorTarget getVariable["meatHarvested",false];
  109. _isMan = cursorTarget isKindOf "Man";
  110. // Pzombie Gut human corpse or animal
  111. if (!alive cursorTarget and (_isAnimal or _isMan) and !_isZombie and !_isHarvested) then {
  112. if (s_player_pzombiesfeed < 0) then {
  113. s_player_pzombiesfeed = player addAction ["Feed", "\z\addons\dayz_code\actions\pzombie\pz_feed.sqf",cursorTarget, 3, true, false, "",""];
  114. };
  115. } else {
  116. player removeAction s_player_pzombiesfeed;
  117. s_player_pzombiesfeed = -1;
  118. };
  119. } else {
  120. player removeAction s_player_pzombiesfeed;
  121. s_player_pzombiesfeed = -1;
  122. };
  123. };
  124.  
  125. // Increase distance only if AIR OR SHIP
  126. _allowedDistance = 4;
  127. _isAir = cursorTarget isKindOf "Air";
  128. _isShip = cursorTarget isKindOf "Ship";
  129. if(_isAir or _isShip) then {
  130. _allowedDistance = 6;
  131. };
  132.  
  133. if (!isNull cursorTarget and !_inVehicle and !_isPZombie and (player distance cursorTarget < _allowedDistance) and _canDo) then { //Has some kind of target
  134.  
  135. // set cursortarget to variable
  136. _cursorTarget = cursorTarget;
  137.  
  138. // get typeof cursortarget once
  139. _typeOfCursorTarget = typeOf _cursorTarget;
  140.  
  141. // hintsilent _typeOfCursorTarget;
  142.  
  143. _isVehicle = _cursorTarget isKindOf "AllVehicles";
  144. _isVehicletype = _typeOfCursorTarget in ["ATV_US_EP1","ATV_CZ_EP1"];
  145. _isnewstorage = _typeOfCursorTarget in DZE_isNewStorage;
  146.  
  147. // get items and magazines only once
  148. _magazinesPlayer = magazines player;
  149.  
  150. //boiled Water
  151. _hasbottleitem = "ItemWaterbottle" in _magazinesPlayer;
  152. _hastinitem = false;
  153. {
  154. if (_x in _magazinesPlayer) then {
  155. _hastinitem = true;
  156. };
  157. } forEach boil_tin_cans;
  158. _hasFuelE = "ItemJerrycanEmpty" in _magazinesPlayer;
  159. _hasFuelBarrelE = "ItemFuelBarrelEmpty" in _magazinesPlayer;
  160. _hasHotwireKit = "ItemHotwireKit" in _magazinesPlayer;
  161.  
  162. _itemsPlayer = items player;
  163.  
  164. _temp_keys = [];
  165. _temp_keys_names = [];
  166. // find available keys
  167. _key_colors = ["ItemKeyYellow","ItemKeyBlue","ItemKeyRed","ItemKeyGreen","ItemKeyBlack"];
  168. {
  169. if (configName(inheritsFrom(configFile >> "CfgWeapons" >> _x)) in _key_colors) then {
  170. _ownerKeyId = getNumber(configFile >> "CfgWeapons" >> _x >> "keyid");
  171. _ownerKeyName = getText(configFile >> "CfgWeapons" >> _x >> "displayName");
  172. _temp_keys_names set [_ownerKeyId,_ownerKeyName];
  173. _temp_keys set [count _temp_keys,str(_ownerKeyId)];
  174. };
  175. } forEach _itemsPlayer;
  176.  
  177. _hasKnife = "ItemKnife" in _itemsPlayer;
  178. _hasToolbox = "ItemToolbox" in _itemsPlayer;
  179.  
  180. _isMan = _cursorTarget isKindOf "Man";
  181. _traderType = _typeOfCursorTarget;
  182. _ownerID = _cursorTarget getVariable ["CharacterID","0"];
  183. _isAnimal = _cursorTarget isKindOf "Animal";
  184. _isDog = (_cursorTarget isKindOf "DZ_Pastor" || _cursorTarget isKindOf "DZ_Fin");
  185. _isZombie = _cursorTarget isKindOf "zZombie_base";
  186. _isDestructable = _cursorTarget isKindOf "BuiltItems";
  187. _isWreck = _typeOfCursorTarget in DZE_isWreck;
  188. _isWreckBuilding = _typeOfCursorTarget in DZE_isWreckBuilding;
  189. _isModular = _cursorTarget isKindOf "ModularItems";
  190.  
  191. _isRemovable = _typeOfCursorTarget in DZE_isRemovable;
  192. _isDisallowRepair = _typeOfCursorTarget in ["M240Nest_DZ"];
  193.  
  194. _isTent = _cursorTarget isKindOf "TentStorage";
  195.  
  196. _isAlive = alive _cursorTarget;
  197.  
  198. _text = getText (configFile >> "CfgVehicles" >> _typeOfCursorTarget >> "displayName");
  199.  
  200. _rawmeat = meatraw;
  201. _hasRawMeat = false;
  202. {
  203. if (_x in _magazinesPlayer) then {
  204. _hasRawMeat = true;
  205. };
  206. } forEach _rawmeat;
  207.  
  208. _isFuel = false;
  209. if (_hasFuelE or _hasFuelBarrelE) then {
  210. {
  211. if(_cursorTarget isKindOf _x) exitWith {_isFuel = true;};
  212. } forEach dayz_fuelsources;
  213. };
  214.  
  215. // diag_log ("OWNERID = " + _ownerID + " CHARID = " + dayz_characterID + " " + str(_ownerID == dayz_characterID));
  216.  
  217. // logic vars
  218. _player_flipveh = false;
  219. _player_deleteBuild = false;
  220. _player_lockUnlock_crtl = false;
  221.  
  222. // CURSOR TARGET ALIVE
  223. if(_isAlive) then {
  224.  
  225. //Allow player to delete objects
  226. if(_isDestructable or _isWreck or _isRemovable or _isWreckBuilding) then {
  227. if(_hasToolbox and "ItemCrowbar" in _itemsPlayer) then {
  228. _player_deleteBuild = true;
  229. };
  230. };
  231.  
  232. //Allow owners to delete modulars
  233. if(_isModular and (dayz_characterID == _ownerID)) then {
  234. if(_hasToolbox and "ItemCrowbar" in _itemsPlayer) then {
  235. _player_deleteBuild = true;
  236. };
  237. };
  238.  
  239. // CURSOR TARGET VEHICLE
  240. if(_isVehicle) then {
  241.  
  242. //flip vehicle small vehicles by your self and all other vehicles with help nearby
  243. if (!(canmove _cursorTarget) and (player distance _cursorTarget >= 2) and (count (crew _cursorTarget))== 0 and ((vectorUp _cursorTarget) select 2) < 0.5) then {
  244. _playersNear = {isPlayer _x} count (player nearEntities ["CAManBase", 6]);
  245. if(_isVehicletype or (_playersNear >= 2)) then {
  246. _player_flipveh = true;
  247. };
  248. };
  249.  
  250.  
  251. if(!_isMan and _ownerID != "0" and !(_cursorTarget isKindOf "Bicycle")) then {
  252. _player_lockUnlock_crtl = true;
  253. };
  254.  
  255. };
  256.  
  257. };
  258.  
  259. if(_player_deleteBuild) then {
  260. if (s_player_deleteBuild < 0) then {
  261. s_player_deleteBuild = player addAction [format[localize "str_actions_delete",_text], "\z\addons\dayz_code\actions\remove.sqf",_cursorTarget, 1, true, true, "", ""];
  262. };
  263. } else {
  264. player removeAction s_player_deleteBuild;
  265. s_player_deleteBuild = -1;
  266. };
  267.  
  268.  
  269. // Allow Owner to lock and unlock vehicle
  270. if(_player_lockUnlock_crtl) then {
  271. if (s_player_lockUnlock_crtl < 0) then {
  272. _hasKey = _ownerID in _temp_keys;
  273. _oldOwner = (_ownerID == dayz_playerUID);
  274. if(locked _cursorTarget) then {
  275. if(_hasKey or _oldOwner) then {
  276. _Unlock = player addAction [format["Unlock %1",_text], "\z\addons\dayz_code\actions\unlock_veh.sqf",[_cursorTarget,(_temp_keys_names select (parseNumber _ownerID))], 2, true, true, "", ""];
  277. s_player_lockunlock set [count s_player_lockunlock,_Unlock];
  278. s_player_lockUnlock_crtl = 1;
  279. } else {
  280. if(_hasHotwireKit) then {
  281. _Unlock = player addAction [format["Hotwire %1",_text], "\z\addons\dayz_code\actions\hotwire_veh.sqf",_cursorTarget, 2, true, true, "", ""];
  282. } else {
  283. _Unlock = player addAction ["<t color='#ff0000'>Vehicle Locked</t>", "",_cursorTarget, 2, true, true, "", ""];
  284. };
  285. s_player_lockunlock set [count s_player_lockunlock,_Unlock];
  286. s_player_lockUnlock_crtl = 1;
  287. };
  288. } else {
  289. if(_hasKey or _oldOwner) then {
  290. _lock = player addAction [format["Lock %1",_text], "\z\addons\dayz_code\actions\lock_veh.sqf",_cursorTarget, 1, true, true, "", ""];
  291. s_player_lockunlock set [count s_player_lockunlock,_lock];
  292. s_player_lockUnlock_crtl = 1;
  293. };
  294. };
  295. };
  296.  
  297. } else {
  298. {player removeAction _x} forEach s_player_lockunlock;s_player_lockunlock = [];
  299. s_player_lockUnlock_crtl = -1;
  300. };
  301.  
  302. if(DZE_AllowForceSave) then {
  303. //Allow player to force save
  304. if((_isVehicle or _isTent) and !_isMan) then {
  305. if (s_player_forceSave < 0) then {
  306. s_player_forceSave = player addAction [format[localize "str_actions_save",_text], "\z\addons\dayz_code\actions\forcesave.sqf",_cursorTarget, 1, true, true, "", ""];
  307. };
  308. } else {
  309. player removeAction s_player_forceSave;
  310. s_player_forceSave = -1;
  311. };
  312. };
  313.  
  314.  
  315.  
  316. If(DZE_AllowCargoCheck) then {
  317. if((_isVehicle or _isTent or _isnewstorage) and _isAlive and !_isMan and !locked _cursorTarget) then {
  318. if (s_player_checkGear < 0) then {
  319. s_player_checkGear = player addAction [localize "STR_EPOCH_PLAYER_CARGO", "\z\addons\dayz_code\actions\cargocheck.sqf",_cursorTarget, 1, true, true, "", ""];
  320. };
  321. } else {
  322. player removeAction s_player_checkGear;
  323. s_player_checkGear = -1;
  324. };
  325. };
  326.  
  327.  
  328. //flip vehicle small vehicles by your self and all other vehicles with help nearby
  329. if(_player_flipveh) then {
  330. if (s_player_flipveh < 0) then {
  331. s_player_flipveh = player addAction [format[localize "str_actions_flipveh",_text], "\z\addons\dayz_code\actions\player_flipvehicle.sqf",_cursorTarget, 1, true, true, "", ""];
  332. };
  333. } else {
  334. player removeAction s_player_flipveh;
  335. s_player_flipveh = -1;
  336. };
  337.  
  338. //Allow player to fill jerrycan
  339. if((_hasFuelE or _hasFuelBarrelE) and _isFuel) then {
  340. if (s_player_fillfuel < 0) then {
  341. s_player_fillfuel = player addAction [localize "str_actions_self_10", "\z\addons\dayz_code\actions\jerry_fill.sqf",[], 1, false, true, "", ""];
  342. };
  343. } else {
  344. player removeAction s_player_fillfuel;
  345. s_player_fillfuel = -1;
  346. };
  347.  
  348. // logic vars for addactions
  349. _player_butcher = false;
  350. _player_studybody = false;
  351. _player_SurrenderedGear = false;
  352.  
  353. // CURSOR TARGET NOT ALIVE
  354. if (!_isAlive) then {
  355.  
  356. // Gut animal/zed
  357. if((_isAnimal or _isZombie) and _hasKnife) then {
  358. _isHarvested = _cursorTarget getVariable["meatHarvested",false];
  359. if (!_isHarvested) then {
  360. _player_butcher = true;
  361. };
  362. };
  363.  
  364. // Study body
  365. if (_isMan and !_isZombie and !_isAnimal) then {
  366. _player_studybody = true;
  367. }
  368. } else {
  369. // unit alive
  370.  
  371. // gear access on surrendered player
  372. if(_isMan and !_isZombie and !_isAnimal) then {
  373. _isSurrendered = _cursorTarget getVariable ["DZE_Surrendered",false];
  374. if (_isSurrendered) then {
  375. _player_SurrenderedGear = true;
  376. };
  377. };
  378. };
  379.  
  380.  
  381. // Human Gut animal or zombie
  382. if (_player_butcher) then {
  383. if (s_player_butcher < 0) then {
  384. if(_isZombie) then {
  385. s_player_butcher = player addAction ["Gut Zombie", "\z\addons\dayz_code\actions\gather_zparts.sqf",_cursorTarget, 0, true, true, "", ""];
  386. } else {
  387. s_player_butcher = player addAction [localize "str_actions_self_04", "\z\addons\dayz_code\actions\gather_meat.sqf",_cursorTarget, 3, true, true, "", ""];
  388. };
  389. };
  390. } else {
  391. player removeAction s_player_butcher;
  392. s_player_butcher = -1;
  393. };
  394.  
  395. // Study Body
  396. if (_player_studybody) then {
  397. if (s_player_studybody < 0) then {
  398. s_player_studybody = player addAction [localize "str_action_studybody", "\z\addons\dayz_code\actions\study_body.sqf",_cursorTarget, 0, false, true, "",""];
  399. };
  400. } else {
  401. player removeAction s_player_studybody;
  402. s_player_studybody = -1;
  403. };
  404.  
  405. // logic vars
  406. _player_cook = false;
  407. _player_boil = false;
  408.  
  409. // CURSOR TARGET IS FIRE
  410. if (inflamed _cursorTarget) then {
  411.  
  412. //Fireplace Actions check
  413. if (_hasRawMeat) then {
  414. _player_cook = true;
  415. };
  416.  
  417. // Boil water
  418. if (_hasbottleitem and _hastinitem) then {
  419. _player_boil = true;
  420. };
  421. };
  422.  
  423. if (_player_SurrenderedGear) then {
  424. if (s_player_SurrenderedGear < 0) then {
  425. s_player_SurrenderedGear = player addAction ["Gear", "\z\addons\dayz_code\actions\surrender_gear.sqf",_cursorTarget, 1, true, true, "", ""];
  426. };
  427. } else {
  428. player removeAction s_player_SurrenderedGear;
  429. s_player_SurrenderedGear = -1;
  430. };
  431.  
  432. //Fireplace Actions check
  433. if (_player_cook) then {
  434. if (s_player_cook < 0) then {
  435. s_player_cook = player addAction [localize "str_actions_self_05", "\z\addons\dayz_code\actions\cook.sqf",_cursorTarget, 3, true, true, "", ""];
  436. };
  437. } else {
  438. player removeAction s_player_cook;
  439. s_player_cook = -1;
  440. };
  441.  
  442. // Boil water
  443. if (_player_boil) then {
  444. if (s_player_boil < 0) then {
  445. s_player_boil = player addAction [localize "str_actions_boilwater", "\z\addons\dayz_code\actions\boil.sqf",_cursorTarget, 3, true, true, "", ""];
  446. };
  447. } else {
  448. player removeAction s_player_boil;
  449. s_player_boil = -1;
  450. };
  451.  
  452. if(_cursorTarget == dayz_hasFire) then {
  453. if ((s_player_fireout < 0) and !(inflamed _cursorTarget) and (player distance _cursorTarget < 3)) then {
  454. s_player_fireout = player addAction [localize "str_actions_self_06", "\z\addons\dayz_code\actions\fire_pack.sqf",_cursorTarget, 0, false, true, "",""];
  455. };
  456. } else {
  457. player removeAction s_player_fireout;
  458. s_player_fireout = -1;
  459. };
  460.  
  461. //Packing my tent
  462. if(_isTent and (player distance _cursorTarget < 3)) then {
  463. if (_ownerID == dayz_characterID) then {
  464. if (s_player_packtent < 0) then {
  465. s_player_packtent = player addAction [localize "str_actions_self_07", "\z\addons\dayz_code\actions\tent_pack.sqf",_cursorTarget, 0, false, true, "",""];
  466. };
  467. } else {
  468. if(("ItemJerrycan" in _magazinesPlayer) and ("ItemMatchbox_DZE" in weapons player)) then {
  469. if (s_player_packtent < 0) then {
  470. s_player_packtent = player addAction ["Destroy Tent", "\z\addons\dayz_code\actions\remove.sqf",_cursorTarget, 1, true, true, "", ""];
  471. };
  472. };
  473. };
  474. } else {
  475. player removeAction s_player_packtent;
  476. s_player_packtent = -1;
  477. };
  478.  
  479. //Allow owner to unlock vault
  480. if((_typeOfCursorTarget in DZE_LockableStorage) and _ownerID != "0" and (player distance _cursorTarget < 3)) then {
  481. if (s_player_unlockvault < 0) then {
  482. if(_typeOfCursorTarget in DZE_LockedStorage) then {
  483. if(_ownerID == dayz_combination or _ownerID == dayz_playerUID) then {
  484. _combi = player addAction [format["Open %1",_text], "\z\addons\dayz_code\actions\vault_unlock.sqf",_cursorTarget, 0, false, true, "",""];
  485. s_player_combi set [count s_player_combi,_combi];
  486. } else {
  487. _combi = player addAction [format["Unlock %1",_text], "\z\addons\dayz_code\actions\vault_combination_1.sqf",_cursorTarget, 0, false, true, "",""];
  488. s_player_combi set [count s_player_combi,_combi];
  489. };
  490. s_player_unlockvault = 1;
  491. } else {
  492. if(_ownerID != dayz_combination and _ownerID != dayz_playerUID) then {
  493. _combi = player addAction ["Re-Enter Combination", "\z\addons\dayz_code\actions\vault_combination_1.sqf",_cursorTarget, 0, false, true, "",""];
  494. s_player_combi set [count s_player_combi,_combi];
  495. s_player_unlockvault = 1;
  496. };
  497. };
  498. };
  499. } else {
  500. {player removeAction _x} forEach s_player_combi;s_player_combi = [];
  501. s_player_unlockvault = -1;
  502. };
  503.  
  504. //Allow owner to pack vault
  505. if(_typeOfCursorTarget in DZE_UnLockedStorage and _ownerID != "0" and (player distance _cursorTarget < 3)) then {
  506.  
  507. if (s_player_lockvault < 0) then {
  508. if(_ownerID == dayz_combination or _ownerID == dayz_playerUID) then {
  509. s_player_lockvault = player addAction [format["Lock %1",_text], "\z\addons\dayz_code\actions\vault_lock.sqf",_cursorTarget, 0, false, true, "",""];
  510. };
  511. };
  512. if (s_player_packvault < 0 and (_ownerID == dayz_combination or _ownerID == dayz_playerUID)) then {
  513. s_player_packvault = player addAction [format["<t color='#ff0000'>Pack %1</t>",_text], "\z\addons\dayz_code\actions\vault_pack.sqf",_cursorTarget, 0, false, true, "",""];
  514. };
  515. } else {
  516. player removeAction s_player_packvault;
  517. s_player_packvault = -1;
  518. player removeAction s_player_lockvault;
  519. s_player_lockvault = -1;
  520. };
  521.  
  522.  
  523.  
  524. //Player Deaths
  525. if(_typeOfCursorTarget == "Info_Board_EP1") then {
  526. if (s_player_information < 0) then {
  527. s_player_information = player addAction ["Recent Murders", "\z\addons\dayz_code\actions\list_playerDeaths.sqf",[], 7, false, true, "",""];
  528. };
  529. } else {
  530. player removeAction s_player_information;
  531. s_player_information = -1;
  532. };
  533.  
  534. //Fuel Pump
  535. if(_typeOfCursorTarget in dayz_fuelpumparray) then {
  536. if (s_player_fuelauto < 0) then {
  537.  
  538. // check if Generator_DZ is running within 30 meters
  539. _findNearestGens = nearestObjects [player, ["Generator_DZ"], 30];
  540. _findNearestGen = [];
  541. {
  542. if (alive _x and (_x getVariable ["GeneratorRunning", false])) then {
  543. _findNearestGen set [(count _findNearestGen),_x];
  544. };
  545. } foreach _findNearestGens;
  546. _IsNearRunningGen = count (_findNearestGen);
  547.  
  548. // show that pump needs power if no generator nearby.
  549. if(_IsNearRunningGen > 0) then {
  550. s_player_fuelauto = player addAction ["Fill Vehicle", "\z\addons\dayz_code\actions\fill_nearestVehicle.sqf",objNull, 0, false, true, "",""];
  551. } else {
  552. s_player_fuelauto = player addAction ["<t color='#ff0000'>Needs Power</t>", "",[], 0, false, true, "",""];
  553. };
  554. };
  555. } else {
  556. player removeAction s_player_fuelauto;
  557. s_player_fuelauto = -1;
  558. };
  559.  
  560. //Fuel Pump on truck
  561. if(_typeOfCursorTarget in DZE_fueltruckarray and alive _cursorTarget) then {
  562. if (s_player_fuelauto2 < 0) then {
  563. // show that fuel truck pump needs power.
  564. if(isEngineOn _cursorTarget) then {
  565. s_player_fuelauto2 = player addAction ["Fill Vehicle", "\z\addons\dayz_code\actions\fill_nearestVehicle.sqf",_cursorTarget, 0, false, true, "",""];
  566. } else {
  567. s_player_fuelauto2 = player addAction ["<t color='#ff0000'>Needs Power</t>", "",[], 0, false, true, "",""];
  568. };
  569. };
  570. } else {
  571. player removeAction s_player_fuelauto2;
  572. s_player_fuelauto2 = -1;
  573. };
  574.  
  575. // inplace upgrade tool
  576. if ((_cursorTarget isKindOf "ModularItems") or (_cursorTarget isKindOf "Land_DZE_WoodDoor_Base") or (_cursorTarget isKindOf "CinderWallDoor_DZ_Base")) then {
  577. if ((s_player_lastTarget select 0) != _cursorTarget) then {
  578. if (s_player_upgrade_build > 0) then {
  579. player removeAction s_player_upgrade_build;
  580. s_player_upgrade_build = -1;
  581. };
  582. };
  583. if (s_player_upgrade_build < 0) then {
  584. // s_player_lastTarget = _cursorTarget;
  585. s_player_lastTarget set [0,_cursorTarget];
  586. s_player_upgrade_build = player addAction [format["Upgrade %1",_text], "\z\addons\dayz_code\actions\player_upgrade.sqf",_cursorTarget, -1, false, true, "",""];
  587. };
  588. } else {
  589. player removeAction s_player_upgrade_build;
  590. s_player_upgrade_build = -1;
  591. };
  592.  
  593. // downgrade system
  594. if((_isDestructable or _cursorTarget isKindOf "Land_DZE_WoodDoorLocked_Base" or _cursorTarget isKindOf "CinderWallDoorLocked_DZ_Base") and (DZE_Lock_Door == _ownerID)) then {
  595. if ((s_player_lastTarget select 1) != _cursorTarget) then {
  596. if (s_player_downgrade_build > 0) then {
  597. player removeAction s_player_downgrade_build;
  598. s_player_downgrade_build = -1;
  599. };
  600. };
  601.  
  602. if (s_player_downgrade_build < 0) then {
  603. s_player_lastTarget set [1,_cursorTarget];
  604. s_player_downgrade_build = player addAction [format["Remove Lock from %1",_text], "\z\addons\dayz_code\actions\player_buildingDowngrade.sqf",_cursorTarget, -2, false, true, "",""];
  605. };
  606. } else {
  607. player removeAction s_player_downgrade_build;
  608. s_player_downgrade_build = -1;
  609. };
  610.  
  611. // inplace maintenance tool
  612. if((_cursorTarget isKindOf "ModularItems" or _cursorTarget isKindOf "DZE_Housebase" or _typeOfCursorTarget in DZE_ExtraMaintain) and (damage _cursorTarget >= 0.1)) then {
  613. if ((s_player_lastTarget select 2) != _cursorTarget) then {
  614. if (s_player_maint_build > 0) then {
  615. player removeAction s_player_maint_build;
  616. s_player_maint_build = -1;
  617. };
  618. };
  619.  
  620. if (s_player_maint_build < 0) then {
  621. s_player_lastTarget set [2,_cursorTarget];
  622. s_player_maint_build = player addAction [format["Maintain %1",_text], "\z\addons\dayz_code\actions\player_buildingMaint.sqf",_cursorTarget, -2, false, true, "",""];
  623. };
  624. } else {
  625. player removeAction s_player_maint_build;
  626. s_player_maint_build = -1;
  627. };
  628.  
  629.  
  630. //Start Generator
  631. if(_cursorTarget isKindOf "Generator_DZ") then {
  632. if (s_player_fillgen < 0) then {
  633.  
  634. // check if not running
  635. if((_cursorTarget getVariable ["GeneratorRunning", false])) then {
  636. s_player_fillgen = player addAction ["Stop Generator", "\z\addons\dayz_code\actions\stopGenerator.sqf",_cursorTarget, 0, false, true, "",""];
  637. } else {
  638. // check if not filled and player has jerry.
  639. if((_cursorTarget getVariable ["GeneratorFilled", false])) then {
  640. s_player_fillgen = player addAction ["Start Generator", "\z\addons\dayz_code\actions\fill_startGenerator.sqf",_cursorTarget, 0, false, true, "",""];
  641. } else {
  642. if("ItemJerrycan" in _magazinesPlayer) then {
  643. s_player_fillgen = player addAction ["Fill and Start Generator", "\z\addons\dayz_code\actions\fill_startGenerator.sqf",_cursorTarget, 0, false, true, "",""];
  644. };
  645. };
  646. };
  647. };
  648. } else {
  649. player removeAction s_player_fillgen;
  650. s_player_fillgen = -1;
  651. };
  652.  
  653. //Towing with tow truck
  654. /*
  655. if(_typeOfCursorTarget == "TOW_DZE") then {
  656. if (s_player_towing < 0) then {
  657. if(!(_cursorTarget getVariable ["DZEinTow", false])) then {
  658. s_player_towing = player addAction ["Attach Straps", "\z\addons\dayz_code\actions\tow_AttachStraps.sqf",_cursorTarget, 0, false, true, "",""];
  659. } else {
  660. s_player_towing = player addAction ["Detach Straps", "\z\addons\dayz_code\actions\tow_DetachStraps.sqf",_cursorTarget, 0, false, true, "",""];
  661. };
  662. };
  663. } else {
  664. player removeAction s_player_towing;
  665. s_player_towing = -1;
  666. };
  667. */
  668.  
  669.  
  670. //Sleep
  671. if(_isTent and _ownerID == dayz_characterID) then {
  672. if ((s_player_sleep < 0) and (player distance _cursorTarget < 3)) then {
  673. s_player_sleep = player addAction [localize "str_actions_self_sleep", "\z\addons\dayz_code\actions\player_sleep.sqf",_cursorTarget, 0, false, true, "",""];
  674. };
  675. } else {
  676. player removeAction s_player_sleep;
  677. s_player_sleep = -1;
  678. };
  679.  
  680. //Repairing Vehicles
  681. if ((dayz_myCursorTarget != _cursorTarget) and _isVehicle and !_isMan and _hasToolbox and (damage _cursorTarget < 1) and !_isDisallowRepair) then {
  682. if (s_player_repair_crtl < 0) then {
  683. dayz_myCursorTarget = _cursorTarget;
  684. _menu = dayz_myCursorTarget addAction [localize "STR_EPOCH_PLAYER_REPAIRV", "\z\addons\dayz_code\actions\repair_vehicle.sqf",_cursorTarget, 0, true, false, "",""];
  685. _menu1 = dayz_myCursorTarget addAction [localize "STR_EPOCH_PLAYER_SALVAGEV", "\z\addons\dayz_code\actions\salvage_vehicle.sqf",_cursorTarget, 0, true, false, "",""];
  686. s_player_repairActions set [count s_player_repairActions,_menu];
  687. s_player_repairActions set [count s_player_repairActions,_menu1];
  688. s_player_repair_crtl = 1;
  689. } else {
  690. {dayz_myCursorTarget removeAction _x} forEach s_player_repairActions;s_player_repairActions = [];
  691. s_player_repair_crtl = -1;
  692. };
  693. };
  694.  
  695. // All Traders
  696. if (_isMan and !_isPZombie and _traderType in serverTraders) then {
  697.  
  698. if (s_player_parts_crtl < 0) then {
  699.  
  700. // get humanity
  701. _humanity = player getVariable ["humanity",0];
  702. _traderMenu = call compile format["menu_%1;",_traderType];
  703.  
  704. // diag_log ("TRADER = " + str(_traderMenu));
  705.  
  706. _low_high = "low";
  707. _humanity_logic = false;
  708. if((_traderMenu select 2) == "friendly") then {
  709. _humanity_logic = (_humanity < -5000);
  710. };
  711. if((_traderMenu select 2) == "hostile") then {
  712. _low_high = "high";
  713. _humanity_logic = (_humanity > -5000);
  714. };
  715. if((_traderMenu select 2) == "hero") then {
  716. _humanity_logic = (_humanity < 5000);
  717. };
  718. if(_humanity_logic) then {
  719. _cancel = player addAction [format["Your humanity is too %1 this trader refuses to talk to you.",_low_high], "\z\addons\dayz_code\actions\trade_cancel.sqf",["na"], 0, true, false, "",""];
  720. s_player_parts set [count s_player_parts,_cancel];
  721. } else {
  722.  
  723. // Static Menu
  724. {
  725. //diag_log format["DEBUG TRADER: %1", _x];
  726. _buy = player addAction [format["Trade %1 %2 for %3 %4",(_x select 3),(_x select 5),(_x select 2),(_x select 6)], "\z\addons\dayz_code\actions\trade_items_wo_db.sqf",[(_x select 0),(_x select 1),(_x select 2),(_x select 3),(_x select 4),(_x select 5),(_x select 6)], (_x select 7), true, true, "",""];
  727. s_player_parts set [count s_player_parts,_buy];
  728.  
  729. } forEach (_traderMenu select 1);
  730. // Database menu
  731. _buy = player addAction [localize "STR_EPOCH_PLAYER_289", "\z\addons\dayz_code\actions\show_dialog.sqf",(_traderMenu select 0), 99, true, false, "",""];
  732. s_player_parts set [count s_player_parts,_buy];
  733.  
  734. // Add static metals trader options under sub menu
  735. _metals_trader = player addAction [localize "STR_EPOCH_PLAYER_301", "\z\addons\dayz_code\actions\trade_metals.sqf",["na"], 0, true, false, "",""];
  736. s_player_parts set [count s_player_parts,_metals_trader];
  737.  
  738. };
  739. s_player_parts_crtl = 1;
  740.  
  741. };
  742. } else {
  743. {player removeAction _x} forEach s_player_parts;s_player_parts = [];
  744. s_player_parts_crtl = -1;
  745. };
  746.  
  747.  
  748. if(dayz_tameDogs) then {
  749.  
  750. //Dog
  751. if (_isDog and _isAlive and (_hasRawMeat) and _ownerID == "0" and player getVariable ["dogID", 0] == 0) then {
  752. if (s_player_tamedog < 0) then {
  753. s_player_tamedog = player addAction [localize "str_actions_tamedog", "\z\addons\dayz_code\actions\tame_dog.sqf", _cursorTarget, 1, false, true, "", ""];
  754. };
  755. } else {
  756. player removeAction s_player_tamedog;
  757. s_player_tamedog = -1;
  758. };
  759. if (_isDog and _ownerID == dayz_characterID and _isAlive) then {
  760. _dogHandle = player getVariable ["dogID", 0];
  761. if (s_player_feeddog < 0 and _hasRawMeat) then {
  762. s_player_feeddog = player addAction [localize "str_actions_feeddog","\z\addons\dayz_code\actions\dog\feed.sqf",[_dogHandle,0], 0, false, true,"",""];
  763. };
  764. if (s_player_waterdog < 0 and "ItemWaterbottle" in _magazinesPlayer) then {
  765. s_player_waterdog = player addAction [localize "str_actions_waterdog","\z\addons\dayz_code\actions\dog\feed.sqf",[_dogHandle,1], 0, false, true,"",""];
  766. };
  767. if (s_player_staydog < 0) then {
  768. _lieDown = _dogHandle getFSMVariable "_actionLieDown";
  769. if (_lieDown) then { _text = "str_actions_liedog"; } else { _text = "str_actions_sitdog"; };
  770. s_player_staydog = player addAction [localize _text,"\z\addons\dayz_code\actions\dog\stay.sqf", _dogHandle, 5, false, true,"",""];
  771. };
  772. if (s_player_trackdog < 0) then {
  773. s_player_trackdog = player addAction [localize "str_actions_trackdog","\z\addons\dayz_code\actions\dog\track.sqf", _dogHandle, 4, false, true,"",""];
  774. };
  775. if (s_player_barkdog < 0) then {
  776. s_player_barkdog = player addAction [localize "str_actions_barkdog","\z\addons\dayz_code\actions\dog\speak.sqf", _cursorTarget, 3, false, true,"",""];
  777. };
  778. if (s_player_warndog < 0) then {
  779. _warn = _dogHandle getFSMVariable "_watchDog";
  780. if (_warn) then { _text = (localize "str_epoch_player_247"); _warn = false; } else { _text = (localize "str_epoch_player_248"); _warn = true; };
  781. s_player_warndog = player addAction [format[localize "str_actions_warndog",_text],"\z\addons\dayz_code\actions\dog\warn.sqf",[_dogHandle, _warn], 2, false, true,"",""];
  782. };
  783. if (s_player_followdog < 0) then {
  784. s_player_followdog = player addAction [localize "str_actions_followdog","\z\addons\dayz_code\actions\dog\follow.sqf",[_dogHandle,true], 6, false, true,"",""];
  785. };
  786. } else {
  787. player removeAction s_player_feeddog;
  788. s_player_feeddog = -1;
  789. player removeAction s_player_waterdog;
  790. s_player_waterdog = -1;
  791. player removeAction s_player_staydog;
  792. s_player_staydog = -1;
  793. player removeAction s_player_trackdog;
  794. s_player_trackdog = -1;
  795. player removeAction s_player_barkdog;
  796. s_player_barkdog = -1;
  797. player removeAction s_player_warndog;
  798. s_player_warndog = -1;
  799. player removeAction s_player_followdog;
  800. s_player_followdog = -1;
  801. };
  802. };
  803.  
  804. } else {
  805. //Engineering
  806. {dayz_myCursorTarget removeAction _x} forEach s_player_repairActions;s_player_repairActions = [];
  807. s_player_repair_crtl = -1;
  808.  
  809. {player removeAction _x} forEach s_player_combi;s_player_combi = [];
  810.  
  811. dayz_myCursorTarget = objNull;
  812. s_player_lastTarget = [objNull,objNull,objNull,objNull,objNull];
  813.  
  814. {player removeAction _x} forEach s_player_parts;s_player_parts = [];
  815. s_player_parts_crtl = -1;
  816.  
  817. {player removeAction _x} forEach s_player_lockunlock;s_player_lockunlock = [];
  818. s_player_lockUnlock_crtl = -1;
  819.  
  820. player removeAction s_player_checkGear;
  821. s_player_checkGear = -1;
  822.  
  823. player removeAction s_player_SurrenderedGear;
  824. s_player_SurrenderedGear = -1;
  825.  
  826. //Others
  827. player removeAction s_player_forceSave;
  828. s_player_forceSave = -1;
  829. player removeAction s_player_flipveh;
  830. s_player_flipveh = -1;
  831. player removeAction s_player_sleep;
  832. s_player_sleep = -1;
  833. player removeAction s_player_deleteBuild;
  834. s_player_deleteBuild = -1;
  835. player removeAction s_player_butcher;
  836. s_player_butcher = -1;
  837. player removeAction s_player_cook;
  838. s_player_cook = -1;
  839. player removeAction s_player_boil;
  840. s_player_boil = -1;
  841. player removeAction s_player_fireout;
  842. s_player_fireout = -1;
  843. player removeAction s_player_packtent;
  844. s_player_packtent = -1;
  845. player removeAction s_player_fillfuel;
  846. s_player_fillfuel = -1;
  847. player removeAction s_player_studybody;
  848. s_player_studybody = -1;
  849. //Dog
  850. player removeAction s_player_tamedog;
  851. s_player_tamedog = -1;
  852. player removeAction s_player_feeddog;
  853. s_player_feeddog = -1;
  854. player removeAction s_player_waterdog;
  855. s_player_waterdog = -1;
  856. player removeAction s_player_staydog;
  857. s_player_staydog = -1;
  858. player removeAction s_player_trackdog;
  859. s_player_trackdog = -1;
  860. player removeAction s_player_barkdog;
  861. s_player_barkdog = -1;
  862. player removeAction s_player_warndog;
  863. s_player_warndog = -1;
  864. player removeAction s_player_followdog;
  865. s_player_followdog = -1;
  866.  
  867. // vault
  868. player removeAction s_player_unlockvault;
  869. s_player_unlockvault = -1;
  870. player removeAction s_player_packvault;
  871. s_player_packvault = -1;
  872. player removeAction s_player_lockvault;
  873. s_player_lockvault = -1;
  874.  
  875. player removeAction s_player_information;
  876. s_player_information = -1;
  877. player removeAction s_player_fillgen;
  878. s_player_fillgen = -1;
  879. player removeAction s_player_upgrade_build;
  880. s_player_upgrade_build = -1;
  881. player removeAction s_player_maint_build;
  882. s_player_maint_build = -1;
  883. player removeAction s_player_downgrade_build;
  884. s_player_downgrade_build = -1;
  885. player removeAction s_player_towing;
  886. s_player_towing = -1;
  887. player removeAction s_player_fuelauto;
  888. s_player_fuelauto = -1;
  889. player removeAction s_player_fuelauto2;
  890. s_player_fuelauto2 = -1;
  891. };
  892.  
  893.  
  894.  
  895. //Dog actions on player self
  896. _dogHandle = player getVariable ["dogID", 0];
  897. if (_dogHandle > 0) then {
  898. _dog = _dogHandle getFSMVariable "_dog";
  899. _ownerID = "0";
  900. if (!isNull cursorTarget) then { _ownerID = cursorTarget getVariable ["CharacterID","0"]; };
  901. if (_canDo and !_inVehicle and alive _dog and _ownerID != dayz_characterID) then {
  902. if (s_player_movedog < 0) then {
  903. s_player_movedog = player addAction [localize "str_actions_movedog", "\z\addons\dayz_code\actions\dog\move.sqf", player getVariable ["dogID", 0], 1, false, true, "", ""];
  904. };
  905. if (s_player_speeddog < 0) then {
  906. _text = (localize "str_epoch_player_249");
  907. _speed = 0;
  908. if (_dog getVariable ["currentSpeed",1] == 0) then { _speed = 1; _text = (localize "str_epoch_player_250"); };
  909. 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, "", ""];
  910. };
  911. if (s_player_calldog < 0) then {
  912. 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, "", ""];
  913. };
  914. };
  915. } else {
  916. player removeAction s_player_movedog;
  917. s_player_movedog = -1;
  918. player removeAction s_player_speeddog;
  919. s_player_speeddog = -1;
  920. player removeAction s_player_calldog;
  921. s_player_calldog = -1;
  922. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement