Implemented Tree Gnome Village Quest

Added Tree Gnome Village Quest requirement to Spirit Tree Network
Rewrote GnomeSpiritTree Plugin (converted to listener)
Added authentic "Local Gnome" NPC spawns
This commit is contained in:
downthecrop 2022-08-21 04:16:16 +00:00 committed by Ryan
parent ed29db1cb4
commit 744ee81124
18 changed files with 1249 additions and 179 deletions

View file

@ -1257,7 +1257,7 @@
}, },
{ {
"npc_id": "484", "npc_id": "484",
"loc_data": "{2542,3169,0,1,4}-{2541,3170,0,1,4}-{2537,3168,0,1,5}" "loc_data": "{2537,3168,0,1,5}-{2542,3167,0,0,1}-{2541,3168,0,0,2}-{2541,3171,0,0,3}-{2542,3172,0,0,4}"
}, },
{ {
"npc_id": "491", "npc_id": "491",

View file

@ -1,136 +0,0 @@
package core.game.content.dialogue;
import core.game.node.entity.player.Player;
import core.game.node.entity.player.link.diary.DiaryType;
import core.game.system.task.Pulse;
import rs09.game.world.GameWorld;
import core.game.world.map.Location;
import core.game.world.update.flag.context.Animation;
import core.plugin.Initializable;
import core.game.world.update.flag.context.Graphics;
/**
* Represents the dialogue plugin used for the gnome spirit tree.
*
* @author 'Vexia
* @author SonicForce41
*/
@Initializable
public final class GnomeSpiritTreeDialogue extends DialoguePlugin {
/**
* Represents the locations to travel to.
*/
private static final Location[] LOCATIONS = new Location[]{Location.create(2542, 3170, 0), Location.create(2461, 3444, 0), Location.create(2556, 3259, 0), Location.create(3184, 3508, 0)};
/**
* Represents the animations to use.
*/
private static final Animation[] ANIMATIONS = new Animation[]{new Animation(7082), new Animation(7084)};
/**
* Represents the graphics to use.
*/
private static final Graphics[] GRAPHICS = new Graphics[]{new Graphics(1228), new Graphics(1229)};
/**
* Constructs a new {@code GnomeSpiritTreeDialogue} {@code Object}.
*/
public GnomeSpiritTreeDialogue() {
/**
* empty.
*/
}
/**
* Constructs a new {@code GnomeSpiritTreeDialogue} {@code Object}.
*
* @param player the player.
*/
public GnomeSpiritTreeDialogue(Player player) {
super(player);
}
@Override
public DialoguePlugin newInstance(Player player) {
return new GnomeSpiritTreeDialogue(player);
}
@Override
public boolean open(Object... args) {
interpreter.sendDialogues(3636, null, "If you are a friend of the gnome people, you are a", "friend of mine, Do you wish to travel?");
stage = 1;
return true;
}
@Override
public boolean handle(int interfaceId, int buttonId) {
switch (stage) {
case 1:
interpreter.sendOptions("Where would you like to go?", "Tree Gnome Village", "Tree Gnome Stronghold", "Battlefield of Khazard", "Grand Exchange");
stage = 0;
break;
case 0:
Location location = null;
stage = 1;
switch (buttonId) {
case 1:
location = LOCATIONS[0];
sendTeleport(player, location);
break;
case 2:
location = LOCATIONS[1];
sendTeleport(player, location);
break;
case 3:
location = LOCATIONS[2];
sendTeleport(player, location);
break;
case 4:
location = LOCATIONS[3];
sendTeleport(player, location);
break;
}
return true;
}
return true;
}
/**
* Method used to send a gnome teleport.
*
* @param player the player.
* @param location the location.
*/
private void sendTeleport(final Player player, final Location location) {
end();
GameWorld.getPulser().submit(new Pulse(1, player) {
int loop;
@Override
public boolean pulse() {
if (loop == 0) {
player.animate(ANIMATIONS[0]);
player.graphics(GRAPHICS[0]);
} else if (loop == 3) {
player.getProperties().setTeleportLocation(location);
} else if (loop == 5) {
player.animate(ANIMATIONS[1]);
player.graphics(GRAPHICS[1]);
player.face(null);
if (player.getLocation().withinDistance(Location.create(3184, 3508, 0))) {
player.getAchievementDiaryManager().finishTask(player, DiaryType.VARROCK, 1, 5);
}
}
loop++;
return loop == 8;
}
});
}
@Override
public int[] getIds() {
return new int[]{1293, 1317};
}
}

View file

@ -1,42 +0,0 @@
package core.game.interaction.object;
import core.cache.def.impl.SceneryDefinition;
import core.game.interaction.OptionHandler;
import core.game.node.Node;
import core.game.node.entity.player.Player;
import core.plugin.Initializable;
import core.plugin.Plugin;
/**
* Represents the plugin to handle gnome tree teleporting.
* @author 'Vexia
* @version 1.0
*/
@Initializable
public final class GnomeSpiritTreePlugin extends OptionHandler {
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
SceneryDefinition.forId(1317).getHandlers().put("option:talk-to", this);
SceneryDefinition.forId(1317).getHandlers().put("option:teleport", this);
SceneryDefinition.forId(1293).getHandlers().put("option:talk-to", this);
SceneryDefinition.forId(1293).getHandlers().put("option:teleport", this);
SceneryDefinition.forId(1294).getHandlers().put("option:talk-to", this);
SceneryDefinition.forId(1294).getHandlers().put("option:teleport", this);
return this;
}
@Override
public boolean handle(Player player, Node node, String option) {
switch (option) {
case "talk-to":
player.getDialogueInterpreter().open(1317);
return true;
case "teleport":
player.getDialogueInterpreter().open(1317);
return true;
}
return true;
}
}

View file

@ -0,0 +1,46 @@
package rs09.game.content.quest.members.tree
import api.*
import rs09.game.content.dialogue.DialogueFile
import rs09.tools.END_DIALOGUE
class BallistaDialogue : DialogueFile(){
override fun handle(componentID: Int, buttonID: Int) {
val questStage = questStage(player!!, TreeGnomeVillage.questName)
if (questStage > 30) {
when (stage) {
0 -> sendDialogue(player!!, "The Khazard stronghold has already been breached.").also { stage = END_DIALOGUE }
}
} else if (questStage != 30) return
val tracker1 = getAttribute(player!!, "/save:treegnome:tracker1", false)
val tracker2 = getAttribute(player!!, "/save:treegnome:tracker2", false)
val tracker3 = getAttribute(player!!, "/save:treegnome:tracker3", false)
if(tracker1 && tracker2 && tracker3) {
when(stage){
0 -> playerl("That tracker gnome was a bit vague about the x coordinate! What could it be?").also { stage++ }
1 -> interpreter!!.sendOptions("Enter the x-coordinate of the stronghold",
"0001","0002","0003","0004").also { stage++ }
2 -> {
sendDialogue(player!!, "You entered the height and y coordinates you got from the tracker gnomes.")
val answer = getAttribute(player!!,"treegnome:xcoord",1)
when (buttonID) {
answer -> {
sendDialogue(player!!, "The huge spear flies through the air and screams down directly into the Khazard stronghold. A deafening crash echoes over the battlefield as the front entrance is reduced to rubble.")
setQuestStage(player!!, TreeGnomeVillage.questName, 31)
}
else -> sendDialogue(player!!, "The huge spear completely misses the Khazard stronghold!")
}
stage = END_DIALOGUE
}
}
} else {
when(stage){
0 -> sendDialogue(player!!,"You enter some random coordinates.").also { stage++ }
1 -> sendDialogue(player!!,"The huge spear completely misses the Khazard stronghold!").also { stage++ }
2 -> playerl("I've got no hope of hitting the stronghold without knowing any of the coordinates. Maybe I should ask Montai's tracker gnomes for more coordinates.").also { stage = END_DIALOGUE }
}
}
}
}

View file

@ -0,0 +1,106 @@
package rs09.game.content.quest.members.tree
import api.*
import org.rs09.consts.Items
import rs09.game.content.dialogue.DialogueFile
import rs09.tools.END_DIALOGUE
class CommanderMontaiDialogue : DialogueFile(){
override fun handle(componentID: Int, buttonID: Int) {
val questStage = questStage(player!!, TreeGnomeVillage.questName)
if (questStage == 10) {
when(stage) {
0 -> playerl("Hello.").also { stage++ }
1 -> npcl("Hello traveller, are you here to help or just to watch?").also { stage++ }
2 -> playerl("I've been sent by King Bolren to retrieve the orb of protection.").also { stage++ }
3 -> npcl("Excellent we need all the help we can get.").also { stage++ }
4 -> npcl("I'm Commander Montai. The orb is in the Khazard stronghold to the north, but until we weaken their defences we can't get close.").also { stage++ }
5 -> playerl("What can I do?").also { stage++ }
6 -> npcl("Firstly we need to strengthen our own defences. We desperately need wood to make more battlements, once the battlements are gone it's all over. Six loads of normal logs should do it.").also { stage++ }
7 -> options("Ok, I'll gather some wood.", "Sorry, I no longer want to be involved.").also { stage++ }
8 -> when (buttonID) {
1 -> playerl("Ok, I'll gather some wood.").also { stage = 10 }
2 -> playerl("Sorry, I no longer want to be involved.").also { stage = 9 }
}
9 -> npcl("That's a shame, we could have done with your help.").also { stage = END_DIALOGUE }
10 -> npcl("Please be as quick as you can, I don't know how much longer we can hold out.").also {
setQuestStage(player!!, TreeGnomeVillage.questName, 20)
stage = END_DIALOGUE
}
}
} else if (questStage == 20) {
if(inInventory(player!!, Items.LOGS_1511,6)){
when(stage) {
0 -> playerl("Hello.").also { stage++ }
1 -> npcl("Hello again, we're still desperate for wood soldier.").also { stage++ }
2 -> playerl("I have some here. (You give six loads of logs to the commander.)").also{ stage++ }
3 -> {
// Remove the 6 normal logs
for(i in 1..6) { removeItem(player!!,Items.LOGS_1511) }
setQuestStage(player!!, TreeGnomeVillage.questName, 25)
npcl("That's excellent, now we can make more defensive battlements. Give me a moment to organize the troops and then come speak to me. I'll inform you of our next phase of attack.")
stage = END_DIALOGUE
}
}
} else {
when(stage) {
0 -> playerl("Hello.").also { stage++ }
1 -> npcl("Hello again, we're still desperate for wood soldier. We need six loads of normal logs.").also { stage++ }
2 -> playerl("I'll see what I can do.").also { stage++ }
3 -> npcl("Thank you.").also { stage = END_DIALOGUE }
}
}
} else if (questStage == 25) {
when(stage) {
0 -> playerl("How are you doing Montai?").also { stage++ }
1 -> npcl("We're hanging in there soldier. For the next phase of our attack we need to breach their stronghold.").also { stage++ }
2 -> npcl("The ballista can break through the stronghold wall, and then we can advance and seize back the orb.").also { stage++ }
3 -> playerl("So what's the problem?").also { stage++ }
4 -> npcl("From this distance we can't get an accurate enough shot. We need the correct coordinates of the stronghold for a direct hit. I've sent out three tracker gnomes to gather them.").also { stage++ }
5 -> playerl("Have they returned?").also { stage++ }
6 -> npcl("I'm afraid not, and we're running out of time. I need you to go into the heart of the battlefield, find the trackers, and bring back the coordinates.").also { stage++ }
7 -> npcl("Do you think you can do it?").also { stage++ }
8 -> options("No, I've had enough of your battle.", "I'll try my best.").also { stage++ }
9 -> when(buttonID) {
1 -> playerl("No, I've had enough of your battle.").also { stage = 10 }
2 -> playerl("I'll try my best.").also { stage = 11 }
}
10 -> npcl("I understand, this isn't your fight.").also { stage = END_DIALOGUE }
11 -> npcl("Thank you, you're braver than most.").also { stage++ }
12 -> npcl("I don't know how long I will be able to hold out. Once you have the coordinates come back and fire the ballista right into those monsters.").also { stage++ }
13 -> npcl("If you can retrieve the orb and bring safety back to my people, none of the blood spilled on this field will be in vain.").also {
setQuestStage(player!!, TreeGnomeVillage.questName, 30)
stage = END_DIALOGUE
}
}
} else if (questStage == 30) {
when(stage) {
0 -> playerl("Hello.").also { stage++ }
1 -> npcl("Hello warrior. We need the coordinates for a direct hit from the ballista.").also { stage++ }
2 -> npcl("Once you have a direct hit you will be able to enter the stronghold and retrieve the orb.").also { stage = END_DIALOGUE }
}
} else if (questStage == 31) {
if(inInventory(player!!,Items.ORB_OF_PROTECTION_587)){
when(stage) {
0 -> playerl("I have the orb of protection.").also { stage++ }
1 -> npcl("Incredible, for a human you really are something.").also { stage++ }
2 -> playerl("Thanks... I think!").also { stage++ }
3 -> npcl("I'll stay here with my troops and try and hold Khazard's men back. You return the orb to the gnome village. Go as quick as you can, the village is still unprotected.").also { stage = END_DIALOGUE }
}
} else {
when(stage) {
0 -> playerl("I've breached the stronghold.").also { stage++ }
1 -> npcl("I saw, that was a beautiful sight. The Khazard troops didn't know what hit them.").also { stage++ }
2 -> npcl("Now is the time to retrieve the orb. It's all in your hands. I'll be praying for you.").also { stage = END_DIALOGUE }
}
}
} else if (questStage != 0){
when(stage) {
0 -> playerl("Hello Montai, how are you?").also { stage++ }
1 -> npcl("I'm ok, this battle is going to take longer to win than I expected. The Khazard troops won't give up even without the orb.").also { stage++ }
2 -> playerl("Hang in there.").also { stage = END_DIALOGUE }
}
}
}
}

View file

@ -0,0 +1,171 @@
package rs09.game.content.quest.members.tree
import api.*
import core.game.component.Component
import core.game.content.dialogue.FacialExpression
import core.game.node.entity.player.Player
import core.game.system.task.Pulse
import core.game.world.map.Location
import org.rs09.consts.Components
import org.rs09.consts.Items
import rs09.game.content.dialogue.DialogueFile
import rs09.game.content.quest.members.tree.TreeGnomeVillage.Companion.mazeEntrance
import rs09.game.content.quest.members.tree.TreeGnomeVillage.Companion.mazeVillage
import rs09.game.content.quest.members.tree.TreeGnomeVillage.Companion.questName
import rs09.game.world.GameWorld.Pulser
import rs09.tools.END_DIALOGUE
class ElkoyDialogue : DialogueFile(){
fun travelCutscene(player: Player, location: Location){
sendDialogue(player,"Elkoy escorts you through the maze...")
Pulser.submit(object : Pulse(0) {
var count = 0
override fun pulse(): Boolean {
when (count) {
0 -> {
player.interfaceManager.closeOverlay()
player.interfaceManager.openOverlay(Component(Components.FADE_TO_BLACK_120))
}
2 -> {
teleport(player,location)
player.interfaceManager.closeOverlay()
player.interfaceManager.openOverlay(Component(Components.FADE_FROM_BLACK_170))
return true
}
}
count++
return false
}
})
}
override fun handle(componentID: Int, buttonID: Int) {
val questStage = questStage(player!!, questName)
val locY = player!!.location.y
val followLocation = if(locY > 3161) "village" else "exit"
when {
inInventory(player!!, Items.ORBS_OF_PROTECTION_588) && followLocation == "exit" -> {
when(stage) {
0 -> playerl("Hello Elkoy. I have the orb.").also { stage++ }
1 -> npcl("Take it to King Bolren, I'm sure he'll be pleased to see you.").also { stage++ }
2 -> options("Alright, I'll do that.", "Can you guide me out of the maze now?").also { stage++ }
3 -> when(buttonID) {
1 -> playerl("Alright, I'll do that.").also { stage = END_DIALOGUE }
2 -> playerl("Can you guide me out of the maze now?").also { stage = 4 }
}
4 -> npcl("If you like, but please take the orb to King Bolren soon.").also { stage++ }
5 -> {
travelCutscene(player!!, mazeEntrance)
stage++
}
6 -> npcl("Here we are. Please don't lose the orb!").also { stage = END_DIALOGUE }
}
}
inInventory(player!!, Items.ORB_OF_PROTECTION_587) -> {
when(stage) {
0 -> playerl("Hello Elkoy.").also { stage++ }
1 -> npcl("You're back! And the orb?").also { stage++ }
2 -> playerl("I have it here.").also { stage++ }
3 -> {
if(locY > 3161){
npcl("You're our saviour. Please return it to the village and we are all saved. Would you like me to show you the way to the village?").also { stage++ }
} else {
npcl("Take the orb to King Bolren, I'm sure he'll be pleased to see you.").also { stage = END_DIALOGUE }
}
}
4 -> options("Yes please.", "No thanks Elkoy.").also { stage++ }
5 -> when(buttonID) {
1 -> playerl("Yes please.").also { stage = 7 }
2 -> playerl("No thanks Elkoy.").also { stage = 6 }
}
6 -> npcl("Ok then, take care.").also { stage = END_DIALOGUE }
7 -> travelCutscene(player!!, mazeVillage).also { stage++ }
8 -> npcl("Here we are. Take the orb to King Bolren, I'm sure he'll be pleased to see you.").also { stage = END_DIALOGUE }
}
}
inInventory(player!!, Items.ORBS_OF_PROTECTION_588) || questStage == 100 -> {
when(stage) {
0 -> playerl("Hello Elkoy.").also { stage++ }
1 -> npcl("You truly are a hero.").also { stage++ }
2 -> playerl("Thanks.").also { stage++ }
3 -> npcl("You saved us by defeating the warlord. I'm humbled and wish you well.").also { stage++ }
4 -> npcl("Would you like me to show you the way to the ${followLocation}?").also { stage++ }
5 -> options("Yes please.", "No thanks Elkoy.").also { stage++ }
6 -> when(buttonID) {
1 -> playerl("Yes please.").also { stage = 8 }
2 -> playerl("No thanks Elkoy.").also { stage = 7 }
}
7 -> npcl("Ok then, take care.").also { stage = END_DIALOGUE }
8 -> {
if(followLocation == "village") {
travelCutscene(player!!, mazeVillage)
stage = 10
}
else {
travelCutscene(player!!, mazeEntrance)
stage++
}
}
9 -> npcl("Here we are. Have a safe journey.").also { stage = END_DIALOGUE }
10 -> npcl("Here we are. Feel free to have a look around.").also { stage = END_DIALOGUE }
}
}
questStage == 0 -> {
when(stage) {
0 -> playerl("Hello there.").also { stage++ }
1 -> npcl("Hello, welcome to our maze. I'm Elkoy the tree gnome.").also { stage++ }
2 -> playerl("I haven't heard of your sort.").also { stage++ }
3 -> npcl("There's not many of us left. Once you could find tree gnomes anywhere in the world, now we hide in small groups to avoid capture.").also { stage++ }
4 -> playerl("Capture from whom?").also { stage++ }
5 -> npcl("Tree gnomes have been hunted for so called 'fun' since as long as I can remember.").also { stage++ }
6 -> npcl("Our main thread nowadays are General Khazard's troops. They know no mercy, but are also very dense. They'll never find their way through our maze.").also { stage++ }
7 -> npcl("Have fun.").also { stage = END_DIALOGUE }
}
}
questStage in 1..39 -> {
when (stage) {
0 -> npcl("Oh my! The orb, they have the orb. We're doomed.").also { stage++ }
1 -> playerl("Perhaps I'll be able to get it back for you.").also { stage++ }
2 -> npcl("Would you like me to show you the way to the ${followLocation}?").also { stage++ }
3 -> options("Yes please.", "No thanks Elkoy.").also { stage++ }
4 -> when (buttonID) {
1 -> playerl("Yes please.").also { stage = 6 }
2 -> playerl("No thanks Elkoy.").also { stage = 5 }
}
5 -> npcl("Ok then, take care.").also { stage = END_DIALOGUE }
6 -> {
if(followLocation == "village")
travelCutscene(player!!, mazeVillage)
else
travelCutscene(player!!, mazeEntrance)
stage++
}
7 -> npcl("Here we are. I hope you get the orb back soon.").also { stage = END_DIALOGUE }
}
}
questStage == 40 -> {
when(stage) {
0 -> playerl("Hello Elkoy.").also { stage++ }
1 -> npcl("Did you hear? Khazard's men have pillaged the village! They slaughtered many, and took the other orbs in an attempt to lead us out of the maze. When will the misery end?").also { stage++ }
2 -> npcl("Would you like me to show you the way to the ${followLocation}?").also { stage++ }
3 -> options("Yes please.", "No thanks Elkoy.").also { stage++ }
4 -> when(buttonID) {
1 -> playerl("Yes please.").also { stage = 6 }
2 -> playerl("No thanks Elkoy.").also { stage = 5 }
}
5 -> npcl("Ok then, take care.").also { stage = END_DIALOGUE }
6 -> {
if(followLocation == "village") {
travelCutscene(player!!, mazeVillage)
stage = 8
} else {
travelCutscene(player!!, mazeEntrance)
stage++
}
}
7 -> npcl("Please try to get our orbs back for us, otherwise the village is doomed!").also { stage = END_DIALOGUE }
8 -> npcl("Here we are. Despite what has happened here, I hope you feel welcome.").also { stage = END_DIALOGUE }
}
}
}
}
}

View file

@ -0,0 +1,31 @@
package rs09.game.content.quest.members.tree
import api.questStage
import rs09.game.content.dialogue.DialogueFile
import rs09.tools.END_DIALOGUE
class KhazardWarlordDialogue : DialogueFile(){
override fun handle(componentID: Int, buttonID: Int) {
val questStage = questStage(player!!,TreeGnomeVillage.questName)
if(questStage == 31){
when(stage) {
0 -> playerl("Hello there.").also { stage++ }
1 -> npcl("You think you're so clever. You know nothing!").also { stage++ }
2 -> playerl("What?").also { stage++ }
3 -> npcl("I'll crush you and those pesky little green men!").also { stage = END_DIALOGUE }
}
} else if (questStage == 40) {
when(stage) {
0 -> playerl("You there, stop!").also { stage++ }
1 -> npcl("Go back to your pesky little green friends.").also { stage++ }
2 -> playerl("I've come for the orbs.").also { stage++ }
3 -> npcl("You're out of your depth traveller. These orbs are part of a much larger picture.").also { stage++ }
4 -> playerl("They're stolen goods, now give them here!").also { stage++ }
5 -> npcl("Ha, you really think you stand a chance? I'll crush you.").also {
npc!!.attack(player!!)
stage = END_DIALOGUE
}
}
}
}
}

View file

@ -0,0 +1,36 @@
package rs09.game.content.quest.members.tree
import api.addItemOrDrop
import api.questStage
import api.sendDialogue
import core.game.node.entity.Entity
import core.game.node.entity.npc.AbstractNPC
import core.game.node.entity.player.Player
import core.game.world.map.Location
import core.plugin.Initializable
import org.rs09.consts.Items
import org.rs09.consts.NPCs
import rs09.game.interaction.InteractionListener
@Initializable
class KhazardWarlordNPC(id: Int = 0, location: Location? = null) : AbstractNPC(id,location), InteractionListener {
override fun construct(id: Int, location: Location?, vararg objects: Any?): AbstractNPC {
return KhazardWarlordNPC(id, location)
}
override fun getIds(): IntArray {
return intArrayOf(NPCs.KHAZARD_WARLORD_477)
}
override fun defineListeners() {
}
override fun finalizeDeath(killer: Entity?) {
if(questStage(killer as Player,TreeGnomeVillage.questName) == 40) {
sendDialogue(killer,"As the warlord falls to the ground, a ghostly vapour floats upwards from his battle-worn armour. You search his satchel and find the orbs of protection.")
addItemOrDrop(killer, Items.ORBS_OF_PROTECTION_588)
}
super.finalizeDeath(killer)
}
}

View file

@ -0,0 +1,199 @@
package rs09.game.content.quest.members.tree
import api.*
import core.game.component.Component
import core.game.node.entity.player.Player
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 org.rs09.consts.Components
import org.rs09.consts.Items
import org.rs09.consts.NPCs
import rs09.game.content.dialogue.DialogueFile
import rs09.game.content.quest.members.tree.TreeGnomeVillage.Companion.mazeEntrance
import rs09.game.content.quest.members.tree.TreeGnomeVillage.Companion.questName
import rs09.game.world.GameWorld
import rs09.tools.END_DIALOGUE
class KingBolrenDialogue : DialogueFile() {
override fun handle(componentID: Int, buttonID: Int) {
val questStage = questStage(player!!, questName)
when {
questStage < 10 -> {
when (stage) {
0 -> playerl("Hello.").also { stage++ }
1 -> npcl("Well hello stranger. My name's Bolren, I'm the king of the tree gnomes.").also { stage++ }
2 -> npcl("I'm surprised you made it in, maybe I made the maze too easy.").also { stage++ }
3 -> playerl("Maybe.").also { stage++ }
4 -> npcl("I'm afraid I have more serious concerns at the moment. Very serious.").also { stage++ }
5 -> options("I'll leave you to it then.", "Can I help at all?").also { stage++ }
6 -> when (buttonID) {
1 -> playerl("I'll leave you to it then.").also { stage = 7 }
2 -> playerl("Can I help at all?").also { stage = 8 }
}
7 -> npcl("Ok, take care.").also { stage = END_DIALOGUE }
8 -> npcl("I'm glad you asked.").also { stage++ }
9 -> npcl("The truth is my people are in grave danger. We have always been protected by the Spirit Tree. No creature of dark can harm us while its three orbs are in place.").also { stage++ }
10 -> npcl("We are not a violent race, but we fight when we must. Many gnomes have fallen battling the dark forces of Khazard to the North.").also { stage++ }
11 -> npcl("We became desperate, so we took one orb of protection to the battlefield. It was a foolish move.").also { stage++ }
12 -> npcl("Khazard troops seized the orb. Now we are completely defenceless.").also { stage++ }
13 -> playerl("How can I help?").also { stage++ }
14 -> npcl("You would be a huge benefit on the battlefield. If you would go there and try to retrieve the orb, my people and I will be forever grateful.").also { stage++ }
15 -> options("I would be glad to help.", "I'm sorry but I won't be involved.").also { stage++ }
16 -> when (buttonID) {
1 -> playerl("I would be glad to help.").also { stage = 18 }
2 -> playerl("I'm sorry but I won't be involved.").also { stage = 17 }
}
17 -> npcl("Ok then, travel safe.").also { stage = END_DIALOGUE }
18 -> npcl("Thank you. The battlefield is to the north of the maze. Commander Montai will inform you of their current situation.").also { stage++ }
19 -> npcl("That is if he's still alive.").also { stage++ }
20 -> npcl("My assistant shall guide you out. Good luck friend, try your best to return the orb.").also {
stage++
}
21 -> {
teleport(player!!, mazeEntrance)
sendNPCDialogue(player!!, NPCs.ELKOY_5179, "We're out of the maze now. Please hurry, we must have the orb if we are to survive.")
setQuestStage(player!!, questName, 10)
stage = END_DIALOGUE
}
}
}
questStage < 31 -> {
when (stage) {
0 -> playerl("Hello Bolren.").also { stage++ }
1 -> npcl("Hello traveller, we must retrieve the orb. It's being held by Khazard troops north of here.").also { stage++ }
2 -> playerl("Ok, I'll try my best.").also { stage = END_DIALOGUE }
}
}
questStage == 31 -> {
if(inInventory(player!!,Items.ORB_OF_PROTECTION_587)){
when(stage) {
0 -> playerl("I have the orb.").also { stage++ }
1 -> npcl("Oh my... The misery, the horror!").also { stage++ }
2 -> playerl("King Bolren, are you OK?").also { stage++ }
3 -> npcl("Thank you traveller, but it's too late. We're all doomed.").also { stage++ }
4 -> playerl("What happened?").also { stage++ }
5 -> npcl("They came in the night. I don't know how many, but enough.").also { stage++ }
6 -> playerl("Who?").also { stage++ }
7 -> npcl("Khazard troops. They slaughtered anyone who got in their way. Women, children, my wife.").also { stage++ }
8 -> playerl("I'm sorry.").also { stage++ }
9 -> npcl("They took the other orbs, now we are defenceless.").also { stage++ }
10 -> playerl("Where did they take them?").also { stage++ }
11 -> npcl("They headed north of the stronghold. A warlord carries the orbs.").also { stage++ }
12 -> options("I will find the warlord and bring back the orbs.", "I'm sorry but I can't help.").also { stage++ }
13 -> when(buttonID) {
1 -> playerl("I will find the warlord and bring back the orbs.").also { stage = 15 }
2 -> playerl("I'm sorry but I can't help.").also { stage = 14 }
}
14 -> npcl("I understand, this isn't your battle.").also { stage = END_DIALOGUE }
15 -> npcl("You are brave, but this task will be tough even for you. I wish you the best of luck. Once again you are our only hope.").also { stage++ }
16 -> npcl("I will safeguard this orb and pray for your safe return. My assistant will guide you out.").also {
stage++
}
17 -> {
if(removeItem(player!!,Items.ORB_OF_PROTECTION_587)){
teleport(player!!,mazeEntrance)
setQuestStage(player!!, questName,40)
sendNPCDialogue(player!!, NPCs.ELKOY_5179, "Good luck friend.")
}
stage = END_DIALOGUE
}
}
} else {
when(stage) {
0 -> playerl("Hello Bolren.").also { stage++ }
1 -> npcl("Do you have the orb?").also { stage++ }
2 -> playerl("No, I'm afraid not.").also { stage++ }
3 -> npcl("Please, we must have the orb if we are to survive.").also { stage = END_DIALOGUE }
}
}
}
questStage == 40 -> {
if(inInventory(player!!,Items.ORBS_OF_PROTECTION_588)){
when(stage) {
0 -> playerl("Bolren, I have returned.").also { stage++ }
1 -> npcl("You made it back! Do you have the orbs?").also { stage++ }
2 -> playerl("I have them here.").also { stage++ }
3 -> npcl("Hooray, you're amazing. I didn't think it was possible but you've saved us.").also { stage++ }
4 -> npcl("Once the orbs are replaced we will be safe once more. We must begin the ceremony immediately.").also { stage++ }
5 -> playerl("What does the ceremony involve?").also { stage++ }
6 -> npcl("The spirit tree has looked over us for centuries. Now we must pay our respects.").also { stage++ }
7 -> sendDialogue(player!!,"The gnomes begin to chant. Meanwhile, King Bolren holds the orbs of protection out in front of him.").also { stage++ }
8 -> {
// Orbs fly up, gnomes chant, spirit tree animates
GameWorld.Pulser.submit(object : Pulse(0) {
var count = 0
val orbsOfProtection = 79
val spiritTreeWithOrbs = Animation(333)
val gnomeSpots = listOf(Location(2542, 3172, 0),Location(2541, 3171, 0),Location(2542, 3167, 0),Location(2541, 3168, 0))
val spiritTree = getScenery(2543,3168,0)
override fun pulse(): Boolean {
when (count) {
0 -> {
forceWalk(player!!,Location(2542, 3170, 0),"DUMB")
}
2 -> {
player!!.faceLocation(Location(2543,3170,0))
for((i, spot) in gnomeSpots.withIndex()){
val gnome = RegionManager.getNpc(spot, NPCs.LOCAL_GNOME_484, 1)
gnome!!.faceLocation(Location(2543,3169,0))
gnome.animate(Animation(197))
if(i < 2)
gnome.sendChat("En tanai.")
else
gnome.sendChat("Su tana.")
}
}
3 -> {
player!!.packetDispatch.sendGraphic(orbsOfProtection)
}
5 -> {
player!!.packetDispatch.sendSceneryAnimation(spiritTree, spiritTreeWithOrbs, false)
sendDialogue(player!!,"The orbs of protection come to rest gently in the branches of the ancient spirit tree.")
return true
}
}
count++
return false
}
})
// This loops back to the start of the handle..
if(removeItem(player!!,Items.ORBS_OF_PROTECTION_588)){
setQuestStage(player!!,questName,99)
}
stage = 0
}
}
} else {
when(stage) {
0 -> playerl("Bolren, I have returned.").also { stage++ }
1 -> npcl("You made it back! Do you have the orbs?").also { stage++ }
2 -> playerl("No, I'm afraid not.").also { stage++ }
3 -> npcl("Please, we must have the orb if we are to survive.").also { stage = END_DIALOGUE }
}
}
}
questStage == 99 -> {
when(stage){
0 -> npcl("Now at last my people are safe once more. We can live in peace again.").also { stage++ }
1 -> playerl("I'm pleased I could help.").also { stage++ }
2 -> npcl("You are modest brave traveller.").also { stage++ }
3 -> npcl("Please, for your efforts take this amulet. It's made from the same sacred stone as the orbs of protection. It will help keep you safe on your journeys.").also { stage++ }
4 -> playerl("Thank you King Bolren.").also { stage++ }
5 -> npcl("The tree has many other powers, some of which I cannot reveal. As a friend of the gnome people, I can now allow you to use the tree's magic to teleport to other trees grown from related seeds.").also {
finishQuest(player!!,questName)
stage = END_DIALOGUE
}
}
}
isQuestComplete(player!!, questName) -> {
when(stage) {
0 -> playerl("Hello Bolren.").also { stage++ }
1 -> npcl("Thank you for your help traveler.").also { stage = END_DIALOGUE }
}
}
}
}
}

View file

@ -0,0 +1,18 @@
package rs09.game.content.quest.members.tree
import rs09.game.content.dialogue.DialogueFile
import rs09.tools.END_DIALOGUE
class LieutenantSchepburDialogue : DialogueFile(){
override fun handle(componentID: Int, buttonID: Int) {
when(stage) {
0 -> npcl("Move into position lads! eh? Who are you and what do you want?").also { stage++ }
1 -> playerl("Who are you then?").also { stage++ }
2 -> npcl("Lieutenant Schepbur, commanding officer of the new Armoured Tortoise Regiment.").also { stage++ }
3 -> playerl("There's only two tortoises here, that's hardly a regiment.").also { stage++ }
4 -> npcl("This is just the beginning! Gnome breeders and trainers are already working to expand the number of units. Soon we'll have hundreds of these beauties, nay thousands! And they will not only carry mages and").also { stage++ }
5 -> npcl("archers but other fiendish weapons of destruction of gnome devising. An army of giant tortoises will march upon this battlefield and rain the fire of our wrath upon all our enemies! Nothing will be able to stop us!").also { stage++ }
6 -> playerl("Oooookayy...... I'll leave you to it then....").also { stage = END_DIALOGUE }
}
}
}

View file

@ -0,0 +1,13 @@
package rs09.game.content.quest.members.tree
import rs09.game.content.dialogue.DialogueFile
import rs09.tools.END_DIALOGUE
class LocalGnomeDialogue : DialogueFile() {
override fun handle(componentID: Int, buttonID: Int) {
when (stage) {
0 -> playerl("Hello little man.").also { stage++ }
1 -> npcl("Little man stronger than big man. Hee hee, lardi dee, lardi da.").also { stage = END_DIALOGUE }
}
}
}

View file

@ -0,0 +1,49 @@
package rs09.game.content.quest.members.tree
import api.inInventory
import api.questStage
import org.rs09.consts.Items
import rs09.game.content.dialogue.DialogueFile
import rs09.tools.END_DIALOGUE
class RemsaiDialogue : DialogueFile(){
override fun handle(componentID: Int, buttonID: Int) {
val questStage = questStage(player!!, TreeGnomeVillage.questName)
when {
inInventory(player!!,Items.ORBS_OF_PROTECTION_588) -> {
when(stage) {
0 -> playerl("I've returned.").also { stage++ }
1 -> npcl("You're back, well done brave adventurer. Now the orbs are safe we can perform the ritual for the spirit tree. We can live in peace once again.").also { stage = END_DIALOGUE }
}
}
inInventory(player!!, Items.ORB_OF_PROTECTION_587) -> {
when(stage) {
0 -> playerl("Hello Remsai.").also { stage++ }
1 -> npcl("Hello, did you find the orb?").also { stage++ }
2 -> playerl("I have it here.").also { stage++ }
3 -> npcl("You're our saviour.").also { stage = END_DIALOGUE }
}
}
questStage < 40 -> {
when(stage) {
0 -> playerl("Hello Remsai.").also { stage++ }
1 -> npcl("Hello, did you find the orb?").also { stage++ }
2 -> playerl("No, I'm afraid not.").also { stage++ }
3 -> npcl("Please, we must have the orb if we are to survive.").also { stage = END_DIALOGUE }
}
}
questStage == 40 -> {
when(stage) {
0 -> playerl("Are you ok?").also { stage++ }
1 -> npcl("Khazard's men came. Without the orb we were defenceless. They killed many and then took our last hope, the other orbs. Now surely we're all doomed. Without them the spirit tree is useless.").also { stage = END_DIALOGUE }
}
}
questStage > 40 -> {
when(stage) {
0 -> playerl("I've returned.").also { stage++ }
1 -> npcl("You're back, well done brave adventurer. Now the orbs are safe we can perform the ritual for the spirit tree. We can live in peace once again.").also { stage = END_DIALOGUE }
}
}
}
}
}

View file

@ -0,0 +1,46 @@
package rs09.game.content.quest.members.tree
import api.*
import org.rs09.consts.Items
import rs09.game.content.dialogue.DialogueFile
import rs09.tools.END_DIALOGUE
class TrackerGnomeOneDialogue : DialogueFile(){
override fun handle(componentID: Int, buttonID: Int) {
val questStage = questStage(player!!, TreeGnomeVillage.questName)
when {
questStage >= 40 -> {
when (stage) {
0 -> playerl("Hello").also { stage++ }
1 -> npcl("When will this battle end? I feel like I've been fighting forever.").also { stage = END_DIALOGUE }
}
}
questStage > 30 -> {
if(inInventory(player!!, Items.ORB_OF_PROTECTION_587)){
when(stage) {
0 -> playerl("How are you tracker?").also { stage++ }
1 -> npcl("Now we have the orb I'm much better. They won't stand a chance without it.").also { stage = END_DIALOGUE }
}
} else {
when(stage) {
0 -> playerl("Hello again.").also { stage++ }
1 -> npcl("Well done, you've broken down their defences. This battle must be ours.").also { stage = END_DIALOGUE }
}
}
}
questStage == 30 -> {
when (stage) {
0 -> playerl("Do you know the coordinates of the Khazard stronghold?").also { stage++ }
1 -> npcl("I managed to get one, although it wasn't easy.").also { stage++ }
2 -> sendDialogue(player!!, "The gnome tells you the height coordinate.").also {
setAttribute(player!!, "/save:treegnome:tracker1", true)
stage++
}
3 -> playerl("Well done.").also { stage++ }
4 -> npcl("The other two tracker gnomes should have the other coordinates if they're still alive.").also { stage++ }
5 -> playerl("OK, take care.").also { stage = END_DIALOGUE }
}
}
}
}
}

View file

@ -0,0 +1,67 @@
package rs09.game.content.quest.members.tree
import api.*
import rs09.game.content.dialogue.DialogueFile
import rs09.tools.END_DIALOGUE
class TrackerGnomeThreeDialogue : DialogueFile(){
private val xcoordMap = mapOf(
1 to "Less than my hands.",
2 to "More than my head, less than my fingers.",
3 to "More than we but less than our feet.",
4 to "My legs and your legs.")
override fun handle(componentID: Int, buttonID: Int) {
val questStage = questStage(player!!, TreeGnomeVillage.questName)
when {
questStage == 30 -> {
when(stage) {
0 -> playerl("Are you OK?").also { stage++ }
1 -> npcl("OK? Who's OK? Not me! Hee hee!").also { stage++ }
2 -> playerl("What's wrong?").also { stage++ }
3 -> npcl("You can't see me, no one can. Monsters, demons, they're all around me!").also { stage++ }
4 -> playerl("What do you mean?").also { stage++ }
5 -> npcl("They're dancing, all of them, hee hee.").also { stage++ }
6 -> sendDialogue(player!!,"He's clearly lost the plot.").also { stage++ }
7 -> playerl("Do you have the coordinate for the Khazard stronghold?").also { stage++ }
8 -> npcl("Who holds the stronghold?").also { stage++ }
9 -> playerl("What?").also { stage++ }
10 -> {
// Generate the x coordinate answer
if(getAttribute(player!!,"treegnome:xcoord",0) == 0){
val answer = (1..4).random()
npcl(xcoordMap[answer])
setAttribute(player!!,"/save:treegnome:xcoord",answer)
} else {
npcl(xcoordMap[getAttribute(player!!,"treegnome:xcoord",1)])
}
stage++
}
11 -> playerl("You're mad").also { stage++ }
12 -> npcl("Dance with me, and Khazard's men are beat.").also { stage++ }
13 -> sendDialogue(player!!,"The toll of war has affected his mind.").also { stage++ }
14 -> playerl("I'll pray for you little man.").also { stage++ }
15 -> npcl("All day we pray in the hay, hee hee.").also {
setAttribute(player!!, "/save:treegnome:tracker3", true)
stage = END_DIALOGUE
}
}
}
questStage == 31 -> {
when(stage) {
0 -> playerl("Hello again.").also { stage++ }
1 -> npcl("Don't talk to me, you can't see me. No one can, just the demons.").also { stage = END_DIALOGUE }
}
}
questStage > 31 -> {
when(stage) {
0 -> playerl("Hello").also { stage++ }
1 -> npcl("I feel dizzy, where am I? Oh dear, oh dear I need some rest.").also { stage++ }
2 -> playerl("I think you do.").also { stage = END_DIALOGUE }
}
}
}
}
}

View file

@ -0,0 +1,50 @@
package rs09.game.content.quest.members.tree
import api.*
import org.rs09.consts.Items
import rs09.game.content.dialogue.DialogueFile
import rs09.tools.END_DIALOGUE
class TrackerGnomeTwoDialogue : DialogueFile(){
override fun handle(componentID: Int, buttonID: Int) {
val questStage = questStage(player!!, TreeGnomeVillage.questName)
when {
questStage == 30 -> {
when (stage) {
0 -> playerl("Are you OK?").also { stage++ }
1 -> npcl("They caught me spying on the stronghold. They beat and tortured me.").also { stage++ }
2 -> npcl("But I didn't crack. I told them nothing. They can't break me!").also { stage++ }
3 -> playerl("I'm sorry little man.").also { stage++ }
4 -> npcl("Don't be. I have the position of the stronghold!").also { stage++ }
5 -> sendDialogue(player!!, "The gnome tells you the y coordinate.").also {
setAttribute(player!!, "/save:treegnome:tracker2", true)
stage++
}
6 -> playerl("Well done.").also { stage++ }
7 -> npcl("Now leave before they find you and all is lost.").also { stage++ }
8 -> playerl("Hang in there.").also { stage++ }
9 -> npcl("Go!").also { stage = END_DIALOGUE }
}
}
questStage >= 40 -> {
when(stage) {
0 -> playerl("Hello").also { stage++ }
1 -> npcl("When will this battle end? I feel like I've been locked up my whole life.").also { stage = END_DIALOGUE }
}
}
questStage > 30 -> {
if(inInventory(player!!,Items.ORB_OF_PROTECTION_587)){
when(stage) {
0 -> playerl("How are you tracker?").also { stage++ }
1 -> npcl("Now we have the orb I'm much better. Soon my comrades will come and free me.").also { stage = END_DIALOGUE }
}
} else {
when(stage) {
0 -> playerl("Hello again.").also { stage++ }
1 -> npcl("Well done, you've broken down their defences. This battle must be ours.").also { stage = END_DIALOGUE }
}
}
}
}
}
}

View file

@ -0,0 +1,96 @@
package rs09.game.content.quest.members.tree
import api.addItemOrDrop
import api.inInventory
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.world.map.Location
import core.plugin.Initializable
import org.rs09.consts.Items
@Initializable
class TreeGnomeVillage: Quest("Tree Gnome Village", 125, 124, 2, 111, 0, 1, 9) {
override fun newInstance(`object`: Any?): Quest {
return this
}
override fun finish(player: Player?) {
super.finish(player)
player ?: return
var ln = 10
player.packetDispatch.sendItemZoomOnInterface(Items.GNOME_AMULET_589, 230, 277, 5)
drawReward(player,"2 Quest Points", ln++)
drawReward(player,"11,450 Attack XP", ln++)
drawReward(player,"Gnome Amulet of Protection", ln)
player.skills.addExperience(Skills.ATTACK, 11450.0)
addItemOrDrop(player,Items.GNOME_AMULET_589)
player.questRepository.syncronizeTab(player)
}
override fun drawJournal(player: Player?, stage: Int) {
super.drawJournal(player, stage)
var line = 12
player?: return
if(stage == 0){
line(player, "You can start this quest by speaking to !!King Bolren?? in the", line++, stage > 0)
line(player, "!!Tree Gnome Village??", line++, stage > 0)
line++
}
if(stage >= 10){
line(player, "King Bolren said that one of their orbs of", line++, stage > 10)
line(player, "protection has been stolen by Khazard troops.", line++, stage > 10)
line(player, "Commander Montai, North !!of the maze, can help you get?? it", line++, stage > 10)
line++
}
if (stage >= 20) {
line(player, "Commander Montai has asked you to gather !!6 normal logs??", line++, stage > 20)
line(player, "to make more battlements.", line++, stage > 20)
line++
}
if (stage == 25) {
line(player, "You should ask Commander Montai for further instruction.", line++)
line++
}
if (stage >= 30) {
line(player, "Commander Montai needs help locating his !!tracker gnomes?? to", line++,stage > 30)
line(player, "gather the coordinates to strike the Khazard stronghold", line++, stage > 30)
line(player, "You must speak with:", line++, stage > 30)
line(player, "Tracker Gnome 1", line++, player.getAttribute("treegnome:tracker1",false))
line(player, "Tracker Gnome 2", line++, player.getAttribute("treegnome:tracker2",false))
line(player, "Tracker Gnome 3", line++, player.getAttribute("treegnome:tracker3",false))
line++
}
if (stage >= 31) {
line(player, "The ballista opened a hole in the !!Khazard stronghold??.", line++, stage > 31)
line(player, "Commander Montai says the !!Orb of Protection?? should be in there", line++, stage > 31)
line++
}
if (inInventory(player,Items.ORB_OF_PROTECTION_587)) {
line(player, "You've retrieved the orb! You should return it to !!King Bolren??", line++)
}
if (stage >= 40) {
line(player, "Khazard troops took the other !!Orbs of Protection?? ", line++, stage > 40)
line(player, "They were headed north of the stronghold.", line++, stage > 40)
line(player,"A warlord carries the orbs.",line++, stage > 40)
line++
}
if (inInventory(player,Items.ORBS_OF_PROTECTION_588)) {
line(player, "You've retrieved the orbs!", line++)
line(player, "You should return them it to !!King Bolren??",line++)
}
if (stage >= 99) {
line(player,"You have returned the orbs!", line++, stage > 99)
line(player, "Speak with King Bolren for a reward!", line++, stage > 99)
line++
}
if (stage == 100) {
line(player,"QUEST COMPLETE", line, stage > 99)
}
}
companion object {
val mazeVillage = Location(2515,3159,0)
val mazeEntrance = Location(2504,3192,0)
const val questName = "Tree Gnome Village"
}
}

View file

@ -0,0 +1,203 @@
package rs09.game.content.quest.members.tree
import api.*
import core.game.content.global.action.DoorActionHandler
import core.game.node.Node
import core.game.node.entity.impl.ForceMovement
import core.game.node.entity.npc.NPC
import core.game.node.entity.player.Player
import core.game.node.entity.skill.agility.AgilityHandler
import core.game.node.scenery.Scenery
import core.game.node.scenery.SceneryBuilder
import core.game.system.task.Pulse
import core.game.world.map.Direction
import core.game.world.map.Location
import core.game.world.map.RegionManager
import core.game.world.update.flag.context.Animation
import org.rs09.consts.Items
import org.rs09.consts.NPCs
import rs09.game.content.dialogue.DialogueFile
import rs09.game.content.quest.members.tree.TreeGnomeVillage.Companion.mazeEntrance
import rs09.game.content.quest.members.tree.TreeGnomeVillage.Companion.mazeVillage
import rs09.game.interaction.InteractionListener
import rs09.game.world.GameWorld
class TreeGnomeVillageListeners : InteractionListener {
private val ballista = 2181
private val crumbledWall = 12762
private val closedChest = 2183
private val looseRailing = 2186
private val openedChest = 2182
private val strongholdDoor = 2184
override fun defineDestinationOverrides() {
setDest(NPC, intArrayOf(NPCs.TRACKER_GNOME_2_482),"talk-to"){ _, _ ->
return@setDest Location.create(2524, 3256, 0)
}
}
override fun defineListeners() {
on(NPCs.KING_BOLREN_469, NPC, "talk-to"){ player, npc ->
openDialogue(player, KingBolrenDialogue(), npc)
return@on true
}
on(NPCs.ELKOY_5179, NPC, "talk-to"){ player, npc ->
openDialogue(player, ElkoyDialogue(), npc)
return@on true
}
on(NPCs.ELKOY_5182, NPC, "talk-to"){ player, npc ->
openDialogue(player, ElkoyDialogue(), npc)
return@on true
}
on(NPCs.ELKOY_5182, NPC, "follow"){ player, _ ->
ElkoyDialogue().travelCutscene(player, if (player.location.y > 3161) mazeVillage else mazeEntrance)
return@on true
}
on(NPCs.COMMANDER_MONTAI_470, NPC, "talk-to"){ player, npc ->
openDialogue(player, CommanderMontaiDialogue(), npc)
return@on true
}
on(NPCs.TRACKER_GNOME_1_481, NPC, "talk-to"){ player, npc ->
openDialogue(player, TrackerGnomeOneDialogue(), npc)
return@on true
}
on(NPCs.TRACKER_GNOME_2_482, NPC, "talk-to"){ player, npc ->
openDialogue(player, TrackerGnomeTwoDialogue(), npc)
return@on true
}
on(NPCs.TRACKER_GNOME_3_483, NPC, "talk-to"){ player, npc ->
openDialogue(player, TrackerGnomeThreeDialogue(), npc)
return@on true
}
on(NPCs.KHAZARD_WARLORD_477, NPC, "talk-to"){ player, npc ->
openDialogue(player, KhazardWarlordDialogue(), npc)
return@on true
}
on(NPCs.REMSAI_472, NPC, "talk-to"){ player, npc ->
openDialogue(player, RemsaiDialogue(), npc)
return@on true
}
on(NPCs.LOCAL_GNOME_484, NPC, "talk-to"){ player, npc ->
openDialogue(player, LocalGnomeDialogue(), npc)
return@on true
}
on(ballista, SCENERY, "fire"){ player, _ ->
openDialogue(player, BallistaDialogue())
return@on true
}
on(looseRailing, SCENERY, "squeeze-through"){ player, _ ->
if(player.location != location(2516,3161,0)) {
squeezeThrough(player)
} else {
player.pulseManager.run(object : Pulse(0) {
var count = 0
override fun pulse(): Boolean {
when (count) {
0 -> ForceMovement.run(player,player.location,player.location.transform(Direction.WEST,1))
2 -> squeezeThrough(player)
3 -> return true
}
count++
return false
}
})
}
return@on true
}
on(crumbledWall, SCENERY, "climb-over"){ player, _ ->
openDialogue(player, ClimbWall())
return@on true
}
on(closedChest, SCENERY, "open"){ player, node ->
SceneryBuilder.replace(node.asScenery(), Scenery(openedChest, node.location, node.asScenery().rotation),10)
val upperGuard: NPC = RegionManager.getNpc(player.location, NPCs.KHAZARD_COMMANDER_478, 6) ?: return@on true
upperGuard.sendChat("Oi. You! Get out of there.")
upperGuard.attack(player)
return@on true
}
on(openedChest, SCENERY, "search"){ player, _ ->
if(!inInventory(player,Items.ORB_OF_PROTECTION_587)){
sendDialogue(player,"You search the chest. Inside you find the gnomes' stolen orb of protection.")
addItemOrDrop(player,Items.ORB_OF_PROTECTION_587)
}
return@on true
}
on(strongholdDoor, SCENERY, "open"){ player, node ->
if(player.location.y >= 3251){
DoorActionHandler.handleAutowalkDoor(player, node as Scenery)
}
return@on true
}
on(NPCs.LIEUTENANT_SCHEPBUR_3817, NPC, "talk-to"){player, node ->
openDialogue(player, LieutenantSchepburDialogue(),node)
return@on true
}
}
}
fun squeezeThrough(player: Player){
val squeezeAnim = Animation.create(3844)
if(player.location.y >= 3161) {
AgilityHandler.forceWalk(
player,
-1,
player.location,
player.location.transform(Direction.SOUTH, 1),
squeezeAnim,
5,
0.0,
null
)
} else {
AgilityHandler.forceWalk(
player,
-1,
player.location,
player.location.transform(Direction.NORTH, 1),
squeezeAnim,
5,
0.0,
null
)
}
}
private class ClimbWall : DialogueFile() {
val climbAnimation = Animation(839)
val wallLoc = Location(2509,3253,0)
override fun handle(componentID: Int, buttonID: Int) {
if(questStage(player!!, TreeGnomeVillage.questName) > 30){
val northSouth = if (player!!.location.y <= wallLoc.y) Direction.NORTH else Direction.SOUTH
when(stage){
0 -> sendDialogue(player!!,"The wall has been reduced to rubble. It should be possible to climb over the remains").also{ stage++ }
1 -> AgilityHandler.forceWalk(player!!, -1, player!!.location, player!!.location.transform(northSouth, 2), climbAnimation, 20, 0.0, null).also {
end()
if(northSouth == Direction.SOUTH) return
val lowerGuard: NPC = RegionManager.getNpc(player!!.location, NPCs.KHAZARD_COMMANDER_478, 6) ?: return
GameWorld.Pulser.submit(object : Pulse(0) {
var count = 0
override fun pulse(): Boolean {
when (count) {
0 -> {
player!!.lock(4)
lowerGuard.sendChat("What? How did you manage to get in here.")
}
2 -> {
player!!.sendChat("I've come for the orb.")
}
3 -> {
lowerGuard.sendChat("I'll never let you take it.")
lowerGuard.attack(player)
player!!.unlock()
return true
}
}
count++
return false
}
})
}
}
}
}
}

View file

@ -0,0 +1,117 @@
package rs09.game.node.entity.npc
import api.isQuestComplete
import api.openDialogue
import api.sendDialogue
import api.teleport
import core.game.node.entity.npc.NPC
import core.game.node.entity.player.Player
import core.game.node.entity.player.link.diary.DiaryType
import core.game.system.task.Pulse
import core.game.world.map.Location
import core.game.world.update.flag.context.Animation
import core.game.world.update.flag.context.Graphics
import org.rs09.consts.NPCs
import rs09.game.content.dialogue.DialogueFile
import rs09.game.content.quest.members.tree.TreeGnomeVillage
import rs09.game.interaction.InteractionListener
import rs09.game.world.GameWorld.Pulser
import rs09.tools.END_DIALOGUE
class GnomeSpiritTreeListener: InteractionListener {
val spiritTrees = intArrayOf(1317,1293,1294)
override fun defineListeners() {
on(spiritTrees, SCENERY, "talk-to"){ player, _ ->
openDialogue(player, GnomeSpiritTreeDialogue(), NPC(NPCs.SPIRIT_TREE_3636))
return@on true
}
on(spiritTrees, SCENERY, "teleport"){ player, _ ->
openDialogue(player, GnomeSpiritTreeTeleportDialogue(), NPC(NPCs.SPIRIT_TREE_3636))
return@on true
}
}
}
class GnomeSpiritTreeTeleportDialogue: DialogueFile() {
private val LOCATIONS = arrayOf(
Location(2542, 3170, 0),
Location(2461, 3444, 0),
Location(2556, 3259, 0),
Location(3184, 3508, 0)
)
private val ANIMATIONS = arrayOf(Animation(7082), Animation(7084))
private val GRAPHICS = arrayOf(Graphics(1228), Graphics(1229))
fun hasQuestCompleted(player: Player): Boolean {
if (!isQuestComplete(player, TreeGnomeVillage.questName)) {
sendDialogue(player, "The tree doesn't feel like talking.")
stage = END_DIALOGUE
return false
}
return true
}
private fun sendTeleport(player: Player, location: Location) {
end()
Pulser.submit(object : Pulse(1, player) {
var count = 0
override fun pulse(): Boolean {
when (count) {
0 -> {
player.animate(ANIMATIONS[0])
player.graphics(GRAPHICS[0])
}
3 -> { teleport(player,location) }
5 -> {
player.animate(ANIMATIONS[1])
player.graphics(GRAPHICS[1])
player.face(null)
if (player.location.withinDistance(Location.create(3184, 3508, 0))) {
player.achievementDiaryManager.finishTask(player, DiaryType.VARROCK, 1, 5)
}
return true
}
}
count++
return false
}
})
}
override fun handle(componentID: Int, buttonID: Int) {
if(!GnomeSpiritTreeTeleportDialogue().hasQuestCompleted(player!!)) {
stage = END_DIALOGUE
return
}
when (stage) {
0 -> interpreter!!.sendOptions(
"Where would you like to go?",
"Tree Gnome Village",
"Tree Gnome Stronghold",
"Battlefield of Khazard",
"Grand Exchange"
).also { stage++ }
1 -> when (buttonID) {
1 -> sendTeleport(player!!, LOCATIONS[0])
2 -> sendTeleport(player!!, LOCATIONS[1])
3 -> sendTeleport(player!!, LOCATIONS[2])
4 -> sendTeleport(player!!, LOCATIONS[3])
}
}
}
}
class GnomeSpiritTreeDialogue: DialogueFile() {
override fun handle(componentID: Int, buttonID: Int) {
if(!GnomeSpiritTreeTeleportDialogue().hasQuestCompleted(player!!)) {
stage = END_DIALOGUE
return
}
when (stage) {
0 -> npcl("If you are a friend of the gnome people, you are a friend of mine, Do you wish to travel?").also{ stage++ }
1 -> { openDialogue(player!!, GnomeSpiritTreeTeleportDialogue()) }
}
}
}