Enchanting spells repeat if there are more of the same item in the player inventory

This commit is contained in:
randy 2025-05-06 10:57:31 -06:00
parent 7e8c2d8883
commit 52185005aa

View file

@ -14,6 +14,7 @@ import core.game.world.update.flag.context.Animation
import core.game.world.update.flag.context.Graphics
import core.plugin.Plugin
import org.rs09.consts.Items
import core.api.*
/**
* Represents the enchant spells.
@ -46,11 +47,12 @@ class EnchantSpell : MagicSpell {
if (target !is Item || entity !is Player) {
return false
}
entity.interfaceManager.setViewedTab(6)
//entity.interfaceManager.setViewedTab(6)
val enchanted = jewellery?.getOrDefault(target.id,null)
if (enchanted == null) {
entity.packetDispatch.sendMessage("You can't use this spell on this item.")
entity.interfaceManager.setViewedTab(6)
return false
}
if (!meetsRequirements(entity, true, true)) {
@ -89,6 +91,13 @@ class EnchantSpell : MagicSpell {
content.minigame.mta.impl.EnchantingZone.ZONE.incrementPoints(entity, MTAType.ENCHANTERS.ordinal, pizazz)
}
}
// Snowscape: if there are more items to enchant, run the spell again
if (entity.inventory.containsAtLeastOneItem(target)) {
runTask(entity, 2){
castSpell(entity as Player, super.book, super.spellId, target)
}
}
return true
}