Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Progression] Implement Match Goals menu and XP tracking #756

Merged
merged 32 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
28d409f
Match Goals Tracking with XP
Zanieon Oct 22, 2023
9168f44
Partial gamemodes implementation
Zanieon Nov 4, 2023
d9f3bf0
Merge branch 'main' into match_goals_tracking
Zanieon Nov 4, 2023
85d10e1
Merge branch 'main' into match_goals_tracking
Zanieon Nov 5, 2023
4c52449
Sanity checks, minor fixes
Zanieon Nov 5, 2023
7019452
Revert wrong checks
Zanieon Nov 5, 2023
04b6ebf
Merge branch 'main' into match_goals_tracking
Zanieon Nov 7, 2023
3eee7d3
Merge branch 'main' into match_goals_tracking
Zanieon Nov 10, 2023
e2aac2c
Update _challenges.gnut
Zanieon Nov 13, 2023
1518301
Merge branch 'main' into match_goals_tracking
Zanieon Nov 23, 2023
aa86322
Merge branch 'R2Northstar:main' into match_goals_tracking
Zanieon Dec 7, 2023
7b35c49
Merge branch 'R2Northstar:main' into match_goals_tracking
Zanieon Dec 15, 2023
bab8c17
Ignore players with progression disabled.
Zanieon Dec 15, 2023
f4abbfb
Merge branch 'main' into match_goals_tracking
GeckoEidechse Dec 26, 2023
a067afc
Merge branch 'main' into match_goals_tracking
Zanieon Jan 3, 2024
61b4247
Merge remote-tracking branch 'upstream/main' into match_goals_tracking
Zanieon Jan 6, 2024
df6878e
Merge branch 'main' into match_goals_tracking
Zanieon Jan 13, 2024
2b232f7
Update Evac and Double XP Token logic
Zanieon Jan 13, 2024
ddeb13a
Merge remote-tracking branch 'upstream/main' into match_goals_tracking
Zanieon Jan 23, 2024
a362234
Merge Conflict Resolve
Zanieon Jan 23, 2024
8d587d6
Merge branch 'main' into match_goals_tracking
Zanieon Jan 28, 2024
2b5b10a
Reveal Evac Objective only on Epilogue
Zanieon Jan 28, 2024
4027d8d
Merge branch 'main' into match_goals_tracking
Zanieon Jan 30, 2024
80611cf
Merge branch 'main' into match_goals_tracking
GeckoEidechse Feb 5, 2024
4ef0214
Fix small oversight
Zanieon Feb 23, 2024
428dc2e
Merge remote-tracking branch 'upstream/main' into match_goals_tracking
Zanieon Feb 23, 2024
c577275
Merge branch 'R2Northstar:main' into match_goals_tracking
Zanieon Mar 18, 2024
96f6699
Merge branch 'main' into match_goals_tracking
Zanieon Mar 27, 2024
0b5b7ce
Minor fix
Zanieon Apr 16, 2024
0db0320
Merge remote-tracking branch 'upstream/main' into match_goals_tracking
Zanieon Apr 16, 2024
5910771
Merge branch 'main' into match_goals_tracking
Zanieon Jun 18, 2024
6e61313
Merge branch 'R2Northstar:main' into match_goals_tracking
Zanieon Jun 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Northstar.CustomServers/mod/scripts/vscripts/_xp.gnut
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ void function SetupPlayerPreviousXPValues( entity player )
player.SetPersistentVar( "previousFactionXP[" + xpFaction + "]", FactionGetXP( player, xpFaction ) )

foreach ( string xpTitan in shTitanXP.titanClasses )
{
player.SetPersistentVar( "previousTitanXP[" + xpTitan + "]", TitanGetXP( player, xpTitan ) )
player.SetPersistentVar( "fdPreviousTitanXP[" + xpTitan + "]", FD_TitanGetXP( player, xpTitan ) )
}

foreach ( string xpWeapon in shWeaponXP.weaponClassNames )
player.SetPersistentVar( GetItemPersistenceStruct( xpWeapon ) + ".previousWeaponXP", WeaponGetXP( player, xpWeapon ) )
Expand All @@ -35,6 +38,14 @@ void function HandleXPGainForScoreEvent( entity player, ScoreEvent event )
int weaponXp = ScoreEvent_GetXPValueWeapon( event )
int titanXp = ScoreEvent_GetXPValueTitan( event )
int factionXp = ScoreEvent_GetXPValueFaction( event )

