Fixed skill cape perks not applying correctly

This commit is contained in:
Bishop
2026-01-22 13:05:24 +00:00
committed by Ryan
parent 6f6ea174ed
commit 6e9cd98e38
2 changed files with 36 additions and 13 deletions
@@ -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<Int>()
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
}
}
}
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)
}
}
}
@@ -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) {