Merge pull request #1214 from Ganom/projectile-update

events: reduce projectilemoved usage as much as possible
This commit is contained in:
Owain van Brakel
2019-08-02 13:46:38 +02:00
committed by GitHub
9 changed files with 494 additions and 743 deletions

View File

@@ -27,7 +27,6 @@ package net.runelite.client.plugins.cannon;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.inject.Provides; import com.google.inject.Provides;
import java.awt.Color; import java.awt.Color;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.regex.Matcher; import java.util.regex.Matcher;
@@ -52,7 +51,7 @@ import net.runelite.api.events.ConfigChanged;
import net.runelite.api.events.GameObjectSpawned; import net.runelite.api.events.GameObjectSpawned;
import net.runelite.api.events.GameTick; import net.runelite.api.events.GameTick;
import net.runelite.api.events.ItemContainerChanged; import net.runelite.api.events.ItemContainerChanged;
import net.runelite.api.events.ProjectileMoved; import net.runelite.api.events.ProjectileSpawned;
import net.runelite.client.Notifier; import net.runelite.client.Notifier;
import net.runelite.client.callback.ClientThread; import net.runelite.client.callback.ClientThread;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
@@ -60,7 +59,6 @@ import net.runelite.client.eventbus.EventBus;
import net.runelite.client.game.ItemManager; import net.runelite.client.game.ItemManager;
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.ui.overlay.infobox.InfoBoxManager; import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
import net.runelite.client.util.ItemUtil; import net.runelite.client.util.ItemUtil;
@@ -77,57 +75,39 @@ public class CannonPlugin extends Plugin
private static final ImmutableSet<Integer> CANNON_PARTS = ImmutableSet.of( private static final ImmutableSet<Integer> CANNON_PARTS = ImmutableSet.of(
ItemID.CANNON_BASE, ItemID.CANNON_STAND, ItemID.CANNON_BARRELS, ItemID.CANNON_FURNACE ItemID.CANNON_BASE, ItemID.CANNON_STAND, ItemID.CANNON_BARRELS, ItemID.CANNON_FURNACE
); );
private CannonCounter counter; private CannonCounter counter;
private boolean skipProjectileCheckThisTick; private boolean skipProjectileCheckThisTick;
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
private int cballsLeft; private int cballsLeft;
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
private boolean cannonPlaced; private boolean cannonPlaced;
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
private WorldPoint cannonPosition; private WorldPoint cannonPosition;
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
private GameObject cannon; private GameObject cannon;
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
private List<WorldPoint> spotPoints = new ArrayList<>(); private List<WorldPoint> spotPoints = new ArrayList<>();
@Inject @Inject
private ItemManager itemManager; private ItemManager itemManager;
@Inject @Inject
private InfoBoxManager infoBoxManager; private InfoBoxManager infoBoxManager;
@Inject @Inject
private Notifier notifier; private Notifier notifier;
@Inject @Inject
private OverlayManager overlayManager; private OverlayManager overlayManager;
@Inject @Inject
private CannonOverlay cannonOverlay; private CannonOverlay cannonOverlay;
@Inject @Inject
private CannonSpotOverlay cannonSpotOverlay; private CannonSpotOverlay cannonSpotOverlay;
@Inject @Inject
private CannonConfig config; private CannonConfig config;
@Inject @Inject
private Client client; private Client client;
@Inject @Inject
private ClientThread clientThread; private ClientThread clientThread;
@Inject @Inject
private EventBus eventbus; private EventBus eventbus;
private boolean lock; private boolean lock;
private boolean showEmptyCannonNotification; private boolean showEmptyCannonNotification;
private boolean showInfobox; private boolean showInfobox;
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
@@ -178,7 +158,7 @@ public class CannonPlugin extends Plugin
eventbus.subscribe(ConfigChanged.class, this, this::onConfigChanged); eventbus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventbus.subscribe(ItemContainerChanged.class, this, this::onItemContainerChanged); eventbus.subscribe(ItemContainerChanged.class, this, this::onItemContainerChanged);
eventbus.subscribe(GameObjectSpawned.class, this, this::onGameObjectSpawned); eventbus.subscribe(GameObjectSpawned.class, this, this::onGameObjectSpawned);
eventbus.subscribe(ProjectileMoved.class, this, this::onProjectileMoved); eventbus.subscribe(ProjectileSpawned.class, this, this::onProjectileSpawned);
eventbus.subscribe(ChatMessage.class, this, this::onChatMessage); eventbus.subscribe(ChatMessage.class, this, this::onChatMessage);
eventbus.subscribe(GameTick.class, this, this::onGameTick); eventbus.subscribe(GameTick.class, this, this::onGameTick);
} }
@@ -211,37 +191,13 @@ public class CannonPlugin extends Plugin
} }
} }
} }
}
@Schedule(
period = 1,
unit = ChronoUnit.SECONDS
)
public void checkSpots()
{
if (!this.showCannonSpots)
{
return;
}
spotPoints.clear();
for (WorldPoint spot : CannonSpots.getCannonSpots())
{
if (spot.getPlane() != client.getPlane() || !spot.isInScene(client))
{
continue;
}
spotPoints.add(spot);
}
} }
private void onGameObjectSpawned(GameObjectSpawned event) private void onGameObjectSpawned(GameObjectSpawned event)
{ {
GameObject gameObject = event.getGameObject(); final GameObject gameObject = event.getGameObject();
Player localPlayer = client.getLocalPlayer(); final Player localPlayer = client.getLocalPlayer();
if (gameObject.getId() == CANNON_BASE && !cannonPlaced && if (gameObject.getId() == CANNON_BASE && !cannonPlaced &&
localPlayer.getWorldLocation().distanceTo(gameObject.getWorldLocation()) <= 2 && localPlayer.getWorldLocation().distanceTo(gameObject.getWorldLocation()) <= 2 &&
localPlayer.getAnimation() == AnimationID.BURYING_BONES) localPlayer.getAnimation() == AnimationID.BURYING_BONES)
@@ -251,22 +207,15 @@ public class CannonPlugin extends Plugin
} }
} }
private void onProjectileMoved(ProjectileMoved event) private void onProjectileSpawned(ProjectileSpawned event)
{ {
Projectile projectile = event.getProjectile(); final Projectile projectile = event.getProjectile();
if ((projectile.getId() == CANNONBALL || projectile.getId() == GRANITE_CANNONBALL) && cannonPosition != null) if ((projectile.getId() == CANNONBALL || projectile.getId() == GRANITE_CANNONBALL) && cannonPosition != null)
{ {
WorldPoint projectileLoc = WorldPoint.fromLocal(client, projectile.getX1(), projectile.getY1(), client.getPlane()); final WorldPoint projectileLoc = WorldPoint.fromLocal(client, projectile.getX1(), projectile.getY1(), client.getPlane());
//Check to see if projectile x,y is 0 else it will continuously decrease while ball is flying. if (projectileLoc.equals(cannonPosition) && !skipProjectileCheckThisTick)
if (projectileLoc.equals(cannonPosition) && projectile.getX() == 0 && projectile.getY() == 0 &&
// When there's a chat message about cannon reloaded/unloaded/out of ammo,
// the message event runs before the projectile event. However they run
// in the opposite order on the server. So if both fires in the same tick,
// we don't want to update the cannonball counter if it was set to a specific
// amount.
!skipProjectileCheckThisTick)
{ {
cballsLeft--; cballsLeft--;
} }

View File

@@ -86,7 +86,7 @@ public class CoxInfoBox extends Overlay
if (System.currentTimeMillis() < (plugin.getLastPrayTime() + 120000) && plugin.getPrayAgainstOlm() != null) if (System.currentTimeMillis() < (plugin.getLastPrayTime() + 120000) && plugin.getPrayAgainstOlm() != null)
{ {
InfoBoxComponent prayComponent = new InfoBoxComponent(); InfoBoxComponent prayComponent = new InfoBoxComponent();
BufferedImage prayImg = scaleImg(getPrayerImage(plugin.prayAgainstOlm)); BufferedImage prayImg = scaleImg(getPrayerImage(plugin.getPrayAgainstOlm()));
prayComponent.setImage(prayImg); prayComponent.setImage(prayImg);
prayComponent.setColor(Color.WHITE); prayComponent.setColor(Color.WHITE);
prayComponent.setBackgroundColor(client.isPrayerActive(prayAgainst.getPrayer()) prayComponent.setBackgroundColor(client.isPrayerActive(prayAgainst.getPrayer())

View File

@@ -25,6 +25,7 @@
package net.runelite.client.plugins.coxhelper; package net.runelite.client.plugins.coxhelper;
import com.google.common.collect.ImmutableSet;
import java.awt.BasicStroke; import java.awt.BasicStroke;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
@@ -32,6 +33,7 @@ import java.awt.Font;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Polygon; import java.awt.Polygon;
import java.util.List; import java.util.List;
import java.util.Set;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import net.runelite.api.Actor; import net.runelite.api.Actor;
@@ -53,6 +55,9 @@ import net.runelite.client.ui.overlay.OverlayUtil;
@Singleton @Singleton
public class CoxOverlay extends Overlay public class CoxOverlay extends Overlay
{ {
private static final Set<Integer> GAP = ImmutableSet.of(
34, 33, 26, 25, 18, 17, 10, 9, 2, 1
);
private final Client client; private final Client client;
private final CoxPlugin plugin; private final CoxPlugin plugin;
@@ -105,7 +110,6 @@ public class CoxOverlay extends Overlay
if (plugin.isTektonTickCounter()) if (plugin.isTektonTickCounter())
{ {
ticksLeft = npcs.getTicksUntilAttack(); ticksLeft = npcs.getTicksUntilAttack();
int attackTicksleft = plugin.getTektonAttackTicks();
if (ticksLeft > 0) if (ticksLeft > 0)
{ {
if (ticksLeft == 1) if (ticksLeft == 1)
@@ -214,67 +218,67 @@ public class CoxOverlay extends Overlay
if (plugin.isTimers()) if (plugin.isTimers())
{ {
if (plugin.getBurnTarget().size() > 0) if (plugin.getVictims().size() > 0)
{ {
for (Actor actor : plugin.getBurnTarget()) plugin.getVictims().forEach(victim ->
{ {
final int ticksLeft = plugin.getBurnTicks(); final int ticksLeft = victim.getTicks();
String ticksLeftStr = String.valueOf(ticksLeft); String ticksLeftStr = String.valueOf(ticksLeft);
Color tickcolor; Color tickcolor;
if (ticksLeft >= 0) switch (victim.getType())
{ {
if (ticksLeft == 34 || case ACID:
ticksLeft == 33 || if (ticksLeft > 0)
ticksLeft == 26 || {
ticksLeft == 25 || if (ticksLeft > 1)
ticksLeft == 18 || {
ticksLeft == 17 || tickcolor = new Color(69, 241, 44, 255);
ticksLeft == 10 || }
ticksLeft == 9 || else
ticksLeft == 2 || {
ticksLeft == 1) tickcolor = new Color(255, 255, 255, 255);
{ }
tickcolor = new Color(255, 0, 0, 255); Point canvasPoint = victim.getPlayer().getCanvasTextLocation(graphics, ticksLeftStr, 0);
ticksLeftStr = "GAP"; renderTextLocation(graphics, ticksLeftStr, plugin.getTextSize(), plugin.getFontStyle().getFont(), tickcolor, canvasPoint);
} }
else break;
{ case BURN:
tickcolor = new Color(255, 255, 255, 255); if (ticksLeft > 0)
} {
Point canvasPoint = actor.getCanvasTextLocation(graphics, ticksLeftStr, 0); if (GAP.contains(ticksLeft))
renderTextLocation(graphics, ticksLeftStr, plugin.getTextSize(), plugin.getFontStyle().getFont(), tickcolor, canvasPoint); {
tickcolor = new Color(255, 0, 0, 255);
ticksLeftStr = "GAP";
}
else
{
tickcolor = new Color(255, 255, 255, 255);
}
Point canvasPoint = victim.getPlayer().getCanvasTextLocation(graphics, ticksLeftStr, 0);
renderTextLocation(graphics, ticksLeftStr, plugin.getTextSize(), plugin.getFontStyle().getFont(), tickcolor, canvasPoint);
}
break;
case TELEPORT:
if (plugin.isTpOverlay())
{
if (ticksLeft > 0)
{
if (ticksLeft > 1)
{
tickcolor = new Color(193, 255, 245, 255);
}
else
{
tickcolor = new Color(255, 255, 255, 255);
}
Point canvasPoint = victim.getPlayer().getCanvasTextLocation(graphics, ticksLeftStr, 0);
renderTextLocation(graphics, ticksLeftStr, plugin.getTextSize(), plugin.getFontStyle().getFont(), tickcolor, canvasPoint);
}
renderActorOverlay(graphics, victim.getPlayer(), new Color(193, 255, 245, 255), 2, 100, 10);
}
break;
} }
} });
}
if (plugin.getAcidTarget() != null)
{
Actor actor = plugin.getAcidTarget();
renderActorOverlay(graphics, actor, plugin.getAcidColor(), 2, 100, 10);
final int ticksLeft = plugin.getAcidTicks();
Color tickcolor;
if (ticksLeft > 0)
{
if (ticksLeft > 1)
{
tickcolor = new Color(69, 241, 44, 255);
}
else
{
tickcolor = new Color(255, 255, 255, 255);
}
final String ticksLeftStr = String.valueOf(ticksLeft);
Point canvasPoint = actor.getCanvasTextLocation(graphics, ticksLeftStr, 0);
renderTextLocation(graphics, ticksLeftStr, plugin.getTextSize(), plugin.getFontStyle().getFont(), tickcolor, canvasPoint);
}
}
}
if (plugin.isTpOverlay())
{
if (plugin.getTeleportTarget() != null)
{
renderActorOverlay(graphics, plugin.getTeleportTarget(), new Color(193, 255, 245, 255), 2, 100, 10);
} }
} }

View File

@@ -31,8 +31,10 @@ import com.google.inject.Provides;
import java.awt.Color; import java.awt.Color;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import javax.inject.Inject; import javax.inject.Inject;
@@ -59,7 +61,7 @@ import net.runelite.api.events.ConfigChanged;
import net.runelite.api.events.GameTick; import net.runelite.api.events.GameTick;
import net.runelite.api.events.NpcDespawned; import net.runelite.api.events.NpcDespawned;
import net.runelite.api.events.NpcSpawned; import net.runelite.api.events.NpcSpawned;
import net.runelite.api.events.ProjectileMoved; import net.runelite.api.events.ProjectileSpawned;
import net.runelite.api.events.SpotAnimationChanged; import net.runelite.api.events.SpotAnimationChanged;
import net.runelite.client.chat.ChatMessageManager; import net.runelite.client.chat.ChatMessageManager;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
@@ -80,123 +82,77 @@ import net.runelite.client.util.Text;
@Slf4j @Slf4j
@Singleton @Singleton
@Getter(AccessLevel.PACKAGE)
public class CoxPlugin extends Plugin public class CoxPlugin extends Plugin
{ {
private static final int ANIMATION_ID_G1 = 430; private static final int ANIMATION_ID_G1 = 430;
private static final String OLM_HAND_CRIPPLE = "The Great Olm\'s left claw clenches to protect itself temporarily."; private static final String OLM_HAND_CRIPPLE = "The Great Olm\'s left claw clenches to protect itself temporarily.";
private static final Pattern TP_REGEX = Pattern.compile("You have been paired with <col=ff0000>(.*)</col>! The magical power will enact soon..."); private static final Pattern TP_REGEX = Pattern.compile("You have been paired with <col=ff0000>(.*)</col>! The magical power will enact soon...");
@Setter
@Getter(AccessLevel.PACKAGE)
protected PrayAgainst prayAgainstOlm;
@Getter(AccessLevel.PACKAGE)
protected long lastPrayTime;
private int sleepcount = 0;
private boolean needOlm = false;
private GraphicsObject teleportObject;
@Inject @Inject
@Getter(AccessLevel.NONE)
private Client client; private Client client;
@Inject @Inject
@Getter(AccessLevel.NONE)
private ChatMessageManager chatMessageManager; private ChatMessageManager chatMessageManager;
@Inject @Inject
@Getter(AccessLevel.NONE)
private CoxOverlay coxOverlay; private CoxOverlay coxOverlay;
@Inject @Inject
@Getter(AccessLevel.NONE)
private CoxInfoBox coxInfoBox; private CoxInfoBox coxInfoBox;
@Inject @Inject
@Getter(AccessLevel.NONE)
private CoxConfig config; private CoxConfig config;
@Inject @Inject
@Getter(AccessLevel.NONE)
private OverlayManager overlayManager; private OverlayManager overlayManager;
@Inject @Inject
@Getter(AccessLevel.NONE)
private EventBus eventBus; private EventBus eventBus;
@Getter(AccessLevel.PACKAGE) private boolean handCripple;
private boolean HandCripple;
@Getter(AccessLevel.PACKAGE)
private boolean runOlm; private boolean runOlm;
@Getter(AccessLevel.PACKAGE)
private int vanguards; private int vanguards;
@Getter(AccessLevel.PACKAGE)
private boolean tektonActive; private boolean tektonActive;
@Getter(AccessLevel.PACKAGE)
private NPC hand; private NPC hand;
@Getter(AccessLevel.PACKAGE)
private NPC Olm_NPC; private NPC Olm_NPC;
@Getter(AccessLevel.PACKAGE)
private NPC OlmMelee_NPC;
@Getter(AccessLevel.PACKAGE)
private List<WorldPoint> Olm_Crystals = new ArrayList<>(); private List<WorldPoint> Olm_Crystals = new ArrayList<>();
@Getter(AccessLevel.PACKAGE)
private List<WorldPoint> Olm_Heal = new ArrayList<>(); private List<WorldPoint> Olm_Heal = new ArrayList<>();
@Getter(AccessLevel.PACKAGE)
private List<WorldPoint> Olm_TP = new ArrayList<>(); private List<WorldPoint> Olm_TP = new ArrayList<>();
@Getter(AccessLevel.PACKAGE)
private List<WorldPoint> Olm_PSN = new ArrayList<>(); private List<WorldPoint> Olm_PSN = new ArrayList<>();
@Getter(AccessLevel.PACKAGE) private Set<Victim> victims = new HashSet<>();
private List<Actor> burnTarget = new ArrayList<>();
@Getter(AccessLevel.PACKAGE)
private Actor teleportTarget;
@Getter(AccessLevel.PACKAGE)
private Actor acidTarget; private Actor acidTarget;
@Getter(AccessLevel.PACKAGE)
private int crippleTimer = 45; private int crippleTimer = 45;
@Getter(AccessLevel.PACKAGE)
private int burnTicks = 41;
@Getter(AccessLevel.PACKAGE)
private int acidTicks = 25;
@Getter(AccessLevel.PACKAGE)
private int teleportTicks = 10; private int teleportTicks = 10;
@Getter(AccessLevel.PACKAGE)
private int tektonAttackTicks; private int tektonAttackTicks;
@Getter(AccessLevel.PACKAGE)
private int OlmPhase = 0; private int OlmPhase = 0;
@Getter(AccessLevel.PACKAGE)
private int Olm_TicksUntilAction = -1; private int Olm_TicksUntilAction = -1;
@Getter(AccessLevel.PACKAGE)
private int Olm_ActionCycle = -1; //4:0 = auto 3:0 = null 2:0 = auto 1:0 = spec + actioncycle =4 private int Olm_ActionCycle = -1; //4:0 = auto 3:0 = null 2:0 = auto 1:0 = spec + actioncycle =4
@Getter(AccessLevel.PACKAGE)
private int Olm_NextSpec = -1; // 1= crystals 2=lightnig 3=portals 4= heal hand if p4 private int Olm_NextSpec = -1; // 1= crystals 2=lightnig 3=portals 4= heal hand if p4
@Getter(AccessLevel.PACKAGE)
private float percent;
@Getter(AccessLevel.PACKAGE)
private Map<NPC, NPCContainer> npcContainer = new HashMap<>(); private Map<NPC, NPCContainer> npcContainer = new HashMap<>();
@Setter(AccessLevel.PACKAGE)
@Getter(AccessLevel.PACKAGE) private PrayAgainst prayAgainstOlm;
private long lastPrayTime;
private int sleepcount = 0;
private boolean needOlm = false;
private boolean muttadile; private boolean muttadile;
@Getter(AccessLevel.PACKAGE)
private boolean tekton; private boolean tekton;
@Getter(AccessLevel.PACKAGE)
private boolean tektonTickCounter; private boolean tektonTickCounter;
@Getter(AccessLevel.PACKAGE)
private boolean guardians; private boolean guardians;
@Getter(AccessLevel.PACKAGE)
private boolean guardinTickCounter; private boolean guardinTickCounter;
@Getter(AccessLevel.PACKAGE)
private boolean vangHighlight; private boolean vangHighlight;
@Getter(AccessLevel.PACKAGE)
private boolean vangHealth; private boolean vangHealth;
@Getter(AccessLevel.PACKAGE)
private boolean configPrayAgainstOlm; private boolean configPrayAgainstOlm;
@Getter(AccessLevel.PACKAGE)
private boolean timers; private boolean timers;
@Getter(AccessLevel.PACKAGE)
private boolean tpOverlay; private boolean tpOverlay;
@Getter(AccessLevel.PACKAGE)
private boolean olmTick; private boolean olmTick;
@Getter(AccessLevel.PACKAGE)
private Color muttaColor; private Color muttaColor;
@Getter(AccessLevel.PACKAGE)
private Color guardColor; private Color guardColor;
@Getter(AccessLevel.PACKAGE)
private Color tektonColor; private Color tektonColor;
@Getter(AccessLevel.PACKAGE)
private Color burnColor; private Color burnColor;
@Getter(AccessLevel.PACKAGE)
private Color acidColor; private Color acidColor;
@Getter(AccessLevel.PACKAGE)
private Color tpColor; private Color tpColor;
@Getter(AccessLevel.PACKAGE)
private CoxConfig.FontStyle fontStyle; private CoxConfig.FontStyle fontStyle;
@Getter(AccessLevel.PACKAGE)
private int textSize; private int textSize;
@Getter(AccessLevel.PACKAGE)
private boolean shadows; private boolean shadows;
@Provides @Provides
@@ -213,16 +169,12 @@ public class CoxPlugin extends Plugin
overlayManager.add(coxOverlay); overlayManager.add(coxOverlay);
overlayManager.add(coxInfoBox); overlayManager.add(coxInfoBox);
HandCripple = false; handCripple = false;
hand = null; hand = null;
acidTarget = null;
teleportTarget = null;
Olm_TP.clear(); Olm_TP.clear();
prayAgainstOlm = null; prayAgainstOlm = null;
burnTarget.clear(); victims.clear();
crippleTimer = 45; crippleTimer = 45;
burnTicks = 40;
acidTicks = 25;
teleportTicks = 10; teleportTicks = 10;
vanguards = 0; vanguards = 0;
} }
@@ -231,7 +183,6 @@ public class CoxPlugin extends Plugin
protected void shutDown() protected void shutDown()
{ {
eventBus.unregister(this); eventBus.unregister(this);
overlayManager.remove(coxOverlay); overlayManager.remove(coxOverlay);
overlayManager.remove(coxInfoBox); overlayManager.remove(coxInfoBox);
} }
@@ -240,203 +191,231 @@ public class CoxPlugin extends Plugin
{ {
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged); eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventBus.subscribe(ChatMessage.class, this, this::onChatMessage); eventBus.subscribe(ChatMessage.class, this, this::onChatMessage);
eventBus.subscribe(ProjectileMoved.class, this, this::onProjectileMoved); eventBus.subscribe(ProjectileSpawned.class, this, this::onProjectileSpawned);
eventBus.subscribe(SpotAnimationChanged.class, this, this::onSpotAnimationChanged); eventBus.subscribe(SpotAnimationChanged.class, this, this::onSpotAnimationChanged);
eventBus.subscribe(NpcSpawned.class, this, this::onNpcSpawned); eventBus.subscribe(NpcSpawned.class, this, this::onNpcSpawned);
eventBus.subscribe(NpcDespawned.class, this, this::onNpcDespawned); eventBus.subscribe(NpcDespawned.class, this, this::onNpcDespawned);
eventBus.subscribe(GameTick.class, this, this::onGameTick); eventBus.subscribe(GameTick.class, this, this::onGameTick);
} }
private void onChatMessage(ChatMessage chatMessage) private void onConfigChanged(ConfigChanged event)
{ {
if (inRaid()) if (event.getGroup().equals("Cox"))
{ {
if (chatMessage.getType() == ChatMessageType.GAMEMESSAGE) updateConfig();
}
}
private void onChatMessage(ChatMessage event)
{
if (!inRaid())
{
return;
}
if (event.getType() == ChatMessageType.GAMEMESSAGE)
{
final Matcher tpMatcher = TP_REGEX.matcher(event.getMessage());
if (tpMatcher.matches())
{ {
Matcher tpMatcher = TP_REGEX.matcher(chatMessage.getMessage()); for (Player player : client.getPlayers())
if (tpMatcher.matches())
{ {
log.info("TP Matcher has found a match"); if (player.getName().equals(tpMatcher.group(1)))
for (Actor actor : client.getPlayers())
{ {
if (actor.getName().equals(tpMatcher.group(1))) victims.add(new Victim(player, Victim.Type.TELEPORT));
{
log.info("Teleport Target Assigned");
teleportTarget = actor;
}
} }
} }
switch (Text.standardize(chatMessage.getMessageNode().getValue())) }
{
case "the great olm rises with the power of acid.": switch (Text.standardize(event.getMessageNode().getValue()))
case "the great olm rises with the power of crystal.": {
case "the great olm rises with the power of flame.": case "the great olm rises with the power of acid.":
case "the great olm is giving its all. this is its final stand.": case "the great olm rises with the power of crystal.":
if (!runOlm) case "the great olm rises with the power of flame.":
{ case "the great olm is giving its all. this is its final stand.":
Olm_ActionCycle = -1; if (!runOlm)
Olm_TicksUntilAction = 4; {
} Olm_ActionCycle = -1;
else Olm_TicksUntilAction = 4;
{ }
Olm_ActionCycle = -1; else
Olm_TicksUntilAction = 3; {
} Olm_ActionCycle = -1;
OlmPhase = 0; Olm_TicksUntilAction = 3;
runOlm = true; }
needOlm = true; OlmPhase = 0;
crippleTimer = 45; runOlm = true;
Olm_NextSpec = -1; needOlm = true;
break; crippleTimer = 45;
case "the great olm fires a sphere of aggression your way. your prayers have been sapped.": Olm_NextSpec = -1;
prayAgainstOlm = PrayAgainst.MELEE; break;
lastPrayTime = System.currentTimeMillis(); case "the great olm fires a sphere of aggression your way. your prayers have been sapped.":
break; case "the great olm fires a sphere of aggression your way.":
case "the great olm fires a sphere of aggression your way.": prayAgainstOlm = PrayAgainst.MELEE;
prayAgainstOlm = PrayAgainst.MELEE; lastPrayTime = System.currentTimeMillis();
lastPrayTime = System.currentTimeMillis(); break;
break; case "the great olm fires a sphere of magical power your way. your prayers have been sapped.":
case "the great olm fires a sphere of magical power your way. your prayers have been sapped.": case "the great olm fires a sphere of magical power your way.":
prayAgainstOlm = PrayAgainst.MAGIC; prayAgainstOlm = PrayAgainst.MAGIC;
lastPrayTime = System.currentTimeMillis(); lastPrayTime = System.currentTimeMillis();
break; break;
case "the great olm fires a sphere of magical power your way.": case "the great olm fires a sphere of accuracy and dexterity your way. your prayers have been sapped.":
prayAgainstOlm = PrayAgainst.MAGIC; case "the great olm fires a sphere of accuracy and dexterity your way.":
lastPrayTime = System.currentTimeMillis(); prayAgainstOlm = PrayAgainst.RANGED;
break; lastPrayTime = System.currentTimeMillis();
case "the great olm fires a sphere of accuracy and dexterity your way. your prayers have been sapped.": break;
prayAgainstOlm = PrayAgainst.RANGED; case "the great olm's left claw clenches to protect itself temporarily.":
lastPrayTime = System.currentTimeMillis(); handCripple = true;
break;
case "the great olm fires a sphere of accuracy and dexterity your way.":
prayAgainstOlm = PrayAgainst.RANGED;
lastPrayTime = System.currentTimeMillis();
break;
case "the great olm's left claw clenches to protect itself temporarily.":
HandCripple = true;
}
} }
} }
} }
private void onProjectileMoved(ProjectileMoved event) private void onProjectileSpawned(ProjectileSpawned event)
{ {
if (inRaid()) if (!inRaid())
{ {
Projectile projectile = event.getProjectile(); return;
if (projectile.getId() == ProjectileID.OLM_MAGE_ATTACK) }
{
final Projectile projectile = event.getProjectile();
switch (projectile.getId())
{
case ProjectileID.OLM_MAGE_ATTACK:
prayAgainstOlm = PrayAgainst.MAGIC; prayAgainstOlm = PrayAgainst.MAGIC;
lastPrayTime = System.currentTimeMillis(); lastPrayTime = System.currentTimeMillis();
} break;
if (projectile.getId() == ProjectileID.OLM_RANGE_ATTACK) case ProjectileID.OLM_RANGE_ATTACK:
{
prayAgainstOlm = PrayAgainst.RANGED; prayAgainstOlm = PrayAgainst.RANGED;
lastPrayTime = System.currentTimeMillis(); lastPrayTime = System.currentTimeMillis();
} break;
if (projectile.getId() == ProjectileID.OLM_ACID_TRAIL) case ProjectileID.OLM_ACID_TRAIL:
{
acidTarget = projectile.getInteracting(); acidTarget = projectile.getInteracting();
} break;
} }
} }
private void onSpotAnimationChanged(SpotAnimationChanged graphicChanged) private void onSpotAnimationChanged(SpotAnimationChanged event)
{ {
if (inRaid()) if (!inRaid())
{ {
Actor actor = graphicChanged.getActor(); return;
if (actor.getSpotAnimation() == GraphicID.OLM_BURN) }
if (!(event.getActor() instanceof Player))
{
return;
}
final Player player = (Player) event.getActor();
if (player.getSpotAnimation() == GraphicID.OLM_BURN)
{
int add = 0;
for (Victim victim : victims)
{ {
if (!burnTarget.contains(actor)) if (victim.getPlayer().getName().equals(player.getName()))
{ {
burnTarget.add(actor); add++;
} }
} }
if (add == 0)
{
victims.add(new Victim(player, Victim.Type.BURN));
}
} }
} }
private void onNpcSpawned(NpcSpawned npcSpawned) private void onNpcSpawned(NpcSpawned event)
{ {
if (inRaid()) if (inRaid())
{ {
NPC npc = npcSpawned.getNpc(); return;
switch (npc.getId()) }
{
case NpcID.TEKTON: final NPC npc = event.getNpc();
case NpcID.TEKTON_7541:
case NpcID.TEKTON_7542: switch (npc.getId())
case NpcID.TEKTON_7545: {
case NpcID.TEKTON_ENRAGED: case NpcID.TEKTON:
case NpcID.TEKTON_ENRAGED_7544: case NpcID.TEKTON_7541:
npcContainer.put(npc, new NPCContainer(npc)); case NpcID.TEKTON_7542:
tektonAttackTicks = 27; case NpcID.TEKTON_7545:
break; case NpcID.TEKTON_ENRAGED:
case NpcID.MUTTADILE: case NpcID.TEKTON_ENRAGED_7544:
case NpcID.MUTTADILE_7562: npcContainer.put(npc, new NPCContainer(npc));
case NpcID.MUTTADILE_7563: tektonAttackTicks = 27;
case NpcID.GUARDIAN: break;
case NpcID.GUARDIAN_7570: case NpcID.MUTTADILE:
npcContainer.put(npc, new NPCContainer(npc)); case NpcID.MUTTADILE_7562:
break; case NpcID.MUTTADILE_7563:
case NpcID.VANGUARD: case NpcID.GUARDIAN:
case NpcID.VANGUARD_7526: case NpcID.GUARDIAN_7570:
case NpcID.VANGUARD_7527: npcContainer.put(npc, new NPCContainer(npc));
case NpcID.VANGUARD_7528: break;
case NpcID.VANGUARD_7529: case NpcID.VANGUARD:
vanguards++; case NpcID.VANGUARD_7526:
npcContainer.put(npc, new NPCContainer(npc)); case NpcID.VANGUARD_7527:
break; case NpcID.VANGUARD_7528:
case NpcID.GREAT_OLM_LEFT_CLAW: case NpcID.VANGUARD_7529:
case NpcID.GREAT_OLM_LEFT_CLAW_7555: vanguards++;
hand = npc; npcContainer.put(npc, new NPCContainer(npc));
break; break;
} case NpcID.GREAT_OLM_LEFT_CLAW:
case NpcID.GREAT_OLM_LEFT_CLAW_7555:
hand = npc;
break;
} }
} }
private void onNpcDespawned(NpcDespawned event) private void onNpcDespawned(NpcDespawned event)
{ {
if (inRaid()) if (!inRaid())
{ {
NPC npc = event.getNpc(); return;
switch (npc.getId()) }
{
case NpcID.TEKTON: final NPC npc = event.getNpc();
case NpcID.TEKTON_7541:
case NpcID.TEKTON_7542: switch (npc.getId())
case NpcID.TEKTON_7545: {
case NpcID.TEKTON_ENRAGED: case NpcID.TEKTON:
case NpcID.TEKTON_ENRAGED_7544: case NpcID.TEKTON_7541:
case NpcID.MUTTADILE: case NpcID.TEKTON_7542:
case NpcID.MUTTADILE_7562: case NpcID.TEKTON_7545:
case NpcID.MUTTADILE_7563: case NpcID.TEKTON_ENRAGED:
case NpcID.GUARDIAN: case NpcID.TEKTON_ENRAGED_7544:
case NpcID.GUARDIAN_7570: case NpcID.MUTTADILE:
case NpcID.GUARDIAN_7571: case NpcID.MUTTADILE_7562:
case NpcID.GUARDIAN_7572: case NpcID.MUTTADILE_7563:
if (npcContainer.remove(event.getNpc()) != null && !npcContainer.isEmpty()) case NpcID.GUARDIAN:
{ case NpcID.GUARDIAN_7570:
npcContainer.remove(event.getNpc()); case NpcID.GUARDIAN_7571:
} case NpcID.GUARDIAN_7572:
break; if (npcContainer.remove(event.getNpc()) != null && !npcContainer.isEmpty())
case NpcID.VANGUARD: {
case NpcID.VANGUARD_7526: npcContainer.remove(event.getNpc());
case NpcID.VANGUARD_7527: }
case NpcID.VANGUARD_7528: break;
case NpcID.VANGUARD_7529: case NpcID.VANGUARD:
if (npcContainer.remove(event.getNpc()) != null && !npcContainer.isEmpty()) case NpcID.VANGUARD_7526:
{ case NpcID.VANGUARD_7527:
npcContainer.remove(event.getNpc()); case NpcID.VANGUARD_7528:
} case NpcID.VANGUARD_7529:
vanguards--; if (npcContainer.remove(event.getNpc()) != null && !npcContainer.isEmpty())
break; {
case NpcID.GREAT_OLM_RIGHT_CLAW_7553: npcContainer.remove(event.getNpc());
case NpcID.GREAT_OLM_RIGHT_CLAW: }
HandCripple = false; vanguards--;
break; break;
} case NpcID.GREAT_OLM_RIGHT_CLAW_7553:
case NpcID.GREAT_OLM_RIGHT_CLAW:
handCripple = false;
break;
} }
} }
@@ -449,7 +428,7 @@ public class CoxPlugin extends Plugin
sleepcount = 0; sleepcount = 0;
Olm_Heal.clear(); Olm_Heal.clear();
npcContainer.clear(); npcContainer.clear();
burnTarget.clear(); victims.clear();
Olm_NPC = null; Olm_NPC = null;
hand = null; hand = null;
prayAgainstOlm = null; prayAgainstOlm = null;
@@ -457,7 +436,8 @@ public class CoxPlugin extends Plugin
return; return;
} }
npcHandler(); handleNpcs();
handleVictims();
if (needOlm = true) if (needOlm = true)
{ {
@@ -472,57 +452,32 @@ public class CoxPlugin extends Plugin
} }
} }
if (teleportTarget != null) if (handCripple)
{
log.info(teleportTarget.getName());
Player target = (Player) teleportTarget;
client.setHintArrow(target);
teleportTicks--;
if (teleportTicks <= 0)
{
client.clearHintArrow();
teleportTarget = null;
teleportTicks = 10;
}
}
if (acidTarget != null)
{
acidTicks--;
if (acidTicks <= 0)
{
acidTarget = null;
acidTicks = 25;
}
}
if (burnTarget.size() > 0)
{
burnTicks--;
if (burnTicks <= 0)
{
burnTarget.clear();
burnTicks = 41;
}
}
if (HandCripple)
{ {
crippleTimer--; crippleTimer--;
if (crippleTimer <= 0) if (crippleTimer <= 0)
{ {
HandCripple = false; handCripple = false;
crippleTimer = 45; crippleTimer = 45;
} }
} }
if (runOlm) if (runOlm)
{ {
olmHandler(); handleOlm();
} }
} }
private void npcHandler() private void handleVictims()
{
if (victims.size() > 0)
{
victims.forEach(Victim::updateTicks);
victims.removeIf(victim -> victim.getTicks() <= 0);
}
}
private void handleNpcs()
{ {
for (NPCContainer npcs : getNpcContainer().values()) for (NPCContainer npcs : getNpcContainer().values())
{ {
@@ -605,7 +560,7 @@ public class CoxPlugin extends Plugin
} }
} }
private void olmHandler() private void handleOlm()
{ {
Olm_Crystals.clear(); Olm_Crystals.clear();
Olm_Heal.clear(); Olm_Heal.clear();
@@ -706,14 +661,6 @@ public class CoxPlugin extends Plugin
return client.getVar(Varbits.IN_RAID) == 1; return client.getVar(Varbits.IN_RAID) == 1;
} }
private void onConfigChanged(ConfigChanged configChanged)
{
if (configChanged.getGroup().equals("Cox"))
{
updateConfig();
}
}
private void updateConfig() private void updateConfig()
{ {
this.muttadile = config.muttadile(); this.muttadile = config.muttadile();

View File

@@ -34,43 +34,25 @@ import net.runelite.api.Actor;
import net.runelite.api.NPC; import net.runelite.api.NPC;
import net.runelite.api.NPCDefinition; import net.runelite.api.NPCDefinition;
@Getter(AccessLevel.PACKAGE)
class NPCContainer class NPCContainer
{ {
@Getter(AccessLevel.PACKAGE)
private NPC npc; private NPC npc;
@Getter(AccessLevel.PACKAGE)
private int npcIndex; private int npcIndex;
@Getter(AccessLevel.PACKAGE)
private String npcName; private String npcName;
@Getter(AccessLevel.PACKAGE)
private int npcSize; private int npcSize;
@Setter(AccessLevel.PACKAGE) @Setter(AccessLevel.PACKAGE)
@Getter(AccessLevel.PACKAGE)
private int ticksUntilAttack; private int ticksUntilAttack;
@Setter(AccessLevel.PACKAGE) @Setter(AccessLevel.PACKAGE)
@Getter(AccessLevel.PACKAGE)
private int intermissionPeriod; private int intermissionPeriod;
@Setter(AccessLevel.PACKAGE) @Setter(AccessLevel.PACKAGE)
@Getter(AccessLevel.PACKAGE)
private int npcSpeed; private int npcSpeed;
@Setter(AccessLevel.PACKAGE) @Setter(AccessLevel.PACKAGE)
@Getter(AccessLevel.PACKAGE)
private Actor npcInteracting; private Actor npcInteracting;
@Setter(AccessLevel.PACKAGE) @Setter(AccessLevel.PACKAGE)
@Getter(AccessLevel.PACKAGE)
private Specials specials; private Specials specials;
@Setter(AccessLevel.PACKAGE) @Setter(AccessLevel.PACKAGE)
@Getter(AccessLevel.PACKAGE)
private Attackstyle attackStyle; private Attackstyle attackStyle;

View File

@@ -0,0 +1,40 @@
package net.runelite.client.plugins.coxhelper;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import net.runelite.api.Player;
@Getter(AccessLevel.PACKAGE)
class Victim
{
private Player player;
private Type type;
private int ticks;
Victim(Player player, Type type)
{
this.player = player;
this.type = type;
this.ticks = type.getTicks();
}
void updateTicks()
{
if (ticks > 0)
{
ticks--;
}
}
@AllArgsConstructor
@Getter(AccessLevel.PACKAGE)
enum Type
{
BURN(41),
ACID(23),
TELEPORT(10);
private int ticks;
}
}

View File

@@ -24,12 +24,14 @@
*/ */
package net.runelite.client.plugins.demonicgorilla; package net.runelite.client.plugins.demonicgorilla;
import com.google.common.collect.ImmutableSet;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
@@ -54,7 +56,7 @@ import net.runelite.api.events.NpcDespawned;
import net.runelite.api.events.NpcSpawned; import net.runelite.api.events.NpcSpawned;
import net.runelite.api.events.PlayerDespawned; import net.runelite.api.events.PlayerDespawned;
import net.runelite.api.events.PlayerSpawned; import net.runelite.api.events.PlayerSpawned;
import net.runelite.api.events.ProjectileMoved; import net.runelite.api.events.ProjectileSpawned;
import net.runelite.client.callback.ClientThread; import net.runelite.client.callback.ClientThread;
import net.runelite.client.eventbus.EventBus; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
@@ -69,6 +71,8 @@ import net.runelite.client.ui.overlay.OverlayManager;
@Singleton @Singleton
public class DemonicGorillaPlugin extends Plugin public class DemonicGorillaPlugin extends Plugin
{ {
private static final Set<Integer> DEMONIC_PROJECTILES = ImmutableSet.of(ProjectileID.DEMONIC_GORILLA_RANGED, ProjectileID.DEMONIC_GORILLA_MAGIC, ProjectileID.DEMONIC_GORILLA_BOULDER);
@Inject @Inject
private Client client; private Client client;
@@ -118,7 +122,7 @@ public class DemonicGorillaPlugin extends Plugin
private void addSubscriptions() private void addSubscriptions()
{ {
eventBus.subscribe(ProjectileMoved.class, this, this::onProjectileMoved); eventBus.subscribe(ProjectileSpawned.class, this, this::onProjectileSpawned);
eventBus.subscribe(HitsplatApplied.class, this, this::onHitsplatApplied); eventBus.subscribe(HitsplatApplied.class, this, this::onHitsplatApplied);
eventBus.subscribe(GameStateChanged.class, this, this::onGameStateChanged); eventBus.subscribe(GameStateChanged.class, this, this::onGameStateChanged);
eventBus.subscribe(PlayerSpawned.class, this, this::onPlayerSpawned); eventBus.subscribe(PlayerSpawned.class, this, this::onPlayerSpawned);
@@ -175,8 +179,7 @@ public class DemonicGorillaPlugin extends Plugin
npcId == NpcID.DEMONIC_GORILLA_7149; npcId == NpcID.DEMONIC_GORILLA_7149;
} }
private void checkGorillaAttackStyleSwitch(DemonicGorilla gorilla, private void checkGorillaAttackStyleSwitch(DemonicGorilla gorilla, final DemonicGorilla.AttackStyle... protectedStyles)
final DemonicGorilla.AttackStyle... protectedStyles)
{ {
if (gorilla.getAttacksUntilSwitch() <= 0 || if (gorilla.getAttacksUntilSwitch() <= 0 ||
gorilla.getNextPosibleAttackStyles().isEmpty()) gorilla.getNextPosibleAttackStyles().isEmpty())
@@ -545,35 +548,27 @@ public class DemonicGorillaPlugin extends Plugin
} }
} }
private void onProjectileMoved(ProjectileMoved event) private void onProjectileSpawned(ProjectileSpawned event)
{ {
Projectile projectile = event.getProjectile(); final Projectile projectile = event.getProjectile();
int projectileId = projectile.getId(); final int projectileId = projectile.getId();
if (projectileId != ProjectileID.DEMONIC_GORILLA_RANGED &&
projectileId != ProjectileID.DEMONIC_GORILLA_MAGIC && if (!DEMONIC_PROJECTILES.contains(projectileId))
projectileId != ProjectileID.DEMONIC_GORILLA_BOULDER)
{ {
return; return;
} }
// The event fires once before the projectile starts moving, final WorldPoint loc = WorldPoint.fromLocal(client, projectile.getX1(), projectile.getY1(), client.getPlane());
// and we only want to check each projectile once
if (client.getGameCycle() >= projectile.getStartMovementCycle())
{
return;
}
if (projectileId == ProjectileID.DEMONIC_GORILLA_BOULDER) if (projectileId == ProjectileID.DEMONIC_GORILLA_BOULDER)
{ {
recentBoulders.add(WorldPoint.fromLocal(client, event.getPosition())); recentBoulders.add(loc);
} }
else else
{ {
WorldPoint projectileSourcePosition = WorldPoint.fromLocal(
client, projectile.getX1(), projectile.getY1(), client.getPlane());
for (DemonicGorilla gorilla : gorillas.values()) for (DemonicGorilla gorilla : gorillas.values())
{ {
if (gorilla.getNpc().getWorldLocation().distanceTo(projectileSourcePosition) == 0) if (gorilla.getNpc().getWorldLocation().distanceTo(loc) == 0)
{ {
gorilla.setRecentProjectileId(projectile.getId()); gorilla.setRecentProjectileId(projectile.getId());
} }

View File

@@ -10,8 +10,6 @@ package net.runelite.client.plugins.theatre;
import com.google.inject.Provides; import com.google.inject.Provides;
import java.awt.Color; import java.awt.Color;
import java.util.LinkedList;
import java.util.List;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import lombok.AccessLevel; import lombok.AccessLevel;
@@ -28,12 +26,9 @@ import net.runelite.api.events.NpcDefinitionChanged;
import net.runelite.api.events.NpcDespawned; import net.runelite.api.events.NpcDespawned;
import net.runelite.api.events.NpcSpawned; import net.runelite.api.events.NpcSpawned;
import net.runelite.api.events.ProjectileMoved; import net.runelite.api.events.ProjectileMoved;
import net.runelite.api.events.ProjectileSpawned;
import net.runelite.api.events.SpotAnimationChanged; import net.runelite.api.events.SpotAnimationChanged;
import net.runelite.api.events.VarbitChanged; import net.runelite.api.events.VarbitChanged;
import net.runelite.api.events.WidgetLoaded;
import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetID;
import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.EventBus; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.graphics.ModelOutlineRenderer; import net.runelite.client.graphics.ModelOutlineRenderer;
@@ -57,103 +52,55 @@ import net.runelite.client.ui.overlay.OverlayManager;
) )
@Singleton @Singleton
@Slf4j @Slf4j
@Getter
public class TheatrePlugin extends Plugin public class TheatrePlugin extends Plugin
{ {
@Getter(AccessLevel.PUBLIC)
@Setter(AccessLevel.PUBLIC)
private TheatreRoom room;
@Getter(AccessLevel.PUBLIC)
private MaidenHandler maidenHandler;
@Getter(AccessLevel.PUBLIC)
private BloatHandler bloatHandler;
@Getter(AccessLevel.PUBLIC)
private NyloHandler nyloHandler;
@Getter(AccessLevel.PUBLIC)
private SotetsegHandler sotetsegHandler;
@Getter(AccessLevel.PUBLIC)
private XarpusHandler xarpusHandler;
@Getter(AccessLevel.PUBLIC)
private VerzikHandler verzikHandler;
@Inject @Inject
private Client client; private Client client;
@Inject @Inject
private EventBus eventBus; private EventBus eventBus;
private Widget widget = null;
@Getter(AccessLevel.PUBLIC)
@Inject @Inject
private OverlayManager overlayManager; private OverlayManager overlayManager;
@Inject @Inject
private TheatreOverlay overlay; private TheatreOverlay overlay;
@Inject @Inject
private TheatreConfig config; private TheatreConfig config;
@Inject @Inject
private ModelOutlineRenderer modelOutline; private ModelOutlineRenderer modelOutline;
private BloatHandler bloatHandler;
@Getter private MaidenHandler maidenHandler;
private boolean showMaidenBloodToss; private NyloHandler nyloHandler;
@Getter private SotetsegHandler sotetsegHandler;
private boolean showMaidenBloodSpawns; @Setter(AccessLevel.PUBLIC)
@Getter private TheatreRoom room;
private boolean showNyloFreezeHighlights; private VerzikHandler verzikHandler;
@Getter private XarpusHandler xarpusHandler;
private boolean showBloatIndicator;
@Getter
private boolean showBloatHands;
@Getter
private boolean BloatFeetIndicatorRaveEdition; private boolean BloatFeetIndicatorRaveEdition;
@Getter
private boolean showBloatTimer;
@Getter
private boolean showNyloPillarHealth;
@Getter
private TheatreConfig.NYLOOPTION showNylocasExplosions;
@Getter
private boolean showNylocasAmount;
@Getter
private boolean highlightNyloAgros;
@Getter
private boolean showSotetsegAttacks;
@Getter
private boolean showSotetsegMaze;
@Getter
private boolean showSotetsegSolo;
@Getter
private Color mazeTileColour;
@Getter
private boolean showXarpusHeals;
@Getter
private boolean showXarpusTick;
@Getter
private boolean showVerzikAttacks;
@Getter
private boolean showVerzikYellows;
@Getter
private boolean showCrabTargets;
@Getter
private boolean VerzikTankTile;
@Getter
private boolean verzikRangeAttacks;
@Getter
private boolean extraTimers; private boolean extraTimers;
@Getter private boolean highlightNyloAgros;
private boolean p1attacks; private boolean p1attacks;
@Getter
private boolean p2attacks; private boolean p2attacks;
@Getter
private boolean p3attacks; private boolean p3attacks;
private boolean showBloatHands;
private boolean showBloatIndicator;
private boolean showBloatTimer;
private boolean showCrabTargets;
private boolean showMaidenBloodSpawns;
private boolean showMaidenBloodToss;
private boolean showNylocasAmount;
private boolean showNyloFreezeHighlights;
private boolean showNyloPillarHealth;
private boolean showSotetsegAttacks;
private boolean showSotetsegMaze;
private boolean showSotetsegSolo;
private boolean showVerzikAttacks;
private boolean showVerzikYellows;
private boolean showXarpusHeals;
private boolean showXarpusTick;
private boolean verzikRangeAttacks;
private boolean VerzikTankTile;
private Color mazeTileColour;
private TheatreConfig.NYLOOPTION showNylocasExplosions;
@Provides @Provides
TheatreConfig getConfig(ConfigManager configManager) TheatreConfig getConfig(ConfigManager configManager)
@@ -166,16 +113,13 @@ public class TheatrePlugin extends Plugin
{ {
updateConfig(); updateConfig();
addSubscriptions(); addSubscriptions();
room = TheatreRoom.UNKNOWN; room = TheatreRoom.UNKNOWN;
maidenHandler = new MaidenHandler(client, this, modelOutline); maidenHandler = new MaidenHandler(client, this, modelOutline);
bloatHandler = new BloatHandler(client, this); bloatHandler = new BloatHandler(client, this);
nyloHandler = new NyloHandler(client, this); nyloHandler = new NyloHandler(client, this);
sotetsegHandler = new SotetsegHandler(client, this); sotetsegHandler = new SotetsegHandler(client, this);
xarpusHandler = new XarpusHandler(client, this); xarpusHandler = new XarpusHandler(client, this);
verzikHandler = new VerzikHandler(client, this); verzikHandler = new VerzikHandler(client, this);
overlayManager.add(overlay); overlayManager.add(overlay);
} }
@@ -183,52 +127,111 @@ public class TheatrePlugin extends Plugin
protected void shutDown() protected void shutDown()
{ {
eventBus.unregister(this); eventBus.unregister(this);
maidenHandler.onStop(); maidenHandler.onStop();
maidenHandler = null; maidenHandler = null;
bloatHandler.onStop(); bloatHandler.onStop();
bloatHandler = null; bloatHandler = null;
nyloHandler.startTime = 0L; nyloHandler.startTime = 0L;
nyloHandler.onStop(); nyloHandler.onStop();
nyloHandler = null; nyloHandler = null;
sotetsegHandler.onStop(); sotetsegHandler.onStop();
sotetsegHandler = null; sotetsegHandler = null;
xarpusHandler.onStop(); xarpusHandler.onStop();
xarpusHandler = null; xarpusHandler = null;
verzikHandler.onStop(); verzikHandler.onStop();
verzikHandler = null; verzikHandler = null;
room = TheatreRoom.UNKNOWN; room = TheatreRoom.UNKNOWN;
overlayManager.remove(overlay); overlayManager.remove(overlay);
} }
private void addSubscriptions() private void addSubscriptions()
{ {
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventBus.subscribe(SpotAnimationChanged.class, this, this::onSpotAnimationChanged);
eventBus.subscribe(NpcDefinitionChanged.class, this, this::onNpcDefinitionChanged);
eventBus.subscribe(NpcSpawned.class, this, this::onNpcSpawned);
eventBus.subscribe(NpcDespawned.class, this, this::onNpcDespawned);
eventBus.subscribe(AnimationChanged.class, this, this::onAnimationChanged); eventBus.subscribe(AnimationChanged.class, this, this::onAnimationChanged);
eventBus.subscribe(ChatMessage.class, this, this::onChatMessage); eventBus.subscribe(ChatMessage.class, this, this::onChatMessage);
eventBus.subscribe(WidgetLoaded.class, this, this::onWidgetLoaded); eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventBus.subscribe(GameTick.class, this, this::onGameTick); eventBus.subscribe(GameTick.class, this, this::onGameTick);
eventBus.subscribe(GroundObjectSpawned.class, this, this::onGroundObjectSpawned); eventBus.subscribe(GroundObjectSpawned.class, this, this::onGroundObjectSpawned);
eventBus.subscribe(VarbitChanged.class, this, this::onVarbitChanged); eventBus.subscribe(NpcDefinitionChanged.class, this, this::onNpcDefinitionChanged);
eventBus.subscribe(NpcDespawned.class, this, this::onNpcDespawned);
eventBus.subscribe(NpcSpawned.class, this, this::onNpcSpawned);
eventBus.subscribe(ProjectileMoved.class, this, this::onProjectileMoved); eventBus.subscribe(ProjectileMoved.class, this, this::onProjectileMoved);
eventBus.subscribe(ProjectileSpawned.class, this, this::onProjectileSpawned);
eventBus.subscribe(SpotAnimationChanged.class, this, this::onSpotAnimationChanged);
eventBus.subscribe(VarbitChanged.class, this, this::onVarbitChanged);
} }
private void onSpotAnimationChanged(SpotAnimationChanged event) private void onAnimationChanged(AnimationChanged event)
{
if (verzikHandler != null)
{
verzikHandler.onAnimationChanged(event);
}
}
private void onChatMessage(ChatMessage event)
{ {
if (maidenHandler != null) if (maidenHandler != null)
{ {
maidenHandler.onSpotAnimationChanged(event); maidenHandler.onChatMessage(event);
}
}
private void onConfigChanged(ConfigChanged event)
{
if (!event.getGroup().equals("Theatre"))
{
return;
}
if (nyloHandler != null)
{
nyloHandler.onConfigChanged();
}
}
private void onGameTick(GameTick event)
{
if (maidenHandler != null)
{
maidenHandler.onGameTick();
}
if (bloatHandler != null)
{
bloatHandler.onGameTick();
}
if (nyloHandler != null)
{
nyloHandler.onGameTick();
}
if (sotetsegHandler != null)
{
sotetsegHandler.onGameTick();
}
if (xarpusHandler != null)
{
xarpusHandler.onGameTick();
}
if (verzikHandler != null)
{
verzikHandler.onGameTick();
}
}
private void onGroundObjectSpawned(GroundObjectSpawned event)
{
if (sotetsegHandler != null)
{
sotetsegHandler.onGroundObjectSpawned(event);
}
if (xarpusHandler != null)
{
xarpusHandler.onGroundObjectSpawned(event);
} }
} }
@@ -240,6 +243,35 @@ public class TheatrePlugin extends Plugin
} }
} }
private void onNpcDespawned(NpcDespawned event)
{
if (maidenHandler != null)
{
maidenHandler.onNpcDespawned(event);
}
if (bloatHandler != null)
{
bloatHandler.onNpcDespawned(event);
}
if (nyloHandler != null)
{
nyloHandler.onNpcDespawned(event);
}
if (sotetsegHandler != null)
{
sotetsegHandler.onNpcDespawned(event);
}
if (xarpusHandler != null)
{
xarpusHandler.onNpcDespawned(event);
}
}
private void onNpcSpawned(NpcSpawned event) private void onNpcSpawned(NpcSpawned event)
{ {
if (maidenHandler != null) if (maidenHandler != null)
@@ -274,214 +306,28 @@ public class TheatrePlugin extends Plugin
} }
private void onNpcDespawned(NpcDespawned event) private void onProjectileMoved(ProjectileMoved event)
{
if (maidenHandler != null)
{
maidenHandler.onNpcDespawned(event);
}
if (bloatHandler != null)
{
bloatHandler.onNpcDespawned(event);
}
if (nyloHandler != null)
{
nyloHandler.onNpcDespawned(event);
}
if (sotetsegHandler != null)
{
sotetsegHandler.onNpcDespawned(event);
}
if (xarpusHandler != null)
{
xarpusHandler.onNpcDespawned(event);
}
}
private void onAnimationChanged(AnimationChanged event)
{ {
if (verzikHandler != null) if (verzikHandler != null)
{ {
verzikHandler.onAnimationChanged(event); verzikHandler.onProjectileMoved(event);
} }
} }
private void onChatMessage(ChatMessage event) private void onProjectileSpawned(ProjectileSpawned event)
{
if (maidenHandler != null)
{
maidenHandler.onChatMessage(event);
}
}
private void onWidgetLoaded(WidgetLoaded event)
{
if (event.getGroupId() != WidgetID.PERFORMERS_FOR_THE_THEATRE_GROUPS_GROUP_ID && event.getGroupId() != WidgetID.PERFORMERS_FOR_THE_THEATRE_PLAYERS_GROUP_ID)
{
return;
}
if (event.getGroupId() == WidgetID.PERFORMERS_FOR_THE_THEATRE_GROUPS_GROUP_ID)
{
widget = client.getWidget(WidgetID.PERFORMERS_FOR_THE_THEATRE_GROUPS_GROUP_ID, 0);
}
if (event.getGroupId() == WidgetID.PERFORMERS_FOR_THE_THEATRE_PLAYERS_GROUP_ID)
{
widget = client.getWidget(WidgetID.PERFORMERS_FOR_THE_THEATRE_PLAYERS_GROUP_ID, 0);
}
}
private void onGameTick(GameTick event)
{
if (maidenHandler != null)
{
maidenHandler.onGameTick();
}
if (bloatHandler != null)
{
bloatHandler.onGameTick();
}
if (nyloHandler != null)
{
nyloHandler.onGameTick();
}
if (sotetsegHandler != null)
{
sotetsegHandler.onGameTick();
}
if (xarpusHandler != null)
{
xarpusHandler.onGameTick();
}
if (verzikHandler != null)
{
verzikHandler.onGameTick();
}
if (widget == null)
{
return;
}
// recheck if the widget is still active
int p_id = WidgetInfo.TO_GROUP(widget.getId());
List<Widget> widgetList = new LinkedList<>();
if (p_id == WidgetID.PERFORMERS_FOR_THE_THEATRE_GROUPS_GROUP_ID)
{
Widget w = client.getWidget(p_id, 16);
if (w == null)
{
return;
}
Widget[] ws = w.getStaticChildren();
for (Widget widget : ws)
{
Widget[] widgets = widget.getDynamicChildren();
if (widgets.length > 3)
{
widgetList.add(widgets[3]);
}
}
}
else if (p_id == WidgetID.PERFORMERS_FOR_THE_THEATRE_PLAYERS_GROUP_ID)
{
Widget w1 = client.getWidget(p_id, 26);
if (w1 != null)
{
Widget[] dChildsAccepted = w1.getDynamicChildren();
if (dChildsAccepted.length > 2)
{
for (int i = 1; i < dChildsAccepted.length; i += 11)
{
if (!dChildsAccepted[i].getText().equals("-"))
{
widgetList.add(dChildsAccepted[i]);
}
}
}
}
Widget w2 = client.getWidget(p_id, 41);
if (w2 != null)
{
Widget[] dChildsApplied = w2.getDynamicChildren();
if (dChildsApplied.length > 2)
{
for (int i = 1; i < dChildsApplied.length; i += 11)
{
if (!dChildsApplied[i].getText().equals("-"))
{
widgetList.add(dChildsApplied[i]);
}
}
}
}
}
for (Widget w : widgetList)
{
String wtext = w.getText();
if (client.isFriended(wtext, false))
{
w.setTextColor(Color.green.getRGB());
continue;
}
for (int i = 0; i < client.getIgnoreCount(); i++)
{
String name = client.getIgnores()[i].getName();
if (name.replace('\u00A0', ' ').equals(wtext))
{
w.setTextColor(Color.red.getRGB());
break;
}
}
}
widget = null;
}
private void onGroundObjectSpawned(GroundObjectSpawned event)
{ {
if (sotetsegHandler != null) if (sotetsegHandler != null)
{ {
sotetsegHandler.onGroundObjectSpawned(event); sotetsegHandler.onProjectileSpawned(event);
}
if (xarpusHandler != null)
{
xarpusHandler.onGroundObjectSpawned(event);
} }
} }
private void onConfigChanged(ConfigChanged event) private void onSpotAnimationChanged(SpotAnimationChanged event)
{ {
if (!event.getGroup().equals("Theatre")) if (maidenHandler != null)
{ {
return; maidenHandler.onSpotAnimationChanged(event);
}
if (nyloHandler != null)
{
nyloHandler.onConfigChanged();
} }
} }
@@ -498,19 +344,6 @@ public class TheatrePlugin extends Plugin
} }
} }
private void onProjectileMoved(ProjectileMoved event)
{
if (sotetsegHandler != null)
{
sotetsegHandler.onProjectileMoved(event);
}
if (verzikHandler != null)
{
verzikHandler.onProjectileMoved(event);
}
}
private void updateConfig() private void updateConfig()
{ {
this.showMaidenBloodToss = config.showMaidenBloodToss(); this.showMaidenBloodToss = config.showMaidenBloodToss();

View File

@@ -6,9 +6,11 @@ import java.awt.Graphics2D;
import java.awt.Polygon; import java.awt.Polygon;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.Getter; import lombok.Getter;
import net.runelite.api.Client; import net.runelite.api.Client;
@@ -22,7 +24,7 @@ import net.runelite.api.coords.WorldPoint;
import net.runelite.api.events.GroundObjectSpawned; import net.runelite.api.events.GroundObjectSpawned;
import net.runelite.api.events.NpcDespawned; import net.runelite.api.events.NpcDespawned;
import net.runelite.api.events.NpcSpawned; import net.runelite.api.events.NpcSpawned;
import net.runelite.api.events.ProjectileMoved; import net.runelite.api.events.ProjectileSpawned;
import net.runelite.client.plugins.theatre.RoomHandler; import net.runelite.client.plugins.theatre.RoomHandler;
import net.runelite.client.plugins.theatre.TheatreConstant; import net.runelite.client.plugins.theatre.TheatreConstant;
import net.runelite.client.plugins.theatre.TheatrePlugin; import net.runelite.client.plugins.theatre.TheatrePlugin;
@@ -43,7 +45,7 @@ public class SotetsegHandler extends RoomHandler
private final List<WorldPoint> blackUnderworld = new ArrayList<>(); private final List<WorldPoint> blackUnderworld = new ArrayList<>();
private final List<WorldPoint> redUnderworld = new ArrayList<>(); private final List<WorldPoint> redUnderworld = new ArrayList<>();
private final List<Point> gridPath = new ArrayList<>(); private final List<Point> gridPath = new ArrayList<>();
private final Map<Projectile, WorldPoint> soteyProjectiles = new HashMap<>(); private final Set<Projectile> soteyProjectiles = new HashSet<>();
private NPC npc; private NPC npc;
public SotetsegHandler(final Client client, final TheatrePlugin plugin) public SotetsegHandler(final Client client, final TheatrePlugin plugin)
@@ -120,7 +122,7 @@ public class SotetsegHandler extends RoomHandler
{ {
Map<Projectile, String> projectileMap = new HashMap<>(); Map<Projectile, String> projectileMap = new HashMap<>();
for (Projectile p : soteyProjectiles.keySet()) for (Projectile p : soteyProjectiles)
{ {
final int ticksRemaining = p.getRemainingCycles() / 30; final int ticksRemaining = p.getRemainingCycles() / 30;
int id = p.getId(); int id = p.getId();
@@ -140,15 +142,14 @@ public class SotetsegHandler extends RoomHandler
} }
} }
public void onProjectileMoved(ProjectileMoved event) public void onProjectileSpawned(ProjectileSpawned event)
{ {
Projectile projectile = event.getProjectile(); final Projectile projectile = event.getProjectile();
//1604 ball //1604 ball
if (event.getPosition().getX() == playerX && event.getPosition().getY() == playerY || event.getProjectile().getId() == 1604) if (projectile.getId() == 1604 && projectile.getInteracting() == client.getLocalPlayer())
{ {
WorldPoint p = WorldPoint.fromLocal(client, event.getPosition()); soteyProjectiles.add(projectile);
soteyProjectiles.put(projectile, p);
} }
} }
@@ -241,7 +242,7 @@ public class SotetsegHandler extends RoomHandler
//Remove projectiles that are about to die //Remove projectiles that are about to die
if (!soteyProjectiles.isEmpty()) if (!soteyProjectiles.isEmpty())
{ {
soteyProjectiles.keySet().removeIf(p -> p.getRemainingCycles() < 1); soteyProjectiles.removeIf(p -> p.getRemainingCycles() <= 0);
} }
boolean sotetsegFighting = false; boolean sotetsegFighting = false;