Skip to content

Commit

Permalink
Merge pull request #7 from JMM889901/northstarupdatebranch
Browse files Browse the repository at this point in the history
Merge remote-tracking branch 'upstream/main' into northstarupdatebranch
  • Loading branch information
JMM889901 authored Aug 8, 2024
2 parents 404dfac + 94d51e2 commit 4a70734
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 19 deletions.
18 changes: 17 additions & 1 deletion mod/scripts/vscripts/_items.nut
Original file line number Diff line number Diff line change
Expand Up @@ -6168,6 +6168,12 @@ bool function IsSubItemLocked( entity player, string ref, string parentRef )
{
if ( DevEverythingUnlocked( player ) )
return false

if ( IsItemPurchasableEntitlement( ref, parentRef ) )
return false

if ( GetItemType( ref ) == eItemTypes.PRIME_TITAN || GetSubitemType( parentRef, ref ) == eItemTypes.PRIME_TITAN )
return false

if ( IsItemInEntitlementUnlock( ref, parentRef ) )
{
Expand Down Expand Up @@ -6287,6 +6293,12 @@ bool function IsItemLocked( entity player, string ref )
{
if ( DevEverythingUnlocked( player ) )
return false

if ( IsItemPurchasableEntitlement( ref ) )
return false

if ( GetItemType( ref ) == eItemTypes.PRIME_TITAN )
return false

if ( IsItemInEntitlementUnlock( ref ) )
{
Expand Down Expand Up @@ -10602,7 +10614,7 @@ void function InitUnlockAsEntitlement( string itemRef, string parentRef, int ent
unlock = file.entitlementUnlocks[fullRef]
}

unlock.entitlementIds.append( entitlementId )
unlock.entitlementIds.append( 1 ) // Using `1` here instead of the huge DLC check I did previously. Having the `1` seems to keep all paid cosmetics unlocked with progression enabled.
}

array<int> function GetEntitlementIds( string itemRef, string parentRef = "" )
Expand Down Expand Up @@ -10739,6 +10751,10 @@ void function StatUnlock_Unlocked( entity player, string itemRef, string parentR
if ( IsItemNew( player, itemRef, parentRef ) )
return

// early out if the player has progression disabled
if ( !ProgressionEnabledForPlayer( player ) )
return

int refGuid = file.itemRefToGuid[itemRef]
int parentRefGuid = parentRef == "" ? 0 : file.itemRefToGuid[parentRef]

Expand Down
16 changes: 16 additions & 0 deletions mod/scripts/vscripts/_xp.gnut
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ void function SetupPlayerPreviousXPValues( entity player )
player.SetPersistentVar( "previousFactionXP[" + xpFaction + "]", FactionGetXP( player, xpFaction ) )

foreach ( string xpTitan in shTitanXP.titanClasses )
{
player.SetPersistentVar( "previousTitanXP[" + xpTitan + "]", TitanGetXP( player, xpTitan ) )
player.SetPersistentVar( "fdPreviousTitanXP[" + xpTitan + "]", FD_TitanGetXP( player, xpTitan ) )
}

foreach ( string xpWeapon in shWeaponXP.weaponClassNames )
player.SetPersistentVar( GetItemPersistenceStruct( xpWeapon ) + ".previousWeaponXP", WeaponGetXP( player, xpWeapon ) )
Expand All @@ -35,6 +38,14 @@ void function HandleXPGainForScoreEvent( entity player, ScoreEvent event )
int weaponXp = ScoreEvent_GetXPValueWeapon( event )
int titanXp = ScoreEvent_GetXPValueTitan( event )
int factionXp = ScoreEvent_GetXPValueFaction( event )

if ( player.GetPlayerNetInt( "xpMultiplier" ) > 0 || GetCurrentPlaylistVarInt( "double_xp_enabled", 0 ) == 1 )
{
xpValue *= 2
weaponXp *= 2
titanXp *= 2
factionXp *= 2
}

entity weapon = player.GetActiveWeapon()
if ( IsValid( weapon ) && ShouldTrackXPForWeapon( weapon.GetWeaponClassName() ) && weaponXp != 0 )
Expand Down Expand Up @@ -63,5 +74,10 @@ void function AddXP( entity player, int amount )
int newXp = player.GetPersistentVarAsInt( "xp" )
int newLevel = GetLevelForXP( newXp )
if ( newLevel != oldLevel )
{
Remote_CallFunction_NonReplay( player, "ServerCallback_PlayerLeveledUp", player.GetPersistentVarAsInt( "gen" ), newLevel )

if( ProgressionEnabledForPlayer( player ) )
AwardRandomItemsForPlayerLevels( player, player.GetPersistentVarAsInt( "gen" ), newLevel )
}
}
85 changes: 67 additions & 18 deletions 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,34 @@ 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 a string corresponding to the chassis name of the Titan to reset.
/// Valid chassis are: ion, tone, vanguard, northstar, ronin, legion, and scorch.
///
/// Returns `true` on success and `false` on missing args.
bool function ClientCommand_ResetTitanAegis( entity player, array<string> args )
{
if ( !args.len() )
return false

string titanRef = args[0].tolower()
if( !PersistenceEnumValueIsValid( "titanClasses", titanRef ) )
return false

int suitIndex = PersistenceGetEnumIndexForItemName( "titanClasses", titanRef )

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 Expand Up @@ -197,11 +226,12 @@ void function ValidateEquippedItems( entity player )
}

// titan loadouts
int selectedTitanLoadoutIndex = player.GetPersistentVarAsInt( "titanSpawnLoadout.index" )

for ( int titanLoadoutIndex = 0; titanLoadoutIndex < NUM_PERSISTENT_TITAN_LOADOUTS; titanLoadoutIndex++ )
{
printt( "- VALIDATING TITAN LOADOUT: " + titanLoadoutIndex )

bool isSelected = titanLoadoutIndex == player.GetPersistentVarAsInt( "titanSpawnLoadout.index" )
bool isSelected = titanLoadoutIndex == selectedTitanLoadoutIndex
TitanLoadoutDef loadout = GetTitanLoadout( player, titanLoadoutIndex )
TitanLoadoutDef defaultLoadout = shGlobal.defaultTitanLoadouts[titanLoadoutIndex]

Expand Down Expand Up @@ -270,7 +300,7 @@ void function ValidateEquippedItems( entity player )
// camoIndex
if ( loadout.skinIndex == TITAN_SKIN_INDEX_CAMO )
{
array<ItemData> camoSkins = GetAllItemsOfType( eItemTypes.CAMO_SKIN )
array<ItemData> camoSkins = GetAllItemsOfType( eItemTypes.CAMO_SKIN_TITAN )
if ( loadout.camoIndex >= camoSkins.len() || loadout.camoIndex < 0 )
{
printt( " - INVALID TITAN CAMO/SKIN, RESETTING" )
Expand Down Expand Up @@ -365,7 +395,7 @@ void function ValidateEquippedItems( entity player )
// primeCamoIndex
if ( loadout.primeSkinIndex == TITAN_SKIN_INDEX_CAMO )
{
array<ItemData> camoSkins = GetAllItemsOfType( eItemTypes.CAMO_SKIN )
array<ItemData> camoSkins = GetAllItemsOfType( eItemTypes.CAMO_SKIN_TITAN )
if ( loadout.primeCamoIndex >= camoSkins.len() || loadout.primeCamoIndex < 0 )
{
printt( " - INVALID TITAN CAMO/SKIN, RESETTING" )
Expand Down Expand Up @@ -419,11 +449,18 @@ void function ValidateEquippedItems( entity player )
{
printt( " - SELECTED TITAN CLASS IS LOCKED, RESETTING" )
player.SetPersistentVar( "titanSpawnLoadout.index", 0 )
Remote_CallFunction_NonReplay( player, "ServerCallback_UpdateTitanModel", 0 )
selectedTitanLoadoutIndex = 0
}
}

Remote_CallFunction_NonReplay( player, "ServerCallback_UpdateTitanModel", player.GetPersistentVarAsInt( "titanSpawnLoadout.index" ) )
if ( selectedTitanLoadoutIndex < 0 || selectedTitanLoadoutIndex >= NUM_PERSISTENT_TITAN_LOADOUTS )
{
printt( "- SELECTED TITAN CLASS IS INVALID, RESETTING" )
player.SetPersistentVar( "titanSpawnLoadout.index", 0 )
selectedTitanLoadoutIndex = 0
}

Remote_CallFunction_NonReplay( player, "ServerCallback_UpdateTitanModel", selectedTitanLoadoutIndex )

// pilot loadouts
for ( int pilotLoadoutIndex = 0; pilotLoadoutIndex < NUM_PERSISTENT_PILOT_LOADOUTS; pilotLoadoutIndex++ )
Expand Down Expand Up @@ -646,11 +683,15 @@ void function ValidateEquippedItems( entity player )
player.SetPersistentVar( "pilotLoadouts[" + pilotLoadoutIndex + "].primaryCamoIndex", defaultLoadout.primaryCamoIndex )
}
}
else if ( IsSubItemLocked( player, GetWeaponWarpaintRefByIndex( loadout.primarySkinIndex, loadout.primary ), loadout.primary ) )
else
{
printt( " - PRIMARY WEAPON SKIN LOCKED, RESETTING" )
player.SetPersistentVar( "pilotLoadouts[" + pilotLoadoutIndex + "].primarySkinIndex", defaultLoadout.primarySkinIndex )
player.SetPersistentVar( "pilotLoadouts[" + pilotLoadoutIndex + "].primaryCamoIndex", defaultLoadout.primaryCamoIndex )
string warpaintRef = GetWeaponWarpaintRefByIndex( loadout.primarySkinIndex, loadout.primary )
if ( warpaintRef == INVALID_REF || IsSubItemLocked( player, warpaintRef, loadout.primary ) )
{
printt( " - PRIMARY WEAPON SKIN LOCKED/INVALID, RESETTING" )
player.SetPersistentVar( "pilotLoadouts[" + pilotLoadoutIndex + "].primarySkinIndex", defaultLoadout.primarySkinIndex )
player.SetPersistentVar( "pilotLoadouts[" + pilotLoadoutIndex + "].primaryCamoIndex", defaultLoadout.primaryCamoIndex )
}
}
}

Expand Down Expand Up @@ -779,11 +820,15 @@ void function ValidateEquippedItems( entity player )
player.SetPersistentVar( "pilotLoadouts[" + pilotLoadoutIndex + "].secondaryCamoIndex", defaultLoadout.secondaryCamoIndex )
}
}
else if ( IsSubItemLocked( player, GetWeaponWarpaintRefByIndex( loadout.secondarySkinIndex, loadout.secondary ), loadout.secondary ) )
else
{
printt( " - SECONDARY WEAPON SKIN LOCKED, RESETTING" )
player.SetPersistentVar( "pilotLoadouts[" + pilotLoadoutIndex + "].secondarySkinIndex", defaultLoadout.secondarySkinIndex )
player.SetPersistentVar( "pilotLoadouts[" + pilotLoadoutIndex + "].secondaryCamoIndex", defaultLoadout.secondaryCamoIndex )
string warpaintRef = GetWeaponWarpaintRefByIndex( loadout.secondarySkinIndex, loadout.secondary )
if ( warpaintRef == INVALID_REF || IsSubItemLocked( player, warpaintRef, loadout.secondary ) )
{
printt( " - SECONDARY WEAPON SKIN LOCKED/INVALID, RESETTING" )
player.SetPersistentVar( "pilotLoadouts[" + pilotLoadoutIndex + "].secondarySkinIndex", defaultLoadout.secondarySkinIndex )
player.SetPersistentVar( "pilotLoadouts[" + pilotLoadoutIndex + "].secondaryCamoIndex", defaultLoadout.secondaryCamoIndex )
}
}
}

Expand Down Expand Up @@ -912,11 +957,15 @@ void function ValidateEquippedItems( entity player )
player.SetPersistentVar( "pilotLoadouts[" + pilotLoadoutIndex + "].weapon3CamoIndex", defaultLoadout.weapon3CamoIndex )
}
}
else if ( IsSubItemLocked( player, GetWeaponWarpaintRefByIndex( loadout.weapon3SkinIndex, loadout.weapon3 ), loadout.weapon3 ) )
else
{
printt( " - TERTIARY WEAPON SKIN LOCKED, RESETTING" )
player.SetPersistentVar( "pilotLoadouts[" + pilotLoadoutIndex + "].weapon3SkinIndex", defaultLoadout.weapon3SkinIndex )
player.SetPersistentVar( "pilotLoadouts[" + pilotLoadoutIndex + "].weapon3CamoIndex", defaultLoadout.weapon3CamoIndex )
string warpaintRef = GetWeaponWarpaintRefByIndex( loadout.weapon3SkinIndex, loadout.weapon3 )
if ( warpaintRef == INVALID_REF || IsSubItemLocked( player, warpaintRef, loadout.weapon3 ) )
{
printt( " - TERTIARY WEAPON SKIN LOCKED/INVALID, RESETTING" )
player.SetPersistentVar( "pilotLoadouts[" + pilotLoadoutIndex + "].weapon3SkinIndex", defaultLoadout.weapon3SkinIndex )
player.SetPersistentVar( "pilotLoadouts[" + pilotLoadoutIndex + "].weapon3CamoIndex", defaultLoadout.weapon3CamoIndex )
}
}
}

