Fixed a few bugs
This commit is contained in:
@@ -43,7 +43,6 @@ class DigUpPatchDialogue(player: Player? = null) : DialoguePlugin(player) {
|
||||
}
|
||||
}
|
||||
}
|
||||
player.sendMessage("${patch?.getCurrentState()}")
|
||||
patch?.clear()
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package rs09.game.node.entity.skill.farming
|
||||
|
||||
import core.game.node.item.Item
|
||||
import org.rs09.consts.Items
|
||||
import rs09.game.content.dialogue.DialogueFile
|
||||
import rs09.tools.END_DIALOGUE
|
||||
import rs09.tools.START_DIALOGUE
|
||||
|
||||
class FarmerPayOptionDialogue(val patch: Patch): DialogueFile() {
|
||||
var item: Item? = null
|
||||
override fun handle(componentID: Int, buttonID: Int) {
|
||||
when(stage){
|
||||
START_DIALOGUE -> {
|
||||
item = patch.plantable?.protectionItem
|
||||
val protectionText = when(item?.id){
|
||||
Items.COMPOST_6032 -> if(item?.amount == 1) "bucket of compost" else "buckets of compost"
|
||||
Items.POTATOES10_5438 -> if(item?.amount == 1) "sack of potatoes" else "sacks of potatoes"
|
||||
Items.ONIONS10_5458 -> if(item?.amount == 1) "sack of onions" else "sacks of onions"
|
||||
Items.CABBAGES10_5478 -> if(item?.amount == 1) "sack of cabbages" else "sacks of cabbages"
|
||||
Items.JUTE_FIBRE_5931 -> "jute fibres"
|
||||
Items.APPLES5_5386 -> if(item?.amount == 1) "basket of apples" else "baskets of apples"
|
||||
Items.MARIGOLDS_6010 -> "harvest of marigold"
|
||||
Items.TOMATOES5_5968 -> if(item?.amount == 1) "basket of tomatoes" else "baskets of tomatoes"
|
||||
Items.ORANGES5_5396 -> if(item?.amount == 1) "basket of oranges" else "baskets of oranges"
|
||||
Items.COCONUT_5974 -> "coconuts"
|
||||
Items.STRAWBERRIES5_5406 -> if(item?.amount == 1) "basket of strawberries" else "baskets of strawberries"
|
||||
Items.BANANAS5_5416 -> if(item?.amount == 1) "basket of bananas" else "baskets of bananas"
|
||||
else -> item?.name?.toLowerCase()
|
||||
}
|
||||
if(item == null) npc("Sorry, I won't protect that.").also { stage = END_DIALOGUE }
|
||||
else{
|
||||
npc("I would like ${item?.amount} $protectionText","to protect that patch.")
|
||||
stage++
|
||||
}
|
||||
}
|
||||
|
||||
1 -> options("Sure!","No, thanks.").also { stage++ }
|
||||
2 -> {
|
||||
if(player!!.inventory.containsItem(item)){
|
||||
player("Here you go.").also { stage = 10 }
|
||||
} else {
|
||||
item = Item(item!!.noteChange,item!!.amount)
|
||||
if(player!!.inventory.containsItem(item)){
|
||||
player("Here you go.").also { stage = 10 }
|
||||
} else {
|
||||
player("I don't have that to give.").also { stage = 20 }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
10 -> {
|
||||
if(player!!.inventory.remove(item)){
|
||||
npc("Thank you! I'll keep an eye on this patch.").also { stage = END_DIALOGUE }
|
||||
patch?.protectionPaid = true
|
||||
} else {
|
||||
npc("That stuff just... vanished....").also { stage = END_DIALOGUE }
|
||||
}
|
||||
}
|
||||
|
||||
20 -> {
|
||||
npc("Come back when you do.")
|
||||
stage = END_DIALOGUE
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
-127
@@ -1,45 +1,25 @@
|
||||
package rs09.game.node.entity.skill.farming
|
||||
|
||||
import core.cache.def.impl.NPCDefinition
|
||||
import core.game.content.dialogue.DialoguePlugin
|
||||
import core.game.interaction.OptionHandler
|
||||
import core.game.node.Node
|
||||
import core.game.node.entity.npc.NPC
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.item.Item
|
||||
import core.plugin.Initializable
|
||||
import core.plugin.Plugin
|
||||
import org.rs09.consts.Items
|
||||
import rs09.game.interaction.InteractionListener
|
||||
|
||||
@Initializable
|
||||
class FarmerPayOptionHandler : OptionHandler() {
|
||||
override fun newInstance(arg: Any?): Plugin<Any> {
|
||||
NPCDefinition.setOptionHandler("pay",this)
|
||||
NPCDefinition.setOptionHandler("pay (north)",this)
|
||||
NPCDefinition.setOptionHandler("pay (south)",this)
|
||||
NPCDefinition.setOptionHandler("pay (north-west)",this)
|
||||
NPCDefinition.setOptionHandler("pay (south-east)",this)
|
||||
return this
|
||||
class FarmerPayOptionHandler : InteractionListener() {
|
||||
|
||||
override fun defineListeners() {
|
||||
on(NPC,"pay","pay (north)","pay (north-west)"){player,node ->
|
||||
return@on attemptPay(player,node,0)
|
||||
}
|
||||
|
||||
override fun handle(player: Player?, node: Node?, option: String?): Boolean {
|
||||
player ?: return false
|
||||
node ?: return false
|
||||
val farmer = Farmers.forId(node.id)
|
||||
|
||||
if(farmer == null){
|
||||
player.sendMessage("This shouldn't be happening. Report this.")
|
||||
return true
|
||||
on(NPC,"pay (south)","pay (south-east)"){player,node ->
|
||||
return@on attemptPay(player,node,1)
|
||||
}
|
||||
}
|
||||
|
||||
val fPatch = when(option){
|
||||
"pay" -> farmer.patches[0]
|
||||
"pay (north)","pay (north-west)" -> farmer.patches[0]
|
||||
"pay (south)","pay (south-east)" -> farmer.patches[1]
|
||||
else -> farmer.patches[0]
|
||||
}
|
||||
fun attemptPay(player: Player, node: Node, index: Int): Boolean{
|
||||
val farmer = Farmers.forId(node.id) ?: return false
|
||||
val patch = farmer.patches[index].getPatchFor(player)
|
||||
|
||||
val patch = fPatch.getPatchFor(player)
|
||||
if(patch.plantable == null){
|
||||
player.dialogueInterpreter.sendDialogue("I have nothing to protect in that patch.")
|
||||
return true
|
||||
@@ -50,101 +30,7 @@ class FarmerPayOptionHandler : OptionHandler() {
|
||||
return true
|
||||
}
|
||||
|
||||
player.dialogueInterpreter.open(FarmerPayDialogue.KEY,node.asNpc(),patch)
|
||||
player.dialogueInterpreter.open(FarmerPayOptionDialogue(patch),node.asNpc())
|
||||
return true
|
||||
}
|
||||
|
||||
@Initializable
|
||||
class FarmerPayDialogue(player: Player? = null) : DialoguePlugin(player){
|
||||
var patch: Patch? = null
|
||||
var item: Item? = null
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
val KEY = 1256743
|
||||
}
|
||||
|
||||
override fun newInstance(player: Player?): DialoguePlugin {
|
||||
return FarmerPayDialogue(player)
|
||||
}
|
||||
|
||||
override fun open(vararg args: Any?): Boolean {
|
||||
npc = (args[0] as NPC).getShownNPC(player)
|
||||
patch = (args[1] as Patch)
|
||||
if(patch == null){
|
||||
npc("Hello.")
|
||||
stage = 1000
|
||||
return true
|
||||
} else {
|
||||
item = patch?.plantable?.protectionItem
|
||||
val protectionText = when(item?.id){
|
||||
Items.COMPOST_6032 -> if(item?.amount == 1) "bucket of compost" else "buckets of compost"
|
||||
Items.POTATOES10_5438 -> if(item?.amount == 1) "sack of potatoes" else "sacks of potatoes"
|
||||
Items.ONIONS10_5458 -> if(item?.amount == 1) "sack of onions" else "sacks of onions"
|
||||
Items.CABBAGES10_5478 -> if(item?.amount == 1) "sack of cabbages" else "sacks of cabbages"
|
||||
Items.JUTE_FIBRE_5931 -> "jute fibres"
|
||||
Items.APPLES5_5386 -> if(item?.amount == 1) "basket of apples" else "baskets of apples"
|
||||
Items.MARIGOLDS_6010 -> "harvest of marigold"
|
||||
Items.TOMATOES5_5968 -> if(item?.amount == 1) "basket of tomatoes" else "baskets of tomatoes"
|
||||
Items.ORANGES5_5396 -> if(item?.amount == 1) "basket of oranges" else "baskets of oranges"
|
||||
Items.COCONUT_5974 -> "coconuts"
|
||||
Items.STRAWBERRIES5_5406 -> if(item?.amount == 1) "basket of strawberries" else "baskets of strawberries"
|
||||
Items.BANANAS5_5416 -> if(item?.amount == 1) "basket of bananas" else "baskets of bananas"
|
||||
else -> item?.name?.toLowerCase()
|
||||
}
|
||||
if(item == null) npc("Sorry, I won't protect that.").also { stage = 1000 }
|
||||
else{
|
||||
npc("I would like ${item?.amount} $protectionText","to protect that patch.")
|
||||
stage = 0
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
override fun handle(interfaceId: Int, buttonId: Int): Boolean {
|
||||
when(stage){
|
||||
0 -> options("Sure!","No, thanks.").also { stage++ }
|
||||
1 -> when(buttonId){
|
||||
1 -> player("Sure!").also { stage++ }
|
||||
2 -> player("No, thanks.").also { stage = 1000 }
|
||||
}
|
||||
2 -> {
|
||||
if(player.inventory.containsItem(item)){
|
||||
player("Here you go.").also { stage = 10 }
|
||||
player.inventory.remove()
|
||||
} else {
|
||||
item = Item(item!!.noteChange,item!!.amount)
|
||||
if(player.inventory.containsItem(item)){
|
||||
player("Here you go.").also { stage = 10 }
|
||||
} else {
|
||||
player("I don't have that to give.").also { stage = 20 }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
10 -> {
|
||||
if(player.inventory.remove(item)){
|
||||
npc("Thank you! I'll keep an eye on this patch.").also { stage = 1000 }
|
||||
patch?.protectionPaid = true
|
||||
} else {
|
||||
npc("That stuff just... vanished....").also { stage = 1000 }
|
||||
}
|
||||
}
|
||||
|
||||
20 -> {
|
||||
npc("Come back when you do.")
|
||||
stage = 1000
|
||||
}
|
||||
|
||||
1000 -> end()
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
override fun getIds(): IntArray {
|
||||
return intArrayOf(KEY)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,7 +15,7 @@ object PatchRaker {
|
||||
player.pulseManager.run(object : Pulse(){
|
||||
override fun pulse(): Boolean {
|
||||
var patchStage = patch.getPatchFor(player).getCurrentState()
|
||||
if(patchStage < 2){
|
||||
if(patchStage <= 2){
|
||||
player.animator.animate(RAKE_ANIM)
|
||||
}
|
||||
if(delay < 5) {
|
||||
|
||||
@@ -11,7 +11,7 @@ enum class Plantable(val itemID: Int, val value: Int, val stages: Int, val plant
|
||||
NASTURTIUM_SEED(5098,18,4,19.5,111.0,0.0,24,PatchType.FLOWER,Items.NASTURTIUMS_6012),
|
||||
WOAD_SEED(5099,23,4,20.5,115.5,0.0,25,PatchType.FLOWER,Items.WOAD_LEAF_1793),
|
||||
LIMPWURT_SEED(5100,28,4,21.5,120.0,0.0,26,PatchType.FLOWER,Items.LIMPWURT_ROOT_225),
|
||||
WHITE_LILY_SEED(14589,37,4,42.0,250.0,0.0,58,PatchType.FLOWER,Items.WHITE_LILY_14583),
|
||||
WHITE_LILY_SEED(14589,37,4,42.0,250.0,0.0,52,PatchType.FLOWER,Items.WHITE_LILY_14583),
|
||||
|
||||
//Flower(Technically)
|
||||
SCARECROW(6059,33,3,0.0,0.0,0.0,23,PatchType.FLOWER,Items.SCARECROW_6059),
|
||||
|
||||
@@ -34,7 +34,7 @@ class SeedOnPlantPot : UseWithHandler(Items.ACORN_5312,
|
||||
else -> return false
|
||||
}
|
||||
|
||||
if(player.inventory.remove(pot) && player.inventory.remove(seed)){
|
||||
if(player.inventory.remove(pot) && player.inventory.remove(Item(seed.id,1))){
|
||||
player.inventory.add(Item(seedling))
|
||||
}
|
||||
|
||||
|
||||
@@ -197,6 +197,11 @@ class ToolLeprechaunInterface : ComponentPlugin() {
|
||||
}
|
||||
}
|
||||
|
||||
if(finalAmount > hasAmount){
|
||||
finalAmount = hasAmount
|
||||
}
|
||||
if(finalAmount > spaceLeft) finalAmount = spaceLeft
|
||||
|
||||
if(!player.inventory.contains(item,finalAmount)){
|
||||
player.dialogueInterpreter.sendDialogue("You don't have any of those to store.")
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user