mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-10 10:20:41 -07:00
Fixed bug causing loss of xp when interrupted burying bones
This commit is contained in:
parent
ddb9b6f0b0
commit
1f6b0e900f
1 changed files with 23 additions and 47 deletions
|
|
@ -5,6 +5,7 @@ import core.game.event.BoneBuryEvent
|
||||||
import core.game.interaction.Clocks
|
import core.game.interaction.Clocks
|
||||||
import core.game.interaction.IntType
|
import core.game.interaction.IntType
|
||||||
import core.game.interaction.InteractionListener
|
import core.game.interaction.InteractionListener
|
||||||
|
import core.game.interaction.QueueStrength
|
||||||
import core.game.node.entity.player.Player
|
import core.game.node.entity.player.Player
|
||||||
import core.game.node.entity.skill.Skills
|
import core.game.node.entity.skill.Skills
|
||||||
import core.game.node.item.Item
|
import core.game.node.item.Item
|
||||||
|
|
@ -13,62 +14,37 @@ import org.rs09.consts.Sounds
|
||||||
|
|
||||||
class BoneBuryListener : InteractionListener {
|
class BoneBuryListener : InteractionListener {
|
||||||
override fun defineListeners() {
|
override fun defineListeners() {
|
||||||
/**
|
|
||||||
|
/*
|
||||||
* Handles the bury options for bones in Bones.kt
|
* Handles the bury options for bones in Bones.kt
|
||||||
*/
|
*/
|
||||||
on(Bones.array, IntType.ITEM, "bury") { player, node ->
|
on(Bones.array, IntType.ITEM, "bury") { player, node ->
|
||||||
val bones = Bones.forId(node.id) ?: return@on true
|
val bones = Bones.forId(node.id) ?: return@on true
|
||||||
|
if (!clockReady(player, Clocks.SKILLING)) return@on true
|
||||||
|
if (!inInventory(player, node.id)) return@on true
|
||||||
|
|
||||||
// Checks if the player is delayed from burying a bone and begins the clock if none exists.
|
|
||||||
if (!clockReady(player, Clocks.SKILLING)) {
|
|
||||||
return@on true
|
|
||||||
} else {
|
|
||||||
delayClock(player, Clocks.SKILLING, 2)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verifies the bones are in the player's inventory.
|
|
||||||
if (!inInventory(player, bones.itemId)) {
|
|
||||||
return@on true
|
|
||||||
}
|
|
||||||
|
|
||||||
// Replaces the bones slot in the inventory with nothing and checks that the bones are removed.
|
|
||||||
if (replaceSlot(player, node.asItem().slot, Item()) != node.asItem()) {
|
|
||||||
sendMessage(player, "The gods intervene and you keep your bones!")
|
|
||||||
return@on true
|
|
||||||
}
|
|
||||||
|
|
||||||
buryBones(player, bones)
|
|
||||||
return@on true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Buries the bones
|
|
||||||
* @param player the player burying the bones
|
|
||||||
* @param bones the bones being buried
|
|
||||||
*/
|
|
||||||
private fun buryBones(player: Player, bones: Bones): Boolean {
|
|
||||||
queueScript(player, 0) { stage ->
|
|
||||||
when (stage) {
|
|
||||||
0 -> {
|
|
||||||
stopWalk(player)
|
stopWalk(player)
|
||||||
lock(player, 2)
|
lock(player, 2)
|
||||||
|
delayClock(player, Clocks.SKILLING, 2)
|
||||||
|
sendMessage(player, "You dig a hole in the ground.")
|
||||||
animate(player, Animations.HUMAN_BURYING_BONES_827)
|
animate(player, Animations.HUMAN_BURYING_BONES_827)
|
||||||
playAudio(player, Sounds.BONES_DOWN_2738)
|
playAudio(player, Sounds.BONES_DOWN_2738)
|
||||||
sendMessage(player, "You dig a hole in the ground.")
|
|
||||||
return@queueScript delayScript(player, 2)
|
|
||||||
}
|
|
||||||
|
|
||||||
1 -> {
|
// A strong queue is required in the event a player moves immediately after clicking the bones
|
||||||
|
queueScript(player, 1, QueueStrength.STRONG) {
|
||||||
|
if (removeBones(player, node.asItem())) {
|
||||||
sendMessage(player, "You bury the bones.")
|
sendMessage(player, "You bury the bones.")
|
||||||
rewardXP(player, Skills.PRAYER, bones.experience)
|
rewardXP(player, Skills.PRAYER, bones.experience)
|
||||||
player.dispatch(BoneBuryEvent(bones.itemId))
|
player.dispatch(BoneBuryEvent(bones.itemId))
|
||||||
|
}
|
||||||
return@queueScript stopExecuting(player)
|
return@queueScript stopExecuting(player)
|
||||||
}
|
}
|
||||||
|
return@on true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
else -> return@queueScript stopExecuting(player)
|
private fun removeBones(player: Player, item: Item): Boolean {
|
||||||
}
|
val removedBones = replaceSlot(player, item.slot, Item())
|
||||||
}
|
return removedBones == item && removedBones.slot == item.slot
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue