Huge refactor improving the handling of players being given items, or situations where items are exchanged

This commit is contained in:
Player Name 2025-04-06 08:17:21 +00:00 committed by Ryan
parent 3d7f1689f3
commit 300b714048
49 changed files with 236 additions and 472 deletions

View file

@ -162,9 +162,10 @@ class FurClothingInterface : ComponentPlugin(){
return
}
removeItem(player, requiredFur, Container.INVENTORY)
removeItem(player, coins, Container.INVENTORY)
addItem(player, clothing.product.id, amount)
if (removeItem(player, requiredFur, Container.INVENTORY) &&
removeItem(player, coins, Container.INVENTORY)) {
addItem(player, clothing.product.id, amount)
}
}
override fun newInstance(arg: Any?): Plugin<Any> {

View file

@ -25,8 +25,7 @@ class EctophialListener : InteractionListener {
delayEntity(player, fillAnimation.duration)
animate(player, fillAnimation)
playAudio(player, Sounds.FILL_ECTOPLASM_1132)
if (removeItem(player, Items.ECTOPHIAL_4252)) {
addItem(player, Items.ECTOPHIAL_4251)
if (removeItem(player, Items.ECTOPHIAL_4252) && addItem(player, Items.ECTOPHIAL_4251)) {
sendMessage(player, "You refill the ectophial from the Ectofuntus.")
}
}

View file

@ -70,8 +70,7 @@ class EnchantJewelleryTabListener : InteractionListener {
for (item in player.inventory.toArray()) {
if (item == null) continue
val product = items[item.id] ?: continue
if (removeItem(player, node.id) && (removeItem(player, item.id))) {
addItem(player, product)
if (removeItem(player, node.id) && (removeItem(player, item.id)) && addItem(player, product)) {
playAudio(player, Sounds.POH_TABLET_BREAK_979)
animate(player, 4069, true)
break

View file

@ -24,9 +24,11 @@ class CrystalKeyCreateListener : InteractionListener {
return@onUseWith false
}
addItem(player, Items.CRYSTAL_KEY_989)
sendMessage(player, "You join the loop half of a key and the tooth half of a key to make a crystal key.")
if (!addItem(player, Items.CRYSTAL_KEY_989)) {
return@onUseWith false
}
sendMessage(player, "You join the loop half of a key and the tooth half of a key to make a crystal key.")
return@onUseWith true
}
}

View file

@ -15,10 +15,11 @@ class OilFishingRodListener : InteractionListener {
override fun pulse(): Boolean {
when (counter++) {
1 -> {
removeItem(player, used.asItem()) && removeItem(player, with.asItem())
addItem(player, Items.VIAL_229)
addItem(player, Items.OILY_FISHING_ROD_1585)
sendMessage(player, "You rub the oil into the fishing rod.")
if (removeItem(player, used.asItem()) && removeItem(player, with.asItem()) &&
addItem(player, Items.VIAL_229) &&
addItem(player, Items.OILY_FISHING_ROD_1585)) {
sendMessage(player, "You rub the oil into the fishing rod.")
}
}
}
return false
@ -35,9 +36,10 @@ class OilFishingRodListener : InteractionListener {
when (counter++) {
0 -> player.animator.animate(Animation(364))
3 -> {
removeItem(player, Items.THIN_SNAIL_3363)
removeItem(player, Items.SAMPLE_BOTTLE_3377)
addItem(player, Items.BLAMISH_SNAIL_SLIME_1581)
if (removeItem(player, Items.THIN_SNAIL_3363) &&
removeItem(player, Items.SAMPLE_BOTTLE_3377)) {
addItem(player, Items.BLAMISH_SNAIL_SLIME_1581)
}
}
}
return false

View file

@ -14,11 +14,10 @@ class WatermelonOnSack : InteractionListener {
override fun defineListeners() {
onUseWith(IntType.ITEM, SACK, WATERMELON){ player, used, _ ->
if(getStatLevel(player, Skills.FARMING) >= 23){
removeItem(player,SACK, Container.INVENTORY)
removeItem(player,WATERMELON,Container.INVENTORY)
addItem(player, Items.SCARECROW_6059)
rewardXP(player, Skills.FARMING, 25.0)
sendMessage(player, "You stab the watermelon on top of the spear, finishing your scarecrow")
if (removeItem(player,SACK, Container.INVENTORY) && removeItem(player,WATERMELON,Container.INVENTORY) && addItem(player, Items.SCARECROW_6059)) {
rewardXP(player, Skills.FARMING, 25.0)
sendMessage(player, "You stab the watermelon on top of the spear, finishing your scarecrow")
}
}else{
sendMessage(player, "Your Farming level is not high enough to do this")
}

View file

@ -35,8 +35,9 @@ class SandSourceListener : InteractionListener {
animate(player, ANIMATION)
}
sendMessage(player, "You fill the bucket with sand.")
addItem(player, Items.BUCKET_OF_SAND_1783)
if (addItem(player, Items.BUCKET_OF_SAND_1783)) {
sendMessage(player, "You fill the bucket with sand.")
}
}
animationTrigger++

View file

@ -61,8 +61,9 @@ class SapCollectListener : InteractionListener {
override fun pulse(): Boolean {
if (removeItem(player, Items.BUCKET_1925)) {
animate(player, ANIMATION)
sendMessage(player, "You cut the tree and allow its sap to drip down into your bucket.")
addItem(player, Items.BUCKET_OF_SAP_4687)
if (addItem(player, Items.BUCKET_OF_SAP_4687)) {
sendMessage(player, "You cut the tree and allow its sap to drip down into your bucket.")
}
return true
}
return false

View file

@ -82,9 +82,11 @@ class SpiritShieldBlessListener : InteractionListener {
return@onUseWith false
}
addItem(player, Items.BLESSED_SPIRIT_SHIELD_13736)
sendMessage(player, "You successfully bless the shield using the holy elixir.")
if (!addItem(player, Items.BLESSED_SPIRIT_SHIELD_13736)) {
return@onUseWith false
}
sendMessage(player, "You successfully bless the shield using the holy elixir.")
return@onUseWith true
}

View file

@ -105,8 +105,10 @@ class SheepBehavior : NPCBehavior(*sheepIds), InteractionListener {
sheep.locks.lockMovement(2)
sheep.transform(NPCs.SHEEP_5153)
playAudio(player, Sounds.SHEAR_SHEEP_761)
if (!addItem(player, Items.WOOL_1737)) { // 5160
return@on false
}
sendMessage(player, "You get some wool.")
addItem(player, Items.WOOL_1737) // 5160
GameWorld.Pulser.submit(object : Pulse(80, sheep) {
override fun pulse(): Boolean {
sheep.reTransform()

View file

@ -85,13 +85,15 @@ class MillingListener : InteractionListener {
if (removeItem(player, EMPTY_POT)) {
if (getAttribute(player, "milling:sweetcorn", 0) > 0) {
setAttribute(player, "/save:milling:sweetcorn", (getAttribute(player, "milling:sweetcorn", 0) - 1))
addItem(player, POT_OF_CORNFLOUR)
sendMessage(player, if (player.getAttribute("milling:sweetcorn", 0) > 0) "You fill a pot with cornflour from the bin." else "You fill a pot with the last of the cornflour in the bin.")
if (addItem(player, POT_OF_CORNFLOUR)) {
sendMessage(player, if (player.getAttribute("milling:sweetcorn", 0) > 0) "You fill a pot with cornflour from the bin." else "You fill a pot with the last of the cornflour in the bin.")
}
}
else if (getAttribute(player, "milling:grain", 0) > 0) {
setAttribute(player, "/save:milling:grain", (getAttribute(player, "milling:grain", 0) - 1))
addItem(player, POT_OF_FLOUR)
sendMessage(player, if (player.getAttribute("milling:grain", 0) > 0) "You fill a pot with flour from the bin." else "You fill a pot with the last of the flour in the bin.")
if (addItem(player, POT_OF_FLOUR)) {
sendMessage(player, if (player.getAttribute("milling:grain", 0) > 0) "You fill a pot with flour from the bin." else "You fill a pot with the last of the flour in the bin.")
}
}
if (getAttribute(player, "milling:sweetcorn", 0) + getAttribute(player, "milling:grain", 0) <= 0) {
setVarp(player, VARP, 0, true)

View file

@ -31,10 +31,8 @@ class SilverCraftingPulse(
animate(player, Animations.HUMAN_FURNACE_SMELTING_3243)
playAudio(player, Sounds.FURNACE_2725)
if (removeItem(player, Items.SILVER_BAR_2355, Container.INVENTORY)) {
addItem(player, product.producedItemId, product.amountProduced)
if (removeItem(player, Items.SILVER_BAR_2355, Container.INVENTORY) && addItem(player, product.producedItemId, product.amountProduced)) {
rewardXP(player, Skills.CRAFTING, product.xpReward)
player.dispatch(
ResourceProducedEvent(
product.producedItemId,

View file

@ -35,7 +35,7 @@ object PatchRaker {
} else {
patch.getPatchFor(player).currentGrowthStage++
patch.getPatchFor(player).setCurrentState(++patchStage)
addItem(player, Items.WEEDS_6055)
addItem(player, Items.WEEDS_6055) //authentically destroys weeds if inventory was full
rewardXP(player, Skills.FARMING, 4.0)
}
if (patchStage >= 3) {

View file

@ -127,10 +127,10 @@ class FishingPulse(player: Player?, npc: NPC, private val option: FishingOption?
SkillingPets.checkPetDrop(player, SkillingPets.HERON)
val item = fish!!
if (isActive(SkillcapePerks.GREAT_AIM, player) && RandomFunction.random(100) <= 5) {
addItem(player, item.id)
addItemOrDrop(player, item.id)
player.sendMessage(colorize("%RYour expert aim catches you a second fish."))
}
addItem(player, item.id)
addItemOrDrop(player, item.id)
var fishCaught = player.getAttribute(STATS_BASE + ":" + STATS_FISH, 0)
player.setAttribute("/save:$STATS_BASE:$STATS_FISH", ++fishCaught)
player.skills.addExperience(Skills.FISHING, fish!!.experience, true)

View file

@ -325,7 +325,10 @@ class ModernListeners : SpellListener("modern"){
}
visualizeSpell(player, CHARGE_ORB_ANIM, spell.graphics, spell.sound)
removeRunes(player)
addItem(player, spell.chargedOrb)
val success = addItem(player, spell.chargedOrb)
if (!success) {
return@queueScript stopExecuting(player)
}
addXP(player, spell.experience)
setDelay(player, 3)
crafted++

View file

@ -66,8 +66,9 @@ class IncubatorHandler : InteractionListener {
val product = egg.product
val name = product.name.lowercase()
sendMessage(player, "You take your $name out of the incubator.")
addItem(player, product.id)
if (addItem(player, product.id)) {
sendMessage(player, "You take your $name out of the incubator.")
}
return true
}
}

View file

@ -1,9 +1,6 @@
package content.minigame.barbassault
import core.api.Container
import core.api.addItem
import core.api.inInventory
import core.api.removeItem
import core.api.*
import core.game.dialogue.DialoguePlugin
import core.game.dialogue.FacialExpression
import core.game.node.entity.player.Player
@ -46,7 +43,7 @@ class CaptainCainDialogue(player: Player? = null) : DialoguePlugin(player) {
}
10 -> npcl(FacialExpression.FRIENDLY, "Alright, then, that'll be %,d gold please.".format(TORSO_PRICE)).also { stage++ }
11 -> options("Here you go!","Nevermind.").also { stage++ }
11 -> options("Here you go!","Never mind.").also { stage++ }
12 -> when(buttonId){
1 -> if(inInventory(player, 995, TORSO_PRICE))
playerl(FacialExpression.FRIENDLY, "Here you go!").also { stage = 20 }
@ -57,9 +54,13 @@ class CaptainCainDialogue(player: Player? = null) : DialoguePlugin(player) {
}
20 -> {
npcl(FacialExpression.FRIENDLY, "Thank you much, kind sir. And here's your torso.")
if(removeItem(player, Item(995, TORSO_PRICE), Container.INVENTORY)) {
addItem(player, Items.FIGHTER_TORSO_10551, 1)
if (hasSpaceFor(player, Item(Items.FIGHTER_TORSO_10551)) || amountInInventory(player, Items.COINS_995) == TORSO_PRICE) {
npcl(FacialExpression.FRIENDLY, "Thank you much, kind sir. And here's your torso.")
if (removeItem(player, Item(Items.COINS_995, TORSO_PRICE), Container.INVENTORY)) {
addItem(player, Items.FIGHTER_TORSO_10551, 1)
}
} else {
npcl(FacialExpression.FRIENDLY, "Sorry, you don't have space for it! Give my regards to Player Name - he made me check this before I take your cash.")
}
stage = END_DIALOGUE
}

View file

@ -41,7 +41,7 @@ class VelrakDialogue(player: Player? = null) : DialoguePlugin(player) {
2 -> playerl(FacialExpression.NEUTRAL, "No, it's too dangerous for me too.").also { stage = 15 }
}
14 -> sendItemDialogue(player, Items.DUSTY_KEY_1590, "Velrak reaches somewhere mysterious and passes you a key.").also { addItem(player, Items.DUSTY_KEY_1590, 1); stage = END_DIALOGUE }
14 -> sendItemDialogue(player, Items.DUSTY_KEY_1590, "Velrak reaches somewhere mysterious and passes you a key.").also { addItemOrDrop(player, Items.DUSTY_KEY_1590, 1); stage = END_DIALOGUE }
15 -> npcl(FacialExpression.FRIENDLY, "I don't blame you!").also { stage = END_DIALOGUE }

View file

@ -14,8 +14,8 @@ class DarklightListener : InteractionListener {
if (!hasRequirement(player, Quests.SHADOW_OF_THE_STORM) || (!player.inventory.contains(Items.BLACK_MUSHROOM_INK_4622, 1) && (!player.inventory.contains(Items.SILVERLIGHT_2402, 1))))
return@onUseWith false
if (removeItem(player, used.id) && removeItem(player, with.id))
addItem(player, Items.DARKLIGHT_6746)
return@onUseWith true
return@onUseWith addItem(player, Items.DARKLIGHT_6746)
return@onUseWith false
}
}
}

View file

@ -9,11 +9,12 @@ import core.plugin.Initializable
import core.game.dialogue.DialoguePlugin
import core.game.dialogue.FacialExpression
import content.data.Quests
import org.rs09.consts.Items
@Initializable
class SigliTheHuntsman(player: Player? = null) : DialoguePlugin(player){
override fun open(vararg args: Any?): Boolean {
if(player?.inventory?.contains(3702,1) == true){
if(player?.inventory?.contains(Items.CUSTOM_BOW_STRING_3702, 1) == true){
npcl(FacialExpression.HAPPY,"Greetings outerlander.")
stage = 165
return true
@ -104,13 +105,13 @@ class SigliTheHuntsman(player: Player? = null) : DialoguePlugin(player){
//Draugen killed
100 -> player("Thanks!").also {
player.removeAttribute("fremtrials:draugen-killed")
player.setAttribute("/save:fremtrials:sigli-vote",true)
player?.setAttribute("/save:fremtrials:votes",player.getAttribute("fremtrials:votes",0) + 1)
player?.inventory?.remove(Item(3697))
stage = 1000
}
if (player.inventory.remove(Item(Items.HUNTERS_TALISMAN_3697))) {
player.removeAttribute("fremtrials:draugen-killed")
player.setAttribute("/save:fremtrials:sigli-vote", true)
player.setAttribute("/save:fremtrials:votes", player.getAttribute("fremtrials:votes", 0) + 1)
}
stage = 1000
}
150 -> playerl(FacialExpression.ASKING,"I don't suppose you have any idea where I could find a map to unspoiled hunting grounds, do you?").also { stage++ }
151 -> npcl(FacialExpression.HAPPY,"Well, of course I do. I wouldn't be much of a huntsman if I didn't know where to find my prey now, would I outerlander?").also { stage++ }
152 -> playerl(FacialExpression.ASKING,"No, I guess not. So can I have it?").also { stage++ }
@ -127,9 +128,10 @@ class SigliTheHuntsman(player: Player? = null) : DialoguePlugin(player){
161 -> npcl(FacialExpression.ANNOYED,"If I knew I would not have asked you to go and get me one, now would I?").also { stage = 1000 }
165 -> playerl(FacialExpression.HAPPY,"Here. I have your bowstring. Give me your map to the hunting grounds.").also {
removeItem(player,3702)
addItem(player,3701)
stage++
if (removeItem(player, Items.CUSTOM_BOW_STRING_3702)) {
addItem(player, Items.TRACKING_MAP_3701)
stage++
}
}
166 -> npcl(FacialExpression.HAPPY,"Well met, outerlander. I see some hunting potential within you. Here, take my map, I was getting too dependent on it for my skill anyway.").also { stage = 1000 }

View file

@ -10,6 +10,7 @@ import core.game.node.entity.player.Player
import core.plugin.Initializable
import org.rs09.consts.Items
import content.data.Quests
import core.api.addItemOrDrop
@Initializable
class SigmundDialogue (player: Player? = null) : DialoguePlugin(player) {
@ -109,8 +110,9 @@ class SigmundDialogue (player: Player? = null) : DialoguePlugin(player) {
36 -> npcl(FacialExpression.ASKING,"I suggest you ask around the other Fremennik in the town. A good merchant will find exactly what their customer needs somewhere.").also { stage++ }
37 -> playerl(FacialExpression.ASKING,"I was making some trades, but then I lost the goods...").also { stage++ }
38 -> npcl(FacialExpression.THINKING,"Hmmm... well try and start again at the beginning. And try to be more careful of your wares in future.").also {
addItem(player, Items.PROMISSORY_NOTE_3709)
stage = 1000 }
addItemOrDrop(player, Items.PROMISSORY_NOTE_3709)
stage = 1000
}
40 -> npcl(FacialExpression.HAPPY,"Hello again outerlander! I am amazed once more at your apparent skill at merchanting!").also { stage++ }
41 -> playerl(FacialExpression.HAPPY,"So I can count on your vote at the council of elders?").also { stage++ }

View file

@ -8,18 +8,19 @@ import core.game.node.entity.npc.NPC
import core.game.node.entity.player.Player
import core.plugin.Initializable
import content.data.Quests
import org.rs09.consts.Items
@Initializable
class SkulgrimenDialogue(player: Player? = null) : DialoguePlugin(player) {
override fun open(vararg args: Any?): Boolean {
npc = args[0] as NPC
if(player?.inventory?.contains(3703,1) == true){
if(player?.inventory?.contains(Items.UNUSUAL_FISH_3703,1) == true){
playerl(FacialExpression.HAPPY,"Hi there. I got your fish, so can I have that bowstring for Sigli now?")
stage = 20
return true
}
else if(player?.inventory?.contains(3702,1) == true){
else if(player?.inventory?.contains(Items.CUSTOM_BOW_STRING_3702,1) == true){
playerl(FacialExpression.ASKING,"So about this bowstring... was it hard to make or something?")
stage = 25
return true
@ -72,9 +73,9 @@ class SkulgrimenDialogue(player: Player? = null) : DialoguePlugin(player) {
17 -> npcl(FacialExpression.ANNOYED,"Ah. I see. I already told you. Some guy down by the docks was bragging. Best ask there, I reckon.").also { stage = 1000 }
20 -> npcl(FacialExpression.HAPPY,"Ohh... That's a nice fish. Very pleased. Here. Take the bowstring. You fulfilled agreement. Only fair I do same. Good work outerlander.").also {
removeItem(player,3703)
addItem(player,3702)
stage++
if (removeItem(player, Items.UNUSUAL_FISH_3703) && addItem(player, Items.CUSTOM_BOW_STRING_3702)) {
stage++
}
}
21 -> playerl(FacialExpression.HAPPY,"Thanks!").also { stage = 1000 }

View file

@ -8,18 +8,19 @@ import core.plugin.Initializable
import core.game.dialogue.DialoguePlugin
import core.game.dialogue.FacialExpression
import content.data.Quests
import org.rs09.consts.Items
@Initializable
class SwensenTheNavigator(player: Player? = null) : DialoguePlugin(player){
val gender = if (player?.isMale == true){"brother"} else "sister"
val fName = player?.getAttribute("fremennikname","doug hug'em")
override fun open(vararg args: Any?): Boolean {
if(player?.inventory?.contains(3705,1) == true){
if(player?.inventory?.contains(Items.WEATHER_FORECAST_3705, 1) == true){
playerl(FacialExpression.HAPPY,"I would like your map of fishing spots.")
stage = 120
return true
}
else if(player?.inventory?.contains(3704,1) == true){
else if(player?.inventory?.contains(Items.SEA_FISHING_MAP_3704, 1) == true){
playerl(FacialExpression.ASKING,"If this map of fishing spots is so valuable, why did you give it away to me so easily?")
stage = 125
return true
@ -48,7 +49,7 @@ class SwensenTheNavigator(player: Player? = null) : DialoguePlugin(player){
stage = 1000
return true
}
else if(player.questRepository.isComplete(Quests.THE_FREMENNIK_TRIALS)){
else if (player.questRepository.isComplete(Quests.THE_FREMENNIK_TRIALS)){
playerl(FacialExpression.HAPPY,"Hello!")
stage = 140
return true
@ -119,9 +120,9 @@ class SwensenTheNavigator(player: Player? = null) : DialoguePlugin(player){
121 -> playerl(FacialExpression.HAPPY,"What, like this one I have here?").also { stage++ }
122 -> npcl(FacialExpression.AMAZED,"W-what...? I don't believe it! How did you...?").also { stage++ }
123 -> npcl(FacialExpression.HAPPY,"I suppose it doesn't matter, you have my gratitude outerlander! With this forecast I will be able to plan a safe course for our next raiding expedition!").also {
removeItem(player,3705)
addItem(player,3704)
stage++
if (removeItem(player,Items.WEATHER_FORECAST_3705) && addItem(player, Items.SEA_FISHING_MAP_3704)) {
stage++
}
}
124 -> npcl(FacialExpression.HAPPY,"Here, outerlander; you may take my map of local fishing patterns with my gratitude!").also { stage = 1000 }

View file

@ -84,8 +84,7 @@ class TFTInteractionListeners : InteractionListener {
}
onUseWith(IntType.ITEM,TINDERBOX,CHERRY_BOMB){ player, _, _ ->
if(removeItem(player,CHERRY_BOMB)){
addItem(player,LIT_BOMB)
if (removeItem(player,CHERRY_BOMB) && addItem(player,LIT_BOMB)) {
sendMessage(player,"You light the strange object.")
}
return@onUseWith true

View file

@ -5,18 +5,19 @@ import core.api.getQuestStage
import core.api.removeItem
import core.game.node.entity.player.Player
import core.plugin.Initializable
import org.rs09.consts.Items
import org.rs09.consts.NPCs
import content.data.Quests
@Initializable
class ThorvaldDialogue(player: Player? = null) : core.game.dialogue.DialoguePlugin(player){
override fun open(vararg args: Any?): Boolean {
if(player?.inventory?.contains(3706,1) == true){
if(player?.inventory?.contains(Items.CHAMPIONS_TOKEN_3706, 1) == true){
playerl(core.game.dialogue.FacialExpression.HAPPY,"I would like your contract to offer your services as a bodyguard.")
stage = 215
return true
}
else if(player?.inventory?.contains(3710,1) == true){
else if(player?.inventory?.contains(Items.WARRIORS_CONTRACT_3710, 1) == true){
playerl(core.game.dialogue.FacialExpression.ASKING,"You didn't take much persuading to 'lower' yourself to a bodyguard.")
stage = 220
return true
@ -179,9 +180,10 @@ class ThorvaldDialogue(player: Player? = null) : core.game.dialogue.DialoguePlug
216 -> playerl(core.game.dialogue.FacialExpression.HAPPY,"It's a good thing I have the Champions' Token right here then, isn't it?").also { stage++ }
217 -> npcl(core.game.dialogue.FacialExpression.HAPPY,"Ah... well this is a different matter. With that token I can claim my rightful place as a champion in the Long hall!").also { stage++ }
218 -> npcl(core.game.dialogue.FacialExpression.HAPPY,"Here outerlander, I can suffer the indignity of playing babysitter if it means that I can then revel with my warrior equals in the Long Hall afterwards!").also {
removeItem(player,3706)
addItem(player,3710)
stage++
if (removeItem(player, Items.CHAMPIONS_TOKEN_3706)) {
addItem(player, Items.WARRIORS_CONTRACT_3710)
stage++
}
}
219 -> npcl(core.game.dialogue.FacialExpression.HAPPY,"Here outerlander, take this contract; I will fulfill it to my utmost.").also { stage = 1000 }

View file

@ -8,18 +8,19 @@ import core.game.node.entity.npc.NPC
import core.game.node.entity.player.Player
import core.plugin.Initializable
import content.data.Quests
import org.rs09.consts.Items
@Initializable
class YrsaDialogue(player: Player? = null) : DialoguePlugin(player) {
override fun open(vararg args: Any?): Boolean {
npc = args[0] as NPC
if(player?.inventory?.contains(3708,1) == true){
if(player?.inventory?.contains(Items.FISCAL_STATEMENT_3708,1) == true){
playerl(FacialExpression.HAPPY,"Hello. Can I have those boots now? Here is a written statement from Brundt outlining future tax burdens upon Fremennik merchants and shopkeepers for the year.")
stage = 15
return true
}
else if(player?.inventory?.contains(3700,1) == true){
else if(player?.inventory?.contains(Items.STURDY_BOOTS_3700,1) == true){
playerl(FacialExpression.ASKING,"Hey, these shoes look pretty comfy. Think you could make me a pair like them?")
stage = 20
return true
@ -67,9 +68,9 @@ class YrsaDialogue(player: Player? = null) : DialoguePlugin(player) {
10 -> npcl(FacialExpression.NEUTRAL,"Yes I do outerlander. Only the Chieftain may permit such a thing. Talk to him.").also { stage = 1000 }
15 -> npcl(FacialExpression.HAPPY,"Certainly! Let me have a look at what he has written here, just give me a moment...").also {
removeItem(player,3708)
addItem(player,3700)
stage++
if (removeItem(player, Items.FISCAL_STATEMENT_3708) && addItem(player, Items.STURDY_BOOTS_3700)) {
stage++
}
}
16 -> npcl(FacialExpression.HAPPY,"Yes, that all appears in order. Tell Olaf to come to me next time for shoes!").also { stage = 1000 }

View file

@ -1,10 +1,7 @@
package content.region.kandarin.ardougne.quest.arena.dialogue
import content.data.Quests
import core.api.addItem
import core.api.getQuestStage
import core.api.removeItem
import core.api.setQuestStage
import core.api.*
import core.game.dialogue.DialogueFile
import core.game.dialogue.FacialExpression
import core.game.node.entity.npc.NPC
@ -24,7 +21,7 @@ class KhazardBarmanDialogue : DialogueFile() {
1 -> npcl(FacialExpression.FRIENDLY, "There you go, that's two gold coins.").also { stage = 2 }
2 -> if (removeItem(player!!, Item(COINS_995, 2))) {
end()
addItem(player!!, Items.BEER_1917, 1)
addItemOrDrop(player!!, Items.BEER_1917, 1)
stage = END_DIALOGUE
} else {
end()
@ -49,7 +46,7 @@ class KhazardBarmanDialogue : DialogueFile() {
7 -> npcl(FacialExpression.FRIENDLY, "There you go, that's five gold coins. I suggest lying down before you drink it. That way you have less distance to collapse.").also { stage = 9 }
8 -> if (removeItem(player!!, Item(COINS_995, 2))){
end()
addItem(player!!, Items.BEER_1917, 1)
addItemOrDrop(player!!, Items.BEER_1917, 1)
stage = END_DIALOGUE
} else {
end()
@ -57,8 +54,8 @@ class KhazardBarmanDialogue : DialogueFile() {
}
9 -> if (removeItem(player!!, Item(COINS_995, 5))){
end()
addItem(player!!, Items.KHALI_BREW_77, 1)
setQuestStage(player!!, Quests.FIGHT_ARENA, 60)
addItemOrDrop(player!!, Items.KHALI_BREW_77, 1)
setQuestStage(player!!, Quests.FIGHT_ARENA, 60)
stage = END_DIALOGUE
} else {
end()

View file

@ -153,7 +153,7 @@ class ChompyBirdNPC : AbstractNPC, InteractionListener {
val bird = node.asNpc()
if (!bird.getAttribute("plucked", false)) {
addItem(player, Items.FEATHER_314, RandomFunction.random(25, 32))
addItemOrDrop(player, Items.FEATHER_314, RandomFunction.random(25, 32))
produceGroundItem(player, Items.BONES_526, 1, bird.location)
produceGroundItem(player, Items.RAW_CHOMPY_2876, 1, bird.location)
bird.clear()

View file

@ -61,8 +61,11 @@ class SCThormacDialogue(val questStage: Int) : DialogueFile() {
WHY_SHOULD_I_START -> npcl(FacialExpression.WORRIED, "Well I suppose I can aid you with my skills as a staff sorcerer. " +
"Most battlestaffs around here are a bit puny. I can beef them up for you a bit.").also {
// Need to recheck the quest stage since it may have been changed in this dialogue
if(getQuestStage(player!!, Quests.SCORPION_CATCHER) == 0) stage++
else stage = END_DIALOGUE
if (getQuestStage(player!!, Quests.SCORPION_CATCHER) == 0) {
stage++
} else {
stage = END_DIALOGUE
}
}
WHY_SHOULD_I_START+1 -> showTopics(
Topic(FacialExpression.ASKING, "So how would I go about catching them then?", HOW_TO_CATCH),
@ -77,7 +80,7 @@ class SCThormacDialogue(val questStage: Int) : DialogueFile() {
HOW_TO_CATCH+1 -> {
sendItemDialogue(player!!, Items.SCORPION_CAGE_456, "Thormac gives you a cage.").also { stage++ }
startQuest(player!!, Quests.SCORPION_CATCHER)
addItem(player!!, Items.SCORPION_CAGE_456)
addItemOrDrop(player!!, Items.SCORPION_CAGE_456)
}
HOW_TO_CATCH+2 -> npcl(FacialExpression.WORRIED, "If you go up to the village of Seers, to the North of " +
"here, one of them will be able to tell you where the scorpions are now.").also { stage++ }
@ -92,8 +95,7 @@ class SCThormacDialogue(val questStage: Int) : DialogueFile() {
Items.SCORPION_CAGE_459, Items.SCORPION_CAGE_460, Items.SCORPION_CAGE_461,
Items.SCORPION_CAGE_462), false).exists()){
playerl(FacialExpression.SAD, "I've lost my cage.").also { stage = GIVE_ANOTHER_CAGE }
}
else{
} else {
playerl(FacialExpression.NEUTRAL, "I've not caught all the scorpions yet.").also { stage++ }
}
}

View file

@ -17,7 +17,7 @@ class ScorpionCatcher : Quest(Quests.SCORPION_CATCHER, 108, 107, 1, 76, 0, 1, 6
const val QUEST_STATE_PEKSA_HELP = 40
const val QUEST_STATE_DONE = 100
const val ATTRIBUTE_TAVERLY = "scorpion_catcher:caught_taverly"
const val ATTRIBUTE_TAVERLEY = "scorpion_catcher:caught_taverly"
const val ATTRIBUTE_BARB = "scorpion_catcher:caught_barb"
const val ATTRIBUTE_MONK = "scorpion_catcher:caught_monk"
@ -32,7 +32,7 @@ class ScorpionCatcher : Quest(Quests.SCORPION_CATCHER, 108, 107, 1, 76, 0, 1, 6
var ln = 12
val caughtTaverly = player!!.getAttribute(ATTRIBUTE_TAVERLY, false)
val caughtTaverly = player!!.getAttribute(ATTRIBUTE_TAVERLEY, false)
val caughtBarb = player.getAttribute(ATTRIBUTE_BARB, false)
val caughtMonk = player.getAttribute(ATTRIBUTE_MONK, false)

View file

@ -1,342 +1,88 @@
package content.region.kandarin.quest.scorpioncatcher
import content.region.kandarin.quest.scorpioncatcher.ScorpionCatcher.Companion.ATTRIBUTE_TAVERLY
import content.region.kandarin.quest.scorpioncatcher.ScorpionCatcher.Companion.ATTRIBUTE_TAVERLEY
import content.region.kandarin.quest.scorpioncatcher.ScorpionCatcher.Companion.ATTRIBUTE_BARB
import content.region.kandarin.quest.scorpioncatcher.ScorpionCatcher.Companion.ATTRIBUTE_MONK
import core.api.addItem
import core.api.*
import core.game.node.item.Item
import core.api.removeItem
import core.api.runTask
import core.game.interaction.IntType
import core.game.interaction.InteractionListener
import core.game.node.Node
import core.game.node.entity.player.Player
import core.game.system.config.NPCConfigParser
import core.game.world.GameWorld
import core.tools.Log
import org.rs09.consts.Items
import org.rs09.consts.NPCs
class ScorpionCatcherUseListener : InteractionListener {
override fun defineListeners() {
/**
* List of cages
* Talvery Barbarian Monk
* TBM
* 456 ---
* 457 O--
* 458 00-
* 459 -0-
* 460 -00
* 461 --0
* 462 0-0
* 463 000
*
* Scorpions
* 385 - Barbarian
* 386 - Taverly
* 387 - Monastery
*/
val scorpToAttr = mapOf(
/* 385 - Barbarian
* 386 - Taverley
* 387 - Monastery
*/
NPCs.KHARID_SCORPION_385 to ATTRIBUTE_BARB,
NPCs.KHARID_SCORPION_386 to ATTRIBUTE_TAVERLEY,
NPCs.KHARID_SCORPION_387 to ATTRIBUTE_MONK
)
val cageToScorps = mapOf(
/* Taverley(386) Barbarian(385) Monastery(387)
* TBM
* 456 ---
* 457 O--
* 458 00-
* 459 -0-
* 460 -00
* 461 --0
* 462 0-0
* 463 000
*/
Items.SCORPION_CAGE_456 to setOf<Int>(),
Items.SCORPION_CAGE_457 to setOf(NPCs.KHARID_SCORPION_386),
Items.SCORPION_CAGE_458 to setOf(NPCs.KHARID_SCORPION_386, NPCs.KHARID_SCORPION_385),
Items.SCORPION_CAGE_459 to setOf(NPCs.KHARID_SCORPION_385),
Items.SCORPION_CAGE_460 to setOf(NPCs.KHARID_SCORPION_385, NPCs.KHARID_SCORPION_387),
Items.SCORPION_CAGE_461 to setOf(NPCs.KHARID_SCORPION_387),
Items.SCORPION_CAGE_462 to setOf(NPCs.KHARID_SCORPION_386, NPCs.KHARID_SCORPION_387),
Items.SCORPION_CAGE_463 to setOf(NPCs.KHARID_SCORPION_386, NPCs.KHARID_SCORPION_385, NPCs.KHARID_SCORPION_387)
)
/**
* Good captures
*/
/**
* Empty cage on Taverly scorpion
*/
// todo check this message
val haveAlready = "You already have this scorpion in this cage."
val catchMessage = "You catch a scorpion!"
onUseWith(IntType.NPC, Items.SCORPION_CAGE_456, NPCs.KHARID_SCORPION_386){ player, used, with ->
removeItem(player, Item(used.id, 1))
addItem(player, Items.SCORPION_CAGE_457)
player.sendMessage(catchMessage)
// This is the first time taverly has been caught
if (!player.getAttribute(ATTRIBUTE_TAVERLY, false)){
player.setAttribute("/save:$ATTRIBUTE_TAVERLY", true)
fun catchScorpion(player: Player, item: Node, scorpion: Node): Boolean {
val haveInCage = cageToScorps[item.id] ?: return false
if (scorpion.id in haveInCage) {
sendMessage(player, "You already have this scorpion in this cage.") //TODO check this message
return true
}
runTask(player, 2) {
with.asNpc().respawnTick =
GameWorld.ticks + with.asNpc().definition.getConfiguration(NPCConfigParser.RESPAWN_DELAY, 34)
val newScorpionSet = haveInCage + setOf(scorpion.id)
var newItem: Int? = null
for ((cage, scorps) in cageToScorps) {
if (scorps == newScorpionSet) {
newItem = cage
}
}
return@onUseWith true
}
/**
* Barbarian cage on Taverly scorpion
*/
onUseWith(IntType.NPC, Items.SCORPION_CAGE_459, NPCs.KHARID_SCORPION_386){ player, used, with ->
removeItem(player, Item(used.id, 1))
addItem(player, Items.SCORPION_CAGE_458)
player.sendMessage(catchMessage)
// This is the first time taverly has been caught
if (!player.getAttribute(ATTRIBUTE_TAVERLY, false)){
player.setAttribute("/save:$ATTRIBUTE_TAVERLY", true)
if (newItem == null) {
log(this::class.java, Log.ERR, "Error looking up new scorpion cage item - this isn't possible")
return false
}
runTask(player, 2) {
with.asNpc().respawnTick =
GameWorld.ticks + with.asNpc().definition.getConfiguration(NPCConfigParser.RESPAWN_DELAY, 34)
val attribute = scorpToAttr[scorpion.id]
if (removeItem(player, Item(item.id, 1)) && addItem(player, newItem)) {
sendMessage(player, "You catch a scorpion!")
setAttribute(player, "/save:$attribute", true)
runTask(player, 2) {
scorpion.asNpc().respawnTick = GameWorld.ticks + scorpion.asNpc().definition.getConfiguration(NPCConfigParser.RESPAWN_DELAY, 34)
}
return true
}
return@onUseWith true
}
/**
* Monk cage on Taverly scorpion
*/
onUseWith(IntType.NPC, Items.SCORPION_CAGE_461, NPCs.KHARID_SCORPION_386){ player, used, with ->
removeItem(player, Item(used.id, 1))
addItem(player, Items.SCORPION_CAGE_462)
player.sendMessage(catchMessage)
// This is the first time taverly has been caught
if (!player.getAttribute(ATTRIBUTE_TAVERLY, false)){
player.setAttribute("/save:$ATTRIBUTE_TAVERLY", true)
}
runTask(player, 2) {
with.asNpc().respawnTick =
GameWorld.ticks + with.asNpc().definition.getConfiguration(NPCConfigParser.RESPAWN_DELAY, 34)
}
return@onUseWith true
}
/**
* Others on Taverly scorpion
*/
onUseWith(IntType.NPC, Items.SCORPION_CAGE_460, NPCs.KHARID_SCORPION_386){ player, used, with ->
removeItem(player, Item(used.id, 1))
addItem(player, Items.SCORPION_CAGE_463)
player.sendMessage(catchMessage)
// This is the first time taverly has been caught
if (!player.getAttribute(ATTRIBUTE_TAVERLY, false)){
player.setAttribute("/save:$ATTRIBUTE_TAVERLY", true)
}
runTask(player, 2) {
with.asNpc().respawnTick =
GameWorld.ticks + with.asNpc().definition.getConfiguration(NPCConfigParser.RESPAWN_DELAY, 34)
}
return@onUseWith true
return false
}
/**
* Empty cage on barbarian agility course scorpion
*/
onUseWith(IntType.NPC, Items.SCORPION_CAGE_456, NPCs.KHARID_SCORPION_385){ player, used, with ->
removeItem(player, Item(used.id, 1))
addItem(player, Items.SCORPION_CAGE_459)
player.sendMessage(catchMessage)
// This is the first time barbarian has been caught
if (!player.getAttribute(ATTRIBUTE_BARB, false)){
player.setAttribute("/save:$ATTRIBUTE_BARB", true)
for (scorp in scorpToAttr.keys) {
for (cage in cageToScorps.keys) {
onUseWith(IntType.NPC, cage, scorp) { player, usedCage, usedScorp ->
return@onUseWith catchScorpion(player, usedCage, usedScorp)
}
}
runTask(player, 2) {
with.asNpc().respawnTick =
GameWorld.ticks + with.asNpc().definition.getConfiguration(NPCConfigParser.RESPAWN_DELAY, 34)
}
return@onUseWith true
}
/**
* Cage with Taverly scorpion on barbarian scorpion
*/
onUseWith(IntType.NPC, Items.SCORPION_CAGE_457, NPCs.KHARID_SCORPION_385) { player, used, with ->
removeItem(player, Item(used.id, 1))
addItem(player, Items.SCORPION_CAGE_458)
player.sendMessage(catchMessage)
// This is the first time barbarian has been caught
if (!player.getAttribute(ATTRIBUTE_BARB, false)){
player.setAttribute("/save:$ATTRIBUTE_BARB", true)
}
runTask(player, 2) {
with.asNpc().respawnTick =
GameWorld.ticks + with.asNpc().definition.getConfiguration(NPCConfigParser.RESPAWN_DELAY, 34)
}
return@onUseWith true
}
/**
* Cage with Monk scorpion on barbarian scorpion
*/
onUseWith(IntType.NPC, Items.SCORPION_CAGE_461, NPCs.KHARID_SCORPION_385) { player, used, with ->
removeItem(player, Item(used.id, 1))
addItem(player, Items.SCORPION_CAGE_460)
player.sendMessage(catchMessage)
// This is the first time barbarian has been caught
if (!player.getAttribute(ATTRIBUTE_BARB, false)){
player.setAttribute("/save:$ATTRIBUTE_BARB", true)
}
runTask(player, 2) {
with.asNpc().respawnTick =
GameWorld.ticks + with.asNpc().definition.getConfiguration(NPCConfigParser.RESPAWN_DELAY, 34)
}
return@onUseWith true
}
/**
* Others on barbarian scorpion
*/
onUseWith(IntType.NPC, Items.SCORPION_CAGE_462, NPCs.KHARID_SCORPION_385) { player, used, with ->
removeItem(player, Item(used.id, 1))
addItem(player, Items.SCORPION_CAGE_463)
player.sendMessage(catchMessage)
// This is the first time barbarian has been caught
if (!player.getAttribute(ATTRIBUTE_BARB, false)){
player.setAttribute("/save:$ATTRIBUTE_BARB", true)
}
runTask(player, 2) {
with.asNpc().respawnTick =
GameWorld.ticks + with.asNpc().definition.getConfiguration(NPCConfigParser.RESPAWN_DELAY, 34)
}
return@onUseWith true
}
/**
* Empty on Monk scorpion
*/
onUseWith(IntType.NPC, Items.SCORPION_CAGE_456, NPCs.KHARID_SCORPION_387) { player, used, with ->
removeItem(player, Item(used.id, 1))
addItem(player, Items.SCORPION_CAGE_461)
player.sendMessage(catchMessage)
// This is the first time the monastery has been caught
if (!player.getAttribute(ATTRIBUTE_MONK, false)){
player.setAttribute("/save:$ATTRIBUTE_MONK", true)
}
runTask(player, 2) {
with.asNpc().respawnTick =
GameWorld.ticks + with.asNpc().definition.getConfiguration(NPCConfigParser.RESPAWN_DELAY, 34)
}
return@onUseWith true
}
/**
* Taverly cage on Monk scorpion
*/
onUseWith(IntType.NPC, Items.SCORPION_CAGE_457, NPCs.KHARID_SCORPION_387) { player, used, with ->
removeItem(player, Item(used.id, 1))
addItem(player, Items.SCORPION_CAGE_462)
player.sendMessage(catchMessage)
// This is the first time the monastery has been caught
if (!player.getAttribute(ATTRIBUTE_MONK, false)){
player.setAttribute("/save:$ATTRIBUTE_MONK", true)
}
runTask(player, 2) {
with.asNpc().respawnTick =
GameWorld.ticks + with.asNpc().definition.getConfiguration(NPCConfigParser.RESPAWN_DELAY, 34)
}
return@onUseWith true
}
/**
* Barbarian cage on Monk scorpion
*/
onUseWith(IntType.NPC, Items.SCORPION_CAGE_459, NPCs.KHARID_SCORPION_387) { player, used, with ->
removeItem(player, Item(used.id, 1))
addItem(player, Items.SCORPION_CAGE_460)
player.sendMessage(catchMessage)
// This is the first time the monastery has been caught
if (!player.getAttribute(ATTRIBUTE_MONK, false)){
player.setAttribute("/save:$ATTRIBUTE_MONK", true)
}
runTask(player, 2) {
with.asNpc().respawnTick =
GameWorld.ticks + with.asNpc().definition.getConfiguration(NPCConfigParser.RESPAWN_DELAY, 34)
}
return@onUseWith true
}
/**
* Others on Monk scorpion
*/
onUseWith(IntType.NPC, Items.SCORPION_CAGE_458, NPCs.KHARID_SCORPION_387) { player, used, with ->
removeItem(player, Item(used.id, 1))
addItem(player, Items.SCORPION_CAGE_463)
player.sendMessage(catchMessage)
// This is the first time the monastery has been caught
if (!player.getAttribute(ATTRIBUTE_MONK, false)){
player.setAttribute("/save:$ATTRIBUTE_MONK", true)
}
runTask(player, 2) {
with.asNpc().respawnTick =
GameWorld.ticks + with.asNpc().definition.getConfiguration(NPCConfigParser.RESPAWN_DELAY, 34)
}
return@onUseWith true
}
/**
* Player being stupid and trying to recatch one they have already
*/
/**
* Taverly
*/
// Just Taverly
onUseWith(IntType.NPC, Items.SCORPION_CAGE_457, NPCs.KHARID_SCORPION_386){ player, _, _ ->
player.sendMessage(haveAlready)
return@onUseWith true
}
// Taverly and Barb
onUseWith(IntType.NPC, Items.SCORPION_CAGE_458, NPCs.KHARID_SCORPION_386){ player, _, _ ->
player.sendMessage(haveAlready)
return@onUseWith true
}
// Taverly and Monk
onUseWith(IntType.NPC, Items.SCORPION_CAGE_462, NPCs.KHARID_SCORPION_386){ player, _, _ ->
player.sendMessage(haveAlready)
return@onUseWith true
}
// All
onUseWith(IntType.NPC, Items.SCORPION_CAGE_463, NPCs.KHARID_SCORPION_386){ player, _, _ ->
player.sendMessage(haveAlready)
return@onUseWith true
}
/**
* Barbarian
*/
// Just Barb
onUseWith(IntType.NPC, Items.SCORPION_CAGE_459, NPCs.KHARID_SCORPION_385){ player, _, _ ->
player.sendMessage(haveAlready)
return@onUseWith true
}
// Barb and Taverly
onUseWith(IntType.NPC, Items.SCORPION_CAGE_458, NPCs.KHARID_SCORPION_385){ player, _, _ ->
player.sendMessage(haveAlready)
return@onUseWith true
}
// Barb and Monk
onUseWith(IntType.NPC, Items.SCORPION_CAGE_460, NPCs.KHARID_SCORPION_385){ player, _, _ ->
player.sendMessage(haveAlready)
return@onUseWith true
}
// All
onUseWith(IntType.NPC, Items.SCORPION_CAGE_463, NPCs.KHARID_SCORPION_385){ player, _, _ ->
player.sendMessage(haveAlready)
return@onUseWith true
}
/**
* Monastery
*/
// Just Monk
onUseWith(IntType.NPC, Items.SCORPION_CAGE_461, NPCs.KHARID_SCORPION_387){ player, _, _ ->
player.sendMessage(haveAlready)
return@onUseWith true
}
// Monk and Taverly
onUseWith(IntType.NPC, Items.SCORPION_CAGE_462, NPCs.KHARID_SCORPION_387){ player, _, _ ->
player.sendMessage(haveAlready)
return@onUseWith true
}
// Monk and Barb
onUseWith(IntType.NPC, Items.SCORPION_CAGE_460, NPCs.KHARID_SCORPION_387){ player, _, _ ->
player.sendMessage(haveAlready)
return@onUseWith true
}
// All
onUseWith(IntType.NPC, Items.SCORPION_CAGE_463, NPCs.KHARID_SCORPION_387){ player, _, _ ->
player.sendMessage(haveAlready)
return@onUseWith true
}
}
}

View file

@ -75,7 +75,7 @@ class SeerDialogue(player: Player? = null) : DialoguePlugin(player) {
)
}
else if ((scorpionCatcherQuestStage == ScorpionCatcher.QUEST_STATE_DARK_PLACE) and
getAttribute(player!!, ScorpionCatcher.ATTRIBUTE_TAVERLY, false)
getAttribute(player!!, ScorpionCatcher.ATTRIBUTE_TAVERLEY, false)
) {
playerl(
FacialExpression.NEUTRAL,

View file

@ -103,7 +103,7 @@ class EWListeners : InteractionListener {
}
// Player needs to receive a battered book
sendItemDialogue(player, Item(Items.BATTERED_BOOK_2886), "You find a book titled 'The Elemental Shield'.")
addItem(player, batteredBook.id)
addItemOrDrop(player, batteredBook.id)
return@on true
}
@ -120,7 +120,7 @@ class EWListeners : InteractionListener {
}
sendItemDialogue(player, Item(Items.SLASHED_BOOK_9715), "You find a book titled 'The Elemental Shield'.")
addItem(player, slashedBook.id)
addItemOrDrop(player, slashedBook.id)
if (player.inventory.addIfDoesntHave(batteredKey)) {
sendItemDialogue(player, Item(Items.BATTERED_KEY_2887),"You also find a key.")
}
@ -237,7 +237,7 @@ class EWListeners : InteractionListener {
on(Scenery.CRATE_3400, IntType.SCENERY, "search") { player, _ ->
if (!getAttribute(player, "/save:ew1:got_needle", false)) {
setAttribute(player, "/save:ew1:got_needle", true)
addItem(player, Items.NEEDLE_1733)
addItemOrDrop(player, Items.NEEDLE_1733)
sendMessage(player, "You find a needle.")
} else {
sendMessage(player, "You search the crate but find nothing.")
@ -249,7 +249,7 @@ class EWListeners : InteractionListener {
on(Scenery.CRATE_3394, IntType.SCENERY, "search") { player, _ ->
if (!getAttribute(player, "/save:ew1:got_leather", false)) {
setAttribute(player, "/save:ew1:got_leather", true)
addItem(player, Items.LEATHER_1741)
addItemOrDrop(player, Items.LEATHER_1741)
sendMessage(player, "You find some leather.")
} else {
sendMessage(player, "You search the crate but find nothing.")

View file

@ -33,7 +33,7 @@ class TribalTotemListeners : InteractionListener {
on(realCrate, IntType.SCENERY, "Investigate"){ player, node ->
if(player.questRepository.getStage(Quests.TRIBAL_TOTEM) in 1..19 && !player.inventory.containsAtLeastOneItem(Items.ADDRESS_LABEL_1858)){
sendDialogue(player,"There is a label on this crate. It says; To Lord Handelmort, Handelmort Mansion Ardogune.You carefully peel it off and take it.")
addItem(player,Items.ADDRESS_LABEL_1858,1)
addItemOrDrop(player,Items.ADDRESS_LABEL_1858,1)
}
else if(player.questRepository.getStage(Quests.TRIBAL_TOTEM) in 1..19 && player.inventory.containsAtLeastOneItem(Items.ADDRESS_LABEL_1858)){
sendDialogue(player,"There was a label on this crate, but it's gone now since you took it!")
@ -96,7 +96,7 @@ class TribalTotemListeners : InteractionListener {
on(openChest, IntType.SCENERY, "Search"){ player, node ->
if(!player.inventory.containsAtLeastOneItem(Items.TOTEM_1857)){
sendDialogue(player,"Inside the chest you find the tribal totem.")
addItem(player,Items.TOTEM_1857)
addItemOrDrop(player,Items.TOTEM_1857)
}
else{
sendDialogue(player,"Inside the chest you don't find anything because you already took the totem!")

View file

@ -31,9 +31,9 @@ class TutorialCombatInstructorDialogue(player: Player? = null) : DialoguePlugin(
54 -> {
player.dialogueInterpreter.sendDoubleItemMessage(Items.SHORTBOW_841, Items.BRONZE_ARROW_882, "The Combat Guide gives you some bronze arrows and a shortbow!")
if(!inInventory(player, Items.SHORTBOW_841) && !inEquipment(player, Items.SHORTBOW_841))
addItem(player, Items.SHORTBOW_841)
addItemOrDrop(player, Items.SHORTBOW_841)
if(!inInventory(player, Items.BRONZE_ARROW_882) && !inEquipment(player, Items.BRONZE_ARROW_882))
addItem(player, Items.BRONZE_ARROW_882, 30)
addItemOrDrop(player, Items.BRONZE_ARROW_882, 30)
}
}
return true

View file

@ -59,8 +59,8 @@ class TutorialMagicTutorDialogue(player: Player? = null) : core.game.dialogue.Di
70 -> if(!inInventory(player, Items.AIR_RUNE_556) && !inInventory(player, Items.MIND_RUNE_558))
{
player.dialogueInterpreter.sendDoubleItemMessage(Items.AIR_RUNE_556, Items.MIND_RUNE_558, "You receive some spare runes.")
addItem(player, Items.AIR_RUNE_556, 15)
addItem(player, Items.MIND_RUNE_558, 15)
addItemOrDrop(player, Items.AIR_RUNE_556, 15)
addItemOrDrop(player, Items.MIND_RUNE_558, 15)
return false
}
71 -> npcl(core.game.dialogue.FacialExpression.FRIENDLY, "Alright, last thing. Are you interested in being an ironman or changing your experience rate?")

View file

@ -42,14 +42,14 @@ class TutorialMasterChefDialogue(player: Player? = null) : DialoguePlugin(player
if(!inInventory(player, Items.BUCKET_OF_WATER_1929))
{
sendItemDialogue(player, Items.BUCKET_OF_WATER_1929, "The Master Chef gives you another bucket of water.")
addItem(player, Items.BUCKET_OF_WATER_1929)
addItemOrDrop(player, Items.BUCKET_OF_WATER_1929)
TutorialStage.load(player, 19)
return false
}
if(!inInventory(player, Items.POT_OF_FLOUR_1933))
{
sendItemDialogue(player, Items.POT_OF_FLOUR_1933, "The Master Chef gives you another pot of flour.")
addItem(player, Items.POT_OF_FLOUR_1933)
addItemOrDrop(player, Items.POT_OF_FLOUR_1933)
TutorialStage.load(player, 19)
return false
}
@ -102,8 +102,8 @@ class TutorialMasterChefDialogue(player: Player? = null) : DialoguePlugin(player
"The Cooking Guide gives you a <col=08088A>bucket of water<col> and a <col=08088A>pot of flour</col>."
)
)
addItem(player, Items.BUCKET_OF_WATER_1929)
addItem(player, Items.POT_OF_FLOUR_1933)
addItemOrDrop(player, Items.BUCKET_OF_WATER_1929)
addItemOrDrop(player, Items.POT_OF_FLOUR_1933)
stage++
}
4 -> {

View file

@ -1,9 +1,5 @@
package content.region.misc.tutisland.dialogue
import core.api.addItem
import core.api.getAttribute
import core.api.inInventory
import core.api.setAttribute
import core.game.dialogue.DialoguePlugin
import core.game.dialogue.FacialExpression
import core.game.node.entity.npc.NPC
@ -12,6 +8,7 @@ import core.plugin.Initializable
import org.rs09.consts.Items
import org.rs09.consts.NPCs
import content.region.misc.tutisland.handlers.TutorialStage
import core.api.*
/**
* Handles the mining tutor's dialogue
@ -30,7 +27,7 @@ class TutorialMiningInstructorDialogue(player: Player? = null) : DialoguePlugin(
34 -> playerl(FacialExpression.FRIENDLY, "I prospected both types of rock! One set contains tin and the other has copper ore inside.")
35 -> {
if(!inInventory(player, Items.BRONZE_PICKAXE_1265)) {
addItem(player, Items.BRONZE_PICKAXE_1265)
addItemOrDrop(player, Items.BRONZE_PICKAXE_1265)
player.dialogueInterpreter.sendItemMessage(Items.BRONZE_PICKAXE_1265, "Dezzick gives you a bronze pickaxe!")
stage = 3
}
@ -41,7 +38,7 @@ class TutorialMiningInstructorDialogue(player: Player? = null) : DialoguePlugin(
40 -> playerl(FacialExpression.ASKING, "How do I make a weapon out of this?")
41 -> {
if(!inInventory(player, Items.HAMMER_2347)) {
addItem(player, Items.HAMMER_2347)
addItemOrDrop(player, Items.HAMMER_2347)
player.dialogueInterpreter.sendItemMessage(Items.HAMMER_2347, "Dezzick gives you a hammer!")
stage = 3
}

View file

@ -35,12 +35,13 @@ class TutorialFurnaceListener : InteractionListener {
animate(player, ANIMATION)
submitIndividualPulse(player, object: Pulse(2) {
override fun pulse(): Boolean {
removeItem(player, Items.TIN_ORE_438)
removeItem(player, Items.COPPER_ORE_436)
addItem(player, Items.BRONZE_BAR_2349)
rewardXP(player, Skills.SMITHING, Bar.BRONZE.experience)
player.dispatch(ResourceProducedEvent(Items.BRONZE_BAR_2349, 1, player, Items.COPPER_ORE_436))
return true
if (removeItem(player, Items.TIN_ORE_438) && removeItem(player, Items.COPPER_ORE_436)) {
addItem(player, Items.BRONZE_BAR_2349)
rewardXP(player, Skills.SMITHING, Bar.BRONZE.experience)
player.dispatch(ResourceProducedEvent(Items.BRONZE_BAR_2349, 1, player, Items.COPPER_ORE_436))
return true
}
return false
}
})

View file

@ -4,7 +4,6 @@ import core.api.Container;
import core.game.dialogue.DialoguePlugin;
import core.game.node.entity.player.Player;
import core.game.node.entity.player.link.emote.Emotes;
import core.game.node.item.Item;
import org.rs09.consts.Items;
import static core.api.ContentAPIKt.addItem;

View file

@ -56,7 +56,7 @@ public final class GrainOfPlentyDialogue extends DialoguePlugin {
break;
}
player.getSavedData().getGlobalData().getStrongHoldRewards()[1] = true;
interpreter.sendDialogue("...congratualtions adventurer, you have been deemed worthy of this", "reward. You have also unlocked the Slap Head emote!");
interpreter.sendDialogue("...congratulations adventurer, you have been deemed worthy of this", "reward. You have also unlocked the Slap Head emote!");
stage = 1;
player.getEmoteManager().unlock(Emotes.SLAP_HEAD);
break;

View file

@ -32,7 +32,7 @@ class ProfessorHenryDialogue(player : Player? = null) : DialoguePlugin(player){
}
else if (player.savedData.globalData.testStage >= 3){
// The player has already had their test marked and taken
npcl(FacialExpression.HAPPY, "Good job ${player.name}, you completed the test!").also { stage = END_DIALOGUE }
npcl(FacialExpression.HAPPY, "Good job ${player.username}, you completed the test!").also { stage = END_DIALOGUE }
return true
}
else{
@ -83,7 +83,7 @@ class ProfessorHenryDialogue(player : Player? = null) : DialoguePlugin(player){
GET_TEST + 1 -> playerl(FacialExpression.HALF_GUILTY, "Okay, thanks.").also { stage = END_DIALOGUE }
HAND_IN_TEST -> npcl(FacialExpression.HAPPY,
"Ah, ${player.name}. How's the test going?").also { stage ++ }
"Ah, ${player.username}. How's the test going?").also { stage ++ }
HAND_IN_TEST + 1 -> playerl(FacialExpression.NEUTRAL, "I think I've finished.").also { stage++ }
HAND_IN_TEST + 2 -> npcl(FacialExpression.HAPPY, "Excellent! Let me just mark the paper for you then.").also { stage++ }
HAND_IN_TEST + 3 -> npcl(FacialExpression.HAPPY, "Hmm. Uh-huh, yes I see. Good! Yes, that's right.").also{ stage++ }
@ -118,8 +118,9 @@ class ProfessorHenryDialogue(player : Player? = null) : DialoguePlugin(player){
setVarp(player, 1203, 1 shl 29, true)
player.savedData.globalData.testStage = 3
removeItem(player, Items.TEST_PAPER_12626)
addItem(player, Items.ANTIQUE_LAMP_4447, 2)
if (removeItem(player, Items.TEST_PAPER_12626)) {
addItem(player, Items.ANTIQUE_LAMP_4447, 2)
}
player.emoteManager.unlock(Emotes.SAFETY_FIRST)
openInterface(player, iFace)
@ -137,7 +138,6 @@ class ProfessorHenryDialogue(player : Player? = null) : DialoguePlugin(player){
player.packetDispatch.sendString("Player Safety Dungeon", iFace, 11)
player.packetDispatch.sendString("The Safety First' emote", iFace, 12)
sendItemZoomOnInterface(player, iFace, 5, Items.TEST_PAPER_12626)
}

View file

@ -392,16 +392,18 @@ class ZaffPlugin : OptionHandler() {
ammount = getStoreFile().getInt(player.username.toLowerCase())
var amt = value as Int
if(amt > maxStaffs - ammount) amt = maxStaffs - ammount
if(amt == 0){
return@sendInputDialogue
}
val coinage = amt * 7000
if(!inInventory(player, Items.COINS_995, coinage)){
sendDialogue(player, "You can't afford that many.")
return@sendInputDialogue
}
if(amt == 0){
if(!hasSpaceFor(player, Item(Items.BATTLESTAFF_1392, amt)) && amountInInventory(player, Items.COINS_995) > coinage){
sendDialogue(player, "You don't have enough inventory space.")
return@sendInputDialogue
}
if(removeItem(player, Item(Items.COINS_995, coinage), Container.INVENTORY)){
addItem(player, Items.BATTLESTAFF_1392, amt)
getStoreFile()[player.username.toLowerCase()] = amt + ammount

View file

@ -36,7 +36,7 @@ class RoavarDialogue (player: Player? = null) : DialoguePlugin(player) {
1 -> showTopics(
Topic<Int?>(FacialExpression.HALF_GUILTY, "Can I buy a beer?", 10, false),
Topic<Int?>(FacialExpression.HALF_GUILTY, "Can I hear some gossip", 20, false),
Topic<Int?>(FacialExpression.HALF_GUILTY, "Can I hear some gossip?", 20, false),
IfTopic<RoavarDialogueFile?>(FacialExpression.HALF_GUILTY, "Can I buy something to eat?", RoavarDialogueFile(1), player.getQuestRepository().getQuest(Quests.CREATURE_OF_FENKENSTRAIN).getStage(player) == 2, false),
Topic<Int?>(FacialExpression.HALF_GUILTY, "Nothing thanks.", 40, false)
)
@ -81,7 +81,7 @@ class RoavarDialogue (player: Player? = null) : DialoguePlugin(player) {
}
21 -> end()
30 -> stage = if (inInventory(player, 2963, 1)) {
30 -> stage = if (inInventory(player, Items.SILVER_SICKLEB_2963, 1)) {
npc(FacialExpression.HALF_GUILTY, "I don't have a spare lying around, sorry friend.", "Hopefully you'll find something else that can protect you", "against ghasts!")
31
} else {
@ -101,7 +101,7 @@ class RoavarDialogue (player: Player? = null) : DialoguePlugin(player) {
npc(FacialExpression.HALF_GUILTY, "Oh, nevermind. It seems your backpack is full.")
} else {
sendDialogue(player, "The bartender hands you a silver sickle.")
addItem(player, 2963)
addItemOrDrop(player, Items.SILVER_SICKLEB_2963)
}
stage = 31
}

View file

@ -70,8 +70,9 @@ class MortMyreGhastNPC : AbstractNPC {
val consumable = Consumables.getConsumableById(i.id)
if(consumable != null && consumable.consumable is Food) {
hasFood = true
removeItem(player, i, Container.INVENTORY)
addItem(player, Items.ROTTEN_FOOD_2959)
if (removeItem(player, i, Container.INVENTORY)) {
addItem(player, Items.ROTTEN_FOOD_2959)
}
sendMessage(player, "You feel something attacking your backpack, and smell a terrible stench.")
break
}

View file

@ -132,8 +132,7 @@ class NSListeners : InteractionListener {
}
on(SPELLCARD, IntType.ITEM, "cast"){ player, node ->
if(NSUtils.castBloom(player)){
removeItem(player, node.asItem(), Container.INVENTORY)
if (NSUtils.castBloom(player) && removeItem(player, node.asItem(), Container.INVENTORY)) {
addItem(player, Items.A_USED_SPELL_2969)
}
return@on true

View file

@ -127,7 +127,7 @@ class NSTarlockDialogue(player: Player? = null) : DialoguePlugin(player) {
playerl(FacialExpression.NEUTRAL, "Could I have another bloom scroll please?").also { stage++ }
} else end()
74 -> npcl(FacialExpression.NEUTRAL, "Sure, but please look after this one.").also { stage++ }
75 -> sendDialogue("The spirit of Filliman Tarlock gives you","another bloom spell.").also { addItem(player, Items.DRUIDIC_SPELL_2968); stage = END_DIALOGUE }
75 -> sendDialogue("The spirit of Filliman Tarlock gives you","another bloom spell.").also { addItemOrDrop(player, Items.DRUIDIC_SPELL_2968); stage = END_DIALOGUE }
//has fungus
80 -> sendDialogue("You show the fungus to Filliman.").also { stage++ }
@ -190,7 +190,7 @@ class NSTarlockDialogue(player: Player? = null) : DialoguePlugin(player) {
npcl(FacialExpression.NEUTRAL, "No, you've already got one!").also { stage = END_DIALOGUE }
} else {
npcl(FacialExpression.NEUTRAL, "Sure, but look after this one.")
addItem(player, Items.DRUIDIC_SPELL_2968)
addItemOrDrop(player, Items.DRUIDIC_SPELL_2968)
stage = END_DIALOGUE
}

View file

@ -58,7 +58,7 @@ object NSUtils {
if(pouchAmt == 1) shouldAddEmptyPouch = true
if(pouchAmt > 0 && removeItem(player, Items.DRUID_POUCH_2958, Container.INVENTORY)){
if(shouldAddEmptyPouch){
addItem(player, Items.DRUID_POUCH_2957)
addItemOrDrop(player, Items.DRUID_POUCH_2957)
}
spawnProjectile(player, attacker, 268)
submitWorldPulse(object : Pulse(){

View file

@ -1,6 +1,5 @@
package core.game.worldevents.holiday.christmas.randoms
import core.api.addItem
import core.api.addItemOrDrop
import core.api.getAttribute
import core.game.dialogue.DialogueFile