Advertisement
Guest User

Untitled

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