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 package content.global.skill.skillcapeperks
import core.api.sendMessage import core.api.sendMessage
import core.game.container.Container
import core.game.interaction.InteractionListener import core.game.interaction.InteractionListener
import core.game.node.entity.player.Player
import core.game.world.GameWorld 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 { class SkillcapeEquipmentPlugin : InteractionListener {
override fun defineListeners() { override fun defineListeners() {
val capeIds = ArrayList<Int>() val capeIds = ArrayList<Int>()
for(cape in content.data.skill.SkillcapePerks.values()){ for(cape in DataSkillcapes.values()){
cape.skillcapeIds.forEach { capeIds.add(it) } cape.skillcapeIds.forEach { capeIds.add(it) }
} }
val capes = capeIds.toIntArray() val capes = capeIds.toIntArray()
onEquip(capes){player, node -> true}
onEquip(capes){player, node ->
val skillcape = Skillcape.forId(node.id)
val perk = SkillcapePerks.forSkillcape(skillcape)
perk.activate(player)
return@onEquip true
}
onUnequip(capes){player, node -> onUnequip(capes){player, node ->
val skillcape = Skillcape.forId(node.id) 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). // 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.") sendMessage(player, "Unequipping that skillcape would leave you without a light source.")
return@onUnequip false return@onUnequip false
} }
val perk = SkillcapePerks.forSkillcape(skillcape) val perk = SkillcapePerks.forSkillcape(skillcape)
perk.deactivate(player) perk.deactivate(player)
return@onUnequip true 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; package core.game.container.impl;
import content.global.skill.skillcapeperks.SkillcapeEquipmentPlugin;
import content.global.skill.skillcapeperks.SkillcapePerks; import content.global.skill.skillcapeperks.SkillcapePerks;
import core.game.container.Container; import core.game.container.Container;
import core.game.container.ContainerEvent; import core.game.container.ContainerEvent;
@@ -276,6 +277,8 @@ public final class EquipmentContainer extends Container {
updateDefenceAnimation = true; updateDefenceAnimation = true;
} else if (slot == EquipmentContainer.SLOT_SHIELD) { } else if (slot == EquipmentContainer.SLOT_SHIELD) {
updateDefenceAnimation = true; updateDefenceAnimation = true;
} else if (slot == EquipmentContainer.SLOT_CAPE) {
SkillcapeEquipmentPlugin.updateCapePerks(player, c, slot);
} }
} }
if (updateDefenceAnimation) { if (updateDefenceAnimation) {