From 8e9bb5e44807301d3c2b5fb7a1c680b155c3889a Mon Sep 17 00:00:00 2001 From: ceikry Date: Sat, 25 Feb 2023 11:31:44 -0600 Subject: [PATCH] Implement plate pure integration with OpenRSC --- .../handlers/iface/MagicBookInterface.java | 1 - .../global/skill/magic/SpellListeners.kt | 3 + .../quest/dragonslayer/DragonSlayer.kt | 800 +++++++++++------- .../quest/dragonslayer/WormbrainDialogue.java | 2 + Server/src/main/core/ServerConstants.kt | 3 + Server/src/main/core/game/event/Events.kt | 2 +- .../main/core/game/node/entity/Entity.java | 3 +- .../node/entity/combat/spell/MagicSpell.java | 2 + .../game/system/config/ServerConfigParser.kt | 1 + .../main/core/integrations/discord/Discord.kt | 12 + 10 files changed, 503 insertions(+), 326 deletions(-) diff --git a/Server/src/main/content/global/handlers/iface/MagicBookInterface.java b/Server/src/main/content/global/handlers/iface/MagicBookInterface.java index e29e7f114..af5c87baa 100644 --- a/Server/src/main/content/global/handlers/iface/MagicBookInterface.java +++ b/Server/src/main/content/global/handlers/iface/MagicBookInterface.java @@ -44,7 +44,6 @@ public final class MagicBookInterface extends ComponentPlugin { SpellListeners.run(button, SpellListener.NONE, SpellUtils.getBookFromInterface(component.getId()),player,null); boolean result = MagicSpell.castSpell(player, spellBook, button, player); - player.dispatch(new SpellCastEvent(spellBook, button)); return result; } diff --git a/Server/src/main/content/global/skill/magic/SpellListeners.kt b/Server/src/main/content/global/skill/magic/SpellListeners.kt index d90356132..b01c41999 100644 --- a/Server/src/main/content/global/skill/magic/SpellListeners.kt +++ b/Server/src/main/content/global/skill/magic/SpellListeners.kt @@ -1,7 +1,9 @@ package content.global.skill.magic +import core.game.event.SpellCastEvent import core.game.node.Node import core.game.node.entity.player.Player +import core.game.node.entity.player.link.SpellBookManager import core.tools.SystemLogger object SpellListeners { @@ -32,6 +34,7 @@ object SpellListeners { val method = get(button,type,node?.id ?: 0,book) ?: get(button,type,book) ?: return try { method.invoke(player, node) + player.dispatch(SpellCastEvent(SpellBookManager.SpellBook.valueOf(book.uppercase()), button, node)) } catch (e: IllegalStateException){ player.removeAttribute("spell:runes") return diff --git a/Server/src/main/content/region/misthalin/varrock/quest/dragonslayer/DragonSlayer.kt b/Server/src/main/content/region/misthalin/varrock/quest/dragonslayer/DragonSlayer.kt index 7f70e513c..40857c979 100644 --- a/Server/src/main/content/region/misthalin/varrock/quest/dragonslayer/DragonSlayer.kt +++ b/Server/src/main/content/region/misthalin/varrock/quest/dragonslayer/DragonSlayer.kt @@ -1,351 +1,505 @@ -package content.region.misthalin.varrock.quest.dragonslayer; +package content.region.misthalin.varrock.quest.dragonslayer -import core.game.component.Component; -import core.game.node.entity.player.Player; -import core.game.node.entity.player.link.quest.Quest; -import core.game.node.entity.skill.Skills; -import content.global.skill.agility.AgilityHandler; -import core.game.node.item.Item; -import core.game.node.scenery.Scenery; -import core.game.system.task.Pulse; -import core.game.world.map.Location; -import core.game.world.map.RegionManager; -import core.game.world.update.flag.context.Animation; -import core.plugin.Initializable; -import content.region.misthalin.lumbridge.dialogue.DukeHoracioDialogue; -import core.game.world.GameWorld; -import core.plugin.ClassScanner; +import content.global.skill.agility.AgilityHandler +import content.region.misthalin.lumbridge.dialogue.DukeHoracioDialogue +import core.api.Event +import core.api.LoginListener +import core.api.questStage +import core.game.component.Component +import core.game.event.EventHook +import core.game.event.PickUpEvent +import core.game.event.SpellCastEvent +import core.game.node.entity.Entity +import core.game.node.entity.player.Player +import core.game.node.entity.player.link.quest.Quest +import core.game.node.entity.skill.Skills +import core.game.node.item.Item +import core.game.system.task.Pulse +import core.game.world.GameWorld.Pulser +import core.game.world.map.Location +import core.game.world.map.RegionManager.getObject +import core.game.world.update.flag.context.Animation +import core.integrations.discord.Discord +import core.plugin.ClassScanner.definePlugins +import core.plugin.Initializable +import org.rs09.consts.Items /** * Represents the dragon slayer quest. - * @author Vexia - * + * @author Vexia - Converted to Kotlin with use of event hooks by not-Vexia */ @Initializable -public final class DragonSlayer extends Quest { +class DragonSlayer : Quest("Dragon Slayer", 18, 17, 2, 176, 0, 1, 10), LoginListener { + override fun newInstance(`object`: Any?): Quest { + definePlugins( + CrandorMapPlugin(), + DragonSlayerPlugin(), + DSMagicDoorPlugin(), + DragonSlayerCutscene(), + MazeDemonNPC(), + MazeGhostNPC(), + MazeSkeletonNPC(), + MazeZombieNPC(), + MeldarMadNPC(), + WormbrainNPC(), + ZombieRatNPC(), + DSChestDialogue(), + GuildmasterDialogue(), + ElvargNPC(), + WormbrainDialogue(), + OziachDialogue(), + NedDialogue(), + DukeHoracioDialogue() + ) + return this + } - /** - * Represents the maze key given by the guildmaster. - */ - public static final Item MAZE_KEY = new Item(1542); + override fun drawJournal(player: Player, stage: Int) { + super.drawJournal(player, stage) + when (getStage(player)) { + 0 -> { + player.packetDispatch.sendString( + BLUE + "I can start this quest by speaking to the " + RED + "Guildmaster " + BLUE + "in", + 275, + 4 + 7 + ) + player.packetDispatch.sendString( + BLUE + "the " + RED + "Champions' Guild" + BLUE + " , south-west of Varrock.", + 275, + 5 + 7 + ) + player.packetDispatch.sendString( + BLUE + "I will need to be able to defeat a " + RED + "level 83 dragon.", + 275, + 6 + 7 + ) + if (player.questRepository.points < 32) { + player.packetDispatch.sendString( + BLUE + "To enter the Champions' Guild I need" + RED + " 32 Quest Points.", + 275, + 7 + 7 + ) + } else { + player.packetDispatch.sendString( + "To enter the Champions' Guild I need 32 Quest Points.", + 275, + 7 + 7 + ) + } + } - /** - * Represents the red key item. - */ - public static final Item RED_KEY = new Item(1543); + 10 -> { + line(player, "The Guildmaster of the Champions' Guild said I could earn", 4 + 7) + line(player, "the right to wear rune armour if I went on a quest for", 5 + 7) + line(player, "Oziach, who makes the armour.", 6 + 7) + line( + player, + BLUE + "I should speak to " + RED + "Oziach" + BLUE + ", who lives by the cliffs to the", + 7 + 7 + ) + line(player, BLUE + "west of " + RED + "Edgeville.", 8 + 7) + } - /** - * Represents the orange key item. - */ - public static final Item ORANGE_KEY = new Item(1544); + 15 -> { + line(player, "The Guildmaster of the Champions' Guild said I could earn", 4 + 7) + line(player, "the right to wear rune armour if I went on a quest for", 5 + 7) + line(player, "Oziach, who makes the armour.", 6 + 7) + line(player, "I spoke to Oziach in Edgeville. He told me to slay the", 7 + 7) + line(player, "dragon of Crandor island.", 8 + 7) + line( + player, + BLUE + "I should return to the " + RED + "Champions' Guild Guildmaster " + BLUE + "for", + 9 + 7 + ) + line(player, BLUE + "more detailed instructions.", 10 + 7) + } - /** - * Represents the yellow key item. - */ - public static final Item YELLOW_KEY = new Item(1545); + 20 -> { + line(player, "The Guildmaster of the Champions' Guild said I could earn", 4 + 7) + line(player, "the right to wear rune armour if I went on a quest for", 5 + 7) + line(player, "Oziach, who makes the armour.", 6 + 7) + line(player, "I spoke to Oziach in Edgeville. He told me to slay the", 7 + 7) + line(player, "dragon of Crandor island.", 8 + 7) + line(player, "The Champions' Guild Guildmaster gave me more detailed", 9 + 7) + line(player, "instructions.", 10 + 7) + line( + player, + BLUE + "To defeat the dragon I will need to find a " + RED + "map " + BLUE + "to Crandor, a", + 11 + 7 + ) + line( + player, + RED + "ship" + BLUE + ", a " + RED + "captain " + BLUE + "to take me there and some kind of", + 12 + 7 + ) + line(player, RED + "protection " + BLUE + "against the dragon's breath.", 13 + 7) + if (!player.inventory.containsItem(MAZE_PIECE) && !player.bank.containsItem(MAZE_PIECE)) { + line(player, BLUE + "One-third of the map is in " + RED + "Melzar's Maze" + BLUE + ", near", 14 + 7) + line(player, RED + "Rimmington" + ".", 15 + 7) + } else { + line(player, "I found the piece of the map that was hidden in Melzar's", 14 + 7) + line(player, "Maze.", 15 + 7) + } + if (!player.inventory.containsItem(MAGIC_PIECE) && !player.bank.containsItem(MAGIC_PIECE)) { + line( + player, + BLUE + "One)2third of the map is hidden and only the " + RED + "Oracle " + BLUE + "on " + RED + "Ice", + 16 + 7 + ) + line(player, RED + "Mountain" + BLUE + " will know where it is.", 17 + 7) + } else { + line(player, "I found the piece of the map that was hidden beneath Ice", 16 + 7) + line(player, "Mountain.", 18 + 7) + } + if (!player.inventory.containsItem(WORMBRAIN_PIECE) && !player.bank.containsItem(WORMBRAIN_PIECE)) { + line( + player, + BLUE + "One-third of the map was stolen by a " + RED + "goblin " + BLUE + "from the", + 18 + 7 + ) + line(player, RED + "Goblin Village.", 19 + 7) + } else { + line(player, "I found the piece of the map that the goblin, Wormbrain,", 18 + 7) + line(player, "stole.", 19 + 7) + } + if (!player.inventory.containsItem(SHIELD) && !player.bank.containsItem(SHIELD)) { + line( + player, + BLUE + "I should ask the " + RED + "Duke of Lumbridge " + BLUE + "for an " + RED + "anti-", + 20 + 7 + ) + line(player, RED + "dragonbreath shield.", 21 + 7) + } else { + line(player, "The Duke of Lumbridge gave me an anti-dragonbreath", 20 + 7) + line(player, "shield.", 21 + 7) + } + if (!player.savedData.questData.getDragonSlayerAttribute("ship")) { + line( + player, + BLUE + "I should see if there is a " + RED + "ship " + BLUE + "for sale in " + RED + "Port Sarim", + 22 + 7 + ) + } else { + line(player, "I bought a ship in Port Sarim called the Lady Lumbridge.", 22 + 7) + if (!player.savedData.questData.getDragonSlayerAttribute("repaired")) { + line(player, "I need to repair the hole in bottom of the ship.", 23 + 7) + } else { + line(player, "I have repaired my ship using wooden planks and steel", 23 + 7) + line(player, "nails.", 24 + 7) + } + } + } - /** - * Represents the blue key item. - */ - public static final Item BLUE_KEY = new Item(1546); + 30 -> { + line(player, "The Guildmaster of the Champions' Guild said I could earn", 4 + 7) + line(player, "the right to wear rune armour if I went on a quest for", 5 + 7) + line(player, "Oziach, who makes the armour.", 6 + 7) + line(player, "I spoke to Oziach in Edgeville. He told me to slay the", 7 + 7) + line(player, "dragon of Crandor island.", 8 + 7) + line(player, "The Champions' Guild Guildmaster told me I had to find", 9 + 7) + line(player, "three pieces of a map to Crandor, a ship, a captain to take", 10 + 7) + line(player, "me there and a shield to protect me from the dragon's", 11 + 7) + line(player, "breath.", 12 + 7) + line(player, "I found the piece of the map that was hidden in Melzar's", 13 + 7) + line(player, "Maze.", 14 + 7) + line(player, "I found the piece of the map that was hidden beneath Ice", 15 + 7) + line(player, "Mountain.", 16 + 7) + line(player, "I found the piece of the map that the goblin, Wormbrain,", 17 + 7) + line(player, "stole.", 18 + 7) + line(player, "The Duke of Lumbridge gave me an anti-dragonbreath", 19 + 7) + line(player, "shield.", 20 + 7) + line(player, "I bought a ship in Port Sarim called the Lady Lumbridge", 21 + 7) + line(player, "I have repaired my ship using wooden planks and steel", 22 + 7) + line(player, "nails.", 23 + 7) + line(player, "Captain Ned from Draynor Village has agreed to sail the", 24 + 7) + line(player, "ship to Crandor for me.", 25 + 7) + line( + player, + BLUE + "Now I should go to my ship in " + RED + "Port Sarim " + BLUE + "and set sail for", + 26 + 7 + ) + line(player, RED + "Crandor" + BLUE + "!", 27 + 7) + } - /** - * Represents the purple key item. - */ - public static final Item PURPLE_KEY = new Item(1547); + 40 -> { + line(player, "The Guildmaster of the Champions' Guild said I could earn", 4 + 7) + line(player, "the right to wear rune armour if I went on a quest for", 5 + 7) + line(player, "Oziach, who makes the armour.", 6 + 7) + line(player, "I spoke to Oziach in Edgeville. He told me to slay the", 7 + 7) + line(player, "dragon of Crandor island.", 8 + 7) + line(player, "The Champions' Guild Guildmaster told me I had to find", 9 + 7) + line(player, "three pieces of a map to Crandor, a ship, a captain to take", 10 + 7) + line(player, "me there and a shield to protect me from the dragon's", 11 + 7) + line(player, "breath.", 12 + 7) + line(player, "I found the piece of the map that was hidden in Melzar's", 13 + 7) + line(player, "Maze.", 14 + 7) + line(player, "I found the piece of the map that was hidden beneath Ice", 15 + 7) + line(player, "Mountain.", 16 + 7) + line(player, "I found the piece of the map that the goblin, Wormbrain,", 17 + 7) + line(player, "stole.", 18 + 7) + line(player, "The Duke of Lumbridge gave me an anti-dragonbreath", 19 + 7) + line(player, "shield.", 20 + 7) + if (!player.getAttribute("demon-slayer:memorize", false)) { + if (!player.inventory.containsItem(ELVARG_HEAD)) { + line(player, BLUE + "Now all I need to do is kill the " + RED + "dragon" + BLUE + "!", 21 + 7) + } else { + line( + player, + BLUE + "I have slain the dragon! Now I just need to tell " + RED + "Oziach.", + 21 + 7 + ) + } + } else { + line(player, "I have found a secret passage leading from Karamja to", 21 + 7) + line(player, "Crandor, so I no longer need to worry about finding a", 22 + 7) + line(player, "seaworthy ship and captain to take me there.", 23 + 7) + if (!player.inventory.containsItem(ELVARG_HEAD)) { + line(player, BLUE + "Now all I need to do is kill the " + RED + "dragon" + BLUE + "!", 24 + 7) + } else { + line( + player, + BLUE + "I have slain the dragon! Now I just need to tell " + RED + "Oziach.", + 24 + 7 + ) + } + } + } - /** - * Represents the green key item. - */ - public static final Item GREEN_KEY = new Item(1548); + 100 -> { + line(player, "The Guildmaster of the Champions' Guild said I could earn", 4 + 7) + line(player, "the right to wear rune armour if I went on a quest for", 5 + 7) + line(player, "Oziach, who makes the armour.", 6 + 7) + line(player, "I spoke to Oziach in Edgeville. He told me to slay the", 7 + 7) + line(player, "dragon of Crandor island.", 8 + 7) + line(player, "The Champions' Guild Guildmaster told me I had to find", 9 + 7) + line(player, "three pieces of a map to Crandor, a ship, a captain to take", 10 + 7) + line(player, "me there and a shield to protect me from the dragon's", 11 + 7) + line(player, "breath.", 12 + 7) + line(player, "I found the piece of the map that was hidden in Melzar's", 13 + 7) + line(player, "Maze.", 14 + 7) + line(player, "I found the piece of the map that was hidden beneath Ice", 15 + 7) + line(player, "Mountain.", 16 + 7) + line(player, "I found the piece of the map that the goblin, Wormbrain,", 17 + 7) + line(player, "stole.", 18 + 7) + line(player, "The Duke of Lumbridge gave me an anti-dragonbreath", 19 + 7) + line(player, "shield.", 20 + 7) + line(player, "I have found a secret passage leading from Karamja to", 21 + 7) + line(player, "Crandor, so I no longer need to worry about finding a", 22 + 7) + line(player, "seaworthy ship and captain to take me there.", 23 + 7) + line(player, "I sailed to Crandor and killed the dragon. I am not a true", 24 + 7) + line(player, "champion and have proved myself worthy to wear rune", 25 + 7) + line(player, "platemail!", 26 + 7) + line(player, "QUEST COMPLETE!", 27 + 7) + line( + player, + BLUE + "I gained " + RED + "2 Quest Points" + BLUE + ", " + RED + "18,650 Strength XP" + BLUE + ", " + RED + "18,650", + 28 + 7 + ) + line(player, RED + "Defence XP " + BLUE + "and the right to wear " + RED + "rune platebodies.", 29 + 7) + } + } + } - /** - * Represents the maze map piece. - */ - public static final Item MAZE_PIECE = new Item(1535); + override fun finish(player: Player) { + super.finish(player) + player.packetDispatch.sendString("2 Quests Points", 277, 8 + 2) + player.packetDispatch.sendString("Ability to wear rune platebody", 277, 9 + 2) + player.packetDispatch.sendString("18,650 Strength XP", 277, 10 + 2) + player.packetDispatch.sendString("18,650 Defence XP", 277, 11 + 2) + player.packetDispatch.sendString("You have completed the Dragon Slayer Quest!", 277, 2 + 2) + player.packetDispatch.sendItemZoomOnInterface(ELVARG_HEAD.id, 230, 277, 3 + 2) + player.getSkills().addExperience(Skills.STRENGTH, 18650.0) + player.getSkills().addExperience(Skills.DEFENCE, 18650.0) + player.unhook(SpellCastHook) + player.unhook(PickedUpHook) + } - /** - * Represents the magic door map piece. - */ - public static final Item MAGIC_PIECE = new Item(1537); + override fun setStage(player: Player, stage: Int) { + super.setStage(player, stage) + if (stage == 20) { + player.hook(Event.SpellCast, SpellCastHook) + player.hook(Event.PickedUp, PickedUpHook) + } + } - /** - * Represents the wormbrain piece. - */ - public static final Item WORMBRAIN_PIECE = new Item(1536); + override fun login(player: Player) { + if (questStage(player, this.name) == 20) { + player.hook(Event.SpellCast, SpellCastHook) + player.hook(Event.PickedUp, PickedUpHook) + } + } - /** - * Represents the anti dragon fire shield. - */ - public static final Item SHIELD = new Item(1540); + private val SpellCastHook = object : EventHook { + override fun process(entity: Entity, event: SpellCastEvent) { + if (event.spellId == 19 && event.target != null && event.target.id == Items.MAP_PART_1536) {//telegrab + Discord.sendToOpenRSC(entity.name, "Player obtained Wormbrain piece! (Murder-Then-Telegrab)") + entity.unhook(this) + } + } + } - /** - * Represents the crandor map item. - */ - public static final Item CRANDOR_MAP = new Item(1538); + private val PickedUpHook = object : EventHook { + override fun process(entity: Entity, event: PickUpEvent) { + if (event.itemId == Items.MAP_PART_1536) { + Discord.sendToOpenRSC(entity.name, "Player obtained Wormbrain piece! (Yoinked-Off-Floor)") + entity.unhook(this) + } + } + } - /** - * Represents the map component interface. - */ - public static final Component MAP_COMPONENT = new Component(547); + companion object { + /** + * Represents the maze key given by the guildmaster. + */ + @JvmField + val MAZE_KEY = Item(1542) - /** - * Represents the nails item. - */ - public static final Item NAILS = new Item(1539, 30); + /** + * Represents the red key item. + */ + @JvmField + val RED_KEY = Item(1543) - /** - * Represents the plank item. - */ - public static final Item PLANK = new Item(960); + /** + * Represents the orange key item. + */ + @JvmField + val ORANGE_KEY = Item(1544) - /** - * Represents the hammer item. - */ - public static final Item HAMMER = new Item(2347); + /** + * Represents the yellow key item. + */ + @JvmField + val YELLOW_KEY = Item(1545) - /** - * Represents the elvarg head item. - */ - public static final Item ELVARG_HEAD = new Item(11279); + /** + * Represents the blue key item. + */ + @JvmField + val BLUE_KEY = Item(1546) - /** - * Constructs a new {@Code DragonSlayer} {@Code Object} - */ - public DragonSlayer() { - super("Dragon Slayer", 18, 17, 2, 176, 0, 1, 10); - } - - @Override - public Quest newInstance(Object object) { - ClassScanner.definePlugins(new CrandorMapPlugin(), new DragonSlayerPlugin(), new DSMagicDoorPlugin(), new DragonSlayerCutscene(), new MazeDemonNPC(), new MazeGhostNPC(), new MazeSkeletonNPC(), new MazeZombieNPC(), new MeldarMadNPC(), new WormbrainNPC(), new ZombieRatNPC(), new DSChestDialogue(), new GuildmasterDialogue(), new ElvargNPC(), new WormbrainDialogue(), new OziachDialogue(), new NedDialogue(), new DukeHoracioDialogue()); - return this; - } - - @Override - public void drawJournal(Player player, int stage) { - super.drawJournal(player, stage); - switch (getStage(player)) { - case 0: - player.getPacketDispatch().sendString(BLUE + "I can start this quest by speaking to the " + RED + "Guildmaster " + BLUE + "in", 275, 4+ 7); - player.getPacketDispatch().sendString(BLUE + "the " + RED + "Champions' Guild" + BLUE + " , south-west of Varrock.", 275, 5+ 7); - player.getPacketDispatch().sendString(BLUE + "I will need to be able to defeat a " + RED + "level 83 dragon.", 275, 6+ 7); - if (player.getQuestRepository().getPoints() < 32) { - player.getPacketDispatch().sendString(BLUE + "To enter the Champions' Guild I need" + RED + " 32 Quest Points.", 275, 7+ 7); - } else { - player.getPacketDispatch().sendString("To enter the Champions' Guild I need 32 Quest Points.", 275, 7+ 7); - } - break; - case 10: - line(player, "The Guildmaster of the Champions' Guild said I could earn", 4+ 7); - line(player, "the right to wear rune armour if I went on a quest for", 5+ 7); - line(player, "Oziach, who makes the armour.", 6+ 7); - line(player, BLUE + "I should speak to " + RED + "Oziach" + BLUE + ", who lives by the cliffs to the", 7+ 7); - line(player, BLUE + "west of " + RED + "Edgeville.", 8+ 7); - break; - case 15: - line(player, "The Guildmaster of the Champions' Guild said I could earn", 4+ 7); - line(player, "the right to wear rune armour if I went on a quest for", 5+ 7); - line(player, "Oziach, who makes the armour.", 6+ 7); - line(player, "I spoke to Oziach in Edgeville. He told me to slay the", 7+ 7); - line(player, "dragon of Crandor island.", 8+ 7); - line(player, BLUE + "I should return to the " + RED + "Champions' Guild Guildmaster " + BLUE + "for", 9+ 7); - line(player, BLUE + "more detailed instructions.", 10+ 7); - break; - case 20: - line(player, "The Guildmaster of the Champions' Guild said I could earn", 4+ 7); - line(player, "the right to wear rune armour if I went on a quest for", 5+ 7); - line(player, "Oziach, who makes the armour.", 6+ 7); - line(player, "I spoke to Oziach in Edgeville. He told me to slay the", 7+ 7); - line(player, "dragon of Crandor island.", 8+ 7); - line(player, "The Champions' Guild Guildmaster gave me more detailed", 9+ 7); - line(player, "instructions.", 10+ 7); - line(player, BLUE + "To defeat the dragon I will need to find a " + RED + "map " + BLUE + "to Crandor, a", 11+ 7); - line(player, RED + "ship" + BLUE + ", a " + RED + "captain " + BLUE + "to take me there and some kind of", 12+ 7); - line(player, RED + "protection " + BLUE + "against the dragon's breath.", 13+ 7); - if (!player.getInventory().containsItem(MAZE_PIECE) && !player.getBank().containsItem(MAZE_PIECE)) { - line(player, BLUE + "One-third of the map is in " + RED + "Melzar's Maze" + BLUE + ", near", 14+ 7); - line(player, RED + "Rimmington" + ".", 15+ 7); - } else { - line(player, "I found the piece of the map that was hidden in Melzar's", 14+ 7); - line(player, "Maze.", 15+ 7); - } - if (!player.getInventory().containsItem(MAGIC_PIECE) && !player.getBank().containsItem(MAGIC_PIECE)) { - line(player, BLUE + "One)2third of the map is hidden and only the " + RED + "Oracle " + BLUE + "on " + RED + "Ice", 16+ 7); - line(player, RED + "Mountain" + BLUE + " will know where it is.", 17+ 7); - } else { - line(player, "I found the piece of the map that was hidden beneath Ice", 16+ 7); - line(player, "Mountain.", 18+ 7); - } - if (!player.getInventory().containsItem(WORMBRAIN_PIECE) && !player.getBank().containsItem(WORMBRAIN_PIECE)) { - line(player, BLUE + "One-third of the map was stolen by a " + RED + "goblin " + BLUE + "from the", 18+ 7); - line(player, RED + "Goblin Village.", 19+ 7); - } else { - line(player, "I found the piece of the map that the goblin, Wormbrain,", 18+ 7); - line(player, "stole.", 19+ 7); - } - if (!player.getInventory().containsItem(SHIELD) && !player.getBank().containsItem(SHIELD)) { - line(player, BLUE + "I should ask the " + RED + "Duke of Lumbridge " + BLUE + "for an " + RED + "anti-", 20+ 7); - line(player, RED + "dragonbreath shield.", 21+ 7); - } else { - line(player, "The Duke of Lumbridge gave me an anti-dragonbreath", 20+ 7); - line(player, "shield.", 21+ 7); + /** + * Represents the purple key item. + */ + @JvmField + val PURPLE_KEY = Item(1547) - } - if (!player.getSavedData().getQuestData().getDragonSlayerAttribute("ship")) { - line(player, BLUE + "I should see if there is a " + RED + "ship " + BLUE + "for sale in " + RED + "Port Sarim", 22+ 7); - } else { - line(player, "I bought a ship in Port Sarim called the Lady Lumbridge.", 22+ 7); - if (!player.getSavedData().getQuestData().getDragonSlayerAttribute("repaired")) { - line(player, "I need to repair the hole in bottom of the ship.", 23+ 7); - } else { - line(player, "I have repaired my ship using wooden planks and steel", 23+ 7); - line(player, "nails.", 24+ 7); - } - } - break; - case 30: - line(player, "The Guildmaster of the Champions' Guild said I could earn", 4+ 7); - line(player, "the right to wear rune armour if I went on a quest for", 5+ 7); - line(player, "Oziach, who makes the armour.", 6+ 7); - line(player, "I spoke to Oziach in Edgeville. He told me to slay the", 7+ 7); - line(player, "dragon of Crandor island.", 8+ 7); - line(player, "The Champions' Guild Guildmaster told me I had to find", 9+ 7); - line(player, "three pieces of a map to Crandor, a ship, a captain to take", 10+ 7); - line(player, "me there and a shield to protect me from the dragon's", 11+ 7); - line(player, "breath.", 12+ 7); - line(player, "I found the piece of the map that was hidden in Melzar's", 13+ 7); - line(player, "Maze.", 14+ 7); - line(player, "I found the piece of the map that was hidden beneath Ice", 15+ 7); - line(player, "Mountain.", 16+ 7); - line(player, "I found the piece of the map that the goblin, Wormbrain,", 17+ 7); - line(player, "stole.", 18+ 7); - line(player, "The Duke of Lumbridge gave me an anti-dragonbreath", 19+ 7); - line(player, "shield.", 20+ 7); - line(player, "I bought a ship in Port Sarim called the Lady Lumbridge", 21+ 7); - line(player, "I have repaired my ship using wooden planks and steel", 22+ 7); - line(player, "nails.", 23+ 7); - line(player, "Captain Ned from Draynor Village has agreed to sail the", 24+ 7); - line(player, "ship to Crandor for me.", 25+ 7); - line(player, BLUE + "Now I should go to my ship in " + RED + "Port Sarim " + BLUE + "and set sail for", 26+ 7); - line(player, RED + "Crandor" + BLUE + "!", 27+ 7); - break; - case 40: - line(player, "The Guildmaster of the Champions' Guild said I could earn", 4+ 7); - line(player, "the right to wear rune armour if I went on a quest for", 5+ 7); - line(player, "Oziach, who makes the armour.", 6+ 7); - line(player, "I spoke to Oziach in Edgeville. He told me to slay the", 7+ 7); - line(player, "dragon of Crandor island.", 8+ 7); - line(player, "The Champions' Guild Guildmaster told me I had to find", 9+ 7); - line(player, "three pieces of a map to Crandor, a ship, a captain to take", 10+ 7); - line(player, "me there and a shield to protect me from the dragon's", 11+ 7); - line(player, "breath.", 12+ 7); - line(player, "I found the piece of the map that was hidden in Melzar's", 13+ 7); - line(player, "Maze.", 14+ 7); - line(player, "I found the piece of the map that was hidden beneath Ice", 15+ 7); - line(player, "Mountain.", 16+ 7); - line(player, "I found the piece of the map that the goblin, Wormbrain,", 17+ 7); - line(player, "stole.", 18+ 7); - line(player, "The Duke of Lumbridge gave me an anti-dragonbreath", 19+ 7); - line(player, "shield.", 20+ 7); - if (!player.getAttribute("demon-slayer:memorize", false)) { - if (!player.getInventory().containsItem(ELVARG_HEAD)) { - line(player, BLUE + "Now all I need to do is kill the " + RED + "dragon" + BLUE + "!", 21+ 7); - } else { - line(player, BLUE + "I have slain the dragon! Now I just need to tell " + RED + "Oziach.", 21+ 7); - } - } else { - line(player, "I have found a secret passage leading from Karamja to", 21+ 7); - line(player, "Crandor, so I no longer need to worry about finding a", 22+ 7); - line(player, "seaworthy ship and captain to take me there.", 23+ 7); - if (!player.getInventory().containsItem(ELVARG_HEAD)) { - line(player, BLUE + "Now all I need to do is kill the " + RED + "dragon" + BLUE + "!", 24+ 7); - } else { - line(player, BLUE + "I have slain the dragon! Now I just need to tell " + RED + "Oziach.", 24+ 7); - } - } - break; - case 100: - line(player, "The Guildmaster of the Champions' Guild said I could earn", 4+ 7); - line(player, "the right to wear rune armour if I went on a quest for", 5+ 7); - line(player, "Oziach, who makes the armour.", 6+ 7); - line(player, "I spoke to Oziach in Edgeville. He told me to slay the", 7+ 7); - line(player, "dragon of Crandor island.", 8+ 7); - line(player, "The Champions' Guild Guildmaster told me I had to find", 9+ 7); - line(player, "three pieces of a map to Crandor, a ship, a captain to take", 10+ 7); - line(player, "me there and a shield to protect me from the dragon's", 11+ 7); - line(player, "breath.", 12+ 7); - line(player, "I found the piece of the map that was hidden in Melzar's", 13+ 7); - line(player, "Maze.", 14+ 7); - line(player, "I found the piece of the map that was hidden beneath Ice", 15+ 7); - line(player, "Mountain.", 16+ 7); - line(player, "I found the piece of the map that the goblin, Wormbrain,", 17+ 7); - line(player, "stole.", 18+ 7); - line(player, "The Duke of Lumbridge gave me an anti-dragonbreath", 19+ 7); - line(player, "shield.", 20+ 7); - line(player, "I have found a secret passage leading from Karamja to", 21+ 7); - line(player, "Crandor, so I no longer need to worry about finding a", 22+ 7); - line(player, "seaworthy ship and captain to take me there.", 23+ 7); - line(player, "I sailed to Crandor and killed the dragon. I am not a true", 24+ 7); - line(player, "champion and have proved myself worthy to wear rune", 25+ 7); - line(player, "platemail!", 26+ 7); - line(player, "QUEST COMPLETE!", 27+ 7); - line(player, BLUE + "I gained " + RED + "2 Quest Points" + BLUE + ", " + RED + "18,650 Strength XP" + BLUE + ", " + RED + "18,650", 28+ 7); - line(player, RED + "Defence XP " + BLUE + "and the right to wear " + RED + "rune platebodies.", 29+ 7); - break; - } - } + /** + * Represents the green key item. + */ + @JvmField + val GREEN_KEY = Item(1548) - @Override - public void finish(Player player) { - super.finish(player); - player.getPacketDispatch().sendString("2 Quests Points", 277, 8 + 2); - player.getPacketDispatch().sendString("Ability to wear rune platebody", 277, 9 + 2); - player.getPacketDispatch().sendString("18,650 Strength XP", 277, 10 + 2); - player.getPacketDispatch().sendString("18,650 Defence XP", 277, 11 + 2); - player.getPacketDispatch().sendString("You have completed the Dragon Slayer Quest!", 277, 2 + 2); - player.getPacketDispatch().sendItemZoomOnInterface(ELVARG_HEAD.getId(), 230, 277, 3 + 2); - player.getSkills().addExperience(Skills.STRENGTH, 18650); - player.getSkills().addExperience(Skills.DEFENCE, 18650); - } + /** + * Represents the maze map piece. + */ + @JvmField + val MAZE_PIECE = Item(1535) - /** - * Method used to handle going through the magic door. - * @param player the player. - * @param interaction the interaction. - * @return True if so. - */ - public static boolean handleMagicDoor(final Player player, boolean interaction) { - if (!player.getSavedData().getQuestData().getDragonSlayerItem("lobster") || !player.getSavedData().getQuestData().getDragonSlayerItem("bowl") || !player.getSavedData().getQuestData().getDragonSlayerItem("silk") || !player.getSavedData().getQuestData().getDragonSlayerItem("wizard")) { - if (interaction) { - player.getPacketDispatch().sendMessage("You can't see any way to open the door."); - } - return true; - } - player.getPacketDispatch().sendMessage("The door opens..."); - final Scenery object = RegionManager.getObject(new Location(3050, 9839, 0)); - player.faceLocation(object.getLocation()); - player.getPacketDispatch().sendSceneryAnimation(object, new Animation(6636)); - GameWorld.getPulser().submit(new Pulse(1, player) { - int counter = 0; + /** + * Represents the magic door map piece. + */ + @JvmField + val MAGIC_PIECE = Item(1537) - @Override - public boolean pulse() { - switch (counter++) { - case 4: - AgilityHandler.walk(player, 0, player.getLocation(), player.getLocation().getX() == 3051 ? Location.create(3049, 9840, 0) : Location.create(3051, 9840, 0), null, 0, null); - break; - case 5: - player.getPacketDispatch().sendSceneryAnimation(object, new Animation(6637)); - break; - case 6: - player.getPacketDispatch().sendSceneryAnimation(object, new Animation(6635)); - return true; - } - return false; - } - }); - return true; - } - -} + /** + * Represents the wormbrain piece. + */ + @JvmField + val WORMBRAIN_PIECE = Item(1536) + + /** + * Represents the anti dragon fire shield. + */ + val SHIELD = Item(1540) + + /** + * Represents the crandor map item. + */ + @JvmField + val CRANDOR_MAP = Item(1538) + + /** + * Represents the map component interface. + */ + @JvmField + val MAP_COMPONENT = Component(547) + + /** + * Represents the nails item. + */ + @JvmField + val NAILS = Item(1539, 30) + + /** + * Represents the plank item. + */ + @JvmField + val PLANK = Item(960) + + /** + * Represents the hammer item. + */ + @JvmField + val HAMMER = Item(2347) + + /** + * Represents the elvarg head item. + */ + @JvmField + val ELVARG_HEAD = Item(11279) + + /** + * Method used to handle going through the magic door. + * @param player the player. + * @param interaction the interaction. + * @return `True` if so. + */ + @JvmStatic + fun handleMagicDoor(player: Player, interaction: Boolean): Boolean { + if (!player.savedData.questData.getDragonSlayerItem("lobster") || !player.savedData.questData.getDragonSlayerItem( + "bowl" + ) || !player.savedData.questData.getDragonSlayerItem("silk") || !player.savedData.questData.getDragonSlayerItem( + "wizard" + ) + ) { + if (interaction) { + player.packetDispatch.sendMessage("You can't see any way to open the door.") + } + return true + } + player.packetDispatch.sendMessage("The door opens...") + val `object` = getObject(Location(3050, 9839, 0)) + player.faceLocation(`object`!!.location) + player.packetDispatch.sendSceneryAnimation(`object`, Animation(6636)) + Pulser.submit(object : Pulse(1, player) { + var counter = 0 + override fun pulse(): Boolean { + when (counter++) { + 4 -> AgilityHandler.walk( + player, + 0, + player.location, + if (player.location.x == 3051) Location.create(3049, 9840, 0) else Location.create( + 3051, + 9840, + 0 + ), + null, + 0.0, + null + ) + + 5 -> player.packetDispatch.sendSceneryAnimation(`object`, Animation(6637)) + 6 -> { + player.packetDispatch.sendSceneryAnimation(`object`, Animation(6635)) + return true + } + } + return false + } + }) + return true + } + } +} \ No newline at end of file diff --git a/Server/src/main/content/region/misthalin/varrock/quest/dragonslayer/WormbrainDialogue.java b/Server/src/main/content/region/misthalin/varrock/quest/dragonslayer/WormbrainDialogue.java index 73f781d8c..8f1a6629f 100644 --- a/Server/src/main/content/region/misthalin/varrock/quest/dragonslayer/WormbrainDialogue.java +++ b/Server/src/main/content/region/misthalin/varrock/quest/dragonslayer/WormbrainDialogue.java @@ -6,6 +6,7 @@ import core.game.node.entity.player.Player; import core.game.node.entity.player.link.quest.Quest; import core.game.node.item.GroundItemManager; import core.game.node.item.Item; +import core.integrations.discord.Discord; /** * Represents the dialogue used to handle the wormbrain npc related to the @@ -110,6 +111,7 @@ public final class WormbrainDialogue extends DialoguePlugin { GroundItemManager.create(DragonSlayer.WORMBRAIN_PIECE, player); } interpreter.sendItemMessage(DragonSlayer.WORMBRAIN_PIECE.getId(), "You buy the map piece from Wormbrain."); + Discord.sendToOpenRSC(player.getName(), "Player obtained Wormbrain piece! (Dialogue)"); stage = 507; } else { end(); diff --git a/Server/src/main/core/ServerConstants.kt b/Server/src/main/core/ServerConstants.kt index d060ff29a..96dc5ff5c 100644 --- a/Server/src/main/core/ServerConstants.kt +++ b/Server/src/main/core/ServerConstants.kt @@ -253,6 +253,9 @@ class ServerConstants { @JvmField var DISCORD_MOD_WEBHOOK = "" + @JvmField + var DISCORD_OPENRSC_HOOK = "" + @JvmField var PRELOAD_MAP = false diff --git a/Server/src/main/core/game/event/Events.kt b/Server/src/main/core/game/event/Events.kt index 3b511fcc4..bde021dc9 100644 --- a/Server/src/main/core/game/event/Events.kt +++ b/Server/src/main/core/game/event/Events.kt @@ -32,7 +32,7 @@ data class InterfaceOpenEvent(val component: Component) : Event data class InterfaceCloseEvent(val component: Component) : Event data class AttributeSetEvent(val entity: Entity, val attribute: String, val value: Any) : Event data class AttributeRemoveEvent(val entity: Entity, val attribute: String) : Event -data class SpellCastEvent(val spellBook: SpellBook, val spellId: Int) : Event +data class SpellCastEvent(val spellBook: SpellBook, val spellId: Int, val target: Node? = null) : Event data class ItemAlchemizationEvent(val itemId: Int, val isHigh: Boolean) : Event data class ItemEquipEvent(val itemId: Int, val slotId: Int) : Event data class ItemUnequipEvent(val itemId: Int, val slotId: Int) : Event diff --git a/Server/src/main/core/game/node/entity/Entity.java b/Server/src/main/core/game/node/entity/Entity.java index db9a0d417..e66d9c19a 100644 --- a/Server/src/main/core/game/node/entity/Entity.java +++ b/Server/src/main/core/game/node/entity/Entity.java @@ -194,7 +194,8 @@ public abstract class Entity extends Node { { hookList = new ArrayList(); } - hookList.add(hook); + if (!hookList.contains(hook)) + hookList.add(hook); hooks.put(event, hookList); } diff --git a/Server/src/main/core/game/node/entity/combat/spell/MagicSpell.java b/Server/src/main/core/game/node/entity/combat/spell/MagicSpell.java index 53d017c75..b55324de4 100644 --- a/Server/src/main/core/game/node/entity/combat/spell/MagicSpell.java +++ b/Server/src/main/core/game/node/entity/combat/spell/MagicSpell.java @@ -1,6 +1,7 @@ package core.game.node.entity.combat.spell; import core.game.component.Component; +import core.game.event.SpellCastEvent; import core.game.node.entity.skill.Skills; import core.game.node.Node; import core.game.node.entity.Entity; @@ -131,6 +132,7 @@ public abstract class MagicSpell implements Plugin { if (p.getAttribute("magic-delay", 0) <= GameWorld.getTicks()) { p.setAttribute("magic-delay", GameWorld.getTicks() + spell.getDelay()); } + p.dispatch(new SpellCastEvent(book, spellId, target)); return true; } return false; diff --git a/Server/src/main/core/game/system/config/ServerConfigParser.kt b/Server/src/main/core/game/system/config/ServerConfigParser.kt index 413e55cf7..873af0468 100644 --- a/Server/src/main/core/game/system/config/ServerConfigParser.kt +++ b/Server/src/main/core/game/system/config/ServerConfigParser.kt @@ -134,6 +134,7 @@ object ServerConfigParser { ServerConstants.NOAUTH_DEFAULT_ADMIN = data.getBoolean("server.noauth_default_admin", false) ServerConstants.DRAGON_AXE_USE_OSRS_SPEC = data.getBoolean("world.dragon_axe_use_osrs_spec", false) ServerConstants.ENABLE_GLOBALCHAT = data.getBoolean("world.enable_globalchat", true) + ServerConstants.DISCORD_OPENRSC_HOOK = data.getString("server.openrsc_integration_webhook", "") } diff --git a/Server/src/main/core/integrations/discord/Discord.kt b/Server/src/main/core/integrations/discord/Discord.kt index 7e07d69d9..77f841521 100644 --- a/Server/src/main/core/integrations/discord/Discord.kt +++ b/Server/src/main/core/integrations/discord/Discord.kt @@ -55,6 +55,18 @@ object Discord { } } + @JvmStatic fun sendToOpenRSC(player: String, type: String) { + if (ServerConstants.DISCORD_OPENRSC_HOOK.isEmpty()) return + GlobalScope.launch { + val alert = encodeUserAlert(type, player) + try { + sendJsonPost(ServerConstants.DISCORD_OPENRSC_HOOK, alert) + } catch (e: Exception) { + e.printStackTrace() + } + } + } + private fun encodeUpdateJson(sale: Boolean, itemId: Int, value: Int, amtLeft: Int): String { val obj = JSONObject() val embeds = JSONArray()