if ( player.GetPlayerNetInt( "xpMultiplier" ) > 0 || GetCurrentPlaylistVarInt( "double_xp_enabled", 0 ) == 1 )
{
xpValue *= 2
weaponXp *= 2
titanXp *= 2
factionXp *= 2
}

entity weapon = player.GetActiveWeapon()
if ( IsValid( weapon ) && ShouldTrackXPForWeapon( weapon.GetWeaponClassName() ) && weaponXp != 0 )
Expand Down Expand Up @@ -63,5 +74,10 @@ void function AddXP( entity player, int amount )
int newXp = player.GetPersistentVarAsInt( "xp" )
int newLevel = GetLevelForXP( newXp )
if ( newLevel != oldLevel )
{
Remote_CallFunction_NonReplay( player, "ServerCallback_PlayerLeveledUp", player.GetPersistentVarAsInt( "gen" ), newLevel )

if( ProgressionEnabledForPlayer( player ) )
AwardRandomItemsForPlayerLevels( player, player.GetPersistentVarAsInt( "gen" ), newLevel )
}
}
10 changes: 10 additions & 0 deletions Northstar.CustomServers/mod/scripts/vscripts/evac/_evac.gnut
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@ void function Evac( int evacTeam, float initialWait, float arrivalTime, float wa
SetTeamActiveObjective( evacTeam, "EG_DropshipExtract", Time() + arrivalTime, file.evacIcon )
SetTeamActiveObjective( GetOtherTeam( evacTeam ), "EG_StopExtract", Time() + arrivalTime, file.evacIcon )

foreach( entity player in GetPlayerArrayOfTeam( evacTeam ) ) //Show the Evac Match Goal for players of the team that lost the match
Remote_CallFunction_UI( player, "SCB_SetEvacMeritState", 0 )

// would've liked to use cd_dropship_rescue_side_start length here, but can't since this is done before dropship spawn, can't
wait arrivalTime - 4.33333

Expand Down Expand Up @@ -280,6 +283,9 @@ void function Evac( int evacTeam, float initialWait, float arrivalTime, float wa
{
SetTeamActiveObjective( evacTeam, "EG_DropshipExtractDropshipDestroyed" )
SetTeamActiveObjective( GetOtherTeam( evacTeam ), "EG_DropshipExtractDropshipDestroyed" )

foreach( entity player in GetPlayerArrayOfTeam( evacTeam ) )
SetPlayerChallengeEvacState( player, 0 )
}

foreach ( entity player in dropship.s.evacSlots )
Expand Down Expand Up @@ -402,7 +408,10 @@ void function Evac( int evacTeam, float initialWait, float arrivalTime, float wa
if ( !PlayerInDropship( player, dropship ) )
{
if ( player.GetTeam() == dropship.GetTeam() )
{
SetPlayerActiveObjective( player, "EG_DropshipExtractFailedEscape" )
SetPlayerChallengeEvacState( player, 2 )
}

continue
}
Expand All @@ -417,6 +426,7 @@ void function Evac( int evacTeam, float initialWait, float arrivalTime, float wa
Remote_CallFunction_NonReplay( player, "ServerCallback_DisableHudForEvac" )
Remote_CallFunction_NonReplay( player, "ServerCallback_SetClassicSkyScale", dropship.GetEncodedEHandle(), 0.7 )
Remote_CallFunction_NonReplay( player, "ServerCallback_SetMapSettings", 4.0, false, 0.4, 0.125 )
SetPlayerChallengeEvacState( player, 1 )

// display player [Evacuated] in killfeed
foreach ( entity otherPlayer in GetPlayerArray() )
Expand Down
9 changes: 9 additions & 0 deletions Northstar.CustomServers/mod/scripts/vscripts/faction_xp.gnut
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,19 @@ void function AddFactionXP( entity player, int amount )
{
string faction = GetFactionChoice( player )
int oldLevel = FactionGetLevel( player, faction )
int FactionXPMatch = player.GetPersistentVarAsInt( "xp_match[" + XP_TYPE.FACTION_LEVELED + "]" )

// increment xp
player.SetPersistentVar( "factionXP[" + faction + "]", min( FactionGetXP( player, faction ) + amount, FactionGetMaxXP( faction ) ) )

// note: no notif for faction level up
if ( FactionGetLevel( player, faction ) != oldLevel )
{
AddPlayerScore( player, "FactionLevelUp" )
IncrementPlayerChallengeFactionLeveledUp( player )
player.SetPersistentVar( "xp_match[" + XP_TYPE.FACTION_LEVELED + "]", FactionXPMatch + 1 )

if( ProgressionEnabledForPlayer( player ) )
AwardRandomItemsForFactionLevels( player, faction, oldLevel, FactionGetLevel( player, faction ) )
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ void function GamemodeAITdm_Init()
}

ScoreEvent_SetupEarnMeterValuesForMixedModes()
SetupGenericTDMChallenge()
}

// add settings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,12 @@ void function AT_PlayerTitleThink( entity player )
{
// Set player money count
player.SetTitle( "$" + string( AT_GetPlayerBonusPoints( player ) ) )

if( AT_GetPlayerBonusPoints( player ) >= 600 && !HasPlayerCompletedMeritScore( player ) ) //Challenge is: "Earn $600."
{
AddPlayerScore( player, "ChallengeATAssault" )
SetPlayerChallengeMeritScore( player )
}
}
else if ( GetGameState() >= eGameState.WinnerDetermined )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ struct {

array<HardpointStruct> hardpoints
array<CP_PlayerStruct> players
table<entity,int> playerAssaultPoints
table<entity,int> playerDefensePoints
} file

void function GamemodeCP_Init()
Expand Down Expand Up @@ -112,11 +114,13 @@ void function GamemodeCP_OnPlayerKilled(entity victim, entity attacker, var dama
{
AddPlayerScore( attacker , "HardpointDefense", victim )
attacker.AddToPlayerGameStat(PGS_DEFENSE_SCORE,POINTVALUE_HARDPOINT_DEFENSE)
UpdatePlayerScoreForChallenge(attacker,0,POINTVALUE_HARDPOINT_DEFENSE)
}
else if((victimCP.hardpoint.GetTeam()==victim.GetTeam())||(GetHardpointCappingTeam(victimCP)==victim.GetTeam()))
{
AddPlayerScore( attacker, "HardpointAssault", victim )
attacker.AddToPlayerGameStat(PGS_ASSAULT_SCORE,POINTVALUE_HARDPOINT_ASSAULT)
UpdatePlayerScoreForChallenge(attacker,POINTVALUE_HARDPOINT_ASSAULT,0)
}
}
}
Expand All @@ -127,17 +131,20 @@ void function GamemodeCP_OnPlayerKilled(entity victim, entity attacker, var dama
{
AddPlayerScore( attacker , "HardpointSnipe", victim )
attacker.AddToPlayerGameStat(PGS_ASSAULT_SCORE,POINTVALUE_HARDPOINT_SNIPE)
UpdatePlayerScoreForChallenge(attacker,POINTVALUE_HARDPOINT_SNIPE,0)
}
else{
AddPlayerScore( attacker , "HardpointSiege", victim )
attacker.AddToPlayerGameStat(PGS_ASSAULT_SCORE,POINTVALUE_HARDPOINT_SIEGE)
UpdatePlayerScoreForChallenge(attacker,POINTVALUE_HARDPOINT_SIEGE,0)
}
}
else if(attackerCP.hardpoint!=null)//Perimeter Defense
{
if(attackerCP.hardpoint.GetTeam()==attacker.GetTeam())
AddPlayerScore( attacker , "HardpointPerimeterDefense", victim)
attacker.AddToPlayerGameStat(PGS_DEFENSE_SCORE,POINTVALUE_HARDPOINT_PERIMETER_DEFENSE)
UpdatePlayerScoreForChallenge(attacker,0,POINTVALUE_HARDPOINT_PERIMETER_DEFENSE)
}

foreach(CP_PlayerStruct player in file.players) //Reset Victim Holdtime Counter
Expand Down Expand Up @@ -308,6 +315,7 @@ void function CapturePointForTeam(HardpointStruct hardpoint, int Team)
if(player.IsPlayer()){
AddPlayerScore(player,"ControlPointCapture")
player.AddToPlayerGameStat(PGS_ASSAULT_SCORE,POINTVALUE_HARDPOINT_CAPTURE)
UpdatePlayerScoreForChallenge(player,POINTVALUE_HARDPOINT_CAPTURE,0)
}
}
}
Expand All @@ -319,12 +327,17 @@ void function GamemodeCP_InitPlayer(entity player)
playerStruct.timeOnPoints = [0.0,0.0,0.0]
playerStruct.isOnHardpoint = false
file.players.append(playerStruct)
file.playerAssaultPoints[player] <- 0
file.playerDefensePoints[player] <- 0
thread PlayerThink(playerStruct)
}

