From f63ca08e4d820192b9a753d1badbe48e9671aae7 Mon Sep 17 00:00:00 2001 From: Connie Price Date: Thu, 20 Jan 2022 05:56:07 +0000 Subject: GunGame PlaylistVar Enhancements - Define GunGame weapons using playlist vars: e.g. `+setplaylistvaroverrides scorelimit 4 gg_weapon_0 -1|mp_weapon_r97|pas_run_and_gun gg_weapon_1 -1|mp_titanweapon_xo16_vanguard|arc_rounds gg_weapon_2 -1|mp_weapon_car|pas_run_and_gun gg_weapon_3 1|mp_weapon_grenade_sonar|pas_power_cell,amped_tacticals` - Now that any custom weapon lists can be synchronised using playlist vars, server callback icon handling has been removed, and icons are now handled purely clientside. - Cleaned up default weapons. Approximate structure of custom weapon list: `+setplaylistvaroverrides scorelimit gg_weapon_ ||` --- .../scripts/vscripts/gamemodes/_gamemode_gg.gnut | 12 +- .../scripts/vscripts/gamemodes/cl_gamemode_gg.gnut | 33 ++- .../gamemodes/gg_earn_meter/_gg_earn_meter.gnut | 12 -- .../gamemodes/gg_earn_meter/cl_gg_earn_meter.gnut | 26 ++- .../gamemodes/gg_earn_meter/sh_gg_earn_meter.gnut | 4 +- .../scripts/vscripts/gamemodes/sh_gamemode_gg.gnut | 226 +++++++++++---------- 6 files changed, 177 insertions(+), 136 deletions(-) diff --git a/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_gg.gnut b/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_gg.gnut index 5943b8048..14f5f15d1 100644 --- a/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_gg.gnut +++ b/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_gg.gnut @@ -133,7 +133,7 @@ void function UpdateLoadout( entity player ) if ( currentWeaponIndex >= weapons.len() ) currentWeaponIndex = weapons.len() - 1 - if ( currentWeaponIndex > 18 ) // play end of game music for special weapons + if ( currentWeaponIndex > weapons.len() - 3 ) // play end of game music for special or last few weapons PlayMusicToAll( eMusicPieceID.LEVEL_LAST_MINUTE ) // this *shouldn't* overlap if done multiple times GunGameWeapon weapon = weapons[ currentWeaponIndex ] @@ -157,16 +157,6 @@ void function UpdateLoadout( entity player ) player.GiveOffhandWeapon( "melee_pilot_emptyhanded", OFFHAND_MELEE ) } - - if ( currentWeaponIndex == weapons.len() - 1 ) - { - Sv_GGEarnMeter_SetFinalIcon( player ) - - return - } - - GunGameWeapon nextWeapon = weapons[ currentWeaponIndex + 1 ] - Sv_GGEarnMeter_SetWeaponIcon( player, nextWeapon.weapon ) } void function OnWinnerDetermined() diff --git a/Northstar.Custom/mod/scripts/vscripts/gamemodes/cl_gamemode_gg.gnut b/Northstar.Custom/mod/scripts/vscripts/gamemodes/cl_gamemode_gg.gnut index 6f4e015ec..d077e557f 100644 --- a/Northstar.Custom/mod/scripts/vscripts/gamemodes/cl_gamemode_gg.gnut +++ b/Northstar.Custom/mod/scripts/vscripts/gamemodes/cl_gamemode_gg.gnut @@ -1,5 +1,9 @@ global function ClGamemodeGG_Init +struct { + int lastScore = -1 +} file + void function ClGamemodeGG_Init() { // add ffa gamestate asset @@ -24,5 +28,32 @@ void function ClGamemodeGG_Init() RegisterLevelMusicForTeam( eMusicPieceID.LEVEL_LAST_MINUTE, "music_mp_freeagents_lastminute", TEAM_IMC ) RegisterLevelMusicForTeam( eMusicPieceID.LEVEL_LAST_MINUTE, "music_mp_freeagents_lastminute", TEAM_MILITIA ) - Cl_GGEarnMeter_Init() + Cl_GGEarnMeter_Init(ClGamemodeGG_GetWeaponIcon, ClGamemodeGG_ShouldChangeWeaponIcon) +} + +asset function ClGamemodeGG_GetWeaponIcon() +{ + int weaponIndex = GameRules_GetTeamScore( GetLocalViewPlayer().GetTeam() ) + 1 + + array weapons = GetGunGameWeapons() + + if ( weaponIndex >= weapons.len() ) + return RandomFloat( 1 ) > 0.1 ? $"rui/menu/boosts/boost_icon_random" : $"rui/faction/faction_logo_mrvn" + + GunGameWeapon nextWeapon = weapons[ weaponIndex ] + return GetWeaponInfoFileKeyFieldAsset_WithMods_Global( nextWeapon.weapon, nextWeapon.mods, "hud_icon" ) +} + +// Because of our easter egg we have to include the optional test function so that we don't get a flickering icon. +bool function ClGamemodeGG_ShouldChangeWeaponIcon() +{ + int currentScore = GameRules_GetTeamScore( GetLocalViewPlayer().GetTeam() ) + + if ( file.lastScore != currentScore ) + { + file.lastScore = currentScore + return true + } + + return false } \ No newline at end of file diff --git a/Northstar.Custom/mod/scripts/vscripts/gamemodes/gg_earn_meter/_gg_earn_meter.gnut b/Northstar.Custom/mod/scripts/vscripts/gamemodes/gg_earn_meter/_gg_earn_meter.gnut index 1d4e73b73..2da60753e 100644 --- a/Northstar.Custom/mod/scripts/vscripts/gamemodes/gg_earn_meter/_gg_earn_meter.gnut +++ b/Northstar.Custom/mod/scripts/vscripts/gamemodes/gg_earn_meter/_gg_earn_meter.gnut @@ -1,5 +1,3 @@ -global function Sv_GGEarnMeter_SetWeaponIcon -global function Sv_GGEarnMeter_SetFinalIcon global function Sv_GGEarnMeter_SetPercentage global function Sv_GGEarnMeter_AddPercentage global function AddCallback_GGEarnMeterFull @@ -9,16 +7,6 @@ struct array< bool functionref( entity ) > onGGEarnMeterFullCallbacks } file -void function Sv_GGEarnMeter_SetWeaponIcon( entity player, string weaponReference ) -{ - Remote_CallFunction_Replay( player, "ServerCallback_GGEarnMeter_SetWeaponIcon", eDamageSourceId[weaponReference] ) -} - -void function Sv_GGEarnMeter_SetFinalIcon( entity player ) -{ - Remote_CallFunction_Replay( player, "ServerCallback_GGEarnMeter_SetWeaponIcon", -1 ) -} - void function Sv_GGEarnMeter_SetPercentage( entity player, float percentage ) { player.SetPlayerNetFloat( "gunGameLevelPercentage", clamp(percentage, 0.0, 1.0) ) 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 d6369b0cf..92f7be612 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 @@ -14,11 +14,16 @@ struct EarnChangeData struct { EarnChangeData lastEarnedData var earnMeterRui + asset functionref() getIconFunction + bool functionref() testIconFunction } file -void function Cl_GGEarnMeter_Init() +void function Cl_GGEarnMeter_Init( asset functionref() getIconFunction, bool functionref() testIconFunction = null ) { AddCallback_OnClientScriptInit( CreateGGEarnMeterUI ) + + file.getIconFunction = getIconFunction + file.testIconFunction = testIconFunction } void function CreateGGEarnMeterUI( entity player ) @@ -31,6 +36,8 @@ void function CreateGGEarnMeterUI( entity player ) RuiSetInt( file.earnMeterRui, "meterMode", 5 ) RuiTrackFloat( file.earnMeterRui, "earnedFrac", player, RUI_TRACK_SCRIPT_NETWORK_VAR, GetNetworkedVariableIndex( "gunGameLevelPercentage" ) ) + + thread Cl_GGEarnMeter_TrackWeaponIcon() } void function Cl_GGEarnMeter_RegisterNetwork() @@ -59,6 +66,23 @@ float function Cl_GGEarnMeter_GetCurrentMeterValue( EarnChangeData earnData ) return earnData.endValue - (delta * EaseIn( GraphCapped( elapsedTime, 0.0, FILL_ANIM_DURATION, 1.0, 0.0 ) ) ) } +void function Cl_GGEarnMeter_TrackWeaponIcon() +{ + int lastScore = -1 + while ( IsValid( file.earnMeterRui ) ) + { + if ( file.testIconFunction == null || file.testIconFunction() ) + { + asset weaponImage = file.getIconFunction() + + RuiSetImage( file.earnMeterRui, "goalBuildingIcon", weaponImage ) + RuiSetImage( file.earnMeterRui, "goalReadyIcon", weaponImage ) + } + + WaitFrame() + } +} + void function ServerCallback_GGEarnMeter_SetWeaponIcon( int damageSourceId ) { asset weaponImage 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 d3e506ce5..a1dbb75a4 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 @@ -1,8 +1,8 @@ global function Sh_GGEarnMeter_Init -struct +struct { - string gamemode = "" + string gamemode = "" } file void function Sh_GGEarnMeter_Init(string gamemode) diff --git a/Northstar.Custom/mod/scripts/vscripts/gamemodes/sh_gamemode_gg.gnut b/Northstar.Custom/mod/scripts/vscripts/gamemodes/sh_gamemode_gg.gnut index 477f328a5..64f57f95e 100644 --- a/Northstar.Custom/mod/scripts/vscripts/gamemodes/sh_gamemode_gg.gnut +++ b/Northstar.Custom/mod/scripts/vscripts/gamemodes/sh_gamemode_gg.gnut @@ -3,10 +3,12 @@ global function GetGunGameWeapons global const string GAMEMODE_GG = "gg" +global const string default_weapons = "mp_weapon_car|pas_run_and_gun|-1$mp_weapon_alternator_smg|pas_run_and_gun|-1$mp_weapon_hemlok_smg||-1$mp_weapon_hemlok||-1$mp_weapon_vinson|hcog|-1$mp_weapon_rspn101||-1$mp_weapon_esaw||-1$mp_weapon_lstar|pas_run_and_gun|-1$mp_weapon_shotgun||-1$mp_weapon_mastiff||-1$mp_weapon_softball||-1$mp_weapon_epg|jump_kit|-1$mp_weapon_shotgun_pistol|pas_run_and_gun|-1$mp_weapon_wingman_n|pas_run_and_gun,ricochet|-1$mp_weapon_doubletake||-1$mp_weapon_sniper|pas_fast_ads,ricochet|-1$mp_weapon_autopistol|pas_run_and_gun,temp_sight|-1$mp_weapon_semipistol|pas_run_and_gun|-1$mp_weapon_wingman|pas_run_and_gun|-1$mp_weapon_defender||-1$mp_weapon_grenade_sonar|pas_power_cell,amped_tacticals|1" + global struct GunGameWeapon { string weapon - array mods + array mods = [] int offhandSlot = -1 } @@ -38,114 +40,85 @@ void function CreateGamemodeGG() AddPrivateMatchModeSettingArbitrary( "#GAMEMODE_gg", "gg_assist_reward", "0.0" ) AddPrivateMatchModeSettingArbitrary( "#GAMEMODE_gg", "gg_execution_reward", "1.0" ) - // setup guns - - // smgs - // car - GunGameWeapon ggCar = { weapon = "mp_weapon_car", mods = [ "pas_run_and_gun" ], ... } - file.weapons.append( ggCar ) - - // alternator - GunGameWeapon ggAlternator = { weapon = "mp_weapon_alternator_smg", mods = [ "pas_run_and_gun" ], ... } - file.weapons.append( ggAlternator ) - - // volt - GunGameWeapon ggVolt = { weapon = "mp_weapon_hemlok_smg", ... } - file.weapons.append( ggVolt ) - - - // rifles - // hemlok - GunGameWeapon ggHemlok = { weapon = "mp_weapon_hemlok", mods = [ ], ... } - file.weapons.append( ggHemlok ) - - // flatline - GunGameWeapon ggFlatline = { weapon = "mp_weapon_vinson", mods = [ "hcog" ], ... } - file.weapons.append( ggFlatline ) - - // r201 - GunGameWeapon ggR101 = { weapon = "mp_weapon_rspn101", ... } - file.weapons.append( ggR101 ) - - - // lmgs - // devotion - GunGameWeapon ggDevotion = { weapon = "mp_weapon_esaw", ... } - file.weapons.append( ggDevotion ) - - // l-star - GunGameWeapon ggLstar = { weapon = "mp_weapon_lstar", mods = [ "pas_run_and_gun" ], ... } - if ( RandomInt( 100 ) <= 5 ) - ggLstar.mods.append( "rcee" ) // easter egg mod that changes the screen of the lstar - - file.weapons.append( ggLstar ) - - - // shotguns - // eva-8 - GunGameWeapon ggEva = { weapon = "mp_weapon_shotgun", ... } - file.weapons.append( ggEva ) - - // mastiff - GunGameWeapon ggMastiff = { weapon = "mp_weapon_mastiff", ... } - file.weapons.append( ggMastiff ) - - - // grenadiers - // softball - GunGameWeapon ggSoftball = { weapon = "mp_weapon_softball", ... } - file.weapons.append( ggSoftball ) - - // epg - GunGameWeapon ggEpg = { weapon = "mp_weapon_epg", mods = [ "jump_kit" ], ... } - file.weapons.append( ggEpg ) - - - // primary pistols - // mozambique - GunGameWeapon ggMozam = { weapon = "mp_weapon_shotgun_pistol", mods = [ "pas_run_and_gun" ], ... } - file.weapons.append( ggMozam ) - - // wingman elite - GunGameWeapon ggWme = { weapon = "mp_weapon_wingman_n", mods = [ "pas_run_and_gun", "ricochet" ], ... } - file.weapons.append( ggWme ) - - - // snipers - // double take - GunGameWeapon ggTaketake = { weapon = "mp_weapon_doubletake", ... } - file.weapons.append( ggTaketake ) - - // kraber - GunGameWeapon ggKraber = { weapon = "mp_weapon_sniper", mods = [ "pas_fast_ads", "ricochet" ], ... } - file.weapons.append( ggKraber ) - - - // secondary pistols - // re-45 - GunGameWeapon ggRe45 = { weapon = "mp_weapon_autopistol", mods = [ "pas_run_and_gun", "temp_sight" ], ... } - file.weapons.append( ggRe45 ) - - // p2016 - GunGameWeapon ggP2016 = { weapon = "mp_weapon_semipistol", mods = [ "pas_run_and_gun" ], ... } - file.weapons.append( ggP2016 ) - - // wingman - GunGameWeapon ggWingman = { weapon = "mp_weapon_wingman", mods = [ "pas_run_and_gun" ], ... } - file.weapons.append( ggWingman ) - - - // final/special weapons - // charge rifle - GunGameWeapon ggChargeRifle = { weapon = "mp_weapon_defender", ... } - file.weapons.append( ggChargeRifle ) - - // pulse blade - GunGameWeapon ggPulseBlade = { weapon = "mp_weapon_grenade_sonar", mods = [ "pas_power_cell", "amped_tacticals" ], offhandSlot = OFFHAND_SPECIAL } - file.weapons.append( ggPulseBlade ) - - - // set this to the number of guns + // Custom Weapons + int index = 0 + while ( GetCurrentPlaylistVarString( "gg_weapon_" + index, "NOPE" ) != "NOPE" ) + { + file.weapons.append( StringToGGWeapon( GetCurrentPlaylistVarString( "gg_weapon_" + index, "" ) ) ) + index++ + } + + // Default Weapons - Don't edit this to make custom lists anymore, please try to use playlist vars so that everything gets synced correctly. + if ( file.weapons.len() == 0 ) + { + // SMGs + GunGameWeapon ggCar = { weapon = "mp_weapon_car", mods = [ "pas_run_and_gun" ], ... } // CAR + GunGameWeapon ggAlternator = { weapon = "mp_weapon_alternator_smg", mods = [ "pas_run_and_gun" ], ... } // Alternator + GunGameWeapon ggVolt = { weapon = "mp_weapon_hemlok_smg", ... } // Volt + + // Rifles + GunGameWeapon ggHemlok = { weapon = "mp_weapon_hemlok", ... } // Hemlok + GunGameWeapon ggFlatline = { weapon = "mp_weapon_vinson", mods = [ "hcog" ], ... } // Flatline + GunGameWeapon ggR201 = { weapon = "mp_weapon_rspn101", ... } // R201 + + // LMGs + GunGameWeapon ggDevotion = { weapon = "mp_weapon_esaw", ... } // Devotion + GunGameWeapon ggLstar = { weapon = "mp_weapon_lstar", mods = [ "pas_run_and_gun" ], ... } // L-Star + + // Shotguns + GunGameWeapon ggEva = { weapon = "mp_weapon_shotgun", ... } // Eva-8 + GunGameWeapon ggMastiff = { weapon = "mp_weapon_mastiff", ... } // Mastiff + + // Grenadiers + GunGameWeapon ggSoftball = { weapon = "mp_weapon_softball", ... } // Softball + GunGameWeapon ggEpg = { weapon = "mp_weapon_epg", mods = [ "jump_kit" ], ... } // EPG + + // Primary Pistols + GunGameWeapon ggMozam = { weapon = "mp_weapon_shotgun_pistol", mods = [ "pas_run_and_gun" ], ... } // Mozambique + GunGameWeapon ggWme = { weapon = "mp_weapon_wingman_n", mods = [ "pas_run_and_gun", "ricochet" ], ... } // Wingman Elite + + // Snipers + GunGameWeapon ggTaketake = { weapon = "mp_weapon_doubletake", ... } // Double Take + GunGameWeapon ggKraber = { weapon = "mp_weapon_sniper", mods = [ "pas_fast_ads", "ricochet" ], ... } // Kraber + + // Secondary Pistols + GunGameWeapon ggRe45 = { weapon = "mp_weapon_autopistol", mods = [ "pas_run_and_gun", "temp_sight" ], ... } // RE-45 + GunGameWeapon ggP2016 = { weapon = "mp_weapon_semipistol", mods = [ "pas_run_and_gun" ], ... } // P2016 + GunGameWeapon ggWingman = { weapon = "mp_weapon_wingman", mods = [ "pas_run_and_gun" ], ... } // Wingman + + // Final/Special + GunGameWeapon ggChargeRifle = { weapon = "mp_weapon_defender", ... } // Charge Rifle + GunGameWeapon ggPulseBlade = { weapon = "mp_weapon_grenade_sonar", mods = [ "pas_power_cell", "amped_tacticals" ], offhandSlot = OFFHAND_SPECIAL } // Pulse Blade + + file.weapons.append( ggCar ) + file.weapons.append( ggAlternator ) + file.weapons.append( ggVolt ) + file.weapons.append( ggHemlok ) + file.weapons.append( ggFlatline ) + file.weapons.append( ggR201 ) + file.weapons.append( ggDevotion ) + file.weapons.append( ggLstar ) + file.weapons.append( ggEva ) + file.weapons.append( ggMastiff ) + file.weapons.append( ggSoftball ) + file.weapons.append( ggEpg ) + file.weapons.append( ggMozam ) + file.weapons.append( ggWme ) + file.weapons.append( ggTaketake ) + file.weapons.append( ggKraber ) + file.weapons.append( ggRe45 ) + file.weapons.append( ggP2016 ) + file.weapons.append( ggWingman ) + file.weapons.append( ggChargeRifle ) + file.weapons.append( ggPulseBlade ) + } + + foreach ( ggWeapon in file.weapons ) + if ( ggWeapon.weapon == "mp_weapon_lstar" ) + if ( RandomInt( 100 ) <= 5 ) + ggWeapon.mods.append( "rcee" ) // Easter egg mod that changes the screen of the lstar. + + // Set this to the number of guns. GameMode_SetDefaultScoreLimits( GAMEMODE_GG, file.weapons.len(), 0 ) #if SERVER @@ -167,4 +140,39 @@ void function CreateGamemodeGG() array function GetGunGameWeapons() { return file.weapons +} + +string function Join( array strings, string separator ) +{ + string output; + + foreach( int i, string stringoStarr in strings ) + { + if (i == 0) + output = stringoStarr + else + output = output + separator + stringoStarr + } + + return output; +} + +string function GGWeaponToString( GunGameWeapon ggWeapon ) +{ + // We do it in this order because split works weirdly and won't return empty strings for gaps :c + return ggWeapon.offhandSlot + "|" + ggWeapon.weapon + "|" + Join( ggWeapon.mods, "," ) +} + +GunGameWeapon function StringToGGWeapon( string ggWeaponString ) +{ + array ggWeaponStringSplit = split( ggWeaponString, "|" ) + + GunGameWeapon ggWeapon + ggWeapon.offhandSlot = int(ggWeaponStringSplit[0]) + ggWeapon.weapon = ggWeaponStringSplit[1] + + if ( ggWeaponStringSplit.len() > 2 ) + ggWeapon.mods = split( ggWeaponStringSplit[2], "," ) + + return ggWeapon } \ No newline at end of file -- cgit v1.2.3