aboutsummaryrefslogtreecommitdiff
path: root/Northstar.CustomServers/mod/scripts/vscripts/mp
diff options
context:
space:
mode:
Diffstat (limited to 'Northstar.CustomServers/mod/scripts/vscripts/mp')
-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
3 files changed, 37 insertions, 14 deletions
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 )