Merge pull request #2719 from Lucwousin/hint-arrow-prio

mixins: Bring player targeted by hint arrow to front (while not in combat)
This commit is contained in:
Lucwousin
2020-06-28 02:44:40 +02:00
committed by GitHub
2 changed files with 30 additions and 0 deletions

View File

@@ -1196,6 +1196,32 @@ public abstract class RSClientMixin implements RSClient
client.getCallbacks().post(CanvasSizeChanged.class, CanvasSizeChanged.INSTANCE);
}
@FieldHook("hintArrowPlayerIndex")
@Inject
public static void hintPlayerChanged(int ignored)
{
// Setting the localInteractingIndex (aka player target index, it only applies to players)
// causes that player to get priority over others when rendering/menus are added
if (client.getVar(VarPlayer.ATTACKING_PLAYER) == -1)
{
client.setLocalInteractingIndex(client.getHintArrowPlayerTargetIdx() & 2047);
}
}
@FieldHook("combatTargetPlayerIndex")
@Inject
public static void combatPlayerTargetChanged(int ignored)
{
if (client.getLocalInteractingIndex() == -1)
{
final Player p = client.getHintArrowPlayer();
if (p != null)
{
client.setLocalInteractingIndex(p.getPlayerId() & 2047);
}
}
}
@Inject
@Override
public boolean hasHintArrow()
@@ -1247,6 +1273,7 @@ public abstract class RSClientMixin implements RSClient
{
client.setHintArrowTargetType(HintArrowType.PLAYER.getValue());
client.setHintArrowPlayerTargetIdx(((RSPlayer) player).getPlayerId());
hintPlayerChanged(-1);
}
@Inject

View File

@@ -234,6 +234,9 @@ public interface RSClient extends RSGameShell, Client
@Import("combatTargetPlayerIndex")
int getLocalInteractingIndex();
@Import("combatTargetPlayerIndex")
void setLocalInteractingIndex(int idx);
@Import("groundItems")
RSNodeDeque[][][] getGroundItemDeque();