From de671a931cc10a140cdb00742ad2973a9c2b04df Mon Sep 17 00:00:00 2001 From: Ganom Date: Thu, 1 Aug 2019 01:27:02 -0400 Subject: [PATCH] theatre: Use projectile spawned instead of moved, and remove broken stuff. --- .../demonicgorilla/DemonicGorillaPlugin.java | 3 +- .../client/plugins/theatre/TheatrePlugin.java | 453 ++++++------------ .../theatre/rooms/SotetsegHandler.java | 19 +- 3 files changed, 154 insertions(+), 321 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/demonicgorilla/DemonicGorillaPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/demonicgorilla/DemonicGorillaPlugin.java index 83530a4c88..94a4237d59 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/demonicgorilla/DemonicGorillaPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/demonicgorilla/DemonicGorillaPlugin.java @@ -179,8 +179,7 @@ public class DemonicGorillaPlugin extends Plugin npcId == NpcID.DEMONIC_GORILLA_7149; } - private void checkGorillaAttackStyleSwitch(DemonicGorilla gorilla, - final DemonicGorilla.AttackStyle... protectedStyles) + private void checkGorillaAttackStyleSwitch(DemonicGorilla gorilla, final DemonicGorilla.AttackStyle... protectedStyles) { if (gorilla.getAttacksUntilSwitch() <= 0 || gorilla.getNextPosibleAttackStyles().isEmpty()) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/theatre/TheatrePlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/theatre/TheatrePlugin.java index 142d40e982..2f9fe2db68 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/theatre/TheatrePlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/theatre/TheatrePlugin.java @@ -10,8 +10,6 @@ package net.runelite.client.plugins.theatre; import com.google.inject.Provides; import java.awt.Color; -import java.util.LinkedList; -import java.util.List; import javax.inject.Inject; import javax.inject.Singleton; import lombok.AccessLevel; @@ -28,12 +26,9 @@ import net.runelite.api.events.NpcDefinitionChanged; import net.runelite.api.events.NpcDespawned; 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.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.eventbus.EventBus; import net.runelite.client.graphics.ModelOutlineRenderer; @@ -57,103 +52,55 @@ import net.runelite.client.ui.overlay.OverlayManager; ) @Singleton @Slf4j +@Getter 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 private Client client; - @Inject private EventBus eventBus; - - private Widget widget = null; - - @Getter(AccessLevel.PUBLIC) @Inject private OverlayManager overlayManager; - @Inject private TheatreOverlay overlay; - @Inject private TheatreConfig config; - @Inject private ModelOutlineRenderer modelOutline; - - @Getter - private boolean showMaidenBloodToss; - @Getter - private boolean showMaidenBloodSpawns; - @Getter - private boolean showNyloFreezeHighlights; - @Getter - private boolean showBloatIndicator; - @Getter - private boolean showBloatHands; - @Getter + private BloatHandler bloatHandler; + private MaidenHandler maidenHandler; + private NyloHandler nyloHandler; + private SotetsegHandler sotetsegHandler; + @Setter(AccessLevel.PUBLIC) + private TheatreRoom room; + private VerzikHandler verzikHandler; + private XarpusHandler xarpusHandler; 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; - @Getter + private boolean highlightNyloAgros; private boolean p1attacks; - @Getter private boolean p2attacks; - @Getter 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 TheatreConfig getConfig(ConfigManager configManager) @@ -166,16 +113,13 @@ public class TheatrePlugin extends Plugin { updateConfig(); addSubscriptions(); - room = TheatreRoom.UNKNOWN; - maidenHandler = new MaidenHandler(client, this, modelOutline); bloatHandler = new BloatHandler(client, this); nyloHandler = new NyloHandler(client, this); sotetsegHandler = new SotetsegHandler(client, this); xarpusHandler = new XarpusHandler(client, this); verzikHandler = new VerzikHandler(client, this); - overlayManager.add(overlay); } @@ -183,52 +127,111 @@ public class TheatrePlugin extends Plugin protected void shutDown() { eventBus.unregister(this); - maidenHandler.onStop(); maidenHandler = null; - bloatHandler.onStop(); bloatHandler = null; - nyloHandler.startTime = 0L; nyloHandler.onStop(); nyloHandler = null; - sotetsegHandler.onStop(); sotetsegHandler = null; - xarpusHandler.onStop(); xarpusHandler = null; - verzikHandler.onStop(); verzikHandler = null; - room = TheatreRoom.UNKNOWN; - overlayManager.remove(overlay); } 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(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(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(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) { - 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) { if (maidenHandler != null) @@ -274,214 +306,28 @@ 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 onAnimationChanged(AnimationChanged event) + private void onProjectileMoved(ProjectileMoved event) { if (verzikHandler != null) { - verzikHandler.onAnimationChanged(event); + verzikHandler.onProjectileMoved(event); } } - private void onChatMessage(ChatMessage 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 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) + private void onProjectileSpawned(ProjectileSpawned event) { 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; - } - - if (nyloHandler != null) - { - nyloHandler.onConfigChanged(); + maidenHandler.onSpotAnimationChanged(event); } } @@ -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() { this.showMaidenBloodToss = config.showMaidenBloodToss(); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/theatre/rooms/SotetsegHandler.java b/runelite-client/src/main/java/net/runelite/client/plugins/theatre/rooms/SotetsegHandler.java index ae6aabfcf3..8d792afc60 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/theatre/rooms/SotetsegHandler.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/theatre/rooms/SotetsegHandler.java @@ -6,9 +6,11 @@ import java.awt.Graphics2D; import java.awt.Polygon; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Set; import lombok.AccessLevel; import lombok.Getter; 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.NpcDespawned; 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.TheatreConstant; import net.runelite.client.plugins.theatre.TheatrePlugin; @@ -43,7 +45,7 @@ public class SotetsegHandler extends RoomHandler private final List blackUnderworld = new ArrayList<>(); private final List redUnderworld = new ArrayList<>(); private final List gridPath = new ArrayList<>(); - private final Map soteyProjectiles = new HashMap<>(); + private final Set soteyProjectiles = new HashSet<>(); private NPC npc; public SotetsegHandler(final Client client, final TheatrePlugin plugin) @@ -120,7 +122,7 @@ public class SotetsegHandler extends RoomHandler { Map projectileMap = new HashMap<>(); - for (Projectile p : soteyProjectiles.keySet()) + for (Projectile p : soteyProjectiles) { final int ticksRemaining = p.getRemainingCycles() / 30; 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 - 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.put(projectile, p); + soteyProjectiles.add(projectile); } } @@ -241,7 +242,7 @@ public class SotetsegHandler extends RoomHandler //Remove projectiles that are about to die if (!soteyProjectiles.isEmpty()) { - soteyProjectiles.keySet().removeIf(p -> p.getRemainingCycles() < 1); + soteyProjectiles.removeIf(p -> p.getRemainingCycles() <= 0); } boolean sotetsegFighting = false;