theatre: Use projectile spawned instead of moved, and remove broken stuff.

This commit is contained in:
Ganom
2019-08-01 01:27:02 -04:00
parent 40114b528d
commit de671a931c
3 changed files with 154 additions and 321 deletions

View File

@@ -179,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())

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;