From 6e9cd98e385b31446bf64343a0a55476a17d506a Mon Sep 17 00:00:00 2001 From: Bishop Date: Thu, 22 Jan 2026 13:05:24 +0000 Subject: [PATCH] Fixed skill cape perks not applying correctly --- .../SkillcapeEquipmentPlugin.kt | 46 +++++++++++++------ .../container/impl/EquipmentContainer.java | 3 ++ 2 files changed, 36 insertions(+), 13 deletions(-) diff --git a/Server/src/main/content/global/skill/skillcapeperks/SkillcapeEquipmentPlugin.kt b/Server/src/main/content/global/skill/skillcapeperks/SkillcapeEquipmentPlugin.kt index 36a76e8cd..7de63cfd9 100644 --- a/Server/src/main/content/global/skill/skillcapeperks/SkillcapeEquipmentPlugin.kt +++ b/Server/src/main/content/global/skill/skillcapeperks/SkillcapeEquipmentPlugin.kt @@ -1,36 +1,56 @@ package content.global.skill.skillcapeperks import core.api.sendMessage +import core.game.container.Container import core.game.interaction.InteractionListener +import core.game.node.entity.player.Player import core.game.world.GameWorld +import core.game.container.impl.EquipmentContainer +import content.data.skill.SkillcapePerks as DataSkillcapes +import content.global.skill.slayer.SlayerEquipmentFlags +import org.rs09.consts.Items +import java.util.ArrayList class SkillcapeEquipmentPlugin : InteractionListener { override fun defineListeners() { val capeIds = ArrayList() - for(cape in content.data.skill.SkillcapePerks.values()){ + for(cape in DataSkillcapes.values()){ cape.skillcapeIds.forEach { capeIds.add(it) } } val capes = capeIds.toIntArray() - - onEquip(capes){player, node -> - val skillcape = Skillcape.forId(node.id) - val perk = SkillcapePerks.forSkillcape(skillcape) - perk.activate(player) - return@onEquip true - } - + onEquip(capes){player, node -> true} onUnequip(capes){player, node -> val skillcape = Skillcape.forId(node.id) - // For Temple of Ikov. Do not let player unequip firemaking skillcape in the dark basement (need to keep an active light source). - if(player.location.isInRegion(10648) && (node.id == 9804 || node.id == 9805) && GameWorld.settings?.skillcape_perks == true) { + if(player.location.isInRegion(10648) && (node.id == Items.FIREMAKING_CAPE_9804 || node.id == Items.FIREMAKING_CAPET_9805) && GameWorld.settings?.skillcape_perks == true) { sendMessage(player, "Unequipping that skillcape would leave you without a light source.") return@onUnequip false } - val perk = SkillcapePerks.forSkillcape(skillcape) perk.deactivate(player) return@onUnequip true } } -} \ No newline at end of file + companion object { + @JvmStatic + fun updateCapePerks(player: Player, c: Container, slot: Int) { + if (slot == EquipmentContainer.SLOT_CAPE) { + val cape = c.get(slot) + for (perk in SkillcapePerks.values()) { + if (SkillcapePerks.isActive(perk, player)) { + perk.deactivate(player) + } + } + if (cape != null) { + val skillcape = Skillcape.forId(cape.id) + val perk = SkillcapePerks.forSkillcape(skillcape) + if (perk != SkillcapePerks.NONE) { + perk.activate(player) + } + } + } + EquipmentContainer.updateBonuses(player) + SlayerEquipmentFlags.updateFlags(player) + } + } +} diff --git a/Server/src/main/core/game/container/impl/EquipmentContainer.java b/Server/src/main/core/game/container/impl/EquipmentContainer.java index d2eb70398..8e01c91cc 100644 --- a/Server/src/main/core/game/container/impl/EquipmentContainer.java +++ b/Server/src/main/core/game/container/impl/EquipmentContainer.java @@ -1,5 +1,6 @@ package core.game.container.impl; +import content.global.skill.skillcapeperks.SkillcapeEquipmentPlugin; import content.global.skill.skillcapeperks.SkillcapePerks; import core.game.container.Container; import core.game.container.ContainerEvent; @@ -276,6 +277,8 @@ public final class EquipmentContainer extends Container { updateDefenceAnimation = true; } else if (slot == EquipmentContainer.SLOT_SHIELD) { updateDefenceAnimation = true; + } else if (slot == EquipmentContainer.SLOT_CAPE) { + SkillcapeEquipmentPlugin.updateCapePerks(player, c, slot); } } if (updateDefenceAnimation) {