Skip to content

Commit

Permalink
Merge branch 'main' into match_goals_tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
Zanieon authored Nov 5, 2023
2 parents d9f3bf0 + 318561f commit 85d10e1
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 10 deletions.
11 changes: 7 additions & 4 deletions Northstar.Client/mod/scripts/vscripts/ui/panel_mainmenu.nut
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ void function InitMainMenuPanel()
headerIndex++
buttonIndex = 0
var multiplayerHeader = AddComboButtonHeader( comboStruct, headerIndex, "#MULTIPLAYER_ALLCAPS" )
file.mpButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#MULTIPLAYER_LAUNCH" )
Hud_AddEventHandler( file.mpButton, UIE_CLICK, OnPlayMPButton_Activate )
// "Launch Multiplayer" button removed because we don't support vanilla yet :clueless:
//file.mpButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#MULTIPLAYER_LAUNCH" )
//Hud_AddEventHandler( file.mpButton, UIE_CLICK, OnPlayMPButton_Activate )
file.fdButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#MENU_LAUNCH_NORTHSTAR" )
Hud_AddEventHandler( file.fdButton, UIE_CLICK, OnPlayFDButton_Activate )
Hud_SetLocked( file.fdButton, true )
Expand Down Expand Up @@ -169,7 +170,8 @@ void function OnShowMainMenuPanel()
#endif // PS4_PROG

UpdateSPButtons()
thread UpdatePlayButton( file.mpButton )
// dont try and update the launch multiplayer button, because it doesn't exist
//thread UpdatePlayButton( file.mpButton )
thread UpdatePlayButton( file.fdButton )
thread MonitorTrialVersionChange()

Expand Down Expand Up @@ -459,7 +461,8 @@ void function UpdatePlayButton( var button )
message = ""
}

ComboButton_SetText( file.mpButton, buttonText )
// dont try and update the launch multiplayer button, because it doesn't exist
//ComboButton_SetText( file.mpButton, buttonText )

ComboButton_SetText( file.fdButton, "#MENU_LAUNCH_NORTHSTAR" )
//Hud_SetEnabled( file.fdButton, false )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,10 @@ void function PostDeathThread_MP( entity player, var damageInfo ) // based on ga
})

entity attacker = DamageInfo_GetAttacker( damageInfo )
entity inflictor = DamageInfo_GetInflictor( damageInfo )
int eHandle = attacker.GetEncodedEHandle()
if ( inflictor && ShouldTryUseProjectileReplay( player, attacker, damageInfo, false ) )
eHandle = inflictor.GetEncodedEHandle()
int methodOfDeath = DamageInfo_GetDamageSourceIdentifier( damageInfo )

table<int, bool> alreadyAssisted
Expand Down Expand Up @@ -374,7 +378,7 @@ void function PostDeathThread_MP( entity player, var damageInfo ) // based on ga
if ( "respawnTime" in attacker.s )
respawnTime = Time() - expect float ( attacker.s.respawnTime )

thread PlayerWatchesKillReplayWrapper( player, attacker, respawnTime, timeOfDeath, beforeTime, replayTracker )
thread PlayerWatchesKillReplayWrapper( player, attacker, eHandle, respawnTime, timeOfDeath, beforeTime, replayTracker )
}

player.SetPlayerSettings( "spectator" ) // prevent a crash with going from titan => pilot on respawn
Expand Down Expand Up @@ -432,7 +436,7 @@ void function ForceRespawnMeSignalAfterDelay( entity player, int delay = 5 )
player.Signal( "RespawnMe" )
}

void function PlayerWatchesKillReplayWrapper( entity player, entity attacker, float timeSinceAttackerSpawned, float timeOfDeath, float beforeTime, table replayTracker )
void function PlayerWatchesKillReplayWrapper( entity player, entity attacker, int eHandle, float timeSinceAttackerSpawned, float timeOfDeath, float beforeTime, table replayTracker )
{
player.EndSignal( "RespawnMe" )
player.EndSignal( "OnRespawned" )
Expand All @@ -455,7 +459,7 @@ void function PlayerWatchesKillReplayWrapper( entity player, entity attacker, fl
})

player.SetPredictionEnabled( false )
PlayerWatchesKillReplay( player, attacker.GetEncodedEHandle(), attacker.GetIndexForEntity(), timeSinceAttackerSpawned, timeOfDeath, beforeTime, replayTracker )
PlayerWatchesKillReplay( player, eHandle, attacker.GetIndexForEntity(), timeSinceAttackerSpawned, timeOfDeath, beforeTime, replayTracker )
}

void function DecideRespawnPlayer( entity player )
Expand Down
34 changes: 31 additions & 3 deletions Northstar.CustomServers/mod/scripts/vscripts/mp/_gamestate_mp.nut
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ global function SetTimerBased
global function SetShouldUseRoundWinningKillReplay
global function SetRoundWinningKillReplayKillClasses
global function SetRoundWinningKillReplayAttacker
global function SetCallback_TryUseProjectileReplay
global function ShouldTryUseProjectileReplay
global function SetWinner
global function SetTimeoutWinnerDecisionFunc
global function AddTeamScore
Expand Down Expand Up @@ -48,13 +50,28 @@ struct {
float roundWinningKillReplayTime
entity roundWinningKillReplayVictim
entity roundWinningKillReplayAttacker
int roundWinningKillReplayInflictorEHandle // this is either the inflictor or the attacker
int roundWinningKillReplayMethodOfDeath
float roundWinningKillReplayTimeOfDeath
float roundWinningKillReplayHealthFrac

array<void functionref()> roundEndCleanupCallbacks
bool functionref( entity victim, entity attacker, var damageInfo, bool isRoundEnd ) shouldTryUseProjectileReplayCallback
} file

void function SetCallback_TryUseProjectileReplay( bool functionref( entity victim, entity attacker, var damageInfo, bool isRoundEnd ) callback )
{
file.shouldTryUseProjectileReplayCallback = callback
}

bool function ShouldTryUseProjectileReplay( entity victim, entity attacker, var damageInfo, bool isRoundEnd )
{
if ( file.shouldTryUseProjectileReplayCallback != null )
return file.shouldTryUseProjectileReplayCallback( victim, attacker, damageInfo, isRoundEnd )
// default to true (vanilla behaviour)
return true
}

