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

Add button to allow players to change teams #872

Merged
merged 25 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
520468f
Changeteam feature
Zanieon Sep 7, 2024
4cddc1a
Buffer by time the ability to change teams
Zanieon Sep 7, 2024
d7b0678
Replicate convar, hide button on disable
Zanieon Sep 7, 2024
c4c3a78
Changes requested
Zanieon Sep 8, 2024
2fe08c9
Remove from else block
Zanieon Sep 8, 2024
4c5bf08
Update menu_ingame.nut
Zanieon Sep 8, 2024
5e93289
Formatting
Zanieon Sep 8, 2024
30e064c
Update buffer timer on click
Zanieon Sep 8, 2024
a96a9ec
Localization
Zanieon Sep 8, 2024
bf19630
Merge branch 'main' into TeamSwitchBtn
Zanieon Sep 9, 2024
2469c96
Merge branch 'R2Northstar:main' into TeamSwitchBtn
Zanieon Sep 10, 2024
a688a68
Merge branch 'main' into TeamSwitchBtn
Alystrasz Sep 10, 2024
3c36655
Merge branch 'main' into TeamSwitchBtn
Alystrasz Sep 11, 2024
b0f52ab
Update _base_gametype_mp.gnut
Zanieon Sep 11, 2024
d75718e
Merge branch 'R2Northstar:main' into TeamSwitchBtn
Zanieon Sep 13, 2024
b52bca8
Update menu_ingame.nut
Zanieon Sep 13, 2024
49d03f3
Merge branch 'R2Northstar:main' into TeamSwitchBtn
Zanieon Oct 3, 2024
28b363b
Merge branch 'main' into TeamSwitchBtn
Zanieon Oct 23, 2024
0873e03
Include Spectators to not be allowed to switch
Zanieon Oct 30, 2024
95a1ea6
Merge branch 'main' into TeamSwitchBtn
Alystrasz Nov 2, 2024
f483654
Merge branch 'main' into TeamSwitchBtn
Zanieon Nov 5, 2024
b301447
Add Gamemode function to disable the option
Zanieon Nov 10, 2024
32cae91
Merge branch 'R2Northstar:main' into TeamSwitchBtn
Zanieon Nov 16, 2024
28f8f3c
Merge branch 'main' into TeamSwitchBtn
Zanieon Nov 18, 2024
51ddd52
Merge branch 'main' into TeamSwitchBtn
Zanieon Nov 19, 2024
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
21 changes: 21 additions & 0 deletions Northstar.Client/mod/scripts/vscripts/ui/menu_ingame.nut
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ 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 )
var teamChangeButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "#SWITCH_TEAMS" )
Hud_AddEventHandler( teamChangeButton, UIE_CLICK, OnRequestTeamSwitch )
thread UpdateTeamSwitchButton( teamChangeButton )
#if DEV
var devButton = AddComboButton( comboStruct, headerIndex, buttonIndex++, "Dev" )
Hud_AddEventHandler( devButton, UIE_CLICK, AdvanceMenuEventHandler( GetMenu( "DevMenu" ) ) )
Expand Down Expand Up @@ -700,3 +703,21 @@ void function SetTitanSelectButtonVisibleState( bool state )
Hud_Hide( file.titanSelectButton )
}
}

void function UpdateTeamSwitchButton( var button )
Zanieon marked this conversation as resolved.
Show resolved Hide resolved
{
while ( true )
{
Hud_SetLocked( button, !GetConVarBool( "ns_allow_team_change" ) )
wait 0.5
}
}

void function OnRequestTeamSwitch( var button )
{
if ( !Hud_IsLocked( 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"
GeckoEidechse marked this conversation as resolved.
Show resolved Hide resolved
}
],
"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,38 @@ void function SetRecalculateRespawnAsTitanStartPointCallback( entity functionref
file.recalculateRespawnAsTitanStartPointCallback = callbackFunc
}

bool function ClientCommandCallbackChangeTeam( entity player, array<string> args )
{
if ( !GetConVarBool( "ns_allow_team_change" ) )
return true

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 )
file.playerChangeTeamTimeBuffer[ player ] = Time() + 5
return true
}
}

if ( !GamePlaying() )
{
SendHudMessage( player, "Team change not allowed outside playing phase", -1, 0.4, 255, 255, 255, 255, 0.15, 3.0, 0.5 )
return true
}
if ( GetCurrentPlaylistVarInt( "max_teams", 0 ) > 1 && !IsFFAGame() )
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