Converted some Al-Kharidian NPCs to listeners:

Ali the Leaflet Dropper
A'abla
Fadli
Surgeon General Tafani
Sabreen
Jaraah
This commit is contained in:
bushtail
2022-06-16 10:29:02 +00:00
committed by Ryan
parent 0e74cf0495
commit c5d0173282
18 changed files with 541 additions and 1054 deletions
@@ -0,0 +1,49 @@
package rs09.game.node.entity.npc.city.alkharid
import core.game.content.dialogue.DialoguePlugin
import core.game.content.dialogue.FacialExpression
import core.game.node.entity.npc.NPC
import core.game.node.entity.player.Player
import core.plugin.Initializable
import org.rs09.consts.NPCs
import rs09.game.content.dialogue.DialogueFile
import rs09.game.content.dialogue.Topic
import rs09.tools.END_DIALOGUE
/**
* @author bushtail
*/
@Initializable
class AablaDialogue(player: Player? = null) : DialoguePlugin(player) {
override fun newInstance(player: Player?): DialoguePlugin {
return AablaDialogue(player)
}
override fun open(vararg args: Any?): Boolean {
npc = args[0] as NPC
player(FacialExpression.FRIENDLY, "Hi!").also { stage = 0 }
return true
}
override fun handle(interfaceId: Int, buttonId: Int): Boolean {
when(stage) {
0 -> showTopics(
Topic("Can you heal me?", AlKharidHealDialogue(true)),
Topic("Do you see a lot of injured fighters?", 101),
Topic("Do you come here often?", 201)
)
101 -> npcl(FacialExpression.FRIENDLY, "I work here, so yes!").also { stage = END_DIALOGUE }
201 -> npcl(FacialExpression.HALF_THINKING, "Yes I do. Thankfully we can cope with almost anything. Jaraah really is a wonderful surgeon, his methods are a little unorthodox but he gets the job done.").also { stage++ }
202 -> npcl(FacialExpression.HALF_GUILTY, "I shouldn't tell you this but his nickname is 'The Butcher'.").also { stage++ }
203 -> player(FacialExpression.HALF_WORRIED, "That's reassuring.").also { stage = END_DIALOGUE }
}
return true
}
override fun getIds(): IntArray {
return intArrayOf(NPCs.AABLA_959)
}
}
@@ -0,0 +1,53 @@
package rs09.game.node.entity.npc.city.alkharid
import api.*
import core.game.content.dialogue.FacialExpression
import core.game.node.entity.npc.NPC
import core.game.node.entity.skill.Skills
import org.rs09.consts.Animations
import org.rs09.consts.NPCs
import rs09.game.content.dialogue.DialogueFile
import rs09.game.interaction.InteractionListener
import rs09.tools.END_DIALOGUE
/**
* @author bushtail
*/
class AlKharidHealListener : InteractionListener {
override fun defineListeners() {
on(getIds(), NPC, "heal") { player, node ->
openDialogue(player, AlKharidHealDialogue(false), node.asNpc())
return@on true
}
}
fun getIds() : IntArray {
return intArrayOf(
NPCs.AABLA_959,
NPCs.SABREEN_960,
NPCs.SURGEON_GENERAL_TAFANI_961,
NPCs.JARAAH_962
)
}
}
class AlKharidHealDialogue(val skipFirst: Boolean) : DialogueFile() {
override fun handle(componentID: Int, buttonID: Int) {
if (stage == 0 && skipFirst) stage++
when(stage) {
0 -> player(FacialExpression.ASKING, "Can you heal me?").also { stage++ }
1 -> npcl(FacialExpression.FRIENDLY, "Of course!").also { stage++ }
2 -> {
animate(npc!!, Animations.HUMAN_PICKPOCKETING_881)
if(player!!.skills.lifepoints < getStatLevel(player!!, Skills.HITPOINTS)) {
player!!.skills.heal(21)
npcl(FacialExpression.FRIENDLY, "There you go!")
} else {
npcl(FacialExpression.FRIENDLY, "You look healthy to me!")
}
stage = END_DIALOGUE
}
}
}
}
@@ -0,0 +1,55 @@
package rs09.game.node.entity.npc.city.alkharid
import core.game.content.dialogue.DialoguePlugin
import core.game.content.dialogue.FacialExpression
import core.game.node.entity.npc.NPC
import core.game.node.entity.player.Player
import core.plugin.Initializable
import org.rs09.consts.NPCs
import rs09.tools.END_DIALOGUE
/**
* @author bushtail
* "Henceforth, you shall be called... Craig."
*/
@Initializable
class AlKharidShopKeeperDialogue(player: Player? = null) : DialoguePlugin() {
override fun newInstance(player: Player?): DialoguePlugin {
return AlKharidShopKeeperDialogue(player)
}
override fun open(vararg args: Any?): Boolean {
npc = args[0] as NPC
npcl(FacialExpression.HALF_ASKING, "Can I help you at all?")
stage = 100
return true
}
override fun handle(interfaceId: Int, buttonId: Int): Boolean {
when(stage) {
100 -> options(
"Yes, please. What are you selling?",
"How should I use your shop?",
"No, thanks."
).also { stage++ }
101 -> when(buttonId) {
1 -> {
stage = END_DIALOGUE
npc.openShop(player)
}
2 -> player(FacialExpression.ASKING, "How should I use your shop?").also { stage = 201 }
3 -> player(FacialExpression.NEUTRAL, "No, thanks.").also { stage = END_DIALOGUE }
}
201 -> npcl(FacialExpression.FRIENDLY, "I'm glad you ask! You can buy as many of the items stocked as you wish. You can also sell most items to the shop.").also { stage = END_DIALOGUE }
}
return true
}
override fun getIds(): IntArray {
return intArrayOf(
NPCs.SHOPKEEPER_524,
NPCs.SHOP_ASSISTANT_525
)
}
}
@@ -0,0 +1,83 @@
package rs09.game.node.entity.npc.city.alkharid
import api.addItem
import core.game.content.dialogue.DialoguePlugin
import core.game.content.dialogue.FacialExpression
import core.game.node.entity.npc.NPC
import core.game.node.entity.player.Player
import core.plugin.Initializable
import org.rs09.consts.Items
import org.rs09.consts.NPCs
import rs09.tools.END_DIALOGUE
/**
* @author bushtail
* Converts AliTheLeafletDropper.java with a Kotlin implementation
*/
@Initializable
class AliTheLeafletDropperDialogue(player: Player? = null) : DialoguePlugin(player) {
override fun newInstance(player: Player?): DialoguePlugin {
return AliTheLeafletDropperDialogue(player)
}
override fun open(vararg args: Any?): Boolean {
npc = args[0] as NPC
npcl(FacialExpression.CHILD_NORMAL, "I don't have the time to talk right now! Ali Morrisane is paying me to hand out these flyers.")
stage = 100
return true
}
override fun handle(interfaceId: Int, buttonId: Int): Boolean {
when(stage) {
100 -> options(
"Who is Ali Morissane?",
"What are the flyers for?",
"What is there to do round here, boy?"
).also { stage++ }
101 -> when(buttonId) {
1 -> {
player(FacialExpression.ASKING, "Who is Ali Morissane?").also{ stage = 201 }
}
2 -> {
player(FacialExpression.ASKING, "What are the flyers for?").also { stage = 301 }
}
3 -> {
player(FacialExpression.ASKING, "What is there to do round here, boy?").also { stage = 401 }
}
}
201 -> npcl(FacialExpression.CHILD_FRIENDLY, "Ali Morrisane is the greatest merchant in the east!").also { stage++ }
202 -> player(FacialExpression.HALF_ASKING, "Were you paid to say that?").also { stage++ }
203 -> npcl(FacialExpression.CHILD_LOUDLY_LAUGHING, "Of course I was! You can find him on the north edge of town.").also { stage = END_DIALOGUE }
301 -> npcl(FacialExpression.CHILD_THINKING, "Well, Ali Morrisane isn't too popular with the other traders in Al Kharid, mainly because he's from Pollnivneach and they feel he has no business trading in their town.").also { stage++ }
302 -> npcl(FacialExpression.CHILD_FRIENDLY, "I think they're just sour because he's better at making money than them.").also { stage++ }
303 -> npcl(FacialExpression.CHILD_FRIENDLY, "The flyer advertises the different shops you can find in Al Kharid.").also { stage++ }
304 -> npcl(FacialExpression.CHILD_THINKING, "It also entitles you to money off your next purchase in any of the shops listed on it. It's Ali's way of getting on the good side of the traders.").also { stage++ }
305 -> player(FacialExpression.ASKING, "Which shops?").also {
if(player.inventory.containItems(Items.AL_KHARID_FLYER_7922)) {
npcl(FacialExpression.CHILD_SUSPICIOUS, "Are you trying to be funny or has age turned your brain to mush? Look at the flyer you already have!").also { stage = END_DIALOGUE }
} else {
if(addItem(player, Items.AL_KHARID_FLYER_7922)) {
npcl(FacialExpression.CHILD_FRIENDLY, "Here! Take one and let me get back to work.").also { stage = END_DIALOGUE }
} else {
end()
}
}
}
401 -> npcl(FacialExpression.CHILD_NORMAL, "I'm very busy, so listen carefully! I shall say this only once.").also { stage++ }
402 -> npcl(FacialExpression.CHILD_THINKING, "Apart from a busy and wonderous market place in Al Kharid to the south, there is the Duel Arena to the south-east where you can challenge other players to a fight.").also { stage++ }
403 -> npcl(FacialExpression.CHILD_NORMAL, "If you're here to make money, there is a mine to the south.").also { stage++ }
404 -> npcl(FacialExpression.CHILD_SUSPICIOUS, "Watch out for scorpions though, they'll take a pop at you if you go too near them. To avoid them just follow the western fence as you travel south.").also { stage++ }
405 -> npcl(FacialExpression.CHILD_FRIENDLY, "If you're in the mood for a little rest and relaxation, there are a couple of nice fishing spots south of the town.").also { stage++ }
406 -> player(FacialExpression.FRIENDLY, "Thanks for the help!").also { stage = END_DIALOGUE }
}
return true
}
override fun getIds(): IntArray {
return intArrayOf(NPCs.ALI_THE_LEAFLET_DROPPER_3680)
}
}
@@ -0,0 +1,45 @@
package rs09.game.node.entity.npc.city.alkharid
import api.addItem
import api.openDialogue
import core.game.content.dialogue.FacialExpression
import core.game.node.entity.npc.NPC
import org.rs09.consts.Items
import org.rs09.consts.NPCs
import rs09.game.content.dialogue.DialogueFile
import rs09.game.interaction.InteractionListener
import rs09.tools.END_DIALOGUE
/**
* @author bushtail
*/
class AliTheLeafletDropperListener : InteractionListener {
override fun defineListeners() {
on(NPCs.ALI_THE_LEAFLET_DROPPER_3680, NPC, "Take-flyer") { player, node ->
if(player.inventory.containItems(Items.AL_KHARID_FLYER_7922)) {
openDialogue(player, DropperDialogue(2), node as NPC)
} else {
if(addItem(player, Items.AL_KHARID_FLYER_7922)) {
openDialogue(player, DropperDialogue(1), node as NPC)
} else {
return@on false
}
}
return@on true
}
}
}
class DropperDialogue(val it : Int) : DialogueFile() {
override fun handle(componentID: Int, buttonID: Int) {
when(it) {
1 -> when(stage) {
0 -> npcl(FacialExpression.CHILD_NORMAL, "Here! Take one and let me get back to work.").also { stage++ }
1 -> npcl(FacialExpression.CHILD_THINKING, "I still have hundreds of these flyers to hand out. I wonder if Ali would notice if I quietly dumped them somewhere?").also { stage = END_DIALOGUE }
}
2 -> npcl(FacialExpression.CHILD_SUSPICIOUS, "Are you trying to be funny or has age turned your brain to mush? You already have a flyer!").also { stage = END_DIALOGUE }
}
}
}
@@ -0,0 +1,71 @@
package rs09.game.node.entity.npc.city.alkharid
import core.game.content.dialogue.DialoguePlugin
import core.game.content.dialogue.FacialExpression
import core.game.node.entity.npc.NPC
import core.game.node.entity.player.Player
import core.plugin.Initializable
import org.rs09.consts.NPCs
import rs09.game.content.dialogue.Topic
import rs09.game.interaction.InteractionListener
import rs09.tools.END_DIALOGUE
/**
* @author bushtail
*/
@Initializable
class FadliDialogue(player: Player? = null) : DialoguePlugin(player) {
override fun newInstance(player: Player?): DialoguePlugin {
return FadliDialogue(player)
}
override fun open(vararg args: Any?): Boolean {
npc = args[0] as NPC
player(FacialExpression.FRIENDLY, "Hi!").also { stage = 0 }
return true
}
override fun handle(interfaceId: Int, buttonId: Int): Boolean {
when(stage) {
0 -> npcl(FacialExpression.HALF_ASKING, "What?").also { stage++ }
1 -> showTopics(
Topic("What do you do?", 101),
Topic("What is this place?", 201),
Topic(FacialExpression.FRIENDLY,"I'd like to store some items, please.", 301),
Topic("Do you watch any matches?", 401)
)
101 -> npcl(FacialExpression.FRIENDLY, "You can store your stuff here if you want. You can dump anything you don't want to carry whilst your fighting duels and then pick it up again on the way out.").also { stage++ }
102 -> npcl(FacialExpression.SAD, "To be honest I'm wasted here.").also { stage++ }
103 -> npcl(FacialExpression.EVIL_LAUGH, "I should be winning duels in an arena! I'm the best warrior in Al Kharid!").also { stage++ }
104 -> player(FacialExpression.HALF_WORRIED, "Easy, tiger!").also { stage = END_DIALOGUE }
201 -> npcl(FacialExpression.LAUGH, "Isn't it obvious?").also { stage++ }
202 -> npcl(FacialExpression.ANNOYED, "This is the Duel Arena...duh!").also { stage = END_DIALOGUE }
301 -> npcl(FacialExpression.FRIENDLY, "Sure.").also {
end()
player.bank.open()
}
401 -> npcl(FacialExpression.LAUGH, "Most aren't any good so I throw rotten fruit at them!").also { stage = END_DIALOGUE }
}
return true
}
override fun getIds(): IntArray {
return intArrayOf(NPCs.FADLI_958)
}
}
class FadliListener : InteractionListener {
override fun defineListeners() {
on(NPCs.FADLI_958, NPC, "buy") { player, node ->
if(node.asNpc().openShop(player)) {
return@on true
}
return@on false
}
}
}
@@ -0,0 +1,67 @@
package rs09.game.node.entity.npc.city.alkharid
import api.animate
import api.getDynLevel
import api.getStatLevel
import core.game.content.dialogue.DialoguePlugin
import core.game.content.dialogue.FacialExpression
import core.game.node.entity.npc.NPC
import core.game.node.entity.player.Player
import core.game.node.entity.skill.Skills
import core.plugin.Initializable
import org.rs09.consts.Animations
import org.rs09.consts.NPCs
import rs09.game.content.dialogue.Topic
import rs09.tools.END_DIALOGUE
/**
* @author bushtail
*/
@Initializable
class JaraahDialogue(player: Player? = null) : DialoguePlugin(player) {
override fun newInstance(player: Player?): DialoguePlugin {
return JaraahDialogue(player)
}
override fun open(vararg args: Any?): Boolean {
npc = args[0] as NPC
player(FacialExpression.FRIENDLY, "Hi!").also { stage = 0 }
return true
}
override fun handle(interfaceId: Int, buttonId: Int): Boolean {
when(stage) {
0 -> npcl(FacialExpression.ANNOYED, "What? Can't you see I'm busy?!").also { stage++ }
1 -> showTopics(
Topic("Can you heal me?", 101),
Topic("You must see some gruesome things?", 201),
Topic("Why do they call you 'The Butcher'?", 301)
)
// Jaraah has to be special and have different dialogue for the heal listener so I am repeating it here.
101 -> {
animate(npc!!, Animations.HUMAN_PICKPOCKETING_881)
if(player!!.skills.lifepoints < getStatLevel(player!!, Skills.HITPOINTS)) {
player!!.skills.heal(21)
npcl(FacialExpression.FRIENDLY, "There you go!")
} else {
npcl(FacialExpression.FRIENDLY, "Okay, this will hurt you more than it will me.")
}
stage = END_DIALOGUE
}
201 -> npcl(FacialExpression.FRIENDLY, "It's a gruesome business and with the tools they give me it gets mroe gruesome before it gets better!").also { stage = END_DIALOGUE }
301 -> npcl(FacialExpression.HALF_THINKING, "'The Butcher'?").also { stage++ }
302 -> npcl(FacialExpression.LAUGH, "Ha!").also { stage++ }
303 -> npcl(FacialExpression.HALF_ASKING, "Would you like me to demonstrate?").also { stage++ }
304 -> player(FacialExpression.AFRAID, "Er...I'll give it a miss, thanks.").also { stage = END_DIALOGUE }
}
return true
}
override fun getIds(): IntArray {
return intArrayOf(NPCs.JARAAH_962)
}
}
@@ -0,0 +1,49 @@
package rs09.game.node.entity.npc.city.alkharid
import core.game.content.dialogue.DialoguePlugin
import core.game.content.dialogue.FacialExpression
import core.game.node.entity.npc.NPC
import core.game.node.entity.player.Player
import core.plugin.Initializable
import org.rs09.consts.NPCs
import rs09.game.content.dialogue.DialogueFile
import rs09.game.content.dialogue.Topic
import rs09.tools.END_DIALOGUE
/**
* @author bushtail
*/
@Initializable
class SabreenDialogue(player: Player? = null) : DialoguePlugin(player) {
override fun newInstance(player: Player?): DialoguePlugin {
return SabreenDialogue(player)
}
override fun open(vararg args: Any?): Boolean {
npc = args[0] as NPC
player(FacialExpression.FRIENDLY, "Hi!").also { stage = 0 }
return true
}
override fun handle(interfaceId: Int, buttonId: Int): Boolean {
when(stage) {
0 -> showTopics(
Topic("Can you heal me?", AlKharidHealDialogue(true)),
Topic("Do you see a lot of injured fighters?", 101),
Topic("Do you come here often?", 201)
)
101 -> npcl(FacialExpression.FRIENDLY, "I work here, so yes!").also { stage = END_DIALOGUE }
201 -> npcl(FacialExpression.HALF_THINKING, "Yes I do. Thankfully we can cope with almost anything. Jaraah really is a wonderful surgeon, his methods are a little unorthodox but he gets the job done.").also { stage++ }
202 -> npcl(FacialExpression.HALF_GUILTY, "I shouldn't tell you this but his nickname is 'The Butcher'.").also { stage++ }
203 -> player(FacialExpression.HALF_WORRIED, "That's reassuring.").also { stage = END_DIALOGUE }
}
return true
}
override fun getIds(): IntArray {
return intArrayOf(NPCs.SABREEN_960)
}
}
@@ -0,0 +1,69 @@
package rs09.game.node.entity.npc.city.alkharid
import core.game.content.dialogue.DialoguePlugin
import api.*
import core.game.content.dialogue.FacialExpression
import core.game.content.global.Skillcape
import core.game.node.entity.npc.NPC
import core.game.node.entity.player.Player
import core.game.node.entity.skill.Skills
import core.plugin.Initializable
import org.rs09.consts.NPCs
import rs09.game.content.dialogue.*
import rs09.tools.END_DIALOGUE
/**
* @author bushtail
*/
@Initializable
class SurgeonGeneralTafaniDialogue(player: Player? = null) : DialoguePlugin(player) {
override fun newInstance(player: Player?): DialoguePlugin {
return SurgeonGeneralTafaniDialogue(player)
}
override fun open(vararg args: Any?): Boolean {
npc = args[0] as NPC
npcl(FacialExpression.FRIENDLY, "Hi. How can I help?").also { stage = 100 }
return true
}
override fun handle(interfaceId: Int, buttonId: Int): Boolean {
when(stage) {
100 -> showTopics(
Topic("Can you heal me?", AlKharidHealDialogue(true)),
Topic("Do you see a lot of injured fighters?", 201),
Topic("Do you come here often?", 301),
IfTopic("Can I buy a Skillcape of Hitpoints from you?", 401, hasLevelStat(player, Skills.HITPOINTS, 99)),
IfTopic("Where can I get a cape like yours?", 501, !hasLevelStat(player, Skills.HITPOINTS, 99))
)
201 -> npcl(FacialExpression.HALF_THINKING, "Yes I do. Thankfully we can cope with almost anything. Jaraah really is a wonderful surgeon, his methods are a little unorthodox but he gets the job done.").also { stage++ }
202 -> npcl(FacialExpression.HALF_GUILTY, "I shouldn't tell you this but his nickname is 'The Butcher'.").also { stage++ }
203 -> player(FacialExpression.HALF_WORRIED, "That's reassuring.").also { stage = END_DIALOGUE }
301 -> npcl(FacialExpression.LAUGH, "I work here, so yes!").also { stage = END_DIALOGUE }
401 -> npcl(FacialExpression.FRIENDLY, "Why, certainly my friend. However, owning such an item makes you part of an elite group and that privilege will cost you 99000 coins.").also { stage++ }
402 -> showTopics(
Topic(FacialExpression.HALF_GUILTY, "Sorry, that's much too pricey.", 411),
Topic(FacialExpression.HAPPY, "Sure, that's not too expensive for such a magnificent cape.", 421)
)
411 -> npcl(FacialExpression.NEUTRAL, "I'm sorry you feel that way. Still, if you change your mind...").also { stage = END_DIALOGUE }
421 -> if(Skillcape.purchase(player, Skills.HITPOINTS)) {
npcl(FacialExpression.FRIENDLY, "There you go! I hope you enjoy it.").also { stage = END_DIALOGUE }
} else {
npcl(FacialExpression.HALF_GUILTY, "Sorry, you can't buy that right now.").also { stage = END_DIALOGUE }
}
501 -> npcl(FacialExpression.HALF_THINKING, "Well, these capes are only available for people who have achieved a Hitpoint level of 99. You should go and train some more and come back to me when your Hitpoints are higher.").also { stage = END_DIALOGUE }
}
return true
}
override fun getIds(): IntArray {
return intArrayOf(NPCs.SURGEON_GENERAL_TAFANI_961)
}
}