Skip to content

Commit

Permalink
Merge branch 'R2Northstar:main' into crosshairtarget_callback
Browse files Browse the repository at this point in the history
  • Loading branch information
NachosChipeados authored Nov 13, 2024
2 parents 8980e94 + 28f398d commit ce3a1ee
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 58 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
npc_pilot_elite
{
GibModel0 "models/gibs/human_gibs.mdl"
headshotFX "P_headshot_pilot"
}
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ string function GetSelectedBurnCardRef( entity player )

#if SERVER
if ( GetItemDisplayData( ref ).hidden )
ClientCommand( player, "disconnect" )
NSDisconnectPlayer( player, "" )
#endif

#if SERVER || CLIENT
Expand Down
20 changes: 19 additions & 1 deletion Northstar.Custom/mod/scripts/vscripts/melee/sh_melee.gnut
Original file line number Diff line number Diff line change
Expand Up @@ -969,10 +969,28 @@ string function GetVictimSyncedMeleeTargetType( entity ent )
{
targetType = "prowler"
}

// Disabled to allow for executing NPC Pilots

// The way this function works, is that if an entity gets added here, then whatever "targetType" it returns
// gets passed to sh_melee_synced_human.gnut or sh_melee_synced_titan.gnut,
// which determines what animation set that entity should use when getting executed
// If an entity is not included, the it uses its BodyType to determine it ( see line 83 in sh_melee_synced_human)
// As you can see: Grunts, and Spectres are not included here, so it gets their BodyType (human) and goes from there

// I imagine the reason Respawn added the NPC Pilots to this function, is so they could make unique executions for them,
// just like the Prowlers
// Unfortunately, they either scrapped them, or simply never got around to making them
// That means this piece of code has basically no reason to exist anymore
// The only thing it does is break executions and thats it
// Since NPC Pilots also use the "human" BodyType, it means we can execute them with no issues

/*
else if ( IsPilotElite( ent ) )
{
targetType = "pilotelite"
}
*/
else if ( ent.IsNPC() )
{
targetType = ent.GetBodyType()
Expand Down Expand Up @@ -1223,4 +1241,4 @@ SyncedMelee ornull function PickRandomExecution( SyncedMeleeChooser actions, ent
return possibleExecutions[0]
}
#endif
#endif
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -226,37 +226,7 @@ void function SetWinner( int team, string winningReason = "", string losingReaso
SetGameState( eGameState.WinnerDetermined )
ScoreEvent_MatchComplete( team )

array<entity> players = GetPlayerArray()
int functionref( entity, entity ) compareFunc = GameMode_GetScoreCompareFunc( GAMETYPE )
if ( compareFunc != null )
{
players.sort( compareFunc )
int playerCount = players.len()
int currentPlace = 1
for ( int i = 0; i < 3; i++ )
{
if ( i >= playerCount )
continue

if ( i > 0 && compareFunc( players[i - 1], players[i] ) != 0 )
currentPlace += 1

switch( currentPlace )
{
case 1:
UpdatePlayerStat( players[i], "game_stats", "mvp" )
UpdatePlayerStat( players[i], "game_stats", "mvp_total" )
UpdatePlayerStat( players[i], "game_stats", "top3OnTeam" )
break
case 2:
UpdatePlayerStat( players[i], "game_stats", "top3OnTeam" )
break
case 3:
UpdatePlayerStat( players[i], "game_stats", "top3OnTeam" )
break
}
}
}
RegisterMatchStats_OnMatchComplete()
}
}
}
Expand Down
44 changes: 21 additions & 23 deletions Northstar.CustomServers/mod/scripts/vscripts/mp/_stats.nut
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ global function UpdateTitanCoreEarnedStat
global function PreScoreEventUpdateStats
global function PostScoreEventUpdateStats
global function Stats_OnPlayerDidDamage
global function RegisterMatchStats_OnMatchComplete

struct {
table< string, array<string> > refs
Expand All @@ -36,7 +37,6 @@ void function Stats_Init()
AddCallback_OnPlayerRespawned( OnPlayerRespawned )
AddCallback_OnClientConnected( OnClientConnected )
AddCallback_OnClientDisconnected( OnClientDisconnected )
AddCallback_GameStateEnter( eGameState.WinnerDetermined, OnWinnerDetermined )

thread HandleDistanceAndTimeStats_Threaded()
thread SaveStatsPeriodically_Threaded()
Expand Down Expand Up @@ -813,7 +813,7 @@ void function OnPlayerRespawned( entity player )
thread SetLastPosForDistanceStatValid_Threaded( player, true )
}

void function OnWinnerDetermined()
void function RegisterMatchStats_OnMatchComplete()
{
// award players for match completed, wins, and losses
foreach ( entity player in GetPlayerArray() )
Expand Down Expand Up @@ -888,30 +888,28 @@ void function OnWinnerDetermined()
player.SetPersistentVar( "kdratio_lifetime_pvp", kdratio_lifetimepvp )
}

// award mvp and top 3 in each team
if ( !IsFFAGame() )
array<entity> players = GetPlayerArray()
players.sort( GetScoreboardCompareFunc() )
int playerCount = players.len()
int currentPlace = 1
for ( int i = 0; i < 3; i++ )
{
string gamemode = GameRules_GetGameMode()
int functionref( entity, entity ) compareFunc = GameMode_GetScoreCompareFunc( gamemode )

for( int team = 0; team < MAX_TEAMS; team++ )
if ( i >= playerCount )
continue

int functionref( entity, entity ) compareFunc = GetScoreboardCompareFunc()
if ( i > 0 && compareFunc( players[i - 1], players[i] ) != 0 )
currentPlace += 1
switch( currentPlace )
{
array<entity> players = GetPlayerArrayOfTeam( team )
if ( compareFunc == null )
{
printt( "gamemode doesn't have a compare func to get the top 3" )
return
}
players.sort( compareFunc )
int maxAwards = int( min( players.len(), 3 ) )
for ( int i = 0; i < maxAwards; i++ )
{
if ( i == 0 )
Stats_IncrementStat( players[ i ], "game_stats", "mvp", "", 1.0 )
Stats_IncrementStat( players[ i ], "game_stats", "top3OnTeam", "", 1.0 )
}
case 1: // MVP have two parallel stats which one registers MVP for the map played and the other goes to the player's stats menu as a total MVP times
UpdatePlayerStat( players[i], "game_stats", "mvp" )
UpdatePlayerStat( players[i], "game_stats", "mvp_total" )
case 2:
case 3:
UpdatePlayerStat( players[i], "game_stats", "top3OnTeam" ) // Ingame this is the "Times Top 3" for the whole match, not per team
break
}

}
}

Expand Down
5 changes: 3 additions & 2 deletions Northstar.CustomServers/mod/scripts/vscripts/sh_loadouts.nut
Original file line number Diff line number Diff line change
Expand Up @@ -1509,7 +1509,7 @@ string function GetValidatedPersistentLoadoutValue( entity player, string loadou
{
printt( "Invalid Loadout Property: ", loadoutType, loadoutIndex, loadoutProperty, value )
value = ResetLoadoutPropertyToDefault( player, loadoutType, loadoutIndex, loadoutProperty ) //TODO: This will call player.SetPersistentVar() directly. Awkward to do this in a getter function
ClientCommand( player, "disconnect #RESETTING_LOADOUT", 0 ) //Kick player out with a "Resetting Invalid Loadout" message. Mainly necessary so UI/Client script don't crash out later with known, bad data from persistence
NSDisconnectPlayer( player, "#RESETTING_LOADOUT" ) // Kick player out with a "Resetting Invalid Loadout" message. Mainly necessary so UI/Client script don't crash out later with known, bad data from persistence
}
}

Expand All @@ -1519,7 +1519,8 @@ string function GetValidatedPersistentLoadoutValue( entity player, string loadou
{
printt( "Invalid Loadout Property: ", loadoutType, loadoutIndex, loadoutProperty, value )
value = ResetLoadoutPropertyToDefault( player, loadoutType, loadoutIndex, loadoutProperty ) //TODO: This will call player.SetPersistentVar() directly. Awkward to do this in a getter function
ClientCommand( player, "disconnect #RESETTING_LOADOUT", 0 ) //Kick player out with a "Resetting Invalid Loadout" message. Mainly necessary so UI/Client script don't crash out later with known, bad data from persistence
NSDisconnectPlayer( player, "#RESETTING_LOADOUT" ) // Kick player out with a "Resetting Invalid Loadout" message. Mainly necessary so UI/Client script don't crash out later with known, bad data from persistence

}

ValidateSkinAndCamoIndexesAsAPair( player, loadoutType, loadoutIndex, loadoutProperty, value ) //TODO: This is awkward, has the potential to call a SetPersistentLoadoutValue() if skinIndex and camoIndex are not correct as a pair
Expand Down

0 comments on commit ce3a1ee

Please sign in to comment.