Lock legends cape behind 40 QP

This commit is contained in:
ceikry
2021-06-29 17:39:21 -05:00
parent 932d64b84f
commit dc4367fd53
8 changed files with 66 additions and 13 deletions
@@ -10,6 +10,7 @@ import core.game.node.entity.npc.NPC
import core.game.node.entity.player.Player import core.game.node.entity.player.Player
import core.plugin.Plugin import core.plugin.Plugin
import core.game.node.entity.skill.crafting.TanningProduct import core.game.node.entity.skill.crafting.TanningProduct
import org.rs09.consts.NPCs
import rs09.game.interaction.InteractionListener import rs09.game.interaction.InteractionListener
/** /**
@@ -31,6 +32,16 @@ class NPCTradePlugin : InteractionListener() {
} }
return@on npc.openShop(player) 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() { override fun defineDestinationOverrides() {
+22
View File
@@ -889,6 +889,18 @@ object ContentAPI {
player.packetDispatch.sendPlayerOnInterface(iface,child) 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 * Sends an animation to a specific interface child
* @param player the player to send the packet to * @param player the player to send the packet to
@@ -972,4 +984,14 @@ object ContentAPI {
fun submitIndividualPulse(entity: Entity, pulse: Pulse){ fun submitIndividualPulse(entity: Entity, pulse: Pulse){
entity.pulseManager.run(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
}
} }
@@ -41,7 +41,7 @@ class EquipHandler : InteractionListener() {
fun handleEquip(player: Player,node: Node){ fun handleEquip(player: Player,node: Node){
val item = node.asItem() 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 return
} }
@@ -52,7 +52,9 @@ class EquipHandler : InteractionListener() {
return return
} }
} }
InteractionListeners.run(node.id,player,node,true) if(!InteractionListeners.run(node.id,player,node,true)){
return
}
val lock = player.locks.equipmentLock val lock = player.locks.equipmentLock
if (lock != null && lock.isLocked) { if (lock != null && lock.isLocked) {
@@ -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){ fun onUseWith(type: Int, used: IntArray, vararg with: Int, handler: (player: Player, used: Node, with: Node) -> Boolean){
InteractionListeners.add(type,used,with,handler) 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) 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) InteractionListeners.addUnequip(id,handler)
} }
@@ -10,7 +10,7 @@ object InteractionListeners {
private val listeners = HashMap<String,(Player, Node) -> Boolean>(1000) private val listeners = HashMap<String,(Player, Node) -> Boolean>(1000)
private val useWithListeners = HashMap<String,(Player,Node,Node) -> Boolean>(1000) private val useWithListeners = HashMap<String,(Player,Node,Node) -> Boolean>(1000)
private val destinationOverrides = HashMap<String,(Node) -> Location>(100) private val destinationOverrides = HashMap<String,(Node) -> Location>(100)
private val equipListeners = HashMap<String,(Player,Node) -> Unit>(10) private val equipListeners = HashMap<String,(Player,Node) -> Boolean>(10)
@JvmStatic @JvmStatic
fun add(id: Int, type: Int, option: Array<out String>, method: (Player,Node) -> Boolean){ fun add(id: Int, type: Int, option: Array<out String>, method: (Player,Node) -> Boolean){
@@ -53,22 +53,22 @@ object InteractionListeners {
} }
@JvmStatic @JvmStatic
fun addEquip(id: Int,method: (Player, Node) -> Unit){ fun addEquip(id: Int,method: (Player, Node) -> Boolean){
equipListeners["equip:$id"] = method equipListeners["equip:$id"] = method
} }
@JvmStatic @JvmStatic
fun addUnequip(id: Int, method: (Player,Node) -> Unit){ fun addUnequip(id: Int, method: (Player,Node) -> Boolean){
equipListeners["unequip:$id"] = method equipListeners["unequip:$id"] = method
} }
@JvmStatic @JvmStatic
fun getEquip(id: Int): ((Player,Node) -> Unit)? { fun getEquip(id: Int): ((Player,Node) -> Boolean)? {
return equipListeners["equip:$id"] return equipListeners["equip:$id"]
} }
@JvmStatic @JvmStatic
fun getUnequip(id: Int): ((Player,Node) -> Unit)? { fun getUnequip(id: Int): ((Player,Node) -> Boolean)? {
return equipListeners["unequip:$id"] return equipListeners["unequip:$id"]
} }
@@ -124,11 +124,11 @@ object InteractionListeners {
} }
@JvmStatic @JvmStatic
fun run(id: Int, player: Player, node: Node, isEquip: Boolean){ fun run(id: Int, player: Player, node: Node, isEquip: Boolean): Boolean{
if(isEquip){ if(isEquip){
equipListeners["equip:$id"]?.invoke(player,node) return equipListeners["equip:$id"]?.invoke(player,node)!!
} else { } else {
equipListeners["unequip:$id"]?.invoke(player,node) return equipListeners["unequip:$id"]?.invoke(player,node)!!
} }
} }
@@ -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 amount = ContentAPI.amountInInventory(player, node.id) + ContentAPI.amountInEquipment(player, node.id)
val coins = amount * ContentAPI.itemDefinition(node.id).value val coins = amount * ContentAPI.itemDefinition(node.id).value
@@ -51,5 +51,6 @@ class CulChestItems: InteractionListener() {
ContentAPI.addItemOrDrop(player, 995, coins) ContentAPI.addItemOrDrop(player, 995, coins)
ContentAPI.sendDialogue(player, "The item instantly alchemized itself!") 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
} }
} }
@@ -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
}
}
}
@@ -23,10 +23,12 @@ class MistagEasterEgg : InteractionListener() {
onEquip(ZANIK_RING){player,_ -> onEquip(ZANIK_RING){player,_ ->
player.appearance.transformNPC(NPCs.ZANIK_3712) player.appearance.transformNPC(NPCs.ZANIK_3712)
return@onEquip true
} }
onUnequip(ZANIK_RING){player, _ -> onUnequip(ZANIK_RING){player, _ ->
player.appearance.transformNPC(-1) player.appearance.transformNPC(-1)
return@onUnequip true
} }
} }
} }