diff options
author | William Miller <william-millennium@hotmail.com> | 2024-04-12 20:54:55 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-13 01:54:55 +0200 |
commit | 9661372712f47f3c5d3ef83f1c7776484eeab52f (patch) | |
tree | 6040de569add7e627c5f7d5024d7830049b0d1f0 /Northstar.CustomServers/mod/scripts/vscripts | |
parent | f427583ec497f80aa2f80ac4d34dc44b7e23643f (diff) | |
download | NorthstarMods-9661372712f47f3c5d3ef83f1c7776484eeab52f.tar.gz NorthstarMods-9661372712f47f3c5d3ef83f1c7776484eeab52f.zip |
Move all owned NPCs together with player on Team Switching (#789)
Uses a call back that is triggered when the player switches team to update their own entities accordingly.
Diffstat (limited to 'Northstar.CustomServers/mod/scripts/vscripts')
-rw-r--r-- | Northstar.CustomServers/mod/scripts/vscripts/mp/_gamestate_mp.nut | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Northstar.CustomServers/mod/scripts/vscripts/mp/_gamestate_mp.nut b/Northstar.CustomServers/mod/scripts/vscripts/mp/_gamestate_mp.nut index e2bb36d2..5cc096f2 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/mp/_gamestate_mp.nut +++ b/Northstar.CustomServers/mod/scripts/vscripts/mp/_gamestate_mp.nut @@ -96,6 +96,7 @@ void function PIN_GameStart() AddCallback_OnPlayerKilled( OnPlayerKilled ) AddDeathCallback( "npc_titan", OnTitanKilled ) + AddCallback_EntityChangedTeam( "player", OnPlayerChangedTeam ) RegisterSignal( "CleanUpEntitiesForRoundEnd" ) } @@ -1017,3 +1018,21 @@ void function DialoguePlayWinnerDetermined() PlayFactionDialogueToTeam( "scoring_lost", losingTeam ) } } + +/// This is to move all NPCs that a player owns from one team to the other during a match +/// Auto-Titans, Turrets, Ticks and Hacked Spectres will all move along together with the player to the new Team +/// Also possibly prevents mods that spawns other types of NPCs that players can own from breaking when switching (i.e Drones, Hacked Reapers) +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() ) + } +} |