Skip to content

Commit

Permalink
Added Tutorial Hints and fixed Sudden Death
Browse files Browse the repository at this point in the history
  • Loading branch information
Zanieon committed Jul 25, 2024
1 parent 5a1e2ed commit bcbcd6c
Show file tree
Hide file tree
Showing 5 changed files with 190 additions and 12 deletions.
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Name" : "Titan Payload",
"Description" : "Similar payload gamemode from the other TF2",
"Version": "1.0.1",
"Version": "1.0.2",
"LoadPriority": 3,
"RequiredOnClient": true,
"Scripts": [
Expand Down
Binary file modified mod/resource/payload_localisation_english.txt
Binary file not shown.
52 changes: 43 additions & 9 deletions mod/scripts/vscripts/gamemodes/_gamemode_pld.nut
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ struct {
table< entity, PayloadPlayer > matchPlayers
table< entity, array< entity > > checkPoints

array< entity > playerMusicStarted

array< void functionref() > payloadCallbacks

vector nukeTitanSpawnSpot = < 0, 0, 0 >
Expand Down Expand Up @@ -172,7 +174,10 @@ void function StartHarvesterAndPrepareNukeTitan_threaded()

MessageToAll( eEventNotifications.TEMP_TitanGreenRoom )
foreach ( player in GetPlayerArray() )
{
Remote_CallFunction_NonReplay( player, "ServerCallback_PLD_PlayBattleMusic" )
file.playerMusicStarted.append( player )
}

wait 5

Expand Down Expand Up @@ -212,14 +217,19 @@ void function TrackPlayerTimeForPushOrHalt( entity player )

WaitFrame()

if ( GamePlaying() )
Remote_CallFunction_NonReplay( player, "ServerCallback_PLD_PlayBattleMusic" )

bool changedState = false

while( !IsValid( file.theNukeTitan ) ) // Wait for the Nuke Titan to spawn in
WaitFrame()

if( !file.playerMusicStarted.contains( player ) )
{
file.playerMusicStarted.append( player )
Remote_CallFunction_NonReplay( player, "ServerCallback_PLD_PlayBattleMusic" )
}

Remote_CallFunction_NonReplay( player, "ServerCallback_PLD_ShowTutorialHint", ePLDTutorials.Teams )

while( IsValidPlayer( player ) )
{
if ( player.GetTeam() == TEAM_MILITIA )
Expand Down Expand Up @@ -264,6 +274,9 @@ void function GamemodePLD_PlayerDisconnected( entity player )
{
if ( player in file.matchPlayers )
delete file.matchPlayers[player]

if( file.playerMusicStarted.contains( player ) )
file.playerMusicStarted.removebyvalue( player )
}

void function GamemodePLD_OnPlayerKilled( entity victim, entity attacker, var damageInfo )
Expand All @@ -280,6 +293,9 @@ void function GamemodePLD_OnPlayerKilled( entity victim, entity attacker, var da

void function PLD_ShieldedNukeTitan( entity rider, entity titan, entity battery )
{
foreach ( player in GetPlayerArray() )
Remote_CallFunction_NonReplay( player, "ServerCallback_PLD_ShowTutorialHint", ePLDTutorials.NukeTitanBattery )

rider.AddToPlayerGameStat( PGS_DEFENSE_SCORE, PAYLOAD_SCORE_OBJECTIVE_SHIELD_TITAN )
}

Expand Down Expand Up @@ -1036,6 +1052,13 @@ void function OnNukeTitanDamaged( entity npc, var damageInfo )

int function PLD_TimeoutWinner()
{
if ( !IsAlive( file.theNukeTitan ) && IsValid( file.militiaHarvester.harvester ) && file.militiaHarvester.harvester.GetHealth() > 0 )
return TEAM_UNASSIGNED

// Make those score overrides because reason message won't display properly if both teams are still tied by this moment
GameRules_SetTeamScore( TEAM_IMC, 0 )
GameRules_SetTeamScore( TEAM_MILITIA, 1 )

return TEAM_MILITIA
}

Expand Down Expand Up @@ -1117,6 +1140,9 @@ function PayloadUseBatteryFunc( batteryPortvar, playervar )
vector shieldColor = GetShieldTriLerpColor( 1.0 - ( harvester.GetShieldHealth().tofloat() / harvester.GetShieldHealthMax().tofloat() ) )
EffectSetControlPointVector( file.militiaHarvester.particleShield, 1, shieldColor )
}

foreach ( player in GetPlayerArray() )
Remote_CallFunction_NonReplay( player, "ServerCallback_PLD_ShowTutorialHint", ePLDTutorials.HarvesterBattery )
}

void function Payload_RouteHologramRepeater()
Expand All @@ -1126,7 +1152,7 @@ void function Payload_RouteHologramRepeater()
while( true )
{
thread Payload_ShowRouteHologram()
wait 2
wait 3
}
}

Expand Down Expand Up @@ -1158,17 +1184,25 @@ void function Payload_ShowRouteHologram()

void function PLD_PilotStartRodeo( entity pilot, entity titan )
{
Highlight_SetEnemyHighlight( pilot, "sp_objective_entity" )
pilot.Highlight_SetParam( 2, 0, HIGHLIGHT_COLOR_ENEMY )

if( pilot.GetTeam() != titan.GetTeam() && !PlayerHasBattery( pilot ) )
{
Highlight_SetEnemyHighlight( pilot, "sp_objective_entity" )
pilot.Highlight_SetParam( 2, 0, HIGHLIGHT_COLOR_ENEMY )

foreach ( player in GetPlayerArray() )
Remote_CallFunction_NonReplay( player, "ServerCallback_PLD_ShowTutorialHint", ePLDTutorials.NukeTitanRodeo )

pilot.SetInvulnerable()
}
}

void function PLD_PilotEndRodeo( entity pilot, entity titan )
{
Highlight_ClearEnemyHighlight( pilot )

if ( pilot.IsInvulnerable() )
{
if( pilot.GetTeam() != titan.GetTeam() )
Highlight_ClearEnemyHighlight( pilot )

pilot.ClearInvulnerable()
}
}
139 changes: 137 additions & 2 deletions mod/scripts/vscripts/gamemodes/cl_gamemode_pld.nut
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
global function ClGamemodePLD_Init
global function CLPayload_RegisterNetworkFunctions
global function ServerCallback_PLD_PlayBattleMusic
global function ServerCallback_PLD_ShowTutorialHint

struct {
var checkpointARui
Expand All @@ -12,8 +13,11 @@ struct {
var checkpointCHudRui

var harvesterRui
var tutorialTip
} file

table< int, bool > tutorialShown




Expand Down Expand Up @@ -52,6 +56,7 @@ void function ClGamemodePLD_Init()
RegisterLevelMusicForTeam( eMusicPieceID.GAMEMODE_1, "music_s2s_04_maltabattle_alt", TEAM_MILITIA )

ClGameState_RegisterGameStateAsset( $"ui/gamestate_info_cp.rpak" )
CallsignEvents_SetEnabled( true )

AddCreateCallback( "info_hardpoint", OnCheckpointCreated )
AddCreateCallback( "prop_script", OnPropScriptCreated )
Expand All @@ -65,6 +70,8 @@ void function ClGamemodePLD_Init()
file.checkpointBHudRui = CreateCockpitRui( $"ui/cp_hardpoint_hud.rpak", 100 )
file.checkpointCHudRui = CreateCockpitRui( $"ui/cp_hardpoint_hud.rpak", 100 )

file.tutorialTip = CreatePermanentCockpitRui( $"ui/fd_tutorial_tip.rpak", MINIMAP_Z_BASE )

AddCallback_OnClientScriptInit( ClGamemodePLD_OnClientScriptInit )
AddCallback_GameStateEnter( eGameState.WinnerDetermined, ClGamemodePLD_OnWinnerDetermined )
AddCallback_GameStateEnter( eGameState.Postmatch, DisplayPostMatchTop3 )
Expand Down Expand Up @@ -152,11 +159,11 @@ void function OnPropScriptCreated( entity prop )
RuiSetImage( file.harvesterRui, "icon", $"rui/hud/gametype_icons/fd/coop_harvester" )
RuiSetBool( file.harvesterRui, "isVisible", true )
RuiSetBool( file.harvesterRui, "showClampArrow", true )
RuiSetFloat2( file.harvesterRui, "iconSize", <128,128,0> )
RuiSetFloat2( file.harvesterRui, "iconSize", <96,96,0> )
RuiTrackFloat3( file.harvesterRui, "pos", prop, RUI_TRACK_ABSORIGIN_FOLLOW )
}

if ( prop.GetTeam() == TEAM_MILITIA && prop.GetTargetName() == "harvesterBoostPort" )
if ( GetLocalViewPlayer().GetTeam() == TEAM_MILITIA && prop.GetTeam() == TEAM_MILITIA && prop.GetTargetName() == "harvesterBoostPort" )
thread AddOverheadIcon( prop, $"rui/hud/battery/battery_generator", false )
}

