Update RestlessGhostListeners.kt

This commit is contained in:
Beck 2026-06-02 01:18:27 -07:00
parent 177f3974d0
commit 64234417dc

View file

@ -14,6 +14,8 @@ import core.api.lock
import core.api.playGlobalAudio
import core.api.queueScript
import core.api.removeItem
import core.api.sendDialogue
import core.api.sendItemDialogue
import core.api.sendMessage
import core.api.setAttribute
import core.api.setQuestStage
@ -37,57 +39,65 @@ import org.rs09.consts.Sounds
class RestlessGhostListeners : InteractionListener {
private fun createRestlessGhostNPC() : NPC {
val restlessGhostNPC = NPC(NPCs.RESTLESS_GHOST_457, Location(3250, 3195, 0))
restlessGhostNPC.setAttribute("spawned:npc", true)
restlessGhostNPC.isRespawn = false
restlessGhostNPC.direction = Direction.SOUTH
restlessGhostNPC.init()
restlessGhostNPC.isWalks = false
restlessGhostNPC.isNeverWalks = true
return restlessGhostNPC
}
companion object {
private const val Animations_HUMAN_CLOSE_CHEST_535 = 535
private fun createLevel13SkeletonNPC(player: Player) : NPC {
val skele = NPC(NPCs.SKELETON_459, Location(3120, 9569, 0))
skele.setAttribute("spawned:npc", true)
skele.setAttribute("target", player)
skele.isRespawn = false
skele.init()
skele.attack(player)
private const val CLOSED_COFFIN = Scenery.COFFIN_2145
private const val INCOMPLETE_COFFIN_OPEN = Scenery.COFFIN_15052
private const val COMPLETE_COFFIN_OPEN = Scenery.COFFIN_15053
return skele
}
private fun createRestlessGhostNPC() : NPC {
val restlessGhostNPC = NPC(NPCs.RESTLESS_GHOST_457, Location(3250, 3195, 0))
restlessGhostNPC.setAttribute("spawned:npc", true)
restlessGhostNPC.isRespawn = false
restlessGhostNPC.direction = Direction.SOUTH
restlessGhostNPC.init()
restlessGhostNPC.isWalks = false
restlessGhostNPC.isNeverWalks = true
return restlessGhostNPC
}
private fun toggleCoffinSceneryObj(player: Player, coffin: core.game.node.scenery.Scenery) {
lock(player, 2)
private fun createLevel13SkeletonNPC(player: Player) : NPC {
val skele = NPC(NPCs.SKELETON_459, Location(3120, 9569, 0))
skele.setAttribute("spawned:npc", true)
skele.setAttribute("target", player)
skele.isRespawn = false
skele.init()
skele.attack(player)
when (coffin.id) {
//opened
Scenery.COFFIN_15053,
Scenery.COFFIN_15052 -> {
//close it
visualize(player, 535, -1)
SceneryBuilder.replace(coffin, coffin.transform(Scenery.COFFIN_2145))
}
Scenery.COFFIN_2145 -> {
//open it
visualize(player, Animations.HUMAN_OPEN_CHEST_536, -1)
return skele
}
if (isQuestComplete(player, Quests.THE_RESTLESS_GHOST)) {
//full skele with skull
SceneryBuilder.replace(coffin, coffin.transform(Scenery.COFFIN_15053))
} else {
SceneryBuilder.replace(coffin, coffin.transform(Scenery.COFFIN_15052))
private fun toggleCoffinSceneryObj(player: Player, coffin: core.game.node.scenery.Scenery) {
lock(player, 2)
when (coffin.id) {
//opened
COMPLETE_COFFIN_OPEN,
INCOMPLETE_COFFIN_OPEN -> {
//close it
visualize(player, Animations_HUMAN_CLOSE_CHEST_535, -1)
SceneryBuilder.replace(coffin, coffin.transform(CLOSED_COFFIN))
}
CLOSED_COFFIN -> {
//open it
visualize(player, Animations.HUMAN_OPEN_CHEST_536, -1)
if (isQuestComplete(player, Quests.THE_RESTLESS_GHOST)) {
//full skele with skull
SceneryBuilder.replace(coffin, coffin.transform(COMPLETE_COFFIN_OPEN))
} else {
SceneryBuilder.replace(coffin, coffin.transform(INCOMPLETE_COFFIN_OPEN))
}
}
}
}
}
override fun defineListeners() {
on(Scenery.COFFIN_2145, IntType.SCENERY, "open") { player, node ->
on(CLOSED_COFFIN, IntType.SCENERY, "open") { player, node ->
sendMessage(player, "You open the coffin.")
@ -116,7 +126,12 @@ class RestlessGhostListeners : InteractionListener {
return@on true
}
on(Scenery.COFFIN_15053, IntType.SCENERY, "close") { player, node ->
onUseWith(IntType.SCENERY, Items.GHOSTS_SKULL_553, CLOSED_COFFIN) { player, used, with ->
sendMessage(player, "Maybe I should open it first.")
return@onUseWith true
}
on(COMPLETE_COFFIN_OPEN, IntType.SCENERY, "close") { player, node ->
sendMessage(player, "You close the coffin.")
playGlobalAudio(player.location, Sounds.COFFIN_CLOSE_53)
@ -125,18 +140,17 @@ class RestlessGhostListeners : InteractionListener {
return@on true
}
on(Scenery.COFFIN_15052, IntType.SCENERY, "examine") { player, node ->
on(COMPLETE_COFFIN_OPEN, IntType.SCENERY, "search") { player, node ->
sendDialogue(player, "There's a nice and complete skeleton in here!")
return@on true
}
on(INCOMPLETE_COFFIN_OPEN, IntType.SCENERY, "search") { player, node ->
sendMessage(player, "You search the coffin and find some human remains.")
return@on true
}
on(Scenery.COFFIN_15053, IntType.SCENERY, "examine") { player, node ->
sendMessage(player, "There's a nice and complete skeleton in here!")
return@on true
}
on(Scenery.COFFIN_15052, IntType.SCENERY, "close") { player, node ->
on(INCOMPLETE_COFFIN_OPEN, IntType.SCENERY, "close") { player, node ->
sendMessage(player, "You close the coffin.")
playGlobalAudio(player.location, Sounds.COFFIN_CLOSE_53)
@ -145,24 +159,19 @@ class RestlessGhostListeners : InteractionListener {
return@on true
}
onUseWith(IntType.SCENERY, Items.GHOSTS_SKULL_553, Scenery.COFFIN_15052) { player, used, with ->
onUseWith(IntType.SCENERY, Items.GHOSTS_SKULL_553, INCOMPLETE_COFFIN_OPEN) { player, used, with ->
if (removeItem(player, used)) {
sendMessage(player, "You put the skull in the coffin.")
sendItemDialogue(player, Items.GHOSTS_SKULL_553, "You put the skull in the coffin.")
finishQuest(player, Quests.THE_RESTLESS_GHOST)
with as core.game.node.scenery.Scenery
SceneryBuilder.replace(with, with.transform(Scenery.COFFIN_15053))
SceneryBuilder.replace(with, with.transform(COMPLETE_COFFIN_OPEN))
}
return@onUseWith true
}
onUseWith(IntType.SCENERY, Items.GHOSTS_SKULL_553, Scenery.COFFIN_2145) { player, used, with ->
sendMessage(player, "Maybe I should open it first.")
return@onUseWith true
}
on(Scenery.ALTAR_15051, IntType.SCENERY, "search") { player, node ->
if (!inInventory(player, Items.GHOSTS_SKULL_553)) {