Remove
This commit is contained in:
@@ -1,68 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019. PKLite - All Rights Reserved
|
||||
* Unauthorized modification, distribution, or possession of this source file, via any medium is strictly prohibited.
|
||||
* Proprietary and confidential. Refer to PKLite License file for more information on
|
||||
* full terms of this copyright and to determine what constitutes authorized use.
|
||||
* Written by PKLite(ST0NEWALL, others) <stonewall@thots.cc.usa>, 2019
|
||||
*
|
||||
*/
|
||||
|
||||
package net.runelite.client.plugins.freezetimers;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.runelite.api.Actor;
|
||||
import net.runelite.client.util.Text;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class Barrage extends Spell
|
||||
{
|
||||
|
||||
|
||||
@Getter
|
||||
public static final long DURATION = 20000;
|
||||
private long remainingTime;
|
||||
@Getter
|
||||
private boolean isFinished;
|
||||
|
||||
|
||||
public Barrage(Actor affectedTarget, Actor caster)
|
||||
{
|
||||
super(affectedTarget, caster);
|
||||
}
|
||||
|
||||
public long getRemainingTime()
|
||||
{
|
||||
long elapsedTime = System.currentTimeMillis() - this.startTime;
|
||||
if (getDURATION() > elapsedTime)
|
||||
{
|
||||
return getDURATION() - elapsedTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.isFinished = true;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (o instanceof Barrage)
|
||||
{
|
||||
Barrage barrage = (Barrage) o;
|
||||
if (Text.standardize(this.getAffectedTarget().getName()).equals(Text.standardize(((Barrage) o)
|
||||
.getAffectedTarget().getName())) && this.getStartTime() == ((Barrage) o).getStartTime())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
package net.runelite.client.plugins.freezetimers;
|
||||
|
||||
import java.awt.Color;
|
||||
import net.runelite.client.config.Config;
|
||||
import net.runelite.client.config.ConfigGroup;
|
||||
import net.runelite.client.config.ConfigItem;
|
||||
|
||||
@ConfigGroup("freezetimers")
|
||||
public interface FreezeTimersConfig extends Config
|
||||
{
|
||||
|
||||
@ConfigItem(
|
||||
position = 0,
|
||||
keyName = "freezeenable",
|
||||
name = "Enable PvP freeze timers",
|
||||
description = "Configures whether or not to show freeze timers."
|
||||
)
|
||||
default boolean EnableFreezeTimers()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 1,
|
||||
keyName = "tilehighlight",
|
||||
name = "Frozen opponent tile highlighting",
|
||||
description = "Configures whether or not to highlight tiles frozen opponents are standing on."
|
||||
)
|
||||
default boolean drawTiles()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 2,
|
||||
keyName = "timercolor",
|
||||
name = "Freeze Timer Color",
|
||||
description = "Color of freeze timer"
|
||||
)
|
||||
default Color FreezeTimerColor()
|
||||
{
|
||||
return new Color(0, 184, 212);
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 3,
|
||||
keyName = "spellIcon",
|
||||
name = "Show spell icon",
|
||||
description = "Shows the spell icon for the freeze spell affecting the target"
|
||||
)
|
||||
default boolean spellIcon()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 4,
|
||||
keyName = "refreezeTimer",
|
||||
name = "Refreeze Timer",
|
||||
description = "Show a timer that counts up until the target can be refrozen"
|
||||
)
|
||||
default boolean refreezeTimer()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 5,
|
||||
keyName = "refreezeTimerColor",
|
||||
name = "Refreeze color",
|
||||
description = "The color for the timer that counts until the target can be refrozen"
|
||||
)
|
||||
default Color RefreezeTimerColor()
|
||||
{
|
||||
return Color.red;
|
||||
}
|
||||
|
||||
@ConfigItem(position = 6, keyName = "tbtimer", name = "Tele Block Timer", description = "Enables tele block timer")
|
||||
default boolean TBTimer() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigItem(position = 7, keyName = "timerpos", name = "Freeze Timer Position", description = "Position of freeze timer")
|
||||
default int FreezeTimerPos() {
|
||||
return 80;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,200 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019. PKLite - All Rights Reserved
|
||||
* Unauthorized modification, distribution, or possession of this source file, via any medium is strictly prohibited.
|
||||
* Proprietary and confidential. Refer to PKLite License file for more information on
|
||||
* full terms of this copyright and to determine what constitutes authorized use.
|
||||
* Written by PKLite(ST0NEWALL, others) <stonewall@thots.cc.usa>, 2019
|
||||
*
|
||||
*/
|
||||
|
||||
package net.runelite.client.plugins.freezetimers;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.font.TextLayout;
|
||||
import java.awt.image.*;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import net.runelite.api.*;
|
||||
import net.runelite.client.game.SpriteManager;
|
||||
import net.runelite.client.ui.FontManager;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
import net.runelite.client.ui.overlay.OverlayPriority;
|
||||
import net.runelite.client.ui.overlay.OverlayUtil;
|
||||
|
||||
@Singleton
|
||||
public class FreezeTimersOverlay extends Overlay
|
||||
{
|
||||
private final FreezeTimersService FreezeTimersService;
|
||||
private final FreezeTimersConfig config;
|
||||
private final FreezeTimersPlugin plugin;
|
||||
private final SpriteManager spriteManager;
|
||||
private final Client client;
|
||||
|
||||
@Inject
|
||||
private FreezeTimersOverlay(FreezeTimersConfig config, FreezeTimersService FreezeTimersService, FreezeTimersPlugin plugin, Client client, SpriteManager spriteManager)
|
||||
{
|
||||
this.config = config;
|
||||
this.FreezeTimersService = FreezeTimersService;
|
||||
this.plugin = plugin;
|
||||
this.client = client;
|
||||
this.spriteManager = spriteManager;
|
||||
setPosition(OverlayPosition.DYNAMIC);
|
||||
setPriority(OverlayPriority.MED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension render(Graphics2D graphics)
|
||||
{
|
||||
if (!config.EnableFreezeTimers())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
FreezeTimersService.forEachPlayer((player, color) -> renderPlayerOverlay(graphics, player, color));
|
||||
return null;
|
||||
}
|
||||
|
||||
private void renderPlayerOverlay(Graphics2D graphics, Player actor, Color color)
|
||||
{
|
||||
int timer = 0;
|
||||
String name = actor.getName();
|
||||
int freezetype = plugin.freezetype(name);
|
||||
boolean frozenoverlay = false;
|
||||
int offset = 5;
|
||||
long dtime = plugin.opponentfreezetime(name);
|
||||
long tbed = plugin.istbed(name);
|
||||
Point textLocation = null;
|
||||
HeadIcon headIcon = actor.getOverheadIcon();
|
||||
int freezetime = 0;
|
||||
if (freezetype == 1 || freezetype == 4)
|
||||
{
|
||||
freezetime = 5000;
|
||||
}
|
||||
else if (freezetype == 2 || freezetype == 5)
|
||||
{
|
||||
freezetime = 10000;
|
||||
}
|
||||
else if (freezetype == 3 || freezetype == 6)
|
||||
{
|
||||
freezetime = 15000;
|
||||
}
|
||||
else if (freezetype == 7)
|
||||
{
|
||||
freezetime = 20000;
|
||||
}
|
||||
else if (freezetype == 8)
|
||||
{
|
||||
freezetime = 2500;
|
||||
}
|
||||
else if (freezetype == 9)
|
||||
{
|
||||
freezetime = 5000;
|
||||
}
|
||||
else if (freezetype == 10)
|
||||
{
|
||||
freezetime = 7500;
|
||||
}
|
||||
|
||||
long currenttime = System.currentTimeMillis();
|
||||
long timediff = currenttime - dtime;
|
||||
timer = (freezetime - (int) timediff) / 1000;
|
||||
|
||||
if (timediff < freezetime)
|
||||
{
|
||||
// if the freezetimer is still active. . .
|
||||
textLocation = actor.getCanvasTextLocation(graphics, String.valueOf((timer)), offset);
|
||||
textLocation = new Point(textLocation.getX(), textLocation.getY() - config.FreezeTimerPos());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (timediff < freezetime + 3000)
|
||||
{
|
||||
timer = Math.abs(timer);
|
||||
timer += 1;
|
||||
if (config.refreezeTimer())
|
||||
{
|
||||
textLocation = actor.getCanvasTextLocation(graphics, String.valueOf((timer)), offset);
|
||||
textLocation = new Point(textLocation.getX(), textLocation.getY() - config.FreezeTimerPos());
|
||||
graphics.setFont(FontManager.getRunescapeBoldFont());
|
||||
if (headIcon != null)
|
||||
{
|
||||
textLocation = new Point(textLocation.getX() + 10, textLocation.getY() + 5);
|
||||
}
|
||||
frozenoverlay = true;
|
||||
OverlayUtil.renderTextLocation(graphics, textLocation, String.valueOf((timer)), config.RefreezeTimerColor());
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
plugin.deleteopponent(name);
|
||||
}
|
||||
}
|
||||
|
||||
if (textLocation != null)
|
||||
{
|
||||
BufferedImage clanchatImage = plugin.GetFreezeIcon(freezetype - 1);
|
||||
|
||||
if (clanchatImage != null)
|
||||
{
|
||||
int width = clanchatImage.getWidth();
|
||||
int textHeight = graphics.getFontMetrics().getHeight() - graphics.getFontMetrics().getMaxDescent();
|
||||
Point imageLocation = new Point(textLocation.getX() - width, ((textLocation.getY() -
|
||||
graphics.getFontMetrics().getHeight()) + 10));
|
||||
graphics.setFont(FontManager.getRunescapeFont());
|
||||
// graphics.setStroke(new BasicStroke(3));
|
||||
|
||||
if (config.spellIcon())
|
||||
{
|
||||
frozenoverlay = true;
|
||||
// graphics.drawOval(imageLocation.getX(), imageLocation.getY(), clanchatImage.getWidth(), clanchatImage.getHeight());
|
||||
OverlayUtil.renderImageLocation(graphics, imageLocation, clanchatImage);
|
||||
OverlayUtil.renderTextLocation(graphics, textLocation, String.valueOf(timer), color);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
graphics.setColor(Color.cyan);
|
||||
graphics.drawOval(textLocation.getX() - 3, textLocation.getY() - 15, clanchatImage.getWidth(),
|
||||
graphics.getFontMetrics().getHeight());
|
||||
graphics.setColor(Color.blue);
|
||||
graphics.fillOval(textLocation.getX() - 3, textLocation.getY() - 15, clanchatImage.getWidth(),
|
||||
graphics.getFontMetrics().getHeight());
|
||||
|
||||
OverlayUtil.renderTextLocation(graphics, textLocation, String.valueOf(timer), Color.WHITE);
|
||||
}
|
||||
}
|
||||
if (config.TBTimer()) {
|
||||
if (tbed > 0) {
|
||||
int type = plugin.tbtype(name);
|
||||
int tbexpiry;
|
||||
if (type > 0) {
|
||||
if (type == 1) {
|
||||
tbexpiry = 300000;
|
||||
} else if (type == 2) {
|
||||
tbexpiry = 150000;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
long tbtime = currenttime - tbed;
|
||||
int tbtimer = (tbexpiry - (int) tbtime) / 1000;
|
||||
if (tbtime < tbexpiry) {
|
||||
textLocation = actor.getCanvasTextLocation(graphics, Integer.toString(tbtimer), actor.getLogicalHeight() + config.FreezeTimerPos());
|
||||
if (frozenoverlay) {
|
||||
textLocation = new Point(textLocation.getX() + 40, textLocation.getY() - config.FreezeTimerPos());
|
||||
} else {
|
||||
textLocation = new Point(textLocation.getX(), textLocation.getY() - config.FreezeTimerPos());
|
||||
}
|
||||
} else {
|
||||
plugin.deletetb(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,464 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019. PKLite - All Rights Reserved
|
||||
* Unauthorized modification, distribution, or possession of this source file, via any medium is strictly prohibited.
|
||||
* Proprietary and confidential. Refer to PKLite License file for more information on
|
||||
* full terms of this copyright and to determine what constitutes authorized use.
|
||||
* Written by PKLite(ST0NEWALL, others) <stonewall@thots.cc.usa>, 2019
|
||||
*
|
||||
*/
|
||||
|
||||
package net.runelite.client.plugins.freezetimers;
|
||||
|
||||
import net.runelite.api.events.*;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
import com.google.inject.Provides;
|
||||
import javax.inject.Inject;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.runelite.api.*;
|
||||
|
||||
import net.runelite.api.coords.WorldPoint;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.game.SpriteManager;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.plugins.PluginType;
|
||||
import net.runelite.client.ui.overlay.OverlayManager;
|
||||
import net.runelite.client.util.ImageUtil;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "Freeze Timers",
|
||||
description = "PVP Freeze Timers",
|
||||
type = PluginType.PVP,
|
||||
tags = {"PvP", "Freeze", "Timers", "pklite"}
|
||||
)
|
||||
public class FreezeTimersPlugin extends Plugin
|
||||
{
|
||||
@Inject
|
||||
private OverlayManager overlayManager;
|
||||
|
||||
@Inject
|
||||
private FreezeTimersConfig config;
|
||||
|
||||
@Inject
|
||||
private FreezeTimersOverlay FreezeTimersOverlay;
|
||||
|
||||
@Inject
|
||||
private FreezeTimersTileOverlay FreezeTimersTileOverlay;
|
||||
|
||||
@Inject
|
||||
private Client client;
|
||||
|
||||
@Inject
|
||||
private SpriteManager spriteManager;
|
||||
|
||||
@Provides
|
||||
FreezeTimersConfig provideConfig(ConfigManager configManager)
|
||||
{
|
||||
return configManager.getConfig(FreezeTimersConfig.class);
|
||||
}
|
||||
|
||||
private static final int[] FREEZE_ICONS =
|
||||
{
|
||||
SpriteID.SPELL_BIND,
|
||||
SpriteID.SPELL_SNARE,
|
||||
SpriteID.SPELL_ENTANGLE,
|
||||
SpriteID.SPELL_ICE_RUSH,
|
||||
SpriteID.SPELL_ICE_BURST,
|
||||
SpriteID.SPELL_ICE_BLITZ,
|
||||
SpriteID.SPELL_ICE_BARRAGE,
|
||||
SpriteID.SPELL_BIND,
|
||||
SpriteID.SPELL_SNARE,
|
||||
SpriteID.SPELL_ENTANGLE,
|
||||
SpriteID.SPELL_TELE_BLOCK
|
||||
};
|
||||
|
||||
private static final Dimension FREEZE_ICON_DIMENSION = new Dimension(25, 25);
|
||||
private static final Color FREEZE_ICON_OUTLINE_COLOR = new Color(33, 33, 33);
|
||||
private final BufferedImage[] FreezeIcons = new BufferedImage[FREEZE_ICONS.length];
|
||||
|
||||
private final int SPLASH_ID = 85;
|
||||
Map<String, Long> tbedthings = new HashMap<>();
|
||||
Map<String, Integer> tbtypes = new HashMap<>();
|
||||
Map<String, Spell> testMap = new HashMap<String, Spell>();
|
||||
Map<String, Long> frozenthings = new HashMap<String, Long>();
|
||||
Map<String, WorldPoint> frozenthingpoints = new HashMap<String, WorldPoint>();
|
||||
Map<String, Integer> freezetype = new HashMap<String, Integer>();
|
||||
Map<Integer, Integer> magexp = new HashMap<Integer, Integer>();
|
||||
int lastxp;
|
||||
int ticks;
|
||||
int currticks;
|
||||
String currtarget;
|
||||
String spell;
|
||||
|
||||
|
||||
@Subscribe
|
||||
public void onGameStateChanged(GameStateChanged gameStateChanged) {
|
||||
if (gameStateChanged.getGameState() == GameState.LOGGED_IN) {
|
||||
loadFreezeIcons();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void startUp() throws Exception {
|
||||
overlayManager.add(FreezeTimersOverlay);
|
||||
overlayManager.add(FreezeTimersTileOverlay);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void shutDown() throws Exception {
|
||||
overlayManager.remove(FreezeTimersOverlay);
|
||||
overlayManager.remove(FreezeTimersTileOverlay);
|
||||
frozenthings.clear();
|
||||
frozenthingpoints.clear();
|
||||
tbedthings.clear();
|
||||
tbtypes.clear();
|
||||
}
|
||||
|
||||
|
||||
@Subscribe
|
||||
public void onMenuOptionClicked(MenuOptionClicked event)
|
||||
{
|
||||
if (event.getMenuTarget().contains("->"))
|
||||
{
|
||||
final Pattern spattern = Pattern.compile(">(.+?)</col>");
|
||||
final Pattern ppattern = Pattern.compile("> <col=ffffff>(.+?)<col=");
|
||||
final Matcher smatch = spattern.matcher(event.getMenuTarget());
|
||||
final Matcher pmatch = ppattern.matcher(event.getMenuTarget());
|
||||
|
||||
if (smatch.find() && smatch.group(1) != null &&
|
||||
pmatch.find() && pmatch.group(1) != null)
|
||||
{
|
||||
currticks = ticks;
|
||||
spell = smatch.group(1);
|
||||
currtarget = pmatch.group(1).replace(" ", " ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onExperienceChanged(ExperienceChanged event)
|
||||
{
|
||||
if (event.getSkill() == Skill.MAGIC)
|
||||
{
|
||||
final int xp = client.getSkillExperience(Skill.MAGIC);
|
||||
int gains = xp - lastxp;
|
||||
lastxp = xp;
|
||||
if (!magexp.containsKey(ticks))
|
||||
{
|
||||
magexp.clear();
|
||||
magexp.put(ticks, gains);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
private void onAnimationChanged(AnimationChanged event)
|
||||
{
|
||||
Logger l = client.getLogger();
|
||||
final Actor subject = event.getActor();
|
||||
final Actor target = subject.getInteracting();
|
||||
|
||||
if (subject.getAnimation() == 1979)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (target.getGraphic() == SPLASH_ID || target.getGraphic() != -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (frozenthings.containsKey(target.getName()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
testMap.put(target.getName(), new Barrage(target, subject));
|
||||
freezetype.put(target.getName(), 7);
|
||||
frozenthings.put(target.getName(), System.currentTimeMillis());
|
||||
frozenthingpoints.put(target.getName(), target.getWorldLocation());
|
||||
|
||||
}
|
||||
catch (NullPointerException e)
|
||||
{
|
||||
//no
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Subscribe
|
||||
public void onGameTick(GameTick event)
|
||||
{
|
||||
int xp = 0;
|
||||
boolean praymage = false;
|
||||
if (magexp.containsKey(ticks))
|
||||
{
|
||||
xp = magexp.get(ticks);
|
||||
}
|
||||
if (xp > 0 && currtarget != null)
|
||||
{
|
||||
if (frozenthings.containsKey(currtarget))
|
||||
{
|
||||
currtarget = null;
|
||||
return;
|
||||
}
|
||||
WorldPoint targetPosition = null;
|
||||
for (Player player : client.getPlayers())
|
||||
{
|
||||
if (player == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String playerName = player.getName();
|
||||
if (playerName.equals(currtarget))
|
||||
{
|
||||
if (player.getOverheadIcon() != null)
|
||||
{
|
||||
if (player.getOverheadIcon().equals(HeadIcon.MAGIC))
|
||||
{
|
||||
praymage = true;
|
||||
}
|
||||
}
|
||||
targetPosition = player.getWorldLocation();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (targetPosition != null)
|
||||
{
|
||||
if (spell.equals("Bind") && xp > 30)
|
||||
{
|
||||
frozenthings.put(currtarget, System.currentTimeMillis());
|
||||
frozenthingpoints.put(currtarget, targetPosition);
|
||||
if (praymage)
|
||||
{
|
||||
freezetype.put(currtarget, 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
freezetype.put(currtarget, 1);
|
||||
}
|
||||
}
|
||||
else if (spell.equals("Snare") && xp > 60)
|
||||
{
|
||||
frozenthings.put(currtarget, System.currentTimeMillis());
|
||||
frozenthingpoints.put(currtarget, targetPosition);
|
||||
if (praymage)
|
||||
{
|
||||
freezetype.put(currtarget, 9);
|
||||
}
|
||||
else
|
||||
{
|
||||
freezetype.put(currtarget, 2);
|
||||
}
|
||||
}
|
||||
else if (spell.equals("Entangle") && xp >= 89)
|
||||
{
|
||||
frozenthings.put(currtarget, System.currentTimeMillis());
|
||||
frozenthingpoints.put(currtarget, targetPosition);
|
||||
if (praymage)
|
||||
{
|
||||
freezetype.put(currtarget, 10);
|
||||
}
|
||||
else
|
||||
{
|
||||
freezetype.put(currtarget, 3);
|
||||
}
|
||||
}
|
||||
else if (spell.equals("Ice Rush") && xp > 34)
|
||||
{
|
||||
frozenthings.put(currtarget, System.currentTimeMillis());
|
||||
frozenthingpoints.put(currtarget, targetPosition);
|
||||
freezetype.put(currtarget, 4);
|
||||
}
|
||||
else if (spell.equals("Ice Burst") && xp > 40)
|
||||
{
|
||||
frozenthings.put(currtarget, System.currentTimeMillis());
|
||||
frozenthingpoints.put(currtarget, targetPosition);
|
||||
freezetype.put(currtarget, 5);
|
||||
}
|
||||
else if (spell.equals("Ice Blitz") && xp > 46)
|
||||
{
|
||||
frozenthings.put(currtarget, System.currentTimeMillis());
|
||||
frozenthingpoints.put(currtarget, targetPosition);
|
||||
freezetype.put(currtarget, 6);
|
||||
}
|
||||
else if (spell.equals("Ice Barrage") && xp > 52)
|
||||
{
|
||||
Barrage barrage = new Barrage(client.getLocalPlayer().getInteracting(), client.getLocalPlayer());
|
||||
testMap.put(currtarget, barrage);
|
||||
frozenthings.put(currtarget, System.currentTimeMillis());
|
||||
frozenthingpoints.put(currtarget, targetPosition);
|
||||
freezetype.put(currtarget, 7);
|
||||
}
|
||||
} else if (spell.equals("Tele Block") && xp == 95) {
|
||||
if (config.TBTimer()) {
|
||||
if (praymage) {
|
||||
tbtypes.put(currtarget, 2);
|
||||
} else {
|
||||
tbtypes.put(currtarget, 1);
|
||||
}
|
||||
tbedthings.put(currtarget, System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (currtarget != null && ticks > currticks + 1)
|
||||
{
|
||||
Player local = client.getLocalPlayer();
|
||||
Actor interacting = local.getInteracting();
|
||||
if (interacting != null)
|
||||
{
|
||||
if (!interacting.getName().equals(currtarget))
|
||||
{
|
||||
currtarget = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
currtarget = null;
|
||||
}
|
||||
}
|
||||
ticks++;
|
||||
}
|
||||
|
||||
public long opponentfreezetime(String name)
|
||||
{
|
||||
if (frozenthings.containsKey(name))
|
||||
{
|
||||
return frozenthings.get(name);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public WorldPoint playerpos(String name)
|
||||
{
|
||||
if (frozenthingpoints.containsKey(name))
|
||||
{
|
||||
return frozenthingpoints.get(name);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void updatePosition(String name, WorldPoint point)
|
||||
{
|
||||
if (frozenthingpoints.containsKey(name))
|
||||
{
|
||||
frozenthingpoints.remove(name);
|
||||
frozenthingpoints.put(name, point);
|
||||
}
|
||||
}
|
||||
|
||||
public int freezetype(String name)
|
||||
{
|
||||
if (freezetype.containsKey(name))
|
||||
{
|
||||
return freezetype.get(name);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long istbed(String name) {
|
||||
if (tbedthings.containsKey(name)) {
|
||||
return tbedthings.get(name);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public int tbtype(String name) {
|
||||
if (tbtypes.containsKey(name)) {
|
||||
return tbtypes.get(name);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void deleteopponent(String name)
|
||||
{
|
||||
if (frozenthings.containsKey(name))
|
||||
{
|
||||
frozenthings.remove(name);
|
||||
}
|
||||
if (frozenthingpoints.containsKey(name))
|
||||
{
|
||||
frozenthingpoints.remove(name);
|
||||
}
|
||||
if (freezetype.containsKey(name))
|
||||
{
|
||||
freezetype.remove(name);
|
||||
}
|
||||
}
|
||||
|
||||
public void deletetb(String name) {
|
||||
if (tbedthings.containsKey(name)) {
|
||||
tbedthings.remove(name);
|
||||
}
|
||||
if (tbtypes.containsKey(name)) {
|
||||
tbtypes.remove(name);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadFreezeIcons()
|
||||
{
|
||||
final IndexedSprite[] freezeIcons = {};
|
||||
final IndexedSprite[] newfreezeIcons = Arrays.copyOf(freezeIcons, FREEZE_ICONS.length);
|
||||
int curPosition = 0;
|
||||
|
||||
for (int i = 0; i < FREEZE_ICONS.length; i++, curPosition++)
|
||||
{
|
||||
final int resource = FREEZE_ICONS[i];
|
||||
FreezeIcons[i] = rgbaToIndexedBufferedImage(FreezeIconFromSprite(spriteManager.getSprite(resource, 0)));
|
||||
newfreezeIcons[curPosition] = createIndexedSprite(client, FreezeIcons[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private static IndexedSprite createIndexedSprite(Client client, BufferedImage bufferedImage) {
|
||||
IndexColorModel indexedCM = (IndexColorModel)bufferedImage.getColorModel();
|
||||
int width = bufferedImage.getWidth();
|
||||
int height = bufferedImage.getHeight();
|
||||
byte[] pixels = ((DataBufferByte)bufferedImage.getRaster().getDataBuffer()).getData();
|
||||
int[] palette = new int[indexedCM.getMapSize()];
|
||||
indexedCM.getRGBs(palette);
|
||||
IndexedSprite newIndexedSprite = client.createIndexedSprite();
|
||||
newIndexedSprite.setPixels(pixels);
|
||||
newIndexedSprite.setPalette(palette);
|
||||
newIndexedSprite.setWidth(width);
|
||||
newIndexedSprite.setHeight(height);
|
||||
newIndexedSprite.setOriginalWidth(width);
|
||||
newIndexedSprite.setOriginalHeight(height);
|
||||
newIndexedSprite.setOffsetX(0);
|
||||
newIndexedSprite.setOffsetY(0);
|
||||
return newIndexedSprite;
|
||||
}
|
||||
|
||||
private static BufferedImage rgbaToIndexedBufferedImage(BufferedImage sourceBufferedImage) {
|
||||
BufferedImage indexedImage = new BufferedImage(sourceBufferedImage.getWidth(), sourceBufferedImage.getHeight(), BufferedImage.TYPE_BYTE_INDEXED);
|
||||
ColorModel cm = indexedImage.getColorModel();
|
||||
IndexColorModel icm = (IndexColorModel)cm;
|
||||
int size = icm.getMapSize();
|
||||
byte[] reds = new byte[size];
|
||||
byte[] greens = new byte[size];
|
||||
byte[] blues = new byte[size];
|
||||
icm.getReds(reds);
|
||||
icm.getGreens(greens);
|
||||
icm.getBlues(blues);
|
||||
|
||||
final WritableRaster raster = indexedImage.getRaster();
|
||||
final int pixel = raster.getSample(0, 0, 0);
|
||||
final IndexColorModel resultIcm = new IndexColorModel(8, size, reds, greens, blues, pixel);
|
||||
final BufferedImage resultIndexedImage = new BufferedImage(resultIcm, raster, sourceBufferedImage.isAlphaPremultiplied(), null);
|
||||
resultIndexedImage.getGraphics().drawImage(sourceBufferedImage, 0, 0, null);
|
||||
return resultIndexedImage;
|
||||
}
|
||||
|
||||
private static BufferedImage FreezeIconFromSprite(final BufferedImage freezeSprite)
|
||||
{
|
||||
final BufferedImage freezeCanvas = ImageUtil.resizeCanvas(freezeSprite, FREEZE_ICON_DIMENSION.width, FREEZE_ICON_DIMENSION.height);
|
||||
return ImageUtil.outlineImage(freezeCanvas, FREEZE_ICON_OUTLINE_COLOR);
|
||||
}
|
||||
|
||||
BufferedImage GetFreezeIcon(int id)
|
||||
{
|
||||
return FreezeIcons[id];
|
||||
}
|
||||
}
|
||||
@@ -1,123 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019. PKLite - All Rights Reserved
|
||||
* Unauthorized modification, distribution, or possession of this source file, via any medium is strictly prohibited.
|
||||
* Proprietary and confidential. Refer to PKLite License file for more information on
|
||||
* full terms of this copyright and to determine what constitutes authorized use.
|
||||
* Written by PKLite(ST0NEWALL, others) <stonewall@thots.cc.usa>, 2019
|
||||
*
|
||||
*/
|
||||
|
||||
package net.runelite.client.plugins.freezetimers;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.Objects;
|
||||
import java.util.function.BiConsumer;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.Player;
|
||||
import net.runelite.api.coords.WorldPoint;
|
||||
|
||||
|
||||
@Singleton
|
||||
public class FreezeTimersService
|
||||
{
|
||||
private final Client client;
|
||||
private final FreezeTimersConfig config;
|
||||
private final FreezeTimersPlugin plugin;
|
||||
|
||||
@Inject
|
||||
private FreezeTimersService(Client client, FreezeTimersConfig config, FreezeTimersPlugin plugin)
|
||||
{
|
||||
this.config = config;
|
||||
this.plugin = plugin;
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
public void forEachPlayer(final BiConsumer<Player, Color> consumer)
|
||||
{
|
||||
|
||||
for (Player player : client.getPlayers())
|
||||
{
|
||||
if (player == null || player.getName() == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
String name = player.getName();
|
||||
int freezetype = plugin.freezetype(name);
|
||||
long dtime = plugin.opponentfreezetime(name);
|
||||
long tbed = plugin.istbed(name);
|
||||
int freezetime = 0;
|
||||
if (freezetype == 1 || freezetype == 4)
|
||||
{
|
||||
freezetime = 5000;
|
||||
}
|
||||
else if (freezetype == 2 || freezetype == 5)
|
||||
{
|
||||
freezetime = 10000;
|
||||
}
|
||||
else if (freezetype == 3 || freezetype == 6)
|
||||
{
|
||||
freezetime = 15000;
|
||||
}
|
||||
else if (freezetype == 7)
|
||||
{
|
||||
freezetime = 20000;
|
||||
}
|
||||
else if (freezetype == 8)
|
||||
{
|
||||
freezetime = 2500;
|
||||
}
|
||||
else if (freezetype == 9)
|
||||
{
|
||||
freezetime = 5000;
|
||||
}
|
||||
else if (freezetype == 10)
|
||||
{
|
||||
freezetime = 7500;
|
||||
}
|
||||
if (dtime > 0)
|
||||
{
|
||||
long currenttime = System.currentTimeMillis();
|
||||
long timediff = currenttime - dtime;
|
||||
if (timediff < freezetime)
|
||||
{
|
||||
WorldPoint currentWorldPoint = player.getWorldLocation();
|
||||
WorldPoint lastWorldPoint = plugin.playerpos(name);
|
||||
if (currentWorldPoint.equals(lastWorldPoint))
|
||||
{
|
||||
consumer.accept(player, config.FreezeTimerColor());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (timediff < 605)
|
||||
{
|
||||
plugin.updatePosition(name, currentWorldPoint);
|
||||
consumer.accept(player, config.FreezeTimerColor());
|
||||
}
|
||||
else
|
||||
{
|
||||
plugin.deleteopponent(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (timediff < freezetime + 3000)
|
||||
{
|
||||
consumer.accept(player, Color.YELLOW);
|
||||
}
|
||||
else
|
||||
{
|
||||
plugin.deleteopponent(name);
|
||||
}
|
||||
if (tbed > 0) {
|
||||
consumer.accept(player, config.FreezeTimerColor());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019. PKLite - All Rights Reserved
|
||||
* Unauthorized modification, distribution, or possession of this source file, via any medium is strictly prohibited.
|
||||
* Proprietary and confidential. Refer to PKLite License file for more information on
|
||||
* full terms of this copyright and to determine what constitutes authorized use.
|
||||
* Written by PKLite(ST0NEWALL, others) <stonewall@thots.cc.usa>, 2019
|
||||
*
|
||||
*/
|
||||
|
||||
package net.runelite.client.plugins.freezetimers;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Polygon;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.OverlayLayer;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
import net.runelite.client.ui.overlay.OverlayPriority;
|
||||
import net.runelite.client.ui.overlay.OverlayUtil;
|
||||
|
||||
public class FreezeTimersTileOverlay extends Overlay
|
||||
{
|
||||
private final FreezeTimersService FreezeTimersService;
|
||||
private final FreezeTimersConfig config;
|
||||
|
||||
@Inject
|
||||
private FreezeTimersTileOverlay(FreezeTimersConfig config, FreezeTimersService FreezeTimersService)
|
||||
{
|
||||
this.config = config;
|
||||
this.FreezeTimersService = FreezeTimersService;
|
||||
setLayer(OverlayLayer.ABOVE_SCENE);
|
||||
setPosition(OverlayPosition.DYNAMIC);
|
||||
setPriority(OverlayPriority.MED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension render(Graphics2D graphics)
|
||||
{
|
||||
if (!config.drawTiles())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
FreezeTimersService.forEachPlayer((player, color) ->
|
||||
{
|
||||
final Polygon poly = player.getCanvasTilePoly();
|
||||
|
||||
if (poly != null)
|
||||
{
|
||||
OverlayUtil.renderPolygon(graphics, poly, color);
|
||||
}
|
||||
});
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019. PKLite - All Rights Reserved
|
||||
* Unauthorized modification, distribution, or possession of this source file, via any medium is strictly prohibited.
|
||||
* Proprietary and confidential. Refer to PKLite License file for more information on
|
||||
* full terms of this copyright and to determine what constitutes authorized use.
|
||||
* Written by PKLite(ST0NEWALL, others) <stonewall@thots.cc.usa>, 2019
|
||||
*
|
||||
*/
|
||||
|
||||
package net.runelite.client.plugins.freezetimers;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
public enum PlayerSpellEffect
|
||||
{
|
||||
|
||||
|
||||
BARRAGE("Ice Barrage", 20000, false),
|
||||
BLITZ("Ice Blitz", 15000, false);
|
||||
|
||||
@Getter
|
||||
private final String SPELL_NAME;
|
||||
@Getter
|
||||
private long startTime;
|
||||
@Getter
|
||||
private int duration;
|
||||
@Getter
|
||||
private boolean halvable;
|
||||
//private final BufferedImage SPELL_ICON;
|
||||
|
||||
|
||||
|
||||
PlayerSpellEffect(String name, int duration, boolean halvable)
|
||||
{
|
||||
this.SPELL_NAME = name;
|
||||
this.duration = duration;
|
||||
this.halvable = halvable;
|
||||
this.startTime = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019. PKLite - All Rights Reserved
|
||||
* Unauthorized modification, distribution, or possession of this source file, via any medium is strictly prohibited.
|
||||
* Proprietary and confidential. Refer to PKLite License file for more information on
|
||||
* full terms of this copyright and to determine what constitutes authorized use.
|
||||
* Written by PKLite(ST0NEWALL, others) <stonewall@thots.cc.usa>, 2019
|
||||
*
|
||||
*/
|
||||
|
||||
package net.runelite.client.plugins.freezetimers;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.runelite.api.Actor;
|
||||
|
||||
public abstract class Spell
|
||||
{
|
||||
|
||||
@Getter
|
||||
private final Actor affectedTarget;
|
||||
@Getter
|
||||
private final Actor caster;
|
||||
@Getter
|
||||
public final long startTime;
|
||||
private long remainingTime;
|
||||
@Getter
|
||||
private boolean isFinished;
|
||||
|
||||
protected Spell(Actor affectedTarget, Actor caster)
|
||||
{
|
||||
this.affectedTarget = affectedTarget;
|
||||
this.caster = caster;
|
||||
startTime = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, gazivodag <https://github.com/gazivodag>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.runelite.client.plugins.prayagainstplayer;
|
||||
|
||||
import net.runelite.api.Player;
|
||||
|
||||
/**
|
||||
* Contains a player object
|
||||
* When they attacked me
|
||||
* And (in milliseconds) when to expire the overlay around them
|
||||
*/
|
||||
public class PlayerContainer {
|
||||
|
||||
private Player player;
|
||||
private long whenTheyAttackedMe;
|
||||
private int millisToExpireHighlight;
|
||||
|
||||
public PlayerContainer(Player player, long whenTheyAttackedMe, int millisToExpireHighlight) {
|
||||
this.player = player;
|
||||
this.whenTheyAttackedMe = whenTheyAttackedMe;
|
||||
this.millisToExpireHighlight = millisToExpireHighlight;
|
||||
}
|
||||
|
||||
|
||||
//getters
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
public long getWhenTheyAttackedMe() {
|
||||
return whenTheyAttackedMe;
|
||||
}
|
||||
public int getMillisToExpireHighlight() { return millisToExpireHighlight; };
|
||||
|
||||
}
|
||||
@@ -1,183 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, gazivodag <https://github.com/gazivodag>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.runelite.client.plugins.prayagainstplayer;
|
||||
|
||||
import net.runelite.client.config.Config;
|
||||
import net.runelite.client.config.ConfigGroup;
|
||||
import net.runelite.client.config.ConfigItem;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
@ConfigGroup("prayagainstplayer")
|
||||
public interface PrayAgainstPlayerConfig extends Config {
|
||||
@ConfigItem(
|
||||
position = 0,
|
||||
keyName = "attackerPlayerColor",
|
||||
name = "Attacker color",
|
||||
description = "This is the color that will be used to highlight attackers."
|
||||
)
|
||||
default Color attackerPlayerColor() { return new Color(0xFF0006); }
|
||||
|
||||
@ConfigItem(
|
||||
position = 1,
|
||||
keyName = "potentialPlayerColor",
|
||||
name = "Potential Attacker color",
|
||||
description = "This is the color that will be used to highlight potential attackers."
|
||||
)
|
||||
default Color potentialPlayerColor() { return new Color(0xFFFF00); }
|
||||
|
||||
////
|
||||
@ConfigItem(
|
||||
position = 2,
|
||||
keyName = "attackerTargetTimeout",
|
||||
name = "Attacker Timeout",
|
||||
description = "Seconds until attacker is no longer highlighted."
|
||||
)
|
||||
default int attackerTargetTimeout() { return 10; }
|
||||
|
||||
@ConfigItem(
|
||||
position = 3,
|
||||
keyName = "potentialTargetTimeout",
|
||||
name = "Potential Attacker Timeout",
|
||||
description = "Seconds until potential attacker is no longer highlighted."
|
||||
)
|
||||
default int potentialTargetTimeout() { return 10; }
|
||||
|
||||
@ConfigItem(
|
||||
position = 4,
|
||||
keyName = "newSpawnTimeout",
|
||||
name = "New Player Timeout",
|
||||
description = "Seconds until logged in/spawned player is no longer highlighted."
|
||||
)
|
||||
default int newSpawnTimeout() { return 5; }
|
||||
////
|
||||
|
||||
////
|
||||
@ConfigItem(
|
||||
position = 5,
|
||||
keyName = "ignoreFriends",
|
||||
name = "Ignore Friends",
|
||||
description = "This lets you decide whether you want friends to be highlighted by this plugin."
|
||||
)
|
||||
default boolean ignoreFriends() { return true; }
|
||||
|
||||
@ConfigItem(
|
||||
position = 6,
|
||||
keyName = "ignoreClanMates",
|
||||
name = "Ignore Clan Mates",
|
||||
description = "This lets you decide whether you want clan mates to be highlighted by this plugin."
|
||||
)
|
||||
default boolean ignoreClanMates() { return true; }
|
||||
////
|
||||
|
||||
@ConfigItem(
|
||||
position = 7,
|
||||
keyName = "markNewPlayer",
|
||||
name = "Mark new player as potential attacker",
|
||||
description = "Marks someone that logged in or teleported as a potential attacker for your safety\nDO NOT RUN THIS IN WORLD 1-2 GRAND EXCHANGE!"
|
||||
)
|
||||
default boolean markNewPlayer() { return false; }
|
||||
|
||||
@ConfigItem(
|
||||
position = 8,
|
||||
keyName = "drawTargetPrayAgainst",
|
||||
name = "Draw what to pray on attacker",
|
||||
description = "Tells you what to pray from what weapon the attacker is holding"
|
||||
)
|
||||
default boolean drawTargetPrayAgainst() { return true; }
|
||||
|
||||
@ConfigItem(
|
||||
position = 9,
|
||||
keyName = "drawPotentialTargetPrayAgainst",
|
||||
name = "Draw what to pray on potential attacker",
|
||||
description = "Tells you what to pray from what weapon the potential attacker is holding"
|
||||
)
|
||||
default boolean drawPotentialTargetPrayAgainst() { return true; }
|
||||
|
||||
@ConfigItem(
|
||||
position = 10,
|
||||
keyName = "drawTargetPrayAgainstPrayerTab",
|
||||
name = "Draw what to pray from prayer tab",
|
||||
description = "Tells you what to pray from what weapon the attacker is holding from the prayer tab"
|
||||
)
|
||||
default boolean drawTargetPrayAgainstPrayerTab() { return false; }
|
||||
|
||||
@ConfigItem(
|
||||
position = 11,
|
||||
keyName = "drawTargetsName",
|
||||
name = "Draw name on attacker",
|
||||
description = "Configures whether or not the attacker\'s name should be shown"
|
||||
)
|
||||
default boolean drawTargetsName() { return true; }
|
||||
|
||||
@ConfigItem(
|
||||
position = 12,
|
||||
keyName = "drawPotentialTargetsName",
|
||||
name = "Draw name on potential attacker",
|
||||
description = "Configures whether or not the potential attacker\'s name should be shown"
|
||||
)
|
||||
default boolean drawPotentialTargetsName() { return true; }
|
||||
|
||||
@ConfigItem(
|
||||
position = 13,
|
||||
keyName = "drawTargetHighlight",
|
||||
name = "Draw highlight around attacker",
|
||||
description = "Configures whether or not the attacker should be highlighted"
|
||||
)
|
||||
default boolean drawTargetHighlight() { return true; }
|
||||
|
||||
@ConfigItem(
|
||||
position = 14,
|
||||
keyName = "drawPotentialTargetHighlight",
|
||||
name = "Draw highlight around potential attacker",
|
||||
description = "Configures whether or not the potential attacker should be highlighted"
|
||||
)
|
||||
default boolean drawPotentialTargetHighlight() { return true; }
|
||||
|
||||
@ConfigItem(
|
||||
position = 15,
|
||||
keyName = "drawTargetTile",
|
||||
name = "Draw tile under attacker",
|
||||
description = "Configures whether or not the attacker\'s tile be highlighted"
|
||||
)
|
||||
default boolean drawTargetTile() { return false; }
|
||||
|
||||
@ConfigItem(
|
||||
position = 16,
|
||||
keyName = "drawPotentialTargetTile",
|
||||
name = "Draw tile under potential attacker",
|
||||
description = "Configures whether or not the potential attacker\'s tile be highlighted"
|
||||
)
|
||||
default boolean drawPotentialTargetTile() { return false; }
|
||||
|
||||
@ConfigItem(
|
||||
position = 17,
|
||||
keyName = "drawUnknownWeapons",
|
||||
name = "Draw unknown weapons",
|
||||
description = "Configures whether or not the unknown weapons should be shown when a player equips one"
|
||||
)
|
||||
default boolean drawUnknownWeapons() { return false; }
|
||||
|
||||
}
|
||||
@@ -1,158 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, gazivodag <https://github.com/gazivodag>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.runelite.client.plugins.prayagainstplayer;
|
||||
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.ItemComposition;
|
||||
import net.runelite.api.Player;
|
||||
import net.runelite.api.kit.KitType;
|
||||
import net.runelite.client.ui.overlay.*;
|
||||
import net.runelite.client.util.Text;
|
||||
import net.runelite.api.Point;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.ConcurrentModificationException;
|
||||
|
||||
class PrayAgainstPlayerOverlay extends Overlay {
|
||||
|
||||
private final PrayAgainstPlayerPlugin plugin;
|
||||
private final PrayAgainstPlayerConfig config;
|
||||
private final Client client;
|
||||
|
||||
@Inject
|
||||
private PrayAgainstPlayerOverlay(PrayAgainstPlayerPlugin plugin, PrayAgainstPlayerConfig config, Client client) {
|
||||
super(plugin);
|
||||
this.plugin = plugin;
|
||||
this.config = config;
|
||||
this.client = client;
|
||||
|
||||
setLayer(OverlayLayer.ABOVE_SCENE);
|
||||
setPosition(OverlayPosition.DYNAMIC);
|
||||
setPriority(OverlayPriority.HIGH);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Dimension render(Graphics2D graphics) {
|
||||
renderPotentialPlayers(graphics);
|
||||
renderAttackingPlayers(graphics);
|
||||
return null;
|
||||
}
|
||||
|
||||
private void renderPotentialPlayers(Graphics2D graphics) {
|
||||
if (plugin.getPotentialPlayersAttackingMe() == null || !plugin.getPotentialPlayersAttackingMe().isEmpty()) {
|
||||
try {
|
||||
for (PlayerContainer container : plugin.getPotentialPlayersAttackingMe()) {
|
||||
if ((System.currentTimeMillis() > (container.getWhenTheyAttackedMe() + container.getMillisToExpireHighlight())) && (container.getPlayer().getInteracting() != client.getLocalPlayer())) {
|
||||
plugin.removePlayerFromPotentialContainer(container);
|
||||
}
|
||||
if (config.drawPotentialTargetsName()) renderNameAboveHead(graphics, container.getPlayer(), config.potentialPlayerColor());
|
||||
if (config.drawPotentialTargetHighlight()) renderHighlightedPlayer(graphics, container.getPlayer(), config.potentialPlayerColor());
|
||||
if (config.drawPotentialTargetTile()) renderTileUnderPlayer(graphics, container.getPlayer(), config.potentialPlayerColor());
|
||||
if (config.drawPotentialTargetPrayAgainst()) renderPrayAgainstOnPlayer(graphics, container.getPlayer(), config.potentialPlayerColor());
|
||||
}
|
||||
} catch (ConcurrentModificationException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void renderAttackingPlayers(Graphics2D graphics) {
|
||||
if (plugin.getPlayersAttackingMe() == null || !plugin.getPlayersAttackingMe().isEmpty()) {
|
||||
try {
|
||||
for (PlayerContainer container : plugin.getPlayersAttackingMe()) {
|
||||
if ((System.currentTimeMillis() > (container.getWhenTheyAttackedMe() + container.getMillisToExpireHighlight())) && (container.getPlayer().getInteracting() != client.getLocalPlayer())) {
|
||||
plugin.removePlayerFromAttackerContainer(container);
|
||||
}
|
||||
|
||||
if (config.drawTargetsName()) renderNameAboveHead(graphics, container.getPlayer(), config.attackerPlayerColor());
|
||||
if (config.drawTargetHighlight()) renderHighlightedPlayer(graphics, container.getPlayer(), config.attackerPlayerColor());
|
||||
if (config.drawTargetTile()) renderTileUnderPlayer(graphics, container.getPlayer(), config.attackerPlayerColor());
|
||||
if (config.drawTargetPrayAgainst()) renderPrayAgainstOnPlayer(graphics, container.getPlayer(), config.attackerPlayerColor());
|
||||
}
|
||||
} catch (ConcurrentModificationException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void renderNameAboveHead(Graphics2D graphics, Player player, Color color) {
|
||||
final String name = Text.sanitize(player.getName());
|
||||
final int offset = player.getLogicalHeight() + 40;
|
||||
Point textLocation = player.getCanvasTextLocation(graphics, name, offset);
|
||||
if (textLocation != null) {
|
||||
OverlayUtil.renderTextLocation(graphics, textLocation, name, color);
|
||||
}
|
||||
}
|
||||
|
||||
private void renderHighlightedPlayer(Graphics2D graphics, Player player, Color color) {
|
||||
try {
|
||||
OverlayUtil.renderPolygon(graphics, player.getConvexHull(), color);
|
||||
} catch (NullPointerException e) {
|
||||
}
|
||||
}
|
||||
|
||||
private void renderTileUnderPlayer(Graphics2D graphics, Player player, Color color) {
|
||||
Polygon poly = player.getCanvasTilePoly();
|
||||
OverlayUtil.renderPolygon(graphics, poly, color);
|
||||
}
|
||||
|
||||
private void renderPrayAgainstOnPlayer(Graphics2D graphics, Player player, Color color) {
|
||||
final int offset = (player.getLogicalHeight() / 2) + 75;
|
||||
BufferedImage icon;
|
||||
|
||||
switch (WeaponType.checkWeaponOnPlayer(client, player)) {
|
||||
case WEAPON_MELEE:
|
||||
icon = plugin.getProtectionIcon(WeaponType.WEAPON_MELEE);
|
||||
break;
|
||||
case WEAPON_MAGIC:
|
||||
icon = plugin.getProtectionIcon(WeaponType.WEAPON_MAGIC);
|
||||
break;
|
||||
case WEAPON_RANGED:
|
||||
icon = plugin.getProtectionIcon(WeaponType.WEAPON_RANGED);
|
||||
break;
|
||||
default:
|
||||
icon = null;
|
||||
break;
|
||||
}
|
||||
try {
|
||||
if (icon != null) {
|
||||
Point point = player.getCanvasImageLocation(icon, offset);
|
||||
OverlayUtil.renderImageLocation(graphics, point, icon);
|
||||
} else {
|
||||
if (config.drawUnknownWeapons()) {
|
||||
int itemId = player.getPlayerComposition().getEquipmentId(KitType.WEAPON);
|
||||
ItemComposition itemComposition = client.getItemDefinition(itemId);
|
||||
|
||||
final String str = itemComposition.getName().toUpperCase();
|
||||
Point point = player.getCanvasTextLocation(graphics, str, offset);
|
||||
OverlayUtil.renderTextLocation(graphics, point, str, color);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, gazivodag <https://github.com/gazivodag>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.runelite.client.plugins.prayagainstplayer;
|
||||
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.Player;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.client.ui.overlay.*;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.awt.*;
|
||||
import java.util.ConcurrentModificationException;
|
||||
|
||||
class PrayAgainstPlayerOverlayPrayerTab extends Overlay {
|
||||
|
||||
private final PrayAgainstPlayerPlugin plugin;
|
||||
private final PrayAgainstPlayerConfig config;
|
||||
private final Client client;
|
||||
|
||||
@Inject
|
||||
private PrayAgainstPlayerOverlayPrayerTab (PrayAgainstPlayerPlugin plugin, PrayAgainstPlayerConfig config, Client client) {
|
||||
super(plugin);
|
||||
this.plugin = plugin;
|
||||
this.config = config;
|
||||
this.client = client;
|
||||
|
||||
setPosition(OverlayPosition.DETACHED);
|
||||
setLayer(OverlayLayer.ALWAYS_ON_TOP);
|
||||
setPriority(OverlayPriority.MED);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Dimension render(Graphics2D graphics) {
|
||||
if (plugin.getPlayersAttackingMe() == null || !plugin.getPlayersAttackingMe().isEmpty()) {
|
||||
try {
|
||||
for (PlayerContainer container : plugin.getPlayersAttackingMe()) {
|
||||
if (plugin.getPlayersAttackingMe() != null && plugin.getPlayersAttackingMe().size() > 0) {
|
||||
//no reason to show you what prayers to pray in your prayer tab if multiple people are attacking you
|
||||
if ((plugin.getPlayersAttackingMe().size() == 1) && (config.drawTargetPrayAgainstPrayerTab())) {
|
||||
renderPrayerToClick(graphics, container.getPlayer());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (ConcurrentModificationException e) {
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void renderPrayerToClick(Graphics2D graphics, Player player) {
|
||||
Widget PROTECT_FROM_MAGIC = client.getWidget(WidgetInfo.PRAYER_PROTECT_FROM_MAGIC);
|
||||
Widget PROTECT_FROM_RANGED = client.getWidget(WidgetInfo.PRAYER_PROTECT_FROM_MISSILES);
|
||||
Widget PROTECT_FROM_MELEE = client.getWidget(WidgetInfo.PRAYER_PROTECT_FROM_MELEE);
|
||||
Color color = Color.RED;
|
||||
if (PROTECT_FROM_MELEE.isHidden()) return;
|
||||
switch (WeaponType.checkWeaponOnPlayer(client, player)) {
|
||||
case WEAPON_MAGIC:
|
||||
OverlayUtil.renderPolygon(graphics, rectangleToPolygon(PROTECT_FROM_MAGIC.getBounds()), color);
|
||||
break;
|
||||
case WEAPON_MELEE:
|
||||
OverlayUtil.renderPolygon(graphics, rectangleToPolygon(PROTECT_FROM_MELEE.getBounds()), color);
|
||||
break;
|
||||
case WEAPON_RANGED:
|
||||
OverlayUtil.renderPolygon(graphics, rectangleToPolygon(PROTECT_FROM_RANGED.getBounds()), color);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static Polygon rectangleToPolygon(Rectangle rect) {
|
||||
int[] xpoints = {rect.x, rect.x + rect.width, rect.x + rect.width, rect.x};
|
||||
int[] ypoints = {rect.y, rect.y, rect.y + rect.height, rect.y + rect.height};
|
||||
return new Polygon(xpoints, ypoints, 4);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,329 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, gazivodag <https://github.com/gazivodag>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.runelite.client.plugins.prayagainstplayer;
|
||||
|
||||
import com.google.inject.Provides;
|
||||
import net.runelite.api.*;
|
||||
import net.runelite.api.events.*;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
import net.runelite.client.game.SpriteManager;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.plugins.PluginType;
|
||||
import net.runelite.client.ui.overlay.OverlayManager;
|
||||
import net.runelite.client.util.ImageUtil;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "Pray Against Player",
|
||||
description = "Use plugin in PvP situations for best results!!",
|
||||
tags = {"highlight", "pvp", "overlay", "players"},
|
||||
type = PluginType.PVP
|
||||
)
|
||||
|
||||
/**
|
||||
* I am fully aware that there is plenty of overhead and is a MESS!
|
||||
* If you'd like to contribute please do!
|
||||
*/
|
||||
public class PrayAgainstPlayerPlugin extends Plugin {
|
||||
|
||||
private static final int[] PROTECTION_ICONS = {
|
||||
SpriteID.PRAYER_PROTECT_FROM_MISSILES,
|
||||
SpriteID.PRAYER_PROTECT_FROM_MELEE,
|
||||
SpriteID.PRAYER_PROTECT_FROM_MAGIC
|
||||
};
|
||||
private static final Dimension PROTECTION_ICON_DIMENSION = new Dimension(33, 33);
|
||||
private static final Color PROTECTION_ICON_OUTLINE_COLOR = new Color(33, 33, 33);
|
||||
public final BufferedImage[] ProtectionIcons = new BufferedImage[PROTECTION_ICONS.length];
|
||||
|
||||
private ArrayList<PlayerContainer> potentialPlayersAttackingMe;
|
||||
private ArrayList<PlayerContainer> playersAttackingMe;
|
||||
|
||||
@Inject
|
||||
private Client client;
|
||||
|
||||
@Inject
|
||||
private SpriteManager spriteManager;
|
||||
|
||||
@Inject
|
||||
private OverlayManager overlayManager;
|
||||
|
||||
@Inject
|
||||
private PrayAgainstPlayerOverlay overlay;
|
||||
|
||||
@Inject
|
||||
private PrayAgainstPlayerOverlayPrayerTab overlayPrayerTab;
|
||||
|
||||
@Inject
|
||||
private PrayAgainstPlayerConfig config;
|
||||
|
||||
@Provides
|
||||
PrayAgainstPlayerConfig provideConfig(ConfigManager configManager) {
|
||||
return configManager.getConfig(PrayAgainstPlayerConfig.class);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onGameStateChanged(GameStateChanged gameStateChanged) {
|
||||
if (gameStateChanged.getGameState() == GameState.LOGGED_IN) {
|
||||
loadProtectionIcons();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void startUp() {
|
||||
potentialPlayersAttackingMe = new ArrayList<>();
|
||||
playersAttackingMe = new ArrayList<>();
|
||||
overlayManager.add(overlay);
|
||||
overlayManager.add(overlayPrayerTab);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void shutDown() throws Exception {
|
||||
overlayManager.remove(overlay);
|
||||
overlayManager.remove(overlayPrayerTab);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
protected void onAnimationChanged(AnimationChanged animationChanged) {
|
||||
if ((animationChanged.getActor() instanceof Player) && (animationChanged.getActor().getInteracting() instanceof Player) && (animationChanged.getActor().getInteracting() == client.getLocalPlayer())) {
|
||||
Player sourcePlayer = (Player) animationChanged.getActor();
|
||||
|
||||
//is the client is a friend/clan and the config is set to ignore friends/clan dont add them to list
|
||||
if (client.isFriended(sourcePlayer.getName(), true) && config.ignoreFriends()) return;
|
||||
if (client.isClanMember(sourcePlayer.getName()) && config.ignoreClanMates()) return;
|
||||
|
||||
if ((sourcePlayer.getAnimation() != -1) && (!isBlockAnimation(sourcePlayer.getAnimation()))) {
|
||||
//if attacker attacks again, reset his timer so overlay doesn't go away
|
||||
if (findPlayerInAttackerList(sourcePlayer) != null) {
|
||||
resetPlayerFromAttackerContainerTimer(findPlayerInAttackerList(sourcePlayer));
|
||||
}
|
||||
//if he attacks and he was in the potential attackers list, remove him
|
||||
if (!potentialPlayersAttackingMe.isEmpty() && potentialPlayersAttackingMe.contains(findPlayerInPotentialList(sourcePlayer))) {
|
||||
removePlayerFromPotentialContainer(findPlayerInPotentialList(sourcePlayer));
|
||||
}
|
||||
//if he's not in the attackers list, add him
|
||||
if (findPlayerInAttackerList(sourcePlayer) == null) {
|
||||
PlayerContainer container = new PlayerContainer(sourcePlayer, System.currentTimeMillis(), (config.attackerTargetTimeout() * 1000));
|
||||
playersAttackingMe.add(container);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
protected void onInteractingChanged(InteractingChanged interactingChanged) {
|
||||
//if someone interacts with you, add them to the potential attackers list
|
||||
if ((interactingChanged.getSource() instanceof Player) && (interactingChanged.getTarget() instanceof Player)) {
|
||||
Player sourcePlayer = (Player) interactingChanged.getSource();
|
||||
Player targetPlayer = (Player) interactingChanged.getTarget();
|
||||
if ((targetPlayer == client.getLocalPlayer()) && (findPlayerInPotentialList(sourcePlayer) == null)) { //we're being interacted with
|
||||
|
||||
//is the client is a friend/clan and the config is set to ignore friends/clan dont add them to list
|
||||
if (client.isFriended(sourcePlayer.getName(), true) && config.ignoreFriends()) return;
|
||||
if (client.isClanMember(sourcePlayer.getName()) && config.ignoreClanMates()) return;
|
||||
|
||||
PlayerContainer container = new PlayerContainer(sourcePlayer, System.currentTimeMillis(), (config.potentialTargetTimeout() * 1000));
|
||||
potentialPlayersAttackingMe.add(container);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
protected void onPlayerDespawned(PlayerDespawned playerDespawned) {
|
||||
PlayerContainer container = findPlayerInAttackerList(playerDespawned.getPlayer());
|
||||
PlayerContainer container2 = findPlayerInPotentialList(playerDespawned.getPlayer());
|
||||
if (container != null) {
|
||||
playersAttackingMe.remove(container);
|
||||
}
|
||||
if (container2 != null) {
|
||||
potentialPlayersAttackingMe.remove(container2);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
protected void onPlayerSpawned(PlayerSpawned playerSpawned) {
|
||||
if (config.markNewPlayer()) {
|
||||
Player p = playerSpawned.getPlayer();
|
||||
|
||||
if (client.isFriended(p.getName(), true) && config.ignoreFriends()) return;
|
||||
if (client.isClanMember(p.getName()) && config.ignoreClanMates()) return;
|
||||
|
||||
PlayerContainer container = findPlayerInPotentialList(p);
|
||||
if (container == null) {
|
||||
container = new PlayerContainer(p, System.currentTimeMillis(), (config.newSpawnTimeout() * 1000));
|
||||
potentialPlayersAttackingMe.add(container);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PlayerContainer findPlayerInAttackerList(Player player) {
|
||||
if (playersAttackingMe.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
for (int i = 0 ; i < playersAttackingMe.size() ; i++) {
|
||||
PlayerContainer container = playersAttackingMe.get(i);
|
||||
if (container.getPlayer() == player) {
|
||||
return container;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
PlayerContainer findPlayerInPotentialList(Player player) {
|
||||
if (potentialPlayersAttackingMe.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
for (int i = 0 ; i < potentialPlayersAttackingMe.size() ; i++) {
|
||||
PlayerContainer container = potentialPlayersAttackingMe.get(i);
|
||||
if (container.getPlayer() == player) {
|
||||
return container;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets player timer in case he attacks again, so his highlight doesn't go away so easily
|
||||
* @param container
|
||||
*/
|
||||
public void resetPlayerFromAttackerContainerTimer(PlayerContainer container) {
|
||||
removePlayerFromAttackerContainer(container);
|
||||
PlayerContainer newContainer = new PlayerContainer(container.getPlayer(), System.currentTimeMillis(), (config.attackerTargetTimeout() * 1000));
|
||||
playersAttackingMe.add(newContainer);
|
||||
}
|
||||
|
||||
|
||||
public void removePlayerFromPotentialContainer(PlayerContainer container) {
|
||||
if ((potentialPlayersAttackingMe != null) && (!potentialPlayersAttackingMe.isEmpty()) && (potentialPlayersAttackingMe.contains(container))) {
|
||||
potentialPlayersAttackingMe.remove(container);
|
||||
}
|
||||
}
|
||||
|
||||
public void removePlayerFromAttackerContainer(PlayerContainer container) {
|
||||
if ((playersAttackingMe != null) && (!playersAttackingMe.isEmpty()) && (playersAttackingMe.contains(container))) {
|
||||
playersAttackingMe.remove(container);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isBlockAnimation(int anim) {
|
||||
switch (anim) {
|
||||
case AnimationID.BLOCK_DEFENDER:
|
||||
case AnimationID.BLOCK_NO_SHIELD:
|
||||
case AnimationID.BLOCK_SHIELD:
|
||||
case AnimationID.BLOCK_SWORD:
|
||||
case AnimationID.BLOCK_UNARMED:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<PlayerContainer> getPotentialPlayersAttackingMe() { return potentialPlayersAttackingMe; }
|
||||
public ArrayList<PlayerContainer> getPlayersAttackingMe() { return playersAttackingMe; }
|
||||
|
||||
//All of the methods below are from the Zulrah plugin!!! Credits to it's respective owner
|
||||
private void loadProtectionIcons() {
|
||||
final IndexedSprite[] protectionIcons = {};
|
||||
final IndexedSprite[] newProtectionIcons = Arrays.copyOf(protectionIcons, PROTECTION_ICONS.length);
|
||||
int curPosition = 0;
|
||||
|
||||
for (int i = 0; i < PROTECTION_ICONS.length; i++, curPosition++)
|
||||
{
|
||||
final int resource = PROTECTION_ICONS[i];
|
||||
ProtectionIcons[i] = rgbaToIndexedBufferedImage(ProtectionIconFromSprite(spriteManager.getSprite(resource, 0)));
|
||||
newProtectionIcons[curPosition] = createIndexedSprite(client, ProtectionIcons[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private static IndexedSprite createIndexedSprite(final Client client, final BufferedImage bufferedImage) {
|
||||
final IndexColorModel indexedCM = (IndexColorModel) bufferedImage.getColorModel();
|
||||
|
||||
final int width = bufferedImage.getWidth();
|
||||
final int height = bufferedImage.getHeight();
|
||||
final byte[] pixels = ((DataBufferByte) bufferedImage.getRaster().getDataBuffer()).getData();
|
||||
final int[] palette = new int[indexedCM.getMapSize()];
|
||||
indexedCM.getRGBs(palette);
|
||||
|
||||
final IndexedSprite newIndexedSprite = client.createIndexedSprite();
|
||||
newIndexedSprite.setPixels(pixels);
|
||||
newIndexedSprite.setPalette(palette);
|
||||
newIndexedSprite.setWidth(width);
|
||||
newIndexedSprite.setHeight(height);
|
||||
newIndexedSprite.setOriginalWidth(width);
|
||||
newIndexedSprite.setOriginalHeight(height);
|
||||
newIndexedSprite.setOffsetX(0);
|
||||
newIndexedSprite.setOffsetY(0);
|
||||
return newIndexedSprite;
|
||||
}
|
||||
|
||||
private static BufferedImage rgbaToIndexedBufferedImage(final BufferedImage sourceBufferedImage) {
|
||||
final BufferedImage indexedImage = new BufferedImage(
|
||||
sourceBufferedImage.getWidth(),
|
||||
sourceBufferedImage.getHeight(),
|
||||
BufferedImage.TYPE_BYTE_INDEXED);
|
||||
|
||||
final ColorModel cm = indexedImage.getColorModel();
|
||||
final IndexColorModel icm = (IndexColorModel) cm;
|
||||
|
||||
final int size = icm.getMapSize();
|
||||
final byte[] reds = new byte[size];
|
||||
final byte[] greens = new byte[size];
|
||||
final byte[] blues = new byte[size];
|
||||
icm.getReds(reds);
|
||||
icm.getGreens(greens);
|
||||
icm.getBlues(blues);
|
||||
|
||||
final WritableRaster raster = indexedImage.getRaster();
|
||||
final int pixel = raster.getSample(0, 0, 0);
|
||||
final IndexColorModel resultIcm = new IndexColorModel(8, size, reds, greens, blues, pixel);
|
||||
final BufferedImage resultIndexedImage = new BufferedImage(resultIcm, raster, sourceBufferedImage.isAlphaPremultiplied(), null);
|
||||
resultIndexedImage.getGraphics().drawImage(sourceBufferedImage, 0, 0, null);
|
||||
return resultIndexedImage;
|
||||
}
|
||||
|
||||
private static BufferedImage ProtectionIconFromSprite(final BufferedImage freezeSprite) {
|
||||
final BufferedImage freezeCanvas = ImageUtil.resizeCanvas(freezeSprite, PROTECTION_ICON_DIMENSION.width, PROTECTION_ICON_DIMENSION.height);
|
||||
return ImageUtil.outlineImage(freezeCanvas, PROTECTION_ICON_OUTLINE_COLOR);
|
||||
}
|
||||
|
||||
BufferedImage getProtectionIcon(WeaponType weaponType) {
|
||||
switch (weaponType) {
|
||||
case WEAPON_RANGED:
|
||||
return ProtectionIcons[0];
|
||||
case WEAPON_MELEE:
|
||||
return ProtectionIcons[1];
|
||||
case WEAPON_MAGIC:
|
||||
return ProtectionIcons[2];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,125 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, gazivodag <https://github.com/gazivodag>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.runelite.client.plugins.prayagainstplayer;
|
||||
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.ItemComposition;
|
||||
import net.runelite.api.Player;
|
||||
import net.runelite.api.kit.KitType;
|
||||
|
||||
enum WeaponType {
|
||||
|
||||
WEAPON_MELEE,
|
||||
WEAPON_RANGED,
|
||||
WEAPON_MAGIC,
|
||||
WEAPON_UNKNOWN;
|
||||
|
||||
/**
|
||||
* im fully aware this could of been done better!!!
|
||||
* @param client
|
||||
* @param attacker
|
||||
* @return
|
||||
*/
|
||||
public static WeaponType checkWeaponOnPlayer (Client client, Player attacker) {
|
||||
int itemId = attacker.getPlayerComposition().getEquipmentId(KitType.WEAPON);
|
||||
ItemComposition itemComposition = client.getItemDefinition(itemId);
|
||||
String weaponNameGivenLowerCase = itemComposition.getName().toLowerCase();
|
||||
|
||||
if (itemId == -1) return WEAPON_MELEE;
|
||||
if (weaponNameGivenLowerCase == null || weaponNameGivenLowerCase.toLowerCase().contains("null")) return WEAPON_MELEE;
|
||||
|
||||
for (String meleeWeaponName : meleeWeaponNames) {
|
||||
if (weaponNameGivenLowerCase.contains(meleeWeaponName) && !weaponNameGivenLowerCase.contains("thrownaxe")) {
|
||||
return WEAPON_MELEE;
|
||||
}
|
||||
}
|
||||
|
||||
for (String rangedWeaponName : rangedWeaponNames) {
|
||||
if (weaponNameGivenLowerCase.contains(rangedWeaponName)) {
|
||||
return WEAPON_RANGED;
|
||||
}
|
||||
}
|
||||
|
||||
for (String magicWeaponName : magicWeaponNames) {
|
||||
if (weaponNameGivenLowerCase.contains(magicWeaponName)) {
|
||||
return WEAPON_MAGIC;
|
||||
}
|
||||
}
|
||||
|
||||
return WEAPON_UNKNOWN;
|
||||
|
||||
}
|
||||
|
||||
private static String[] meleeWeaponNames = {
|
||||
"sword",
|
||||
"scimitar",
|
||||
"dagger",
|
||||
"spear",
|
||||
"mace",
|
||||
"axe",
|
||||
"whip",
|
||||
"tentacle",
|
||||
"-ket-",
|
||||
"-xil-",
|
||||
"warhammer",
|
||||
"halberd",
|
||||
"claws",
|
||||
"hasta",
|
||||
"scythe",
|
||||
"maul",
|
||||
"anchor",
|
||||
"sabre",
|
||||
"excalibur",
|
||||
"machete",
|
||||
"dragon hunter lance",
|
||||
"event rpg",
|
||||
"silverlight",
|
||||
"darklight",
|
||||
"arclight",
|
||||
"flail",
|
||||
"granite hammer",
|
||||
"rapier",
|
||||
"bulwark"
|
||||
};
|
||||
|
||||
private static String[] rangedWeaponNames = {
|
||||
"bow",
|
||||
"blowpipe",
|
||||
"xil-ul",
|
||||
"knife",
|
||||
"dart",
|
||||
"thrownaxe",
|
||||
"chinchompa",
|
||||
"ballista"
|
||||
};
|
||||
|
||||
private static String[] magicWeaponNames = {
|
||||
"staff",
|
||||
"trident",
|
||||
"wand",
|
||||
"dawnbringer"
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user