aboutsummaryrefslogtreecommitdiff
path: root/Northstar.CustomServers/mod/scripts/vscripts/earn_meter
diff options
context:
space:
mode:
Diffstat (limited to 'Northstar.CustomServers/mod/scripts/vscripts/earn_meter')
-rw-r--r--Northstar.CustomServers/mod/scripts/vscripts/earn_meter/sv_earn_meter_mp.gnut60
1 files changed, 44 insertions, 16 deletions
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 4417168a..935dc4d0 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
@@ -71,14 +71,41 @@ void function OnPlayerRespawned( entity player )
EarnMeterMP_BoostEarned( player )
}
+void function EarnMeterMP_ReplaceReward( entity player, EarnObject reward, float rewardFrac )
+{
+ PlayerEarnMeter_Reset( player )
+ if ( reward.id < 0 )
+ return
+ PlayerEarnMeter_SetReward( player, reward )
+ PlayerEarnMeter_SetRewardFrac( player, rewardFrac )
+
+ if( PlayerEarnMeter_GetRewardFrac( player ) != 0 )
+ PlayerEarnMeter_EnableReward( player )
+}
+
void function EarnMeterMP_PlayerLifeThink( entity player )
{
player.EndSignal( "OnDeath" )
player.EndSignal( "OnDestroy" )
+ EarnObject pilotReward = PlayerEarnMeter_GetReward( player )
+ float pilotRewardFrac = PlayerEarnMeter_GetRewardFrac( player )
int lastEarnMeterMode = PlayerEarnMeter_GetMode( player )
float lastPassiveGainTime = Time()
+ OnThreadEnd(
+ function() : ( player, pilotReward, pilotRewardFrac )
+ {
+ if ( !IsValid( player ) )
+ return
+
+ // Resets the meter to the pilot version if the player dies in a titan or while their titan is alive (otherwise they can be stuck with e-smoke)
+ int earnMode = PlayerEarnMeter_GetMode( player )
+ if( earnMode != eEarnMeterMode.DEFAULT )
+ EarnMeterMP_ReplaceReward( player, pilotReward, pilotRewardFrac )
+ }
+ )
+
while ( true )
{
int desiredEarnMeterMode
@@ -99,25 +126,22 @@ void function EarnMeterMP_PlayerLifeThink( entity player )
if ( desiredEarnMeterMode != lastEarnMeterMode )
{
PlayerEarnMeter_SetMode( player, desiredEarnMeterMode )
-
- if ( desiredEarnMeterMode == eEarnMeterMode.DEFAULT )
+ if ( lastEarnMeterMode == eEarnMeterMode.DEFAULT ) // Set these here in case the player changed boost during the match (e.g. in dropship)
{
- 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 )
- PlayerEarnMeter_SetRewardFrac( player, oldRewardFrac )
- PlayerEarnMeter_EnableReward( player )
- }
-
- if ( PlayerEarnMeter_GetRewardFrac( player ) != 0 )
- PlayerEarnMeter_EnableReward( player )
+ pilotReward = PlayerEarnMeter_GetReward( player )
+ pilotRewardFrac = PlayerEarnMeter_GetRewardFrac( player )
}
- else
+
+ if ( desiredEarnMeterMode == eEarnMeterMode.DEFAULT ) // Only occurs when auto titan dies. Resets reward progress and reverts it back to boost.
+ EarnMeterMP_ReplaceReward( player, pilotReward, pilotRewardFrac )
+ else if ( desiredEarnMeterMode == eEarnMeterMode.CORE ) // Replace the pilot's earn meter reward with smoke when they enter their titan.
{
- PlayerEarnMeter_DisableGoal( player )
- PlayerEarnMeter_DisableReward( player )
+ EarnMeterMP_ReplaceReward( player, EarnObject_GetByRef( "core_electric_smoke" ), CORE_SMOKE_FRAC )
+ if( SoulTitanCore_GetNextAvailableTime( player.GetTitanSoul() ) >= CORE_SMOKE_FRAC )
+ PlayerEarnMeter_SetRewardUsed( player )
}
+ else if ( desiredEarnMeterMode == eEarnMeterMode.CORE_ACTIVE ) // Enables smoke after core use (doesn't show up during active, so looks fine)
+ PlayerEarnMeter_EnableReward( player )
lastEarnMeterMode = desiredEarnMeterMode
}
@@ -148,6 +172,10 @@ void function EarnMeterMP_PlayerLifeThink( entity player )
void function EarnMeterMP_BoostEarned( entity player )
{
+ // Can't have smoke earned via meter. Otherwise, Auto Titan could hit reward frac and get nothing
+ if( player.IsTitan() )
+ return
+
EarnObject earnobject = PlayerEarnMeter_GetReward( player )
BurnReward burncard = BurnReward_GetByRef( earnobject.ref )
@@ -198,4 +226,4 @@ void function EarnMeterMP_SetBoostByRef( entity player, string boostRef )
}
else
PlayerEarnMeter_SetGoal( player, earnobject )
-} \ No newline at end of file
+}