Skip to content

Commit

Permalink
Partial gamemodes implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Zanieon committed Nov 4, 2023
1 parent 28d409f commit 9168f44
Show file tree
Hide file tree
Showing 12 changed files with 220 additions and 18 deletions.
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 Down Expand Up @@ -376,11 +384,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 +584,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 +725,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,8 +421,15 @@ 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()

Expand Down Expand Up @@ -503,6 +510,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 @@ -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 @@ -192,6 +198,13 @@ void function UpdateMarksForKill( entity victim, entity attacker, var damageInfo
svGlobal.levelEnt.Signal( "MarkKilled", { mark = victim } )

if ( 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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ global function GamemodeTTDM_Init

const float TTDMIntroLength = 15.0

struct
{
table< entity, int > challengeCount
} file

void function GamemodeTTDM_Init()
{
Riff_ForceSetSpawnAsTitan( eSpawnAsTitan.Always )
Expand All @@ -14,6 +19,8 @@ void function GamemodeTTDM_Init()
ClassicMP_ForceDisableEpilogue( true )
SetTimeoutWinnerDecisionFunc( CheckScoreForDraw )

AddCallback_OnClientConnected( SetupPlayerTTDMChallenges ) //Just to make up the Match Goals tracking
AddCallback_OnClientDisconnected( RemovePlayerTTDMChallenges ) //Safety removal of data to prevent crashes
AddCallback_OnPlayerKilled( AddTeamScoreForPlayerKilled ) // dont have to track autotitan kills since you cant leave your titan in this mode

// probably needs scoreevent earnmeter values
Expand Down Expand Up @@ -56,6 +63,17 @@ void function TTDMIntroShowIntermissionCam( entity player )
thread PlayerWatchesTTDMIntroIntermissionCam( player )
}

void function SetupPlayerTTDMChallenges( entity player )
{
file.challengeCount[ player ] <- 0
}

void function RemovePlayerTTDMChallenges( entity player )
{
if( player in file.challengeCount )
delete file.challengeCount[ player ]
}

void function PlayerWatchesTTDMIntroIntermissionCam( entity player )
{
player.EndSignal( "OnDestroy" )
Expand All @@ -79,6 +97,19 @@ void function AddTeamScoreForPlayerKilled( entity victim, entity attacker, var d
if ( victim == attacker || !victim.IsPlayer() || !attacker.IsPlayer() && GetGameState() == eGameState.Playing )
return

if( victim in file.challengeCount )
file.challengeCount[victim] = 0

if( attacker in file.challengeCount )
{
file.challengeCount[attacker]++
if( file.challengeCount[attacker] >= 2 && !HasPlayerCompletedMeritScore( attacker ) )
{
AddPlayerScore( attacker, "ChallengeTTDM" )
SetPlayerChallengeMeritScore( attacker )
}
}

AddTeamScore( GetOtherTeam( victim.GetTeam() ), 1 )
}

Expand Down
Loading

0 comments on commit 9168f44

Please sign in to comment.