Skip to content

Commit

Permalink
Add chaos altar teleports and stairs
Browse files Browse the repository at this point in the history
  • Loading branch information
GregHib committed May 3, 2024
1 parent 5c140fd commit 9ce2d3e
Show file tree
Hide file tree
Showing 6 changed files with 167 additions and 11 deletions.
8 changes: 7 additions & 1 deletion data/definitions/objects.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11802,4 +11802,10 @@ abyss_eyes_looking:
examine: "I could probably distract these with thievery."
abyss_eyes_distracted:
id: 7170
examine: "I could probably distract these with thievery."
examine: "I could probably distract these with thievery."
chaos_altar_ladder_up:
id: 38221
examine: "I can climb this."
chaos_altar_ladder_down:
id: 38222
examine: "I can climb down this."
105 changes: 105 additions & 0 deletions data/map/teleports.yml
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,111 @@
to:
x: 3067
y: 10254
######## 9035 ########
- id: chaos_altar_portal
option: Enter
tile:
x: 2276
y: 4847
level: 3
to:
x: 3060
y: 3585
- id: chaos_altar_portal
option: Enter
tile:
x: 2273
y: 4856
level: 3
to:
x: 3060
y: 3585
- id: chaos_altar_ladder_down
option: Climb-down
tile:
x: 2255
y: 4829
level: 3
delta:
level: -1
- id: chaos_altar_ladder_up
option: Climb-up
tile:
x: 2255
y: 4829
level: 2
delta:
level: 1
- id: chaos_altar_ladder_down
option: Climb-down
tile:
x: 2282
y: 4853
level: 2
delta:
level: -1
- id: chaos_altar_ladder_up
option: Climb-up
tile:
x: 2282
y: 4853
level: 1
delta:
level: 1
- id: chaos_altar_ladder_down
option: Climb-down
tile:
x: 2275
y: 4834
level: 2
delta:
level: -1
- id: chaos_altar_ladder_up
option: Climb-up
tile:
x: 2275
y: 4834
level: 1
delta:
level: 1
- id: chaos_altar_ladder_down
option: Climb-down
tile:
x: 2254
y: 4849
level: 1
delta:
level: -1
- id: chaos_altar_ladder_up
option: Climb-up
tile:
x: 2254
y: 4849
delta:
level: 1
- id: chaos_altar_ladder_down
option: Climb-down
tile:
x: 2259
y: 4845
level: 1
delta:
level: -1
- id: chaos_altar_ladder_up
option: Climb-up
tile:
x: 2259
y: 4845
delta:
level: 1
- id: chaos_altar_portal
option: Enter
tile:
x: 2282
y: 4837
to:
x: 3060
y: 3585
######## 9297 ########
- id: 16049
option: Climb-up
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package world.gregs.voidps.world.activity.skill.runecrafting
import net.pearx.kasechange.toSentenceCase
import world.gregs.voidps.engine.client.message
import world.gregs.voidps.engine.client.ui.interact.itemOnObjectOperate
import world.gregs.voidps.engine.client.variable.hasClock
import world.gregs.voidps.engine.client.variable.start
import world.gregs.voidps.engine.data.definition.ObjectDefinitions
import world.gregs.voidps.engine.entity.character.clearAnimation
import world.gregs.voidps.engine.entity.character.mode.interact.Interact
Expand All @@ -14,8 +16,13 @@ import world.gregs.voidps.engine.entity.playerSpawn
import world.gregs.voidps.engine.inject
import world.gregs.voidps.engine.inv.itemAdded
import world.gregs.voidps.engine.inv.itemRemoved
import world.gregs.voidps.engine.queue.softQueue
import world.gregs.voidps.engine.suspend.delay
import world.gregs.voidps.network.login.protocol.visual.update.player.EquipSlot
import world.gregs.voidps.type.equals
import world.gregs.voidps.world.interact.dialogue.type.choice
import world.gregs.voidps.world.interact.dialogue.type.statement
import world.gregs.voidps.world.interact.entity.obj.Teleports
import world.gregs.voidps.world.interact.entity.obj.teleportTakeOff
import world.gregs.voidps.world.interact.entity.sound.playSound

