Skip to content

Commit

Permalink
Add Max active Titans Riff
Browse files Browse the repository at this point in the history
  • Loading branch information
Zanieon committed Nov 29, 2024
1 parent 22ac495 commit fdf6332
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void function Sv_EarnMeterMP_Init()

void function EarnMeterMP_SetTitanLoadout( entity player )
{
if ( EarnMeterMP_IsTitanEarnGametype() )
if ( EarnMeterMP_IsTitanEarnGametype() && level.nv.titanDropEnabledForTeam != TEAM_BOTH && level.nv.titanDropEnabledForTeam != player.GetTeam() )
PlayerEarnMeter_SetGoal( player, EarnObject_GetByRef( GetTitanLoadoutForPlayer( player ).titanClass ) )
else
PlayerEarnMeter_SetGoal( player, PlayerEarnMeter_GetReward( player ) )
Expand Down Expand Up @@ -79,9 +79,12 @@ void function OnPlayerRespawned( entity player )

void function EarnMeterMP_ReplaceReward( entity player, EarnObject reward, float rewardFrac )
{
PlayerEarnMeter_Reset( player )
if ( !IsTitanAvailable( player ) )
PlayerEarnMeter_Reset( player )

if ( reward.id < 0 )
return

PlayerEarnMeter_SetReward( player, reward )
PlayerEarnMeter_SetRewardFrac( player, rewardFrac )

Expand Down Expand Up @@ -129,6 +132,12 @@ void function EarnMeterMP_PlayerLifeThink( entity player )
}
else if ( IsValid( player.GetPetTitan() ) )
desiredEarnMeterMode = eEarnMeterMode.PET
else if ( Riff_TitanQueueLimit() > 0 && GetTitanCountForTeam( player.GetTeam() ) >= Riff_TitanQueueLimit() ) // Hides Meter when max active Titan limit is reached
{
desiredEarnMeterMode = eEarnMeterMode.DISABLED
if( titanReadyMsg ) // Resets so next time people can drop titans because a slot opened, they will be greeted with the message right away
titanReadyMsg = false
}
else
desiredEarnMeterMode = eEarnMeterMode.DEFAULT

Expand Down Expand Up @@ -167,7 +176,7 @@ void function EarnMeterMP_PlayerLifeThink( entity player )
else if( PlayerEarnMeter_GetOwnedFrac( player ) < 0.75 )
saidTitanSoon = false
}

if ( PlayerEarnMeter_GetOwnedFrac( player ) < 1.0 )
{
PlayerEarnMeter_DisableGoal( player )
Expand All @@ -187,9 +196,9 @@ void function EarnMeterMP_PlayerLifeThink( entity player )
}
}

