entityhider: Hide npcs on death. (#1195)

This commit is contained in:
Ganom
2019-07-30 10:34:04 -04:00
committed by Kyleeld
parent 659bfe889c
commit 252b3bb06b
5 changed files with 49 additions and 9 deletions

View File

@@ -1456,6 +1456,13 @@ public interface Client extends GameShell
*/
void setNPCsNames(String names);
/**
* Sets which NPCs are hidden on death
*
* @param names the names of the npcs seperated by ','
*/
void setNPCsHiddenOnDeath(String names);
/**
* Sets whether 2D sprites (ie. overhead prayers) related to
* the NPCs are hidden.
@@ -1685,9 +1692,9 @@ public interface Client extends GameShell
MouseRecorder getMouseRecorder();
void setPrintMenuActions(boolean b);
String getSelectedSpellName();
boolean isSpellSelected();
/**
@@ -1714,7 +1721,7 @@ public interface Client extends GameShell
* Set spells excluded from above hiding
*/
void setUnhiddenCasts(Set<String> casts);
/**
* Sorts the current menu entries in the same way the client does this.
* The last entry will be the left click one after this.

View File

@@ -142,6 +142,17 @@ public interface EntityHiderConfig extends Config
return "";
}
@ConfigItem(
position = 10,
keyName = "hideNPCsOnDeath",
name = "Hide NPCs On Death",
description = "Configures which NPCs to hide when they die"
)
default String hideNPCsOnDeath()
{
return "";
}
@ConfigItem(
position = 11,
keyName = "hideProjectiles",

View File

@@ -108,6 +108,7 @@ public class EntityHiderPlugin extends Plugin
client.setNPCsHidden(config.hideNPCs());
client.setNPCsHidden2D(config.hideNPCs2D());
client.setNPCsNames(config.hideNPCsNames());
client.setNPCsHiddenOnDeath(config.hideNPCsOnDeath());
client.setAttackersHidden(config.hideAttackers());

View File

@@ -70,6 +70,8 @@ public abstract class EntityHiderBridgeMixin implements RSClient
@Inject
public static String hideNPCsNames;
@Inject
public static String hideNPCsOnDeath;
@Inject
@Override
@@ -141,6 +143,13 @@ public abstract class EntityHiderBridgeMixin implements RSClient
hideNPCsNames = NPCs;
}
@Inject
@Override
public void setNPCsHiddenOnDeath(String NPCs)
{
hideNPCsOnDeath = NPCs;
}
@Inject
@Override
public void setAttackersHidden(boolean state)

View File

@@ -68,7 +68,10 @@ public abstract class EntityHiderMixin implements RSScene
private static boolean hideNPCs;
@Shadow("hideNPCsNames")
private static String hideNPCsNames;
private static String hideNPCsNames;
@Shadow("hideNPCsOnDeath")
private static String hideNPCsOnDeath;
@Shadow("hideNPCs2D")
private static boolean hideNPCs2D;
@@ -158,6 +161,7 @@ public abstract class EntityHiderMixin implements RSScene
{
RSNPC npc = (RSNPC) renderable;
String[] names = hideNPCsNames.split(",");
String[] removeOnDeath = hideNPCsOnDeath.split(",");
if (!hideAttackers)
{
@@ -176,12 +180,20 @@ public abstract class EntityHiderMixin implements RSScene
{
if (name != null && !name.equals(""))
{
if (npc.getName() != null)
if (npc.getName() != null && npc.getName().startsWith(name))
{
if (npc.getName().startsWith(name))
{
return false;
}
return false;
}
}
}
for (String name : removeOnDeath)
{
if (name != null && !name.equals(""))
{
if (npc.getName() != null && npc.getName().startsWith(name) && npc.getHealthRatio() == 0)
{
return false;
}
}
}