Skip to content

Commit

Permalink
Merge branch 'R2Northstar:main' into progression_aegis_reset
Browse files Browse the repository at this point in the history
  • Loading branch information
Zanieon authored Dec 7, 2023
2 parents 4c9fe64 + 0c5c9b1 commit 533fad4
Show file tree
Hide file tree
Showing 12 changed files with 146 additions and 44 deletions.
14 changes: 1 addition & 13 deletions .github/nativefuncs.json
Original file line number Diff line number Diff line change
Expand Up @@ -421,13 +421,7 @@
"helpText":"Returns whether or not a given path leads to a folder.",
"returnTypeString":"bool",
"argTypes":"string path"
},
{
"name":"NSPushGameStateData",
"helpText":"",
"returnTypeString":"void",
"argTypes":"struct gamestate"
}
}
],
"UI":[
{
Expand Down Expand Up @@ -724,12 +718,6 @@
"returnTypeString":"bool",
"argTypes":"string path"
},
{
"name":"NSPushUIPresence",
"helpText":"",
"returnTypeString":"void",
"argTypes":"struct presence"
},
{
"name":"NSGetMasterServerAuthResult",
"helpText":"",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,5 +353,9 @@ Choisissez Oui si vous êtes d'accord. Ce choix peut être modifié à tout inst
"TOGGLE_PROGRESSION" "Activer la progression"
"Y_BUTTON_TOGGLE_PROGRESSION" "%[Y_BUTTON|]% Activer la progression"
"PROGRESSION_ANNOUNCEMENT_BODY" "^CCCC0000Le système de progression peut être activé !^\n\nNorthstar supporte désormais le système de progression du jeu original, vous permettant de choisir si vous souhaitez débloquer les armes, skins, titans etc. en gagnant des niveaux et en complétant des défis.\n\nVous pouvez activer la progression en utilisant le bouton en bas de l'écran d'accueil.\n\nCeci peut être changé à tout moment."
"AUTHENTICATION_FAILED_HEADER" "Échec de l'authentification"
"AUTHENTICATION_FAILED_HELP" "Aide"
"AUTHENTICATION_FAILED_ERROR_CODE" "Code d'erreur : ^DB6F2C00%s1^"
"AUTHENTICATION_FAILED_BODY" "L'authentification avec Atlas a échoué."
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
global enum eDiscordGameState
{
LOADING = 0
MAINMENU
LOBBY
INGAME
}

global struct GameStateStruct {

string map
Expand All @@ -15,10 +23,7 @@ global struct GameStateStruct {
}

global struct UIPresenceStruct {
bool isLoading
bool isLobby
string loadingLevel
string loadedLevel
int gameState
}

global struct RequiredModInfo
Expand Down
11 changes: 4 additions & 7 deletions Northstar.Client/mod/scripts/vscripts/presence/cl_presence.nut
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
untyped
globalize_all_functions

void function NorthstarCodeCallback_GenerateGameState() {

GameStateStruct gs

GameStateStruct function DiscordRPC_GenerateGameState( GameStateStruct gs )
{
int highestScore = 0
int secondHighest = 0

Expand Down Expand Up @@ -40,6 +38,5 @@ void function NorthstarCodeCallback_GenerateGameState() {
gs.timeEnd = expect float(level.nv.roundEndTime - Time())
else
gs.timeEnd = expect float(level.nv.gameEndTime - Time())

NSPushGameStateData(gs)
}
return gs
}
20 changes: 12 additions & 8 deletions Northstar.Client/mod/scripts/vscripts/presence/ui_presence.nut
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
untyped
globalize_all_functions

void function NorthstarCodeCallback_GenerateUIPresence() {
UIPresenceStruct uis
UIPresenceStruct function DiscordRPC_GenerateUIPresence( UIPresenceStruct uis )
{
if ( uiGlobal.isLoading )
uis.gameState = eDiscordGameState.LOADING;
else if ( uiGlobal.loadedLevel == "" )
uis.gameState = eDiscordGameState.MAINMENU;
else if ( IsLobby() || uiGlobal.loadedLevel == "mp_lobby" )
uis.gameState = eDiscordGameState.LOBBY;
else
uis.gameState = eDiscordGameState.INGAME;

uis.isLoading = uiGlobal.isLoading
uis.isLobby = IsLobby()
uis.loadingLevel = uiGlobal.loadingLevel
uis.loadedLevel = uiGlobal.loadedLevel
NSPushUIPresence(uis)
}
return uis
}
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 @@ -193,6 +193,10 @@ bool function ClientCommandCallback_SwapSecondaryAndWeapon3PersistentLoadoutData

// get loadout
int index = args[0].tointeger()

if ( !IsValidPilotLoadoutIndex(index) )
return false

PilotLoadoutDef loadout = GetPilotLoadoutFromPersistentData( player, index )

// swap loadouts
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 @@ -394,7 +412,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 @@ -460,6 +478,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 @@ -483,7 +502,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 @@ -578,6 +597,9 @@ void function OnPlayerKilled( entity victim, entity attacker, var damageInfo )
return
}

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 @@ -587,6 +609,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 @@ -637,6 +660,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 @@ -647,6 +673,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 @@ -761,11 +788,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
50 changes: 48 additions & 2 deletions Northstar.CustomServers/mod/scripts/vscripts/mp/_score.nut
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ void function InitPlayerForScoreEvents( entity player )
player.s.currentKillstreak <- 0
player.s.lastKillTime <- 0.0
player.s.currentTimedKillstreak <- 0
player.s.lastKillTime_Mayhem <- 0.0
player.s.currentTimedKillstreak_Mayhem <- 0
player.s.lastKillTime_Onslaught <- 0.0
player.s.currentTimedKillstreak_Onslaught <- 0
}

void function AddPlayerScore( entity targetPlayer, string scoreEventName, entity associatedEnt = null, string noideawhatthisis = "", int pointValueOverride = -1 )
Expand Down Expand Up @@ -93,6 +97,7 @@ void function ScoreEvent_PlayerKilled( entity victim, entity attacker, var damag
victim.s.currentTimedKillstreak = 0

victim.p.numberOfDeathsSinceLastKill++ // this is reset on kill
victim.p.lastKiller = attacker

// have to do this early before we reset victim's player killstreaks
// nemesis when you kill a player that is dominating you
Expand Down Expand Up @@ -131,12 +136,20 @@ void function ScoreEvent_PlayerKilled( entity victim, entity attacker, var damag
attacker.p.numberOfDeathsSinceLastKill = 0
}

// revenge + quick revenge
if ( attacker.p.lastKiller == victim )
{
if ( Time() - GetPlayerLastRespawnTime( attacker ) < QUICK_REVENGE_TIME_LIMIT )
AddPlayerScore( attacker, "QuickRevenge" )
else
AddPlayerScore( attacker, "Revenge" )
}

// untimed killstreaks
attacker.s.currentKillstreak++
if ( attacker.s.currentKillstreak == 3 )
if ( attacker.s.currentKillstreak == KILLINGSPREE_KILL_REQUIREMENT )
AddPlayerScore( attacker, "KillingSpree" )
else if ( attacker.s.currentKillstreak == 5 )
else if ( attacker.s.currentKillstreak == RAMPAGE_KILL_REQUIREMENT )
AddPlayerScore( attacker, "Rampage" )

// increment untimed killstreaks against specific players
Expand Down Expand Up @@ -234,6 +247,39 @@ void function ScoreEvent_NPCKilled( entity victim, entity attacker, var damageIn
AddPlayerScore( attacker, ScoreEventForNPCKilled( victim, damageInfo ), victim )
}
catch ( ex ) {}

if ( !attacker.IsPlayer() )
return

// mayhem/onslaught (timed killstreaks vs AI)

// reset before checking
if ( Time() - attacker.s.lastKillTime_Mayhem > MAYHEM_REQUIREMENT_TIME )
{
attacker.s.currentTimedKillstreak_Mayhem = 0
attacker.s.lastKillTime_Mayhem = Time()
}
if ( Time() - attacker.s.lastKillTime_Mayhem <= MAYHEM_REQUIREMENT_TIME )
{
attacker.s.currentTimedKillstreak_Mayhem++

if ( attacker.s.currentTimedKillstreak_Mayhem == MAYHEM_REQUIREMENT_KILLS )
AddPlayerScore( attacker, "Mayhem" )
}

// reset before checking
if ( Time() - attacker.s.lastKillTime_Onslaught > ONSLAUGHT_REQUIREMENT_TIME )
{
attacker.s.currentTimedKillstreak_Onslaught = 0
attacker.s.lastKillTime_Onslaught = Time()
}
if ( Time() - attacker.s.lastKillTime_Onslaught <= ONSLAUGHT_REQUIREMENT_TIME )
{
attacker.s.currentTimedKillstreak_Onslaught++

if ( attacker.s.currentTimedKillstreak_Onslaught == ONSLAUGHT_REQUIREMENT_KILLS )
AddPlayerScore( attacker, "Onslaught" )
}
}

void function ScoreEvent_MatchComplete( int winningTeam )
Expand Down
Loading

0 comments on commit 533fad4

Please sign in to comment.