From c8f6f9cb598af82bdfa08ba7da4eefe4b2bf813e Mon Sep 17 00:00:00 2001 From: MatthewGould123 Date: Sun, 28 Aug 2022 08:33:36 +0000 Subject: [PATCH] Fixed pest control spinner NPCs returning to spawn and becoming unattackable (pest control now playable again) --- .../activity/pestcontrol/PCPortalNPC.java | 158 +++++++++--------- .../pestcontrol/PestControlSession.java | 1 + .../pestcontrol/monsters/PCSpinnerNPC.java | 8 +- .../java/core/game/node/entity/npc/NPC.java | 5 +- 4 files changed, 89 insertions(+), 83 deletions(-) diff --git a/Server/src/main/java/core/game/content/activity/pestcontrol/PCPortalNPC.java b/Server/src/main/java/core/game/content/activity/pestcontrol/PCPortalNPC.java index 2ab59697a..dbafc9503 100644 --- a/Server/src/main/java/core/game/content/activity/pestcontrol/PCPortalNPC.java +++ b/Server/src/main/java/core/game/content/activity/pestcontrol/PCPortalNPC.java @@ -24,57 +24,64 @@ public final class PCPortalNPC extends AbstractNPC { /** * The splatter NPCs. */ - private static final int[][] SPLATTERS = { { 3727, 3728, 3729 }, // Novice - { 3728, 3729, 3730 }, // Intermediate - { 3729, 3730, 3731 }, // Veteran + private static final int[][] SPLATTERS = { + { 3727, 3728, 3729 }, // Novice + { 3728, 3729, 3730 }, // Intermediate + { 3729, 3730, 3731 }, // Veteran }; /** * The shifter NPCs. */ - private static final int[][] SHIFTERS = { { 3732, 3733, 3734, 3735, 3736, 3737 }, // Novice - { 3734, 3735, 3736, 3737, 3738, 3739 }, // Intermediate - { 3736, 3737, 3738, 3739, 3740, 3741 }, // Veteran + private static final int[][] SHIFTERS = { + { 3732, 3733, 3734, 3735, 3736, 3737 }, // Novice + { 3734, 3735, 3736, 3737, 3738, 3739 }, // Intermediate + { 3736, 3737, 3738, 3739, 3740, 3741 }, // Veteran }; /** * The ravager NPCs. */ - private static final int[][] RAVAGERS = { { 3742, 3743, 3744 }, // Novice - { 3743, 3744, 3745 }, // Intermediate - { 3744, 3745, 3746 }, // Veteran + private static final int[][] RAVAGERS = { + { 3742, 3743, 3744 }, // Novice + { 3743, 3744, 3745 }, // Intermediate + { 3744, 3745, 3746 }, // Veteran }; /** * The spinner NPCs. */ - private static final int[][] SPINNERS = { { 3747, 3748, 3749 }, // Novice - { 3748, 3749, 3750 }, // Intermediate - { 3749, 3750, 3751 }, // Veteran + private static final int[][] SPINNERS = { + { 3747, 3748, 3749 }, // Novice + { 3748, 3749, 3750 }, // Intermediate + { 3749, 3750, 3751 }, // Veteran }; /** * The torcher NPCs. */ - private static final int[][] TORCHERS = { { 3752, 3753, 3754, 3755, 3756, 3757 }, // Novice - { 3754, 3755, 3756, 3757, 3758, 3759 }, // Intermediate - { 3756, 3757, 3758, 3759, 3760, 3761 }, // Veteran + private static final int[][] TORCHERS = { + { 3752, 3753, 3754, 3755, 3756, 3757 }, // Novice + { 3754, 3755, 3756, 3757, 3758, 3759 }, // Intermediate + { 3756, 3757, 3758, 3759, 3760, 3761 }, // Veteran }; /** * The defiler NPCs. */ - private static final int[][] DEFILERS = { { 3762, 3763, 3764, 3765, 3766, 3767 }, // Novice - { 3764, 3765, 3766, 3767, 3768, 3769 }, // Intermediate - { 3766, 3767, 3768, 3769, 3770, 3771 }, // Veteran + private static final int[][] DEFILERS = { + { 3762, 3763, 3764, 3765, 3766, 3767 }, // Novice + { 3764, 3765, 3766, 3767, 3768, 3769 }, // Intermediate + { 3766, 3767, 3768, 3769, 3770, 3771 }, // Veteran }; /** * The brawler NPCs. */ - private static final int[][] BRAWLERS = { { 3772, 3773, 3774 }, // Novice - { 3773, 3774, 3775 }, // Intermediate - { 3774, 3775, 3776 }, // Veteran + private static final int[][] BRAWLERS = { + { 3772, 3773, 3774 }, // Novice + { 3773, 3774, 3775 }, // Intermediate + { 3774, 3775, 3776 }, // Veteran }; /** @@ -97,15 +104,14 @@ public final class PCPortalNPC extends AbstractNPC { */ private NPC[] brawlers = new NPC[2]; - /** * The portal ids? */ - final static Integer[] portalIds = new Integer[] { 6142, 6143, 6144, 6145, 6146, 6147, 6148, 6149, - - 6150, 6151, 6152, 6153, 6154, 6155, 6156, 6157, - - 7551, 7552, 7553, 7554, 7555, 7556, 7557, 7558 }; + final static Integer[] portalIds = new Integer[] { + 6142, 6143, 6144, 6145, 6146, 6147, 6148, 6149, + 6150, 6151, 6152, 6153, 6154, 6155, 6156, 6157, + 7551, 7552, 7553, 7554, 7555, 7556, 7557, 7558 + }; /** * Constructs a new {@code PCPortalNPC} {@code Object}. @@ -151,10 +157,10 @@ public final class PCPortalNPC extends AbstractNPC { } } - @Override - public boolean shouldPreventStacking(Entity mover) { - return true; - } + @Override + public boolean shouldPreventStacking(Entity mover) { + return true; + } @Override public void onImpact(final Entity entity, BattleState state) { @@ -189,49 +195,49 @@ public final class PCPortalNPC extends AbstractNPC { for (int i = 0; i < amount; i++) { int[] ids = SHIFTERS[index]; switch (r.nextInt(7)) { - case 0: - ids = SPLATTERS[index]; - break; - case 1: - ids = SHIFTERS[index]; - break; - case 2: - ids = RAVAGERS[index]; - break; - case 3: - boolean spawn = false; - for (PCSpinnerNPC npc : spinners) { - if (npc == null || !npc.isActive()) { - spawn = true; - break; + case 0: + ids = SPLATTERS[index]; + break; + case 1: + ids = SHIFTERS[index]; + break; + case 2: + ids = RAVAGERS[index]; + break; + case 3: + boolean spawn = false; + for (PCSpinnerNPC npc : spinners) { + if (npc == null || !npc.isActive()) { + spawn = true; + break; + } } - } - if (spawn) { - ids = SPINNERS[index]; - } else { + if (spawn) { + ids = SPINNERS[index]; + } else { + ids = TORCHERS[index]; + } + break; + case 4: ids = TORCHERS[index]; - } - break; - case 4: - ids = TORCHERS[index]; - break; - case 5: - ids = DEFILERS[index]; - break; - case 6: - spawn = false; - for (NPC npc : brawlers) { - if (npc == null || !npc.isActive()) { - spawn = true; - break; - } - } - if (spawn) { - ids = BRAWLERS[index]; - } else { + break; + case 5: ids = DEFILERS[index]; - } - break; + break; + case 6: + spawn = false; + for (NPC npc : brawlers) { + if (npc == null || !npc.isActive()) { + spawn = true; + break; + } + } + if (spawn) { + ids = BRAWLERS[index]; + } else { + ids = DEFILERS[index]; + } + break; } int x = dir.getStepX() * 3; int y = dir.getStepY() * 3; @@ -295,11 +301,11 @@ public final class PCPortalNPC extends AbstractNPC { @Override public int[] getIds() { - return new int[] { 6142, 6143, 6144, 6145, 6146, 6147, 6148, 6149, - - 6150, 6151, 6152, 6153, 6154, 6155, 6156, 6157, - - 7551, 7552, 7553, 7554, 7555, 7556, 7557, 7558 }; + return new int[] { + 6142, 6143, 6144, 6145, 6146, 6147, 6148, 6149, + 6150, 6151, 6152, 6153, 6154, 6155, 6156, 6157, + 7551, 7552, 7553, 7554, 7555, 7556, 7557, 7558 + }; } /** diff --git a/Server/src/main/java/core/game/content/activity/pestcontrol/PestControlSession.java b/Server/src/main/java/core/game/content/activity/pestcontrol/PestControlSession.java index c9b69c07d..23967b663 100644 --- a/Server/src/main/java/core/game/content/activity/pestcontrol/PestControlSession.java +++ b/Server/src/main/java/core/game/content/activity/pestcontrol/PestControlSession.java @@ -307,6 +307,7 @@ public final class PestControlSession { */ public NPC addNPC(NPC npc) { npc.addExtension(PestControlSession.class, this); + npc.setAttribute("no-spawn-return", true); npc.init(); return npc; } diff --git a/Server/src/main/java/core/game/content/activity/pestcontrol/monsters/PCSpinnerNPC.java b/Server/src/main/java/core/game/content/activity/pestcontrol/monsters/PCSpinnerNPC.java index 917b2dba2..6b00811b5 100644 --- a/Server/src/main/java/core/game/content/activity/pestcontrol/monsters/PCSpinnerNPC.java +++ b/Server/src/main/java/core/game/content/activity/pestcontrol/monsters/PCSpinnerNPC.java @@ -111,10 +111,10 @@ public final class PCSpinnerNPC extends AbstractNPC { }); } - @Override - public boolean shouldPreventStacking(Entity mover) { - return mover instanceof NPC; - } + @Override + public boolean shouldPreventStacking(Entity mover) { + return mover instanceof NPC; + } @Override public void onImpact(final Entity entity, BattleState state) { diff --git a/Server/src/main/java/core/game/node/entity/npc/NPC.java b/Server/src/main/java/core/game/node/entity/npc/NPC.java index 5aeac5356..9078027a9 100644 --- a/Server/src/main/java/core/game/node/entity/npc/NPC.java +++ b/Server/src/main/java/core/game/node/entity/npc/NPC.java @@ -403,9 +403,7 @@ public class NPC extends Entity { /** * Called when the NPC respawns. */ - protected void onRespawn() { - - } + protected void onRespawn() {} /** * Handles the automatic actions of the NPC. @@ -417,6 +415,7 @@ public class NPC extends Entity { !pathBoundMovement && walkRadius > 0 && !getLocation().withinDistance(getProperties().getSpawnLocation(), (int)(walkRadius * 1.5)) + && !getAttribute("no-spawn-return", false) ) { if(!isNeverWalks()){