Skip to content

Commit

Permalink
Add Aegis Rank reset functionality command for Progression (#727)
Browse files Browse the repository at this point in the history
Adds a console command to allow players to reset the Aegis Ranks of their Titans
  • Loading branch information
Zanieon authored Dec 14, 2023
1 parent f4df314 commit 6d678ac
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Northstar.CustomServers/mod/scripts/vscripts/sh_progression.nut
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ void function Progression_Init()
#if SERVER
AddCallback_OnClientDisconnected( OnClientDisconnected )
AddClientCommandCallback( "ns_progression", ClientCommand_SetProgression )
AddClientCommandCallback( "ns_resettitanaegis", ClientCommand_ResetTitanAegis )
AddCallback_GameStateEnter( eGameState.Playing, OnPlaying )
#elseif CLIENT
AddCallback_OnClientScriptInit( OnClientScriptInit )
Expand Down Expand Up @@ -84,6 +85,28 @@ bool function ClientCommand_SetProgression( entity player, array<string> args )

return true
}

/// Resets a specific Titan's Aegis rank back to `0`
/// * `player` - The player entity to perform the action on
/// * `args` - The arguments passed from the client command. `args[0]` should be an integer corresponding to the index of the Titan to reset.
///
/// Returns `true` on success and `false` on missing args.
bool function ClientCommand_ResetTitanAegis( entity player, array<string> args )
{
if ( !args.len() )
return false

int suitIndex = args[0].tointeger()
player.SetPersistentVar( "titanFDUnlockPoints[" + suitIndex + "]", 0 )
player.SetPersistentVar( "previousFDUnlockPoints[" + suitIndex + "]", 0 )
player.SetPersistentVar( "fdTitanXP[" + suitIndex + "]", 0 )
player.SetPersistentVar( "fdPreviousTitanXP[" + suitIndex + "]", 0 )

// Refresh Highest Aegis Titan since we might get all of them back to 1 if players wants
RecalculateHighestTitanFDLevel( player )

return true
}
#endif

#if CLIENT
Expand Down
16 changes: 16 additions & 0 deletions Northstar.CustomServers/mod/scripts/vscripts/sh_utility_all.gnut
Original file line number Diff line number Diff line change
Expand Up @@ -1540,6 +1540,22 @@ array<string> function GetAvailableTitanRefs( entity player )
return availableTitanRefs
}

/// Gets the highest Titan FD level and stores it in the corresponding persistent var.
/// * `player` - The player entity to perform the action on
void function RecalculateHighestTitanFDLevel( entity player )
{
int enumCount = PersistenceGetEnumCount( "titanClasses" )
int highestAegis = 0
for ( int i = 0; i < enumCount; i++ )
{
string enumName = PersistenceGetEnumItemNameForIndex( "titanClasses", i )
int aegisLevel = FD_TitanGetLevelForXP( enumName, FD_TitanGetXP( player, enumName ) )
if ( highestAegis < aegisLevel )
highestAegis = aegisLevel
}
player.SetPersistentVar( "fdStats.highestTitanFDLevel", highestAegis )
}

#if MP
string function GetTitanRefForLoadoutIndex( entity player, int loadoutIndex )
{
Expand Down

0 comments on commit 6d678ac

Please sign in to comment.