From cb37ba48b9477ea1bdecf5717ab9d5f5cd43ef9b Mon Sep 17 00:00:00 2001 From: LightBlueCube <115393812+LightBlueCube@users.noreply.github.com> Date: Sat, 12 Oct 2024 12:42:22 +0800 Subject: [PATCH] fix when player zoom OffhandWeapon and switch back to main weapon will not call the OnWeaponZoom callback --- .../mp_titanweapon_particle_accelerator.nut | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Northstar.CustomServers/mod/scripts/vscripts/weapons/mp_titanweapon_particle_accelerator.nut b/Northstar.CustomServers/mod/scripts/vscripts/weapons/mp_titanweapon_particle_accelerator.nut index 6ae3c0edf..994512386 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/weapons/mp_titanweapon_particle_accelerator.nut +++ b/Northstar.CustomServers/mod/scripts/vscripts/weapons/mp_titanweapon_particle_accelerator.nut @@ -56,7 +56,10 @@ function MpTitanWeaponParticleAccelerator_Init() void function OnWeaponStartZoomIn_titanweapon_particle_accelerator( entity weapon ) { - array mods = weapon.GetMods() + // modified variable for fix zoom problem + weapon.s.lastZoomState <- true + + array mods = weapon.GetMods() if ( weapon.HasMod( "fd_split_shot_cost") ) { if ( weapon.HasMod( "pas_ion_weapon_ads" ) ) @@ -86,6 +89,9 @@ void function OnWeaponStartZoomIn_titanweapon_particle_accelerator( entity weapo void function OnWeaponStartZoomOut_titanweapon_particle_accelerator( entity weapon ) { + // modified variable for fix zoom problem + weapon.s.lastZoomState <- false + array mods = weapon.GetMods() mods.fastremovebyvalue( "proto_particle_accelerator" ) mods.fastremovebyvalue( "proto_particle_accelerator_pas" ) @@ -101,6 +107,20 @@ void function OnWeaponActivate_titanweapon_particle_accelerator( entity weapon ) { weapon.s.initialized <- true } + + // modified variable for fix zoom problem + if ( !( "lastZoomState" in weapon.s ) ) + weapon.s.lastZoomState <- false + + // fix when player zoom OffhandWeapon and switch back to main weapon will not call the OnWeaponZoom callback + if( weapon.IsWeaponInAds() != weapon.s.lastZoomState ) + { + if( weapon.IsWeaponInAds() ) + OnWeaponStartZoomIn_titanweapon_particle_accelerator( weapon ) + else + OnWeaponStartZoomOut_titanweapon_particle_accelerator( weapon ) + } + #if SERVER entity owner = weapon.GetWeaponOwner() owner.SetSharedEnergyRegenDelay( 0.5 )