diff --git a/Server/src/main/java/core/game/interaction/npc/NPCTradePlugin.kt b/Server/src/main/java/core/game/interaction/npc/NPCTradePlugin.kt index f867050d2..6adf59936 100644 --- a/Server/src/main/java/core/game/interaction/npc/NPCTradePlugin.kt +++ b/Server/src/main/java/core/game/interaction/npc/NPCTradePlugin.kt @@ -10,6 +10,7 @@ import core.game.node.entity.npc.NPC import core.game.node.entity.player.Player import core.plugin.Plugin import core.game.node.entity.skill.crafting.TanningProduct +import org.rs09.consts.NPCs import rs09.game.interaction.InteractionListener /** @@ -31,6 +32,16 @@ class NPCTradePlugin : InteractionListener() { } return@on npc.openShop(player) } + + on(NPCs.SIEGFRIED_ERKLE_933, NPC, "trade"){player, node -> + val points = ContentAPI.getQP(player) + if(points < 40){ + ContentAPI.sendNPCDialogue(player, NPCs.SIEGFRIED_ERKLE_933, "I'm sorry, adventurer, but you need 40 quest points to buy from me.") + return@on true + } + node.asNpc().openShop(player) + return@on true + } } override fun defineDestinationOverrides() { diff --git a/Server/src/main/kotlin/api/ContentAPI.kt b/Server/src/main/kotlin/api/ContentAPI.kt index b23c9509f..b04703066 100644 --- a/Server/src/main/kotlin/api/ContentAPI.kt +++ b/Server/src/main/kotlin/api/ContentAPI.kt @@ -889,6 +889,18 @@ object ContentAPI { player.packetDispatch.sendPlayerOnInterface(iface,child) } + /** + * Sends a dialogue that uses the player's chathead. + * @param player the player to send the dialogue to + * @param npc the ID of the NPC to use for the chathead + * @param msg the message to send. + * @param expr the FacialExpression to use. An enum exists for these called FacialExpression. Defaults to FacialExpression.FRIENDLY + */ + @JvmStatic + fun sendNPCDialogue(player: Player, npc: Int, msg: String, expr: FacialExpression = FacialExpression.FRIENDLY){ + player.dialogueInterpreter.sendDialogues(npc, expr, *DialUtils.splitLines(msg)) + } + /** * Sends an animation to a specific interface child * @param player the player to send the packet to @@ -972,4 +984,14 @@ object ContentAPI { fun submitIndividualPulse(entity: Entity, pulse: Pulse){ entity.pulseManager.run(pulse) } + + /** + * Gets the number of QP a player has + * @param player the player to get the QP for + * @return the number of QP the player has + */ + @JvmStatic + fun getQP(player: Player): Int{ + return player.questRepository.points + } } \ No newline at end of file diff --git a/Server/src/main/kotlin/rs09/game/content/global/action/EquipHandler.kt b/Server/src/main/kotlin/rs09/game/content/global/action/EquipHandler.kt index a6083ab63..30f389b6f 100644 --- a/Server/src/main/kotlin/rs09/game/content/global/action/EquipHandler.kt +++ b/Server/src/main/kotlin/rs09/game/content/global/action/EquipHandler.kt @@ -41,7 +41,7 @@ class EquipHandler : InteractionListener() { fun handleEquip(player: Player,node: Node){ val item = node.asItem() - if(item == null || player.inventory[item.slot] != item){ + if(item == null || player.inventory[item.slot] != item || item.name.toLowerCase().contains("goblin mail")){ return } @@ -52,7 +52,9 @@ class EquipHandler : InteractionListener() { return } } - InteractionListeners.run(node.id,player,node,true) + if(!InteractionListeners.run(node.id,player,node,true)){ + return + } val lock = player.locks.equipmentLock if (lock != null && lock.isLocked) { diff --git a/Server/src/main/kotlin/rs09/game/interaction/InteractionListener.kt b/Server/src/main/kotlin/rs09/game/interaction/InteractionListener.kt index 1b9edc614..7526cc706 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/InteractionListener.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/InteractionListener.kt @@ -28,10 +28,10 @@ abstract class InteractionListener : Listener{ fun onUseWith(type: Int, used: IntArray, vararg with: Int, handler: (player: Player, used: Node, with: Node) -> Boolean){ InteractionListeners.add(type,used,with,handler) } - fun onEquip(id: Int, handler: (player: Player, node: Node) -> Unit){ + fun onEquip(id: Int, handler: (player: Player, node: Node) -> Boolean){ InteractionListeners.addEquip(id,handler) } - fun onUnequip(id:Int, handler: (player: Player, node: Node) -> Unit){ + fun onUnequip(id:Int, handler: (player: Player, node: Node) -> Boolean){ InteractionListeners.addUnequip(id,handler) } diff --git a/Server/src/main/kotlin/rs09/game/interaction/InteractionListeners.kt b/Server/src/main/kotlin/rs09/game/interaction/InteractionListeners.kt index 4e2f5b1c4..25ce5f44c 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/InteractionListeners.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/InteractionListeners.kt @@ -10,7 +10,7 @@ object InteractionListeners { private val listeners = HashMap Boolean>(1000) private val useWithListeners = HashMap Boolean>(1000) private val destinationOverrides = HashMap Location>(100) - private val equipListeners = HashMap Unit>(10) + private val equipListeners = HashMap Boolean>(10) @JvmStatic fun add(id: Int, type: Int, option: Array, method: (Player,Node) -> Boolean){ @@ -53,22 +53,22 @@ object InteractionListeners { } @JvmStatic - fun addEquip(id: Int,method: (Player, Node) -> Unit){ + fun addEquip(id: Int,method: (Player, Node) -> Boolean){ equipListeners["equip:$id"] = method } @JvmStatic - fun addUnequip(id: Int, method: (Player,Node) -> Unit){ + fun addUnequip(id: Int, method: (Player,Node) -> Boolean){ equipListeners["unequip:$id"] = method } @JvmStatic - fun getEquip(id: Int): ((Player,Node) -> Unit)? { + fun getEquip(id: Int): ((Player,Node) -> Boolean)? { return equipListeners["equip:$id"] } @JvmStatic - fun getUnequip(id: Int): ((Player,Node) -> Unit)? { + fun getUnequip(id: Int): ((Player,Node) -> Boolean)? { return equipListeners["unequip:$id"] } @@ -124,11 +124,11 @@ object InteractionListeners { } @JvmStatic - fun run(id: Int, player: Player, node: Node, isEquip: Boolean){ + fun run(id: Int, player: Player, node: Node, isEquip: Boolean): Boolean{ if(isEquip){ - equipListeners["equip:$id"]?.invoke(player,node) + return equipListeners["equip:$id"]?.invoke(player,node)!! } else { - equipListeners["unequip:$id"]?.invoke(player,node) + return equipListeners["unequip:$id"]?.invoke(player,node)!! } } diff --git a/Server/src/main/kotlin/rs09/game/interaction/item/CulChestItems.kt b/Server/src/main/kotlin/rs09/game/interaction/item/CulChestItems.kt index 7ced37e7f..3d9a4efc4 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/item/CulChestItems.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/item/CulChestItems.kt @@ -42,7 +42,7 @@ class CulChestItems: InteractionListener() { } - fun alchemize(player: Player, node: Node){ + fun alchemize(player: Player, node: Node): Boolean{ val amount = ContentAPI.amountInInventory(player, node.id) + ContentAPI.amountInEquipment(player, node.id) val coins = amount * ContentAPI.itemDefinition(node.id).value @@ -51,5 +51,6 @@ class CulChestItems: InteractionListener() { ContentAPI.addItemOrDrop(player, 995, coins) ContentAPI.sendDialogue(player, "The item instantly alchemized itself!") + return false //tell equip handler not to equip the gloves at all if they still even exist lel } } \ No newline at end of file diff --git a/Server/src/main/kotlin/rs09/game/interaction/item/LegendsCapeLock.kt b/Server/src/main/kotlin/rs09/game/interaction/item/LegendsCapeLock.kt new file mode 100644 index 000000000..f4c4a86f8 --- /dev/null +++ b/Server/src/main/kotlin/rs09/game/interaction/item/LegendsCapeLock.kt @@ -0,0 +1,15 @@ +package rs09.game.interaction.item + +import api.ContentAPI +import org.rs09.consts.Items +import rs09.game.interaction.InteractionListener + +class LegendsCapeLock : InteractionListener() { + override fun defineListeners() { + onEquip(Items.CAPE_OF_LEGENDS_1052){player, node -> + val points = ContentAPI.getQP(player) + if(points < 40) ContentAPI.sendDialogue(player, "You need 40 QP to equip that.") + return@onEquip points >= 40 + } + } +} \ No newline at end of file diff --git a/Server/src/main/kotlin/rs09/game/interaction/item/withnpc/MistagEasterEgg.kt b/Server/src/main/kotlin/rs09/game/interaction/item/withnpc/MistagEasterEgg.kt index c5abf1209..ce131bc81 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/item/withnpc/MistagEasterEgg.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/item/withnpc/MistagEasterEgg.kt @@ -23,10 +23,12 @@ class MistagEasterEgg : InteractionListener() { onEquip(ZANIK_RING){player,_ -> player.appearance.transformNPC(NPCs.ZANIK_3712) + return@onEquip true } onUnequip(ZANIK_RING){player, _ -> player.appearance.transformNPC(-1) + return@onUnequip true } } }