Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.runelite.client.plugins.hydra;
- import com.google.inject.Provides;
- import lombok.AccessLevel;
- import lombok.Getter;
- import net.runelite.api.*;
- import net.runelite.api.coords.LocalPoint;
- import net.runelite.api.coords.WorldPoint;
- import net.runelite.api.events.*;
- import net.runelite.client.config.ConfigManager;
- import net.runelite.client.eventbus.Subscribe;
- import java.util.*;
- import net.runelite.client.plugins.Plugin;
- import net.runelite.client.plugins.PluginDescriptor;
- import net.runelite.client.ui.overlay.OverlayManager;
- import javax.inject.Inject;
- import java.util.List;
- @PluginDescriptor(
- name = " Hydra",
- description = "Helps you kill hydra",
- tags = {"hydra", "slayer", "pvm"},
- enabledByDefault =false
- )
- public class HydraPlugin extends Plugin {
- @Inject
- private Client client;
- @Getter(AccessLevel.PUBLIC)
- @Inject
- private OverlayManager overlayManager;
- @Inject
- private HydraConfig config;
- @Inject
- private HydraOverlay overlay;
- public boolean isMage = false;
- public int HydraCounter = 0;
- private boolean lastphase = false;
- private int NumberAttacks = 0;
- public Set<Integer> HydraID = new HashSet<>();
- NPC hydra = null;
- @Provides
- HydraConfig provideConfig(ConfigManager configManager)
- {
- return configManager.getConfig(HydraConfig.class);
- }
- @Override
- protected void startUp() throws Exception
- {
- HydraID.add(8615);HydraID.add(8619);HydraID.add(8620);HydraID.add(8621);
- overlayManager.add(overlay);
- }
- @Override
- protected void shutDown() throws Exception
- {
- overlayManager.remove(overlay);
- }
- @Subscribe
- public void onGameTick(GameTick tick) {
- List<NPC> npcs = client.getNpcs();
- if (npcs == null) { return; }
- //if (!client.isInInstancedRegion()) { return; }
- for (NPC npc : npcs) {
- if (HydraID.contains(npc.getId())) {
- this.hydra = npc;
- if (this.hydra.getHealth() <= 275) {
- lastphase = true;
- }
- }
- }
- List<Projectile> p = client.getProjectiles();
- for ( Projectile P: p ) {
- int id = P.getId();
- HandleCounter(id);
- }
- this.HydraCounter--;
- if (HydraCounter < 0) {
- HydraCounter = 0;
- }
- }
- private void HandleCounter(int projid) {
- if (projid == ProjectileID.HYDRA_MAGE || projid == ProjectileID.HYDRA_RANGE) {
- if (NumberAttacks==0) {
- if (projid == ProjectileID.HYDRA_MAGE) {
- this.NumberAttacks++;
- this.isMage = true;
- HydraCounter = 7;
- }
- }
- if (HydraCounter < 2) {
- this.NumberAttacks++;
- if (lastphase) {
- this.isMage = !this.isMage;
- }
- else if (this.NumberAttacks-1 % 3 == 0) {
- this.isMage = !this.isMage;
- }
- HydraCounter = 7;
- }
- }
- else {
- if (HydraCounter < 2) {
- HydraCounter = 7;
- }
- }
- }
- @Subscribe
- public void onNpcDespawned(NpcDespawned despawned){
- NumberAttacks = 0;
- }
- }
- ******** HydraOverlay.java ********
- package net.runelite.client.plugins.hydra;
- import net.runelite.api.*;
- import net.runelite.api.Point;
- import net.runelite.api.coords.LocalPoint;
- import net.runelite.client.ui.overlay.*;
- import javax.inject.Inject;
- import java.awt.*;
- public class HydraOverlay extends Overlay {
- private Client client;
- private final HydraPlugin plugin;
- @Inject
- public HydraOverlay(Client client, HydraPlugin plugin)
- {
- this.client = client;
- this.plugin = plugin;
- setPosition(OverlayPosition.DYNAMIC);
- setLayer(OverlayLayer.ABOVE_SCENE);
- }
- @Override
- public Dimension render(Graphics2D graphics)
- {
- graphics.setFont(new Font("Arial", Font.BOLD, 20));
- NPC npc = plugin.hydra;
- if((npc == null) || !client.isInInstancedRegion()){
- return null;
- }
- if (plugin.HydraCounter >= 0) {
- String str = Integer.toString(plugin.HydraCounter);
- LocalPoint lp = npc.getLocalLocation();
- //Point textLocation = Perspective.getCanvasTextLocation(client, graphics, lp, str, 0);
- Point textLocation = npc.getCanvasTextLocation(graphics, npc.getName(), 0);
- if (plugin.isMage) {
- OverlayUtil.renderTextLocation(graphics, textLocation, str, Color.BLUE);
- } else {
- OverlayUtil.renderTextLocation(graphics, textLocation, str, Color.GREEN);
- }
- }
- return null;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement