Skip to content

Commit

Permalink
Move all owned NPCs together with player
Browse files Browse the repository at this point in the history
  • Loading branch information
Zanieon committed Feb 5, 2024
1 parent 06fd34d commit caf10cf
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Northstar.CustomServers/mod/scripts/vscripts/mp/_gamestate_mp.nut
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ void function PIN_GameStart()

AddCallback_OnPlayerKilled( OnPlayerKilled )
AddDeathCallback( "npc_titan", OnTitanKilled )
AddCallback_EntityChangedTeam( "player", OnPlayerChangedTeam )

RegisterSignal( "CleanUpEntitiesForRoundEnd" )
}
Expand Down Expand Up @@ -1017,3 +1018,18 @@ void function DialoguePlayWinnerDetermined()
PlayFactionDialogueToTeam( "scoring_lost", losingTeam )
}
}

void function OnPlayerChangedTeam( entity player )
{
if ( !player.hasConnected ) //Prevents players who just joined to trigger below code, as server always pre setups their teams
return

NotifyClientsOfTeamChange( player, GetOtherTeam( player.GetTeam() ), player.GetTeam() )

foreach( npc in GetNPCArray() )
{
entity bossPlayer = npc.GetBossPlayer()
if ( IsValidPlayer( bossPlayer ) && bossPlayer == player && IsAlive( npc ) )
SetTeam( npc, player.GetTeam() )
}
}

0 comments on commit caf10cf

Please sign in to comment.