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); 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 * Sets whether 2D sprites (ie. overhead prayers) related to
* the NPCs are hidden. * the NPCs are hidden.

View File

@@ -142,6 +142,17 @@ public interface EntityHiderConfig extends Config
return ""; 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( @ConfigItem(
position = 11, position = 11,
keyName = "hideProjectiles", keyName = "hideProjectiles",

View File

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

View File

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

View File

@@ -68,7 +68,10 @@ public abstract class EntityHiderMixin implements RSScene
private static boolean hideNPCs; private static boolean hideNPCs;
@Shadow("hideNPCsNames") @Shadow("hideNPCsNames")
private static String hideNPCsNames; private static String hideNPCsNames;
@Shadow("hideNPCsOnDeath")
private static String hideNPCsOnDeath;
@Shadow("hideNPCs2D") @Shadow("hideNPCs2D")
private static boolean hideNPCs2D; private static boolean hideNPCs2D;
@@ -158,6 +161,7 @@ public abstract class EntityHiderMixin implements RSScene
{ {
RSNPC npc = (RSNPC) renderable; RSNPC npc = (RSNPC) renderable;
String[] names = hideNPCsNames.split(","); String[] names = hideNPCsNames.split(",");
String[] removeOnDeath = hideNPCsOnDeath.split(",");
if (!hideAttackers) if (!hideAttackers)
{ {
@@ -176,12 +180,20 @@ public abstract class EntityHiderMixin implements RSScene
{ {
if (name != null && !name.equals("")) 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;
} }
} }
} }