Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.49 KB | None | 0 0
  1. /***********************************************************************
  2. Sabers
  3. ************************************************************************/
  4.  
  5. _mission_fnc_A3C_Sabers = {
  6. // Generate sounds from idle saber and add handler
  7. params ["_unit"];
  8.  
  9. if( currentWeapon _unit == "a3c_blue_lightsaber" ||
  10. currentWeapon _unit == "a3c_yellow_lightsaber" ||
  11. currentWeapon _unit == "a3c_red_lightsaber" ||
  12. currentWeapon _unit == "a3c_green_lightsaber" ||
  13. currentWeapon _unit == "a3c_purple_lightsaber" ||
  14. currentWeapon _unit == "a3c_orange_lightsaber" ||
  15. currentWeapon _unit == "a3c_white_lightsaber" ||
  16. currentWeapon _unit == "a3c_blue_lance_lightsaber" ||
  17. currentWeapon _unit == "a3c_green_lance_lightsaber" ||
  18. currentWeapon _unit == "a3c_purple_lance_lightsaber" ||
  19. currentWeapon _unit == "a3c_orange_lance_lightsaber" ||
  20. currentWeapon _unit == "a3c_red_lance_lightsaber" ||
  21. currentWeapon _unit == "a3c_yellow_lance_lightsaber" ) then {
  22.  
  23. if(currentWeaponMode _unit == "on") then {
  24. // Saber is active
  25.  
  26. // Play sound
  27. playSound3D ["A3C_StarWarsMain\lightsaber_a3c\sounds\ls_sound.ogg", _unit,false,getPosASL _unit,1,1,50];
  28.  
  29. // Add HIT handler
  30. _temp=_unit getVariable ["SW_Mod_HandleDamage_State", -1];
  31. if(_temp!=1) then {
  32. _temp=_unit getVariable ["SW_Mod_HandleDamage_Handle", -1];
  33. if(_temp>=0) then {
  34. _unit removeEventHandler ["HandleDamage", _temp];
  35. };
  36.  
  37. _temp = _unit addEventHandler ["HandleDamage", {params ["_unit"]; _unit playAction "gestureFollow"; }];
  38. _unit setVariable ["SW_Mod_HandleDamage_Handle", _temp, true];
  39. _unit setVariable ["SW_Mod_HandleDamage_State", 1, true];
  40. };
  41.  
  42. // Fix for MP
  43. removeAllHandgunItems _unit;
  44.  
  45. } else {
  46. // Saber is hidden
  47.  
  48. // Add HIT handler
  49. _temp=_unit getVariable ["SW_Mod_HandleDamage_State", -1];
  50. if(_temp!=2) then {
  51. _temp=_unit getVariable ["SW_Mod_HandleDamage_Handle", -1];
  52. if(_temp>=0)then {
  53. _unit removeEventHandler ["HandleDamage", _temp];
  54. };
  55.  
  56. _temp = _unit addEventHandler ["HandleDamage", {params ["_unit"]; _unit playMove "AmovPercMstpSrasWpstDnon_AadjPpneMstpSrasWpstDright"; }];
  57. _unit setVariable ["SW_Mod_HandleDamage_Handle", _temp, true];
  58. _unit setVariable ["SW_Mod_HandleDamage_State", 2, true];
  59. };
  60.  
  61. // Fix for MP
  62. _unit addHandgunItem "lightsaber_emiter";
  63. };
  64.  
  65. } else {
  66. // Light saber not equippmed remove event hander
  67.  
  68. // Remove event handler
  69. _temp=_unit getVariable ["SW_Mod_HandleDamage_State", -1];
  70. if(_temp!=-1) then {
  71. _temp=_unit getVariable ["SW_Mod_HandleDamage_Handle", -1];
  72. if(_temp>=0)then {
  73. _unit removeEventHandler ["HandleDamage", _temp];
  74. };
  75. _unit setVariable ["SW_Mod_HandleDamage_State", -1, true];
  76. };
  77. };
  78. };
  79.  
  80. // Wait until game is really started
  81. waitUntil {time > 0};
  82.  
  83. while{true} do {
  84. // Wait untill all sounds are finished
  85. _future = time + 1;
  86.  
  87. // Run of client PCs
  88. if (hasInterface) then {
  89. _unit = player;
  90. _curator_unit= missionnamespace getvariable ["bis_fnc_moduleRemoteControl_unit",objnull];
  91.  
  92. // Check if we deal with the zeus controlled unit
  93. if(!isnull(_curator_unit)) then {
  94. _unit = _curator_unit;
  95. };
  96.  
  97. // Run the function
  98. [_unit] call _mission_fnc_A3C_Sabers;
  99.  
  100. };
  101.  
  102.  
  103. // Run on server - HC,Dedicated or SelfHosted
  104. if(!hasInterface || isServer) then {
  105. // For all units
  106. {
  107. // Run the function
  108. [_x] call _mission_fnc_A3C_Sabers;
  109. } forEach (allUnits-playableUnits);
  110. };
  111.  
  112. waitUntil {time >= _future};
  113. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement