aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2022-04-27 00:58:16 +0000
committerBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2022-04-27 00:58:16 +0000
commit42c982500f06d04ac87fe9a6030d26f83be089c1 (patch)
tree6e92843a5600560656387a0f62a5df743b84c0ac
parent31cba09fea290cfddde6cc77af836b1cd4756bdd (diff)
downloadNorthstarMods-42c982500f06d04ac87fe9a6030d26f83be089c1.tar.gz
NorthstarMods-42c982500f06d04ac87fe9a6030d26f83be089c1.zip
potentially better ctf spawns fr this time
-rw-r--r--Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_ctf.nut58
1 files changed, 33 insertions, 25 deletions
diff --git a/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_ctf.nut b/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_ctf.nut
index 99f34164..cca446d2 100644
--- a/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_ctf.nut
+++ b/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_ctf.nut
@@ -42,7 +42,6 @@ void function CaptureTheFlag_Init()
AddCallback_OnPilotBecomesTitan( DropFlagForBecomingTitan )
SetSpawnZoneRatingFunc( DecideSpawnZone_CTF )
- AddSpawnpointValidationRule( VerifyCTFSpawnpoint )
RegisterSignal( "FlagReturnEnded" )
RegisterSignal( "ResetDropTimeout" )
@@ -67,33 +66,42 @@ void function CaptureTheFlag_Init()
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
-
- if ( HasSwitchedSides() )
- team = GetOtherTeam( team )
-
- array<entity> startSpawns = SpawnPoints_GetPilotStart( team )
- array<entity> enemyStartSpawns = SpawnPoints_GetPilotStart( GetOtherTeam( team ) )
-
- vector averageFriendlySpawns
- vector averageEnemySpawns
-
- foreach ( entity spawn in startSpawns )
- averageFriendlySpawns += spawn.GetOrigin()
-
- averageFriendlySpawns /= startSpawns.len()
+ // get the player's frontline and try to spawn them there, then give less good ratings as we get away from the frontline in the direction of the player's base
+ Frontline frontline = GetFrontline( player.GetTeam() )
- foreach ( entity spawn in enemyStartSpawns )
- averageEnemySpawns += spawn.GetOrigin()
+ entity ourFlag = GetFlagForTeam( player.GetTeam() )
+ entity theirFlag = GetFlagForTeam( GetOtherTeam( player.GetTeam() ) )
+ float flagDist = Distance2D( ourFlag.GetOrigin(), theirFlag.GetOrigin() )
- averageEnemySpawns /= startSpawns.len()
+ // dividing dist between flags by 3ish gives a good radius for the initial circle
+ // should this be based on the distance to the frontline? unsure, it probably should be based more on map size than spawn pos anyway
+ float initialRatingRad = flagDist / 2.75 / 2
- return Distance2D( spawnpoint.GetOrigin(), averageEnemySpawns ) / Distance2D( averageFriendlySpawns, averageEnemySpawns ) > 0.35
+ foreach ( entity spawnpoint in spawnpoints )
+ {
+ float rating
+
+ // assume 150 is the max possible rating, with a range of 50-150 if within the initial rating radius, and 0-50 outside of it
+ float dist = Distance2D( spawnpoint.GetOrigin(), frontline.origin )
+ if ( dist <= initialRatingRad )
+ rating = 50 + ( ( ( initialRatingRad / dist ) - initialRatingRad ) * 100 )
+ else
+ {
+ // determine the angles of the lines we need to be within to be rated here
+ // magic number gives roughly ~8deg from right mid to base on glitch
+ float ratingAnglePos = flagDist / 0.0026
+ float ratingAngleNeg = flagDist / -0.0026
+ ratingAngleNeg = ( ( ( ratingAngleNeg % 360 ) + 360 ) % 360 ) // this is probably shit i just copied a negative modulo func
+
+ // calc angle between our spawnpoint and frontline, check if it's within the previous 2 angles
+ float angle = atan2( spawnpoint.GetOrigin().y - frontline.origin.y, spawnpoint.GetOrigin().x - frontline.origin.x ) * ( 180 / PI )
+ if ( angle <= ratingAnglePos && angle <= ratingAngleNeg )
+ // max out at flagDist
+ rating = ( ( ( flagDist / dist ) - flagDist ) * 50 )
+ }
+
+ spawnpoint.CalculateRating( checkClass, player.GetTeam(), rating, rating > 0 ? rating * 0.25 : rating )
+ }
}
void function CTFInitPlayer( entity player )