aboutsummaryrefslogtreecommitdiff
path: root/Northstar.CustomServers/mod/scripts/vscripts/mp/spawn.nut
diff options
context:
space:
mode:
authorWilliam Miller <william-millennium@hotmail.com>2024-07-05 19:02:11 -0300
committerGitHub <noreply@github.com>2024-07-06 00:02:11 +0200
commit0198d3f99c40ab641c85fff62b62276407e0dfc3 (patch)
tree99b555698aeb4ec2bef26817cb7fe4b632cad967 /Northstar.CustomServers/mod/scripts/vscripts/mp/spawn.nut
parent8181dd7e0726883e335d09df637487f61dcbbb11 (diff)
downloadNorthstarMods-0198d3f99c40ab641c85fff62b62276407e0dfc3.tar.gz
NorthstarMods-0198d3f99c40ab641c85fff62b62276407e0dfc3.zip
Unfuck the Spawns (#808)v1.26.1-rc4v1.26.1-rc3v1.26.1-rc2
1. Get rid of the odd logic of limiting the algorithm to 3 spawn points 2. Changes the specific CTF algorithm to calculate the spawn points from the flag bases themselves rather than the initial spawn points which was causing severe inconsistencies. 3. Remove some checks in regards to map side swapping when matches reaches half-times due to odd behaviour in native code 4. Mitigate usage of `GetOtherTeam` for certain checks since that function might return Unreachable when it's a gamemode with more than 2 Teams and intentionally script crash the server.
Diffstat (limited to 'Northstar.CustomServers/mod/scripts/vscripts/mp/spawn.nut')
-rw-r--r--Northstar.CustomServers/mod/scripts/vscripts/mp/spawn.nut48
1 files changed, 19 insertions, 29 deletions
diff --git a/Northstar.CustomServers/mod/scripts/vscripts/mp/spawn.nut b/Northstar.CustomServers/mod/scripts/vscripts/mp/spawn.nut
index 4956375b..d64e3a5b 100644
--- a/Northstar.CustomServers/mod/scripts/vscripts/mp/spawn.nut
+++ b/Northstar.CustomServers/mod/scripts/vscripts/mp/spawn.nut
@@ -130,7 +130,7 @@ entity function FindSpawnPoint( entity player, bool isTitan, bool useStartSpawnp
{
int team = player.GetTeam()
if ( HasSwitchedSides() )
- team = GetOtherTeam( team )
+ team = ( team == TEAM_MILITIA ) ? TEAM_IMC : TEAM_MILITIA
array<entity> spawnpoints
if ( useStartSpawnpoint )
@@ -181,29 +181,19 @@ entity function GetBestSpawnpoint( entity player, array<entity> spawnpoints )
foreach ( entity spawnpoint in spawnpoints )
{
if ( IsSpawnpointValid( spawnpoint, player.GetTeam() ) )
- {
validSpawns.append( spawnpoint )
-
- if ( validSpawns.len() == 3 ) // arbitrary small sample size
- break
- }
}
- if ( validSpawns.len() == 0 )
+ if ( !validSpawns.len() )
{
// no valid spawns, very bad, so dont care about spawns being valid anymore
print( "found no valid spawns! spawns may be subpar!" )
foreach ( entity spawnpoint in spawnpoints )
- {
validSpawns.append( spawnpoint )
-
- if ( validSpawns.len() == 3 ) // arbitrary small sample size
- break
- }
}
// last resort
- if ( validSpawns.len() == 0 )
+ if ( !validSpawns.len() )
{
print( "map has literally 0 spawnpoints, as such everything is fucked probably, attempting to use info_player_start if present" )
entity start = GetEnt( "info_player_start" )
@@ -215,7 +205,7 @@ entity function GetBestSpawnpoint( entity player, array<entity> spawnpoints )
}
}
- return validSpawns[ RandomInt( validSpawns.len() ) ] // slightly randomize it
+ return validSpawns.getrandom() // slightly randomize it
}
bool function IsSpawnpointValid( entity spawnpoint, int team )
@@ -232,15 +222,18 @@ bool function IsSpawnpointValid( entity spawnpoint, int team )
return false
}
+ if( IsFFAGame() && !spawnpoint.IsVisibleToEnemies( team ) )
+ return true
+
int compareTeam = spawnpoint.GetTeam()
- if ( HasSwitchedSides() && ( compareTeam == TEAM_MILITIA || compareTeam == TEAM_IMC ) )
- compareTeam = GetOtherTeam( compareTeam )
-
+ if ( HasSwitchedSides() )
+ compareTeam = ( compareTeam == TEAM_MILITIA ) ? TEAM_IMC : TEAM_MILITIA
+
foreach ( bool functionref( entity, int ) customValidationRule in file.customSpawnpointValidationRules )
if ( !customValidationRule( spawnpoint, team ) )
return false
- if ( spawnpoint.GetTeam() > 0 && compareTeam != team && !IsFFAGame() )
+ if ( spawnpoint.GetTeam() > 0 && compareTeam != team )
return false
if ( spawnpoint.IsOccupied() )
@@ -261,13 +254,12 @@ bool function IsSpawnpointValid( entity spawnpoint, int team )
return false
}
- const minEnemyDist = 1000.0 // about 20 meters?
- // in rsquirrel extend returns null unlike in vanilla squirrel
- array< entity > spawnBlockers = GetPlayerArrayEx( "any", TEAM_ANY, TEAM_ANY, spawnpoint.GetOrigin(), minEnemyDist )
- spawnBlockers.extend( GetProjectileArrayEx( "any", TEAM_ANY, TEAM_ANY, spawnpoint.GetOrigin(), minEnemyDist ) )
- foreach ( entity blocker in spawnBlockers )
- if ( blocker.GetTeam() != team )
- return false
+ const minEnemyDist = 1200.0
+ array< entity > spawnBlockers = GetPlayerArrayEx( "any", TEAM_ANY, spawnpoint.GetTeam(), spawnpoint.GetOrigin(), minEnemyDist )
+ spawnBlockers.extend( GetProjectileArrayEx( "any", TEAM_ANY, spawnpoint.GetTeam(), spawnpoint.GetOrigin(), minEnemyDist ) )
+ spawnBlockers.extend( GetNPCArrayEx( "any", TEAM_ANY, spawnpoint.GetTeam(), spawnpoint.GetOrigin(), minEnemyDist ) )
+ if ( spawnBlockers.len() )
+ return false
// los check
return !spawnpoint.IsVisibleToEnemies( team )
@@ -399,11 +391,9 @@ void function InitPreferSpawnNodes()
// frontline
void function RateSpawnpoints_Frontline( int checkClass, array<entity> spawnpoints, int team, entity player )
{
+ float rating = RandomFloatRange( 0.0, 100.0 )
foreach ( entity spawnpoint in spawnpoints )
- {
- float rating = spawnpoint.CalculateFrontlineRating()
- spawnpoint.CalculateRating( checkClass, player.GetTeam(), rating, rating > 0 ? rating * 0.25 : rating )
- }
+ spawnpoint.CalculateRating( checkClass, player.GetTeam(), rating, rating )
}
// spawnzones