combatlevel: fix attack range indicator
Co-authored-by: Jordan Atwood <jordan.atwood423@gmail.com>
This commit is contained in:
@@ -772,7 +772,7 @@ public class WidgetID
|
|||||||
static final int KILLDEATH_RATIO = 26;
|
static final int KILLDEATH_RATIO = 26;
|
||||||
static final int SKULL_CONTAINER = 45;
|
static final int SKULL_CONTAINER = 45;
|
||||||
static final int SAFE_ZONE = 47;
|
static final int SAFE_ZONE = 47;
|
||||||
static final int WILDERNESS_LEVEL = 49; // this can also be the Deadman Mode "Protection" text
|
static final int WILDERNESS_LEVEL = 50; // this can also be the Deadman Mode "Protection" text
|
||||||
}
|
}
|
||||||
|
|
||||||
static class KourendFavour
|
static class KourendFavour
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ import net.runelite.api.events.GameTick;
|
|||||||
import net.runelite.api.events.ScriptPostFired;
|
import net.runelite.api.events.ScriptPostFired;
|
||||||
import net.runelite.api.widgets.Widget;
|
import net.runelite.api.widgets.Widget;
|
||||||
import net.runelite.api.widgets.WidgetInfo;
|
import net.runelite.api.widgets.WidgetInfo;
|
||||||
import net.runelite.client.callback.ClientThread;
|
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
import net.runelite.client.eventbus.Subscribe;
|
||||||
import net.runelite.client.events.ConfigChanged;
|
import net.runelite.client.events.ConfigChanged;
|
||||||
@@ -59,19 +58,11 @@ public class CombatLevelPlugin extends Plugin
|
|||||||
private static final String CONFIG_GROUP = "combatlevel";
|
private static final String CONFIG_GROUP = "combatlevel";
|
||||||
private static final String ATTACK_RANGE_CONFIG_KEY = "wildernessAttackLevelRange";
|
private static final String ATTACK_RANGE_CONFIG_KEY = "wildernessAttackLevelRange";
|
||||||
private static final Pattern WILDERNESS_LEVEL_PATTERN = Pattern.compile("^Level: (\\d+)$");
|
private static final Pattern WILDERNESS_LEVEL_PATTERN = Pattern.compile("^Level: (\\d+)$");
|
||||||
private static final int SKULL_CONTAINER_ADJUSTED_ORIGINAL_Y = 6;
|
|
||||||
private static final int WILDERNESS_LEVEL_TEXT_ADJUSTED_ORIGINAL_Y = 3;
|
|
||||||
private static final int MIN_COMBAT_LEVEL = 3;
|
private static final int MIN_COMBAT_LEVEL = 3;
|
||||||
|
|
||||||
private int originalWildernessLevelTextPosition = -1;
|
|
||||||
private int originalSkullContainerPosition = -1;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private Client client;
|
private Client client;
|
||||||
|
|
||||||
@Inject
|
|
||||||
private ClientThread clientThread;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private CombatLevelConfig config;
|
private CombatLevelConfig config;
|
||||||
|
|
||||||
@@ -187,25 +178,10 @@ public class CombatLevelPlugin extends Plugin
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Widget skullContainer = client.getWidget(WidgetInfo.PVP_SKULL_CONTAINER);
|
|
||||||
if (originalWildernessLevelTextPosition == -1)
|
|
||||||
{
|
|
||||||
originalWildernessLevelTextPosition = wildernessLevelWidget.getOriginalY();
|
|
||||||
}
|
|
||||||
if (originalSkullContainerPosition == -1)
|
|
||||||
{
|
|
||||||
originalSkullContainerPosition = skullContainer.getRelativeY();
|
|
||||||
}
|
|
||||||
|
|
||||||
final int wildernessLevel = Integer.parseInt(m.group(1));
|
final int wildernessLevel = Integer.parseInt(m.group(1));
|
||||||
final int combatLevel = client.getLocalPlayer().getCombatLevel();
|
final int combatLevel = client.getLocalPlayer().getCombatLevel();
|
||||||
|
|
||||||
wildernessLevelWidget.setText(wildernessLevelText + "<br>" + combatAttackRange(combatLevel, wildernessLevel));
|
wildernessLevelWidget.setText(wildernessLevelText + "<br>" + combatAttackRange(combatLevel, wildernessLevel));
|
||||||
wildernessLevelWidget.setOriginalY(WILDERNESS_LEVEL_TEXT_ADJUSTED_ORIGINAL_Y);
|
|
||||||
skullContainer.setOriginalY(SKULL_CONTAINER_ADJUSTED_ORIGINAL_Y);
|
|
||||||
|
|
||||||
clientThread.invoke(wildernessLevelWidget::revalidate);
|
|
||||||
clientThread.invoke(skullContainer::revalidate);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void shutDownAttackLevelRange()
|
private void shutDownAttackLevelRange()
|
||||||
@@ -223,18 +199,7 @@ public class CombatLevelPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
wildernessLevelWidget.setText(wildernessLevelText.substring(0, wildernessLevelText.indexOf("<br>")));
|
wildernessLevelWidget.setText(wildernessLevelText.substring(0, wildernessLevelText.indexOf("<br>")));
|
||||||
}
|
}
|
||||||
wildernessLevelWidget.setOriginalY(originalWildernessLevelTextPosition);
|
|
||||||
clientThread.invoke(wildernessLevelWidget::revalidate);
|
|
||||||
}
|
}
|
||||||
originalWildernessLevelTextPosition = -1;
|
|
||||||
|
|
||||||
final Widget skullContainer = client.getWidget(WidgetInfo.PVP_SKULL_CONTAINER);
|
|
||||||
if (skullContainer != null)
|
|
||||||
{
|
|
||||||
skullContainer.setOriginalY(originalSkullContainerPosition);
|
|
||||||
clientThread.invoke(skullContainer::revalidate);
|
|
||||||
}
|
|
||||||
originalSkullContainerPosition = -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String combatAttackRange(final int combatLevel, final int wildernessLevel)
|
private static String combatAttackRange(final int combatLevel, final int wildernessLevel)
|
||||||
|
|||||||
Reference in New Issue
Block a user