Expand Down Expand Up @@ -422,4 +429,132 @@ void function ServerCallback_PLD_PlayBattleMusic()
{
StopMusic()
thread ForceLoopMusic_DEPRECATED( eMusicPieceID.GAMEMODE_1 )
}









/*
████████╗██╗ ██╗████████╗ ██████╗ ██████╗ ██╗ █████╗ ██╗ ███████╗
╚══██╔══╝██║ ██║╚══██╔══╝██╔═══██╗██╔══██╗██║██╔══██╗██║ ██╔════╝
██║ ██║ ██║ ██║ ██║ ██║██████╔╝██║███████║██║ ███████╗
██║ ██║ ██║ ██║ ██║ ██║██╔══██╗██║██╔══██║██║ ╚════██║
██║ ╚██████╔╝ ██║ ╚██████╔╝██║ ██║██║██║ ██║███████╗███████║
╚═╝ ╚═════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝╚═╝ ╚═╝╚══════╝╚══════╝
*/


void function ServerCallback_PLD_ShowTutorialHint( int tutorialID )
{
entity player = GetLocalClientPlayer()

if ( tutorialID in tutorialShown )
{
if ( tutorialShown[tutorialID] )
return
}

asset backgroundImage = $""
asset tipIcon = $""
string tipTitle = ""
string tipDesc = ""

switch ( tutorialID )
{
case ePLDTutorials.Teams:
if ( player.GetTeam() == TEAM_MILITIA )
{
backgroundImage = $"rui/menu/boosts/boost_harvester"
tipTitle = "#PLD_TUTORIAL_DEFENDING_TITLE"
tipDesc = "#PLD_TUTORIAL_DEFENDING_DESC"
}
else
{
backgroundImage = $"rui/menu/boosts/boost_nuke"
tipTitle = "#PLD_TUTORIAL_PUSHING_TITLE"
tipDesc = "#PLD_TUTORIAL_PUSHING_DESC"
}
break

case ePLDTutorials.NukeTitanRodeo:
if ( player.GetTeam() == TEAM_MILITIA )
{
backgroundImage = $"rui/hud/gametype_icons/fd/onboard_core_overload"
tipTitle = "#PLD_TUTORIAL_RODEO_DEFENDING_TITLE"
tipDesc = "#PLD_TUTORIAL_RODEO_DEFENDING_DESC"
}
else
{
backgroundImage = $"rui/hud/gametype_icons/fd/onboard_core_overload"
tipTitle = "#PLD_TUTORIAL_RODEO_PUSHING_TITLE"
tipDesc = "#PLD_TUTORIAL_RODEO_PUSHING_DESC"
}
break

case ePLDTutorials.NukeTitanBattery:
if ( player.GetTeam() == TEAM_MILITIA )
{
backgroundImage = $"rui/hud/gametype_icons/fd/onboard_titan_nuke"
tipTitle = "#PLD_TUTORIAL_TITAN_SHIELD_DEFENDING_TITLE"
tipDesc = "#PLD_TUTORIAL_TITAN_SHIELD_DEFENDING_DESC"
}
else
{
backgroundImage = $"rui/hud/gametype_icons/fd/onboard_titan_nuke"
tipTitle = "#PLD_TUTORIAL_TITAN_SHIELD_PUSHING_TITLE"
tipDesc = "#PLD_TUTORIAL_TITAN_SHIELD_PUSHING_DESC"
}
break

case ePLDTutorials.HarvesterBattery:
if ( player.GetTeam() == TEAM_MILITIA )
{
backgroundImage = $"rui/hud/gametype_icons/fd/onboard_harvester"
tipTitle = "#PLD_TUTORIAL_HARVESTER_SHIELD_DEFENDING_TITLE"
tipDesc = "#PLD_TUTORIAL_HARVESTER_SHIELD_DEFENDING_DESC"
}
else
{
backgroundImage = $"rui/hud/gametype_icons/fd/onboard_harvester"
tipTitle = "#PLD_TUTORIAL_HARVESTER_SHIELD_PUSHING_TITLE"
tipDesc = "#PLD_TUTORIAL_HARVESTER_SHIELD_PUSHING_DESC"
}
break

default:
return
}

if ( !( tutorialID in tutorialShown ) )
tutorialShown[tutorialID] <- true

PLDDisplayTutorialTip( backgroundImage, tipIcon, tipTitle, tipDesc )
}

