Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable a button to allow players to change teams #872

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions Northstar.Client/mod/scripts/vscripts/ui/menu_ingame.nut
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,12 @@ void function InitInGameMPMenu()
var gameHeader = AddComboButtonHeader( comboStruct, headerIndex, "#MENU_HEADER_GAME" )
var leaveButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#LEAVE_MATCH" )
Hud_AddEventHandler( leaveButton, UIE_CLICK, OnLeaveButton_Activate )
#if DEV
var devButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "Dev" )
Hud_AddEventHandler( devButton, UIE_CLICK, AdvanceMenuEventHandler( GetMenu( "DevMenu" ) ) )
#endif
Zanieon marked this conversation as resolved.
Show resolved Hide resolved
ASpoonPlaysGames marked this conversation as resolved.
Show resolved Hide resolved

if ( GetConVarBool( "ns_allow_team_change" ) )
Zanieon marked this conversation as resolved.
Show resolved Hide resolved
{
var devButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#SWITCH_TEAMS" )
Zanieon marked this conversation as resolved.
Show resolved Hide resolved
Zanieon marked this conversation as resolved.
Show resolved Hide resolved
Hud_AddEventHandler( devButton, UIE_CLICK, OnRequestTeamSwitch )
}

headerIndex++
buttonIndex = 0
Expand Down Expand Up @@ -700,3 +702,9 @@ void function SetTitanSelectButtonVisibleState( bool state )
Hud_Hide( file.titanSelectButton )
}
}

void function OnRequestTeamSwitch( var button )
{
ClientCommand( "changeteam" )
CloseAllMenus()
}
5 changes: 5 additions & 0 deletions Northstar.CustomServers/mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@
"Name": "ns_progression_enabled",
"DefaultValue": "0",
"Flags": "ARCHIVE_PLAYERPROFILE"
},
{
"Name": "ns_allow_team_change",
"DefaultValue": "1",
"Flags": "REPLICATED"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know spoon wanted this ( and I agree with it ) but would be great to know version compat of this change before release

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be up to @GeckoEidechse when he does a release with this change right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have the capacity to test that atm. If someone could take care of that, that would great.
It can be tested without making a release.

Basically testing should cover

  • New server <-> Old Client
  • Old server <-> New Client

And on that note

  • New server with old client not working is a non-issue as we can just version gate
  • Old server with new client would suck as servers don't update that fast. We could still do it though, just need to ping server hosts.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New Clients to Old Servers won't change anything, the server will recieve the command from the button but ignore it.

New Servers to Old Clients will also not change anything substantial besides old clients having to type "changeteam" in console in order to swap.

}
],
"Scripts": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ struct {
array<entity> specCams

entity functionref( entity player, entity basePoint ) recalculateRespawnAsTitanStartPointCallback
table<entity, float> playerChangeTeamTimeBuffer
} file

void function BaseGametype_Init_MPSP()
{
AddClientCommandCallback( "changeteam", ClientCommandCallbackChangeTeam )
AddSpawnCallback( "info_intermission", SetIntermissionCamera )

AddPostDamageCallback( "player", AddToTitanDamageStat )
Expand Down Expand Up @@ -630,6 +632,27 @@ void function SetRecalculateRespawnAsTitanStartPointCallback( entity functionref
file.recalculateRespawnAsTitanStartPointCallback = callbackFunc
}

bool function ClientCommandCallbackChangeTeam( entity player, array<string> args )
{
if ( !( player in file.playerChangeTeamTimeBuffer ) )
file.playerChangeTeamTimeBuffer[ player ] <- Time() + 5
else
{
if ( file.playerChangeTeamTimeBuffer[ player ] > Time() )
{
SendHudMessage( player, "Team Switching is on Cooldown", -1, 0.4, 255, 255, 255, 255, 0.15, 3.0, 0.5 )
return true
}
}
Zanieon marked this conversation as resolved.
Show resolved Hide resolved

if ( GetCurrentPlaylistVarInt( "max_teams", 0 ) > 1 && !IsFFAGame() && GamePlaying() )
SetTeam( player, GetOtherTeam( player.GetTeam() ) )
else
SendHudMessage( player, "Current gamemode doesn't support team change", -1, 0.4, 255, 255, 255, 255, 0.15, 3.0, 0.5 )

return true
}

// stuff to change later

bool function ShouldEntTakeDamage_SPMP( entity ent, var damageInfo )
Expand Down
Loading