if ( Time() - lastPassiveGainTime > 4.0 && file.passiveMeterGainEnabled )
if ( Time() >= lastPassiveGainTime && file.passiveMeterGainEnabled && GetGameState() != eGameState.Prematch )
{
lastPassiveGainTime = Time()
lastPassiveGainTime = Time() + 4.0
PlayerEarnMeter_AddOwnedFrac( player, 0.01 )
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ void function CodeCallback_OnClientConnectionStarted( entity player )
{
if ( GetCurrentPlaylistVarInt( "max_teams", 0 ) > 1 && !IsFFAGame() )
{
if ( GetPlayerArrayOfTeam( TEAM_MILITIA ).len() > GetPlayerArrayOfTeam( TEAM_IMC ).len() )
if ( GetTeamPlayerCount( TEAM_MILITIA ) > GetTeamPlayerCount( TEAM_IMC ) )
SetTeam( player, TEAM_IMC )
else
SetTeam( player, TEAM_MILITIA )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ global function CreateTitanForPlayerAndHotdrop
global function SetRequestTitanAllowedCallback

global function ShouldDoTitanfall
global function TitanDropDisabledForPlayerTeam
global function GiveTitanfallScoreMedal

struct {
Expand Down Expand Up @@ -109,16 +110,10 @@ bool function IsReplacementTitanAvailable( player, timeBuffer = 0 )
{
expect entity( player )

if ( !IsReplacementTitanAvailableForGameState() )
return false

if ( player.IsTitan() )
return false

if ( IsAlive( player.GetPetTitan() ) )
if ( !IsReplacementTitanAvailableForGameState() || IsAlive( player.GetPetTitan() ) )
return false

if ( player.isSpawning )
if ( player.IsTitan() || player.isSpawning || TitanDropDisabledForPlayerTeam( player ) )
return false

if ( !file.ReplacementTitanGamemodeRules( player ) )
Expand Down Expand Up @@ -197,11 +192,23 @@ void function SetRequestTitanGamemodeRules( bool functionref( entity, vector ) r

bool function ReplacementTitanGamemodeRules_Default( entity player )
{
if ( Riff_TitanQueueLimit() > 0 && GetTitanCountForTeam( player.GetTeam() ) >= Riff_TitanQueueLimit() )
{
EmitSoundOnEntityOnlyToPlayer( player, player, "coop_sentrygun_deploymentdeniedbeep" )
SendHudMessage( player, "Titan limit enabled.\nMax of " + Riff_TitanQueueLimit() + " Titans active per team.", -1, 0.4, 255, 255, 255, 255, 0.15, 3.0, 0.5 )
return false
}
return true
}

bool function RequestTitanGamemodeRules_Default( entity player, vector origin )
{
if ( Riff_TitanQueueLimit() > 0 && GetTitanCountForTeam( player.GetTeam() ) >= Riff_TitanQueueLimit() )
{
EmitSoundOnEntityOnlyToPlayer( player, player, "coop_sentrygun_deploymentdeniedbeep" )
SendHudMessage( player, "Titan limit enabled.\nMax of " + Riff_TitanQueueLimit() + " Titans active per team.", -1, 0.4, 255, 255, 255, 255, 0.15, 3.0, 0.5 )
return false
}
return true
}

Expand Down Expand Up @@ -488,7 +495,7 @@ function TryReplacementTitanReadyAnnouncement( entity player )
if ( GetPlayerTitanInMap( player ) )
return

if ( level.nv.titanDropEnabledForTeam != TEAM_BOTH && level.nv.titanDropEnabledForTeam != player.GetTeam() )
if ( TitanDropDisabledForPlayerTeam( player ) )
return

if ( player.p.replacementTitanReady_lastNagTime == 0 || Time() - player.p.replacementTitanReady_lastNagTime >= nagInterval )
Expand Down Expand Up @@ -582,33 +589,41 @@ bool function ReplacementTitan( entity player )
{
if ( !IsAlive( player ) )
{
#if DEV
printt( "ReplacementTitan", player, player.entindex(), "failed", "IsAlive( player ) was false" )
#endif
return false
}

if ( !IsReplacementTitanAvailable( player, 0 ) )
{
#if DEV
printt( "ReplacementTitan", player, player.entindex(), "failed", "IsReplacementTitanAvailable was false" )
#endif
return false
}

entity titan = GetPlayerTitanInMap( player )
if ( IsAlive( titan ) )
{
#if DEV
printt( "ReplacementTitan", player, player.entindex(), "failed", "GetPlayerTitanInMap was true" )
#endif
return false
}

if ( player in file.warpFallDebounce )
{
if ( Time() - file.warpFallDebounce[ player ] < 3.0 )
{
#if DEV
printt( "ReplacementTitan", player, player.entindex(), "failed", "player in file.warpFallDebounce was true" )
#endif
return false
}
}

if ( level.nv.titanDropEnabledForTeam != TEAM_BOTH && level.nv.titanDropEnabledForTeam != player.GetTeam() )
if ( TitanDropDisabledForPlayerTeam( player ) )
return false

Point spawnPoint = GetTitanReplacementPoint( player, false )
Expand Down Expand Up @@ -1186,6 +1201,11 @@ bool function ShouldDoTitanfall()
return ( GetCurrentPlaylistVarInt( "enable_titanfalls", 1 ) == 1 )
}

bool function TitanDropDisabledForPlayerTeam( entity player )
{
return ( level.nv.titanDropEnabledForTeam != TEAM_BOTH && level.nv.titanDropEnabledForTeam != player.GetTeam() )
}

void function GiveTitanfallScoreMedal( entity player )
{
#if HAS_STATS
Expand Down

0 comments on commit fdf6332

Please sign in to comment.