From 919acdacd2ef8b230df5d75d125e074d31c75f17 Mon Sep 17 00:00:00 2001 From: DBmaoha <56738369+DBmaoha@users.noreply.github.com> Date: Tue, 1 Nov 2022 07:18:38 +0800 Subject: Better Decloaking Check to Support Modding (#514) * Better Decloaking Check to Support Modding Respawn hardcoded decloaking which messed up many things, this will make vanilla cloak to behave properly in any offhand slot and have a better support for modded cloak * commit fix --- .../mod/scripts/vscripts/mp/_base_gametype.gnut | 29 ++++++++++++++++------ 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype.gnut b/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype.gnut index a4c6e187..362407b3 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype.gnut +++ b/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype.gnut @@ -1412,15 +1412,28 @@ void function CodeCallback_WeaponFireInCloak( entity player ) //player.SetCloakFlicker( 1.0, 2.0 ) DisableCloak( player, 0.5 ) - entity weapon = player.GetOffhandWeapon( OFFHAND_LEFT ) - //printt( "weapon", weapon.GetWeaponClassName() ) - // JFS; need code feature to properly reset next attack time/cooldown stuff - if ( IsValid( weapon ) && weapon.GetWeaponClassName() == "mp_ability_cloak" ) + entity cloakWeapon + int offhandSlot + for ( int i = 0; i <= OFFHAND_MELEE; i++ ) // OFFHAND_MELEE is the largest { - player.TakeOffhandWeapon( OFFHAND_LEFT ) - player.GiveOffhandWeapon( "mp_ability_cloak", OFFHAND_LEFT ) - weapon = player.GetOffhandWeapon( OFFHAND_LEFT ) - weapon.SetWeaponPrimaryClipCountAbsolute( 0 ) + entity nowWeapon = player.GetOffhandWeapon( i ) + if( IsValid( nowWeapon )) + { + if( nowWeapon.GetWeaponClassName() == "mp_ability_cloak" ) + { + cloakWeapon = nowWeapon + offhandSlot = i + } + } + } + if( IsValid( cloakWeapon ) ) + { + array mods = cloakWeapon.GetMods() + // can't reset cooldown properly in script, let's give player a empty one + player.TakeWeapon( "mp_ability_cloak" ) // not using TakeWeaponNow() to fit vanilla behavior + player.GiveOffhandWeapon( "mp_ability_cloak", offhandSlot, mods ) + cloakWeapon = player.GetOffhandWeapon( offhandSlot ) + cloakWeapon.SetWeaponPrimaryClipCountAbsolute( 0 ) } } else -- cgit v1.2.3