diff --git a/Server/src/main/content/region/kandarin/quest/waterfall/MithrilSeedsListener.kt b/Server/src/main/content/region/kandarin/quest/waterfall/MithrilSeedsListener.kt index b0b194769..bf60962c8 100644 --- a/Server/src/main/content/region/kandarin/quest/waterfall/MithrilSeedsListener.kt +++ b/Server/src/main/content/region/kandarin/quest/waterfall/MithrilSeedsListener.kt @@ -22,8 +22,8 @@ import org.rs09.consts.Scenery as SceneryObj class MithrilSeedsListener : InteractionListener { companion object { - private val attributeDelay = "mithril-flowers:delay" - private val flowersToItems = mapOf( + private const val attributeDelay = "mithril-flowers:delay" + private val flowersToItems = mapOf( SceneryObj.FLOWERS_2980 to Items.FLOWERS_2460, // multicolored pastels SceneryObj.FLOWERS_2981 to Items.FLOWERS_2462, // red SceneryObj.FLOWERS_2982 to Items.FLOWERS_2464, // blue @@ -37,6 +37,7 @@ class MithrilSeedsListener : InteractionListener { } override fun defineListeners() { + on(Items.MITHRIL_SEEDS_299, IntType.ITEM, "plant") { player, _ -> closeAllInterfaces(player) val flowerLoc = player.location @@ -50,10 +51,10 @@ class MithrilSeedsListener : InteractionListener { if (removeItem(player, Items.MITHRIL_SEEDS_299)) { // Source: Mod Ash https://reldo.runescape.wiki/i/106311 val flowerObj = when (RandomFunction.random(1001)) { - in 0..897 -> RandomFunction.random(SceneryObj.FLOWERS_2981, SceneryObj.FLOWERS_2986 + 1) // normal flowers + in 0..897 -> RandomFunction.random(SceneryObj.FLOWERS_2981, SceneryObj.FLOWERS_2986 + 1) // normal flowers in 898..997 -> SceneryObj.FLOWERS_2980 // multicolored pastels, 100/1001 in 998..999 -> SceneryObj.FLOWERS_2988 // black flowers, 2/1001 - else -> SceneryObj.FLOWERS_2987 // white flowers, 1/1001 + else -> SceneryObj.FLOWERS_2987 // white flowers, 1/1001 } val thisFlower = addScenery(flowerObj, flowerLoc, 0, 10) sendMessage(player, "You open the small mithril case and drop a seed by your feet.") diff --git a/Server/src/main/content/region/kandarin/quest/waterfall/WaterfallListeners.kt b/Server/src/main/content/region/kandarin/quest/waterfall/WaterfallListeners.kt index 3d6d107cb..494369f06 100644 --- a/Server/src/main/content/region/kandarin/quest/waterfall/WaterfallListeners.kt +++ b/Server/src/main/content/region/kandarin/quest/waterfall/WaterfallListeners.kt @@ -16,10 +16,11 @@ import core.game.world.map.Location import core.game.world.update.flag.context.Animation import core.game.world.update.flag.context.Graphics import core.tools.ticksToCycles +import java.util.concurrent.atomic.AtomicBoolean import org.rs09.consts.Animations +import org.rs09.consts.Graphics as GFX import org.rs09.consts.Items import org.rs09.consts.NPCs -import java.util.concurrent.atomic.AtomicBoolean import org.rs09.consts.Scenery as SceneryObj /** @@ -32,49 +33,35 @@ import org.rs09.consts.Scenery as SceneryObj class WaterfallListeners : InteractionListener { companion object { - // Animations - private val animationSwim = Animation(164) - private val animationRopeToss = Animation(774) - private val animationRopeWalk = Animation(776) - private val animationDrowning = Animation(765) - private val animationWhirlpool = Animation(528) - private val animationRenderRopeWalk = Animation(273) - private val animationRenderDrowning = Animation(163) - private val animationRenderWhirlpool = Animation(847) // Attributes - private const val attributeRunes = "waterfall:runes-placed" - // Graphics - private val graphicRopeToss = Graphics(67) - private val graphicsSplash = Graphics(68) - private val graphicsRunePoof = Graphics(580, 250) - private val graphicsRocksFall = Graphics(74) + private const val attributeRunes = "waterfall:runes-placed" // Flags - private val someoneIsSwimming = AtomicBoolean(false) + private val someoneIsSwimming = AtomicBoolean(false) // Locations - private val locIslandAfterRaft = Location(2512, 3481) - private val locIslandBeforeRock = Location(2512, 3476) - private val locSwimmingGoal = Location(2512, 3471) - private val locInFrontOfRock = Location(2512, 3470) - private val locRock = Location(2512, 3468) - private val locWaterfallLedge = Location(2511, 3463) - private val locDownstream = Location(2527, 3413) - private val locInsideTomb = Location(2555, 9844) - private val locInWaterfallCave = Location(2575, 9861) - private val locWaterfallDoorSouth = Location(2568, 9893) - private val locWaterfallDoorNorth = Location(2566, 9901) - private val locWaterfallDoorChamber = Location(2604, 9900) - private val locBeforeFloodedStatue = Location(2539, 9914) - private val locBeforeFinalStatue = Location(2603, 9914) + private val locIslandAfterRaft = Location(2512, 3481) + private val locIslandBeforeRock = Location(2512, 3476) + private val locSwimmingGoal = Location(2512, 3471) + private val locInFrontOfRock = Location(2512, 3470) + private val locRock = Location(2512, 3468) + private val locWaterfallLedge = Location(2511, 3463) + private val locDownstream = Location(2527, 3413) + private val locInsideTomb = Location(2555, 9844) + private val locInWaterfallCave = Location(2575, 9861) + private val locWaterfallDoorSouth = Location(2568, 9893) + private val locWaterfallDoorNorth = Location(2566, 9901) + private val locWaterfallDoorChamber = Location(2604, 9900) + private val locBeforeFloodedStatue = Location(2539, 9914) + private val locBeforeFinalStatue = Location(2603, 9914) // Misc data - private val ropeYSpan = intArrayOf(3469, 3470, 3471, 3472, 3473, 3474, 3475) - private val pedestalLocations = arrayOf( + private val ropeYSpan = intArrayOf(3469, 3470, 3471, 3472, 3473, 3474, 3475) + private val pedestalLocations = arrayOf( Location(2562, 9914), Location(2562, 9912), Location(2562, 9910), Location(2569, 9914), Location(2569, 9912), Location(2569, 9910), ) - private val runes = intArrayOf( + private val puzzleRunes = intArrayOf( Items.WATER_RUNE_555, Items.AIR_RUNE_556, Items.EARTH_RUNE_557, ) - private val anyRunes = intArrayOf( + private val anyRunes = intArrayOf( Items.FIRE_RUNE_554, Items.WATER_RUNE_555, Items.AIR_RUNE_556, Items.EARTH_RUNE_557, Items.MIND_RUNE_558, Items.BODY_RUNE_559, Items.DEATH_RUNE_560, Items.NATURE_RUNE_561, Items.CHAOS_RUNE_562, Items.LAW_RUNE_563, Items.COSMIC_RUNE_564, Items.BLOOD_RUNE_565, Items.SOUL_RUNE_566, Items.ASTRAL_RUNE_9075, Items.STEAM_RUNE_4694, @@ -124,9 +111,9 @@ class WaterfallListeners : InteractionListener { // Try to swim to the rock at the waterfall, or just swim in general on(intArrayOf(SceneryObj.ROCK_1996, SceneryObj.ROCK_1997, SceneryObj.RIVER_10283), IntType.SCENERY, "swim to", "swim") { player, _ -> sendMessage(player, "It looks like a long distance, but you swim out into the water.") - sendGraphics(graphicsSplash, player.location) + sendGraphics(GFX.WATER_SPLASH_68, player.location) AgilityHandler.walk( - player, -1, player.location, locSwimmingGoal, animationSwim, 0.0, null + player, -1, player.location, locSwimmingGoal, Animation(Animations.HUMAN_SWIM_164), 0.0, null ) lock(player, 6) queueScript(player, 3, QueueStrength.SOFT) { stage -> @@ -153,8 +140,8 @@ class WaterfallListeners : InteractionListener { return@onUseWith true } someoneIsSwimming.set(true) - animate(player, animationRopeToss) - sendGraphics(graphicRopeToss, Location(locRock.x, ropeYSpan[3])) + animate(player, Animations.HUMAN_TOSS_ROPE_774) + sendGraphics(GFX.ROPE_EXTENDS_67, Location(locRock.x, ropeYSpan[3])) lock(player, 9) queueScript(player, 1, QueueStrength.SOFT) { stage -> when (stage) { @@ -164,19 +151,18 @@ class WaterfallListeners : InteractionListener { addScenery(Scenery(SceneryObj.ROPE_1998, Location(locRock.x, y), 10, 0)) } face(player, locRock) - player.appearance.setAnimations(animationRenderRopeWalk) - player.appearance.sync() + renderAnimation(player, Animations.HUMAN_WADE_WITH_ROPE_R_273) AgilityHandler.walk( player, -1, player.location, locInFrontOfRock, null, 0.0, null ) - return@queueScript delayScript(player, 1) + return@queueScript keepRunning(player) } in 1..6 -> { removeScenery(Scenery(SceneryObj.ROPE_1998, Location(locRock.x, ropeYSpan[7 - stage]), 10, 0)) if (stage == 1 && getScenery(locRock.x, ropeYSpan[6], 0) == null) { addScenery(SceneryObj.RIVER_10283, Location(locRock.x, ropeYSpan[6])) } - return@queueScript delayScript(player, 1) + return@queueScript keepRunning(player) } 7 -> { AgilityHandler.walk( @@ -184,12 +170,10 @@ class WaterfallListeners : InteractionListener { ) replaceScenery(getScenery(locRock)!!, SceneryObj.ROCK_1996, -1) removeScenery(Scenery(SceneryObj.ROPE_1998, Location(locRock.x, ropeYSpan[0]), 10, 0)) - return@queueScript delayScript(player, 1) + return@queueScript keepRunning(player) } 8 -> { - player.appearance.setDefaultAnimations() - player.appearance.setAnimations() - player.appearance.sync() + resetRenderAnimation(player) forceMove(player, player.location, locInFrontOfRock.transform(1, -2, 0), 0, ticksToCycles(1)) someoneIsSwimming.set(false) return@queueScript stopExecuting(player) @@ -483,10 +467,10 @@ class WaterfallListeners : InteractionListener { } // Use runes on the pedestals - onUseWith(IntType.SCENERY, runes, SceneryObj.PILLAR_2004) { player, used, with -> + onUseWith(IntType.SCENERY, puzzleRunes, SceneryObj.PILLAR_2004) { player, used, with -> val pIndex = pedestalLocations.indexOf(with.location) - val rIndex = runes.indexOf(used.id) - val activeIndex = (pIndex * runes.size) + rIndex + val rIndex = puzzleRunes.indexOf(used.id) + val activeIndex = (pIndex * puzzleRunes.size) + rIndex var activeState = getAttribute(player, attributeRunes, 0) if (pIndex == -1) return@onUseWith false if (activeState and (1 shl activeIndex) == 0) { @@ -495,7 +479,7 @@ class WaterfallListeners : InteractionListener { lock(player, 1) queueScript(player, 1, QueueStrength.SOFT) { sendMessage(player, "The rune stone disappears in a puff of smoke.") - sendGraphics(graphicsRunePoof, with.location) + sendGraphics(Graphics(GFX.PUFF_OF_SMOKE_580, 250), with.location) return@queueScript stopExecuting(player) } activeState = activeState or (1 shl activeIndex) @@ -517,7 +501,7 @@ class WaterfallListeners : InteractionListener { lock(player, 4) queueScript(player, 3, QueueStrength.SOFT) { sendMessage(player, "Rocks fall from the ceiling and hit you in the head.") - sendGraphics(graphicsRocksFall, player.location) + sendGraphics(GFX.ROCKS_FALL_74, player.location) impact(player, 20, HitsplatType.NORMAL) return@queueScript stopExecuting(player) } @@ -554,13 +538,12 @@ class WaterfallListeners : InteractionListener { when (stage) { 0 -> { sendMessage(player, "Water floods into the cavern.") - animate(player, animationDrowning) + animate(player, Animations.HUMAN_DROWN_765) teleport(player, locBeforeFloodedStatue) return@queueScript keepRunning(player) } 1 -> { - player.appearance.setAnimations(animationRenderDrowning) - player.appearance.sync() + renderAnimation(player, Animations.HUMAN_DROWN_R_163) AgilityHandler.walk(player, -1, player.location, player.location.transform(0, -2, 0), null, 0.0, null) return@queueScript delayScript(player, 2) } @@ -569,15 +552,12 @@ class WaterfallListeners : InteractionListener { return@queueScript keepRunning(player) } 3 -> { - player.appearance.setAnimations(animationRenderWhirlpool) - player.appearance.sync() + renderAnimation(player, Animations.HUMAN_WHIRLPOOL_R_847) return@queueScript delayScript(player, 12) } 4 -> { sendMessage(player, "You are washed downstream, but feel lucky to be alive.") - player.appearance.setDefaultAnimations() - player.appearance.setAnimations() - player.appearance.sync() + resetRenderAnimation(player) teleport(player, locDownstream) return@queueScript stopExecuting(player) }