aboutsummaryrefslogtreecommitdiff
path: root/Northstar.CustomServers
diff options
context:
space:
mode:
Diffstat (limited to 'Northstar.CustomServers')
-rw-r--r--Northstar.CustomServers/mod/scripts/vscripts/_powerup.gnut14
-rw-r--r--Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_cp.nut3
-rw-r--r--Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_ctf.nut28
-rw-r--r--Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_riff_floor_is_lava.nut21
-rw-r--r--Northstar.CustomServers/mod/scripts/vscripts/lobby/_lobby.gnut2
-rw-r--r--Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut26
-rw-r--r--Northstar.CustomServers/mod/scripts/vscripts/mp/_gamestate_mp.nut5
-rw-r--r--Northstar.CustomServers/mod/scripts/vscripts/mp/spawn.nut20
8 files changed, 86 insertions, 33 deletions
diff --git a/Northstar.CustomServers/mod/scripts/vscripts/_powerup.gnut b/Northstar.CustomServers/mod/scripts/vscripts/_powerup.gnut
index 03b9fcfc7..60c4560f5 100644
--- a/Northstar.CustomServers/mod/scripts/vscripts/_powerup.gnut
+++ b/Northstar.CustomServers/mod/scripts/vscripts/_powerup.gnut
@@ -33,9 +33,13 @@ void function PowerupSpawnerThink( entity spawnpoint, PowerUp powerupDef )
svGlobal.levelEnt.EndSignal( "CleanUpEntitiesForRoundEnd" )
entity base = CreatePropDynamic( powerupDef.baseModel, spawnpoint.GetOrigin(), spawnpoint.GetAngles(), 2 )
- OnThreadEnd( function() : ( base )
+
+ entity powerup
+ OnThreadEnd( function() : ( base, powerup )
{
base.Destroy()
+ if ( IsValid( powerup ) )
+ powerup.Destroy()
})
while ( true )
@@ -43,7 +47,7 @@ void function PowerupSpawnerThink( entity spawnpoint, PowerUp powerupDef )
if ( !powerupDef.spawnFunc() )
return
- entity powerup = CreateEntity( "item_powerup" )
+ powerup = CreateEntity( "item_powerup" )
powerup.SetOrigin( base.GetOrigin() + powerupDef.modelOffset )
powerup.SetAngles( base.GetAngles() + powerupDef.modelAngles )
@@ -62,12 +66,6 @@ void function PowerupSpawnerThink( entity spawnpoint, PowerUp powerupDef )
PickupGlow glow = CreatePickupGlow( powerup, powerupDef.glowColor.x.tointeger(), powerupDef.glowColor.y.tointeger(), powerupDef.glowColor.z.tointeger() )
glow.glowFX.SetOrigin( spawnpoint.GetOrigin() ) // want the glow to be parented to the powerup, but have the position of the spawnpoint
- OnThreadEnd( function() : ( powerup )
- {
- if ( IsValid( powerup ) )
- powerup.Destroy()
- })
-
powerup.WaitSignal( "OnDestroy" )
wait powerupDef.respawnDelay
}
diff --git a/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_cp.nut b/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_cp.nut
index 4c9f61d55..41f5fedbf 100644
--- a/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_cp.nut
+++ b/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_cp.nut
@@ -34,7 +34,10 @@ void function GamemodeCP_Init()
void function RateSpawnpoints_CP( int checkClass, array<entity> spawnpoints, int team, entity player )
{
+ // check hardpoints
+ array<entity> startSpawns = SpawnPoints_GetPilotStart( team )
+ array<entity> enemyStartSpawns = SpawnPoints_GetPilotStart( GetOtherTeam( team ) )
}
void function SpawnHardpoints()
diff --git a/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_ctf.nut b/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_ctf.nut
index 09caa48d1..4a756c02f 100644
--- a/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_ctf.nut
+++ b/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_ctf.nut
@@ -40,6 +40,8 @@ void function CaptureTheFlag_Init()
AddCallback_OnPlayerKilled( OnPlayerKilled )
AddCallback_OnPilotBecomesTitan( DropFlagForBecomingTitan )
+ AddSpawnpointValidationRule( VerifyCTFSpawnpoint )
+
RegisterSignal( "FlagReturnEnded" )
RegisterSignal( "ResetDropTimeout" )
@@ -128,6 +130,32 @@ void function RateSpawnpoints_CTF( int checkClass, array<entity> spawnpoints, in
}
}
+bool function VerifyCTFSpawnpoint( entity spawnpoint, int team )
+{
+ // ensure spawnpoints aren't too close to enemy base
+
+ if ( HasSwitchedSides() && spawnpoint.GetTeam() >= 2 )
+ 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()
+
+ foreach ( entity spawn in enemyStartSpawns )
+ averageEnemySpawns += spawn.GetOrigin()
+
+ averageEnemySpawns /= startSpawns.len()
+
+ return Distance2D( spawnpoint.GetOrigin(), averageEnemySpawns ) / Distance2D( averageFriendlySpawns, averageEnemySpawns ) > 0.35
+}
+
void function CTFInitPlayer( entity player )
{
if ( !IsValid( file.imcFlagSpawn ) )
diff --git a/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_riff_floor_is_lava.nut b/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_riff_floor_is_lava.nut
index f8aa77998..99f513967 100644
--- a/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_riff_floor_is_lava.nut
+++ b/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_riff_floor_is_lava.nut
@@ -1,16 +1,17 @@
global function RiffFloorIsLava_Init
-struct {
- float pilotDamageMultiplier
- float titanDamageMultiplier
-} file
-
void function RiffFloorIsLava_Init()
{
AddCallback_OnPlayerRespawned( FloorIsLava_PlayerRespawned )
AddSpawnCallback( "env_fog_controller", InitLavaFogController )
AddCallback_EntitiesDidLoad( CreateCustomSpawns )
+ AddSpawnpointValidationRule( VerifyFloorIsLavaSpawnpoint )
+}
+
+bool function VerifyFloorIsLavaSpawnpoint( entity spawnpoint, int team )
+{
+ return spawnpoint.GetOrigin().z > GetLethalFogTop()
}
void function InitLavaFogController( entity fogController )
@@ -98,14 +99,14 @@ void function FloorIsLava_ThinkForPlayer( entity player )
if ( height < GetLethalFogTop() )
{
// do damage
- float damageMultiplier = 0.08
+ float damageMultiplier
if ( player.IsTitan() )
- damageMultiplier = 0.04
+ damageMultiplier = 0.0025
+ else
+ damageMultiplier = 0.05
// scale damage by time spent in fog and depth
- damageMultiplier *= 1 - ( height / GetLethalFogTop() )
-
- player.TakeDamage( player.GetMaxHealth() * damageMultiplier, null, null, { damageSourceId = eDamageSourceId.floor_is_lava } )
+ player.TakeDamage( player.GetMaxHealth() * GraphCapped( ( GetLethalFogTop() - height ) / ( GetLethalFogTop() - GetLethalFogBottom() ), 0.0, 1.0, 0.2, 1.0 ) * damageMultiplier, null, null, { damageSourceId = eDamageSourceId.floor_is_lava } )
wait 0.1
}
diff --git a/Northstar.CustomServers/mod/scripts/vscripts/lobby/_lobby.gnut b/Northstar.CustomServers/mod/scripts/vscripts/lobby/_lobby.gnut
index fd877f8cf..0f37251d6 100644
--- a/Northstar.CustomServers/mod/scripts/vscripts/lobby/_lobby.gnut
+++ b/Northstar.CustomServers/mod/scripts/vscripts/lobby/_lobby.gnut
@@ -31,7 +31,7 @@ bool function ClientCommandCallback_StartPrivateMatchSearch( entity player, arra
{
// open lobby in private match mode
SetCurrentPlaylist( "private_match" ) // required for private match lobby to start properly
- ServerCommand( "changelevel mp_lobby" )
+ GameRules_ChangeMap( "mp_lobby", GAMETYPE )
return true
} \ No newline at end of file
diff --git a/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut b/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut
index 6673d1743..5a0ec9894 100644
--- a/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut
+++ b/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut
@@ -163,9 +163,7 @@ void function CodeCallback_OnClientConnectionCompleted( entity player )
// Added via AddCallback_OnClientConnected
foreach ( callbackFunc in svGlobal.onClientConnectedCallbacks )
- {
callbackFunc( player )
- }
if ( !Flag( "PlayerDidSpawn") )
__PlayerDidSpawn( player )
@@ -232,6 +230,7 @@ void function CodeCallback_OnPlayerRespawned( entity player )
void function CodeCallback_OnPlayerKilled( entity player, var damageInfo )
{
PlayerOrNPCKilled( player, damageInfo )
+ HandleDeathPackage( player, damageInfo )
thread PostDeathThread_MP( player, damageInfo )
}
@@ -294,6 +293,12 @@ void function PostDeathThread_MP( entity player, var damageInfo ) // based on ga
if ( shouldDoReplay )
thread TrackDestroyTimeForReplay( attacker, replayTracker )
+ player.StartObserverMode( OBS_MODE_DEATHCAM )
+ if ( ShouldSetObserverTarget( attacker ) )
+ player.SetObserverTarget( attacker )
+ else
+ player.SetObserverTarget( null )
+
if ( !file.playerDeathsHidden )
Remote_CallFunction_NonReplay( player, "ServerCallback_YouDied", attacker.GetEncodedEHandle(), GetHealthFrac( attacker ), methodOfDeath )
@@ -310,7 +315,7 @@ void function PostDeathThread_MP( entity player, var damageInfo ) // based on ga
}
// quick note: in cases where player.Die() is called: e.g. for round ends, player == attacker
- if ( shouldDoReplay && KillcamsEnabled() ) // hack: double check if killcams are enabled here in case gamestate has changed this
+ if ( shouldDoReplay && Replay_IsEnabled() && KillcamsEnabled() && IsValid( attacker ) ) // hack: double check if killcams are enabled and valid here in case gamestate has changed this
{
player.watchingKillreplayEndTime = Time() + replayLength
float beforeTime = GetKillReplayBeforeTime( player, methodOfDeath )
@@ -357,13 +362,20 @@ void function PlayerWatchesKillReplayWrapper( entity player, entity attacker, fl
{
player.EndSignal( "RespawnMe" )
player.EndSignal( "OnRespawned" )
- player.EndSignal( "GameStateChanged" )
+
+ player.EndSignal( "OnDestroy" )
+ attacker.EndSignal( "OnDestroy" )
+
+ svGlobal.levelEnt.EndSignal( "GameStateChanged" )
OnThreadEnd( function() : ( player )
{
- player.ClearReplayDelay()
- player.ClearViewEntity()
- player.SetPredictionEnabled( true )
+ if ( IsValid( player ) )
+ {
+ player.ClearReplayDelay()
+ player.ClearViewEntity()
+ player.SetPredictionEnabled( true )
+ }
})
player.SetPredictionEnabled( false )
diff --git a/Northstar.CustomServers/mod/scripts/vscripts/mp/_gamestate_mp.nut b/Northstar.CustomServers/mod/scripts/vscripts/mp/_gamestate_mp.nut
index 46872692a..58c8bb9bf 100644
--- a/Northstar.CustomServers/mod/scripts/vscripts/mp/_gamestate_mp.nut
+++ b/Northstar.CustomServers/mod/scripts/vscripts/mp/_gamestate_mp.nut
@@ -643,7 +643,7 @@ void function CleanUpEntitiesForRoundEnd()
ClearTitanAvailable( player )
if ( IsAlive( player ) )
- player.Die()
+ player.Die( svGlobal.worldspawn, svGlobal.worldspawn, { damageSourceId = eDamageSourceId.round_end } )
if ( IsAlive( player.GetPetTitan() ) )
player.GetPetTitan().Destroy()
@@ -655,6 +655,9 @@ void function CleanUpEntitiesForRoundEnd()
foreach ( entity weapon in GetEntArrayByClass_Expensive( "weaponx" ) )
weapon.Destroy()
+
+ foreach ( entity battery in GetEntArrayByClass_Expensive( "item_titan_battery" ) )
+ battery.Destroy()
// allow other scripts to clean stuff up too
svGlobal.levelEnt.Signal( "CleanUpEntitiesForRoundEnd" )
diff --git a/Northstar.CustomServers/mod/scripts/vscripts/mp/spawn.nut b/Northstar.CustomServers/mod/scripts/vscripts/mp/spawn.nut
index 70d1e5276..941385612 100644
--- a/Northstar.CustomServers/mod/scripts/vscripts/mp/spawn.nut
+++ b/Northstar.CustomServers/mod/scripts/vscripts/mp/spawn.nut
@@ -7,6 +7,7 @@ global function SetRespawnsEnabled
global function RespawnsEnabled
global function SetSpawnpointGamemodeOverride
global function GetSpawnpointGamemodeOverride
+global function AddSpawnpointValidationRule
global function CreateNoSpawnArea
global function DeleteNoSpawnArea
@@ -27,6 +28,7 @@ struct NoSpawnArea
struct {
bool respawnsEnabled = true
string spawnpointGamemodeOverride
+ array< bool functionref( entity, int ) > customSpawnpointValidationRules
table<string, NoSpawnArea> noSpawnAreas
@@ -75,6 +77,11 @@ bool function RespawnsEnabled()
return file.respawnsEnabled
}
+void function AddSpawnpointValidationRule( bool functionref( entity spawn, int team ) rule )
+{
+ file.customSpawnpointValidationRules.append( rule )
+}
+
string function CreateNoSpawnArea( int blockSpecificTeam, int blockEnemiesOfTeam, vector position, float lifetime, float radius )
{
NoSpawnArea noSpawnArea
@@ -166,7 +173,7 @@ entity function FindSpawnPoint( entity player, bool isTitan, bool useStartSpawnp
}
entity spawnpoint = GetBestSpawnpoint( player, spawnpoints )
-
+
spawnpoint.s.lastUsedTime = Time()
player.SetLastSpawnPoint( spawnpoint )
@@ -230,21 +237,22 @@ bool function IsSpawnpointValid( entity spawnpoint, int team )
else if ( GameModeRemove( spawnpoint ) )
return false
}
-
- if ( Riff_FloorIsLava() && spawnpoint.GetOrigin().z < GetLethalFogTop() )
- return false
int compareTeam = spawnpoint.GetTeam()
if ( HasSwitchedSides() && ( compareTeam == TEAM_MILITIA || compareTeam == TEAM_IMC ) )
compareTeam = GetOtherTeam( compareTeam )
-
+
+ foreach ( bool functionref( entity, int ) customValidationRule in file.customSpawnpointValidationRules )
+ if ( !customValidationRule( spawnpoint, team ) )
+ return false
+
if ( spawnpoint.GetTeam() > 0 && compareTeam != team && !IsFFAGame() )
return false
if ( spawnpoint.IsOccupied() )
return false
- if ( Time() - spawnpoint.s.lastUsedTime <= 1.0 )
+ if ( Time() - spawnpoint.s.lastUsedTime <= 10.0 )
return false
foreach ( k, NoSpawnArea noSpawnArea in file.noSpawnAreas )