void function PIN_GameStart()
{
// todo: using the pin telemetry function here, weird and was done veeery early on before i knew how this all worked, should use a different one
Expand Down Expand Up @@ -319,6 +336,7 @@ void function GameStateEnter_WinnerDetermined_Threaded()

WaitFrame() // prevent a race condition with PlayerWatchesRoundWinningKillReplay
file.roundWinningKillReplayAttacker = null // clear this
file.roundWinningKillReplayInflictorEHandle = -1

if ( killcamsWereEnabled )
SetKillcamsEnabled( true )
Expand Down Expand Up @@ -395,7 +413,7 @@ void function PlayerWatchesRoundWinningKillReplay( entity player, float replayLe
if ( IsValid( attacker ) )
{
player.SetKillReplayDelay( Time() - replayLength, THIRD_PERSON_KILL_REPLAY_ALWAYS )
player.SetKillReplayInflictorEHandle( attacker.GetEncodedEHandle() )
player.SetKillReplayInflictorEHandle( file.roundWinningKillReplayInflictorEHandle )
player.SetKillReplayVictim( file.roundWinningKillReplayVictim )
player.SetViewIndex( attacker.GetIndexForEntity() )
player.SetIsReplayRoundWinning( true )
Expand Down Expand Up @@ -461,6 +479,7 @@ void function GameStateEnter_SwitchingSides_Threaded()
svGlobal.levelEnt.Signal( "RoundEnd" ) // might be good to get a new signal for this? not 100% necessary tho i think
SetServerVar( "switchedSides", 1 )
file.roundWinningKillReplayAttacker = null // reset this after replay
file.roundWinningKillReplayInflictorEHandle = -1

if ( file.usePickLoadoutScreen )
SetGameState( eGameState.PickLoadout )
Expand All @@ -484,7 +503,7 @@ void function PlayerWatchesSwitchingSidesKillReplay( entity player, bool doRepla

entity attacker = file.roundWinningKillReplayAttacker
player.SetKillReplayDelay( Time() - replayLength, THIRD_PERSON_KILL_REPLAY_ALWAYS )
player.SetKillReplayInflictorEHandle( attacker.GetEncodedEHandle() )
player.SetKillReplayInflictorEHandle( file.roundWinningKillReplayInflictorEHandle )
player.SetKillReplayVictim( file.roundWinningKillReplayVictim )
player.SetViewIndex( attacker.GetIndexForEntity() )
player.SetIsReplayRoundWinning( true )
Expand Down Expand Up @@ -581,6 +600,9 @@ void function OnPlayerKilled( entity victim, entity attacker, var damageInfo )

ShowDeathHint( victim, damageInfo )

entity inflictor = DamageInfo_GetInflictor( damageInfo )
bool shouldUseInflictor = IsValid( inflictor ) && ShouldTryUseProjectileReplay( victim, attacker, damageInfo, true )

// set round winning killreplay info here if we're tracking pilot kills
// todo: make this not count environmental deaths like falls, unsure how to prevent this
if ( file.roundWinningKillReplayTrackPilotKills && victim != attacker && attacker != svGlobal.worldspawn && IsValid( attacker ) )
Expand All @@ -590,6 +612,7 @@ void function OnPlayerKilled( entity victim, entity attacker, var damageInfo )
file.roundWinningKillReplayTime = Time()
file.roundWinningKillReplayVictim = victim
file.roundWinningKillReplayAttacker = attacker
file.roundWinningKillReplayInflictorEHandle = ( shouldUseInflictor ? inflictor : attacker ).GetEncodedEHandle()
file.roundWinningKillReplayMethodOfDeath = DamageInfo_GetDamageSourceIdentifier( damageInfo )
file.roundWinningKillReplayTimeOfDeath = Time()
file.roundWinningKillReplayHealthFrac = GetHealthFrac( attacker )
Expand Down Expand Up @@ -640,6 +663,9 @@ void function OnTitanKilled( entity victim, var damageInfo )
return
}

entity inflictor = DamageInfo_GetInflictor( damageInfo )
bool shouldUseInflictor = IsValid( inflictor ) && ShouldTryUseProjectileReplay( victim, DamageInfo_GetAttacker( damageInfo ), damageInfo, true )

// set round winning killreplay info here if we're tracking titan kills
// todo: make this not count environmental deaths like falls, unsure how to prevent this
entity attacker = DamageInfo_GetAttacker( damageInfo )
Expand All @@ -650,6 +676,7 @@ void function OnTitanKilled( entity victim, var damageInfo )
file.roundWinningKillReplayTime = Time()
file.roundWinningKillReplayVictim = victim
file.roundWinningKillReplayAttacker = attacker
file.roundWinningKillReplayInflictorEHandle = ( shouldUseInflictor ? inflictor : attacker ).GetEncodedEHandle()
file.roundWinningKillReplayMethodOfDeath = DamageInfo_GetDamageSourceIdentifier( damageInfo )
file.roundWinningKillReplayTimeOfDeath = Time()
file.roundWinningKillReplayHealthFrac = GetHealthFrac( attacker )
Expand Down Expand Up @@ -764,11 +791,12 @@ void function SetRoundWinningKillReplayKillClasses( bool pilot, bool titan )
file.roundWinningKillReplayTrackTitanKills = titan // player kills in titans should get tracked anyway, might be worth renaming this
}

void function SetRoundWinningKillReplayAttacker( entity attacker )
void function SetRoundWinningKillReplayAttacker( entity attacker, int inflictorEHandle = -1 )
{
file.roundWinningKillReplayTime = Time()
file.roundWinningKillReplayHealthFrac = GetHealthFrac( attacker )
file.roundWinningKillReplayAttacker = attacker
file.roundWinningKillReplayInflictorEHandle = inflictorEHandle == -1 ? attacker.GetEncodedEHandle() : inflictorEHandle
file.roundWinningKillReplayTimeOfDeath = Time()
}

Expand Down

0 comments on commit 85d10e1

Please sign in to comment.