Expand Down Expand Up @@ -71,8 +78,43 @@ teleportTakeOff("Enter", "*_altar_ruins_enter") {
player.message("You feel a powerful force talk hold of you...")
}

val teleports: Teleports by inject()

teleportTakeOff("Enter", "*_altar_portal") {
if (id == "chaos_altar_portal" && !player.hasClock("chaos_altar_skip")) {
player.softQueue("chaos_altar_check") {
statement("Warning! This portal will teleport you into the Wilderness.")
choice("Are you sure you wish to use this portal?") {
option("Yes, I'm brave.") {
player.start("chaos_altar_skip", 1)
teleports.teleport(this, player, obj, tile, option)
}
option("Eeep! The Wilderness... No thank you.") {
player.message("You decide not to use this portal.")
cancel()
}
}
}
cancel()
return@teleportTakeOff
}
player.clearAnimation()
player.playSound("teleport")
player.message("You step through the portal...")
}

teleportTakeOff("Climb-down", "chaos_altar_ladder_down") {
if (tile.equals(2259, 4845, 1)) {
player.message("The ladder is broken, I can't climb it.")
cancel()
return@teleportTakeOff
}
}

teleportTakeOff("Climb-up", "chaos_altar_ladder_up") {
if (tile.equals(2259, 4845)) {
player.message("The ladder is broken, I can't climb it.")
cancel()
return@teleportTakeOff
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,4 @@ fun String.isLadder() = contains("ladder", true) || contains("rope", true) || co
fun String.isTrapDoor(): Boolean {
val name = replace(" ", "")
return name.equals("trapdoor", true) || name.equals("manhole", true)
}

fun hasClimbOption(options: Array<String?>?): Boolean {
val count = options?.count { it?.startsWith("Climb") == true } ?: return false
return count > 1
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ data class Teleport(

override val size = 5

override val notification: Boolean = true

override fun parameter(dispatcher: EventDispatcher, index: Int) = when (index) {
0 -> "${dispatcher.key}_teleport_${if (land) "land" else "takeoff"}"
1 -> dispatcher.identifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ package world.gregs.voidps.world.interact.entity.obj

import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap
import world.gregs.voidps.cache.definition.data.ObjectDefinition
import world.gregs.voidps.engine.entity.character.CharacterContext
import world.gregs.voidps.engine.entity.character.move.tele
import world.gregs.voidps.engine.entity.character.player.Player
import world.gregs.voidps.engine.entity.obj.ObjectOption
import world.gregs.voidps.engine.get
import world.gregs.voidps.engine.getProperty
Expand All @@ -21,13 +24,16 @@ class Teleports {
private lateinit var teleports: Map<String, Map<Int, TeleportDefinition>>

suspend fun teleport(objectOption: ObjectOption, option: String = objectOption.option): Boolean {
val id = objectOption.def.stringId.ifEmpty { objectOption.def.id.toString() }
val definition = teleports[option]?.get(objectOption.target.tile.id) ?: return false
return teleport(objectOption, objectOption.player, objectOption.def, objectOption.target.tile, option)
}

suspend fun teleport(context: CharacterContext, player: Player, def: ObjectDefinition, targetTile: Tile, option: String): Boolean {
val id = def.stringId.ifEmpty { def.id.toString() }
val definition = teleports[option]?.get(targetTile.id) ?: return false
if (definition.id != id) {
return false
}
val player = objectOption.player
val teleport = Teleport(player, definition.id, definition.tile, objectOption.def, definition.option)
val teleport = Teleport(player, definition.id, definition.tile, def, definition.option)
player.emit(teleport)
if (teleport.cancelled) {
return false
Expand All @@ -39,7 +45,7 @@ class Teleports {
}
val delay = teleport.delay
if (delay != null) {
objectOption.delay(delay)
context.delay(delay)
}
player.tele(tile)
teleport.land = true
Expand Down

0 comments on commit 9ce2d3e

Please sign in to comment.