mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2026-08-22 02:45:10 -06:00
this zone somewhat works
This commit is contained in:
parent
2c720efd44
commit
e009d55ab2
1 changed files with 52 additions and 32 deletions
|
|
@ -4,59 +4,79 @@ import content.data.Quests
|
|||
import content.region.kandarin.seers.quest.elementalworkshop2.EW2Listeners.Companion.syncCart
|
||||
import content.region.kandarin.seers.quest.elementalworkshop2.EW2Listeners.Companion.syncCrane
|
||||
import content.region.kandarin.seers.quest.elementalworkshop2.EW2Listeners.Companion.syncFan
|
||||
import content.region.kandarin.seers.quest.elementalworkshop2.EW2Listeners.Companion.syncSteamPress
|
||||
import content.region.kandarin.seers.quest.elementalworkshop2.EW2Listeners.Companion.syncTank
|
||||
import content.region.kandarin.seers.quest.elementalworkshop2.EW2Listeners.Companion.syncTankDoor
|
||||
import content.region.kandarin.seers.quest.elementalworkshop2.EW2Listeners.Companion.toInstance
|
||||
import content.region.kandarin.seers.quest.elementalworkshop2.ElementalWorkshop2.Companion.EW2StageVarbit
|
||||
import core.api.*
|
||||
import core.game.interaction.QueueStrength
|
||||
import core.game.node.entity.Entity
|
||||
import core.game.node.entity.player.Player
|
||||
import core.game.node.scenery.SceneryBuilder
|
||||
import core.game.world.map.Location
|
||||
import core.plugin.Initializable
|
||||
import core.game.world.map.zone.MapZone
|
||||
import core.game.world.map.build.DynamicRegion
|
||||
import core.game.world.map.zone.ZoneBorders
|
||||
import core.game.world.map.zone.ZoneBuilder
|
||||
import core.plugin.Plugin
|
||||
import org.rs09.consts.Scenery
|
||||
|
||||
/**
|
||||
* This updates the Elemental Workshop II state whenever the player enters,
|
||||
* keeping the equipment state synced to the saved varbits.
|
||||
* keeping the equipment state synced to the saved varbits. The workshop
|
||||
* area is a dynamic region, per OSRS wiki.
|
||||
*/
|
||||
|
||||
@Initializable
|
||||
class EW2Zone : MapZone("Elemental Workshop II", true), Plugin<Any?> {
|
||||
class EW2Zone : MapArea {
|
||||
|
||||
override fun newInstance(arg: Any?): EW2Zone {
|
||||
ZoneBuilder.configure(this)
|
||||
return this
|
||||
override fun defineAreaBorders(): Array<ZoneBorders> {
|
||||
return arrayOf(ZoneBorders(1920,5120,1983,5183))
|
||||
}
|
||||
|
||||
override fun configure() {
|
||||
super.register(ZoneBorders(1936,5128,1982,5172))
|
||||
}
|
||||
override fun areaEnter(entity: Entity) {
|
||||
if(entity is Player) {
|
||||
|
||||
// updates the workshop state based on the varbits for Elemental Workshop II
|
||||
override fun enter(e: Entity?): Boolean {
|
||||
if(e is Player) {
|
||||
val baseRegion = 7760
|
||||
|
||||
if(getQuestStage(e, Quests.ELEMENTAL_WORKSHOP_II) <= 5) {
|
||||
setQuestStage(e, Quests.ELEMENTAL_WORKSHOP_II, 6)
|
||||
setVarbit(e, EW2StageVarbit, 6, true)
|
||||
// create the dynamic region
|
||||
val dynamicRegion = DynamicRegion.create(baseRegion)
|
||||
|
||||
// save the exit location back to the real world surface
|
||||
setAttribute(entity, "ew2_exit_location", Location.create(2713, 3484, 0))
|
||||
|
||||
// find the player's offset from the base coordinates
|
||||
val offsetX = entity.location.x - ((baseRegion shr 8) shl 6)
|
||||
val offsetY = entity.location.y - ((baseRegion and 0xFF) shl 6)
|
||||
|
||||
// apply offset to the dynamic region base
|
||||
val destX = dynamicRegion.borders.southWestX + offsetX
|
||||
val destY = dynamicRegion.borders.southWestY + offsetY
|
||||
|
||||
// teleport the player into the instance
|
||||
teleport(entity, Location.create(destX, destY, entity.location.z))
|
||||
|
||||
// save the dynamic region coords to the player to reference later
|
||||
setAttribute(entity, ElementalWorkshop2.coordsX, dynamicRegion.borders.southWestX)
|
||||
setAttribute(entity, ElementalWorkshop2.coordsY, dynamicRegion.borders.southWestY)
|
||||
|
||||
// advance quest
|
||||
if(getQuestStage(entity, Quests.ELEMENTAL_WORKSHOP_II) <= 5) {
|
||||
setQuestStage(entity, Quests.ELEMENTAL_WORKSHOP_II, 6)
|
||||
setVarbit(entity, EW2StageVarbit, 6, true)
|
||||
}
|
||||
|
||||
SceneryBuilder.add(core.game.node.scenery.Scenery(Scenery.DOOR_18651, Location.create(1953, 5162, 2), 1))
|
||||
syncCrane(e)
|
||||
syncCart(e)
|
||||
//syncSteamPress(e)
|
||||
syncTank(e)
|
||||
syncTankDoor(e)
|
||||
syncFan(e)
|
||||
}
|
||||
return super.enter(e)
|
||||
}
|
||||
// sync the workshop state
|
||||
queueScript(entity, 2, QueueStrength.SOFT) { _ ->
|
||||
|
||||
override fun fireEvent(identifier: String?, vararg args: Any?): Any {
|
||||
return Unit
|
||||
// add this door because I can't interact without parlour chairs todo test removing this on test
|
||||
// toInstance(entity, Location.create(1953, 5162, 2))
|
||||
addScenery(core.game.node.scenery.Scenery(Scenery.DOOR_18651, location(33,42,2), 1))
|
||||
|
||||
syncCrane(entity)
|
||||
syncCart(entity)
|
||||
syncSteamPress(entity)
|
||||
syncTank(entity)
|
||||
syncTankDoor(entity)
|
||||
syncFan(entity)
|
||||
return@queueScript stopExecuting(entity)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue