diff options
-rw-r--r-- | Northstar.CustomServers/mod/scripts/vscripts/mp/spawn.nut | 51 |
1 files changed, 3 insertions, 48 deletions
diff --git a/Northstar.CustomServers/mod/scripts/vscripts/mp/spawn.nut b/Northstar.CustomServers/mod/scripts/vscripts/mp/spawn.nut index 84317c6e..5bf150c0 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/mp/spawn.nut +++ b/Northstar.CustomServers/mod/scripts/vscripts/mp/spawn.nut @@ -396,55 +396,10 @@ void function InitPreferSpawnNodes() // frontline void function RateSpawnpoints_Frontline( int checkClass, array<entity> spawnpoints, int team, entity player ) { - Frontline frontline = GetFrontline( player.GetTeam() ) - - // heavily based on ctf spawn algo iteration 4, only changes it at the end - array<entity> startSpawns = SpawnPoints_GetPilotStart( team ) - array<entity> enemyStartSpawns = SpawnPoints_GetPilotStart( GetOtherTeam( team ) ) - - if ( startSpawns.len() == 0 || enemyStartSpawns.len() == 0 ) // ensure we don't crash - return - - // get average startspawn position and max dist between spawns - // could probably cache this, tbh, not like it should change outside of halftimes - vector averageFriendlySpawns - float maxFriendlySpawnDist - - foreach ( entity spawn in startSpawns ) - { - foreach ( entity otherSpawn in startSpawns ) - { - float dist = Distance2D( spawn.GetOrigin(), otherSpawn.GetOrigin() ) - if ( dist > maxFriendlySpawnDist ) - maxFriendlySpawnDist = dist - } - - averageFriendlySpawns += spawn.GetOrigin() - } - - averageFriendlySpawns /= startSpawns.len() - - // get average enemy startspawn position - vector averageEnemySpawns - - foreach ( entity spawn in enemyStartSpawns ) - averageEnemySpawns += spawn.GetOrigin() - - averageEnemySpawns /= enemyStartSpawns.len() - - // from here, rate spawns - float baseDistance = Distance2D( averageFriendlySpawns, averageEnemySpawns ) - foreach ( entity spawn in spawnpoints ) + foreach ( entity spawnpoint in spawnpoints ) { - // ratings should max/min out at 100 / -100 - // start by prioritizing closer spawns, but not so much that enemies won't really affect them - float rating = 10 * ( 1.0 - Distance2D( averageFriendlySpawns, spawn.GetOrigin() ) / baseDistance ) - - // rate based on distance to frontline, and then prefer spawns in the same dir from the frontline as the combatdir - rating += rating * ( 1.0 - ( Distance2D( spawn.GetOrigin(), frontline.friendlyCenter ) / baseDistance ) ) - rating *= fabs( frontline.combatDir.y - Normalize( spawn.GetOrigin() - averageFriendlySpawns ).y ) - - spawn.CalculateRating( checkClass, player.GetTeam(), rating, rating ) + float rating = spawnpoint.CalculateFrontlineRating() + spawnpoint.CalculateRating( checkClass, player.GetTeam(), rating, rating > 0 ? rating * 0.25 : rating ) } } |