Advertisement
Guest User

player_build

a guest
May 23rd, 2014
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.07 KB | None | 0 0
  1. private ["_item","_classname","_require","_text","_location","_sfx","_object","_string","_onLadder","_isWater","_boundingBox","_maxPoint","_actionBuild","_actionCancel"];
  2.  
  3. call gear_ui_init;
  4.  
  5. closeDialog 1;
  6.  
  7. if (r_action_count != 1) exitWith { cutText [localize "str_player_actionslimit", "PLAIN DOWN"]; };
  8.  
  9. _item = _this;
  10. _classname = getText (configFile >> "CfgMagazines" >> _item >> "ItemActions" >> "Build" >> "create");
  11. _require = getText (configFile >> "CfgMagazines" >> _item >> "ItemActions" >> "Build" >> "require");
  12. _text = getText (configFile >> "CfgVehicles" >> _classname >> "displayName");
  13. _onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1;
  14. _isWater = (surfaceIsWater (getPosATL player)) or dayz_isSwimming;
  15.  
  16. if (_classname == "Wire_cat1" || _classname == "Hedgehog_DZ" || _classname == "Sandbag1_DZ" || _classname == "CamoNet_DZ") exitWith {
  17. r_action_count = 0;
  18. call player_build2;
  19. };
  20.  
  21. if(_isWater) exitWith {
  22. r_action_count = 0;
  23. cutText [localize "str_player_26", "PLAIN DOWN"];
  24. };
  25.  
  26. if(_onLadder) exitWith {
  27. r_action_count = 0;
  28. cutText [localize "str_player_21", "PLAIN DOWN"];
  29. };
  30.  
  31. // item is missing
  32. if ((!(_item IN magazines player))) exitWith {
  33. r_action_count = 0;
  34. _string = switch true do {
  35. case (_object isKindOf "Land_A_tent"): {"str_player_31_pitch"};
  36. default {"str_player_31_build"};
  37. };
  38. cutText [format[(localize "str_player_31"),_text,(localize _string)] , "PLAIN DOWN"];
  39. diag_log(format["player_build: item:%1 require:%2 Player items:%3 magazines:%4", _item, _require, (items player), (magazines player)]);
  40. };
  41.  
  42. // tools are missing
  43. if ((_require != "") and {(!(_require IN items player))}) exitWith {
  44. r_action_count = 0;
  45. cutText [format[(localize "str_player_31_missingtools"),_text,_require] , "PLAIN DOWN"];
  46. };
  47.  
  48. if (!isNull (player getVariable "constructionObject")) exitWith {
  49. r_action_count = 0;
  50. cutText [localize "str_already_building", "PLAIN DOWN"];
  51. };
  52.  
  53. player setVariable ["constructionObject", player]; //Quick fix to stop multi build bug
  54.  
  55. player removeMagazine _item;
  56.  
  57. cutText [localize "str_player_build_rotate", "PLAIN DOWN"];
  58.  
  59. _location = getMarkerpos "respawn_west";
  60. _object = createVehicle [_classname, _location, [], 0, "NONE"];
  61. _boundingBox = boundingBox _object;
  62. _maxPoint = ([[0,0], _boundingBox select 1] call BIS_fnc_distance2D) + 1;
  63. //_object attachTo [player, [0, _maxPoint + 1, 0]];
  64.  
  65. player setVariable ["constructionObject", _object];
  66. _object setVariable ["characterID",dayz_characterID,true];
  67.  
  68. _sfx = switch true do {
  69. case (_object isKindOf "Land_A_tent"): {"tentunpack"};
  70. default {"repair"};
  71. };
  72.  
  73. s_player_tent_build = player addAction [localize "str_player_build_complete", "dayz_code\actions\object_build.sqf", [_object, _item, _classname, _text, true, 20, _sfx], 1, true, true, "", "!isNull (_target getVariable [""constructionObject"", objNull])"];
  74. s_player_tent_cancel = player addAction [localize "str_player_build_cancel", "dayz_code\actions\object_build.sqf", [_object, _item, _classname, _text, false, 0, "none"], 1, true, true, "", "!isNull (_target getVariable [""constructionObject"", objNull])"];
  75.  
  76. _position = [0,0,0];
  77. while {!isNull (player getVariable "constructionObject")} do {
  78. if (vehicle player != player) then {
  79. player action ["eject", vehicle player];
  80. };
  81.  
  82. if (speed player > 10 or speed player <= -8) then {
  83. cutText [localize "str_player_build_movingfast", "PLAIN DOWN"];
  84. player playMove "amovpercmstpssurwnondnon";
  85. };
  86.  
  87. if (!((count ((getPosATL player) - _position)) == 0)) then {
  88. _position = getPosATL player;
  89. _object setPosATL [(_position select 0) + _maxPoint * sin(getDir player), (_position select 1) + _maxPoint * cos(getDir player), 0.01];
  90. };
  91.  
  92. sleep 0.01;
  93.  
  94. if ((!alive player) or {((getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1)}) then {
  95. [[],[],[],[_object, _item, _classname, _text, false, 0, "none"]] call object_build;
  96. };
  97. };
  98.  
  99. player removeAction s_player_tent_build;
  100. player removeAction s_player_tent_cancel;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement