Skip to content

Commit

Permalink
Move CTF spawn point related functions
Browse files Browse the repository at this point in the history
as part of the refactoring effort in #830
  • Loading branch information
Zanieon committed Aug 30, 2024
1 parent 8b34689 commit 9e9d08f
Showing 1 changed file with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,30 +67,6 @@ void function CaptureTheFlag_Init()
ScoreEvent_SetEarnMeterValues( "FlagReturn", 0.0, 0.20 )
}

void function RateSpawnpoints_CTF( int checkClass, array<entity> spawnpoints, int team, entity player )
{
RateSpawnpoints_SpawnZones( checkClass, spawnpoints, team, player )
}

bool function VerifyCTFSpawnpoint( entity spawnpoint, int team )
{
// ensure spawnpoints aren't too close to enemy base
vector allyFlagSpot
vector enemyFlagSpot
foreach ( entity spawn in GetEntArrayByClass_Expensive( "info_spawnpoint_flag" ) )
{
if( spawn.GetTeam() == team )
allyFlagSpot = spawn.GetOrigin()
else
enemyFlagSpot = spawn.GetOrigin()
}

if( Distance2D( spawnpoint.GetOrigin(), allyFlagSpot ) > Distance2D( spawnpoint.GetOrigin(), enemyFlagSpot ) )
return false

return true
}

void function CreateFlags()
{
if ( IsValid( file.imcFlagSpawn ) )
Expand Down Expand Up @@ -211,6 +187,30 @@ void function RemoveFlags()
SetFlagStateForTeam( TEAM_IMC, eFlagState.None )
}

void function RateSpawnpoints_CTF( int checkClass, array<entity> spawnpoints, int team, entity player )
{
RateSpawnpoints_SpawnZones( checkClass, spawnpoints, team, player )
}

bool function VerifyCTFSpawnpoint( entity spawnpoint, int team )
{
// ensure spawnpoints aren't too close to enemy base
vector allyFlagSpot
vector enemyFlagSpot
foreach ( entity spawn in GetEntArrayByClass_Expensive( "info_spawnpoint_flag" ) )
{
if( spawn.GetTeam() == team )
allyFlagSpot = spawn.GetOrigin()
else
enemyFlagSpot = spawn.GetOrigin()
}

if( Distance2D( spawnpoint.GetOrigin(), allyFlagSpot ) > Distance2D( spawnpoint.GetOrigin(), enemyFlagSpot ) )
return false

return true
}

void function CTFInitPlayer( entity player )
{
if ( !IsValid( file.imcFlagSpawn ) )
Expand Down

0 comments on commit 9e9d08f

Please sign in to comment.