Merge pull request #3949 from deathbeam/jad-fix
Make Fight Cave plugin more accurate
This commit is contained in:
@@ -52,7 +52,7 @@ public class FightCaveOverlay extends Overlay
|
||||
private BufferedImage protectFromMissilesImg;
|
||||
|
||||
@Inject
|
||||
FightCaveOverlay(Client client, FightCavePlugin plugin)
|
||||
private FightCaveOverlay(Client client, FightCavePlugin plugin)
|
||||
{
|
||||
setPosition(OverlayPosition.BOTTOM_RIGHT);
|
||||
setPriority(OverlayPriority.HIGH);
|
||||
@@ -63,7 +63,7 @@ public class FightCaveOverlay extends Overlay
|
||||
@Override
|
||||
public Dimension render(Graphics2D graphics)
|
||||
{
|
||||
JadAttack attack = plugin.getAttack();
|
||||
final JadAttack attack = plugin.getAttack();
|
||||
|
||||
if (attack == null)
|
||||
{
|
||||
|
||||
@@ -24,38 +24,37 @@
|
||||
*/
|
||||
package net.runelite.client.plugins.fightcave;
|
||||
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.GameState;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import net.runelite.api.NPC;
|
||||
import net.runelite.api.Query;
|
||||
import net.runelite.api.queries.NPCQuery;
|
||||
import net.runelite.api.NpcID;
|
||||
import net.runelite.api.events.AnimationChanged;
|
||||
import net.runelite.api.events.NpcDespawned;
|
||||
import net.runelite.api.events.NpcSpawned;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.task.Schedule;
|
||||
import net.runelite.client.ui.overlay.OverlayManager;
|
||||
import net.runelite.client.util.QueryRunner;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "Fight Cave"
|
||||
)
|
||||
public class FightCavePlugin extends Plugin
|
||||
{
|
||||
@Inject
|
||||
private Client client;
|
||||
|
||||
@Inject
|
||||
private QueryRunner queryRunner;
|
||||
|
||||
@Inject
|
||||
private OverlayManager overlayManager;
|
||||
|
||||
@Inject
|
||||
private FightCaveOverlay overlay;
|
||||
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
@Nullable
|
||||
private JadAttack attack;
|
||||
|
||||
private NPC jad;
|
||||
|
||||
@Override
|
||||
protected void startUp() throws Exception
|
||||
{
|
||||
@@ -66,46 +65,46 @@ public class FightCavePlugin extends Plugin
|
||||
protected void shutDown() throws Exception
|
||||
{
|
||||
overlayManager.remove(overlay);
|
||||
jad = null;
|
||||
attack = null;
|
||||
}
|
||||
|
||||
@Schedule(
|
||||
period = 600,
|
||||
unit = ChronoUnit.MILLIS
|
||||
)
|
||||
public void update()
|
||||
@Subscribe
|
||||
public void onNpcSpawned(final NpcSpawned event)
|
||||
{
|
||||
if (client.getGameState() != GameState.LOGGED_IN)
|
||||
{
|
||||
return;
|
||||
}
|
||||
final int id = event.getNpc().getId();
|
||||
|
||||
NPC jad = findJad();
|
||||
if (jad != null)
|
||||
if (id == NpcID.TZTOKJAD || id == NpcID.TZTOKJAD_6506)
|
||||
{
|
||||
if (jad.getAnimation() == JadAttack.MAGIC.getAnimation())
|
||||
{
|
||||
attack = JadAttack.MAGIC;
|
||||
}
|
||||
else if (jad.getAnimation() == JadAttack.RANGE.getAnimation())
|
||||
{
|
||||
attack = JadAttack.RANGE;
|
||||
}
|
||||
jad = event.getNpc();
|
||||
}
|
||||
else
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onNpcDespawned(final NpcDespawned event)
|
||||
{
|
||||
if (jad == event.getNpc())
|
||||
{
|
||||
jad = null;
|
||||
attack = null;
|
||||
}
|
||||
}
|
||||
|
||||
private NPC findJad()
|
||||
@Subscribe
|
||||
public void onAnimationChanged(final AnimationChanged event)
|
||||
{
|
||||
Query query = new NPCQuery().nameContains("TzTok-Jad");
|
||||
NPC[] result = queryRunner.runQuery(query);
|
||||
return result.length >= 1 ? result[0] : null;
|
||||
}
|
||||
if (event.getActor() != jad)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
JadAttack getAttack()
|
||||
{
|
||||
return attack;
|
||||
if (jad.getAnimation() == JadAttack.MAGIC.getAnimation())
|
||||
{
|
||||
attack = JadAttack.MAGIC;
|
||||
}
|
||||
else if (jad.getAnimation() == JadAttack.RANGE.getAnimation())
|
||||
{
|
||||
attack = JadAttack.RANGE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user