void function GamemodeCP_RemovePlayer(entity player)
{

if(player in file.playerAssaultPoints)
delete file.playerAssaultPoints[player]
if(player in file.playerDefensePoints)
delete file.playerDefensePoints[player]
foreach(index,CP_PlayerStruct playerStruct in file.players)
{
if(playerStruct.player==player)
Expand Down Expand Up @@ -376,11 +389,13 @@ void function PlayerThink(CP_PlayerStruct player)
{
AddPlayerScore(player.player,"ControlPointAmpedHold")
player.player.AddToPlayerGameStat( PGS_DEFENSE_SCORE, POINTVALUE_HARDPOINT_AMPED_HOLD )
UpdatePlayerScoreForChallenge(player.player,0,POINTVALUE_HARDPOINT_AMPED_HOLD)
}
else
{
AddPlayerScore(player.player,"ControlPointHold")
player.player.AddToPlayerGameStat( PGS_DEFENSE_SCORE, POINTVALUE_HARDPOINT_HOLD )
UpdatePlayerScoreForChallenge(player.player,0,POINTVALUE_HARDPOINT_HOLD)
}
}
break
Expand Down Expand Up @@ -574,6 +589,7 @@ void function HardpointThink( HardpointStruct hardpoint )
{
AddPlayerScore(player,"ControlPointAmped")
player.AddToPlayerGameStat(PGS_DEFENSE_SCORE,POINTVALUE_HARDPOINT_AMPED)
UpdatePlayerScoreForChallenge(player,0,POINTVALUE_HARDPOINT_AMPED)
}
}
}
Expand Down Expand Up @@ -714,3 +730,26 @@ string function GetHardpointGroup(entity hardpoint) //Hardpoint Entity B on Home

