aboutsummaryrefslogtreecommitdiff
path: root/Northstar.CustomServers/mod/scripts/vscripts/earn_meter
diff options
context:
space:
mode:
authorConnie Price <contact@connieprice.co.uk>2022-01-04 19:13:56 +0000
committerConnie Price <contact@connieprice.co.uk>2022-01-04 19:13:56 +0000
commita352fbb877aabdaf9b124eee47fb78f2ac0007a6 (patch)
treea97dc0ed1c8673715e1fce1420560589aa312973 /Northstar.CustomServers/mod/scripts/vscripts/earn_meter
parente128e87bd23d5c7702e92c01e07684e3804f5a69 (diff)
downloadNorthstarMods-a352fbb877aabdaf9b124eee47fb78f2ac0007a6.tar.gz
NorthstarMods-a352fbb877aabdaf9b124eee47fb78f2ac0007a6.zip
Big Boost/Earn Meter Fixes!
* Only set the boost from persistence once, allowing for the boost to be changed mid game by other scripts. * Added `PlayerEarnMeter_SetBoostByRef(string boostRef)` to simplify setting boosts. * Boosts now correctly disappear after being reward to the player. * Client-side reward icon will now update when the boost is changed. * Titan cores will now pull the HUD icon from the core, instead of the titan chassis. Allowing this to be handled better by other scripts. * Player boost inventory implemented! Now players will be able to store multiple boosts like vanilla. * Boost inventory limits, all vanilla boost limits are respected, and `BurnMeter_SetBoostLimit( string burnRef, int limit )` was added to accommodate this. * Fixed the unused nuke titan boost code so that if anyone decides to use it it's not horribly error prone.
Diffstat (limited to 'Northstar.CustomServers/mod/scripts/vscripts/earn_meter')
-rw-r--r--Northstar.CustomServers/mod/scripts/vscripts/earn_meter/sv_earn_meter.gnut22
-rw-r--r--Northstar.CustomServers/mod/scripts/vscripts/earn_meter/sv_earn_meter_mp.gnut64
2 files changed, 48 insertions, 38 deletions
diff --git a/Northstar.CustomServers/mod/scripts/vscripts/earn_meter/sv_earn_meter.gnut b/Northstar.CustomServers/mod/scripts/vscripts/earn_meter/sv_earn_meter.gnut
index dda84976..691f07fb 100644
--- a/Northstar.CustomServers/mod/scripts/vscripts/earn_meter/sv_earn_meter.gnut
+++ b/Northstar.CustomServers/mod/scripts/vscripts/earn_meter/sv_earn_meter.gnut
@@ -39,6 +39,8 @@ global function SharedEarnMeter_AddEarnedAndOwned
global function PlayerEarnMeter_SetEnabled
global function PlayerEarnMeter_Enabled
+global function PlayerEarnMeter_SetBoostByRef
+
global struct EarnMeterThresholdEarnedStruct
{
float threshold
@@ -505,4 +507,24 @@ void function PlayerEarnMeter_SetEnabled( bool enabled )
bool function PlayerEarnMeter_Enabled()
{
return file.earnMeterEnabled
+}
+
+void function PlayerEarnMeter_SetBoostByRef( entity player, string boostRef ) {
+ EarnObject earnobject = EarnObject_GetByRef( boostRef )
+ BurnReward burncard = BurnReward_GetByRef( boostRef )
+
+ if ( Riff_BoostAvailability() != eBoostAvailability.Disabled )
+ {
+ PlayerEarnMeter_SetReward( player, earnobject ) // pretty sure this works?
+ PlayerEarnMeter_SetRewardFrac( player, burncard.cost )
+ PlayerEarnMeter_EnableReward( player )
+ }
+
+ if ( EarnMeterMP_IsTitanEarnGametype() )
+ {
+ PlayerEarnMeter_SetGoal( player, EarnObject_GetByRef( GetTitanLoadoutForPlayer( player ).titanClass ) )
+ PlayerEarnMeter_EnableGoal( player ) // prevents goalstate from being set incorrectly
+ }
+ else
+ PlayerEarnMeter_SetGoal( player, earnobject )
} \ No newline at end of file
diff --git a/Northstar.CustomServers/mod/scripts/vscripts/earn_meter/sv_earn_meter_mp.gnut b/Northstar.CustomServers/mod/scripts/vscripts/earn_meter/sv_earn_meter_mp.gnut
index 4c42a825..193262f1 100644
--- a/Northstar.CustomServers/mod/scripts/vscripts/earn_meter/sv_earn_meter_mp.gnut
+++ b/Northstar.CustomServers/mod/scripts/vscripts/earn_meter/sv_earn_meter_mp.gnut
@@ -23,7 +23,7 @@ void function EarnMeterMP_SetTitanLoadout( entity player )
if ( EarnMeterMP_IsTitanEarnGametype() )
PlayerEarnMeter_SetGoal( player, EarnObject_GetByRef( GetTitanLoadoutForPlayer( player ).titanClass ) )
else
- PlayerEarnMeter_SetGoal( player, EarnObject_GetByRef( GetSelectedBurncardRefFromWeaponOrPlayer( null, player ) ) )
+ PlayerEarnMeter_SetGoal( player, PlayerEarnMeter_GetReward( player ) )
}
void function EarnMeterMP_SetPassiveMeterGainEnabled( bool enabled )
@@ -34,23 +34,10 @@ void function EarnMeterMP_SetPassiveMeterGainEnabled( bool enabled )
void function SetupPlayerEarnMeter( entity player )
{
PlayerEarnMeter_Reset( player )
-
- if ( Riff_BoostAvailability() != eBoostAvailability.Disabled )
- {
- string burncardRef = GetSelectedBurncardRefFromWeaponOrPlayer( null, player )
- PlayerEarnMeter_SetReward( player, EarnObject_GetByRef( burncardRef ) ) // pretty sure this works?
- PlayerEarnMeter_SetRewardFrac( player, BurnReward_GetByRef( burncardRef ).cost )
- PlayerEarnMeter_EnableReward( player )
- }
-
- if ( EarnMeterMP_IsTitanEarnGametype() )
- {
- PlayerEarnMeter_SetGoal( player, EarnObject_GetByRef( GetTitanLoadoutForPlayer( player ).titanClass ) )
- PlayerEarnMeter_EnableGoal( player ) // prevents goalstate from being set incorrectly
- }
- else
- PlayerEarnMeter_SetGoal( player, EarnObject_GetByRef( GetSelectedBurncardRefFromWeaponOrPlayer( null, player ) ) )
-
+
+ string burncardRef = GetSelectedBurnCardRef( player )
+ PlayerEarnMeter_SetBoostByRef( player, burncardRef )
+
// catchup bonus for late joiners
// todo: maths on this is fine but for some reason it won't set correctly, could be getting reset somewhere?
PlayerEarnMeter_AddOwnedFrac( player, ( ( Time() - file.playingStartTime ) / 4.0 ) * 0.01 )
@@ -61,24 +48,24 @@ void function OnPlaying()
file.playingStartTime = Time()
foreach ( entity player in GetPlayerArray() )
SetupPlayerEarnMeter( player )
-
+
if ( Riff_BoostAvailability() != eBoostAvailability.Disabled )
SetCallback_EarnMeterRewardEarned( EarnMeterMP_BoostEarned )
-
+
// do this in playing so that gamemodes/maps can disable and this'll take affect
if ( EarnMeterMP_IsTitanEarnGametype() ) // settitanavailable when earnmeter full
{
Riff_ForceTitanAvailability( eTitanAvailability.Custom ) // doesn't seem to affect anything aside from preventing some annoying client stuff
svGlobal.titanAvailabilityCheck = IsTitanAvailable
}
-
+
SetCallback_EarnMeterGoalEarned( EarnMeterMP_TitanEarned )
}
void function OnPlayerRespawned( entity player )
{
thread EarnMeterMP_PlayerLifeThink( player )
-
+
if ( PlayerEarnMeter_IsRewardAvailable( player ) )
EarnMeterMP_BoostEarned( player )
}
@@ -116,14 +103,12 @@ void function EarnMeterMP_PlayerLifeThink( entity player )
{
if ( !IsTitanAvailable( player ) && PlayerEarnMeter_GetOwnedFrac( player ) == 1.0 ) // this should only be the case after player has dropped their titan
{
+ float oldRewardFrac = PlayerEarnMeter_GetRewardFrac( player )
PlayerEarnMeter_Reset( player )
- // reset rewards
- string burncardRef = GetSelectedBurncardRefFromWeaponOrPlayer( null, player )
- PlayerEarnMeter_SetReward( player, EarnObject_GetByRef( burncardRef ) )
- PlayerEarnMeter_SetRewardFrac( player, BurnReward_GetByRef( burncardRef ).cost )
+ PlayerEarnMeter_SetRewardFrac( player, oldRewardFrac )
PlayerEarnMeter_EnableReward( player )
}
-
+
if ( PlayerEarnMeter_GetRewardFrac( player ) != 0 )
PlayerEarnMeter_EnableReward( player )
}
@@ -135,7 +120,7 @@ void function EarnMeterMP_PlayerLifeThink( entity player )
lastEarnMeterMode = desiredEarnMeterMode
}
-
+
if ( lastEarnMeterMode == eEarnMeterMode.DEFAULT )
{
if ( PlayerEarnMeter_GetOwnedFrac( player ) < 1.0 )
@@ -148,26 +133,31 @@ void function EarnMeterMP_PlayerLifeThink( entity player )
player.SetPlayerNetInt( "goalState", eRewardState.AVAILABLE )
PlayerEarnMeter_RefreshGoal( player )
}
-
+
if ( Time() - lastPassiveGainTime > 4.0 && file.passiveMeterGainEnabled ) // this might be 5.0
{
lastPassiveGainTime = Time()
PlayerEarnMeter_AddOwnedFrac( player, 0.01 )
}
}
-
+
WaitFrame()
}
}
void function EarnMeterMP_BoostEarned( entity player )
{
- BurnReward burncard = BurnReward_GetByRef( GetSelectedBurnCardRef( player ) )
-
+ EarnObject earnobject = PlayerEarnMeter_GetReward( player )
+ BurnReward burncard = BurnReward_GetByRef( earnobject.ref )
+
while ( burncard.ref == "burnmeter_random_foil" )
burncard = BurnReward_GetRandom()
- BurnMeter_GiveRewardDirect( player, burncard.ref )
+ if ( !BurnMeter_CheckBoostLimit( player ) ) {
+ BurnMeter_GiveRewardDirect( player, burncard.ref )
+ }
+
+ PlayerEarnMeter_DisableReward( player )
}
void function EarnMeterMP_TitanEarned( entity player )
@@ -179,13 +169,11 @@ void function EarnMeterMP_TitanEarned( entity player )
}
else
{
+ float oldRewardFrac = PlayerEarnMeter_GetRewardFrac( player )
PlayerEarnMeter_Reset( player )
- // reset rewards
- string burncardRef = GetSelectedBurncardRefFromWeaponOrPlayer( null, player )
- PlayerEarnMeter_SetReward( player, EarnObject_GetByRef( burncardRef ) )
- PlayerEarnMeter_SetRewardFrac( player, BurnReward_GetByRef( burncardRef ).cost )
+ PlayerEarnMeter_SetRewardFrac( player, oldRewardFrac )
PlayerEarnMeter_EnableReward( player )
-
+
if ( PlayerEarnMeter_GetRewardFrac( player ) != 0 )
PlayerEarnMeter_EnableReward( player )
}