From 72aa12e04b0e01f33fd3d89db10992aeaa7dfcd0 Mon Sep 17 00:00:00 2001 From: Connie Price Date: Fri, 21 Jan 2022 03:23:48 +0000 Subject: Some extra earn meter cleanup. - Fixed `sh_gg_earn_meter.gnut` when used in multiple gamemodes. - Removed some unnecessary functions from `cl_gg_earn_meter.gnut`. --- .../gamemodes/gg_earn_meter/cl_gg_earn_meter.gnut | 23 ---------------------- .../gamemodes/gg_earn_meter/sh_gg_earn_meter.gnut | 22 ++++++++++++--------- 2 files changed, 13 insertions(+), 32 deletions(-) (limited to 'Northstar.Custom/mod/scripts') diff --git a/Northstar.Custom/mod/scripts/vscripts/gamemodes/gg_earn_meter/cl_gg_earn_meter.gnut b/Northstar.Custom/mod/scripts/vscripts/gamemodes/gg_earn_meter/cl_gg_earn_meter.gnut index 92f7be61..f28e8cbd 100644 --- a/Northstar.Custom/mod/scripts/vscripts/gamemodes/gg_earn_meter/cl_gg_earn_meter.gnut +++ b/Northstar.Custom/mod/scripts/vscripts/gamemodes/gg_earn_meter/cl_gg_earn_meter.gnut @@ -1,6 +1,5 @@ global function Cl_GGEarnMeter_Init global function Cl_GGEarnMeter_RegisterNetwork -global function ServerCallback_GGEarnMeter_SetWeaponIcon const float FILL_ANIM_DURATION = 0.2 @@ -81,26 +80,4 @@ void function Cl_GGEarnMeter_TrackWeaponIcon() WaitFrame() } -} - -void function ServerCallback_GGEarnMeter_SetWeaponIcon( int damageSourceId ) -{ - asset weaponImage - - if ( damageSourceId > -1 ) - { - if ( !DamageSourceIDHasString(damageSourceId) ) - { - return - } - - weaponImage = GetItemImage( DamageSourceIDToString( damageSourceId ) ) - } - else - { - weaponImage = RandomFloat( 1 ) > 0.1 ? $"rui/menu/boosts/boost_icon_random" : $"rui/faction/faction_logo_mrvn" - } - - RuiSetImage( file.earnMeterRui, "goalBuildingIcon", weaponImage ) - RuiSetImage( file.earnMeterRui, "goalReadyIcon", weaponImage ) } \ No newline at end of file diff --git a/Northstar.Custom/mod/scripts/vscripts/gamemodes/gg_earn_meter/sh_gg_earn_meter.gnut b/Northstar.Custom/mod/scripts/vscripts/gamemodes/gg_earn_meter/sh_gg_earn_meter.gnut index a1dbb75a..2eba4eee 100644 --- a/Northstar.Custom/mod/scripts/vscripts/gamemodes/gg_earn_meter/sh_gg_earn_meter.gnut +++ b/Northstar.Custom/mod/scripts/vscripts/gamemodes/gg_earn_meter/sh_gg_earn_meter.gnut @@ -2,25 +2,29 @@ global function Sh_GGEarnMeter_Init struct { - string gamemode = "" + bool callbackAdded = false + array gamemodes } file void function Sh_GGEarnMeter_Init(string gamemode) { - file.gamemode = gamemode + file.gamemodes.append(gamemode) - AddCallback_OnRegisteringCustomNetworkVars( RegisterSharedNetwork ) + if ( !file.callbackAdded ) + { + file.callbackAdded = true + AddCallback_OnRegisteringCustomNetworkVars( RegisterSharedNetwork ) + } } void function RegisterSharedNetwork() { - if ( GAMETYPE != file.gamemode ) - return + if ( !( file.gamemodes.contains(GAMETYPE) ) ) + return RegisterNetworkedVariable( "gunGameLevelPercentage", SNDC_PLAYER_EXCLUSIVE, SNVT_FLOAT_RANGE, 0.0, 0.0, 1.0 ) - Remote_RegisterFunction( "ServerCallback_GGEarnMeter_SetWeaponIcon" ) - #if CLIENT - Cl_GGEarnMeter_RegisterNetwork() - #endif + #if CLIENT + Cl_GGEarnMeter_RegisterNetwork() + #endif } \ No newline at end of file -- cgit v1.2.3