Advertisement
Guest User

Untitled

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