diff --git a/Server/src/main/content/region/kandarin/seers/quest/merlinsquest/MerlinCrystalPlugin.java b/Server/src/main/content/region/kandarin/seers/quest/merlinsquest/MerlinCrystalPlugin.java index 2f339872d..ce2695d38 100644 --- a/Server/src/main/content/region/kandarin/seers/quest/merlinsquest/MerlinCrystalPlugin.java +++ b/Server/src/main/content/region/kandarin/seers/quest/merlinsquest/MerlinCrystalPlugin.java @@ -67,7 +67,6 @@ public final class MerlinCrystalPlugin extends OptionHandler { SceneryDefinition.forId(71).getHandlers().put("option:open", this); SceneryDefinition.forId(71).getHandlers().put("option:knock-at", this); SceneryDefinition.forId(72).getHandlers().put("option:knock-at", this); - ItemDefinition.forId(530).getHandlers().put("option:drop", this); SceneryDefinition.forId(62).getHandlers().put("option:smash", this); return this; } @@ -128,24 +127,6 @@ public final class MerlinCrystalPlugin extends OptionHandler { DoorActionHandler.handleAutowalkDoor(player, node.asScenery()); } return true; - case 530: - if (player.getLocation().equals(new Location(2780, 3515, 0)) && quest.getStage(player) == 80) { - if (player.getInventory().contains(32, 1) && player.getAttribute("thrantax_npc") == null) { - ForceMovement.run(player, player.getLocation().transform(-2, 0, 0)).setDirection(Direction.EAST); - NPC npc = new ThrantaxNPC(player, Location.create(2780, 3515, 0)); - npc.init(); - npc.setRespawn(false); - player.setAttribute("thrantax_npc", npc); - npc.setAttribute("thrantax_owner", player.getUsername()); - player.getDialogueInterpreter().open("thrantax_dialogue", 34, 248); - } else { - player.getDialogueInterpreter().sendDialogue("You'll need to light the black candle before the spirit", "will appear."); - } - return true; - } else { - DropListener.drop(player, node.asItem()); - } - return true; case 40026: if (player.getLocation().withinDistance(Location.create(3013, 3245, 0)) && quest.getStage(player) == 60 && player.getAttribute("beggar_npc") == null) { NPC npc = new BeggarNPC(player, Location.create(3012, 3248, 1)); @@ -493,68 +474,6 @@ public final class MerlinCrystalPlugin extends OptionHandler { } } - /** - * Handles the thrantax npc. - * @author Vexia - */ - public final class ThrantaxNPC extends NPC { - - /** - * The player. - */ - private final Player player; - - /** - * Constructs a new {@code AnimatedArmour} {@code Object}. - * @param player The player. - * @param location The location to spawn. - */ - protected ThrantaxNPC(Player player, Location location) { - super(238, location); - this.player = player; - } - - @Override - public boolean isHidden(final Player player) { - if (player.getQuestRepository().getQuest("Merlin's Crystal").getStage(player) == 80 && this.getAttribute("thrantax_owner", "").equals(player.getUsername())) { - return false; - } - return true; - } - - @Override - public void init() { - super.init(); - } - - @Override - public void handleTickActions() { - if (player != null && !player.isActive() || player != null && !player.getLocation().withinDistance(getLocation(), 20)) { - clear(); - } - super.handleTickActions(); - } - - @Override - public void finalizeDeath(Entity entity) { - if (entity instanceof Player) { - Player p = entity.asPlayer(); - super.finalizeDeath(p); - } - } - - @Override - public boolean canAttack(Entity entity) { - return getAttribute("thrantax_owner", entity) == entity; - } - - @Override - public void clear() { - super.clear(); - player.getHintIconManager().clear(); - } - } - /** * Used for item handling during the quest. * @author Adam Rodrigues diff --git a/Server/src/main/content/region/kandarin/seers/quest/merlinsquest/MerlinListeners.kt b/Server/src/main/content/region/kandarin/seers/quest/merlinsquest/MerlinListeners.kt new file mode 100644 index 000000000..ab153b6e9 --- /dev/null +++ b/Server/src/main/content/region/kandarin/seers/quest/merlinsquest/MerlinListeners.kt @@ -0,0 +1,41 @@ +package content.region.kandarin.seers.quest.merlinsquest + +import core.api.* +import core.game.interaction.* +import core.game.world.map.Location +import core.game.world.map.Direction +import core.game.global.action.DropListener +import core.game.node.entity.npc.NPC +import core.game.node.entity.impl.ForceMovement +import org.rs09.consts.Items +import org.rs09.consts.NPCs + +class MerlinListeners : InteractionListener { + private val BONE_DROP_LOCATION = Location(2780, 3515, 0) + + override fun defineListeners() { + on (Items.BAT_BONES_530, IntType.ITEM, "drop") { player, node -> + val merlinStage = questStage(player, "Merlin's Crystal") + var doingQuest = player.location == BONE_DROP_LOCATION && merlinStage == 80 + var hasAuxiliaryRequirements = inInventory(player, Items.LIT_BLACK_CANDLE_32) && getAttribute(player, "thrantax_npc", null) == null + + if (doingQuest && hasAuxiliaryRequirements) { + ForceMovement.run(player, player.location.transform(-2, 0, 0)).direction = Direction.EAST + var npc = ThrantaxNPC(player, Location(2780, 3515, 0)) + npc.player = player + npc.init() + npc.isRespawn = false + setAttribute(player, "thrantax_npc", npc) + setAttribute(npc, "thrantax_owner", player.username) + player.dialogueInterpreter.open("thrantax_dialogue", 34, 248) + return@on true + } else if (doingQuest) { + sendDialogue(player, "You'll need to light the black candle before the spirit will appear.") + return@on true + } + + DropListener.drop(player, node.asItem()) + return@on true + } + } +} diff --git a/Server/src/main/content/region/kandarin/seers/quest/merlinsquest/ThrantaxNPC.java b/Server/src/main/content/region/kandarin/seers/quest/merlinsquest/ThrantaxNPC.java new file mode 100644 index 000000000..d96b52f7c --- /dev/null +++ b/Server/src/main/content/region/kandarin/seers/quest/merlinsquest/ThrantaxNPC.java @@ -0,0 +1,68 @@ +package content.region.kandarin.seers.quest.merlinsquest; + +import core.game.node.entity.Entity; +import core.game.node.entity.player.Player; +import core.game.node.entity.npc.NPC; +import core.game.world.map.Location; + +/** + * Handles the thrantax npc. + * @author Vexia + */ +public class ThrantaxNPC extends NPC { + + /** + * The player. + */ + public Player player; + + /** + * Constructs a new {@code AnimatedArmour} {@code Object}. + * @param player The player. + * @param location The location to spawn. + */ + protected ThrantaxNPC(Player player, Location location) { + super(238, location); + this.player = player; + } + + @Override + public boolean isHidden(final Player player) { + if (player.getQuestRepository().getQuest("Merlin's Crystal").getStage(player) == 80 && this.getAttribute("thrantax_owner", "").equals(player.getUsername())) { + return false; + } + return true; + } + + @Override + public void init() { + super.init(); + } + + @Override + public void handleTickActions() { + if (player != null && !player.isActive() || player != null && !player.getLocation().withinDistance(getLocation(), 20)) { + clear(); + } + super.handleTickActions(); + } + + @Override + public void finalizeDeath(Entity entity) { + if (entity instanceof Player) { + Player p = entity.asPlayer(); + super.finalizeDeath(p); + } + } + + @Override + public boolean canAttack(Entity entity) { + return getAttribute("thrantax_owner", entity) == entity; + } + + @Override + public void clear() { + super.clear(); + player.getHintIconManager().clear(); + } +}