void function PLDDisplayTutorialTip( asset backgroundImage, asset tipIcon, string tipTitle, string tipDesc )
{
RuiSetImage( file.tutorialTip, "backgroundImage", backgroundImage )
RuiSetImage( file.tutorialTip, "iconImage", tipIcon )
RuiSetString( file.tutorialTip, "titleText", tipTitle )
RuiSetString( file.tutorialTip, "descriptionText", tipDesc )
RuiSetGameTime( file.tutorialTip, "updateTime", Time() )
RuiSetFloat( file.tutorialTip, "duration", 10.0 )
thread PLDTutorialTipSounds()
}

void function PLDTutorialTipSounds()
{
entity player = GetLocalClientPlayer()
player.EndSignal( "OnDestroy" )

EmitSoundOnEntity( player, "UI_InGame_FD_InfoCardSlideIn" )
wait 6.0
EmitSoundOnEntity( player, "UI_InGame_FD_InfoCardSlideOut" )
}
9 changes: 9 additions & 0 deletions mod/scripts/vscripts/gamemodes/sh_gamemode_payload.gnut
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ global function Sh_GamemodePayload_Init

global const string GAMEMODE_PLD = "payload"

global enum ePLDTutorials
{
Teams,
NukeTitanRodeo,
NukeTitanBattery,
HarvesterBattery
}

void function Sh_GamemodePayload_Init()
{
AddPrivateMatchMode( "payload" )
Expand Down Expand Up @@ -70,6 +78,7 @@ void function PLDRegisterNetworkVars()
RegisterNetworkedVariable( "showOverheadIcon", SNDC_TITAN_SOUL, SNVT_BOOL, false )

Remote_RegisterFunction( "ServerCallback_PLD_PlayBattleMusic" )
Remote_RegisterFunction( "ServerCallback_PLD_ShowTutorialHint" )

#if CLIENT
CLPayload_RegisterNetworkFunctions()
Expand Down

0 comments on commit bcbcd6c

Please sign in to comment.