diff --git a/Server/src/main/content/region/kandarin/seers/quest/elementalworkshop2/EW2Cutscene.kt b/Server/src/main/content/region/kandarin/seers/quest/elementalworkshop2/EW2Cutscene.kt new file mode 100644 index 000000000..fd2b5d917 --- /dev/null +++ b/Server/src/main/content/region/kandarin/seers/quest/elementalworkshop2/EW2Cutscene.kt @@ -0,0 +1,89 @@ +package content.region.kandarin.seers.quest.elementalworkshop2 + +import content.data.Quests +import content.region.kandarin.seers.quest.elementalworkshop2.EW2Listeners.Companion.EXTRACTOR_BAD +import content.region.kandarin.seers.quest.elementalworkshop2.EW2Listeners.Companion.EXTRACTOR_BAD_GFX +import content.region.kandarin.seers.quest.elementalworkshop2.EW2Listeners.Companion.EXTRACTOR_GOOD +import content.region.kandarin.seers.quest.elementalworkshop2.EW2Listeners.Companion.EXTRACTOR_GOOD_GFX +import content.region.kandarin.seers.quest.elementalworkshop2.EW2Listeners.Companion.EXTR_GUN +import content.region.kandarin.seers.quest.elementalworkshop2.EW2Listeners.Companion.toInstance +import content.region.kandarin.seers.quest.elementalworkshop2.EW2Session.Companion.EW2_REGION +import content.region.kandarin.seers.quest.elementalworkshop2.ElementalWorkshop2.Companion.EW2ExtractorGun +import content.region.kandarin.seers.quest.elementalworkshop2.ElementalWorkshop2.Companion.EW2StageVarbit +import core.api.* +import core.game.activity.Cutscene +import core.game.node.entity.player.Player +import core.game.node.entity.skill.Skills +import core.game.world.map.Location +import core.game.world.update.flag.context.Animation +import org.rs09.consts.Sounds + +/** + * The extractor hat cutscene in EW2 + */ + +class EW2Cutscene(player: Player, good: Boolean) : Cutscene(player) { + override fun setup() { + setExit(toInstance(player, Location.create(1961, 5150, 0))) + loadRegion(EW2_REGION) + } + + val successfulExtract = good + + override fun runStage(stage: Int) { + when(stage) { + 0 -> { + teleport(player, 41, 30) + moveCamera(37, 25, 350) + rotateCamera(42, 29) + timedUpdate(0) + } + + 1 -> { + face(player, player.location.transform(1, 0, 0)) + timedUpdate(0) + } + + 2 -> { + teleport(player, 42, 30) + if (successfulExtract) { + visualize(player, EXTRACTOR_GOOD, EXTRACTOR_GOOD_GFX) + playAudio(player, Sounds.EW2_EXTRACTOR_OPERATION_3166) + val gun = getScenery(base.transform(42, 28, 0)) + if (gun != null) animateScenery(gun, EXTR_GUN) + timedUpdate(Animation(EXTRACTOR_GOOD).duration) + } else { + visualize(player, EXTRACTOR_BAD, EXTRACTOR_BAD_GFX) + playAudio(player, Sounds.EW2_EXTRACTOR_ZAP_3173) + timedUpdate(Animation(EXTRACTOR_BAD).duration) + } + } + + 3 -> { + teleport(player, 41, 30) + if (successfulExtract) { + // make a mind bar + setVarbit(player, EW2ExtractorGun, 2, true) + + // drain magic + adjustLevel(player, Skills.MAGIC, -20) + sendMessage(player, "You feel magically weakened.") + + // advance quest + if (getQuestStage(player, Quests.ELEMENTAL_WORKSHOP_II) <= 9) { + setQuestStage(player, Quests.ELEMENTAL_WORKSHOP_II, 10) + setVarbit(player, EW2StageVarbit, 10, true) + } + } else { + impact(player, 4) + sendMessage(player, "The extractor hat shocks you!") + } + timedUpdate(1) + } + + 4 -> { + endWithoutFade { } + } + } + } +} \ No newline at end of file diff --git a/Server/src/main/content/region/kandarin/seers/quest/elementalworkshop2/EW2Listeners.kt b/Server/src/main/content/region/kandarin/seers/quest/elementalworkshop2/EW2Listeners.kt index 7a832974c..66b3d6505 100644 --- a/Server/src/main/content/region/kandarin/seers/quest/elementalworkshop2/EW2Listeners.kt +++ b/Server/src/main/content/region/kandarin/seers/quest/elementalworkshop2/EW2Listeners.kt @@ -26,14 +26,21 @@ import content.region.kandarin.seers.quest.elementalworkshop2.ElementalWorkshop2 import content.region.kandarin.seers.quest.elementalworkshop2.ElementalWorkshop2.Companion.attrWatered import content.region.kandarin.seers.quest.elementalworkshop2.ElementalWorkshop2.Companion.attrWinded import core.api.* +import core.api.utils.PlayerCamera +import core.game.dialogue.DialogueLabeller import core.game.interaction.IntType import core.game.interaction.InteractionListener import core.game.interaction.QueueStrength import core.game.node.entity.npc.NPC import core.game.node.entity.player.Player import core.game.node.entity.skill.Skills +import core.game.node.item.Item +import core.game.world.map.Direction import core.game.world.map.Location import core.game.world.update.flag.context.Animation +import core.net.packet.PacketRepository +import core.net.packet.context.CameraContext +import core.net.packet.out.CameraViewPacket import org.rs09.consts.* class EW2Listeners : InteractionListener { @@ -68,39 +75,29 @@ class EW2Listeners : InteractionListener { */ companion object { + + // interface + const val LEVER_SCHEM = 466 // graphics const val EXTRACTOR_GOOD_GFX = Graphics.EXTRACTOR_HAT_CHAIR_807 const val EXTRACTOR_BAD_GFX = Graphics.IMPROPERLY_EXTRACTOR_HAT_CHAIR_808 // animations + const val VALVE_TURN = 4861 const val DOOR_OPEN = 4871 // 4875 is another open const val DOOR_CLOSE = 4872 // 4876 is another open const val DOOR_EXTEND = 4873 // 4877 is another extend const val DOOR_RETRACT = 4874 // 4878 is another retract - // 4879 - // 4880 - // 4881 - // 4882 - // 4883 const val EXTRACTOR_GOOD = Animations.HUMAN_USE_EXTRACTOR_HAT_CHAIR_4884 const val EXTRACTOR_BAD = Animations.HUMAN_IMPROPERLY_USE_EXTRACTOR_HAT_CHAIR_4885 - // 4886 const val CRANE_LOWER_CART = 4887 const val CRANE_RAISE_CART = 4888 const val CRANE_LOWER_LAVA = 4889 const val CRANE_RAISE_LAVA = 4890 - // 4891 (another pivot anim, unused) const val CRANE_PIVOT = 4892 - // 4893 - // 4894 - // 4895 - const val COG_REV = 4896 - // 4897 - const val FAN_SPIN = 4898 - // 4899 - // 4900 - // 4901 + //const val COG_REV = 4896 // not used + const val EXTR_GUN = 4897 const val TANK_FILL = 4902 const val TANK_DRAIN = 4903 const val COG_FWD = 4906 @@ -277,20 +274,23 @@ class EW2Listeners : InteractionListener { val trackCenter = toInstance(player, Location.create(1953, 5155, 2)) val existingCart = findLocalNPCs(trackCenter, 15).find { it.id in jigCartStates } if (existingCart != null) { + // update appearance if (existingCart.id != targetId) { - existingCart.transform(targetId) + existingCart.transform(targetId) // needs to be permanent so can't use the contentAPI transform } + // failsafe to reset the cart where it's supposed to be. right now cart just teleports so this shouldn't trigger if (!existingCart.walkingQueue.isMoving && existingCart.location != targetLocation) { teleport(existingCart, targetLocation) } + // if cart is inside water tank, clear it if (tankState == 3 || tankState == 4 || tankState == 6 || tankState == 7) { existingCart.clear() } - // if there is no cart, spawn a new one (like if player is just logging in) + // if there is no cart, spawn a new one (like if player is just entering) } else { // create the cart val newCart = NPC.create(targetId, targetLocation) @@ -342,14 +342,13 @@ class EW2Listeners : InteractionListener { val tankLoc = toInstance(player, location(1951, 5164, 2)) val currentObject = getScenery(tankLoc) - if (waterIn == 0 && waterOut == 0) { - // both valves closed, nothing happens - return + // both valves closed, nothing happens + if (waterIn == 0 && waterOut == 0) return - } else if (waterIn == 0 && waterOut == 1) { - // drain is open, empty the tank + // drain is open, empty the tank + if (waterIn == 0 && waterOut == 1) { + // tank is full: play drain anim, then remove if (currentObject != null && currentObject.id == Scenery.WATER_TANK_18661) { - // tank is full: play drain anim, then remove queueScript(player, 0, QueueStrength.SOFT) { stage: Int -> when (stage) { 0 -> { @@ -364,14 +363,17 @@ class EW2Listeners : InteractionListener { else -> return@queueScript stopExecuting(player) } } - } else if (currentObject != null && currentObject.id == Scenery.WATER_TANK_18660) { - // tank is damp: just remove the scenery + } + + // tank is damp: just remove the scenery + if (currentObject != null && currentObject.id == Scenery.WATER_TANK_18660) { removeScenery(core.game.node.scenery.Scenery(Scenery.WATER_TANK_18660, tankLoc)) playAudio(player, Sounds.EW2_WATER_RACK_3184) } + } - } else if (waterIn == 1 && waterOut == 0) { - // inlet is open, fill tank + // inlet is open, fill tank + if (waterIn == 1 && waterOut == 0) { if (currentObject?.id == Scenery.WATER_TANK_18661) return // already full queueScript(player, 0, QueueStrength.SOFT) { stage: Int -> @@ -388,6 +390,7 @@ class EW2Listeners : InteractionListener { playAudio(player, Sounds.EW2_WATER_FLOW_3183) return@queueScript delayScript(player, Animation(TANK_FILL).duration) } + 1 -> { // swap damp for full tank val existing = getScenery(tankLoc) @@ -407,14 +410,16 @@ class EW2Listeners : InteractionListener { } return@queueScript stopExecuting(player) } + else -> return@queueScript stopExecuting(player) } } + } - } else if (waterIn == 1 && waterOut == 1) { - // inlet and drain are open, tank is damp + // inlet and drain are open, tank is damp + if (waterIn == 1 && waterOut == 1) { + // tank is full: play drain anim, then swap to damp if (currentObject?.id == Scenery.WATER_TANK_18661) { - // tank is full: play drain anim, then swap to damp queueScript(player, 0, QueueStrength.SOFT) { stage: Int -> when (stage) { 0 -> { @@ -422,16 +427,20 @@ class EW2Listeners : InteractionListener { playAudio(player, Sounds.EW2_WATER_FLOW_3183) return@queueScript delayScript(player, Animation(TANK_DRAIN).duration) } + 1 -> { removeScenery(core.game.node.scenery.Scenery(Scenery.WATER_TANK_18661, tankLoc)) addScenery(core.game.node.scenery.Scenery(Scenery.WATER_TANK_18660, tankLoc)) return@queueScript stopExecuting(player) } + else -> return@queueScript stopExecuting(player) } } - } else if (currentObject?.id != Scenery.WATER_TANK_18660) { - // tank is empty: add the damp scenery + } + + // tank is empty: add the damp scenery + if (currentObject?.id != Scenery.WATER_TANK_18660) { addScenery(core.game.node.scenery.Scenery(Scenery.WATER_TANK_18660, tankLoc)) playAudio(player, Sounds.EW2_WATER_FLOW_3183) } @@ -464,53 +473,115 @@ class EW2Listeners : InteractionListener { animId = DOOR_CLOSE soundId = Sounds.EW2_DIAL_SPIN_2326 } - // rack extending/retracting - (currentObject.id == Scenery.DOOR_18652 && targetId == Scenery.DOOR_18653) || - (currentObject.id == Scenery.DOOR_18655 && targetId == Scenery.DOOR_18656) || - (currentObject.id == Scenery.DOOR_18658 && targetId == Scenery.DOOR_18659) -> { + + // rack extending + (currentObject.id == Scenery.DOOR_18652 && targetId == Scenery.DOOR_18653) || // extend empty + (currentObject.id == Scenery.DOOR_18655 && targetId == Scenery.DOOR_18656) || // extend holding hot + (currentObject.id == Scenery.DOOR_18658 && targetId == Scenery.DOOR_18659) -> { // extend holding cooled animId = DOOR_EXTEND soundId = Sounds.EW2_SCREW_TURN_3182 } - (currentObject.id == Scenery.DOOR_18653 && targetId == Scenery.DOOR_18652) || - (currentObject.id == Scenery.DOOR_18656 && targetId == Scenery.DOOR_18655) || - (currentObject.id == Scenery.DOOR_18659 && targetId == Scenery.DOOR_18658) -> { + + // rack retracting + (currentObject.id == Scenery.DOOR_18653 && targetId == Scenery.DOOR_18652) || // retract empty + (currentObject.id == Scenery.DOOR_18653 && targetId == Scenery.DOOR_18655) || // retract grabbing hot cart + (currentObject.id == Scenery.DOOR_18656 && targetId == Scenery.DOOR_18652) || // retract leaving hot cart + (currentObject.id == Scenery.DOOR_18659 && targetId == Scenery.DOOR_18652) -> { // retract leaving cooled cart animId = DOOR_RETRACT soundId = Sounds.EW2_SCREW_TURN_3182 } } + // if the cart is being dropped off + val isDroppingCart = (currentObject.id == Scenery.DOOR_18656 || currentObject.id == Scenery.DOOR_18659) && targetId == Scenery.DOOR_18652 + queueScript(player, 0, QueueStrength.SOFT) { stage: Int -> when (stage) { 0 -> { + // spawn cart visually immediately so the empty rack retracts away from it + if (isDroppingCart) syncCart(player) + if (animId != -1) { - val anim = Animation(animId) animateScenery(player, currentObject, animId) if (soundId != -1) playAudio(player, soundId) - return@queueScript delayScript(player, anim.duration) + return@queueScript delayScript(player, Animation(animId).duration) } return@queueScript delayScript(player, 1) } + 1 -> { - // replaceScenery doesn't work. why? idfk + // replaceScenery doesn't work here. Why? idfk. removeScenery(core.game.node.scenery.Scenery(currentObject.id, doorLoc, 1)) addScenery(core.game.node.scenery.Scenery(targetId, doorLoc, 1)) - syncCart(player) - + // sync the cart after the door closes + if (!isDroppingCart) syncCart(player) return@queueScript stopExecuting(player) } + else -> return@queueScript stopExecuting(player) } } } - // updates fan state. fun fact, the fan state varbit isn't saved even if you say to save it. gotta make sure it's set on login. + // updates fan state. fun fact, the fan state varbit isn't saved even if you say to save it. gotta make sure it's set on entry. fun syncFan(player: Player) { val fanMachine = getVarbit(player, EW2FanLeverVarbit) - if (fanMachine == 1) { - // spins the fan - setVarbit(player, EW2FanStateVarbit, 1, true) + setVarbit(player, EW2FanStateVarbit, fanMachine, true) + } + + // helper function for the cog crates + private fun searchCogCrate(player: Player, cogItem: Int, cogName: String) { + if (!inInventory(player, cogItem)) { + addItemOrDrop(player, cogItem) + sendMessage(player, "You find a $cogName cog.") } else { - setVarbit(player, EW2FanStateVarbit, 0, true) + sendMessage(player, "It's empty.") + } + } + + // helper function for cog placement + private fun placeCog(player: Player, item: Item, varbit: Int) { + val (cogVal, cogName) = when (item.id) { + Items.SMALL_COG_9726 -> 1 to "small" + Items.MEDIUM_COG_9725 -> 2 to "medium-sized" + Items.LARGE_COG_9724 -> 3 to "big" + else -> return + } + if (removeItem(player, item)) { + setVarbit(player, varbit, cogVal, true) + sendItemDialogue(player, item, "You put the $cogName cog onto the shaft.") + animate(player, 537) + playAudio(player, Sounds.EW2_PLACE_COG_3178) + syncCogs(player) + } + } + + // helper function for the water valves + private fun handleValve(player: Player, valveVarbit: Int) { + val valveState = getVarbit(player, valveVarbit) + val door = getVarbit(player, EW2TankDoorStatusVarbit) // 0 if door closed, 1 if open + + if (door == 1) { + sendMessage(player, "The valve won't turn, maybe the door needs to be closed first.") + return + } + + // only the west (fill) valve requires the pipe to be fixed first + if (valveVarbit == EW2ValveWestVarbit && getVarbit(player, EW2PipeVarbit) == 0) { + sendMessage(player, "You turn the valve but nothing happens, maybe the pipe needs to be repaired first.") + return + } + + lockInteractions(player, 4) + animate(player, VALVE_TURN) + + val nextState = valveState xor 1 + setVarbit(player, valveVarbit, nextState, true) + queueScript(player, 3, QueueStrength.SOFT) { + syncTank(player) + sendDialogue(player, if (nextState == 1) "You open the valve." else "You close the valve.") + playAudio(player, Sounds.EW2_WATER_VALVE_3185) + return@queueScript true } } @@ -540,7 +611,8 @@ class EW2Listeners : InteractionListener { sendItemDialogue(player, Items.BEATEN_BOOK_9717, "You find an old-looking book.") addItemOrDrop(player, Items.BEATEN_BOOK_9717) - if(getQuestStage(player, Quests.ELEMENTAL_WORKSHOP_II) == 0) { + // advance quest stage + if (getQuestStage(player, Quests.ELEMENTAL_WORKSHOP_II) == 0) { setQuestStage(player, Quests.ELEMENTAL_WORKSHOP_II, 1) setVarbit(player, EW2StageVarbit, 1, true) } @@ -564,24 +636,29 @@ class EW2Listeners : InteractionListener { setInterfaceText(player, "4 W", 222, 8) setInterfaceText(player, "Pipe 3.", 222, 9) - if(getQuestStage(player, Quests.ELEMENTAL_WORKSHOP_II) == 2) { + // advance quest stage + if (getQuestStage(player, Quests.ELEMENTAL_WORKSHOP_II) == 2) { setQuestStage(player, Quests.ELEMENTAL_WORKSHOP_II, 3) setVarbit(player, EW2StageVarbit, 3, true) } - if(getVarbit(player, EW2MachineryVarbit) == 0) + + // set the varbit that unlocks the machinery key (below) + if (getVarbit(player, EW2MachineryVarbit) == 0) setVarbit(player, EW2MachineryVarbit, 1, true) return@on true } // machinery where you find the key. on(Scenery.MACHINERY_18594, IntType.SCENERY, "search") { player, _ -> - if(!inInventory(player, Items.KEY_9722)) { + if (!inInventory(player, Items.KEY_9722)) { sendItemDialogue(player, Items.KEY_9722, "You find a key hidden in the third pipe.") addItemOrDrop(player, Items.KEY_9722) } else { sendDialogue(player, "You search the machinery but find nothing.") } - if(getQuestStage(player, Quests.ELEMENTAL_WORKSHOP_II) == 3) { + + // advance quest stage + if (getQuestStage(player, Quests.ELEMENTAL_WORKSHOP_II) == 3) { setQuestStage(player, Quests.ELEMENTAL_WORKSHOP_II, 4) setVarbit(player, EW2StageVarbit, 4, true) } @@ -615,7 +692,8 @@ class EW2Listeners : InteractionListener { // start the instanced workshop session EW2Session(player).start() - if(getQuestStage(player, Quests.ELEMENTAL_WORKSHOP_II) == 4) { + // advance quest stage + if (getQuestStage(player, Quests.ELEMENTAL_WORKSHOP_II) == 4) { setQuestStage(player, Quests.ELEMENTAL_WORKSHOP_II, 5) setVarbit(player, EW2StageVarbit, 5, true) } @@ -629,14 +707,14 @@ class EW2Listeners : InteractionListener { return@on true } - // stairs to lower level + // stairs to EW2 lower level on(Scenery.STAIRWELL_18597, IntType.SCENERY, "climb-down") { player, _ -> teleport(player, toInstance(player,location(1948, 5158, 0))) sendMessage(player, "You climb down the stairs.") return@on true } - // stairs back up to EW2 + // stairs from EW2 lower level back up to EW2 main level on(Scenery.STAIRS_18599, IntType.SCENERY, "climb-up") { player, _ -> teleport(player, toInstance(player,location(1948, 5157, 2))) sendMessage(player, "You climb up the stairs.") @@ -655,18 +733,16 @@ class EW2Listeners : InteractionListener { addDialogueAction(player) { _, buttonId -> when (buttonId) { 2 -> { - if(!inInventory(player, Items.CRANE_SCHEMATIC_9718)){ + if (!inInventory(player, Items.CRANE_SCHEMATIC_9718)) { addItemOrDrop(player, Items.CRANE_SCHEMATIC_9718) sendItemDialogue(player, Items.CRANE_SCHEMATIC_9718, "You take a copy of the schematic drawing.") - } - else sendDialogue(player, "You already have this schematic.") + } else sendDialogue(player, "You already have this schematic.") } 3 -> { - if(!inInventory(player, Items.LEVER_SCHEMATIC_9719)){ + if (!inInventory(player, Items.LEVER_SCHEMATIC_9719)) { addItemOrDrop(player, Items.LEVER_SCHEMATIC_9719) sendItemDialogue(player, Items.LEVER_SCHEMATIC_9719, "You take a copy of the schematic drawing.") - } - else sendDialogue(player, "You already have this schematic.") + } else sendDialogue(player, "You already have this schematic.") } } } @@ -685,8 +761,9 @@ class EW2Listeners : InteractionListener { // find the player's cart val existingCart = findLocalNPCs(player, jigCartStates, 32).firstOrNull() + // no cart (should not happen) if (existingCart == null) { - sendMessage(player, "CART MISSING. LOG IN AND OUT TO RESET IT.") + sendMessage(player, "CART MISSING. RE-ENTER THE WORKSHOP TO RESET IT, OR REPORT THIS.") return@on true } @@ -695,20 +772,24 @@ class EW2Listeners : InteractionListener { sendMessage(player, "You cannot do that while the claw is down.") return@on true } + // door must be closed if (currentPos == 2 && doorPos == 1) { sendMessage(player, "You cannot do that while the door is open.") return@on true } + // fan must be off if (currentPos == 3 && fanState == 1) { sendMessage(player, "You cannot do that while the fan is on.") return@on true } + // cart must be currently stopped if (existingCart.walkingQueue.isMoving) { return@on true } + // cart must not be in the water tank if (tankState == 3 || tankState == 4 || tankState == 6 || tankState == 7) { sendMessage(player, "You cannot do that while the cart is inside the tank.") @@ -759,7 +840,7 @@ class EW2Listeners : InteractionListener { on(jigCartStates, IntType.NPC, "take-from") { player, node -> val cartPos = getVarbit(player, EW2CartLeverVarbit) // cart moving lever. 0 = start (south), 1 = west, 2 = north, 3 = east - // don't allow interact if cart is not at south station + // don't allow interaction if cart is not at south station if (cartPos != 0) { sendMessage(player, "I can't reach that.") return@on true @@ -772,22 +853,16 @@ class EW2Listeners : InteractionListener { animate(player, 537) setVarbit(player, EW2JigCartVarbit, 0, true) } - NPCs.JIG_CART_4915 -> { - sendMessage(player, "The bar is too hot to touch.") - } - NPCs.JIG_CART_4916 -> { - sendMessage(player, "The bar is too hot to touch.") - } - NPCs.JIG_CART_4917 -> { - sendMessage(player, "You should finish the process before taking the bar.") - } + NPCs.JIG_CART_4915 -> sendMessage(player, "The bar is too hot to touch.") + NPCs.JIG_CART_4916 -> sendMessage(player, "The bar is too hot to touch.") + NPCs.JIG_CART_4917 -> sendMessage(player, "You should finish the process before taking the bar.") NPCs.JIG_CART_4918 -> { addItemOrDrop(player, Items.PRIMED_BAR_9727) sendItemDialogue(player, Items.PRIMED_BAR_9727, "You take the primed bar.") setVarbit(player, EW2JigCartVarbit, 0, true) // advance quest stage - if(getQuestStage(player, Quests.ELEMENTAL_WORKSHOP_II) <= 6) { + if (getQuestStage(player, Quests.ELEMENTAL_WORKSHOP_II) <= 6) { setQuestStage(player, Quests.ELEMENTAL_WORKSHOP_II, 7) setVarbit(player, EW2StageVarbit, 7, true) } @@ -802,7 +877,7 @@ class EW2Listeners : InteractionListener { val cranePos = getVarbit(player, EW2CranePosVarbit) val cartPos = getVarbit(player, EW2CartLeverVarbit) // cart moving lever. 0 = start (south), 1 = west, 2 = north, 3 = east - // don't allow interact if cart is not at south station + // don't allow interaction if cart is not at south station if (cartPos != 0) { sendMessage(player, "I can't reach that.") return@onUseWith true @@ -825,7 +900,8 @@ class EW2Listeners : InteractionListener { setVarbit(player, EW2StageVarbit, 6, true) } - if(!getAttribute(player, attrJigged, false) && getQuestStage(player, Quests.ELEMENTAL_WORKSHOP_II) <= 6) { + // attribute for quest log + if (!getAttribute(player, attrJigged, false) && getQuestStage(player, Quests.ELEMENTAL_WORKSHOP_II) <= 6) { setAttribute(player, attrJigged, true) } return@onUseWith true @@ -845,22 +921,24 @@ class EW2Listeners : InteractionListener { // lever schematic (what lever is this even for?) on(Items.LEVER_SCHEMATIC_9719, IntType.ITEM, "read") { player, _ -> - openInterface(player, 466) + openInterface(player, LEVER_SCHEM) return@on true } // fix crane onUseWith(IntType.SCENERY, Items.CRANE_CLAW_9720, Scenery.OLD_CRANE_18636) { player, used, _ -> // check if already repaired - if(getVarbit(player, EW2CraneStateVarbit) != 0) { + if (getVarbit(player, EW2CraneStateVarbit) != 0) { sendMessage(player, "The crane is already repaired.") return@onUseWith true } - sendItemDialogue(player, used, "You replace the broken claw.") - removeItem(player, used) - - setVarbit(player, EW2CraneStateVarbit, 1, true) - syncCrane(player) + + // repair crane + if (removeItem(player, used)) { + sendItemDialogue(player, used, "You replace the broken claw.") + setVarbit(player, EW2CraneStateVarbit, 1, true) + syncCrane(player) + } return@onUseWith true } @@ -896,7 +974,7 @@ class EW2Listeners : InteractionListener { setVarbit(player, EW2CranePosVarbit, nextPos, true) lockInteractions(player, 5) animate(player, Animations.HUMAN_PULL_LEVER_4909) - syncCrane(player) // also syncs the cart inside the crane function + syncCrane(player) // this also syncs the cart inside the crane function return@on true } @@ -942,28 +1020,31 @@ class EW2Listeners : InteractionListener { if (cartPos == 1) { when (cartState) { 0 -> { // empty. nothing happens. + // "hardy" is the real word used. I thought it was a typo for 'hammer' but it's not. https://en.wikipedia.org/wiki/Hardy_tool + // also note during one of the source videos it's authentic that the press state shows a purple ele bar for a moment. weird. sendDialogue(player, "You pull the lever and the press responds. The hardy comes down, stopping inches from the jig, then returns to its original position.") playAudio(player, Sounds.EW2_PRESS_BAR_3180) animate(player, Animations.HUMAN_PULL_LEVER_4909) } + 1 -> { // ele bar. nothing happens. - // "hardy" is the real word used. I thought it was a typo for 'hammer' but it's not. https://en.wikipedia.org/wiki/Hardy_tool - // also note during one of the source videos it's authentic that the press state shows a purple ele bar for a moment. weird. sendDialogue(player, "You pull the lever and the press responds. The hardy comes down, hitting the elemental bar. The bar is not hot enough to flatten.") playAudio(player, Sounds.EW2_PRESS_BAR_3180) animate(player, Animations.HUMAN_PULL_LEVER_4909) } + 2 -> { // hot ele bar. changes state to hot smashed bar. setVarbit(player, EW2JigCartVarbit, 3, true) - // "hardy" is correct. see above. sendDialogue(player, "You pull the lever and the press responds. The hardy comes down, hitting the elemental bar. The bar has been flattened.") playAudio(player, Sounds.EW2_PRESS_BAR_3180) animate(player, Animations.HUMAN_PULL_LEVER_4909) syncCart(player) - if(!getAttribute(player, attrFlattened, false) && getQuestStage(player, Quests.ELEMENTAL_WORKSHOP_II) <= 6) { + // attribute for quest log + if (!getAttribute(player, attrFlattened, false) && getQuestStage(player, Quests.ELEMENTAL_WORKSHOP_II) <= 6) { setAttribute(player, attrFlattened, true) } } + else -> { // smashed hot, smashed cooled, or primed. nothing happens. sendDialogue(player, "You pull the lever and the press responds. The hardy comes down, hitting the elemental bar. The bar is already flattened.") playAudio(player, Sounds.EW2_PRESS_BAR_3180) @@ -979,7 +1060,6 @@ class EW2Listeners : InteractionListener { sendDialogue(player, "You pull the lever but nothing happens. Maybe the pipes are connected the wrong way round.") animate(player, Animations.HUMAN_PULL_LEVER_4909) } - return@on true } @@ -994,19 +1074,18 @@ class EW2Listeners : InteractionListener { if (!inInventory(player, Items.PIPE_9723)) { addItemOrDrop(player, Items.PIPE_9723) sendMessage(player, "You find a pipe.") - } else { - sendMessage(player, "It's empty.") - } + } else sendMessage(player, "It's empty.") return@on true } // fix the pipe onUseWith(IntType.SCENERY, Items.PIPE_9723, Scenery.PIPING_18650) { player, item, _ -> - animate(player, 537) - sendItemDialogue(player, item, "You replace the section of broken pipe.") - playAudio(player, Sounds.EW2_PLACE_PIPE_3433) - setVarbit(player, EW2PipeVarbit, 1, true) - removeItem(player, item) + if (removeItem(player, item)) { + animate(player, 537) + sendItemDialogue(player, item, "You replace the section of broken pipe.") + playAudio(player, Sounds.EW2_PLACE_PIPE_3433) + setVarbit(player, EW2PipeVarbit, 1, true) + } return@onUseWith true } @@ -1019,19 +1098,19 @@ class EW2Listeners : InteractionListener { animate(player, Animations.HUMAN_PULL_LEVER_4909) // if tank has water, don't open. - if(tankScen != null) { + if (tankScen != null) { sendDialogue(player, "You pull the lever but nothing happens. Maybe the tank needs to be empty first.") return@on true } // check the rack is not out - if(tankState == 2 || tankState == 5 || tankState == 8) { + if (tankState == 2 || tankState == 5 || tankState == 8) { sendDialogue(player, "You pull the lever but nothing happens. Maybe the rack needs retracting first.") return@on true } // update door status open/close - if(doorOpen == 0) { + if (doorOpen == 0) { setVarbit(player, EW2TankDoorStatusVarbit, 1, true) } else { setVarbit(player, EW2TankDoorStatusVarbit, 0, true) @@ -1045,7 +1124,6 @@ class EW2Listeners : InteractionListener { 3 -> 4 // Closed/Hot -> Opened/Hot 7 -> 6 // Opened/Cooled -> Closed/Cooled 6 -> 7 // Closed/Cooled -> Opened/Cooled - // six seeeven hehehehe else -> tankState } @@ -1077,113 +1155,49 @@ class EW2Listeners : InteractionListener { animate(player, Animations.HUMAN_TURN_CORKSCREW_LEVER_4905) // either pull cart in or push it out. transfer between all the door open states - runTask(player, 1) { + queueScript(player, 1, QueueStrength.SOFT) { when (tankState) { - 1 -> { // 1 door opened, grabber inside - setVarbit(player, EW2TankDoorStateVarbit, 2, true) // 2 door opened, grabber out - // no cart update - } + + // 1 door opened, grabber inside. no cart update + 1 -> setVarbit(player, EW2TankDoorStateVarbit, 2, true) // 2 door opened, grabber out + 2 -> { // 2 door opened, grabber out // only grab the hot bar. otherwise, put the grabber back in - if(cartState == 3) { + if (cartState == 3) { setVarbit(player, EW2TankDoorStateVarbit, 4, true) // 4 door opened, hot bar inside // remove hot bar cart } else { setVarbit(player, EW2TankDoorStateVarbit, 1, true) // 1 door opened, grabber inside } } - 4 -> { // 4 door opened, hot bar inside - setVarbit(player, EW2TankDoorStateVarbit, 5, true) // 5 door opened, hot bar out - } - 5 -> { // 5 door opened, hot bar out - setVarbit(player, EW2TankDoorStateVarbit, 1, true) // 1 door opened, grabber inside - // add hot bar cart - } - 7 -> { // 7 door opened, cooled bar inside - setVarbit(player, EW2TankDoorStateVarbit, 8, true) // 8 door opened, cooled bar out - } - 8 -> { // 8 door opened, cooled bar out - setVarbit(player, EW2TankDoorStateVarbit, 1, true) // 1 door opened, grabber inside - // add cool bar cart - } + + // 4 door opened, hot bar inside + 4 -> setVarbit(player, EW2TankDoorStateVarbit, 5, true) // 5 door opened, hot bar out + + // 5 door opened, hot bar out. add hot bar cart + 5 -> setVarbit(player, EW2TankDoorStateVarbit, 1, true) // 1 door opened, grabber inside + + // 7 door opened, cooled bar inside + 7 -> setVarbit(player, EW2TankDoorStateVarbit, 8, true) // 8 door opened, cooled bar out + + // 8 door opened, cooled bar out. add cool bar cart + 8 -> setVarbit(player, EW2TankDoorStateVarbit, 1, true) // 1 door opened, grabber inside } syncTankDoor(player) // also syncs the cart inside there + return@queueScript true } return@on true } // west water valve operates the water inflow. requires pipe to be fixed. on(Scenery.WATER_VALVE_18646, IntType.SCENERY, "turn") { player, _ -> - - val valveState = getVarbit(player, EW2ValveWestVarbit) // water valve west. 0 = closed, 1 = open - val door = getVarbit(player, EW2TankDoorStatusVarbit) // 0 if door closed, 1 if open - - if(door == 1) { - sendMessage(player, "The valve won't turn, maybe the door needs to be closed first.") - return@on true - } - - if(getVarbit(player, EW2PipeVarbit) == 0) { - sendMessage(player, "You turn the valve but nothing happens, maybe the pipe needs to be repaired first.") - return@on true - } - - lockInteractions(player, 4) - animate(player, 4861) - - // if closed, open the valve - if(valveState == 0){ - setVarbit(player, EW2ValveWestVarbit, 1, true) - queueScript(player, 3, QueueStrength.SOFT) { - syncTank(player) - sendDialogue(player, "You open the valve.") - playAudio(player, Sounds.EW2_WATER_VALVE_3185) - return@queueScript true - } - // if open, close the valve - } else { - setVarbit(player, EW2ValveWestVarbit, 0, true) - queueScript(player, 3, QueueStrength.SOFT) { - syncTank(player) - sendDialogue(player, "You close the valve.") - playAudio(player, Sounds.EW2_WATER_VALVE_3185) - return@queueScript true - } - } + handleValve(player, EW2ValveWestVarbit) return@on true } // east water valve operates the drain on(Scenery.WATER_VALVE_18647, IntType.SCENERY, "turn") { player, _ -> - - val valveState = getVarbit(player, EW2ValveEastVarbit) // water valve west. 0 = closed, 1 = open - val door = getVarbit(player, EW2TankDoorStatusVarbit) // 0 if door closed, 1 if open - - if(door == 1) { - sendMessage(player, "The valve won't turn, maybe the door needs to be closed first.") - return@on true - } - - player.locks.lockInteractions(4) - animate(player, 4861) - - // if closed, open the valve - if(valveState == 0){ - setVarbit(player, EW2ValveEastVarbit, 1, true) - runTask(player, 3) { - syncTank(player) - sendDialogue(player, "You open the valve.") - playAudio(player, Sounds.EW2_WATER_VALVE_3185) - } - // if open, close the valve - } else { - setVarbit(player, EW2ValveEastVarbit, 0, true) - runTask(player, 3) { - syncTank(player) - sendDialogue(player, "You close the valve.") - playAudio(player, Sounds.EW2_WATER_VALVE_3185) - } - } + handleValve(player, EW2ValveEastVarbit) return@on true } @@ -1201,34 +1215,19 @@ class EW2Listeners : InteractionListener { // small cog crate on(Scenery.CRATE_18618, IntType.SCENERY, "search") { player, _ -> - if (!inInventory(player, Items.SMALL_COG_9726)) { - addItemOrDrop(player, Items.SMALL_COG_9726) - sendMessage(player, "You find a small cog.") - } else { - sendMessage(player, "It's empty.") - } + searchCogCrate(player, Items.SMALL_COG_9726, "small") return@on true } // medium cog crate on(Scenery.CRATES_18617, IntType.SCENERY, "search") { player, _ -> - if (!inInventory(player, Items.MEDIUM_COG_9725)) { - addItemOrDrop(player, Items.MEDIUM_COG_9725) - sendMessage(player, "You find a medium-sized cog.") - } else { - sendMessage(player, "It's empty.") - } + searchCogCrate(player, Items.MEDIUM_COG_9725, "medium-sized") return@on true } // large cog crate on(Scenery.CRATE_18616, IntType.SCENERY, "search") { player, _ -> - if (!inInventory(player, Items.LARGE_COG_9724)) { - addItemOrDrop(player, Items.LARGE_COG_9724) - sendMessage(player, "You find a big cog.") - } else { - sendMessage(player, "It's empty.") - } + searchCogCrate(player, Items.LARGE_COG_9724, "big") return@on true } @@ -1264,88 +1263,25 @@ class EW2Listeners : InteractionListener { // use cog with pin 1 // pin 1: 2655: val 0 is scenery 18665 (pin). val 1 is scenery 18673 (small cog). val 2 is scenery 18674 (med cog). val 3 is scenery 18675 (large cog). onUseWith(IntType.SCENERY, intArrayOf(Items.SMALL_COG_9726, Items.MEDIUM_COG_9725, Items.LARGE_COG_9724), Scenery.PIN_18665) { player, item, _ -> - when(item.id) { - Items.SMALL_COG_9726 -> { - setVarbit(player, EW2CogVarbit1, 1, true) - sendItemDialogue(player, item, "You put the small cog onto the shaft.") - animate(player, 537) - playAudio(player, Sounds.EW2_PLACE_COG_3178) - removeItem(player, item) - } - Items.MEDIUM_COG_9725 -> { - setVarbit(player, EW2CogVarbit1, 2, true) - sendItemDialogue(player, item, "You put the medium-sized cog onto the shaft.") - animate(player, 537) - playAudio(player, Sounds.EW2_PLACE_COG_3178) - removeItem(player, item) - } - Items.LARGE_COG_9724 -> { - setVarbit(player, EW2CogVarbit1, 3, true) - sendItemDialogue(player, item, "You put the big cog onto the shaft.") - animate(player, 537) - playAudio(player, Sounds.EW2_PLACE_COG_3178) - removeItem(player, item) - } - } - syncCogs(player) + placeCog(player, item as Item, EW2CogVarbit1) return@onUseWith true } // use cog with pin 2 // This listener brought to you by Player Name and his famous work with Arios RegionChunk fixing. Without that work it wouldn't have been possible to interact with this pin. // pin 2: 2656: val 0 is scenery 18664 (pin). val 1 is scenery 18667 (small cog). val 2 is scenery 18668 (med cog). val 3 is scenery 18669 (large cog) onUseWith(IntType.SCENERY, intArrayOf(Items.SMALL_COG_9726, Items.MEDIUM_COG_9725, Items.LARGE_COG_9724), Scenery.PIN_18664) { player, item, _ -> - when(item.id) { - Items.SMALL_COG_9726 -> { - setVarbit(player, EW2CogVarbit2, 1, true) - sendItemDialogue(player, item, "You put the small cog onto the shaft.") - animate(player, 537) - removeItem(player, item) - } - Items.MEDIUM_COG_9725 -> { - setVarbit(player, EW2CogVarbit2, 2, true) - sendItemDialogue(player, item, "You put the medium cog onto the shaft.") - animate(player, 537) - removeItem(player, item) - } - Items.LARGE_COG_9724 -> { - setVarbit(player, EW2CogVarbit2, 3, true) - sendItemDialogue(player, item, "You put the large cog onto the shaft.") - animate(player, 537) - removeItem(player, item) - } - } - syncCogs(player) + placeCog(player, item as Item, EW2CogVarbit2) return@onUseWith true } // use cog with pin 3 // pin 3: 2657: val 0 is scenery 18666 (pin). val 1 is scenery 18670 (small cog). val 2 is scenery 18671 (med cog). val 3 is scenery 18672 (large cog) onUseWith(IntType.SCENERY, intArrayOf(Items.SMALL_COG_9726, Items.MEDIUM_COG_9725, Items.LARGE_COG_9724), Scenery.PIN_18666) { player, item, _ -> - when(item.id) { - Items.SMALL_COG_9726 -> { - setVarbit(player, EW2CogVarbit3, 1, true) - sendItemDialogue(player, item, "You put the small cog onto the shaft.") - animate(player, 537) - removeItem(player, item) - } - Items.MEDIUM_COG_9725 -> { - setVarbit(player, EW2CogVarbit3, 2, true) - sendItemDialogue(player, item, "You put the medium cog onto the shaft.") - animate(player, 537) - removeItem(player, item) - } - Items.LARGE_COG_9724 -> { - setVarbit(player, EW2CogVarbit3, 3, true) - sendItemDialogue(player, item, "You put the large cog onto the shaft.") - animate(player, 537) - removeItem(player, item) - } - } - syncCogs(player) + placeCog(player, item as Item, EW2CogVarbit3) return@onUseWith true } - // fan lever. todo Authentically this check should allow the machine to start and the fan to either not start, start backwards, or start correctly, but I'm simplifying it for my sanity. + // fan lever. on(Scenery.AN_OLD_LEVER_18663, IntType.SCENERY, "pull") { player, _ -> animate(player, Animations.HUMAN_PULL_LEVER_4909) @@ -1359,19 +1295,29 @@ class EW2Listeners : InteractionListener { // pin 2 (2656) should have the med cog. // pin 3 (2656) should have the large cog. if (allCogs == 57) { - if(lever == 0) { + if (lever == 0) { + // rotate camera to view fan + val cam = PlayerCamera(player) + cam.setPosition(38, 28, 350) + // turn on - sendDialogue(player, "The machine rumbles and the fan starts to blow.") // Is authentically two messages of "The machine starts rumbling." and "The fan starts to blow.", but I am simplifying this check. playAudio(player, Sounds.EW2_MACHINE_RUMBLE_3175) playAudio(player, Sounds.EW2_FANBLADE_3174) setVarbit(player, EW2FanLeverVarbit, 1, true) syncFan(player) syncCogs(player) + openDialogue(player, object : DialogueLabeller() { + override fun addConversation() { + line("The machine starts rumbling.") + line("The fan starts to blow.") + } + }) + // check cart and cool if necessary. otherwise nothing should happen. if (cartpos == 3 && cartstate == 4) { setVarbit(player, EW2JigCartVarbit, 5, true) syncCart(player) - if(!getAttribute(player, attrWinded, false) && getQuestStage(player, Quests.ELEMENTAL_WORKSHOP_II) <= 6) { + if (!getAttribute(player, attrWinded, false) && getQuestStage(player, Quests.ELEMENTAL_WORKSHOP_II) <= 6) { setAttribute(player, attrWinded, true) } } @@ -1381,7 +1327,7 @@ class EW2Listeners : InteractionListener { syncFan(player) syncCogs(player) } - } else { // allCogs != 57, cogs are not correct + } else { // allCogs != 57, cogs are not correct todo Authentically there is an extra check where the fan can start backwards, but I'm simplifying it for my sanity. this would require reverse cog anims, too sendDialogue(player, "The machine starts up, but the fan does not blow.") playAudio(player, Sounds.EW2_MACHINE_RUMBLE_3175) } @@ -1393,11 +1339,11 @@ class EW2Listeners : InteractionListener { * ------------------------- */ // use bar with extractor gun - onUseWith(IntType.SCENERY, intArrayOf(Items.PRIMED_BAR_9727), Scenery.EXTRACTOR_GUN_18693) { player, item, _ -> - if(removeItem(player, item)) { + onUseWith(IntType.SCENERY, Items.PRIMED_BAR_9727, Scenery.EXTRACTOR_GUN_18693) { player, used, _ -> + if (removeItem(player, used as Item)) { setVarbit(player, EW2ExtractorGun, 1, true) sendItemDialogue(player, Items.PRIMED_BAR_9727, "You place the primed bar under the device.") - if(getQuestStage(player, Quests.ELEMENTAL_WORKSHOP_II) <= 8) { + if (getQuestStage(player, Quests.ELEMENTAL_WORKSHOP_II) <= 8) { setQuestStage(player, Quests.ELEMENTAL_WORKSHOP_II, 9) setVarbit(player, EW2StageVarbit, 9, true) } @@ -1405,81 +1351,37 @@ class EW2Listeners : InteractionListener { return@onUseWith true } - // take primed bar - on(intArrayOf(Scenery.EXTRACTOR_GUN_18694), IntType.SCENERY, "take-from") { player, _ -> + // take primed bar from the extractor gun + on(Scenery.EXTRACTOR_GUN_18694, IntType.SCENERY, "take-from") { player, _ -> addItemOrDrop(player, Items.PRIMED_BAR_9727) setVarbit(player, EW2ExtractorGun, 0, true) sendItemDialogue(player, Items.PRIMED_BAR_9727, "You take the primed bar.") return@on true } - // take mind bar - on(intArrayOf(Scenery.EXTRACTOR_GUN_18695), IntType.SCENERY, "take-from") { player, _ -> + // take mind bar from the extractor gun + on(Scenery.EXTRACTOR_GUN_18695, IntType.SCENERY, "take-from") { player, _ -> addItemOrDrop(player, Items.ELEMENTAL_MIND_BAR_9728) setVarbit(player, EW2ExtractorGun, 0, true) sendItemDialogue(player, Items.ELEMENTAL_MIND_BAR_9728, "You take the elemental mind bar.") return@on true } - // sit in chair - // todo the extractor gun needs a graphic - // todo per one of the sources the camera angle changes for this. - on(intArrayOf(Scenery.EXTRACTOR_HAT_18690), IntType.SCENERY, "operate") { player, _ -> - // check magic level - if(getDynLevel(player, Skills.MAGIC) < 20) { + // sit in the extractor chair + on(Scenery.EXTRACTOR_HAT_18690, IntType.SCENERY, "operate") { player, _ -> + // check magic level. if you use the extractor too much, it can drain you too far. + if (getDynLevel(player, Skills.MAGIC) < 20) { sendMessage(player, "You must have a Magic level of 20 and above to use the device.") return@on true } - // if bar is in place, charge it and drain magic - if(getVarbit(player, EW2ExtractorGun) == 1) { - runTask(player) { - forceMove( - player, - toInstance(player, Location.create(1961, 5150, 0)), - toInstance(player, Location.create(1962, 5150, 0)), - 0, - 0 - ) - visualize(player, EXTRACTOR_GOOD, EXTRACTOR_GOOD_GFX) - playAudio(player, Sounds.EW2_EXTRACTOR_OPERATION_3166) - sendGraphics(809, Location.create(1962, 5148, 0)) - setVarbit(player, EW2ExtractorGun, 2, true) - adjustLevel(player, Skills.MAGIC, -20) - sendMessage(player, "You feel magically weakened.") - if(getQuestStage(player, Quests.ELEMENTAL_WORKSHOP_II) <= 9) { - setQuestStage(player, Quests.ELEMENTAL_WORKSHOP_II, 10) - setVarbit(player, EW2StageVarbit, 10, true) - } - } - forceMove( - player, - toInstance(player,Location.create(1962, 5150, 0)), - toInstance(player,Location.create(1961, 5150, 0)), - 200, - 2 - ) - // if bar is not in place (or if it's already a primed bar), hit player + + // start the cutscene + if (getVarbit(player, EW2ExtractorGun) == 1) { + // if bar is in place, charge it and drain magic + EW2Cutscene(player, true).start() } else { - runTask(player) { // 50 client cycles = 1 second - forceMove( - player, - toInstance(player,Location.create(1961, 5150, 0)), - toInstance(player,Location.create(1962, 5150, 0)), - 0, - 0 - ) - visualize(player, EXTRACTOR_BAD, EXTRACTOR_BAD_GFX) - playAudio(player, Sounds.EW2_EXTRACTOR_ZAP_3173) - impact(player, 4) - sendMessage(player, "The extractor hat shocks you!.") - } - forceMove( - player, - toInstance(player,Location.create(1962, 5150, 0)), - toInstance(player,Location.create(1961, 5150, 0)), - 350, - 2 - ) + // if bar is not in place (or if it's already a primed bar), hit player + EW2Cutscene(player, false).start() } return@on true } @@ -1488,28 +1390,36 @@ class EW2Listeners : InteractionListener { // fixes to get right interact locations override fun defineDestinationOverrides() { setDest(IntType.SCENERY, intArrayOf(Scenery.OLD_CRANE_18636), "use") { entity, _ -> - return@setDest toInstance(entity as Player,Location.create(1954, 5148, 2)) + return@setDest toInstance(entity as Player, Location.create(1954, 5148, 2)) } setDest(IntType.NPC, intArrayOf(NPCs.JIG_CART_4913), "use") { entity, _ -> - return@setDest toInstance(entity as Player,Location.create(1954, 5148, 2)) + return@setDest toInstance(entity as Player, Location.create(1954, 5148, 2)) } - setDest(IntType.NPC, intArrayOf(NPCs.JIG_CART_4914, NPCs.JIG_CART_4915, NPCs.JIG_CART_4916, NPCs.JIG_CART_4917, NPCs.JIG_CART_4918), "take-from") { entity, _ -> - return@setDest toInstance(entity as Player,Location.create(1954, 5148, 2)) + setDest( + IntType.NPC, intArrayOf( + NPCs.JIG_CART_4914, NPCs.JIG_CART_4915, + NPCs.JIG_CART_4916, NPCs.JIG_CART_4917, + NPCs.JIG_CART_4918 + ), "take-from" + ) { entity, _ -> + return@setDest toInstance(entity as Player, Location.create(1954, 5148, 2)) } setDest(IntType.SCENERY, intArrayOf(Scenery.PIPING_18650), "use") { entity, _ -> - return@setDest toInstance(entity as Player,Location.create(1953, 5167, 3)) + return@setDest toInstance(entity as Player, Location.create(1953, 5167, 3)) } // the double stacked pins and the cogs on them. - setDest(IntType.SCENERY, intArrayOf( - Scenery.PIN_18664, Scenery.PIN_18665, - Scenery.COG_18673, Scenery.COG_18674, Scenery.COG_18675, - Scenery.COG_18667, Scenery.COG_18668, Scenery.COG_18669 - ), "use","take") { entity, _ -> - return@setDest toInstance(entity as Player,Location.create(1958, 5157, 2)) + setDest( + IntType.SCENERY, intArrayOf( + Scenery.PIN_18664, Scenery.PIN_18665, + Scenery.COG_18673, Scenery.COG_18674, Scenery.COG_18675, + Scenery.COG_18667, Scenery.COG_18668, Scenery.COG_18669 + ), "use", "take" + ) { entity, _ -> + return@setDest toInstance(entity as Player, Location.create(1958, 5157, 2)) } } } \ No newline at end of file diff --git a/Server/src/main/content/region/kandarin/seers/quest/elementalworkshop2/EW2Session.kt b/Server/src/main/content/region/kandarin/seers/quest/elementalworkshop2/EW2Session.kt index 59995acee..cc3ed2d86 100644 --- a/Server/src/main/content/region/kandarin/seers/quest/elementalworkshop2/EW2Session.kt +++ b/Server/src/main/content/region/kandarin/seers/quest/elementalworkshop2/EW2Session.kt @@ -8,6 +8,7 @@ import content.region.kandarin.seers.quest.elementalworkshop2.EW2Listeners.Compa import content.region.kandarin.seers.quest.elementalworkshop2.EW2Listeners.Companion.syncTank import content.region.kandarin.seers.quest.elementalworkshop2.EW2Listeners.Companion.syncTankDoor import core.api.* +import core.game.interaction.QueueStrength import core.game.node.entity.Entity import core.game.node.entity.player.Player import core.game.world.map.Location @@ -20,6 +21,10 @@ import core.game.world.map.zone.ZoneBorders class EW2Session(val player: Player? = null) : MapArea { + companion object { + const val EW2_REGION = 7760 + } + lateinit var region: DynamicRegion lateinit var base: Location @@ -32,12 +37,11 @@ class EW2Session(val player: Player? = null) : MapArea { fun start() { val p = player ?: return - region = DynamicRegion.create(7760) + region = DynamicRegion.create(EW2_REGION) base = region.baseLocation zone.register(getRegionBorders(region.id)) setAttribute(p, "ew2-session", this) - teleport(p, base.transform(35, 35, 2)) // logout listener returns player to the EW1 workshop registerLogoutListener(p, "ew2-logout") { @@ -55,6 +59,12 @@ class EW2Session(val player: Player? = null) : MapArea { syncTankDoor(p) syncFan(p) syncCogs(p) + + // teleport in after the workshop is ready + queueScript(player, 1, QueueStrength.SOFT) { + teleport(p, base.transform(35, 35, 2)) + return@queueScript true + } } // clean up the instanced area diff --git a/Server/src/main/content/region/kandarin/seers/quest/elementalworkshop2/ElementalWorkshop2.kt b/Server/src/main/content/region/kandarin/seers/quest/elementalworkshop2/ElementalWorkshop2.kt index 35c0fc0cb..919b105f8 100644 --- a/Server/src/main/content/region/kandarin/seers/quest/elementalworkshop2/ElementalWorkshop2.kt +++ b/Server/src/main/content/region/kandarin/seers/quest/elementalworkshop2/ElementalWorkshop2.kt @@ -195,7 +195,7 @@ class ElementalWorkshop2 : Quest(Quests.ELEMENTAL_WORKSHOP_II, 53, 52, 1, EW2Sta line++ } - // stage 8, went through the mind door + // stage 8, went through the mind door. I skip using this due to lack of source /* if (stage >= 8) { line(player, "", line++, stage > 8) @@ -238,11 +238,15 @@ class ElementalWorkshop2 : Quest(Quests.ELEMENTAL_WORKSHOP_II, 53, 52, 1, EW2Sta // these varps wipes all the varbits setVarp(player, EW2Varp1, 0, true) setVarp(player, EW2Varp2, 0, true) + + // remove attributes removeAttribute(player, attrJigged) removeAttribute(player, attrDipped) removeAttribute(player, attrFlattened) removeAttribute(player, attrWatered) removeAttribute(player, attrWinded) + + // sync the quest tab player.getQuestRepository().syncronizeTab(player) super.reset(player) } diff --git a/Server/src/main/content/region/kandarin/seers/quest/elementalworkshop2/JunctionBoxInterface.kt b/Server/src/main/content/region/kandarin/seers/quest/elementalworkshop2/JunctionBoxInterface.kt index ade19851b..ac15f71a7 100644 --- a/Server/src/main/content/region/kandarin/seers/quest/elementalworkshop2/JunctionBoxInterface.kt +++ b/Server/src/main/content/region/kandarin/seers/quest/elementalworkshop2/JunctionBoxInterface.kt @@ -241,21 +241,27 @@ class JunctionBoxInterface : InterfaceListener { 1 -> when (endBtn) { // Top Left b4 -> 0; b5 -> 6; b6 -> 7; b2 -> 8; b3 -> 9; else -> -1 } + 2 -> when (endBtn) { // Top Mid b5 -> 1; b4 -> 10; b6 -> 11; b1 -> 8; b3 -> 12; else -> -1 } + 3 -> when (endBtn) { // Top Right b6 -> 2; b4 -> 13; b5 -> 14; b1 -> 9; b2 -> 12; else -> -1 } + 4 -> when (endBtn) { // Bottom Left b1 -> 0; b5 -> 3; b6 -> 4; b2 -> 10; b3 -> 13; else -> -1 } + 5 -> when (endBtn) { // Bottom Mid b2 -> 1; b4 -> 3; b6 -> 5; b1 -> 6; b3 -> 14; else -> -1 } + 6 -> when (endBtn) { // Bottom Right b3 -> 2; b4 -> 4; b5 -> 5; b1 -> 7; b2 -> 11; else -> -1 } + else -> -1 } }