mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-10 10:20:41 -07:00
Jewelry fix
This commit is contained in:
parent
ad5ad6333c
commit
e4a465a082
1 changed files with 42 additions and 41 deletions
|
|
@ -11,6 +11,7 @@ import core.game.node.entity.player.Player
|
|||
import core.game.node.entity.player.link.TeleportManager
|
||||
import core.game.node.item.Item
|
||||
import core.game.system.task.Pulse
|
||||
import core.game.world.GameWorld
|
||||
import core.game.world.map.Location
|
||||
import core.game.world.update.flag.context.Animation
|
||||
import core.game.world.update.flag.context.Graphics
|
||||
|
|
@ -20,7 +21,7 @@ import org.rs09.consts.Sounds
|
|||
import java.util.*
|
||||
|
||||
/**
|
||||
* Represents an enchanted jewellery.
|
||||
* Represents a piece of enchanted jewellery.
|
||||
* @author Vexia, downthecrop, Player Name
|
||||
*/
|
||||
enum class EnchantedJewellery(
|
||||
|
|
@ -238,35 +239,50 @@ enum class EnchantedJewellery(
|
|||
if (!canTeleport(player, nextJewellery)) {
|
||||
return false
|
||||
}
|
||||
Pulser.submit(object : Pulse(0) {
|
||||
private var count = 0
|
||||
private var location = getLocation(buttonID)
|
||||
override fun pulse(): Boolean {
|
||||
when (count) {
|
||||
0 -> {
|
||||
lock(player,4)
|
||||
visualize(player, ANIMATION, GRAPHICS)
|
||||
playGlobalAudio(player.location, Sounds.TELEPORT_ALL_200)
|
||||
player.impactHandler.disabledTicks = 4
|
||||
closeInterface(player)
|
||||
}
|
||||
3 -> {
|
||||
teleport(player,location)
|
||||
resetAnimator(player)
|
||||
if (isLastItemIndex(itemIndex)) {
|
||||
if (isCrumble) crumbleJewellery(player, item, isEquipped)
|
||||
} else {
|
||||
replaceJewellery(player, item, nextJewellery, isEquipped)
|
||||
val location = getLocation(buttonID)
|
||||
player.scripts.delay = GameWorld.ticks + 4
|
||||
queueScript(player, 0, QueueStrength.SOFT) { stage ->
|
||||
when (stage) {
|
||||
0 -> {
|
||||
lock(player, 4)
|
||||
visualize(player, ANIMATION, GRAPHICS)
|
||||
playGlobalAudio(player.location, Sounds.TELEPORT_ALL_200)
|
||||
player.impactHandler.disabledTicks = 4
|
||||
closeInterface(player)
|
||||
return@queueScript delayScript(player, 3)
|
||||
}
|
||||
1 -> {
|
||||
teleport(player, location)
|
||||
resetAnimator(player)
|
||||
unlock(player)
|
||||
player.dispatch(TeleportEvent(TeleportManager.TeleportType.NORMAL, TeleportMethod.JEWELRY, item, location))
|
||||
if (isLastItemIndex(itemIndex)) {
|
||||
if (isSlayerRing(item)) {
|
||||
if (isEquipped) {
|
||||
// Remove it now, but only addItemOrDrop the gem after the teleport has procced
|
||||
removeItem(player, item, Container.INVENTORY)
|
||||
return@queueScript delayScript(player, 1)
|
||||
}
|
||||
// Not equipped -> can replace fluently
|
||||
replaceSlot(player, item.slot, Item(Items.ENCHANTED_GEM_4155), item)
|
||||
return@queueScript stopExecuting(player)
|
||||
}
|
||||
unlock(player)
|
||||
player.dispatch(TeleportEvent(TeleportManager.TeleportType.NORMAL, TeleportMethod.JEWELRY, item, location))
|
||||
return true
|
||||
// Not slayer ring
|
||||
if (isCrumble) {
|
||||
val removeFrom = if (isEquipped) Container.EQUIPMENT else Container.INVENTORY
|
||||
removeItem(player, item, removeFrom)
|
||||
}
|
||||
} else {
|
||||
replaceJewellery(player, item, nextJewellery, isEquipped)
|
||||
}
|
||||
}
|
||||
count += 1
|
||||
return false
|
||||
2 -> {
|
||||
addItemOrDrop(player, Items.ENCHANTED_GEM_4155)
|
||||
sendMessage(player, "Your Ring of Slaying reverts back into a regular enchanted gem.")
|
||||
}
|
||||
}
|
||||
})
|
||||
return@queueScript stopExecuting(player)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
@ -278,21 +294,6 @@ enum class EnchantedJewellery(
|
|||
}
|
||||
}
|
||||
|
||||
private fun crumbleJewellery(player: Player, item: Item, isEquipped: Boolean) {
|
||||
if (isEquipped) {
|
||||
removeItem(player, item, Container.EQUIPMENT)
|
||||
} else {
|
||||
removeItem(player, item)
|
||||
}
|
||||
if (isSlayerRing(item)) {
|
||||
queueScript(player, 1, QueueStrength.SOFT) {
|
||||
addItemOrDrop(player, Items.ENCHANTED_GEM_4155)
|
||||
sendMessage(player, "Your Ring of Slaying reverts back into a regular enchanted gem.")
|
||||
return@queueScript stopExecuting(player)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun isSlayerRing(item: Item): Boolean {
|
||||
return (item.id in RING_OF_SLAYING.ids)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue