Skip to content

Commit

Permalink
Merge branch 'main' into main_bug_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zxcPandora authored Nov 19, 2023
2 parents 98a1e28 + 1486b86 commit a035a41
Show file tree
Hide file tree
Showing 14 changed files with 93 additions and 55 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
2 changes: 0 additions & 2 deletions Northstar.Custom/keyvalues/playlists_v2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ playlists
max_teams 12
classic_mp 1

scorelimit 21 // temp until we have a way of dynamically setting non-default scorelimit in code

gamemode_score_hint #GAMEMODE_SCORE_HINT_FFA
gamemode_bullet_001 #GAMEMODE_BULLET_FFA_001
gamemode_bullet_002 #GAMEMODE_BULLET_FFA_002
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@ void function GamemodeGG_Init()
AddCallback_GameStateEnter( eGameState.WinnerDetermined, OnWinnerDetermined )

AddCallback_GGEarnMeterFull( OnGGEarnMeterFilled )

// set scorelimit if it's wrong, sort of a jank way to do it but best i've got rn
try
{
if ( GetCurrentPlaylistVarInt( "scorelimit", GetGunGameWeapons().len() ) != GetGunGameWeapons().len() )
SetPlaylistVarOverride( "scorelimit", GetGunGameWeapons().len().tostring() )
}
catch ( ex ) {}
}

void function OnPlayerDisconnected(entity player)
Expand Down
4 changes: 4 additions & 0 deletions Northstar.CustomServers/mod/scripts/vscripts/_items.nut
Original file line number Diff line number Diff line change
Expand Up @@ -10231,6 +10231,10 @@ void function StatUnlock_Unlocked( entity player, string itemRef, string parentR
if ( IsItemNew( player, itemRef, parentRef ) )
return

// early out if the player has progression disabled
if ( !ProgressionEnabledForPlayer( player ) )
return

int refGuid = file.itemRefToGuid[itemRef]
int parentRefGuid = parentRef == "" ? 0 : file.itemRefToGuid[parentRef]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,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 @@ -385,7 +389,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 @@ -443,7 +447,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 @@ -466,7 +470,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
2 changes: 1 addition & 1 deletion Northstar.CustomServers/mod/scripts/vscripts/mp/_stats.nut
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ void function HandleKillStats( entity victim, entity attacker, var damageInfo )
string source = DamageSourceIDToString( attackerInfo.damageSourceId )

if ( IsValidStatItemString( source ) )
Stats_IncrementStat( attacker, "weapon_kill_stats", "assistsTotal", source, 1.0 )
Stats_IncrementStat( attackerInfo.attacker, "weapon_kill_stats", "assistsTotal", source, 1.0 )
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ void function ValidateEquippedItems( entity player )
// camoIndex
if ( loadout.skinIndex == TITAN_SKIN_INDEX_CAMO )
{
array<ItemData> camoSkins = GetAllItemsOfType( eItemTypes.CAMO_SKIN )
array<ItemData> camoSkins = GetAllItemsOfType( eItemTypes.CAMO_SKIN_TITAN )
if ( loadout.camoIndex >= camoSkins.len() || loadout.camoIndex < 0 )
{
printt( " - INVALID TITAN CAMO/SKIN, RESETTING" )
Expand Down Expand Up @@ -363,7 +363,7 @@ void function ValidateEquippedItems( entity player )
// primeCamoIndex
if ( loadout.primeSkinIndex == TITAN_SKIN_INDEX_CAMO )
{
array<ItemData> camoSkins = GetAllItemsOfType( eItemTypes.CAMO_SKIN )
array<ItemData> camoSkins = GetAllItemsOfType( eItemTypes.CAMO_SKIN_TITAN )
if ( loadout.primeCamoIndex >= camoSkins.len() || loadout.primeCamoIndex < 0 )
{
printt( " - INVALID TITAN CAMO/SKIN, RESETTING" )
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# NorthstarMods
<a href="https://translate.harmony.tf/engage/northstar/">
<img src="https://translate.harmony.tf/widgets/northstar/-/client/svg-badge.svg" alt="Translation status" />
</a>

[Squirrel](http://www.squirrel-lang.org/squirreldoc/reference/index.html) scripts used to recreate server-side gamelogic and add [custom content](https://r2northstar.gitbook.io/r2northstar-wiki/using-northstar/gamemodes) to the game.

Expand All @@ -9,3 +12,11 @@ Issues in this repository should be created if they are related to these domains
- `Northstar.Coop` - Soon™.
- `Northstar.Custom` - Northstar custom content.
- `Northstar.CustomServer` - Server config files and scripts necessary for multiplayer.

### Translating

Translations can be submitted via [weblate](https://translate.harmony.tf/projects/northstar/client/).

<a href="https://translate.harmony.tf/engage/northstar/">
<img src="https://translate.harmony.tf/widgets/northstar/-/client/multi-auto.svg" alt="Translation status" />
</a>

0 comments on commit a035a41

Please sign in to comment.