mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-10 10:20:41 -07:00
added produce noting
This commit is contained in:
parent
7adbe80164
commit
99f93e8c60
1 changed files with 42 additions and 0 deletions
|
|
@ -0,0 +1,42 @@
|
|||
package core.game.node.entity.skill.farming
|
||||
|
||||
import core.game.content.dialogue.FacialExpression
|
||||
import core.game.interaction.NodeUsageEvent
|
||||
import core.game.interaction.UseWithHandler
|
||||
import core.game.node.item.Item
|
||||
import core.plugin.Initializable
|
||||
import core.plugin.Plugin
|
||||
|
||||
@Initializable
|
||||
class LeprechaunNoter : UseWithHandler(*Plantable.values().map{ it.harvestItem }.toIntArray()) {
|
||||
override fun newInstance(arg: Any?): Plugin<Any> {
|
||||
addHandler(3021, NPC_TYPE,this)
|
||||
addHandler(8000, NPC_TYPE,this)
|
||||
addHandler(4965, NPC_TYPE,this)
|
||||
return this
|
||||
}
|
||||
|
||||
override fun handle(event: NodeUsageEvent?): Boolean {
|
||||
event ?: return false
|
||||
val player = event.player ?: return false
|
||||
val usedItem = event.usedItem ?: return false
|
||||
val npc = event.usedWith.asNpc() ?: return false
|
||||
|
||||
val expr = when(npc.id){
|
||||
3021 -> FacialExpression.OLD_NORMAL
|
||||
else -> FacialExpression.FRIENDLY
|
||||
}
|
||||
|
||||
if(usedItem.noteChange != usedItem.id){
|
||||
val amt = player.inventory.getAmount(usedItem.id)
|
||||
if(player.inventory.remove(Item(usedItem.id,amt))){
|
||||
player.inventory.add(Item(usedItem.noteChange,amt))
|
||||
}
|
||||
player.dialogueInterpreter.sendDialogues(npc.id,expr,"There ya go.")
|
||||
} else {
|
||||
player.dialogueInterpreter.sendDialogues(npc.id,expr,"But that's already a note!")
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue