Temporarily fix hydra plugin (#434)
This commit is contained in:
@@ -53,6 +53,7 @@ class Hydra
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private NPC npc;
|
||||
|
||||
@Getter
|
||||
|
||||
@@ -24,18 +24,21 @@
|
||||
*/
|
||||
package net.runelite.client.plugins.alchemicalhydra;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import lombok.Getter;
|
||||
import net.runelite.api.AnimationID;
|
||||
import net.runelite.api.NpcID;
|
||||
import net.runelite.api.ProjectileID;
|
||||
import net.runelite.api.SpriteID;
|
||||
import net.runelite.api.coords.WorldPoint;
|
||||
|
||||
enum HydraPhase
|
||||
{ // Sorry for the autism
|
||||
ONE(3, AnimationID.HYDRA_1_1, AnimationID.HYDRA_1_2, ProjectileID.HYDRA_POISON, 0, SpriteID.BIG_ASS_GUTHIX_SPELL, new WorldPoint(1371, 10263, 0)),
|
||||
TWO(3, AnimationID.HYDRA_2_1, AnimationID.HYDRA_2_2, 0, AnimationID.HYDRA_LIGHTNING, SpriteID.BIG_SPEC_TRANSFER, new WorldPoint(1371, 10272, 0)),
|
||||
THREE(3, AnimationID.HYDRA_3_1, AnimationID.HYDRA_3_2, 0, AnimationID.HYDRA_FIRE, SpriteID.BIG_SUPERHEAT, new WorldPoint(1362, 10272, 0)),
|
||||
FOUR(1, AnimationID.HYDRA_4_1, AnimationID.HYDRA_4_2, ProjectileID.HYDRA_POISON, 0, SpriteID.BIG_ASS_GUTHIX_SPELL, null);
|
||||
ONE(3, AnimationID.HYDRA_1_1, AnimationID.HYDRA_1_2, ProjectileID.HYDRA_POISON, 0, SpriteID.BIG_ASS_GUTHIX_SPELL, new WorldPoint(1371, 10263, 0), NpcID.ALCHEMICAL_HYDRA),
|
||||
TWO(3, AnimationID.HYDRA_2_1, AnimationID.HYDRA_2_2, ProjectileID.HYDRA_LIGHTNING, AnimationID.HYDRA_LIGHTNING, SpriteID.BIG_SPEC_TRANSFER, new WorldPoint(1371, 10272, 0), NpcID.ALCHEMICAL_HYDRA_8619),
|
||||
THREE(3, AnimationID.HYDRA_3_1, AnimationID.HYDRA_3_2, 0, AnimationID.HYDRA_FIRE, SpriteID.BIG_SUPERHEAT, new WorldPoint(1362, 10272, 0), NpcID.ALCHEMICAL_HYDRA_8620),
|
||||
FOUR(1, AnimationID.HYDRA_4_1, AnimationID.HYDRA_4_2, ProjectileID.HYDRA_POISON, 0, SpriteID.BIG_ASS_GUTHIX_SPELL, null, NpcID.ALCHEMICAL_HYDRA_8621);
|
||||
|
||||
@Getter
|
||||
private final int attacksPerSwitch;
|
||||
@@ -58,7 +61,30 @@ enum HydraPhase
|
||||
@Getter
|
||||
private WorldPoint fountain;
|
||||
|
||||
HydraPhase(int attacksPerSwitch, int deathAnim1, int deathAnim2, int specProjectileId, int specAnimationId, int specImage, WorldPoint fountain)
|
||||
@Getter
|
||||
private int npcID;
|
||||
|
||||
@Getter
|
||||
private static final ImmutableSet<Integer> idSet;
|
||||
|
||||
private static final ImmutableMap<Integer, HydraPhase> idMap;
|
||||
|
||||
static
|
||||
{
|
||||
ImmutableMap.Builder<Integer, HydraPhase> mapBuilder = new ImmutableMap.Builder<>();
|
||||
ImmutableSet.Builder<Integer> setBuilder = new ImmutableSet.Builder<>();
|
||||
|
||||
for (HydraPhase p : values())
|
||||
{
|
||||
mapBuilder.put(p.getNpcID(), p);
|
||||
setBuilder.add(p.getNpcID());
|
||||
}
|
||||
|
||||
idMap = mapBuilder.build();
|
||||
idSet = setBuilder.build();
|
||||
}
|
||||
|
||||
HydraPhase(int attacksPerSwitch, int deathAnim1, int deathAnim2, int specProjectileId, int specAnimationId, int specImage, WorldPoint fountain, int npcID)
|
||||
{
|
||||
this.attacksPerSwitch = attacksPerSwitch;
|
||||
this.deathAnim1 = deathAnim1;
|
||||
@@ -67,5 +93,11 @@ enum HydraPhase
|
||||
this.specAnimationId = specAnimationId;
|
||||
this.specImage = specImage;
|
||||
this.fountain = fountain;
|
||||
this.npcID = npcID;
|
||||
}
|
||||
|
||||
static HydraPhase getFromId(int ID)
|
||||
{
|
||||
return idMap.get(ID);
|
||||
}
|
||||
}
|
||||
@@ -38,10 +38,12 @@ import net.runelite.api.GameState;
|
||||
import net.runelite.api.NPC;
|
||||
import net.runelite.api.NpcID;
|
||||
import net.runelite.api.Projectile;
|
||||
import net.runelite.api.ProjectileID;
|
||||
import net.runelite.api.coords.LocalPoint;
|
||||
import net.runelite.api.events.AnimationChanged;
|
||||
import net.runelite.api.events.ChatMessage;
|
||||
import net.runelite.api.events.GameStateChanged;
|
||||
import net.runelite.api.events.GameTick;
|
||||
import net.runelite.api.events.NpcSpawned;
|
||||
import net.runelite.api.events.ProjectileMoved;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
@@ -103,6 +105,57 @@ public class HydraPlugin extends Plugin
|
||||
lastAttackTick = -1;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
private void onGameTick(GameTick event)
|
||||
{
|
||||
if (!inHydraInstance)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
NPC hydraNpc = hydra.getNpc();
|
||||
|
||||
for (NPC npc : client.getNpcs())
|
||||
{
|
||||
if (!HydraPhase.getIdSet().contains(npc.getId()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
HydraPhase phase = HydraPhase.getFromId(npc.getId());
|
||||
|
||||
if (hydra.getPhase() != phase)
|
||||
{
|
||||
log.debug("Hydra phase changed!");
|
||||
changePhase(phase);
|
||||
}
|
||||
|
||||
if (hydraNpc != npc)
|
||||
{
|
||||
log.debug("Hydra npc changed!");
|
||||
hydra.setNpc(npc);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!poisonProjectiles.isEmpty())
|
||||
{
|
||||
Set<LocalPoint> exPoisonProjectiles = new HashSet<>();
|
||||
for (Map.Entry<LocalPoint, Projectile> entry : poisonProjectiles.entrySet())
|
||||
{
|
||||
if (entry.getValue().getEndCycle() < client.getGameCycle())
|
||||
{
|
||||
exPoisonProjectiles.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
for (LocalPoint toRemove : exPoisonProjectiles)
|
||||
{
|
||||
poisonProjectiles.remove(toRemove);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
private void onGameStateChanged(GameStateChanged state)
|
||||
{
|
||||
@@ -146,6 +199,7 @@ public class HydraPlugin extends Plugin
|
||||
return;
|
||||
}
|
||||
|
||||
log.debug("Hydra spawned");
|
||||
hydra = new Hydra(event.getNpc());
|
||||
addOverlays();
|
||||
}
|
||||
@@ -160,6 +214,7 @@ public class HydraPlugin extends Plugin
|
||||
return;
|
||||
}
|
||||
|
||||
log.debug("Animation changed: {}, {}", actor.getName(), actor.getAnimation());
|
||||
HydraPhase phase = hydra.getPhase();
|
||||
|
||||
if (actor.getAnimation() == phase.getDeathAnim2() &&
|
||||
@@ -171,11 +226,9 @@ public class HydraPlugin extends Plugin
|
||||
{
|
||||
case ONE:
|
||||
changePhase(HydraPhase.TWO);
|
||||
hydra.setWeakened(false);
|
||||
return;
|
||||
case TWO:
|
||||
changePhase(HydraPhase.THREE);
|
||||
hydra.setWeakened(false);
|
||||
return;
|
||||
case THREE:
|
||||
changePhase(HydraPhase.FOUR);
|
||||
@@ -195,24 +248,6 @@ public class HydraPlugin extends Plugin
|
||||
{
|
||||
hydra.setNextSpecial(hydra.getNextSpecial() + 9);
|
||||
}
|
||||
|
||||
if (poisonProjectiles.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Set<LocalPoint> exPoisonProjectiles = new HashSet<>();
|
||||
for (Map.Entry<LocalPoint, Projectile> entry : poisonProjectiles.entrySet())
|
||||
{
|
||||
if (entry.getValue().getEndCycle() < client.getGameCycle())
|
||||
{
|
||||
exPoisonProjectiles.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
for (LocalPoint toRemove : exPoisonProjectiles)
|
||||
{
|
||||
poisonProjectiles.remove(toRemove);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@@ -229,12 +264,16 @@ public class HydraPlugin extends Plugin
|
||||
|
||||
if (hydra.getPhase().getSpecProjectileId() != 0 && hydra.getPhase().getSpecProjectileId() == id)
|
||||
{
|
||||
if (poisonProjectiles.isEmpty())
|
||||
if (hydra.getAttackCount() == hydra.getNextSpecial())
|
||||
{
|
||||
// Only add 9 to next special on the first poison projectile (whoops)
|
||||
hydra.setNextSpecial(hydra.getNextSpecial() + 9);
|
||||
}
|
||||
poisonProjectiles.put(event.getPosition(), projectile);
|
||||
|
||||
if (id == ProjectileID.HYDRA_POISON)
|
||||
{
|
||||
poisonProjectiles.put(event.getPosition(), projectile);
|
||||
}
|
||||
}
|
||||
else if (client.getTickCount() != lastAttackTick
|
||||
&& (id == Hydra.AttackStyle.MAGIC.getProjId() || id == Hydra.AttackStyle.RANGED.getProjId()))
|
||||
@@ -247,12 +286,16 @@ public class HydraPlugin extends Plugin
|
||||
@Subscribe
|
||||
public void onChatMessage(ChatMessage event)
|
||||
{
|
||||
if (!event.getMessage().equals("The chemicals neutralise the Alchemical Hydra's defences!"))
|
||||
if (event.getMessage().equals("The chemicals neutralise the Alchemical Hydra's defences!"))
|
||||
{
|
||||
return;
|
||||
hydra.setWeakened(true);
|
||||
}
|
||||
else if (event.getMessage().startsWith("Your Alchemical Hydra kill count is"))
|
||||
{
|
||||
hydra = null;
|
||||
poisonProjectiles.clear();
|
||||
removeOverlays();
|
||||
}
|
||||
|
||||
hydra.setWeakened(true);
|
||||
}
|
||||
|
||||
private boolean checkArea()
|
||||
@@ -277,6 +320,8 @@ public class HydraPlugin extends Plugin
|
||||
hydra.setPhase(newPhase);
|
||||
hydra.setNextSpecial(3);
|
||||
hydra.setAttackCount(0);
|
||||
hydra.setWeakened(newPhase != HydraPhase.FOUR);
|
||||
|
||||
if (newPhase == HydraPhase.FOUR)
|
||||
{
|
||||
switchStyles();
|
||||
|
||||
Reference in New Issue
Block a user