timers: consolidate teleblock timers

This commit is contained in:
Adam
2020-09-09 10:37:32 -04:00
parent d2c72d6cbe
commit 01447e52a7
3 changed files with 59 additions and 72 deletions

View File

@@ -46,12 +46,6 @@ enum GameTimer
OVERLOAD(ItemID.OVERLOAD_4, GameTimerImageType.ITEM, "Overload", 5, ChronoUnit.MINUTES, true),
CANNON(ItemID.CANNON_BARRELS, GameTimerImageType.ITEM, "Cannon", 25, ChronoUnit.MINUTES),
MAGICIMBUE(SpriteID.SPELL_MAGIC_IMBUE, GameTimerImageType.SPRITE, "Magic imbue", 21, GAME_TICKS),
FULLTB(SpriteID.SPELL_TELE_BLOCK, GameTimerImageType.SPRITE, "Full Teleblock", 5, ChronoUnit.MINUTES, true),
HALFTB(SpriteID.SPELL_TELE_BLOCK, GameTimerImageType.SPRITE, "Half Teleblock", 150, ChronoUnit.SECONDS, true),
DMM_FULLTB(SpriteID.SPELL_TELE_BLOCK, GameTimerImageType.SPRITE, "Deadman Mode Full Teleblock", 150, ChronoUnit.SECONDS, true),
DMM_HALFTB(SpriteID.SPELL_TELE_BLOCK, GameTimerImageType.SPRITE, "Deadman Mode Half Teleblock", 75, ChronoUnit.SECONDS, true),
MAGE_ARENA_FULLTB(SpriteID.SPELL_TELE_BLOCK, GameTimerImageType.SPRITE, "Mage Arena 2 Full Teleblock", 2, ChronoUnit.MINUTES, true),
MAGE_ARENA_HALFTB(SpriteID.SPELL_TELE_BLOCK, GameTimerImageType.SPRITE, "Mage Arena 2 Half Teleblock", 1, ChronoUnit.MINUTES, true),
SUPERANTIFIRE(ItemID.SUPER_ANTIFIRE_POTION4, GameTimerImageType.ITEM, "Super antifire", 3, ChronoUnit.MINUTES),
BIND(SpriteID.SPELL_BIND, GameTimerImageType.SPRITE, "Bind", GraphicID.BIND, 8, GAME_TICKS, true),
SNARE(SpriteID.SPELL_SNARE, GameTimerImageType.SPRITE, "Snare", GraphicID.SNARE, 16, GAME_TICKS, true),
@@ -81,7 +75,8 @@ enum GameTimer
DIVINE_BASTION(ItemID.DIVINE_BASTION_POTION4, GameTimerImageType.ITEM, "Divine Bastion", 5, ChronoUnit.MINUTES),
DIVINE_BATTLEMAGE(ItemID.DIVINE_BATTLEMAGE_POTION4, GameTimerImageType.ITEM, "Divine Battlemage", 5, ChronoUnit.MINUTES),
ANTIPOISON(ItemID.ANTIPOISON4, GameTimerImageType.ITEM, "Antipoison", false),
ANTIVENOM(ItemID.ANTIVENOM4, GameTimerImageType.ITEM, "Anti-venom", false);
ANTIVENOM(ItemID.ANTIVENOM4, GameTimerImageType.ITEM, "Anti-venom", false),
TELEBLOCK(SpriteID.SPELL_TELE_BLOCK, GameTimerImageType.SPRITE, "Teleblock", true);
@Nullable
private final Duration duration;

View File

@@ -114,11 +114,7 @@ public class TimersPlugin extends Plugin
private static final String PRAYER_ENHANCE_EXPIRED = "<col=ff0000>Your prayer enhance effect has worn off.</col>";
private static final String ENDURANCE_EFFECT_MESSAGE = "Your Ring of endurance doubles the duration of your stamina potion's effect.";
private static final Pattern DEADMAN_HALF_TELEBLOCK_PATTERN = Pattern.compile("A Tele Block spell has been cast on you by (.+)\\. It will expire in 1 minute, 15 seconds\\.</col>");
private static final Pattern FULL_TELEBLOCK_PATTERN = Pattern.compile("A Tele Block spell has been cast on you by (.+)\\. It will expire in 5 minutes\\.</col>");
private static final Pattern HALF_TELEBLOCK_PATTERN = Pattern.compile("A Tele Block spell has been cast on you by (.+)\\. It will expire in 2 minutes, 30 seconds\\.</col>");
private static final Pattern MAGE_ARENA_FULL_TELEBLOCK_PATTERN = Pattern.compile("A Tele Block spell has been cast on you\\. It will expire in 2 minutes\\.</col>");
private static final Pattern MAGE_ARENA_HALF_TELEBLOCK_PATTERN = Pattern.compile("A Tele Block spell has been cast on you\\. It will expire in 1 minute\\.</col>");
private static final Pattern TELEBLOCK_PATTERN = Pattern.compile("A Tele Block spell has been cast on you(?: by .+)?\\. It will expire in (?<mins>\\d+) minutes?(?:, (?<secs>\\d+) seconds?)?\\.");
private static final Pattern DIVINE_POTION_PATTERN = Pattern.compile("You drink some of your divine (.+) potion\\.");
private static final int VENOM_VALUE_CUTOFF = -40; // Antivenom < -40 <= Antipoison < 0
private static final int POISON_TICK_LENGTH = 30;
@@ -239,7 +235,7 @@ public class TimersPlugin extends Plugin
&& inWilderness == 0)
{
log.debug("Left wilderness in non-PVP world, clearing Teleblock timer.");
removeTbTimers();
removeGameTimer(TELEBLOCK);
}
lastWildernessVarb = inWilderness;
@@ -366,7 +362,7 @@ public class TimersPlugin extends Plugin
if (!config.showTeleblock())
{
removeTbTimers();
removeGameTimer(TELEBLOCK);
}
if (!config.showFreezes())
@@ -542,36 +538,18 @@ public class TimersPlugin extends Plugin
if (config.showTeleblock())
{
if (FULL_TELEBLOCK_PATTERN.matcher(event.getMessage()).find())
Matcher m = TELEBLOCK_PATTERN.matcher(event.getMessage());
if (m.find())
{
createGameTimer(FULLTB);
}
else if (HALF_TELEBLOCK_PATTERN.matcher(event.getMessage()).find())
{
if (client.getWorldType().contains(WorldType.DEADMAN))
{
createGameTimer(DMM_FULLTB);
}
else
{
createGameTimer(HALFTB);
}
}
else if (DEADMAN_HALF_TELEBLOCK_PATTERN.matcher(event.getMessage()).find())
{
createGameTimer(DMM_HALFTB);
}
else if (MAGE_ARENA_FULL_TELEBLOCK_PATTERN.matcher(event.getMessage()).find())
{
createGameTimer(MAGE_ARENA_FULLTB);
}
else if (MAGE_ARENA_HALF_TELEBLOCK_PATTERN.matcher(event.getMessage()).find())
{
createGameTimer(MAGE_ARENA_HALFTB);
String minss = m.group("mins");
String secss = m.group("secs");
int mins = Integer.parseInt(minss);
int secs = secss != null ? Integer.parseInt(secss) : 0;
createGameTimer(TELEBLOCK, Duration.ofSeconds(mins * 60 + secs));
}
else if (event.getMessage().contains(KILLED_TELEBLOCK_OPPONENT_TEXT))
{
removeTbTimers();
removeGameTimer(TELEBLOCK);
}
}
@@ -785,7 +763,7 @@ public class TimersPlugin extends Plugin
if (widget != null && !widget.isSelfHidden())
{
log.debug("Entered safe zone in PVP world, clearing Teleblock timer.");
removeTbTimers();
removeGameTimer(TELEBLOCK);
}
}
@@ -812,7 +790,7 @@ public class TimersPlugin extends Plugin
}
removeTzhaarTimer(); // will be readded by the wave message
removeTbTimers();
removeGameTimer(TELEBLOCK);
break;
case LOGGED_IN:
loggedInRace = true;
@@ -1074,14 +1052,4 @@ public class TimersPlugin extends Plugin
{
infoBoxManager.removeIf(t -> t instanceof IndicatorIndicator && ((IndicatorIndicator) t).getIndicator() == indicator);
}
private void removeTbTimers()
{
removeGameTimer(FULLTB);
removeGameTimer(HALFTB);
removeGameTimer(DMM_FULLTB);
removeGameTimer(DMM_HALFTB);
removeGameTimer(MAGE_ARENA_FULLTB);
removeGameTimer(MAGE_ARENA_HALFTB);
}
}