Convert skillcape perk activation to an interaction listener, fixes HP cape giving perm boost
This commit is contained in:
+13
-26
@@ -1,40 +1,27 @@
|
|||||||
package rs09.game.node.entity.skill.skillcapeperks
|
package rs09.game.node.entity.skill.skillcapeperks
|
||||||
|
|
||||||
import core.cache.def.impl.ItemDefinition
|
import rs09.game.interaction.InteractionListener
|
||||||
import core.game.node.entity.player.Player
|
|
||||||
import core.game.node.item.Item
|
|
||||||
import core.plugin.Initializable
|
|
||||||
import core.plugin.Plugin
|
|
||||||
|
|
||||||
@Initializable
|
class SkillcapeEquipmentPlugin : InteractionListener {
|
||||||
class SkillcapeEquipmentPlugin : Plugin<Item> {
|
override fun defineListeners() {
|
||||||
override fun newInstance(arg: Item?): Plugin<Item> {
|
val capeIds = ArrayList<Int>()
|
||||||
for(cape in core.game.content.global.SkillcapePerks.values()){
|
for(cape in core.game.content.global.SkillcapePerks.values()){
|
||||||
cape.skillcapeIds.forEach {
|
cape.skillcapeIds.forEach { capeIds.add(it) }
|
||||||
ItemDefinition.forId(it).handlers["equipment"] = this
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this
|
|
||||||
}
|
}
|
||||||
|
val capes = capeIds.toIntArray()
|
||||||
|
|
||||||
override fun fireEvent(identifier: String?, vararg args: Any?): Any {
|
onEquip(capes){player, node ->
|
||||||
val player = args[0] as Player
|
val skillcape = Skillcape.forId(node.id)
|
||||||
val id = (args[1] as Item).id
|
|
||||||
|
|
||||||
val skillcape = Skillcape.forId(id)
|
|
||||||
val perk = SkillcapePerks.forSkillcape(skillcape)
|
val perk = SkillcapePerks.forSkillcape(skillcape)
|
||||||
|
|
||||||
when(identifier){
|
|
||||||
|
|
||||||
"equip" -> {
|
|
||||||
perk.activate(player)
|
perk.activate(player)
|
||||||
|
return@onEquip true
|
||||||
}
|
}
|
||||||
|
|
||||||
"unequip" -> {
|
onUnequip(capes){player, node ->
|
||||||
|
val skillcape = Skillcape.forId(node.id)
|
||||||
|
val perk = SkillcapePerks.forSkillcape(skillcape)
|
||||||
perk.deactivate(player)
|
perk.deactivate(player)
|
||||||
|
return@onUnequip true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user