Optimised, fixed and refactored container (bank/inventory/equipment) checks
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
package content.global.handlers.npc
|
||||
|
||||
import core.api.isEquipped
|
||||
import core.api.anyInEquipment
|
||||
import core.api.openDepositBox
|
||||
import core.api.sendNPCDialogue
|
||||
import core.api.setInterfaceText
|
||||
@@ -14,9 +14,7 @@ class NPCDepositListener : InteractionListener {
|
||||
|
||||
override fun defineListeners() {
|
||||
on(NPCs.PEER_THE_SEER_1288, IntType.NPC, "deposit") { player, _ ->
|
||||
if (isEquipped(player, Items.FREMENNIK_SEA_BOOTS_1_14571) ||
|
||||
isEquipped(player, Items.FREMENNIK_SEA_BOOTS_2_14572) ||
|
||||
isEquipped(player, Items.FREMENNIK_SEA_BOOTS_3_14573)) {
|
||||
if (anyInEquipment(player, Items.FREMENNIK_SEA_BOOTS_1_14571, Items.FREMENNIK_SEA_BOOTS_2_14572, Items.FREMENNIK_SEA_BOOTS_3_14573)) {
|
||||
openDepositBox(player)
|
||||
setInterfaceText(player, "Peer the Seer's Deposits", 11, 12)
|
||||
} else {
|
||||
|
||||
@@ -42,7 +42,7 @@ class CatherbyGrappleShortcut : InteractionListener {
|
||||
|
||||
on(Scenery.ROCKS_17042, IntType.SCENERY, "grapple") { player, _ ->
|
||||
if (isPlayerInRangeToGrapple(player)) {
|
||||
forceWalk(player, content.global.skill.agility.shortcuts.CatherbyGrappleShortcut.Companion.START_LOCATION, "smart")
|
||||
forceWalk(player, START_LOCATION, "smart")
|
||||
} else {
|
||||
sendMessage(player, "Nothing interesting happens.")
|
||||
return@on true
|
||||
@@ -56,10 +56,10 @@ class CatherbyGrappleShortcut : InteractionListener {
|
||||
if (!doesPlayerHaveRequiredLevels(player)) {
|
||||
sendDialogueLines(player,
|
||||
"You need at least " +
|
||||
content.global.skill.agility.shortcuts.CatherbyGrappleShortcut.Companion.REQUIREMENTS[Skills.AGILITY] + " " + Skills.SKILL_NAME[Skills.AGILITY] + ", " +
|
||||
content.global.skill.agility.shortcuts.CatherbyGrappleShortcut.Companion.REQUIREMENTS[Skills.RANGE] + " " + Skills.SKILL_NAME[Skills.RANGE] + ", ",
|
||||
REQUIREMENTS[Skills.AGILITY] + " " + Skills.SKILL_NAME[Skills.AGILITY] + ", " +
|
||||
REQUIREMENTS[Skills.RANGE] + " " + Skills.SKILL_NAME[Skills.RANGE] + ", ",
|
||||
"and " +
|
||||
content.global.skill.agility.shortcuts.CatherbyGrappleShortcut.Companion.REQUIREMENTS[Skills.STRENGTH] + " " + Skills.SKILL_NAME[Skills.STRENGTH] + " to use this shortcut."
|
||||
REQUIREMENTS[Skills.STRENGTH] + " " + Skills.SKILL_NAME[Skills.STRENGTH] + " to use this shortcut."
|
||||
)
|
||||
return@on true
|
||||
}
|
||||
@@ -70,7 +70,7 @@ class CatherbyGrappleShortcut : InteractionListener {
|
||||
override fun pulse() : Boolean {
|
||||
when (counter++) {
|
||||
1 -> {
|
||||
face(player, content.global.skill.agility.shortcuts.CatherbyGrappleShortcut.Companion.END_LOCATION)
|
||||
face(player, END_LOCATION)
|
||||
// Audit: shows player climbing (probably a wall), need a cliff climb animation
|
||||
animate(player, Animation(4455))
|
||||
}
|
||||
@@ -79,7 +79,7 @@ class CatherbyGrappleShortcut : InteractionListener {
|
||||
replaceScenery(rocks!!, rocks!!.id + 1, 10)
|
||||
}
|
||||
8 -> {
|
||||
teleport(player, content.global.skill.agility.shortcuts.CatherbyGrappleShortcut.Companion.END_LOCATION)
|
||||
teleport(player, END_LOCATION)
|
||||
}
|
||||
9 -> {
|
||||
sendMessage(player, "You successfully grapple the rock and climb the cliffside.")
|
||||
@@ -96,11 +96,11 @@ class CatherbyGrappleShortcut : InteractionListener {
|
||||
}
|
||||
|
||||
private fun doesPlayerHaveRequiredItemsEquipped(player: Player): Boolean {
|
||||
return isEquipped(player, Items.MITH_GRAPPLE_9419) && areAnyEquipped(player, *content.global.skill.agility.shortcuts.CatherbyGrappleShortcut.Companion.VALID_CROSSBOWS)
|
||||
return inEquipment(player, Items.MITH_GRAPPLE_9419) && anyInEquipment(player, *VALID_CROSSBOWS)
|
||||
}
|
||||
|
||||
private fun doesPlayerHaveRequiredLevels(player: Player): Boolean {
|
||||
for ((skill, requiredLevel) in content.global.skill.agility.shortcuts.CatherbyGrappleShortcut.Companion.REQUIREMENTS) {
|
||||
for ((skill, requiredLevel) in REQUIREMENTS) {
|
||||
if (!hasLevelDyn(player, skill, requiredLevel)) {
|
||||
return false
|
||||
}
|
||||
@@ -109,6 +109,6 @@ class CatherbyGrappleShortcut : InteractionListener {
|
||||
}
|
||||
|
||||
private fun isPlayerInRangeToGrapple(player: Player): Boolean {
|
||||
return inBorders(player, content.global.skill.agility.shortcuts.CatherbyGrappleShortcut.Companion.START_LOCATION.x - 2, content.global.skill.agility.shortcuts.CatherbyGrappleShortcut.Companion.START_LOCATION.y - 2, content.global.skill.agility.shortcuts.CatherbyGrappleShortcut.Companion.START_LOCATION.x, content.global.skill.agility.shortcuts.CatherbyGrappleShortcut.Companion.START_LOCATION.y)
|
||||
return inBorders(player, START_LOCATION.x - 2, START_LOCATION.y - 2, START_LOCATION.x, START_LOCATION.y)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package content.region.asgarnia.falador.diary
|
||||
|
||||
import core.api.areEquipped
|
||||
import core.api.allInEquipment
|
||||
import core.api.inBorders
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.entity.player.link.diary.DiaryType
|
||||
@@ -131,8 +131,8 @@ class FaladorAchievementDiary : DiaryEventHookBase(DiaryType.FALADOR) {
|
||||
DiaryLevel.HARD,
|
||||
HardTasks.DARK_WIZARDS_TOWER_ASCEND_IN_FULL_PROSELYTE_ARMOR,
|
||||
) { player ->
|
||||
areEquipped(player, *PROSELYTE_FULL_ARMOR_MALE)
|
||||
|| areEquipped(player, *PROSELYTE_FULL_ARMOR_FEMALE)
|
||||
allInEquipment(player, *PROSELYTE_FULL_ARMOR_MALE)
|
||||
|| allInEquipment(player, *PROSELYTE_FULL_ARMOR_FEMALE)
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ import core.game.world.update.flag.context.Graphics;
|
||||
import core.plugin.Plugin;
|
||||
import org.rs09.consts.Items;
|
||||
|
||||
import static core.api.ContentAPIKt.isEquipped;
|
||||
import static core.api.ContentAPIKt.allInEquipment;
|
||||
|
||||
/**
|
||||
* Represents the black knights fortress node option plugin.
|
||||
@@ -140,7 +140,7 @@ public final class BKFortressPlugin extends OptionHandler {
|
||||
case 2337: // Guard Door - only check for uniform from outside
|
||||
switch (player.getLocation().getY()) {
|
||||
case 3514: // Outside constant Y location, block the player for checks
|
||||
if(isEquipped(player, Items.BRONZE_MED_HELM_1139) && isEquipped(player, Items.IRON_CHAINBODY_1101)){
|
||||
if(allInEquipment(player, Items.BRONZE_MED_HELM_1139, Items.IRON_CHAINBODY_1101)){
|
||||
DoorActionHandler.handleAutowalkDoor(player, (Scenery) node);
|
||||
}
|
||||
else player.getDialogueInterpreter().open(4605, Repository.findNPC(4604), true);
|
||||
|
||||
@@ -115,7 +115,7 @@ class FightArenaListeners : InteractionListener {
|
||||
when (player.location.y) {
|
||||
3171 -> DoorActionHandler.handleAutowalkDoor(player, maingate.asScenery())
|
||||
3172 -> {
|
||||
if (isEquipped(player, HELMET) && isEquipped(player, ARMOUR)) {
|
||||
if (allInEquipment(player, HELMET, ARMOUR)) {
|
||||
openDialogue(player, EastDoorSupportDialogue())
|
||||
} else {
|
||||
sendPlayerDialogue(player, "This door appears to be locked.")
|
||||
@@ -126,7 +126,7 @@ class FightArenaListeners : InteractionListener {
|
||||
when (player.location.x) {
|
||||
2585 -> DoorActionHandler.handleAutowalkDoor(player, maingate.asScenery())
|
||||
2584 -> {
|
||||
if (isEquipped(player, HELMET) && isEquipped(player, ARMOUR)) {
|
||||
if (allInEquipment(player, HELMET, ARMOUR)) {
|
||||
openDialogue(player, WestDoorSupportDialogue())
|
||||
} else {
|
||||
sendPlayerDialogue(player, "This door appears to be locked.")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package content.region.kandarin.ardougne.quest.arena
|
||||
|
||||
import core.api.isEquipped
|
||||
import core.api.allInEquipment
|
||||
import core.game.dialogue.DialoguePlugin
|
||||
import core.game.dialogue.FacialExpression
|
||||
import core.game.node.entity.npc.NPC
|
||||
@@ -14,7 +14,7 @@ import org.rs09.consts.NPCs
|
||||
class FightslaveDialogue(player: Player? = null) : DialoguePlugin(player) {
|
||||
override fun open(vararg args: Any?): Boolean {
|
||||
npc = args[0] as NPC
|
||||
if (isEquipped(player!!, Items.KHAZARD_HELMET_74) && isEquipped(player!!, Items.KHAZARD_ARMOUR_75)) {
|
||||
if (allInEquipment(player, Items.KHAZARD_HELMET_74, Items.KHAZARD_ARMOUR_75)) {
|
||||
playerl(FacialExpression.FRIENDLY, "Do you know of a Justin or Jeremy in this arena?").also { stage = 0 }
|
||||
} else {
|
||||
playerl(FacialExpression.FRIENDLY, "Do you know of a Justin or Jeremy in this arena?").also { stage = 1 }
|
||||
|
||||
@@ -7,6 +7,7 @@ import core.game.dialogue.FacialExpression
|
||||
import core.game.node.entity.npc.NPC
|
||||
import core.game.world.map.RegionManager
|
||||
import core.tools.END_DIALOGUE
|
||||
import org.rs09.consts.Items
|
||||
import org.rs09.consts.NPCs.GENERAL_KHAZARD_258
|
||||
|
||||
class GeneralKhazardDialogue : DialogueFile() {
|
||||
@@ -20,7 +21,7 @@ class GeneralKhazardDialogue : DialogueFile() {
|
||||
|
||||
(questStage == 71) -> {
|
||||
when (stage) {
|
||||
0 -> if (!isEquipped(player!!, 74) && !isEquipped(player!!, 75)) {
|
||||
0 -> if (!anyInEquipment(player!!, Items.KHAZARD_HELMET_74, Items.KHAZARD_ARMOUR_75)) {
|
||||
sendPlayerDialogue(player!!, "General Khazard?").also { stage = 2 }
|
||||
} else {
|
||||
sendNPCDialogue(player!!, 258, "Who dares enter my home? You? A feeble traveller?").also { stage = 6 }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package content.region.kandarin.ardougne.quest.arena
|
||||
|
||||
import core.api.isEquipped
|
||||
import core.api.allInEquipment
|
||||
import core.game.dialogue.DialoguePlugin
|
||||
import core.game.dialogue.FacialExpression
|
||||
import core.game.node.entity.npc.NPC
|
||||
@@ -16,7 +16,7 @@ class GuardsDialogue(player: Player? = null) : DialoguePlugin(player) {
|
||||
|
||||
override fun open(vararg args: Any?): Boolean {
|
||||
npc = args[0] as NPC
|
||||
if (isEquipped(player!!, Items.KHAZARD_HELMET_74) && isEquipped(player!!, Items.KHAZARD_ARMOUR_75)) {
|
||||
if (allInEquipment(player, Items.KHAZARD_HELMET_74, Items.KHAZARD_ARMOUR_75)) {
|
||||
playerl(FacialExpression.FRIENDLY, "Hello.").also { stage = 0 }
|
||||
} else {
|
||||
playerl(FacialExpression.FRIENDLY, "Hi.").also { stage = 2 }
|
||||
@@ -49,7 +49,7 @@ class GuardsDialogue(player: Player? = null) : DialoguePlugin(player) {
|
||||
class KhazardGuard254Dialogue(player: Player? = null) : DialoguePlugin(player) {
|
||||
override fun open(vararg args: Any?): Boolean {
|
||||
npc = args[0] as NPC
|
||||
if (isEquipped(player!!, Items.KHAZARD_HELMET_74) && isEquipped(player!!, Items.KHAZARD_ARMOUR_75)) {
|
||||
if (allInEquipment(player, Items.KHAZARD_HELMET_74, Items.KHAZARD_ARMOUR_75)) {
|
||||
playerl(FacialExpression.FRIENDLY, "Hello.").also { stage = 0 }
|
||||
} else {
|
||||
playerl(FacialExpression.FRIENDLY, "Hi.").also { stage = 7 }
|
||||
@@ -90,7 +90,7 @@ class KhazardGuard254Dialogue(player: Player? = null) : DialoguePlugin(player) {
|
||||
class KhazardGuard255Dialogue(player: Player? = null) : DialoguePlugin(player) {
|
||||
override fun open(vararg args: Any?): Boolean {
|
||||
npc = args[0] as NPC
|
||||
if (isEquipped(player!!, Items.KHAZARD_HELMET_74) && isEquipped(player!!, Items.KHAZARD_ARMOUR_75)) {
|
||||
if (allInEquipment(player, Items.KHAZARD_HELMET_74, Items.KHAZARD_ARMOUR_75)) {
|
||||
playerl(FacialExpression.FRIENDLY, "Hello.").also { stage = 0 }
|
||||
} else {
|
||||
playerl(FacialExpression.FRIENDLY, "Hi.").also { stage = 2 }
|
||||
@@ -123,7 +123,7 @@ class KhazardGuard255Dialogue(player: Player? = null) : DialoguePlugin(player) {
|
||||
class KhazardGuard256Dialogue(player: Player? = null) : DialoguePlugin(player) {
|
||||
override fun open(vararg args: Any?): Boolean {
|
||||
npc = args[0] as NPC
|
||||
if (isEquipped(player!!, Items.KHAZARD_HELMET_74) && isEquipped(player!!, Items.KHAZARD_ARMOUR_75)) {
|
||||
if (allInEquipment(player, Items.KHAZARD_HELMET_74, Items.KHAZARD_ARMOUR_75)) {
|
||||
playerl(FacialExpression.FRIENDLY, "Hello.").also { stage = 0 }
|
||||
} else {
|
||||
playerl(FacialExpression.FRIENDLY, "Hi.").also { stage = 3 }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package content.region.kandarin.ardougne.quest.arena
|
||||
|
||||
import core.api.isEquipped
|
||||
import core.api.allInEquipment
|
||||
import core.api.sendNPCDialogue
|
||||
import core.game.dialogue.DialoguePlugin
|
||||
import core.game.dialogue.FacialExpression
|
||||
@@ -16,7 +16,7 @@ class JoeDialogue(player: Player? = null) : DialoguePlugin(player) {
|
||||
|
||||
override fun open(vararg args: Any?): Boolean {
|
||||
npc = args[0] as NPC
|
||||
if (isEquipped(player!!, Items.KHAZARD_HELMET_74) && isEquipped(player!!, Items.KHAZARD_ARMOUR_75)) {
|
||||
if (allInEquipment(player, Items.KHAZARD_HELMET_74, Items.KHAZARD_ARMOUR_75)) {
|
||||
playerl(FacialExpression.FRIENDLY, "Do you know of a Justin or Jeremy in this arena?").also { stage = 0 }
|
||||
} else {
|
||||
playerl(FacialExpression.FRIENDLY, "Do you know of a Justin or Jeremy in this arena?").also { stage = 3 }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package content.region.kandarin.ardougne.quest.arena
|
||||
|
||||
import core.api.isEquipped
|
||||
import core.api.allInEquipment
|
||||
import core.api.sendNPCDialogue
|
||||
import core.game.dialogue.DialoguePlugin
|
||||
import core.game.dialogue.FacialExpression
|
||||
@@ -15,7 +15,7 @@ import org.rs09.consts.NPCs
|
||||
class KelvinDialogue(player: Player? = null) : DialoguePlugin(player) {
|
||||
override fun open(vararg args: Any?): Boolean {
|
||||
npc = args[0] as NPC
|
||||
if (isEquipped(player, Items.KHAZARD_HELMET_74) && isEquipped(player, Items.KHAZARD_ARMOUR_75)) {
|
||||
if (allInEquipment(player, Items.KHAZARD_HELMET_74, Items.KHAZARD_ARMOUR_75)) {
|
||||
sendNPCDialogue(player, NPCs.KELVIN_260, "Get away, get away. One day I'll have my revenge, and I'll have all your heads.", FacialExpression.ANNOYED).also { stage = END_DIALOGUE }
|
||||
} else {
|
||||
sendNPCDialogue(player, NPCs.KELVIN_260, "You're not safe here traveller. Leave while you still can", FacialExpression.FRIENDLY).also { stage = END_DIALOGUE }
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package content.region.kandarin.seers.diary
|
||||
|
||||
import core.api.*
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.entity.player.link.diary.DiaryType
|
||||
import core.game.node.item.Item
|
||||
@@ -10,6 +9,8 @@ import org.rs09.consts.Items
|
||||
import org.rs09.consts.NPCs
|
||||
import content.global.handlers.iface.FairyRing
|
||||
import content.global.handlers.item.withnpc.PoisonChaliceOnKingArthurDialogue
|
||||
import core.api.inBorders
|
||||
import core.api.inEquipment
|
||||
import core.game.diary.DiaryEventHookBase
|
||||
import core.game.diary.DiaryLevel
|
||||
import core.game.event.*
|
||||
@@ -142,7 +143,7 @@ class SeersVillageAchivementDiary : DiaryEventHookBase(DiaryType.SEERS_VILLAGE)
|
||||
}
|
||||
|
||||
Items.SHARK_385 -> {
|
||||
if (isEquipped(player, Items.COOKING_GAUNTLETS_775)) {
|
||||
if (inEquipment(player, Items.COOKING_GAUNTLETS_775)) {
|
||||
progressIncrementalTask(
|
||||
player,
|
||||
DiaryLevel.HARD,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package content.region.misc.zanaris.handlers
|
||||
|
||||
import core.api.isEquipped
|
||||
import core.api.anyInEquipment
|
||||
import core.api.isQuestComplete
|
||||
import core.game.component.Component
|
||||
import core.game.node.entity.player.Player
|
||||
@@ -42,11 +42,11 @@ class FairyRingPlugin : InteractionListener {
|
||||
}
|
||||
|
||||
private fun fairyMagic(player: Player) : Boolean {
|
||||
if(!isQuestComplete(player,"Lost City")) { // should be converted to a FTP2 stage requirement once FTP2 is implemented
|
||||
if (!isQuestComplete(player,"Lost City")) { // should be converted to a FTP2 stage requirement once FTP2 is implemented
|
||||
player.sendMessage("The fairy ring is inert.")
|
||||
return false
|
||||
}
|
||||
if(!isEquipped(player, Items.DRAMEN_STAFF_772) && !isEquipped(player,Items.LUNAR_STAFF_9084)) {
|
||||
if (!anyInEquipment(player, Items.DRAMEN_STAFF_772, Items.LUNAR_STAFF_9084)) {
|
||||
player.sendMessage("The fairy ring only works for those who wield fairy magic.")
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user