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