return string(hardpoint.kv.hardpointGroup)
}

void function UpdatePlayerScoreForChallenge(entity player,int assaultpoints = 0,int defensepoints = 0)
{
if(player in file.playerAssaultPoints)
{
file.playerAssaultPoints[player] += assaultpoints
if( file.playerAssaultPoints[player] >= 1000 && !HasPlayerCompletedMeritScore(player) )
{
AddPlayerScore(player,"ChallengeCPAssault")
SetPlayerChallengeMeritScore(player)
}
}

if(player in file.playerDefensePoints)
{
file.playerDefensePoints[player] += defensepoints
if( file.playerDefensePoints[player] >= 500 && !HasPlayerCompletedMeritScore(player) )
{
AddPlayerScore(player,"ChallengeCPDefense")
SetPlayerChallengeMeritScore(player)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -421,15 +421,28 @@ void function CaptureFlag( entity player, entity flag )
assistList = file.militiaCaptureAssistList

foreach( entity assistPlayer in assistList )
{
if ( player != assistPlayer )
AddPlayerScore( assistPlayer, "FlagCaptureAssist", player )
if( !HasPlayerCompletedMeritScore( assistPlayer ) )
{
AddPlayerScore( assistPlayer, "ChallengeCTFCapAssist" )
SetPlayerChallengeMeritScore( assistPlayer )
}
}

assistList.clear()

// notifs
MessageToPlayer( player, eEventNotifications.YouCapturedTheEnemyFlag )
EmitSoundOnEntityOnlyToPlayer( player, player, "UI_CTF_1P_PlayerScore" )

if( !HasPlayerCompletedMeritScore( player ) )
{
AddPlayerScore( player, "ChallengeCTFRetAssist" )
SetPlayerChallengeMeritScore( player )
}

MessageToTeam( team, eEventNotifications.PlayerCapturedEnemyFlag, player, player )
EmitSoundOnEntityToTeamExceptPlayer( flag, "UI_CTF_3P_TeamScore", player.GetTeam(), player )

Expand Down Expand Up @@ -503,6 +516,12 @@ void function TryReturnFlag( entity player, entity flag )
AddPlayerScore( player, "FlagReturn", player )
player.AddToPlayerGameStat( PGS_DEFENSE_SCORE, 1 )

if( !HasPlayerCompletedMeritScore( player ) )
{
AddPlayerScore( player, "ChallengeCTFRetAssist" )
SetPlayerChallengeMeritScore( player )
}

MessageToTeam( flag.GetTeam(), eEventNotifications.PlayerReturnedFriendlyFlag, null, player )
EmitSoundOnEntityToTeam( flag, "UI_CTF_3P_TeamReturnsFlag", flag.GetTeam() )
PlayFactionDialogueToTeam( "ctf_flagReturnedFriendly", flag.GetTeam() )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ void function GamemodeFRA_Init()
ScoreEvent_SetEarnMeterValues( "PilotBatteryPickup", 0.0, 0.34 )
EarnMeterMP_SetPassiveMeterGainEnabled( false )
PilotBattery_SetMaxCount( 3 )
SetupGenericFFAChallenge()

AddCallback_OnPlayerKilled( FRARemoveEarnMeter )
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ struct {
float lastDamageInfoTime

bool shouldDoHighlights

table< entity, int > pilotstreak
} file

void function GamemodeLts_Init()
Expand All @@ -34,6 +36,37 @@ void function GamemodeLts_Init()
ClassicMP_SetCustomIntro( ClassicMP_DefaultNoIntro_Setup, ClassicMP_DefaultNoIntro_GetLength() )
ClassicMP_ForceDisableEpilogue( true )
AddCallback_GameStateEnter( eGameState.Playing, WaitForThirtySecondsLeft )

AddCallback_OnClientConnected( SetupPlayerLTSChallenges ) //Just to make up the Match Goals tracking
AddCallback_OnClientDisconnected( RemovePlayerLTSChallenges ) //Safety removal of data to prevent crashes
AddCallback_OnPlayerKilled( LTSChallengeForPlayerKilled )
}

void function SetupPlayerLTSChallenges( entity player )
{
file.pilotstreak[ player ] <- 0
}

void function RemovePlayerLTSChallenges( entity player )
{
if( player in file.pilotstreak )
delete file.pilotstreak[ player ]
}

void function LTSChallengeForPlayerKilled( entity victim, entity attacker, var damageInfo )
{
if ( victim == attacker || !attacker.IsPlayer() || GetGameState() != eGameState.Playing )
return

if ( victim.IsPlayer() && attacker in file.pilotstreak )
{
file.pilotstreak[attacker]++
if( file.pilotstreak[attacker] >= 2 && !HasPlayerCompletedMeritScore( attacker ) )
{
AddPlayerScore( attacker, "ChallengeLTS" )
SetPlayerChallengeMeritScore( attacker )
}
}
}

void function WaitForThirtySecondsLeft()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ void function MarkPlayers( entity imcMark, entity militiaMark )
entity livingMark = GetMarked( GetOtherTeam( deadMark.GetTeam() ) )
livingMark.SetPlayerGameStat( PGS_DEFENSE_SCORE, livingMark.GetPlayerGameStat( PGS_DEFENSE_SCORE ) + 1 )

if( !HasPlayerCompletedMeritScore( livingMark ) )
{
AddPlayerScore( livingMark, "ChallengeMFD" )
SetPlayerChallengeMeritScore( livingMark )
}

// thread this so we don't kill our own thread
thread AddTeamScore( livingMark.GetTeam(), 1 )
}
Expand All @@ -195,8 +201,15 @@ void function UpdateMarksForKill( entity victim, entity attacker, var damageInfo

MessageToAll( eEventNotifications.MarkedForDeathKill, null, victim, actualAttacker.GetEncodedEHandle() )
svGlobal.levelEnt.Signal( "MarkKilled", { mark = victim } )

if ( !isSuicide && attacker.IsPlayer() )
{
attacker.SetPlayerGameStat( PGS_ASSAULT_SCORE, attacker.GetPlayerGameStat( PGS_ASSAULT_SCORE ) + 1 )
if( !HasPlayerCompletedMeritScore( attacker ) )
{
AddPlayerScore( attacker, "ChallengeMFD" )
SetPlayerChallengeMeritScore( attacker )
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ void function GamemodePs_Init()
AddCallback_OnPlayerKilled( GiveScoreForPlayerKill )
ScoreEvent_SetupEarnMeterValuesForMixedModes()
SetTimeoutWinnerDecisionFunc( CheckScoreForDraw )
SetupGenericFFAChallenge()

// spawnzone stuff
SetShouldCreateMinimapSpawnZones( true )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ void function GamemodeSpeedball_Init()
Riff_ForceTitanAvailability( eTitanAvailability.Never )
Riff_ForceSetEliminationMode( eEliminationMode.Pilots )
ScoreEvent_SetupEarnMeterValuesForMixedModes()
SetupGenericFFAChallenge()

AddSpawnCallbackEditorClass( "script_ref", "info_speedball_flag", CreateFlag )

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ void function GamemodeTdm_Init()
AddCallback_OnPlayerKilled( GiveScoreForPlayerKill )
ScoreEvent_SetupEarnMeterValuesForMixedModes()
SetTimeoutWinnerDecisionFunc( CheckScoreForDraw )
SetupGenericTDMChallenge()
}

void function GiveScoreForPlayerKill( entity victim, entity attacker, var damageInfo )
Expand Down
Loading
Loading