Skip to content

Commit

Permalink
timers: fix showMinigameTeleports check
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam- committed Jun 12, 2022
1 parent b886d45 commit 575469a
Showing 1 changed file with 3 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import com.google.inject.Provides;
import java.time.Duration;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.inject.Inject;
Expand Down Expand Up @@ -146,8 +145,6 @@ public class TimersPlugin extends Plugin
private int lastPoisonVarp;
private int lastPvpVarb;
private int lastCorruptionVarb;
private int lastHomeTeleport;
private int lastMinigameTeleport;
private int lastStaminaEffect;
private int lastImbuedHeartVarb;
private boolean imbuedHeartTimerActive;
Expand Down Expand Up @@ -202,8 +199,6 @@ protected void shutDown() throws Exception
staminaTimer = null;
imbuedHeartTimerActive = false;
lastImbuedHeartVarb = 0;
lastHomeTeleport = 0;
lastMinigameTeleport = 0;
lastStaminaEffect = 0;
}

Expand All @@ -217,8 +212,6 @@ public void onVarbitChanged(VarbitChanged event)
int pvpVarb = client.getVarbitValue(Varbits.PVP_SPEC_ORB);
int corruptionCooldownVarb = client.getVarbitValue(Varbits.CORRUPTION_COOLDOWN);
int imbuedHeartCooldownVarb = client.getVarbitValue(Varbits.IMBUED_HEART_COOLDOWN);
int homeTeleportVarp = client.getVar(VarPlayer.LAST_HOME_TELEPORT);
int minigameTeleportVarp = client.getVar(VarPlayer.LAST_MINIGAME_TELEPORT);
int staminaEffectActive = client.getVarbitValue(Varbits.RUN_SLOWED_DEPLETION_ACTIVE);
int staminaPotionEffectVarb = client.getVarbitValue(Varbits.STAMINA_EFFECT);
int enduranceRingEffectVarb = client.getVarbitValue(Varbits.RING_OF_ENDURANCE_EFFECT);
Expand Down Expand Up @@ -331,16 +324,14 @@ else if (!imbuedHeartTimerActive)
lastImbuedHeartVarb = imbuedHeartCooldownVarb;
}

if (lastHomeTeleport != homeTeleportVarp)
if (event.getIndex() == VarPlayer.LAST_HOME_TELEPORT.getId() && config.showHomeMinigameTeleports())
{
checkTeleport(VarPlayer.LAST_HOME_TELEPORT);
lastHomeTeleport = homeTeleportVarp;
}

if (lastMinigameTeleport != minigameTeleportVarp)
if (event.getIndex() == VarPlayer.LAST_MINIGAME_TELEPORT.getId() && config.showHomeMinigameTeleports())
{
checkTeleport(VarPlayer.LAST_MINIGAME_TELEPORT);
lastMinigameTeleport = minigameTeleportVarp;
}

// staminaEffectActive is checked to match https://github.com/Joshua-F/cs2-scripts/blob/741271f0c3395048c1bad4af7881a13734516adf/scripts/%5Bproc%2Cbuff_bar_get_value%5D.cs2#L25
Expand Down Expand Up @@ -913,7 +904,7 @@ private void checkTeleport(VarPlayer varPlayer)

int lastTeleport = client.getVar(varPlayer);
long lastTeleportSeconds = (long) lastTeleport * 60;
Instant teleportExpireInstant = Instant.ofEpochSecond(lastTeleportSeconds).plus(teleport.getDuration().getSeconds(), ChronoUnit.SECONDS);
Instant teleportExpireInstant = Instant.ofEpochSecond(lastTeleportSeconds).plus(teleport.getDuration());
Duration remainingTime = Duration.between(Instant.now(), teleportExpireInstant);

if (remainingTime.getSeconds() > 0)
Expand Down

0 comments on commit 575469a

Please sign in to comment.