Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /***********************************************************************
- Sabers
- ************************************************************************/
- _mission_fnc_A3C_Sabers = {
- // Generate sounds from idle saber and add handler
- params ["_unit"];
- if( currentWeapon _unit == "a3c_blue_lightsaber" ||
- currentWeapon _unit == "a3c_yellow_lightsaber" ||
- currentWeapon _unit == "a3c_red_lightsaber" ||
- currentWeapon _unit == "a3c_green_lightsaber" ||
- currentWeapon _unit == "a3c_purple_lightsaber" ||
- currentWeapon _unit == "a3c_orange_lightsaber" ||
- currentWeapon _unit == "a3c_white_lightsaber" ||
- currentWeapon _unit == "a3c_blue_lance_lightsaber" ||
- currentWeapon _unit == "a3c_green_lance_lightsaber" ||
- currentWeapon _unit == "a3c_purple_lance_lightsaber" ||
- currentWeapon _unit == "a3c_orange_lance_lightsaber" ||
- currentWeapon _unit == "a3c_red_lance_lightsaber" ||
- currentWeapon _unit == "a3c_yellow_lance_lightsaber" ) then {
- if(currentWeaponMode _unit == "on") then {
- // Saber is active
- // Play sound
- playSound3D ["A3C_StarWarsMain\lightsaber_a3c\sounds\ls_sound.ogg", _unit,false,getPosASL _unit,1,1,50];
- // Add HIT handler
- _temp=_unit getVariable ["SW_Mod_HandleDamage_State", -1];
- if(_temp!=1) then {
- _temp=_unit getVariable ["SW_Mod_HandleDamage_Handle", -1];
- if(_temp>=0) then {
- _unit removeEventHandler ["HandleDamage", _temp];
- };
- _temp = _unit addEventHandler ["HandleDamage", {params ["_unit"]; _unit playAction "gestureFollow"; }];
- _unit setVariable ["SW_Mod_HandleDamage_Handle", _temp, true];
- _unit setVariable ["SW_Mod_HandleDamage_State", 1, true];
- };
- // Fix for MP
- removeAllHandgunItems _unit;
- } else {
- // Saber is hidden
- // Add HIT handler
- _temp=_unit getVariable ["SW_Mod_HandleDamage_State", -1];
- if(_temp!=2) then {
- _temp=_unit getVariable ["SW_Mod_HandleDamage_Handle", -1];
- if(_temp>=0)then {
- _unit removeEventHandler ["HandleDamage", _temp];
- };
- _temp = _unit addEventHandler ["HandleDamage", {params ["_unit"]; _unit playMove "AmovPercMstpSrasWpstDnon_AadjPpneMstpSrasWpstDright"; }];
- _unit setVariable ["SW_Mod_HandleDamage_Handle", _temp, true];
- _unit setVariable ["SW_Mod_HandleDamage_State", 2, true];
- };
- // Fix for MP
- _unit addHandgunItem "lightsaber_emiter";
- };
- } else {
- // Light saber not equippmed remove event hander
- // Remove event handler
- _temp=_unit getVariable ["SW_Mod_HandleDamage_State", -1];
- if(_temp!=-1) then {
- _temp=_unit getVariable ["SW_Mod_HandleDamage_Handle", -1];
- if(_temp>=0)then {
- _unit removeEventHandler ["HandleDamage", _temp];
- };
- _unit setVariable ["SW_Mod_HandleDamage_State", -1, true];
- };
- };
- };
- // Wait until game is really started
- waitUntil {time > 0};
- while{true} do {
- // Wait untill all sounds are finished
- _future = time + 1;
- // Run of client PCs
- if (hasInterface) then {
- _unit = player;
- _curator_unit= missionnamespace getvariable ["bis_fnc_moduleRemoteControl_unit",objnull];
- // Check if we deal with the zeus controlled unit
- if(!isnull(_curator_unit)) then {
- _unit = _curator_unit;
- };
- // Run the function
- [_unit] call _mission_fnc_A3C_Sabers;
- };
- // Run on server - HC,Dedicated or SelfHosted
- if(!hasInterface || isServer) then {
- // For all units
- {
- // Run the function
- [_x] call _mission_fnc_A3C_Sabers;
- } forEach (allUnits-playableUnits);
- };
- waitUntil {time >= _future};
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement