Implement plate pure integration with OpenRSC

This commit is contained in:
ceikry 2023-02-25 11:31:44 -06:00
parent 26f037ef4e
commit 8e9bb5e448
10 changed files with 503 additions and 326 deletions

View file

@ -44,7 +44,6 @@ public final class MagicBookInterface extends ComponentPlugin {
SpellListeners.run(button, SpellListener.NONE, SpellUtils.getBookFromInterface(component.getId()),player,null); SpellListeners.run(button, SpellListener.NONE, SpellUtils.getBookFromInterface(component.getId()),player,null);
boolean result = MagicSpell.castSpell(player, spellBook, button, player); boolean result = MagicSpell.castSpell(player, spellBook, button, player);
player.dispatch(new SpellCastEvent(spellBook, button));
return result; return result;
} }

View file

@ -1,7 +1,9 @@
package content.global.skill.magic package content.global.skill.magic
import core.game.event.SpellCastEvent
import core.game.node.Node import core.game.node.Node
import core.game.node.entity.player.Player import core.game.node.entity.player.Player
import core.game.node.entity.player.link.SpellBookManager
import core.tools.SystemLogger import core.tools.SystemLogger
object SpellListeners { object SpellListeners {
@ -32,6 +34,7 @@ object SpellListeners {
val method = get(button,type,node?.id ?: 0,book) ?: get(button,type,book) ?: return val method = get(button,type,node?.id ?: 0,book) ?: get(button,type,book) ?: return
try { try {
method.invoke(player, node) method.invoke(player, node)
player.dispatch(SpellCastEvent(SpellBookManager.SpellBook.valueOf(book.uppercase()), button, node))
} catch (e: IllegalStateException){ } catch (e: IllegalStateException){
player.removeAttribute("spell:runes") player.removeAttribute("spell:runes")
return return

View file

@ -1,351 +1,505 @@
package content.region.misthalin.varrock.quest.dragonslayer; package content.region.misthalin.varrock.quest.dragonslayer
import core.game.component.Component; import content.global.skill.agility.AgilityHandler
import core.game.node.entity.player.Player; import content.region.misthalin.lumbridge.dialogue.DukeHoracioDialogue
import core.game.node.entity.player.link.quest.Quest; import core.api.Event
import core.game.node.entity.skill.Skills; import core.api.LoginListener
import content.global.skill.agility.AgilityHandler; import core.api.questStage
import core.game.node.item.Item; import core.game.component.Component
import core.game.node.scenery.Scenery; import core.game.event.EventHook
import core.game.system.task.Pulse; import core.game.event.PickUpEvent
import core.game.world.map.Location; import core.game.event.SpellCastEvent
import core.game.world.map.RegionManager; import core.game.node.entity.Entity
import core.game.world.update.flag.context.Animation; import core.game.node.entity.player.Player
import core.plugin.Initializable; import core.game.node.entity.player.link.quest.Quest
import content.region.misthalin.lumbridge.dialogue.DukeHoracioDialogue; import core.game.node.entity.skill.Skills
import core.game.world.GameWorld; import core.game.node.item.Item
import core.plugin.ClassScanner; 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. * Represents the dragon slayer quest.
* @author Vexia * @author Vexia - Converted to Kotlin with use of event hooks by not-Vexia
*
*/ */
@Initializable @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
}
/** override fun drawJournal(player: Player, stage: Int) {
* Represents the maze key given by the guildmaster. super.drawJournal(player, stage)
*/ when (getStage(player)) {
public static final Item MAZE_KEY = new Item(1542); 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(
"<str>To enter the Champions' Guild I need 32 Quest Points.",
275,
7 + 7
)
}
}
/** 10 -> {
* Represents the red key item. line(player, "<str>The Guildmaster of the Champions' Guild said I could earn", 4 + 7)
*/ line(player, "<str>the right to wear rune armour if I went on a quest for", 5 + 7)
public static final Item RED_KEY = new Item(1543); line(player, "<str>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)
}
/** 15 -> {
* Represents the orange key item. line(player, "<str>The Guildmaster of the Champions' Guild said I could earn", 4 + 7)
*/ line(player, "<str>the right to wear rune armour if I went on a quest for", 5 + 7)
public static final Item ORANGE_KEY = new Item(1544); line(player, "<str>Oziach, who makes the armour.", 6 + 7)
line(player, "<str>I spoke to Oziach in Edgeville. He told me to slay the", 7 + 7)
line(player, "<str>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)
}
/** 20 -> {
* Represents the yellow key item. line(player, "<str>The Guildmaster of the Champions' Guild said I could earn", 4 + 7)
*/ line(player, "<str>the right to wear rune armour if I went on a quest for", 5 + 7)
public static final Item YELLOW_KEY = new Item(1545); line(player, "<str>Oziach, who makes the armour.", 6 + 7)
line(player, "<str>I spoke to Oziach in Edgeville. He told me to slay the", 7 + 7)
line(player, "<str>dragon of Crandor island.", 8 + 7)
line(player, "<str>The Champions' Guild Guildmaster gave me more detailed", 9 + 7)
line(player, "<str>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, "<str>I found the piece of the map that was hidden in Melzar's", 14 + 7)
line(player, "<str>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, "<str>I found the piece of the map that was hidden beneath Ice", 16 + 7)
line(player, "<str>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, "<str>I found the piece of the map that the goblin, Wormbrain,", 18 + 7)
line(player, "<str>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, "<str>The Duke of Lumbridge gave me an anti-dragonbreath", 20 + 7)
line(player, "<str>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, "<str>I bought a ship in Port Sarim called the Lady Lumbridge.", 22 + 7)
if (!player.savedData.questData.getDragonSlayerAttribute("repaired")) {
line(player, "<str>I need to repair the hole in bottom of the ship.", 23 + 7)
} else {
line(player, "<str>I have repaired my ship using wooden planks and steel", 23 + 7)
line(player, "<str>nails.", 24 + 7)
}
}
}
/** 30 -> {
* Represents the blue key item. line(player, "<str>The Guildmaster of the Champions' Guild said I could earn", 4 + 7)
*/ line(player, "<str>the right to wear rune armour if I went on a quest for", 5 + 7)
public static final Item BLUE_KEY = new Item(1546); line(player, "<str>Oziach, who makes the armour.", 6 + 7)
line(player, "<str>I spoke to Oziach in Edgeville. He told me to slay the", 7 + 7)
line(player, "<str>dragon of Crandor island.", 8 + 7)
line(player, "<str>The Champions' Guild Guildmaster told me I had to find", 9 + 7)
line(player, "<str>three pieces of a map to Crandor, a ship, a captain to take", 10 + 7)
line(player, "<str>me there and a shield to protect me from the dragon's", 11 + 7)
line(player, "<str>breath.", 12 + 7)
line(player, "<str>I found the piece of the map that was hidden in Melzar's", 13 + 7)
line(player, "<str>Maze.", 14 + 7)
line(player, "<str>I found the piece of the map that was hidden beneath Ice", 15 + 7)
line(player, "<str>Mountain.", 16 + 7)
line(player, "<str>I found the piece of the map that the goblin, Wormbrain,", 17 + 7)
line(player, "<str>stole.", 18 + 7)
line(player, "<str>The Duke of Lumbridge gave me an anti-dragonbreath", 19 + 7)
line(player, "<str>shield.", 20 + 7)
line(player, "<str>I bought a ship in Port Sarim called the Lady Lumbridge", 21 + 7)
line(player, "<str>I have repaired my ship using wooden planks and steel", 22 + 7)
line(player, "<str>nails.", 23 + 7)
line(player, "<str>Captain Ned from Draynor Village has agreed to sail the", 24 + 7)
line(player, "<str>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)
}
/** 40 -> {
* Represents the purple key item. line(player, "<str>The Guildmaster of the Champions' Guild said I could earn", 4 + 7)
*/ line(player, "<str>the right to wear rune armour if I went on a quest for", 5 + 7)
public static final Item PURPLE_KEY = new Item(1547); line(player, "<str>Oziach, who makes the armour.", 6 + 7)
line(player, "<str>I spoke to Oziach in Edgeville. He told me to slay the", 7 + 7)
line(player, "<str>dragon of Crandor island.", 8 + 7)
line(player, "<str>The Champions' Guild Guildmaster told me I had to find", 9 + 7)
line(player, "<str>three pieces of a map to Crandor, a ship, a captain to take", 10 + 7)
line(player, "<str>me there and a shield to protect me from the dragon's", 11 + 7)
line(player, "<str>breath.", 12 + 7)
line(player, "<str>I found the piece of the map that was hidden in Melzar's", 13 + 7)
line(player, "<str>Maze.", 14 + 7)
line(player, "<str>I found the piece of the map that was hidden beneath Ice", 15 + 7)
line(player, "<str>Mountain.", 16 + 7)
line(player, "<str>I found the piece of the map that the goblin, Wormbrain,", 17 + 7)
line(player, "<str>stole.", 18 + 7)
line(player, "<str>The Duke of Lumbridge gave me an anti-dragonbreath", 19 + 7)
line(player, "<str>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, "<str>I have found a secret passage leading from Karamja to", 21 + 7)
line(player, "<str>Crandor, so I no longer need to worry about finding a", 22 + 7)
line(player, "<str>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
)
}
}
}
/** 100 -> {
* Represents the green key item. line(player, "<str>The Guildmaster of the Champions' Guild said I could earn", 4 + 7)
*/ line(player, "<str>the right to wear rune armour if I went on a quest for", 5 + 7)
public static final Item GREEN_KEY = new Item(1548); line(player, "<str>Oziach, who makes the armour.", 6 + 7)
line(player, "<str>I spoke to Oziach in Edgeville. He told me to slay the", 7 + 7)
line(player, "<str>dragon of Crandor island.", 8 + 7)
line(player, "<str>The Champions' Guild Guildmaster told me I had to find", 9 + 7)
line(player, "<str>three pieces of a map to Crandor, a ship, a captain to take", 10 + 7)
line(player, "<str>me there and a shield to protect me from the dragon's", 11 + 7)
line(player, "<str>breath.", 12 + 7)
line(player, "<str>I found the piece of the map that was hidden in Melzar's", 13 + 7)
line(player, "<str>Maze.", 14 + 7)
line(player, "<str>I found the piece of the map that was hidden beneath Ice", 15 + 7)
line(player, "<str>Mountain.", 16 + 7)
line(player, "<str>I found the piece of the map that the goblin, Wormbrain,", 17 + 7)
line(player, "<str>stole.", 18 + 7)
line(player, "<str>The Duke of Lumbridge gave me an anti-dragonbreath", 19 + 7)
line(player, "<str>shield.", 20 + 7)
line(player, "<str>I have found a secret passage leading from Karamja to", 21 + 7)
line(player, "<str>Crandor, so I no longer need to worry about finding a", 22 + 7)
line(player, "<str>seaworthy ship and captain to take me there.", 23 + 7)
line(player, "<str>I sailed to Crandor and killed the dragon. I am not a true", 24 + 7)
line(player, "<str>champion and have proved myself worthy to wear rune", 25 + 7)
line(player, "<str>platemail!", 26 + 7)
line(player, "<col=FF0000>QUEST COMPLETE!</col>", 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)
}
}
}
/** override fun finish(player: Player) {
* Represents the maze map piece. super.finish(player)
*/ player.packetDispatch.sendString("2 Quests Points", 277, 8 + 2)
public static final Item MAZE_PIECE = new Item(1535); 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)
}
/** override fun setStage(player: Player, stage: Int) {
* Represents the magic door map piece. super.setStage(player, stage)
*/ if (stage == 20) {
public static final Item MAGIC_PIECE = new Item(1537); player.hook(Event.SpellCast, SpellCastHook)
player.hook(Event.PickedUp, PickedUpHook)
}
}
/** override fun login(player: Player) {
* Represents the wormbrain piece. if (questStage(player, this.name) == 20) {
*/ player.hook(Event.SpellCast, SpellCastHook)
public static final Item WORMBRAIN_PIECE = new Item(1536); player.hook(Event.PickedUp, PickedUpHook)
}
}
/** private val SpellCastHook = object : EventHook<SpellCastEvent> {
* Represents the anti dragon fire shield. override fun process(entity: Entity, event: SpellCastEvent) {
*/ if (event.spellId == 19 && event.target != null && event.target.id == Items.MAP_PART_1536) {//telegrab
public static final Item SHIELD = new Item(1540); Discord.sendToOpenRSC(entity.name, "Player obtained Wormbrain piece! (Murder-Then-Telegrab)")
entity.unhook(this)
}
}
}
/** private val PickedUpHook = object : EventHook<PickUpEvent> {
* Represents the crandor map item. override fun process(entity: Entity, event: PickUpEvent) {
*/ if (event.itemId == Items.MAP_PART_1536) {
public static final Item CRANDOR_MAP = new Item(1538); Discord.sendToOpenRSC(entity.name, "Player obtained Wormbrain piece! (Yoinked-Off-Floor)")
entity.unhook(this)
}
}
}
/** companion object {
* Represents the map component interface. /**
*/ * Represents the maze key given by the guildmaster.
public static final Component MAP_COMPONENT = new Component(547); */
@JvmField
val MAZE_KEY = Item(1542)
/** /**
* Represents the nails item. * Represents the red key item.
*/ */
public static final Item NAILS = new Item(1539, 30); @JvmField
val RED_KEY = Item(1543)
/** /**
* Represents the plank item. * Represents the orange key item.
*/ */
public static final Item PLANK = new Item(960); @JvmField
val ORANGE_KEY = Item(1544)
/** /**
* Represents the hammer item. * Represents the yellow key item.
*/ */
public static final Item HAMMER = new Item(2347); @JvmField
val YELLOW_KEY = Item(1545)
/** /**
* Represents the elvarg head item. * Represents the blue key item.
*/ */
public static final Item ELVARG_HEAD = new Item(11279); @JvmField
val BLUE_KEY = Item(1546)
/** /**
* Constructs a new {@Code DragonSlayer} {@Code Object} * Represents the purple key item.
*/ */
public DragonSlayer() { @JvmField
super("Dragon Slayer", 18, 17, 2, 176, 0, 1, 10); val PURPLE_KEY = Item(1547)
}
@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("<str>To enter the Champions' Guild I need 32 Quest Points.", 275, 7+ 7);
}
break;
case 10:
line(player, "<str>The Guildmaster of the Champions' Guild said I could earn", 4+ 7);
line(player, "<str>the right to wear rune armour if I went on a quest for", 5+ 7);
line(player, "<str>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, "<str>The Guildmaster of the Champions' Guild said I could earn", 4+ 7);
line(player, "<str>the right to wear rune armour if I went on a quest for", 5+ 7);
line(player, "<str>Oziach, who makes the armour.", 6+ 7);
line(player, "<str>I spoke to Oziach in Edgeville. He told me to slay the", 7+ 7);
line(player, "<str>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, "<str>The Guildmaster of the Champions' Guild said I could earn", 4+ 7);
line(player, "<str>the right to wear rune armour if I went on a quest for", 5+ 7);
line(player, "<str>Oziach, who makes the armour.", 6+ 7);
line(player, "<str>I spoke to Oziach in Edgeville. He told me to slay the", 7+ 7);
line(player, "<str>dragon of Crandor island.", 8+ 7);
line(player, "<str>The Champions' Guild Guildmaster gave me more detailed", 9+ 7);
line(player, "<str>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, "<str>I found the piece of the map that was hidden in Melzar's", 14+ 7);
line(player, "<str>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, "<str>I found the piece of the map that was hidden beneath Ice", 16+ 7);
line(player, "<str>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, "<str>I found the piece of the map that the goblin, Wormbrain,", 18+ 7);
line(player, "<str>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, "<str>The Duke of Lumbridge gave me an anti-dragonbreath", 20+ 7);
line(player, "<str>shield.", 21+ 7);
} /**
if (!player.getSavedData().getQuestData().getDragonSlayerAttribute("ship")) { * Represents the green key item.
line(player, BLUE + "I should see if there is a " + RED + "ship " + BLUE + "for sale in " + RED + "Port Sarim", 22+ 7); */
} else { @JvmField
line(player, "<str>I bought a ship in Port Sarim called the Lady Lumbridge.", 22+ 7); val GREEN_KEY = Item(1548)
if (!player.getSavedData().getQuestData().getDragonSlayerAttribute("repaired")) {
line(player, "<str>I need to repair the hole in bottom of the ship.", 23+ 7);
} else {
line(player, "<str>I have repaired my ship using wooden planks and steel", 23+ 7);
line(player, "<str>nails.", 24+ 7);
}
}
break;
case 30:
line(player, "<str>The Guildmaster of the Champions' Guild said I could earn", 4+ 7);
line(player, "<str>the right to wear rune armour if I went on a quest for", 5+ 7);
line(player, "<str>Oziach, who makes the armour.", 6+ 7);
line(player, "<str>I spoke to Oziach in Edgeville. He told me to slay the", 7+ 7);
line(player, "<str>dragon of Crandor island.", 8+ 7);
line(player, "<str>The Champions' Guild Guildmaster told me I had to find", 9+ 7);
line(player, "<str>three pieces of a map to Crandor, a ship, a captain to take", 10+ 7);
line(player, "<str>me there and a shield to protect me from the dragon's", 11+ 7);
line(player, "<str>breath.", 12+ 7);
line(player, "<str>I found the piece of the map that was hidden in Melzar's", 13+ 7);
line(player, "<str>Maze.", 14+ 7);
line(player, "<str>I found the piece of the map that was hidden beneath Ice", 15+ 7);
line(player, "<str>Mountain.", 16+ 7);
line(player, "<str>I found the piece of the map that the goblin, Wormbrain,", 17+ 7);
line(player, "<str>stole.", 18+ 7);
line(player, "<str>The Duke of Lumbridge gave me an anti-dragonbreath", 19+ 7);
line(player, "<str>shield.", 20+ 7);
line(player, "<str>I bought a ship in Port Sarim called the Lady Lumbridge", 21+ 7);
line(player, "<str>I have repaired my ship using wooden planks and steel", 22+ 7);
line(player, "<str>nails.", 23+ 7);
line(player, "<str>Captain Ned from Draynor Village has agreed to sail the", 24+ 7);
line(player, "<str>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, "<str>The Guildmaster of the Champions' Guild said I could earn", 4+ 7);
line(player, "<str>the right to wear rune armour if I went on a quest for", 5+ 7);
line(player, "<str>Oziach, who makes the armour.", 6+ 7);
line(player, "<str>I spoke to Oziach in Edgeville. He told me to slay the", 7+ 7);
line(player, "<str>dragon of Crandor island.", 8+ 7);
line(player, "<str>The Champions' Guild Guildmaster told me I had to find", 9+ 7);
line(player, "<str>three pieces of a map to Crandor, a ship, a captain to take", 10+ 7);
line(player, "<str>me there and a shield to protect me from the dragon's", 11+ 7);
line(player, "<str>breath.", 12+ 7);
line(player, "<str>I found the piece of the map that was hidden in Melzar's", 13+ 7);
line(player, "<str>Maze.", 14+ 7);
line(player, "<str>I found the piece of the map that was hidden beneath Ice", 15+ 7);
line(player, "<str>Mountain.", 16+ 7);
line(player, "<str>I found the piece of the map that the goblin, Wormbrain,", 17+ 7);
line(player, "<str>stole.", 18+ 7);
line(player, "<str>The Duke of Lumbridge gave me an anti-dragonbreath", 19+ 7);
line(player, "<str>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, "<str>I have found a secret passage leading from Karamja to", 21+ 7);
line(player, "<str>Crandor, so I no longer need to worry about finding a", 22+ 7);
line(player, "<str>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, "<str>The Guildmaster of the Champions' Guild said I could earn", 4+ 7);
line(player, "<str>the right to wear rune armour if I went on a quest for", 5+ 7);
line(player, "<str>Oziach, who makes the armour.", 6+ 7);
line(player, "<str>I spoke to Oziach in Edgeville. He told me to slay the", 7+ 7);
line(player, "<str>dragon of Crandor island.", 8+ 7);
line(player, "<str>The Champions' Guild Guildmaster told me I had to find", 9+ 7);
line(player, "<str>three pieces of a map to Crandor, a ship, a captain to take", 10+ 7);
line(player, "<str>me there and a shield to protect me from the dragon's", 11+ 7);
line(player, "<str>breath.", 12+ 7);
line(player, "<str>I found the piece of the map that was hidden in Melzar's", 13+ 7);
line(player, "<str>Maze.", 14+ 7);
line(player, "<str>I found the piece of the map that was hidden beneath Ice", 15+ 7);
line(player, "<str>Mountain.", 16+ 7);
line(player, "<str>I found the piece of the map that the goblin, Wormbrain,", 17+ 7);
line(player, "<str>stole.", 18+ 7);
line(player, "<str>The Duke of Lumbridge gave me an anti-dragonbreath", 19+ 7);
line(player, "<str>shield.", 20+ 7);
line(player, "<str>I have found a secret passage leading from Karamja to", 21+ 7);
line(player, "<str>Crandor, so I no longer need to worry about finding a", 22+ 7);
line(player, "<str>seaworthy ship and captain to take me there.", 23+ 7);
line(player, "<str>I sailed to Crandor and killed the dragon. I am not a true", 24+ 7);
line(player, "<str>champion and have proved myself worthy to wear rune", 25+ 7);
line(player, "<str>platemail!", 26+ 7);
line(player, "<col=FF0000>QUEST COMPLETE!</col>", 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;
}
}
@Override /**
public void finish(Player player) { * Represents the maze map piece.
super.finish(player); */
player.getPacketDispatch().sendString("2 Quests Points", 277, 8 + 2); @JvmField
player.getPacketDispatch().sendString("Ability to wear rune platebody", 277, 9 + 2); val MAZE_PIECE = Item(1535)
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);
}
/** /**
* Method used to handle going through the magic door. * Represents the magic door map piece.
* @param player the player. */
* @param interaction the interaction. @JvmField
* @return <code>True</code> if so. val MAGIC_PIECE = Item(1537)
*/
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;
@Override /**
public boolean pulse() { * Represents the wormbrain piece.
switch (counter++) { */
case 4: @JvmField
AgilityHandler.walk(player, 0, player.getLocation(), player.getLocation().getX() == 3051 ? Location.create(3049, 9840, 0) : Location.create(3051, 9840, 0), null, 0, null); val WORMBRAIN_PIECE = Item(1536)
break;
case 5: /**
player.getPacketDispatch().sendSceneryAnimation(object, new Animation(6637)); * Represents the anti dragon fire shield.
break; */
case 6: val SHIELD = Item(1540)
player.getPacketDispatch().sendSceneryAnimation(object, new Animation(6635));
return true; /**
} * Represents the crandor map item.
return false; */
} @JvmField
}); val CRANDOR_MAP = Item(1538)
return true;
} /**
* 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
}
}
}

View file

@ -6,6 +6,7 @@ import core.game.node.entity.player.Player;
import core.game.node.entity.player.link.quest.Quest; import core.game.node.entity.player.link.quest.Quest;
import core.game.node.item.GroundItemManager; import core.game.node.item.GroundItemManager;
import core.game.node.item.Item; import core.game.node.item.Item;
import core.integrations.discord.Discord;
/** /**
* Represents the dialogue used to handle the wormbrain npc related to the * 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); GroundItemManager.create(DragonSlayer.WORMBRAIN_PIECE, player);
} }
interpreter.sendItemMessage(DragonSlayer.WORMBRAIN_PIECE.getId(), "You buy the map piece from Wormbrain."); interpreter.sendItemMessage(DragonSlayer.WORMBRAIN_PIECE.getId(), "You buy the map piece from Wormbrain.");
Discord.sendToOpenRSC(player.getName(), "Player obtained Wormbrain piece! (Dialogue)");
stage = 507; stage = 507;
} else { } else {
end(); end();

View file

@ -253,6 +253,9 @@ class ServerConstants {
@JvmField @JvmField
var DISCORD_MOD_WEBHOOK = "" var DISCORD_MOD_WEBHOOK = ""
@JvmField
var DISCORD_OPENRSC_HOOK = ""
@JvmField @JvmField
var PRELOAD_MAP = false var PRELOAD_MAP = false

View file

@ -32,7 +32,7 @@ data class InterfaceOpenEvent(val component: Component) : Event
data class InterfaceCloseEvent(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 AttributeSetEvent(val entity: Entity, val attribute: String, val value: Any) : Event
data class AttributeRemoveEvent(val entity: Entity, val attribute: String) : 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 ItemAlchemizationEvent(val itemId: Int, val isHigh: Boolean) : Event
data class ItemEquipEvent(val itemId: Int, val slotId: Int) : Event data class ItemEquipEvent(val itemId: Int, val slotId: Int) : Event
data class ItemUnequipEvent(val itemId: Int, val slotId: Int) : Event data class ItemUnequipEvent(val itemId: Int, val slotId: Int) : Event

View file

@ -194,7 +194,8 @@ public abstract class Entity extends Node {
{ {
hookList = new ArrayList<EventHook>(); hookList = new ArrayList<EventHook>();
} }
hookList.add(hook); if (!hookList.contains(hook))
hookList.add(hook);
hooks.put(event, hookList); hooks.put(event, hookList);
} }

View file

@ -1,6 +1,7 @@
package core.game.node.entity.combat.spell; package core.game.node.entity.combat.spell;
import core.game.component.Component; import core.game.component.Component;
import core.game.event.SpellCastEvent;
import core.game.node.entity.skill.Skills; import core.game.node.entity.skill.Skills;
import core.game.node.Node; import core.game.node.Node;
import core.game.node.entity.Entity; import core.game.node.entity.Entity;
@ -131,6 +132,7 @@ public abstract class MagicSpell implements Plugin<SpellType> {
if (p.getAttribute("magic-delay", 0) <= GameWorld.getTicks()) { if (p.getAttribute("magic-delay", 0) <= GameWorld.getTicks()) {
p.setAttribute("magic-delay", GameWorld.getTicks() + spell.getDelay()); p.setAttribute("magic-delay", GameWorld.getTicks() + spell.getDelay());
} }
p.dispatch(new SpellCastEvent(book, spellId, target));
return true; return true;
} }
return false; return false;

View file

@ -134,6 +134,7 @@ object ServerConfigParser {
ServerConstants.NOAUTH_DEFAULT_ADMIN = data.getBoolean("server.noauth_default_admin", false) 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.DRAGON_AXE_USE_OSRS_SPEC = data.getBoolean("world.dragon_axe_use_osrs_spec", false)
ServerConstants.ENABLE_GLOBALCHAT = data.getBoolean("world.enable_globalchat", true) ServerConstants.ENABLE_GLOBALCHAT = data.getBoolean("world.enable_globalchat", true)
ServerConstants.DISCORD_OPENRSC_HOOK = data.getString("server.openrsc_integration_webhook", "")
} }

View file

@ -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 { private fun encodeUpdateJson(sale: Boolean, itemId: Int, value: Int, amtLeft: Int): String {
val obj = JSONObject() val obj = JSONObject()
val embeds = JSONArray() val embeds = JSONArray()