Added NPC kill counts with message display (#644)

* Added kill counts with message display

* Fixed barrows chest count

* Preserve insertion order of NPC IDs for Constants

* Added KC command and interfaces

* Added more robustness to KC command

* Added alias and documentation to new commands

* Added more aliases for new commands

* Merged slayer KC interface names

* Preserve slayerkc nameToKills insertion order and formatting fix

* Updated comment

* Added missing boss NPC id

* Moved giant mole up in set

* Emptied out quest interface properly for kc

* Fixed whitespace

* Fixed formatting

* Hide boss KC messages by default
This commit is contained in:
ipkpjersi
2024-09-20 21:40:58 -04:00
committed by GitHub
parent fd731242dd
commit e404eadb3b
7 changed files with 318 additions and 5 deletions
@@ -65,6 +65,10 @@ public class Npc {
transformUpdateRequired = true;
updateRequired = true;
}
public String name() {
return NpcHandler.getNpcListName(this.npcType);
}
public void shearSheep(Player player, int itemNeeded, int itemGiven, int animation, final int currentId, final int newId, int transformTime) {
if (!player.getItemAssistant().playerHasItem(itemNeeded)) {
@@ -333,28 +333,34 @@ public class NpcHandler {
npcs[slot] = newNPC;
}
private void killedBarrow(int i) {
private boolean killedBarrow(int i) {
boolean barrows = false;
Player c = (Client) PlayerHandler.players[npcs[i].killedBy];
if (c != null) {
for (int o = 0; o < c.barrowsNpcs.length; o++) {
if (npcs[i].npcType == c.barrowsNpcs[o][0]) {
c.barrowsNpcs[o][1] = 2; // 2 for dead
c.barrowsKillCount++;
barrows = true;
}
}
}
return barrows;
}
private void killedCrypt(int i) {
private boolean killedCrypt(int i) {
boolean crypt = false;
Player c = (Client) PlayerHandler.players[npcs[i].killedBy];
if (c != null) {
for (int o = 0; o < c.barrowCrypt.length; o++) {
if (npcs[i].npcType == c.barrowCrypt[o][0]) {
c.barrowsKillCount++;
c.getPacketSender().sendString("" + c.barrowsKillCount, 4536);
crypt = true;
}
}
}
return crypt;
}
public void newNPC(int npcType, int x, int y, int heightLevel,
@@ -747,10 +753,16 @@ public class NpcHandler {
npcs[i].animUpdateRequired = true;
npcs[i].freezeTimer = 0;
npcs[i].applyDead = true;
killedBarrow(i);
killedCrypt(i);
boolean barrows = killedBarrow(i);
boolean crypt = killedCrypt(i);
npcs[i].actionTimer = 4; // delete time
resetPlayersInCombat(i);
if (!crypt && !barrows && c != null) {
c.incrementNpcKillCount(npcs[i].npcType, 1);
if (c.displayRegularKcMessages || (c.displayBossKcMessages && Constants.BOSS_NPC_IDS.contains(npcs[i].npcType)) || (c.displaySlayerKcMessages && Constants.SLAYER_NPC_IDS.contains(npcs[i].npcType))) {
c.getPacketSender().sendMessage("Your " + npcs[i].name() + " kill count is now: " + c.getNpcKillCount(npcs[i].npcType));
}
}
} else if (npcs[i].actionTimer == 0
&& npcs[i].applyDead
&& npcs[i].needRespawn == false) {