diff options
Diffstat (limited to 'Northstar.Custom/mod/scripts/vscripts/gamemodes')
6 files changed, 287 insertions, 72 deletions
diff --git a/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_gg.gnut b/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_gg.gnut index 608fd869..5943b804 100644 --- a/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_gg.gnut +++ b/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_gg.gnut @@ -10,12 +10,14 @@ void function GamemodeGG_Init() SetWeaponDropsEnabled( false ) Riff_ForceTitanAvailability( eTitanAvailability.Never ) Riff_ForceBoostAvailability( eBoostAvailability.Disabled ) - + AddCallback_OnPlayerRespawned( OnPlayerRespawned ) AddCallback_OnPlayerKilled( OnPlayerKilled ) - + AddCallback_GameStateEnter( eGameState.WinnerDetermined, OnWinnerDetermined ) - + + AddCallback_GGEarnMeterFull( OnGGEarnMeterFilled ) + // set scorelimit if it's wrong, sort of a jank way to do it but best i've got rn try { @@ -44,76 +46,127 @@ void function OnPlayerKilled( entity victim, entity attacker, var damageInfo ) { if ( !victim.IsPlayer() || !attacker.IsPlayer() || GetGameState() != eGameState.Playing ) return - + if ( attacker == victim ) // suicide { string message = victim.GetPlayerName() + " committed suicide." foreach ( entity player in GetPlayerArray() ) SendHudMessage( player, message, -1, 0.4, 255, 0, 0, 0, 0, 3, 0.15 ) - - if ( GameRules_GetTeamScore( victim.GetTeam() ) != 0 ) - { - AddTeamScore( victim.GetTeam(), -1 ) // get absolutely fucking destroyed lol - victim.AddToPlayerGameStat( PGS_ASSAULT_SCORE, -1 ) - } + + DeRank( victim ) } - else + else { if ( DamageInfo_GetDamageSourceIdentifier( damageInfo ) != eDamageSourceId.melee_pilot_emptyhanded ) { - AddTeamScore( attacker.GetTeam(), 1 ) - attacker.AddToPlayerGameStat( PGS_ASSAULT_SCORE, 1 ) - UpdateLoadout( attacker ) + float percentageReward = GetCurrentPlaylistVarFloat( "gg_kill_reward", 1.0 ) + string scoreEvent = "KillPilot" + + if ( DamageInfo_GetDamageSourceIdentifier( damageInfo ) == eDamageSourceId.human_execution ) + { + string message = victim.GetPlayerName() + " got executed." + foreach ( entity player in GetPlayerArray() ) + SendHudMessage( player, message, -1, 0.4, 255, 0, 0, 0, 0, 3, 0.15 ) + + DeRank( victim ) + + percentageReward = GetCurrentPlaylistVarFloat( "gg_execution_reward", 1.0 ) + scoreEvent = "Execution" + } + + Reward( attacker, victim, scoreEvent, percentageReward ) } - - if ( DamageInfo_GetDamageSourceIdentifier( damageInfo ) == eDamageSourceId.human_execution ) + } + + table<int, bool> alreadyAssisted + foreach( DamageHistoryStruct attackerInfo in victim.e.recentDamageHistory ) + { + if( attackerInfo.attacker != attacker && !alreadyAssisted[attackerInfo.attacker.GetEncodedEHandle()] ) { - string message = victim.GetPlayerName() + " got executed." - foreach ( entity player in GetPlayerArray() ) - SendHudMessage( player, message, -1, 0.4, 255, 0, 0, 0, 0, 3, 0.15 ) - - if ( GameRules_GetTeamScore( victim.GetTeam() ) != 0 ) - { - AddTeamScore( victim.GetTeam(), -1 ) // get absolutely fucking destroyed lol - victim.AddToPlayerGameStat( PGS_ASSAULT_SCORE, -1 ) + if ( attackerInfo.damageSourceId != eDamageSourceId.melee_pilot_emptyhanded ) { + alreadyAssisted[attackerInfo.attacker.GetEncodedEHandle()] <- true + + Reward( attackerInfo.attacker, victim, "PilotAssist", GetCurrentPlaylistVarFloat( "gg_assist_reward", 0.0 ) ) } } } } +void function Reward( entity player, entity victim, string scoreEvent, float percentageReward ) +{ + percentageReward = clamp(percentageReward, 0.0, 1.0) + Sv_GGEarnMeter_AddPercentage( player, percentageReward ) + Remote_CallFunction_NonReplay( player, "ServerCallback_ScoreEvent", GetScoreEvent(scoreEvent).eventId, 0, eEventDisplayType.MEDAL, victim.GetEncodedEHandle(), 0.0, percentageReward) +} + +void function DeRank( entity player ) +{ + Sv_GGEarnMeter_SetPercentage( player, 0.0 ) + + if ( GameRules_GetTeamScore( player.GetTeam() ) != 0 ) + { + AddTeamScore( player.GetTeam(), -1 ) // get absolutely fucking destroyed lol + player.AddToPlayerGameStat( PGS_ASSAULT_SCORE, -1 ) + UpdateLoadout( player ) + } +} + +bool function OnGGEarnMeterFilled( entity player ) +{ + AddTeamScore( player.GetTeam(), 1 ) + player.AddToPlayerGameStat( PGS_ASSAULT_SCORE, 1 ) + UpdateLoadout( player ) + + int currentScore = GameRules_GetTeamScore( player.GetTeam() ) + int maxScore = GetGunGameWeapons().len() + + return currentScore >= maxScore +} + void function UpdateLoadout( entity player ) { // todo: honestly, this should be reworked to use PilotLoadoutDefs instead of directly modifying weapons and shit - + int currentWeaponIndex = GameRules_GetTeamScore( player.GetTeam() ) array<GunGameWeapon> weapons = GetGunGameWeapons() - + if ( currentWeaponIndex >= weapons.len() ) currentWeaponIndex = weapons.len() - 1 - + if ( currentWeaponIndex > 18 ) // play end of game music for special weapons PlayMusicToAll( eMusicPieceID.LEVEL_LAST_MINUTE ) // this *shouldn't* overlap if done multiple times - + GunGameWeapon weapon = weapons[ currentWeaponIndex ] - + foreach ( entity weapon in player.GetMainWeapons() ) player.TakeWeaponNow( weapon.GetWeaponClassName() ) - + foreach ( entity weapon in player.GetOffhandWeapons() ) player.TakeWeaponNow( weapon.GetWeaponClassName() ) - + if ( weapon.offhandSlot != -1 ) { - // TEMP: give archer so player so player has a weapon which lets them use offhands - // need to replace this with a custom empty weapon at some point - player.GiveWeapon( "mp_weapon_rocket_launcher" ) - player.GiveOffhandWeapon( weapon.weapon, weapon.offhandSlot, weapon.mods ) + + player.GiveOffhandWeapon( "melee_pilot_emptyhanded", OFFHAND_MELEE, [ "allow_as_primary" ] ) + player.SetActiveWeaponByName( "melee_pilot_emptyhanded" ) // Let the player use the melee in the primary slot, and then force equip it. Effectively gives them an empty hand. } else + { player.GiveWeapon( weapon.weapon, weapon.mods ) - - player.GiveOffhandWeapon( "melee_pilot_emptyhanded", OFFHAND_MELEE ) + + 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 de8a3449..6f4e015e 100644 --- a/Northstar.Custom/mod/scripts/vscripts/gamemodes/cl_gamemode_gg.gnut +++ b/Northstar.Custom/mod/scripts/vscripts/gamemodes/cl_gamemode_gg.gnut @@ -23,4 +23,6 @@ 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() }
\ 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 new file mode 100644 index 00000000..1d4e73b7 --- /dev/null +++ b/Northstar.Custom/mod/scripts/vscripts/gamemodes/gg_earn_meter/_gg_earn_meter.gnut @@ -0,0 +1,56 @@ +global function Sv_GGEarnMeter_SetWeaponIcon +global function Sv_GGEarnMeter_SetFinalIcon +global function Sv_GGEarnMeter_SetPercentage +global function Sv_GGEarnMeter_AddPercentage +global function AddCallback_GGEarnMeterFull + +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) ) + + thread CheckPercentage( player ) +} + +void function Sv_GGEarnMeter_AddPercentage( entity player, float percentage ) +{ + Sv_GGEarnMeter_SetPercentage(player, player.GetPlayerNetFloat( "gunGameLevelPercentage") + percentage) +} + +void function AddCallback_GGEarnMeterFull( bool functionref( entity ) callbackFunc ) +{ + Assert( !file.onGGEarnMeterFullCallbacks.contains( callbackFunc ), "Already added " + FunctionToString( callbackFunc ) + " with AddCallback_GGEarnMeterFull" ) + + file.onGGEarnMeterFullCallbacks.append( callbackFunc ) +} + +void function CheckPercentage( entity player ) +{ + float percentage = player.GetPlayerNetFloat( "gunGameLevelPercentage") + + if ( percentage < 1.0 ) + return + + wait 0.2 + + bool lastWeapon = false + foreach ( callbackFunc in file.onGGEarnMeterFullCallbacks ) + lastWeapon = callbackFunc( player ) + + if ( !lastWeapon ) + Sv_GGEarnMeter_SetPercentage(player, 0.0) +}
\ No newline at end of file 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 new file mode 100644 index 00000000..d6369b0c --- /dev/null +++ b/Northstar.Custom/mod/scripts/vscripts/gamemodes/gg_earn_meter/cl_gg_earn_meter.gnut @@ -0,0 +1,82 @@ +global function Cl_GGEarnMeter_Init +global function Cl_GGEarnMeter_RegisterNetwork +global function ServerCallback_GGEarnMeter_SetWeaponIcon + +const float FILL_ANIM_DURATION = 0.2 + +struct EarnChangeData +{ + float startValue = 0.0 + float endValue = 0.0 + float updateTime = 0.0 +} + +struct { + EarnChangeData lastEarnedData + var earnMeterRui +} file + +void function Cl_GGEarnMeter_Init() +{ + AddCallback_OnClientScriptInit( CreateGGEarnMeterUI ) +} + +void function CreateGGEarnMeterUI( entity player ) +{ + file.earnMeterRui = CreateCockpitRui( $"ui/earn_meter.rpak" ) + + RuiSetFloat( file.earnMeterRui, "fillAnimDuration", FILL_ANIM_DURATION ) + RuiSetGameTime( file.earnMeterRui, "lastEarnChangeTime", RUI_BADGAMETIME ) + RuiSetFloat( file.earnMeterRui, "earnedStartFrac", 0.0 ) + RuiSetInt( file.earnMeterRui, "meterMode", 5 ) + + RuiTrackFloat( file.earnMeterRui, "earnedFrac", player, RUI_TRACK_SCRIPT_NETWORK_VAR, GetNetworkedVariableIndex( "gunGameLevelPercentage" ) ) +} + +void function Cl_GGEarnMeter_RegisterNetwork() +{ + RegisterNetworkedVariableChangeCallback_float( "gunGameLevelPercentage", GunGamePercentageUpdate ) +} + +void function GunGamePercentageUpdate( entity player, float oldValue, float newValue, bool actuallyChanged ) +{ + if ( !actuallyChanged ) + return + + float currentValue = Cl_GGEarnMeter_GetCurrentMeterValue( file.lastEarnedData ) + RuiSetGameTime( file.earnMeterRui, "lastEarnChangeTime", Time() ) + RuiSetFloat( file.earnMeterRui, "earnedStartFrac", currentValue ) + + file.lastEarnedData.startValue = oldValue + file.lastEarnedData.endValue = newValue + file.lastEarnedData.updateTime = Time() +} + +float function Cl_GGEarnMeter_GetCurrentMeterValue( EarnChangeData earnData ) +{ + float elapsedTime = Time() - earnData.updateTime + float delta = earnData.endValue - earnData.startValue + return earnData.endValue - (delta * EaseIn( GraphCapped( elapsedTime, 0.0, FILL_ANIM_DURATION, 1.0, 0.0 ) ) ) +} + +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 new file mode 100644 index 00000000..0428ecfa --- /dev/null +++ b/Northstar.Custom/mod/scripts/vscripts/gamemodes/gg_earn_meter/sh_gg_earn_meter.gnut @@ -0,0 +1,16 @@ +global function Sh_GGEarnMeter_Init + +void function Sh_GGEarnMeter_Init() +{ + AddCallback_OnRegisteringCustomNetworkVars( RegisterSharedNetwork ) +} + +void function RegisterSharedNetwork() +{ + 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 +}
\ No newline at end of file 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 c4021a3c..852d7663 100644 --- a/Northstar.Custom/mod/scripts/vscripts/gamemodes/sh_gamemode_gg.gnut +++ b/Northstar.Custom/mod/scripts/vscripts/gamemodes/sh_gamemode_gg.gnut @@ -18,6 +18,9 @@ void function Sh_GamemodeGG_Init() { // create custom gamemode AddCallback_OnCustomGamemodesInit( CreateGamemodeGG ) + + if ( GAMETYPE != GAMEMODE_GG ) + Sh_GGEarnMeter_Init() } void function CreateGamemodeGG() @@ -30,119 +33,122 @@ void function CreateGamemodeGG() GameMode_AddScoreboardColumnData( GAMEMODE_GG, "#SCOREBOARD_SCORE", PGS_ASSAULT_SCORE, 2 ) GameMode_AddScoreboardColumnData( GAMEMODE_GG, "#SCOREBOARD_PILOT_KILLS", PGS_PILOT_KILLS, 2 ) GameMode_SetColor( GAMEMODE_GG, [147, 204, 57, 255] ) - + AddPrivateMatchMode( GAMEMODE_GG ) // add to private lobby modes - + AddPrivateMatchModeSettingArbitrary( "#GAMEMODE_gg", "gg_kill_reward", "1.0" ) + 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 = 0 } file.weapons.append( ggPulseBlade ) - - + + // set this to the number of guns GameMode_SetDefaultScoreLimits( GAMEMODE_GG, file.weapons.len(), 0 ) - + #if SERVER GameMode_AddServerInit( GAMEMODE_GG, GamemodeGG_Init ) GameMode_AddServerInit( GAMEMODE_GG, GamemodeFFAShared_Init ) |