Expand Down
23 changes: 23 additions & 0 deletions mod/scripts/vscripts/titan_xp.gnut
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
global function AddTitanXP
global function AddFDTitanXP

void function AddTitanXP( entity player, int amount )
{
Expand All @@ -10,13 +11,35 @@ void function AddTitanXP( entity player, int amount )
ServerToClientStringCommand(player, "AddModdedTitanXP " + titan + " " + amount)
return
}
int TitanXPMatch = player.GetPersistentVarAsInt( "xp_match[" + XP_TYPE.TITAN_LEVELED + "]" )

// increment xp
player.SetPersistentVar( "titanXP[" + titan + "]", min( TitanGetXP( player, titan ) + amount, TitanGetMaxXP( titan ) ) )
Remote_CallFunction_NonReplay( player, "ServerCallback_TitanXPAdded", shTitanXP.titanClasses.find( titan ), TitanGetXP( player, titan ), amount )

// level up notif
if ( TitanGetLevel( player, titan ) != oldLevel )
{
Remote_CallFunction_NonReplay( player, "ServerCallback_TitanLeveledUp", shTitanXP.titanClasses.find( titan ), TitanGetGen( player, titan ), TitanGetLevel( player, titan ) )
AddPlayerScore( player, "TitanLevelUp" )
IncrementPlayerChallengeTitanLeveledUp( player )
player.SetPersistentVar( "xp_match[" + XP_TYPE.TITAN_LEVELED + "]", TitanXPMatch + 1 )

if( ProgressionEnabledForPlayer( player ) )
AwardRandomItemsForTitanLevels( player, titan, oldLevel, TitanGetLevel( player, titan ) )
}
}

void function AddFDTitanXP( entity player, int fdXPamount )
{
string titanRef = GetActiveTitanLoadout( player ).titanClass

player.SetPersistentVar( "fdTitanXP[" + titanRef + "]", FD_TitanGetPreviousXP( player, titanRef ) + fdXPamount )
int startingLevel = FD_TitanGetLevelForXP( titanRef, FD_TitanGetPreviousXP( player, titanRef ) )
int endingLevel = FD_TitanGetLevelForXP( titanRef, FD_TitanGetXP( player, titanRef ) )

Player_GiveFDUnlockPoints( player, endingLevel - startingLevel )

if( ProgressionEnabledForPlayer( player ) )
AwardRandomItemsForFDTitanLevels( player, titanRef, startingLevel, endingLevel )
}

0 comments on commit 4a70734

Please sign in to comment.