diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/client/ui/InterfaceOption.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/client/ui/InterfaceOption.kt index f24e5798de..3593ebd468 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/client/ui/InterfaceOption.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/client/ui/InterfaceOption.kt @@ -1,13 +1,13 @@ package world.gregs.voidps.engine.client.ui -import world.gregs.voidps.engine.entity.character.Character import world.gregs.voidps.engine.entity.character.mode.interact.Interaction +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.item.Item import world.gregs.voidps.engine.event.EventDispatcher import world.gregs.voidps.engine.event.Events data class InterfaceOption( - override val character: Character, + override val character: Player, val id: String, val component: String, val optionIndex: Int, @@ -15,7 +15,7 @@ data class InterfaceOption( val item: Item, val itemSlot: Int, val inventory: String -) : Interaction() { +) : Interaction() { override fun copy(approach: Boolean) = copy().apply { this.approach = approach } override val size = 5 diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/client/ui/event/Command.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/client/ui/event/Command.kt index 7404da63c6..f74b647914 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/client/ui/event/Command.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/client/ui/event/Command.kt @@ -9,10 +9,12 @@ import world.gregs.voidps.engine.event.EventDispatcher import world.gregs.voidps.engine.event.Events data class Command( - override val character: Character, + val player: Player, val prefix: String, val content: String -) : Interaction() { +) : Interaction() { + override val character = player + override fun copy(approach: Boolean) = copy().apply { this.approach = approach } override val size = 3 diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/client/ui/interact/ItemOnFloorItem.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/client/ui/interact/ItemOnFloorItem.kt index 1ea115f6ae..13b6b778a7 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/client/ui/interact/ItemOnFloorItem.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/client/ui/interact/ItemOnFloorItem.kt @@ -2,21 +2,22 @@ package world.gregs.voidps.engine.client.ui.interact import world.gregs.voidps.engine.entity.character.Character import world.gregs.voidps.engine.entity.character.mode.interact.Interaction +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.item.Item import world.gregs.voidps.engine.entity.item.floor.FloorItem import world.gregs.voidps.engine.event.EventDispatcher import world.gregs.voidps.engine.event.Events import world.gregs.voidps.engine.suspend.arriveDelay -data class ItemOnFloorItem( - override val character: Character, +data class ItemOnFloorItem( + override val character: C, val floorItem: FloorItem, val id: String, val component: String, val item: Item, val itemSlot: Int, val inventory: String -) : Interaction() { +) : Interaction() { override fun copy(approach: Boolean) = copy().apply { this.approach = approach } override val size = 5 @@ -31,8 +32,8 @@ data class ItemOnFloorItem( } } -fun itemOnFloorItemOperate(item: String = "*", floorItem: String = "*", id: String = "*", component: String = "*", arrive: Boolean = true, handler: suspend ItemOnFloorItem.() -> Unit) { - Events.handle("item_approach_floor_item", item, floorItem, id, component) { +fun itemOnFloorItemOperate(item: String = "*", floorItem: String = "*", id: String = "*", component: String = "*", arrive: Boolean = true, handler: suspend ItemOnFloorItem.() -> Unit) { + Events.handle>("item_approach_floor_item", item, floorItem, id, component) { if (arrive) { arriveDelay() } @@ -40,8 +41,8 @@ fun itemOnFloorItemOperate(item: String = "*", floorItem: String = "*", id: Stri } } -fun itemOnFloorItemApproach(item: String = "*", floorItem: String = "*", id: String = "*", component: String = "*", handler: suspend ItemOnFloorItem.() -> Unit) { - Events.handle("item_approach_floor_item", item, floorItem, id, component) { +fun itemOnFloorItemApproach(item: String = "*", floorItem: String = "*", id: String = "*", component: String = "*", handler: suspend ItemOnFloorItem.() -> Unit) { + Events.handle>("item_approach_floor_item", item, floorItem, id, component) { handler.invoke(this) } } diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/client/ui/interact/ItemOnNPC.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/client/ui/interact/ItemOnNPC.kt index ac8c6ae2a8..675eaceac3 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/client/ui/interact/ItemOnNPC.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/client/ui/interact/ItemOnNPC.kt @@ -1,23 +1,26 @@ package world.gregs.voidps.engine.client.ui.interact -import world.gregs.voidps.engine.entity.character.Character import world.gregs.voidps.engine.entity.character.mode.interact.Interaction import world.gregs.voidps.engine.entity.character.mode.interact.TargetNPCContext import world.gregs.voidps.engine.entity.character.npc.NPC +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.item.Item import world.gregs.voidps.engine.event.EventDispatcher import world.gregs.voidps.engine.event.Events import world.gregs.voidps.engine.suspend.arriveDelay data class ItemOnNPC( - override val character: Character, + val player: Player, override val target: NPC, val id: String, val component: String, val item: Item, val itemSlot: Int, val inventory: String -) : Interaction(), TargetNPCContext { +) : Interaction(), TargetNPCContext { + + override val character = player + override fun copy(approach: Boolean) = copy().apply { this.approach = approach } override val size = 5 diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/client/ui/interact/ItemOnObject.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/client/ui/interact/ItemOnObject.kt index 55b852a2d1..494a8b63d0 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/client/ui/interact/ItemOnObject.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/client/ui/interact/ItemOnObject.kt @@ -1,6 +1,5 @@ package world.gregs.voidps.engine.client.ui.interact -import world.gregs.voidps.engine.entity.character.Character import world.gregs.voidps.engine.entity.character.mode.interact.Interaction import world.gregs.voidps.engine.entity.character.mode.interact.TargetObjectContext import world.gregs.voidps.engine.entity.character.player.Player @@ -11,14 +10,16 @@ import world.gregs.voidps.engine.event.Events import world.gregs.voidps.engine.suspend.arriveDelay data class ItemOnObject( - override val character: Character, + val player: Player, override val target: GameObject, val id: String, val component: String, val item: Item, val itemSlot: Int, val inventory: String -) : Interaction(), TargetObjectContext { +) : Interaction(), TargetObjectContext { + override val character = player + override fun copy(approach: Boolean) = copy().apply { this.approach = approach } override val size = 5 diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/client/ui/interact/ItemOnPlayer.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/client/ui/interact/ItemOnPlayer.kt index 6b2e323778..b0fab3d6fc 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/client/ui/interact/ItemOnPlayer.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/client/ui/interact/ItemOnPlayer.kt @@ -9,15 +9,15 @@ import world.gregs.voidps.engine.event.EventDispatcher import world.gregs.voidps.engine.event.Events import world.gregs.voidps.engine.suspend.arriveDelay -data class ItemOnPlayer( - override val character: Character, +data class ItemOnPlayer( + override val character: C, override val target: Player, val id: String, val component: String, val item: Item, val itemSlot: Int, val inventory: String -) : Interaction(), TargetPlayerContext { +) : Interaction(), TargetPlayerContext { override fun copy(approach: Boolean) = copy().apply { this.approach = approach } override val size = 4 @@ -31,8 +31,8 @@ data class ItemOnPlayer( } } -fun itemOnPlayerOperate(item: String = "*", id: String = "*", component: String = "*", arrive: Boolean = true, override: Boolean = true, handler: suspend ItemOnPlayer.() -> Unit) { - Events.handle("item_on_operate_player", item, id, component, override = override) { +fun itemOnPlayerOperate(item: String = "*", id: String = "*", component: String = "*", arrive: Boolean = true, override: Boolean = true, handler: suspend ItemOnPlayer.() -> Unit) { + Events.handle>("item_on_operate_player", item, id, component, override = override) { if (arrive) { arriveDelay() } @@ -40,8 +40,8 @@ fun itemOnPlayerOperate(item: String = "*", id: String = "*", component: String } } -fun itemOnPlayerApproach(item: String = "*", id: String = "*", component: String = "*", override: Boolean = true, handler: suspend ItemOnPlayer.() -> Unit) { - Events.handle("item_on_approach_player", item, id, component, override = override) { +fun itemOnPlayerApproach(item: String = "*", id: String = "*", component: String = "*", override: Boolean = true, handler: suspend ItemOnPlayer.() -> Unit) { + Events.handle>("item_on_approach_player", item, id, component, override = override) { handler.invoke(this) } } diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/CharacterContext.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/CharacterContext.kt index 427d3db5a8..3d2704a0cc 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/CharacterContext.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/CharacterContext.kt @@ -6,11 +6,11 @@ import world.gregs.voidps.engine.entity.character.player.Player /** * Context of a queue or interaction action to access a [character] as either [player] or [npc] but which is only known implicitly */ -interface CharacterContext { - val character: Character - val player: Player - get() = character as Player - val npc: NPC - get() = character as NPC +interface CharacterContext { + val character: C var onCancel: (() -> Unit)? + val CharacterContext.player: Player + get() = character + val CharacterContext.npc: NPC + get() = character } \ No newline at end of file diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/mode/interact/Interact.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/mode/interact/Interact.kt index 13e6b8bc76..09a192fc71 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/mode/interact/Interact.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/mode/interact/Interact.kt @@ -28,18 +28,18 @@ import world.gregs.voidps.engine.suspend.resumeSuspension class Interact( character: Character, val target: Entity, - interaction: Interaction, + interaction: Interaction<*>, strategy: TargetStrategy = TargetStrategy(target), private var approachRange: Int? = null, private val faceTarget: Boolean = true, shape: Int? = null ) : Movement(character, strategy, shape) { - private var approach: Interaction = interaction.copy(true) - private var operate: Interaction = interaction.copy(false) + private var approach: Interaction<*> = interaction.copy(true) + private var operate: Interaction<*> = interaction.copy(false) private var clearInteracted = false - fun updateInteraction(interaction: Interaction) { + fun updateInteraction(interaction: Interaction<*>) { approach = interaction.copy(true) operate = interaction.copy(false) clearInteracted = true @@ -151,7 +151,7 @@ class Interact( /** * Continue any suspended, clear any finished or start a new interaction */ - private fun launch(event: Interaction): Boolean { + private fun launch(event: Interaction<*>): Boolean { if (character.suspension != null) { character.resumeSuspension() return true diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/mode/interact/Interaction.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/mode/interact/Interaction.kt index 8632f8ba45..c4c8020089 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/mode/interact/Interaction.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/mode/interact/Interaction.kt @@ -1,15 +1,16 @@ package world.gregs.voidps.engine.entity.character.mode.interact +import world.gregs.voidps.engine.entity.character.Character import world.gregs.voidps.engine.entity.character.CharacterContext import world.gregs.voidps.engine.event.CancellableEvent import world.gregs.voidps.engine.event.SuspendableEvent -abstract class Interaction : CancellableEvent(), SuspendableEvent, CharacterContext { +abstract class Interaction : CancellableEvent(), SuspendableEvent, CharacterContext { var approach = false val operate: Boolean get() = !approach override var onCancel: (() -> Unit)? = null var launched = false - abstract fun copy(approach: Boolean): Interaction + abstract fun copy(approach: Boolean): Interaction } \ No newline at end of file diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/mode/interact/TargetFloorItemContext.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/mode/interact/TargetFloorItemContext.kt index 4a2a5840ec..6a3004870a 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/mode/interact/TargetFloorItemContext.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/mode/interact/TargetFloorItemContext.kt @@ -1,8 +1,9 @@ package world.gregs.voidps.engine.entity.character.mode.interact +import world.gregs.voidps.engine.entity.character.Character import world.gregs.voidps.engine.entity.character.CharacterContext import world.gregs.voidps.engine.entity.item.floor.FloorItem -interface TargetFloorItemContext : CharacterContext { +interface TargetFloorItemContext : CharacterContext { val target: FloorItem } \ No newline at end of file diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/mode/interact/TargetNPCContext.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/mode/interact/TargetNPCContext.kt index 4077101307..678ebe9d63 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/mode/interact/TargetNPCContext.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/mode/interact/TargetNPCContext.kt @@ -1,8 +1,9 @@ package world.gregs.voidps.engine.entity.character.mode.interact +import world.gregs.voidps.engine.entity.character.Character import world.gregs.voidps.engine.entity.character.CharacterContext import world.gregs.voidps.engine.entity.character.npc.NPC -interface TargetNPCContext : CharacterContext { +interface TargetNPCContext : CharacterContext { val target: NPC } \ No newline at end of file diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/mode/interact/TargetObjectContext.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/mode/interact/TargetObjectContext.kt index 6d8abcb252..979f0f5b66 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/mode/interact/TargetObjectContext.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/mode/interact/TargetObjectContext.kt @@ -1,8 +1,9 @@ package world.gregs.voidps.engine.entity.character.mode.interact +import world.gregs.voidps.engine.entity.character.Character import world.gregs.voidps.engine.entity.character.CharacterContext import world.gregs.voidps.engine.entity.obj.GameObject -interface TargetObjectContext : CharacterContext { +interface TargetObjectContext : CharacterContext { val target: GameObject } \ No newline at end of file diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/mode/interact/TargetPlayerContext.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/mode/interact/TargetPlayerContext.kt index 3886cb8bc9..d4f78ad53d 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/mode/interact/TargetPlayerContext.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/mode/interact/TargetPlayerContext.kt @@ -1,8 +1,9 @@ package world.gregs.voidps.engine.entity.character.mode.interact +import world.gregs.voidps.engine.entity.character.Character import world.gregs.voidps.engine.entity.character.CharacterContext import world.gregs.voidps.engine.entity.character.player.Player -interface TargetPlayerContext : CharacterContext { +interface TargetPlayerContext : CharacterContext { val target: Player } \ No newline at end of file diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/mode/move/AreaEntered.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/mode/move/AreaEntered.kt index b31bd909fc..a31092ac05 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/mode/move/AreaEntered.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/mode/move/AreaEntered.kt @@ -9,12 +9,12 @@ import world.gregs.voidps.engine.event.Events import world.gregs.voidps.engine.event.SuspendableEvent import world.gregs.voidps.type.Area -data class AreaEntered( - override val character: Character, +data class AreaEntered( + override val character: C, val name: String, val tags: Set, val area: Area -) : SuspendableEvent, CharacterContext { +) : SuspendableEvent, CharacterContext { override var onCancel: (() -> Unit)? = null override val size = 5 @@ -29,20 +29,20 @@ data class AreaEntered( } } -fun enterArea(area: String = "*", tag: String = "*", handler: suspend AreaEntered.() -> Unit) { - Events.handle("player_enter", area, "player", tag, "*") { +fun enterArea(area: String = "*", tag: String = "*", handler: suspend AreaEntered.() -> Unit) { + Events.handle>("player_enter", area, "player", tag, "*") { handler.invoke(this) } } -fun npcEnterArea(npc: String = "*", area: String = "*", tag: String = "*", handler: suspend AreaEntered.() -> Unit) { - Events.handle("npc_enter", area, npc, tag, "*") { +fun npcEnterArea(npc: String = "*", area: String = "*", tag: String = "*", handler: suspend AreaEntered.() -> Unit) { + Events.handle>("npc_enter", area, npc, tag, "*") { handler.invoke(this) } } -fun characterEnterArea(area: String = "*", tag: String = "*", handler: suspend AreaEntered.() -> Unit) { - val block: suspend AreaEntered.(EventDispatcher) -> Unit = { +fun characterEnterArea(area: String = "*", tag: String = "*", handler: suspend AreaEntered.() -> Unit) { + val block: suspend AreaEntered.(EventDispatcher) -> Unit = { handler.invoke(this) } Events.handle("player_enter", area, "player", tag, "*", handler = block) diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/mode/move/AreaExited.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/mode/move/AreaExited.kt index dfbe960efa..ef954ec411 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/mode/move/AreaExited.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/mode/move/AreaExited.kt @@ -9,12 +9,12 @@ import world.gregs.voidps.engine.event.Events import world.gregs.voidps.engine.event.SuspendableEvent import world.gregs.voidps.type.Area -data class AreaExited( - override val character: Character, +data class AreaExited( + override val character: C, val name: String, val tags: Set, val area: Area -) : SuspendableEvent, CharacterContext { +) : SuspendableEvent, CharacterContext { override var onCancel: (() -> Unit)? = null override val size = 5 @@ -29,20 +29,20 @@ data class AreaExited( } } -fun exitArea(area: String = "*", tag: String = "*", handler: suspend AreaExited.() -> Unit) { - Events.handle("player_exit", area, "player", tag, "*") { +fun exitArea(area: String = "*", tag: String = "*", handler: suspend AreaExited.() -> Unit) { + Events.handle>("player_exit", area, "player", tag, "*") { handler.invoke(this) } } -fun npcExitArea(npc: String = "*", area: String = "*", tag: String = "*", handler: suspend AreaExited.() -> Unit) { - Events.handle("npc_exit", area, npc, tag, "*") { +fun npcExitArea(npc: String = "*", area: String = "*", tag: String = "*", handler: suspend AreaExited.() -> Unit) { + Events.handle>("npc_exit", area, npc, tag, "*") { handler.invoke(this) } } -fun characterExitArea(area: String = "*", tag: String = "*", handler: suspend AreaExited.() -> Unit) { - val block: suspend AreaExited.(EventDispatcher) -> Unit = { +fun characterExitArea(area: String = "*", tag: String = "*", handler: suspend AreaExited.() -> Unit) { + val block: suspend AreaExited.(EventDispatcher) -> Unit = { handler.invoke(this) } Events.handle("player_exit", area, "player", tag, "*", handler = block) diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/mode/move/Moved.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/mode/move/Moved.kt index 0d0df9712f..be74633eff 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/mode/move/Moved.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/mode/move/Moved.kt @@ -13,11 +13,11 @@ import world.gregs.voidps.type.Tile /** * Entity moved between [from] and [to] tiles */ -data class Moved( - override val character: Character, +data class Moved( + override val character: C, val from: Tile, val to: Tile -) : CancellableEvent(), CharacterContext, SuspendableEvent { +) : CancellableEvent(), CharacterContext, SuspendableEvent { override var onCancel: (() -> Unit)? = null override val size = 4 @@ -31,39 +31,39 @@ data class Moved( } } -fun move(from: Tile = Tile.EMPTY, to: Tile = Tile.EMPTY, handler: suspend Moved.(Player) -> Unit) { +fun move(from: Tile = Tile.EMPTY, to: Tile = Tile.EMPTY, handler: suspend Moved.(Player) -> Unit) { Events.handle("player_move", "player", if (from == Tile.EMPTY) "*" else from, if (to == Tile.EMPTY) "*" else to, handler = handler) } -fun npcMove(npc: String = "*", from: Tile = Tile.EMPTY, to: Tile = Tile.EMPTY, handler: suspend Moved.(NPC) -> Unit) { +fun npcMove(npc: String = "*", from: Tile = Tile.EMPTY, to: Tile = Tile.EMPTY, handler: suspend Moved.(NPC) -> Unit) { Events.handle("npc_move", npc, if (from == Tile.EMPTY) "*" else from, if (to == Tile.EMPTY) "*" else to, handler = handler) } -fun characterMove(from: Tile = Tile.EMPTY, to: Tile = Tile.EMPTY, handler: suspend Moved.(Character) -> Unit) { +fun characterMove(from: Tile = Tile.EMPTY, to: Tile = Tile.EMPTY, handler: suspend Moved.(Character) -> Unit) { val fromTile: Any = if (from == Tile.EMPTY) "*" else from val toTile: Any = if (to == Tile.EMPTY) "*" else to Events.handle("player_move", "player", fromTile, toTile, handler = handler) Events.handle("npc_move", "*", fromTile, toTile, handler = handler) } -fun move(filter: Moved.(Player) -> Boolean = { true }, handler: suspend Moved.(Player) -> Unit) { - Events.handle("player_move", "player", "*", "*") { +fun move(filter: Moved.(Player) -> Boolean = { true }, handler: suspend Moved.(Player) -> Unit) { + Events.handle>("player_move", "player", "*", "*") { if (filter.invoke(this, it)) { handler.invoke(this, it) } } } -fun npcMove(filter: Moved.(NPC) -> Boolean = { true }, handler: suspend Moved.(NPC) -> Unit) { - Events.handle("npc_move", "*", "*", "*") { +fun npcMove(filter: Moved.(NPC) -> Boolean = { true }, handler: suspend Moved.(NPC) -> Unit) { + Events.handle>("npc_move", "*", "*", "*") { if (filter.invoke(this, it)) { handler.invoke(this, it) } } } -fun characterMove(filter: Moved.(Character) -> Boolean = { true }, block: suspend Moved.(Character) -> Unit) { - val handler: suspend Moved.(Character) -> Unit = { +fun characterMove(filter: Moved.(Character) -> Boolean = { true }, block: suspend Moved.(Character) -> Unit) { + val handler: suspend Moved.(Character) -> Unit = { if (filter.invoke(this, it)) { block.invoke(this, it) } diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/npc/NPCOption.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/npc/NPCOption.kt index a0254355d2..ae7e53453c 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/npc/NPCOption.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/npc/NPCOption.kt @@ -9,12 +9,12 @@ import world.gregs.voidps.engine.event.EventDispatcher import world.gregs.voidps.engine.event.Events import world.gregs.voidps.engine.suspend.arriveDelay -data class NPCOption( - override val character: Character, +data class NPCOption( + override val character: C, override val target: NPC, val def: NPCDefinition, val option: String -) : Interaction(), TargetNPCContext { +) : Interaction(), TargetNPCContext { override fun copy(approach: Boolean) = copy().apply { this.approach = approach } override val size = 3 @@ -27,41 +27,41 @@ data class NPCOption( } } -fun npcOperate(option: String, vararg npcs: String = arrayOf("*"), arrive: Boolean = false, override: Boolean = true, handler: suspend NPCOption.() -> Unit) { - npcOption("player_operate_npc", npcs, option, override, handler, arrive) +fun npcOperate(option: String, vararg npcs: String = arrayOf("*"), arrive: Boolean = false, override: Boolean = true, handler: suspend NPCOption.() -> Unit) { + npcOption("player_operate_npc", npcs, option, override, handler, arrive) } -fun npcApproach(option: String, vararg npcs: String = arrayOf("*"), override: Boolean = true, handler: suspend NPCOption.() -> Unit) { - npcOption("player_approach_npc", npcs, option, override, handler) +fun npcApproach(option: String, vararg npcs: String = arrayOf("*"), override: Boolean = true, handler: suspend NPCOption.() -> Unit) { + npcOption("player_approach_npc", npcs, option, override, handler) } -fun npcOperateNPC(option: String, vararg npcs: String = arrayOf("*"), arrive: Boolean = false, override: Boolean = true, handler: suspend NPCOption.() -> Unit) { - npcOption("npc_operate_npc", npcs, option, override, handler, arrive) +fun npcOperateNPC(option: String, vararg npcs: String = arrayOf("*"), arrive: Boolean = false, override: Boolean = true, handler: suspend NPCOption.() -> Unit) { + npcOption("npc_operate_npc", npcs, option, override, handler, arrive) } -fun npcApproachNPC(option: String, vararg npcs: String = arrayOf("*"), override: Boolean = true, handler: suspend NPCOption.() -> Unit) { - npcOption("npc_approach_npc", npcs, option, override, handler) +fun npcApproachNPC(option: String, vararg npcs: String = arrayOf("*"), override: Boolean = true, handler: suspend NPCOption.() -> Unit) { + npcOption("npc_approach_npc", npcs, option, override, handler) } -fun characterOperateNPC(option: String, vararg npcs: String = arrayOf("*"), arrive: Boolean = false, override: Boolean = true, handler: suspend NPCOption.() -> Unit) { - npcOption("player_operate_npc", npcs, option, override, handler, arrive) - npcOption("npc_operate_npc", npcs, option, override, handler, arrive) +fun characterOperateNPC(option: String, vararg npcs: String = arrayOf("*"), arrive: Boolean = false, override: Boolean = true, handler: suspend NPCOption.() -> Unit) { + npcOption("player_operate_npc", npcs, option, override, handler, arrive) + npcOption("npc_operate_npc", npcs, option, override, handler, arrive) } -fun characterApproachNPC(option: String, vararg npcs: String = arrayOf("*"), override: Boolean = true, handler: suspend NPCOption.() -> Unit) { - npcOption("player_approach_npc", npcs, option, override, handler) - npcOption("npc_approach_npc", npcs, option, override, handler) +fun characterApproachNPC(option: String, vararg npcs: String = arrayOf("*"), override: Boolean = true, handler: suspend NPCOption.() -> Unit) { + npcOption("player_approach_npc", npcs, option, override, handler) + npcOption("npc_approach_npc", npcs, option, override, handler) } -private fun npcOption( +private fun npcOption( type: String, npcs: Array, option: String, override: Boolean, - block: suspend NPCOption.() -> Unit, + block: suspend NPCOption.() -> Unit, arrive: Boolean = false ) { - val handler: suspend NPCOption.(D) -> Unit = { + val handler: suspend NPCOption.(D) -> Unit = { if (arrive) { arriveDelay() } diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/player/PlayerOption.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/player/PlayerOption.kt index 5eb102af14..4a0f5f64c9 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/player/PlayerOption.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/character/player/PlayerOption.kt @@ -3,15 +3,16 @@ package world.gregs.voidps.engine.entity.character.player import world.gregs.voidps.engine.entity.character.Character import world.gregs.voidps.engine.entity.character.mode.interact.Interaction import world.gregs.voidps.engine.entity.character.mode.interact.TargetPlayerContext +import world.gregs.voidps.engine.entity.character.npc.NPC import world.gregs.voidps.engine.event.EventDispatcher import world.gregs.voidps.engine.event.Events import world.gregs.voidps.engine.suspend.arriveDelay -data class PlayerOption( - override val character: Character, +data class PlayerOption( + override val character: C, override val target: Player, val option: String -) : Interaction(), TargetPlayerContext { +) : Interaction(), TargetPlayerContext { override fun copy(approach: Boolean) = copy().apply { this.approach = approach } override val size = 3 @@ -24,8 +25,8 @@ data class PlayerOption( } } -fun playerOperate(option: String, arrive: Boolean = false, override: Boolean = true, handler: suspend PlayerOption.() -> Unit) { - Events.handle("player_operate_player", option, "player", override = override) { +fun playerOperate(option: String, arrive: Boolean = false, override: Boolean = true, handler: suspend PlayerOption.() -> Unit) { + Events.handle>("player_operate_player", option, "player", override = override) { if (arrive) { arriveDelay() } @@ -33,14 +34,14 @@ fun playerOperate(option: String, arrive: Boolean = false, override: Boolean = t } } -fun playerApproach(option: String, override: Boolean = true, handler: suspend PlayerOption.() -> Unit) { - Events.handle("player_approach_player", option, "player", override = override) { +fun playerApproach(option: String, override: Boolean = true, handler: suspend PlayerOption.() -> Unit) { + Events.handle>("player_approach_player", option, "player", override = override) { handler.invoke(this) } } -fun npcOperatePlayer(option: String, npc: String = "*", arrive: Boolean = false, override: Boolean = true, handler: suspend PlayerOption.() -> Unit) { - Events.handle("npc_operate_player", option, npc, override = override) { +fun npcOperatePlayer(option: String, npc: String = "*", arrive: Boolean = false, override: Boolean = true, handler: suspend PlayerOption.() -> Unit) { + Events.handle>("npc_operate_player", option, npc, override = override) { if (arrive) { arriveDelay() } @@ -48,14 +49,14 @@ fun npcOperatePlayer(option: String, npc: String = "*", arrive: Boolean = false, } } -fun npcApproachPlayer(option: String, npc: String = "*", override: Boolean = true, handler: suspend PlayerOption.() -> Unit) { - Events.handle("npc_approach_player", option, npc, override = override) { +fun npcApproachPlayer(option: String, npc: String = "*", override: Boolean = true, handler: suspend PlayerOption.() -> Unit) { + Events.handle>("npc_approach_player", option, npc, override = override) { handler.invoke(this) } } -fun characterOperatePlayer(option: String, arrive: Boolean = false, override: Boolean = true, block: suspend PlayerOption.() -> Unit) { - val handler: suspend PlayerOption.(EventDispatcher) -> Unit = { +fun characterOperatePlayer(option: String, arrive: Boolean = false, override: Boolean = true, block: suspend PlayerOption.() -> Unit) { + val handler: suspend PlayerOption.(EventDispatcher) -> Unit = { if (arrive) { arriveDelay() } @@ -65,8 +66,8 @@ fun characterOperatePlayer(option: String, arrive: Boolean = false, override: Bo Events.handle("npc_operate_player", option, "*", override = override, handler = handler) } -fun characterApproachPlayer(option: String, override: Boolean = true, block: suspend PlayerOption.() -> Unit) { - val handler: suspend PlayerOption.(EventDispatcher) -> Unit = { +fun characterApproachPlayer(option: String, override: Boolean = true, block: suspend PlayerOption.() -> Unit) { + val handler: suspend PlayerOption.(EventDispatcher) -> Unit = { block.invoke(this) } Events.handle("player_approach_player", option, "player", override = override, handler = handler) diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/item/floor/FloorItemOption.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/item/floor/FloorItemOption.kt index ed9cb81d36..5e93b98803 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/item/floor/FloorItemOption.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/item/floor/FloorItemOption.kt @@ -3,15 +3,17 @@ package world.gregs.voidps.engine.entity.item.floor import world.gregs.voidps.engine.entity.character.Character import world.gregs.voidps.engine.entity.character.mode.interact.Interaction import world.gregs.voidps.engine.entity.character.mode.interact.TargetFloorItemContext +import world.gregs.voidps.engine.entity.character.npc.NPC +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.event.EventDispatcher import world.gregs.voidps.engine.event.Events import world.gregs.voidps.engine.suspend.arriveDelay -data class FloorItemOption( - override val character: Character, +data class FloorItemOption( + override val character: C, override val target: FloorItem, val option: String -) : Interaction(), TargetFloorItemContext { +) : Interaction(), TargetFloorItemContext { override fun copy(approach: Boolean) = copy().apply { this.approach = approach } override val size = 4 @@ -25,8 +27,8 @@ data class FloorItemOption( } } -fun floorItemOperate(option: String, item: String = "*", arrive: Boolean = true, override: Boolean = true, handler: suspend FloorItemOption.() -> Unit) { - Events.handle("player_operate_floor_item", option, item, "player", override = override) { +fun floorItemOperate(option: String, item: String = "*", arrive: Boolean = true, override: Boolean = true, handler: suspend FloorItemOption.() -> Unit) { + Events.handle>("player_operate_floor_item", option, item, "player", override = override) { if (arrive) { arriveDelay() } @@ -34,14 +36,14 @@ fun floorItemOperate(option: String, item: String = "*", arrive: Boolean = true, } } -fun floorItemApproach(option: String, item: String = "*", override: Boolean = true, handler: suspend FloorItemOption.() -> Unit) { - Events.handle("player_approach_floor_item", option, item, "player", override = override) { +fun floorItemApproach(option: String, item: String = "*", override: Boolean = true, handler: suspend FloorItemOption.() -> Unit) { + Events.handle>("player_approach_floor_item", option, item, "player", override = override) { handler.invoke(this) } } -fun npcOperateFloorItem(option: String, item: String = "*", npc: String = "*", arrive: Boolean = true, override: Boolean = true, handler: suspend FloorItemOption.() -> Unit) { - Events.handle("npc_operate_floor_item", option, item, npc, override = override) { +fun npcOperateFloorItem(option: String, item: String = "*", npc: String = "*", arrive: Boolean = true, override: Boolean = true, handler: suspend FloorItemOption.() -> Unit) { + Events.handle>("npc_operate_floor_item", option, item, npc, override = override) { if (arrive) { arriveDelay() } @@ -49,14 +51,14 @@ fun npcOperateFloorItem(option: String, item: String = "*", npc: String = "*", a } } -fun npcApproachFloorItem(option: String, item: String = "*", npc: String = "*", override: Boolean = true, handler: suspend FloorItemOption.() -> Unit) { - Events.handle("npc_approach_floor_item", option, item, npc, override = override) { +fun npcApproachFloorItem(option: String, item: String = "*", npc: String = "*", override: Boolean = true, handler: suspend FloorItemOption.() -> Unit) { + Events.handle>("npc_approach_floor_item", option, item, npc, override = override) { handler.invoke(this) } } -fun characterOperateFloorItem(option: String, item: String = "*", arrive: Boolean = true, override: Boolean = true, block: suspend FloorItemOption.() -> Unit) { - val handler: suspend FloorItemOption.(Character) -> Unit = { +fun characterOperateFloorItem(option: String, item: String = "*", arrive: Boolean = true, override: Boolean = true, block: suspend FloorItemOption.() -> Unit) { + val handler: suspend FloorItemOption.(Character) -> Unit = { if (arrive) { arriveDelay() } @@ -66,8 +68,8 @@ fun characterOperateFloorItem(option: String, item: String = "*", arrive: Boolea Events.handle("npc_operate_floor_item", option, item, "*", override = override, handler = handler) } -fun characterApproachFloorItem(option: String, item: String = "*", override: Boolean = true, block: suspend FloorItemOption.() -> Unit) { - val handler: suspend FloorItemOption.(Character) -> Unit = { +fun characterApproachFloorItem(option: String, item: String = "*", override: Boolean = true, block: suspend FloorItemOption.() -> Unit) { + val handler: suspend FloorItemOption.(Character) -> Unit = { block.invoke(this) } Events.handle("player_approach_floor_item", option, item, "player", override = override, handler = handler) diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/obj/ObjectOption.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/obj/ObjectOption.kt index 1b784ab238..a76944942b 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/entity/obj/ObjectOption.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/entity/obj/ObjectOption.kt @@ -10,12 +10,12 @@ import world.gregs.voidps.engine.event.EventDispatcher import world.gregs.voidps.engine.event.Events import world.gregs.voidps.engine.suspend.arriveDelay -data class ObjectOption( - override val character: Character, +data class ObjectOption( + override val character: C, override val target: GameObject, val def: ObjectDefinition, val option: String -) : Interaction(), TargetObjectContext { +) : Interaction(), TargetObjectContext { override fun copy(approach: Boolean) = copy().apply { this.approach = approach } override val size = 4 @@ -29,8 +29,8 @@ data class ObjectOption( } } -fun objectOperate(option: String, vararg objects: String = arrayOf("*"), arrive: Boolean = true, override: Boolean = true, block: suspend ObjectOption.() -> Unit) { - val handler: suspend ObjectOption.(Player) -> Unit = { +fun objectOperate(option: String, vararg objects: String = arrayOf("*"), arrive: Boolean = true, override: Boolean = true, block: suspend ObjectOption.() -> Unit) { + val handler: suspend ObjectOption.(Player) -> Unit = { if (arrive) { arriveDelay() } @@ -41,8 +41,8 @@ fun objectOperate(option: String, vararg objects: String = arrayOf("*"), arrive: } } -fun objectApproach(option: String, vararg objects: String = arrayOf("*"), override: Boolean = true, block: suspend ObjectOption.() -> Unit) { - val handler: suspend ObjectOption.(Player) -> Unit = { +fun objectApproach(option: String, vararg objects: String = arrayOf("*"), override: Boolean = true, block: suspend ObjectOption.() -> Unit) { + val handler: suspend ObjectOption.(Player) -> Unit = { block.invoke(this) } for (id in objects) { @@ -50,8 +50,8 @@ fun objectApproach(option: String, vararg objects: String = arrayOf("*"), overri } } -fun npcOperateObject(option: String, vararg objects: String = arrayOf("*"), npc: String = "*", arrive: Boolean = true, override: Boolean = true, block: suspend ObjectOption.() -> Unit) { - val handler: suspend ObjectOption.(NPC) -> Unit = { +fun npcOperateObject(option: String, vararg objects: String = arrayOf("*"), npc: String = "*", arrive: Boolean = true, override: Boolean = true, block: suspend ObjectOption.() -> Unit) { + val handler: suspend ObjectOption.(NPC) -> Unit = { if (arrive) { arriveDelay() } @@ -62,8 +62,8 @@ fun npcOperateObject(option: String, vararg objects: String = arrayOf("*"), npc: } } -fun npcApproachObject(option: String, vararg objects: String = arrayOf("*"), npc: String = "*", override: Boolean = true, block: suspend ObjectOption.() -> Unit) { - val handler: suspend ObjectOption.(NPC) -> Unit = { +fun npcApproachObject(option: String, vararg objects: String = arrayOf("*"), npc: String = "*", override: Boolean = true, block: suspend ObjectOption.() -> Unit) { + val handler: suspend ObjectOption.(NPC) -> Unit = { block.invoke(this) } for (id in objects) { @@ -71,8 +71,8 @@ fun npcApproachObject(option: String, vararg objects: String = arrayOf("*"), npc } } -fun characterOperateObject(option: String, vararg objects: String = arrayOf("*"), arrive: Boolean = true, override: Boolean = true, block: suspend ObjectOption.() -> Unit) { - val handler: suspend ObjectOption.(Character) -> Unit = { +fun characterOperateObject(option: String, vararg objects: String = arrayOf("*"), arrive: Boolean = true, override: Boolean = true, block: suspend ObjectOption.() -> Unit) { + val handler: suspend ObjectOption.(Character) -> Unit = { if (arrive) { arriveDelay() } @@ -84,8 +84,8 @@ fun characterOperateObject(option: String, vararg objects: String = arrayOf("*") } } -fun characterApproachObject(option: String, vararg objects: String = arrayOf("*"), override: Boolean = true, block: suspend ObjectOption.() -> Unit) { - val handler: suspend ObjectOption.(Character) -> Unit = { +fun characterApproachObject(option: String, vararg objects: String = arrayOf("*"), override: Boolean = true, block: suspend ObjectOption.() -> Unit) { + val handler: suspend ObjectOption.(Character) -> Unit = { block.invoke(this) } for (id in objects) { diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/event/SourceContext.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/event/SourceContext.kt deleted file mode 100644 index 2a5e500b61..0000000000 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/event/SourceContext.kt +++ /dev/null @@ -1,14 +0,0 @@ -package world.gregs.voidps.engine.event - -import world.gregs.voidps.engine.entity.character.Character -import world.gregs.voidps.engine.entity.character.player.Player - -interface SourceContext : Event { - val character: C -} - -val SourceContext.player: Player - get() = character - -val SourceContext.npc: Player - get() = character \ No newline at end of file diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/event/TargetContext.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/event/TargetContext.kt deleted file mode 100644 index 38ede37e51..0000000000 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/event/TargetContext.kt +++ /dev/null @@ -1,8 +0,0 @@ -package world.gregs.voidps.engine.event - -import world.gregs.voidps.engine.entity.Entity -import world.gregs.voidps.engine.entity.character.Character - -interface TargetContext : SourceContext { - val target: T -} \ No newline at end of file diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/queue/Action.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/queue/Action.kt index eae323ee95..77515b37aa 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/queue/Action.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/queue/Action.kt @@ -7,15 +7,15 @@ import world.gregs.voidps.engine.entity.character.Character import world.gregs.voidps.engine.entity.character.CharacterContext import world.gregs.voidps.engine.entity.character.clearAnimation -class Action( - override val character: Character, +class Action( + override val character: C, val name: String, val priority: ActionPriority, delay: Int = 0, val behaviour: LogoutBehaviour = LogoutBehaviour.Discard, override var onCancel: (() -> Unit)? = { character.clearAnimation() }, - var action: suspend Action.() -> Unit = {} -) : CharacterContext { + var action: suspend Action<*>.() -> Unit = {} +) : CharacterContext { var suspension: CancellableContinuation? = null var remaining: Int = delay private set diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/queue/ActionQueue.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/queue/ActionQueue.kt index 29faa68567..f1f470a5d1 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/queue/ActionQueue.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/queue/ActionQueue.kt @@ -23,11 +23,11 @@ class ActionQueue( } } - private val pending = ConcurrentLinkedQueue() - private val queue = ConcurrentLinkedQueue() - private var action: Action? = null + private val pending = ConcurrentLinkedQueue>() + private val queue = ConcurrentLinkedQueue>() + private var action: Action<*>? = null - fun add(action: Action): Boolean { + fun add(action: Action<*>): Boolean { return pending.add(action) } @@ -87,7 +87,7 @@ class ActionQueue( pending.clear() } - private fun processed(action: Action): Boolean { + private fun processed(action: Action<*>): Boolean { if (action.priority.closeInterfaces) { (character as? Player)?.closeMenu() } @@ -97,13 +97,13 @@ class ActionQueue( return action.removed } - private fun canProcess(action: Action) = action.priority == ActionPriority.Soft || (noDelay() && noInterrupt()) + private fun canProcess(action: Action<*>) = action.priority == ActionPriority.Soft || (noDelay() && noInterrupt()) private fun noDelay() = !character.hasClock("delay") private fun noInterrupt() = character is NPC || (character is Player && !character.hasMenuOpen() && character.dialogue == null) - private fun CoroutineScope.launch(action: Action) { + private fun CoroutineScope.launch(action: Action<*>) { if (character.resumeSuspension() || (character is Player && character.dialogueSuspension != null)) { return } @@ -143,36 +143,36 @@ class ActionQueue( } } -fun Character.queue(name: String, initialDelay: Int = 0, behaviour: LogoutBehaviour = LogoutBehaviour.Discard, onCancel: (() -> Unit)? = { clearAnimation() }, block: suspend Action.() -> Unit) { - queue.add(Action(this, name, ActionPriority.Normal, initialDelay, behaviour, onCancel = onCancel, action = block)) +fun C.queue(name: String, initialDelay: Int = 0, behaviour: LogoutBehaviour = LogoutBehaviour.Discard, onCancel: (() -> Unit)? = { clearAnimation() }, block: suspend Action.() -> Unit) { + queue.add(Action(this, name, ActionPriority.Normal, initialDelay, behaviour, onCancel = onCancel, action = block as suspend Action<*>.() -> Unit)) } -fun Character.softQueue( +fun C.softQueue( name: String, initialDelay: Int = 0, behaviour: LogoutBehaviour = LogoutBehaviour.Discard, onCancel: (() -> Unit)? = { clearAnimation() }, - block: suspend Action.() -> Unit + block: suspend Action.() -> Unit ) { - queue.add(Action(this, name, ActionPriority.Soft, initialDelay, behaviour, onCancel = onCancel, action = block)) + queue.add(Action(this, name, ActionPriority.Soft, initialDelay, behaviour, onCancel = onCancel, action = block as suspend Action<*>.() -> Unit)) } -fun Character.weakQueue( +fun C.weakQueue( name: String, initialDelay: Int = 0, behaviour: LogoutBehaviour = LogoutBehaviour.Discard, onCancel: (() -> Unit)? = { clearAnimation() }, - block: suspend Action.() -> Unit + block: suspend Action.() -> Unit ) { - queue.add(Action(this, name, ActionPriority.Weak, initialDelay, behaviour, onCancel = onCancel, action = block)) + queue.add(Action(this, name, ActionPriority.Weak, initialDelay, behaviour, onCancel = onCancel, action = block as suspend Action<*>.() -> Unit)) } -fun Character.strongQueue( +fun C.strongQueue( name: String, initialDelay: Int = 0, behaviour: LogoutBehaviour = LogoutBehaviour.Discard, onCancel: (() -> Unit)? = { clearAnimation() }, - block: suspend Action.() -> Unit + block: suspend Action.() -> Unit ) { - queue.add(Action(this, name, ActionPriority.Strong, initialDelay, behaviour, onCancel = onCancel, action = block)) + queue.add(Action(this, name, ActionPriority.Strong, initialDelay, behaviour, onCancel = onCancel, action = block as suspend Action<*>.() -> Unit)) } \ No newline at end of file diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/suspend/InfiniteSuspension.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/suspend/InfiniteSuspension.kt index e0b585301c..213d0a8a89 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/suspend/InfiniteSuspension.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/suspend/InfiniteSuspension.kt @@ -10,7 +10,7 @@ object InfiniteSuspension : Suspension() { return false } - context(CharacterContext) suspend operator fun invoke() { + context(CharacterContext<*>) suspend operator fun invoke() { suspendCancellableCoroutine { character.suspension = InfiniteSuspension } diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/suspend/PredicateSuspension.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/suspend/PredicateSuspension.kt index 497d0e5163..b417d1f29f 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/suspend/PredicateSuspension.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/suspend/PredicateSuspension.kt @@ -23,7 +23,7 @@ class PredicateSuspension( } companion object { - context(CharacterContext) suspend operator fun invoke(predicate: () -> Boolean) { + context(CharacterContext<*>) suspend operator fun invoke(predicate: () -> Boolean) { if (predicate.invoke()) { return } diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/suspend/Suspend.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/suspend/Suspend.kt index db6b9629bb..d8cf5931dd 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/suspend/Suspend.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/suspend/Suspend.kt @@ -34,7 +34,7 @@ fun Player.resumeDialogueSuspension(): Boolean { /** * Prevents non-interface player input and most processing */ -suspend fun CharacterContext.delay(ticks: Int = 1) { +suspend fun CharacterContext<*>.delay(ticks: Int = 1) { if (ticks <= 0) { return } @@ -49,34 +49,28 @@ suspend fun CharacterContext.delay(ticks: Int = 1) { * Note: can't be used after a dialogue suspension in an interaction as the * interaction will have finished and there will be nothing to resume the suspension */ -suspend fun CharacterContext.pause(ticks: Int = 1) { +suspend fun CharacterContext<*>.pause(ticks: Int = 1) { TickSuspension(ticks) } -suspend fun CharacterContext.awaitDialogues(): Boolean { - if (character !is Player) { - return false - } +suspend fun CharacterContext.awaitDialogues(): Boolean { PredicateSuspension { player.dialogue == null } return true } -suspend fun CharacterContext.awaitInterfaces(): Boolean { - if (character !is Player) { - return false - } +suspend fun CharacterContext.awaitInterfaces(): Boolean { PredicateSuspension { player.menu == null } return true } -suspend fun CharacterContext.pauseForever() { +suspend fun CharacterContext<*>.pauseForever() { InfiniteSuspension() } /** * Movement delay, typically used by interactions that perform animations or exact movements */ -suspend fun CharacterContext.arriveDelay() { +suspend fun CharacterContext<*>.arriveDelay() { val delay = character.remaining("last_movement") if (delay == -1) { return @@ -84,14 +78,14 @@ suspend fun CharacterContext.arriveDelay() { delay(delay) } -context(CharacterContext) fun Character.approachRange(range: Int?, update: Boolean = true) { +context(CharacterContext<*>) fun Character.approachRange(range: Int?, update: Boolean = true) { val interact = mode as? Interact ?: return interact.updateRange(range, update) } private val logger = InlineLogger() -context(CharacterContext) suspend fun Character.playAnimation(id: String, override: Boolean = false, canInterrupt: Boolean = true) { +context(CharacterContext<*>) suspend fun Character.playAnimation(id: String, override: Boolean = false, canInterrupt: Boolean = true) { val ticks = setAnimation(id, override = override) if (ticks == -1) { logger.warn { "No animation delay $id" } @@ -104,7 +98,7 @@ context(CharacterContext) suspend fun Character.playAnimation(id: String, overri } } } -context(Action) suspend fun Character.playAnimation(id: String, override: Boolean = false, canInterrupt: Boolean = true) { +context(Action<*>) suspend fun Character.playAnimation(id: String, override: Boolean = false, canInterrupt: Boolean = true) { val ticks = setAnimation(id, override = override) if (ticks == -1) { logger.warn { "No animation delay $id" } diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/suspend/TickSuspension.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/suspend/TickSuspension.kt index 81af9be7de..ba3b0122f9 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/suspend/TickSuspension.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/suspend/TickSuspension.kt @@ -22,7 +22,7 @@ data class TickSuspension( } companion object { - context(CharacterContext) suspend operator fun invoke(ticks: Int) { + context(CharacterContext<*>) suspend operator fun invoke(ticks: Int) { if (ticks <= 0) { return } diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/suspend/dialogue/ContinueSuspension.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/suspend/dialogue/ContinueSuspension.kt index a37ee70bcd..1813a4979f 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/suspend/dialogue/ContinueSuspension.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/suspend/dialogue/ContinueSuspension.kt @@ -3,6 +3,7 @@ package world.gregs.voidps.engine.suspend.dialogue import kotlinx.coroutines.CancellableContinuation import kotlinx.coroutines.suspendCancellableCoroutine import world.gregs.voidps.engine.entity.character.CharacterContext +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.suspend.Suspension import kotlin.coroutines.resume @@ -21,7 +22,7 @@ class ContinueSuspension( } companion object { - context(CharacterContext) suspend operator fun invoke() { + context(CharacterContext) suspend operator fun invoke() { suspendCancellableCoroutine { player.dialogueSuspension = ContinueSuspension(onCancel, it) } diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/suspend/dialogue/IntSuspension.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/suspend/dialogue/IntSuspension.kt index 0a2984c6fd..b8a9781a12 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/suspend/dialogue/IntSuspension.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/suspend/dialogue/IntSuspension.kt @@ -3,6 +3,7 @@ package world.gregs.voidps.engine.suspend.dialogue import kotlinx.coroutines.CancellableContinuation import kotlinx.coroutines.suspendCancellableCoroutine import world.gregs.voidps.engine.entity.character.CharacterContext +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.suspend.Suspension import kotlin.coroutines.resume @@ -23,7 +24,7 @@ class IntSuspension( } companion object { - context(CharacterContext) suspend operator fun invoke(): Int { + context(CharacterContext) suspend operator fun invoke(): Int { val int = suspendCancellableCoroutine { player.dialogueSuspension = IntSuspension(onCancel, it) } diff --git a/engine/src/main/kotlin/world/gregs/voidps/engine/suspend/dialogue/StringSuspension.kt b/engine/src/main/kotlin/world/gregs/voidps/engine/suspend/dialogue/StringSuspension.kt index 4a38a8ac3e..7aeda12b6d 100644 --- a/engine/src/main/kotlin/world/gregs/voidps/engine/suspend/dialogue/StringSuspension.kt +++ b/engine/src/main/kotlin/world/gregs/voidps/engine/suspend/dialogue/StringSuspension.kt @@ -3,6 +3,7 @@ package world.gregs.voidps.engine.suspend.dialogue import kotlinx.coroutines.CancellableContinuation import kotlinx.coroutines.suspendCancellableCoroutine import world.gregs.voidps.engine.entity.character.CharacterContext +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.suspend.Suspension import kotlin.coroutines.resume @@ -23,7 +24,7 @@ class StringSuspension( } companion object { - context(CharacterContext) suspend operator fun invoke(): String { + context(CharacterContext) suspend operator fun invoke(): String { val string = suspendCancellableCoroutine { player.dialogueSuspension = StringSuspension(onCancel, it) } diff --git a/game/src/main/kotlin/world/gregs/voidps/bot/skill/combat/TrainingBot.kts b/game/src/main/kotlin/world/gregs/voidps/bot/skill/combat/TrainingBot.kts index 6251b2b7fc..24a4e120a2 100644 --- a/game/src/main/kotlin/world/gregs/voidps/bot/skill/combat/TrainingBot.kts +++ b/game/src/main/kotlin/world/gregs/voidps/bot/skill/combat/TrainingBot.kts @@ -88,7 +88,7 @@ suspend fun Bot.train(map: AreaDefinition, skill: Skill, range: IntRange) { while (player.levels.getMax(skill) < range.last + 1 && hasAmmo(skill)) { if (target is GameObject) { objectOption(target, "Shoot-at") - await() + await>() await("tick") } else if (target is NPC) { npcOption(target, "Attack") diff --git a/game/src/main/kotlin/world/gregs/voidps/world/activity/achievement/ExplorerJack.kts b/game/src/main/kotlin/world/gregs/voidps/world/activity/achievement/ExplorerJack.kts index 807a2ea782..24292ecc35 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/activity/achievement/ExplorerJack.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/activity/achievement/ExplorerJack.kts @@ -81,7 +81,7 @@ npcOperate("Talk-to", "explorer_jack") { */ } -suspend fun NPCOption.whatIsTaskSystem() { +suspend fun NPCOption.whatIsTaskSystem() { npc("Well, the Task System is a potent method of guiding yourself to useful things to do around the world.") npc("You'll see up to six Tasks in your side bar if you click on the glowing Task List icon. You can click on one for more information about it, hints, waypoint arrows, that sort of thing.") npc("Every Task you do will earn you something of value which you can claim from me. It'll be money, mostly, but the Rewards tab for a Task will tell you more.
Good luck!") @@ -93,7 +93,7 @@ suspend fun NPCOption.whatIsTaskSystem() { val variables: VariableDefinitions by inject() -suspend fun NPCOption.claim(inventoryId: String) { +suspend fun NPCOption.claim(inventoryId: String) { npc("I'll just fill your $inventoryId with what you need, then.") val inventory = player.inventories.inventory(inventoryId) val progress = player["task_progress_overall", 0] diff --git a/game/src/main/kotlin/world/gregs/voidps/world/activity/quest/Cutscene.kt b/game/src/main/kotlin/world/gregs/voidps/world/activity/quest/Cutscene.kt index 566314d445..8c79cdc626 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/activity/quest/Cutscene.kt +++ b/game/src/main/kotlin/world/gregs/voidps/world/activity/quest/Cutscene.kt @@ -6,6 +6,7 @@ import world.gregs.voidps.engine.client.minimap import world.gregs.voidps.engine.client.ui.close import world.gregs.voidps.engine.client.ui.open import world.gregs.voidps.engine.entity.character.CharacterContext +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.get import world.gregs.voidps.engine.map.instance.Instances import world.gregs.voidps.engine.map.zone.DynamicZones @@ -24,28 +25,28 @@ private val tabs = listOf( "notes" ) -fun CharacterContext.startCutscene(region: Region): Region { +fun CharacterContext.startCutscene(region: Region): Region { val instance = Instances.small() get().copy(region, instance) hideTabs() return instance } -fun CharacterContext.hideTabs() { +fun CharacterContext.hideTabs() { tabs.forEach { player.close(it) } player.minimap(Minimap.HideMap) } -fun CharacterContext.stopCutscene(instance: Region) { +fun CharacterContext.stopCutscene(instance: Region) { Instances.free(instance) get().clear(instance) player.open("fade_in") showTabs() } -fun CharacterContext.showTabs() { +fun CharacterContext.showTabs() { tabs.forEach { player.open(it) } diff --git a/game/src/main/kotlin/world/gregs/voidps/world/activity/quest/mini/AlfredGrimhandsBarCrawl.kt b/game/src/main/kotlin/world/gregs/voidps/world/activity/quest/mini/AlfredGrimhandsBarCrawl.kt index be2b59b817..b8466c2cdd 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/activity/quest/mini/AlfredGrimhandsBarCrawl.kt +++ b/game/src/main/kotlin/world/gregs/voidps/world/activity/quest/mini/AlfredGrimhandsBarCrawl.kt @@ -2,6 +2,7 @@ package world.gregs.voidps.world.activity.quest.mini import world.gregs.voidps.engine.client.message import world.gregs.voidps.engine.entity.character.mode.interact.TargetNPCContext +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.inv.inventory import world.gregs.voidps.engine.inv.remove import world.gregs.voidps.engine.queue.queue @@ -11,9 +12,9 @@ import world.gregs.voidps.world.interact.dialogue.Talk import world.gregs.voidps.world.interact.dialogue.type.npc import world.gregs.voidps.world.interact.dialogue.type.player -suspend fun TargetNPCContext.barCrawlDrink( - start: (suspend TargetNPCContext.() -> Unit)? = null, - effects: suspend TargetNPCContext.() -> Unit = {}, +suspend fun TargetNPCContext.barCrawlDrink( + start: (suspend TargetNPCContext.() -> Unit)? = null, + effects: suspend TargetNPCContext.() -> Unit = {}, ) { player("I'm doing Alfred Grimhand's Barcrawl.") val info: Map = target.def.getOrNull("bar_crawl") ?: return @@ -35,7 +36,7 @@ suspend fun TargetNPCContext.barCrawlDrink( } } -val barCrawlFilter: TargetNPCContext.() -> Boolean = filter@{ +val barCrawlFilter: TargetNPCContext.() -> Boolean = filter@{ val info: Map = target.def.getOrNull("bar_crawl") ?: return@filter false val id = info["id"] as String player.quest("alfred_grimhands_barcrawl") == "signatures" && !player.containsVarbit("barcrawl_signatures", id) diff --git a/game/src/main/kotlin/world/gregs/voidps/world/activity/quest/mini/AlfredGrimhandsBarCrawl.kts b/game/src/main/kotlin/world/gregs/voidps/world/activity/quest/mini/AlfredGrimhandsBarCrawl.kts index 8d3f5d650c..6fcf361645 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/activity/quest/mini/AlfredGrimhandsBarCrawl.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/activity/quest/mini/AlfredGrimhandsBarCrawl.kts @@ -4,6 +4,7 @@ import world.gregs.voidps.engine.client.message import world.gregs.voidps.engine.client.ui.chat.Colours import world.gregs.voidps.engine.client.ui.chat.toTag import world.gregs.voidps.engine.entity.character.CharacterContext +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.world.activity.quest.sendMessageScroll import world.gregs.voidps.world.interact.entity.player.equip.inventoryItem @@ -31,7 +32,7 @@ inventoryItem("Read", "barcrawl_card") { ) } -fun CharacterContext.line(name: String, id: String): String { +fun CharacterContext.line(name: String, id: String): String { val complete = player.containsVarbit("barcrawl_signatures", id) return "<${Colours.bool(complete)}>$name - ${if (complete) "Completed!" else "Not Completed"}" } \ No newline at end of file diff --git a/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/crafting/Jewellery.kts b/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/crafting/Jewellery.kts index 12207e3d35..af1fa2f451 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/crafting/Jewellery.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/crafting/Jewellery.kts @@ -74,7 +74,7 @@ interfaceClose("make_mould*") { player -> player.sendScript("clear_dialogues") } -fun CharacterContext.make(component: String, amount: Int) { +fun CharacterContext.make(component: String, amount: Int) { val type = component.split("options_").first().removePrefix("make_").removeSuffix("_") val index = component.split("_").last().toInt() val gem = gems[index] diff --git a/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/crafting/Pottery.kts b/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/crafting/Pottery.kts index e48db682d6..8e156a8d11 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/crafting/Pottery.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/crafting/Pottery.kts @@ -38,7 +38,7 @@ objectOperate("Fire", "pottery_oven*", arrive = false) { make("cook_range", item) } -suspend fun TargetObjectContext.make(animation: String, item: Item) { +suspend fun TargetObjectContext.make(animation: String, item: Item) { val pottery = item.pottery.map val (id, amount) = makeAmount( items = pottery.keys.toList(), diff --git a/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/crafting/Weaving.kts b/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/crafting/Weaving.kts index e24dce742f..a6f51be252 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/crafting/Weaving.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/crafting/Weaving.kts @@ -56,7 +56,7 @@ itemOnObjectOperate(obj = "loom_*", itemDef = "weaving", arrive = false) { weave(target, item, amount) } -fun CharacterContext.weave(obj: GameObject, item: Item, amount: Int) { +fun CharacterContext.weave(obj: GameObject, item: Item, amount: Int) { val data = item.weaving val current = player.inventory.count(item.id) if (current < data.amount) { diff --git a/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/firemaking/Firemaking.kts b/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/firemaking/Firemaking.kts index 1887321e94..32fd4c0e8d 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/firemaking/Firemaking.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/firemaking/Firemaking.kts @@ -56,7 +56,7 @@ floorItemOperate("Light") { lightFire(player, target) } -suspend fun CharacterContext.lightFire( +suspend fun CharacterContext.lightFire( player: Player, floorItem: FloorItem ) { diff --git a/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/prayer/PrayerAltars.kts b/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/prayer/PrayerAltars.kts index 55bab2fe8d..5455f5a2a6 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/prayer/PrayerAltars.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/prayer/PrayerAltars.kts @@ -1,6 +1,7 @@ package world.gregs.voidps.world.activity.skill.prayer import world.gregs.voidps.engine.client.message +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.character.player.skill.Skill import world.gregs.voidps.engine.entity.character.setAnimation import world.gregs.voidps.engine.entity.obj.ObjectOption @@ -14,7 +15,7 @@ objectOperate("Pray-at", "prayer_altar_*") { pray() } -fun ObjectOption.pray() { +fun ObjectOption.pray() { if (player.levels.getOffset(Skill.Prayer) >= 0) { player.message("You already have full Prayer points.") } else { diff --git a/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/smithing/Anvil.kts b/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/smithing/Anvil.kts index a1e3591b33..ce14591e9e 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/smithing/Anvil.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/smithing/Anvil.kts @@ -130,7 +130,7 @@ interfaceClose("smithing") { player -> player.sendScript("clear_dialogues") } -suspend fun CharacterContext.smith(player: Player, metal: String, type: String, amount: Int) { +suspend fun CharacterContext.smith(player: Player, metal: String, type: String, amount: Int) { val item = if (metal == "steel" && type == "lantern") { "bullseye_lantern_frame" } else if (metal == "mithril" && type == "grapple") { @@ -155,7 +155,7 @@ suspend fun CharacterContext.smith(player: Player, metal: String, type: String, smith(smithing, metal, bars, quantity, type, item, actualAmount, true) } -suspend fun CharacterContext.smith( +suspend fun CharacterContext.smith( smithing: Smithing, metal: String, bars: Int, diff --git a/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/smithing/Furnace.kts b/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/smithing/Furnace.kts index 4204713acb..c69f5eb5ab 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/smithing/Furnace.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/activity/skill/smithing/Furnace.kts @@ -56,7 +56,7 @@ itemOnObjectOperate("*_ore", "furnace*", arrive = false) { smeltingOptions(player, target, list) } -suspend fun CharacterContext.smeltingOptions( +suspend fun CharacterContext.smeltingOptions( player: Player, gameObject: GameObject, bars: List diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/Choice.kt b/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/Choice.kt index f89e1360f9..1a274c8b2f 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/Choice.kt +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/Choice.kt @@ -3,6 +3,7 @@ package world.gregs.voidps.world.interact.dialogue.type import world.gregs.voidps.engine.client.ui.close import world.gregs.voidps.engine.client.ui.open import world.gregs.voidps.engine.entity.character.CharacterContext +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.suspend.dialogue.IntSuspension import world.gregs.voidps.world.interact.dialogue.sendLines @@ -21,7 +22,7 @@ private const val APPROXIMATE_WIDE_TITLE_LENGTH = 30 * } * } */ -suspend fun T.choice(title: String? = null, block: suspend ChoiceBuilder.() -> Unit) { +suspend fun > T.choice(title: String? = null, block: suspend ChoiceBuilder.() -> Unit) { val builder = ChoiceBuilder() block.invoke(builder) val lines = builder.build(this) @@ -40,7 +41,7 @@ suspend fun T.choice(title: String? = null, block: suspen * // ... * } */ -suspend fun CharacterContext.choice(lines: List, title: String? = null): Int { +suspend fun CharacterContext.choice(lines: List, title: String? = null): Int { check(lines.size in CHOICE_LINE_RANGE) { "Invalid choice line count ${lines.size} for $player" } val question = title?.trimIndent()?.replace("\n", "
") val multilineTitle = question?.contains("
") ?: false diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/ChoiceBuilder.kt b/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/ChoiceBuilder.kt index 29236b4140..796cbfc8cd 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/ChoiceBuilder.kt +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/ChoiceBuilder.kt @@ -1,15 +1,16 @@ package world.gregs.voidps.world.interact.dialogue.type import world.gregs.voidps.engine.entity.character.CharacterContext +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.world.interact.dialogue.Expression -typealias PlayerChoice = ChoiceBuilder +typealias PlayerChoice = ChoiceBuilder> -class ChoiceBuilder { +class ChoiceBuilder> { val values = mutableListOf>() - data class Option( + data class Option>( val text: String, val filter: Context.() -> Boolean, val block: suspend Context.() -> Unit diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/Destroy.kt b/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/Destroy.kt index 62a08d8642..af2153d702 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/Destroy.kt +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/Destroy.kt @@ -4,12 +4,13 @@ import world.gregs.voidps.engine.client.ui.close import world.gregs.voidps.engine.client.ui.open import world.gregs.voidps.engine.data.definition.ItemDefinitions import world.gregs.voidps.engine.entity.character.CharacterContext +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.get import world.gregs.voidps.engine.suspend.dialogue.StringSuspension private const val DESTROY_INTERFACE_ID = "dialogue_confirm_destroy" -suspend fun CharacterContext.destroy(item: String, text: String): Boolean { +suspend fun CharacterContext.destroy(item: String, text: String): Boolean { val itemDecoder: ItemDefinitions = get() check(player.open(DESTROY_INTERFACE_ID)) { "Unable to open destroy dialogue for $item $player" } player.interfaces.sendText(DESTROY_INTERFACE_ID, "line1", text.trimIndent().replace("\n", "
")) diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/ExpSkillLamp.kt b/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/ExpSkillLamp.kt index 479c8e80fd..298374613f 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/ExpSkillLamp.kt +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/ExpSkillLamp.kt @@ -4,12 +4,13 @@ import net.pearx.kasechange.toPascalCase import world.gregs.voidps.engine.client.ui.close import world.gregs.voidps.engine.client.ui.open import world.gregs.voidps.engine.entity.character.CharacterContext +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.character.player.skill.Skill import world.gregs.voidps.engine.suspend.dialogue.StringSuspension private const val EXPERIENCE_SKILL_LAMP = "skill_stat_advance" -suspend fun CharacterContext.skillLamp(): Skill { +suspend fun CharacterContext.skillLamp(): Skill { check(player.open(EXPERIENCE_SKILL_LAMP)) { "Unable to open skill lamp dialogue for $player" } val result = StringSuspension() player.close(EXPERIENCE_SKILL_LAMP) diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/IntEntry.kt b/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/IntEntry.kt index 23b632649d..43c21a7284 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/IntEntry.kt +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/IntEntry.kt @@ -2,9 +2,10 @@ package world.gregs.voidps.world.interact.dialogue.type import world.gregs.voidps.engine.client.sendScript import world.gregs.voidps.engine.entity.character.CharacterContext +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.suspend.dialogue.IntSuspension -suspend fun CharacterContext.intEntry(text: String): Int { +suspend fun CharacterContext.intEntry(text: String): Int { player.sendScript("int_entry", text) return IntSuspension() } \ No newline at end of file diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/ItemBox.kt b/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/ItemBox.kt index 94dae58755..e098c62a7a 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/ItemBox.kt +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/ItemBox.kt @@ -6,13 +6,14 @@ import world.gregs.voidps.engine.client.ui.open import world.gregs.voidps.engine.data.definition.FontDefinitions import world.gregs.voidps.engine.data.definition.ItemDefinitions import world.gregs.voidps.engine.entity.character.CharacterContext +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.get import world.gregs.voidps.engine.suspend.dialogue.ContinueSuspension private const val ITEM_INTERFACE_ID = "dialogue_obj_box" private const val DOUBLE_ITEM_INTERFACE_ID = "dialogue_double_obj_box" -suspend fun CharacterContext.item(item: String, zoom: Int, text: String, sprite: Int? = null) { +suspend fun CharacterContext.item(item: String, zoom: Int, text: String, sprite: Int? = null) { check(player.open(ITEM_INTERFACE_ID)) { "Unable to open item dialogue for $player" } player.sendScript("dialogue_item_zoom", get().get(item).id, zoom) if (sprite != null) { @@ -24,7 +25,7 @@ suspend fun CharacterContext.item(item: String, zoom: Int, text: String, sprite: player.close(ITEM_INTERFACE_ID) } -suspend fun CharacterContext.items(item1: String, item2: String, text: String) { +suspend fun CharacterContext.items(item1: String, item2: String, text: String) { check(player.open(DOUBLE_ITEM_INTERFACE_ID)) { "Unable to open item dialogue for $player" } player.interfaces.sendItem(DOUBLE_ITEM_INTERFACE_ID, "model1", get().get(item1).id) player.interfaces.sendItem(DOUBLE_ITEM_INTERFACE_ID, "model2", get().get(item2).id) diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/LevelUp.kt b/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/LevelUp.kt index 1ebbe7de0b..26e9fcb4c3 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/LevelUp.kt +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/LevelUp.kt @@ -3,12 +3,13 @@ package world.gregs.voidps.world.interact.dialogue.type import world.gregs.voidps.engine.client.ui.close import world.gregs.voidps.engine.client.ui.open import world.gregs.voidps.engine.entity.character.CharacterContext +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.character.player.skill.Skill import world.gregs.voidps.engine.suspend.dialogue.ContinueSuspension private const val LEVEL_UP_INTERFACE_ID = "dialogue_level_up" -suspend fun CharacterContext.levelUp(skill: Skill, text: String) { +suspend fun CharacterContext.levelUp(skill: Skill, text: String) { val lines = text.trimIndent().lines() check(player.open(LEVEL_UP_INTERFACE_ID)) { "Unable to open level up interface for $player" } for ((index, line) in lines.withIndex()) { diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/MakeAmount.kt b/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/MakeAmount.kt index 5c9334f51e..34288ac93a 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/MakeAmount.kt +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/MakeAmount.kt @@ -12,7 +12,7 @@ private const val INTERFACE_ID = "dialogue_skill_creation" private const val INTERFACE_AMOUNT_ID = "skill_creation_amount" private const val DEFAULT_TEXT = "Choose how many you wish to make, then
click on the chosen item to begin." -suspend fun CharacterContext.makeAmount( +suspend fun CharacterContext.makeAmount( items: List, type: String, maximum: Int, @@ -25,7 +25,7 @@ suspend fun CharacterContext.makeAmount( return id to result.second } -suspend fun CharacterContext.makeAmountIndex( +suspend fun CharacterContext.makeAmountIndex( items: List, type: String, maximum: Int, diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/NPCDialogue.kt b/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/NPCDialogue.kt index c9e6a90055..b0621503ad 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/NPCDialogue.kt +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/NPCDialogue.kt @@ -17,18 +17,18 @@ import world.gregs.voidps.network.login.protocol.encode.npcDialogueHead import world.gregs.voidps.world.interact.dialogue.Expression import world.gregs.voidps.world.interact.dialogue.sendChat -suspend inline fun CharacterContext.npc(text: String, largeHead: Boolean? = null, clickToContinue: Boolean = true, title: String? = null) { +suspend inline fun CharacterContext.npc(text: String, largeHead: Boolean? = null, clickToContinue: Boolean = true, title: String? = null) { val expression = E::class.simpleName!!.toSnakeCase() npc(expression, text, largeHead, clickToContinue, title) } -suspend inline fun CharacterContext.npc(npcId: String, text: String, largeHead: Boolean? = null, clickToContinue: Boolean = true, title: String? = null) { +suspend inline fun CharacterContext.npc(npcId: String, text: String, largeHead: Boolean? = null, clickToContinue: Boolean = true, title: String? = null) { val expression = E::class.simpleName!!.toSnakeCase() npc(npcId, expression, text, largeHead, clickToContinue, title) } @JvmName("npcExpression") -suspend fun CharacterContext.npc(expression: String, text: String, largeHead: Boolean? = null, clickToContinue: Boolean = true, title: String? = null) { +suspend fun CharacterContext.npc(expression: String, text: String, largeHead: Boolean? = null, clickToContinue: Boolean = true, title: String? = null) { val target: NPC = player["dialogue_target"] ?: throw IllegalArgumentException("No npc specified for dialogue. Please use player.talkWith(npc) or npc(npcId, text).") val id = target["transform_id", player.get("dialogue_def")?.stringId ?: target.id] if (target["faces", true]) { @@ -37,7 +37,7 @@ suspend fun CharacterContext.npc(expression: String, text: String, largeHead: Bo npc(id, expression, text, largeHead, clickToContinue, title) } -suspend fun CharacterContext.npc(npcId: String, expression: String, text: String, largeHead: Boolean? = null, clickToContinue: Boolean = true, title: String? = null) { +suspend fun CharacterContext.npc(npcId: String, expression: String, text: String, largeHead: Boolean? = null, clickToContinue: Boolean = true, title: String? = null) { val lines = if (text.contains("\n")) text.trimIndent().lines() else get().get("q8_full").splitLines(text, 380) check(lines.size <= 4) { "Maximum npc chat lines exceeded ${lines.size} for $player" } val id = getInterfaceId(lines.size, clickToContinue) diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/PlayerDialogue.kt b/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/PlayerDialogue.kt index 7f04220530..5b08bba30d 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/PlayerDialogue.kt +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/PlayerDialogue.kt @@ -14,12 +14,12 @@ import world.gregs.voidps.network.login.protocol.encode.playerDialogueHead import world.gregs.voidps.world.interact.dialogue.Expression import world.gregs.voidps.world.interact.dialogue.sendChat -suspend inline fun CharacterContext.player(text: String, largeHead: Boolean = false, clickToContinue: Boolean = true, title: String? = null) { +suspend inline fun CharacterContext.player(text: String, largeHead: Boolean = false, clickToContinue: Boolean = true, title: String? = null) { val expression = E::class.simpleName!!.toSnakeCase() player(expression, text, largeHead, clickToContinue, title) } -suspend fun CharacterContext.player(expression: String, text: String, largeHead: Boolean = false, clickToContinue: Boolean = true, title: String? = null) { +suspend fun CharacterContext.player(expression: String, text: String, largeHead: Boolean = false, clickToContinue: Boolean = true, title: String? = null) { val lines = if (text.contains("\n")) text.trimIndent().lines() else get().get("q8_full").splitLines(text, 380) check(lines.size <= 4) { "Maximum player chat lines exceeded ${lines.size} for $player" } val id = getInterfaceId(lines.size, clickToContinue) diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/QuestStart.kt b/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/QuestStart.kt index 6a20793744..06d78ae267 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/QuestStart.kt +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/QuestStart.kt @@ -6,6 +6,7 @@ import world.gregs.voidps.engine.client.ui.close import world.gregs.voidps.engine.client.ui.open import world.gregs.voidps.engine.data.definition.QuestDefinitions import world.gregs.voidps.engine.entity.character.CharacterContext +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.character.player.skill.Skill import world.gregs.voidps.engine.entity.character.player.skill.level.Level.hasMax import world.gregs.voidps.engine.get @@ -15,7 +16,7 @@ import world.gregs.voidps.world.activity.quest.questComplete private const val QUEST_START_ID = "quest_intro" -suspend fun CharacterContext.startQuest(questId: String): Boolean { +suspend fun CharacterContext.startQuest(questId: String): Boolean { check(player.open(QUEST_START_ID)) { "Unable to open destroy dialogue for $questId $player" } val questDefinitions: QuestDefinitions = get() val quest = questDefinitions.getOrNull(questId) diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/Statement.kt b/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/Statement.kt index 759f4b5fb4..a66dccdaa4 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/Statement.kt +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/Statement.kt @@ -4,13 +4,14 @@ import world.gregs.voidps.engine.client.ui.close import world.gregs.voidps.engine.client.ui.open import world.gregs.voidps.engine.data.definition.FontDefinitions import world.gregs.voidps.engine.entity.character.CharacterContext +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.get import world.gregs.voidps.engine.suspend.dialogue.ContinueSuspension import world.gregs.voidps.world.interact.dialogue.sendLines private const val MAXIMUM_STATEMENT_SIZE = 5 -suspend fun CharacterContext.statement(text: String, clickToContinue: Boolean = true) { +suspend fun CharacterContext.statement(text: String, clickToContinue: Boolean = true) { val lines = if (text.contains("\n")) text.trimIndent().lines() else get().get("q8_full").splitLines(text, 470) check(lines.size <= MAXIMUM_STATEMENT_SIZE) { "Maximum statement lines exceeded ${lines.size} for $player" } val id = getInterfaceId(lines.size, clickToContinue) diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/StringEntry.kt b/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/StringEntry.kt index 9256346796..d6d786dd1e 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/StringEntry.kt +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/dialogue/type/StringEntry.kt @@ -2,9 +2,10 @@ package world.gregs.voidps.world.interact.dialogue.type import world.gregs.voidps.engine.client.sendScript import world.gregs.voidps.engine.entity.character.CharacterContext +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.suspend.dialogue.StringSuspension -suspend fun CharacterContext.stringEntry(text: String): String { +suspend fun CharacterContext.stringEntry(text: String): String { player.sendScript("string_entry", text) return StringSuspension() } \ No newline at end of file diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/combat/Combat.kts b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/combat/Combat.kts index 33592a4641..4e091b472e 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/combat/Combat.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/combat/Combat.kts @@ -24,7 +24,7 @@ import world.gregs.voidps.world.interact.entity.player.combat.special.specialAtt * to allow movement & [Interact] to complete and start [combat] on the same tick * After [Interact] is complete switch to using [CombatMovement] */ -onEvent { +onEvent> { combat(character, target) } diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/combat/CombatInteraction.kt b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/combat/CombatInteraction.kt index a2323ea019..d4e0959417 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/combat/CombatInteraction.kt +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/combat/CombatInteraction.kt @@ -11,10 +11,10 @@ import world.gregs.voidps.engine.event.EventDispatcher * allow the first [CombatSwing] to occur on the same tick. * After [Interact] is complete it is switched to [CombatMovement] */ -data class CombatInteraction( - override val character: Character, +data class CombatInteraction( + override val character: C, val target: Character -) : Interaction() { +) : Interaction() { override fun copy(approach: Boolean) = copy().apply { this.approach = approach } override val size = 1 diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/npc/Banker.kts b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/npc/Banker.kts index ecca786ebf..cfe76b8372 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/npc/Banker.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/npc/Banker.kts @@ -6,6 +6,7 @@ import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.entity.character.CharacterContext import world.gregs.voidps.engine.entity.character.npc.NPCs import world.gregs.voidps.engine.entity.character.npc.npcApproach +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.obj.objectOperate import world.gregs.voidps.engine.inject import world.gregs.voidps.engine.suspend.approachRange @@ -39,7 +40,7 @@ objectOperate("Use", "bank_*", arrive = false) { menu() } -suspend fun CharacterContext.menu() { +suspend fun CharacterContext.menu() { choice { option("I'd like to access my bank account, please.", block = { player.open("bank") }) option("I'd like to check my PIN settings.", block = { player.open("bank_pin") }) @@ -73,7 +74,7 @@ npcApproach("Collect", "banker*") { player.open("collection_box") } -fun CharacterContext.achievement() { +fun CharacterContext.achievement() { if (!player["you_can_bank_on_us_task", false]) { player["you_can_bank_on_us_task"] = true player.addVarbit("task_reward_items", "red_dye") diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/npc/Canoe.kt b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/npc/Canoe.kt index 572026f3f7..e109445fe2 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/npc/Canoe.kt +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/npc/Canoe.kt @@ -1,13 +1,14 @@ package world.gregs.voidps.world.interact.entity.npc import world.gregs.voidps.engine.entity.character.CharacterContext +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.character.player.skill.Skill import world.gregs.voidps.world.interact.dialogue.Neutral import world.gregs.voidps.world.interact.dialogue.Quiz import world.gregs.voidps.world.interact.dialogue.type.npc import world.gregs.voidps.world.interact.dialogue.type.player -suspend fun CharacterContext.minimumCanoeLevel(): Boolean { +suspend fun CharacterContext.minimumCanoeLevel(): Boolean { player("Could you teach me about canoes?") if (player.levels.get(Skill.Woodcutting) < 12) { npc("Well, you don't look like you have the skill to make a canoe.") diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/npc/shop/Shop.kt b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/npc/shop/Shop.kt index 79717b3d6c..edbc072021 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/npc/shop/Shop.kt +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/npc/shop/Shop.kt @@ -25,7 +25,7 @@ fun Player.shopInventory(sample: Boolean = hasShopSample()): Inventory { } } -suspend fun TargetNPCContext.buy(item: String, cost: Int, message: String = "Oh dear. I don't seem to have enough money."): Boolean { +suspend fun TargetNPCContext.buy(item: String, cost: Int, message: String = "Oh dear. I don't seem to have enough money."): Boolean { player.inventory.transaction { remove("coins", cost) add(item) diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/obj/Teleport.kt b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/obj/Teleport.kt index 1bf95368da..0b12bf1cb2 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/obj/Teleport.kt +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/obj/Teleport.kt @@ -10,12 +10,13 @@ import world.gregs.voidps.engine.event.Events import world.gregs.voidps.type.Tile data class Teleport( - override val character: Character, + val player: Player, val id: String, val tile: Tile, val obj: ObjectDefinition, val option: String -) : CancellableEvent(), CharacterContext { +) : CancellableEvent(), CharacterContext { + override val character = player var delay: Int? = null override var onCancel: (() -> Unit)? = null var land: Boolean = false diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/obj/Teleports.kt b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/obj/Teleports.kt index d238c9dc4d..ab0272039c 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/obj/Teleports.kt +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/obj/Teleports.kt @@ -23,11 +23,11 @@ class Teleports { private lateinit var teleports: Map> - suspend fun teleport(objectOption: ObjectOption, option: String = objectOption.option): Boolean { - return teleport(objectOption, objectOption.player, objectOption.def, objectOption.target.tile, option) + suspend fun teleport(objectOption: ObjectOption, option: String = objectOption.option): Boolean { + return teleport(objectOption, objectOption.character, objectOption.def, objectOption.target.tile, option) } - suspend fun teleport(context: CharacterContext, player: Player, def: ObjectDefinition, targetTile: Tile, option: String): Boolean { + 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) { diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/player/display/tab/Emotes.kts b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/player/display/tab/Emotes.kts index ecf59a47fd..15657a4fc4 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/player/display/tab/Emotes.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/player/display/tab/Emotes.kts @@ -79,7 +79,7 @@ interfaceOption(id = "emotes") { } } -suspend fun CharacterContext.unlocked(id: String, emote: String): Boolean { +suspend fun CharacterContext.unlocked(id: String, emote: String): Boolean { if (emote.startsWith("Goblin")) { if (player["unlocked_emote_lost_tribe", false]) { return true @@ -148,16 +148,16 @@ itemChange("worn_equipment", EquipSlot.Cape) { player -> player["unlocked_emote_skillcape"] = item.def.contains("skill_cape") || item.def.contains("skill_cape_t") || item.id == "quest_point_cape" } -suspend fun CharacterContext.playEnhancedEmote(player: Player, type: String) { +suspend fun CharacterContext.playEnhancedEmote(player: Player, type: String) { player.playAnimation("emote_enhanced_$type") } -suspend fun CharacterContext.playEnhancedYawnEmote(player: Player) { +suspend fun CharacterContext.playEnhancedYawnEmote(player: Player) { player.setGraphic("emote_enhanced_yawn") player.playAnimation("emote_enhanced_yawn") } -suspend fun CharacterContext.playGiveThanksEmote(player: Player) { +suspend fun CharacterContext.playGiveThanksEmote(player: Player) { player.setGraphic("emote_give_thanks") player.playAnimation("emote_turkey_transform") player.transform("turkey") @@ -167,7 +167,7 @@ suspend fun CharacterContext.playGiveThanksEmote(player: Player) { player.playAnimation("emote_turkey_return") } -suspend fun CharacterContext.playSealOfApprovalEmote(player: Player) { +suspend fun CharacterContext.playSealOfApprovalEmote(player: Player) { player.setGraphic("emote_seal_of_approval") player.playAnimation("emote_seal_of_approval") player.transform("seal") @@ -178,12 +178,12 @@ suspend fun CharacterContext.playSealOfApprovalEmote(player: Player) { player.playAnimation("emote_seal_stand") } -suspend fun CharacterContext.playSkillCapeEmote(player: Player, skill: String) { +suspend fun CharacterContext.playSkillCapeEmote(player: Player, skill: String) { player.setGraphic("emote_$skill") player.playAnimation("emote_$skill") } -suspend fun CharacterContext.playDungeoneeringCapeEmote(player: Player) { +suspend fun CharacterContext.playDungeoneeringCapeEmote(player: Player) { player.setGraphic("emote_dungeoneering_start") player.playAnimation("emote_dungeoneering_start") when (random.nextInt(3)) { @@ -203,7 +203,7 @@ suspend fun CharacterContext.playDungeoneeringCapeEmote(player: Player) { player.transform("") } -suspend fun CharacterContext.playDungeoneeringMasterCapeEmote(player: Player) { +suspend fun CharacterContext.playDungeoneeringMasterCapeEmote(player: Player) { val direction = player.facing player.transform("sagittarian_ranger") diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/player/equip/InventoryOption.kt b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/player/equip/InventoryOption.kt index f500277731..8667f358e6 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/player/equip/InventoryOption.kt +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/player/equip/InventoryOption.kt @@ -1,18 +1,21 @@ package world.gregs.voidps.world.interact.entity.player.equip -import world.gregs.voidps.engine.entity.character.Character import world.gregs.voidps.engine.entity.character.mode.interact.Interaction +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.item.Item import world.gregs.voidps.engine.event.EventDispatcher import world.gregs.voidps.engine.event.Events data class InventoryOption( - override val character: Character, + val player: Player, val inventory: String, val item: Item, val slot: Int, val option: String -) : Interaction() { +) : Interaction() { + + override val character = player + override fun copy(approach: Boolean) = copy().apply { this.approach = approach } override val size = 4 diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/Doric.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/Doric.kts index 4f0be60a80..ee19d55c85 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/Doric.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/Doric.kts @@ -2,6 +2,7 @@ package world.gregs.voidps.world.map import world.gregs.voidps.engine.entity.character.CharacterContext import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.character.player.skill.Skill import world.gregs.voidps.engine.entity.item.Item import world.gregs.voidps.engine.entity.item.floor.FloorItems @@ -47,7 +48,7 @@ npcOperate("Talk-to", "doric") { } } -suspend fun CharacterContext.noOre() { +suspend fun CharacterContext.noOre() { player("Sorry, I don't have them all yet.") npc("Not to worry, stick at it. Remember, I need 6 clay, 4 copper ore, and 2 iron ore.") choice { @@ -62,7 +63,7 @@ suspend fun CharacterContext.noOre() { } } -suspend fun CharacterContext.unstarted() { +suspend fun CharacterContext.unstarted() { npc("Hello traveller, what brings you to my humble smithy?") choice { option("I wanted to use your anvils.") { @@ -101,7 +102,7 @@ suspend fun CharacterContext.unstarted() { } } -suspend fun CharacterContext.startQuest() { +suspend fun CharacterContext.startQuest() { if (player.levels.get(Skill.Mining) < 15) { statement("Before starting this quest, be aware that one or more of your skill levels are lower than recommended.") } @@ -133,13 +134,13 @@ suspend fun CharacterContext.startQuest() { } } -suspend fun CharacterContext.takeOre() { +suspend fun CharacterContext.takeOre() { item("copper_ore", 600, "You hand the clay, copper, and iron to Doric.") player.inventory.remove(ores) questComplete() } -fun CharacterContext.questComplete() { +fun CharacterContext.questComplete() { player["dorics_quest"] = "completed" player.playJingle("quest_complete_1") player.experience.add(Skill.Mining, 1300.0) diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/al_kharid/AlTheCamel.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/al_kharid/AlTheCamel.kts index 6d5f654b6b..f4b2ff3297 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/al_kharid/AlTheCamel.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/al_kharid/AlTheCamel.kts @@ -7,6 +7,7 @@ import world.gregs.voidps.engine.entity.character.CharacterContext import world.gregs.voidps.engine.entity.character.npc.NPC import world.gregs.voidps.engine.entity.character.npc.NPCOption import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.character.player.equip.equipped import world.gregs.voidps.engine.entity.character.setAnimation import world.gregs.voidps.engine.entity.obj.GameObjects @@ -53,23 +54,23 @@ npcOperate("Talk-to", "*camel") { } } -suspend fun CharacterContext.bestOfLuck() { +suspend fun CharacterContext.bestOfLuck() { player("Well, best of luck with that.") npc("If you want to hear my poems once more, please come back again.") } -suspend fun CharacterContext.noThankYou() { +suspend fun CharacterContext.noThankYou() { npc("Ah, well. I shall return to writing poems to Elly's beauty.") whatDoesSheThink() } -suspend fun CharacterContext.idLoveTo() { +suspend fun CharacterContext.idLoveTo() { npc("That's so kind of you. Which one would you like to hear?") npc("'Shall I compare thee to a desert's day' is my finest yet, but I've also composed others.") poems() } -suspend fun CharacterContext.poems() { +suspend fun CharacterContext.poems() { choice("Select an Option") { option("Listen to 'Shall I compare thee to a desert's day'.") { desertsDay(interrupt = false) @@ -80,7 +81,7 @@ suspend fun CharacterContext.poems() { } } -suspend fun CharacterContext.justToSay() { +suspend fun CharacterContext.justToSay() { npc("I wrote this poem when I went to the oasis to nibble at a tree, then discovered I'd left nothing for Elly to nibble. I was distraught.") npc("This Is Just To Say") npc("I have nibbled the cacti that were by the oasis,") @@ -90,7 +91,7 @@ suspend fun CharacterContext.justToSay() { whatDoesSheThink() } -suspend fun CharacterContext.desertsDay(interrupt: Boolean) { +suspend fun CharacterContext.desertsDay(interrupt: Boolean) { if (!interrupt) { npc("That's my favourite poem. Ahem...") } @@ -116,7 +117,7 @@ suspend fun CharacterContext.desertsDay(interrupt: Boolean) { } } -suspend fun CharacterContext.whatDoesSheThink() { +suspend fun CharacterContext.whatDoesSheThink() { player("What does she think of your poems?") npc("She's never heard them.") player("Why not?") @@ -133,7 +134,7 @@ suspend fun CharacterContext.whatDoesSheThink() { } } -suspend fun NPCOption.dung() { +suspend fun NPCOption.dung() { player("I'm sorry to bother you, but could you spare me a little dung?") npc("Are you serious?") player("Oh yes. If you'd be so kind...") @@ -149,7 +150,7 @@ suspend fun NPCOption.dung() { player("Ohhh yes. Lovely.") } -suspend fun NPCOption.listenTo() { +suspend fun NPCOption.listenTo() { npc("Oh, it's you again. Have you come back to listen to my poems?") choice { option("I'd love to!") { @@ -161,7 +162,7 @@ suspend fun NPCOption.listenTo() { } } -suspend fun NPCOption.talkingToMe() { +suspend fun NPCOption.talkingToMe() { npc("Sorry, were you saying something to me?") player("No, er, nothing important.") npc("Never mind, it is unimportant when I have such important matters weighing on my soul.") @@ -189,7 +190,7 @@ itemOnObjectOperate(obj = "dung") { scoopPoop() } -suspend fun NPCOption.insult() { +suspend fun NPCOption.insult() { player(when (random.nextInt(3)) { 0 -> "Mmm... looks like that camel would make a nice kebab." 1 -> "I wonder if that camel has fleas..." @@ -197,7 +198,7 @@ suspend fun NPCOption.insult() { }) } -suspend fun CharacterContext.scoopPoop() { +suspend fun CharacterContext.scoopPoop() { if (!player.inventory.replace("bucket", "ugthanki_dung")) { return } diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/al_kharid/Ellis.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/al_kharid/Ellis.kts index 0e319fb792..9d33769f1a 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/al_kharid/Ellis.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/al_kharid/Ellis.kts @@ -54,7 +54,7 @@ npcOperate("Trade", "ellis", "tanner") { player.open("tanner") } -suspend fun NPCOption.leather() { +suspend fun NPCOption.leather() { choice("What would you like to say?") { option("Can I buy some leather then?") { npc("I make leather from animal hides. Bring me some cowhides and one gold coin per hide, and I'll tan them into soft leather for you.") diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/al_kharid/Tollgate.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/al_kharid/Tollgate.kts index 06892f6651..e66319da20 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/al_kharid/Tollgate.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/al_kharid/Tollgate.kts @@ -51,7 +51,7 @@ npcOperate("Talk-to", "border_guard_al_kharid*") { fun getGuard(player: Player) = get()[player.tile.regionLevel].firstOrNull { it.id.startsWith("border_guard_al_kharid") } -suspend fun CharacterContext.dialogue(player: Player, npc: NPC? = getGuard(player)) { +suspend fun CharacterContext.dialogue(player: Player, npc: NPC? = getGuard(player)) { if (npc == null) { return } diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/al_kharid/Zeke.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/al_kharid/Zeke.kts index cfdbb76a51..b6c209ad15 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/al_kharid/Zeke.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/al_kharid/Zeke.kts @@ -2,6 +2,7 @@ package world.gregs.voidps.world.map.al_kharid import world.gregs.voidps.engine.entity.character.CharacterContext import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.character.player.male import world.gregs.voidps.world.activity.quest.quest import world.gregs.voidps.world.interact.dialogue.* @@ -44,7 +45,7 @@ npcOperate("Talk-to", "zeke") { } } -suspend fun CharacterContext.takeALook() { +suspend fun CharacterContext.takeALook() { choice { option("Yes please, Zeke.", block = { player.openShop("zekes_superior_scimitars") }) option("Not today, thank you.") diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/al_kharid/duel_arena/Mubariz.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/al_kharid/duel_arena/Mubariz.kts index ca72f65807..864df0fc83 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/al_kharid/duel_arena/Mubariz.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/al_kharid/duel_arena/Mubariz.kts @@ -2,6 +2,7 @@ package world.gregs.voidps.world.map.al_kharid.duel_arena import world.gregs.voidps.engine.entity.character.CharacterContext import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.world.interact.dialogue.* import world.gregs.voidps.world.interact.dialogue.type.PlayerChoice import world.gregs.voidps.world.interact.dialogue.type.choice @@ -16,7 +17,7 @@ npcOperate("Talk-to", "mubariz") { menu() } -suspend fun CharacterContext.menu() { +suspend fun CharacterContext.menu() { choice { place() duelling() @@ -39,7 +40,7 @@ suspend fun PlayerChoice.place(): Unit = option("What is this place?" } } -suspend fun CharacterContext.looksOld() { +suspend fun CharacterContext.looksOld() { player("It looks really old. Where did it come from?") npc("The archaeologists that are excavating the area east of Varrock have been working on this site as well. From these cliffs they uncovered this huge building. The experts think it may date back to the second age!") npc("Now that the archaeologists have moved out, a group of warriors, headed by myself, have bought the land and converted it to a set of arenas for duels. The best fighters from around the world come here to fight!") @@ -57,7 +58,7 @@ suspend fun PlayerChoice.challenge(): Unit = option("I challenge you menu() } -suspend fun CharacterContext.duelling() { +suspend fun CharacterContext.duelling() { player("How do I challenge someone to a duel?") npc("When you go to the arena you'll go up an access ramp to the walkways that overlook the arenas. From the walkways you can watch the duels and challenge other players.") npc("You'll know you're in the right place as you'll have a Duel-with option when you right-click a player.") diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/al_kharid/duel_arena/Nurses.kt b/game/src/main/kotlin/world/gregs/voidps/world/map/al_kharid/duel_arena/Nurses.kt index abb83ea8ce..90ea8f0f12 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/al_kharid/duel_arena/Nurses.kt +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/al_kharid/duel_arena/Nurses.kt @@ -3,6 +3,7 @@ package world.gregs.voidps.world.map.al_kharid.duel_arena import world.gregs.voidps.engine.client.message import world.gregs.voidps.engine.entity.character.face import world.gregs.voidps.engine.entity.character.mode.interact.TargetNPCContext +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.character.player.skill.Skill import world.gregs.voidps.engine.entity.character.setAnimation import world.gregs.voidps.world.interact.dialogue.Chuckle @@ -20,7 +21,7 @@ internal suspend fun PlayerChoice.fighters(): Unit = option("Do you s player("That's reassuring.") } -internal suspend fun TargetNPCContext.heal() { +internal suspend fun TargetNPCContext.heal() { target.face(player) val heal = player.levels.getMax(Skill.Constitution) if (player.levels.get(Skill.Constitution) < heal) { diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/al_kharid/duel_arena/SurgeonGeneralTafani.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/al_kharid/duel_arena/SurgeonGeneralTafani.kts index c81270f6dc..3cb359457e 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/al_kharid/duel_arena/SurgeonGeneralTafani.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/al_kharid/duel_arena/SurgeonGeneralTafani.kts @@ -2,6 +2,7 @@ package world.gregs.voidps.world.map.al_kharid.duel_arena import world.gregs.voidps.engine.entity.character.npc.NPCOption import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.world.interact.dialogue.Happy import world.gregs.voidps.world.interact.dialogue.Neutral import world.gregs.voidps.world.interact.dialogue.Quiz @@ -20,7 +21,7 @@ npcOperate("Heal", "surgeon_general_tafani") { heal() } -suspend fun NPCOption.menu() { +suspend fun NPCOption.menu() { choice { option("Can you heal me?") { heal() diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/ardougne/BartenderFlyingHorseInn.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/ardougne/BartenderFlyingHorseInn.kts index 3690db03f7..43cf2eb26e 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/ardougne/BartenderFlyingHorseInn.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/ardougne/BartenderFlyingHorseInn.kts @@ -4,6 +4,7 @@ import world.gregs.voidps.engine.client.message import world.gregs.voidps.engine.client.ui.interact.itemOnNPCOperate import world.gregs.voidps.engine.entity.character.mode.interact.TargetNPCContext import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.character.player.chat.noInterest import world.gregs.voidps.engine.entity.character.player.skill.Skill import world.gregs.voidps.world.interact.dialogue.Quiz @@ -43,7 +44,7 @@ itemOnNPCOperate("barcrawl_card", "bartender_flying_horse_inn") { barCrawl() } -suspend fun TargetNPCContext.barCrawl() = barCrawlDrink( +suspend fun TargetNPCContext.barCrawl() = barCrawlDrink( effects = { player.message("signing your barcrawl card") player.damage(player.levels.get(Skill.Constitution) / 4) diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/ardougne/LegendsGuild.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/ardougne/LegendsGuild.kts index 2f64e9fbfb..287d73a14d 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/ardougne/LegendsGuild.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/ardougne/LegendsGuild.kts @@ -34,13 +34,13 @@ itemOnObjectOperate("skills_necklace", "legends_guild_totem_pole") { } } -suspend fun CharacterContext.combatBracelet(player: Player) { +suspend fun CharacterContext.combatBracelet(player: Player) { player.message("You touch the jewellery against the totem pole...") player.setAnimation("bend_down") item("combat_bracelet", 300, "You feel a power emanating from the totem pole as it recharges your bracelet. You can now rub the bracelet to teleport and wear it to get information while on a Slayer assignment.") } -suspend fun CharacterContext.skillsNecklace(player: Player) { +suspend fun CharacterContext.skillsNecklace(player: Player) { player.message("You touch the jewellery against the totem pole...") player.setAnimation("bend_down") item("skills_necklace", 200, "You feel a power emanating from the totem pole as it recharges your necklace. You can now rub the necklace to teleport and wear it to get more caskets while big net Fishing.") diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/ardougne/WizardCromperty.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/ardougne/WizardCromperty.kts index 3fbbe522f2..9e26909eba 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/ardougne/WizardCromperty.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/ardougne/WizardCromperty.kts @@ -2,9 +2,11 @@ package world.gregs.voidps.world.map.ardougne import world.gregs.voidps.engine.client.message import world.gregs.voidps.engine.entity.character.forceChat +import world.gregs.voidps.engine.entity.character.mode.interact.TargetNPCContext import world.gregs.voidps.engine.entity.character.move.tele import world.gregs.voidps.engine.entity.character.npc.NPCOption import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.character.setGraphic import world.gregs.voidps.engine.queue.softQueue import world.gregs.voidps.world.activity.quest.questComplete @@ -45,7 +47,7 @@ npcOperate("Teleport", "wizard_cromperty") { } } -fun ChoiceBuilder.whatHaveYouInvented() { +fun ChoiceBuilder>.whatHaveYouInvented() { option("So what have you invented?") { npc("Ah! My latest invention is my patent pending teleportation block! It emits a low level magical signal, that will allow me to locate it anywhere in the world, and teleport anything") npc("directly to it! I hope to revolutionise the entire teleportation system! Don't you think I'm great? Uh, I mean it's great?") @@ -68,16 +70,16 @@ fun ChoiceBuilder.whatHaveYouInvented() { } } -fun ChoiceBuilder.teleportMe() { +fun ChoiceBuilder>.teleportMe() { option("Can I be teleported please?") { npc("By all means! I'm afraid I can't give you any specifics as to where you will come out however. Presumably wherever the other block is located.") choice { option("Yes, that sounds good. Teleport me!") { npc("Okey dokey! Ready?") player.setGraphic("curse_hit") - npc.setGraphic("curse_cast") - npc.forceChat = "Dipsolum sententa sententi!" - npc.shoot("curse", player.tile, offset = 64) + target.setGraphic("curse_cast") + target.forceChat = "Dipsolum sententa sententi!" + target.shoot("curse", player.tile, offset = 64) player.softQueue("cromperty_teleport", 2) { player.tele(2649, 3271) } diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/barbarian_outpost/BarbarianGuard.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/barbarian_outpost/BarbarianGuard.kts index dfdb6763d2..47c869d658 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/barbarian_outpost/BarbarianGuard.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/barbarian_outpost/BarbarianGuard.kts @@ -3,6 +3,7 @@ package world.gregs.voidps.world.map.barbarian_outpost import world.gregs.voidps.engine.client.message import world.gregs.voidps.engine.entity.character.npc.NPCOption import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.character.player.chat.inventoryFull import world.gregs.voidps.engine.inv.add import world.gregs.voidps.engine.inv.inventory @@ -24,7 +25,7 @@ npcOperate("Talk-to", "barbarian_guard") { } } -suspend fun NPCOption.startBarCrawl() { +suspend fun NPCOption.startBarCrawl() { npc("Oi, whaddya want?") choice { option("I want to come through this gate.") { @@ -52,7 +53,7 @@ suspend fun NPCOption.startBarCrawl() { } } -suspend fun NPCOption.toggleVialSmashing() { +suspend fun NPCOption.toggleVialSmashing() { if (player["vial_smashing", false]) { npc("'Ello friend. I see you're drinking like a barbarian - do you want to stop smashing your vials when you finish them?") choice { @@ -79,7 +80,7 @@ suspend fun NPCOption.toggleVialSmashing() { } } -suspend fun NPCOption.questComplete() { +suspend fun NPCOption.questComplete() { npc("So, how's the Barcrawl coming along?") player("I tink I jusht 'bout done dem all... but I losht count...") if (player.inventory.remove("barcrawl_card")) { @@ -98,7 +99,7 @@ suspend fun NPCOption.questComplete() { } } -suspend fun NPCOption.checkProcess() { +suspend fun NPCOption.checkProcess() { npc("So, how's the Barcrawl coming along?") if (player.ownsItem("barcrawl_card")) { player("I haven't finished it yet.") diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/barbarian_village/ChieftainGunthor.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/barbarian_village/ChieftainGunthor.kts index 21d054eb91..b787f36aeb 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/barbarian_village/ChieftainGunthor.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/barbarian_village/ChieftainGunthor.kts @@ -2,6 +2,7 @@ package world.gregs.voidps.world.map.barbarian_village import world.gregs.voidps.engine.entity.character.CharacterContext import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.world.activity.quest.quest import world.gregs.voidps.world.interact.dialogue.* import world.gregs.voidps.world.interact.dialogue.type.choice @@ -22,7 +23,7 @@ npcOperate("Talk-to", "chieftain_gunthor") { } } -suspend fun CharacterContext.meetChieftain() { +suspend fun CharacterContext.meetChieftain() { npc("Begone, outerlander! Your kind are not welcome here!") choice { option("I need to speak with you, chieftain.") { @@ -34,7 +35,7 @@ suspend fun CharacterContext.meetChieftain() { } } -suspend fun CharacterContext.makeItShort() { +suspend fun CharacterContext.makeItShort() { npc("Make it short.") player("Your daughter seeks permission to court an outerlander.") npc("WHAT??") @@ -48,7 +49,7 @@ suspend fun CharacterContext.makeItShort() { } } -suspend fun CharacterContext.barbarians() { +suspend fun CharacterContext.barbarians() { npc("Do you have ANY idea who we are?") choice { option("You're barbarians.") { @@ -60,7 +61,7 @@ suspend fun CharacterContext.barbarians() { } } -suspend fun CharacterContext.waitAMoment() { +suspend fun CharacterContext.waitAMoment() { npc("We are storm that sweeps from the mountains! We are the scourge of these soft lands!") choice { option("Please wait a moment.") { @@ -72,7 +73,7 @@ suspend fun CharacterContext.waitAMoment() { } } -suspend fun CharacterContext.campOfWar() { +suspend fun CharacterContext.campOfWar() { npc("We are the freemen of the ice. You think this a settlement, but it is a camp of war!") npc("haakon_the_champion", "Chieftain! May I interrupt?") npc("What is it, Haakon?") @@ -93,7 +94,7 @@ suspend fun CharacterContext.campOfWar() { seeHimTry() } -suspend fun CharacterContext.seeHimTry() { +suspend fun CharacterContext.seeHimTry() { choice { option("I'm going!") { } @@ -106,6 +107,6 @@ suspend fun CharacterContext.seeHimTry() { } } -suspend fun CharacterContext.unstarted() { +suspend fun CharacterContext.unstarted() { npc("Begone, outerlander! Your kind are not welcome here!") } \ No newline at end of file diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/barbarian_village/Dororan.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/barbarian_village/Dororan.kts index 809c895aea..971eed18b6 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/barbarian_village/Dororan.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/barbarian_village/Dororan.kts @@ -58,7 +58,7 @@ npcOperate("Talk-to", "dororan") { } } -suspend fun CharacterContext.poem() { +suspend fun CharacterContext.poem() { if (!player.ownsItem("gunnars_ground")) { player("Er, I lost the poem.") npc("Luckily for you, I wrote a second draft.") @@ -79,7 +79,7 @@ suspend fun CharacterContext.poem() { } } -suspend fun CharacterContext.poemDone() { +suspend fun CharacterContext.poemDone() { npc("At last! It's done! It's finished! My finest work! Thank you so much for your help!") player("Are you ready to present it to Chieftain?!") npc("What? No! I'm a writer, not a performer.") @@ -98,20 +98,20 @@ suspend fun CharacterContext.poemDone() { } } -suspend fun CharacterContext.sweptToWar() { +suspend fun CharacterContext.sweptToWar() { npc("'Who then, in face of madness, swept to war.'") npc("That's it! That's brilliant!") player["gunnars_ground"] = "poem_done" poemDone() } -suspend fun CharacterContext.oneMore() { +suspend fun CharacterContext.oneMore() { npc("It's coming together. We're nearly done! One more to go!") npc("This one is tricky, though. It's a phrase I need. Someone did something.") phraseMenu() } -suspend fun CharacterContext.phraseMenu() { +suspend fun CharacterContext.phraseMenu() { choice { option("Threw the ball.") { npc("That doesn't really fit. It needs tp rhyme with the word 'lore'.") @@ -132,7 +132,7 @@ suspend fun CharacterContext.phraseMenu() { } } -suspend fun CharacterContext.threeSyllablesMenu() { +suspend fun CharacterContext.threeSyllablesMenu() { choice { option("Picked a rose.") { npc("That doesn't really fit. It needs tp rhyme with the word 'lore'.") @@ -156,7 +156,7 @@ suspend fun CharacterContext.threeSyllablesMenu() { } } -suspend fun CharacterContext.threeSyllablesMenu2() { +suspend fun CharacterContext.threeSyllablesMenu2() { choice { option("Heard a song.") { npc("that doesn't really fit. It needs to imply some aggressive action, like 'started a fight'.") @@ -179,7 +179,7 @@ suspend fun CharacterContext.threeSyllablesMenu2() { } } -suspend fun CharacterContext.fightMenu() { +suspend fun CharacterContext.fightMenu() { choice { option("Picked a fight.") { npc("That doesn't really fit. It needs tp rhyme with the word 'lore'.") @@ -203,7 +203,7 @@ suspend fun CharacterContext.fightMenu() { } } -suspend fun CharacterContext.fightMenu2() { +suspend fun CharacterContext.fightMenu2() { choice { option("Swept to war.") { sweptToWar() @@ -226,7 +226,7 @@ suspend fun CharacterContext.fightMenu2() { } } -suspend fun CharacterContext.loreMenu() { +suspend fun CharacterContext.loreMenu() { choice { option("Started a war.") { npc("that doesn't really fit. It needs to be three syllables long.") @@ -250,7 +250,7 @@ suspend fun CharacterContext.loreMenu() { } } -suspend fun CharacterContext.loreMenu2() { +suspend fun CharacterContext.loreMenu2() { choice { option("Learned to soar") { npc("that doesn't really fit. It needs to imply some aggressive action, like 'started a fight'.") @@ -273,14 +273,14 @@ suspend fun CharacterContext.loreMenu2() { } } -suspend fun CharacterContext.threat() { +suspend fun CharacterContext.threat() { npc("'But long is gone the author of that threat.'") npc("Perfect! Yes!") player["gunnars_ground"] = "one_more_poem" oneMore() } -suspend fun CharacterContext.morePoem() { +suspend fun CharacterContext.morePoem() { npc("The poem still isn't finished, though. I have another missing word. Give me another one; anything, to get me started.") choice { option("Stockade.") { @@ -302,7 +302,7 @@ suspend fun CharacterContext.morePoem() { } } -suspend fun CharacterContext.syllablePoemMenu() { +suspend fun CharacterContext.syllablePoemMenu() { choice { option("Storm.") { npc("That doesn't really fit. It needs to rhyme with the word 'yet'.") @@ -326,7 +326,7 @@ suspend fun CharacterContext.syllablePoemMenu() { } } -suspend fun CharacterContext.syllablePoemMenu2() { +suspend fun CharacterContext.syllablePoemMenu2() { choice { option("Debt.") { npc("That doesn't really fit. It needs to mean something like 'danger'.") @@ -349,7 +349,7 @@ suspend fun CharacterContext.syllablePoemMenu2() { } } -suspend fun CharacterContext.rhymePoemMenu() { +suspend fun CharacterContext.rhymePoemMenu() { choice { option("Debt.") { npc("That doesn't really fit. It needs to mean something like 'danger'.") @@ -373,7 +373,7 @@ suspend fun CharacterContext.rhymePoemMenu() { } } -suspend fun CharacterContext.rhymePoemMenu2() { +suspend fun CharacterContext.rhymePoemMenu2() { choice { option("Threat.") { threat() @@ -396,7 +396,7 @@ suspend fun CharacterContext.rhymePoemMenu2() { } } -suspend fun CharacterContext.dangerPoemMenu() { +suspend fun CharacterContext.dangerPoemMenu() { choice { option("Risk.") { npc("That doesn't really fit. It needs to rhyme with the word 'yet'.") @@ -420,7 +420,7 @@ suspend fun CharacterContext.dangerPoemMenu() { } } -suspend fun CharacterContext.dangerPoemMenu2() { +suspend fun CharacterContext.dangerPoemMenu2() { choice { option("Upset.") { npc("That doesn't really fit. It needs to be one syllable long.") @@ -443,7 +443,7 @@ suspend fun CharacterContext.dangerPoemMenu2() { } } -suspend fun CharacterContext.aboutRing() { +suspend fun CharacterContext.aboutRing() { npc("Did you give Gudrun the ring? What did she think? Did it capture her heart?") player("There's a problem.") npc("It's because I'm a dwarf, isn't it? Or because I'm a poet? I knew it! I'm completely worthless!") @@ -459,7 +459,7 @@ suspend fun CharacterContext.aboutRing() { } } -suspend fun CharacterContext.mostCruel() { +suspend fun CharacterContext.mostCruel() { player("Gudrun's father won't let her be with someone from outside the village.") npc("Most cruel is fate! Most cruel! Why not?") player("He's obsessed with the stories of his ancestors. He says his people are still at war.") @@ -477,7 +477,7 @@ suspend fun CharacterContext.mostCruel() { } } -suspend fun CharacterContext.anyIdea() { +suspend fun CharacterContext.anyIdea() { npc("An idea occurs to me, but it is hubris of the greatest magnitude.") player("What is it?") npc("What if I wrote a poem? Forged a sweeping, historical epic? Crafted a tale to touch the chieftain's soul?") @@ -491,7 +491,7 @@ suspend fun CharacterContext.anyIdea() { writePoem() } -suspend fun CharacterContext.writePoem() { +suspend fun CharacterContext.writePoem() { npc("'Even the bloodiest rose must settle.' Mixed metaphor. Whats settles? Detritus. That's hardly flattering.") npc("'Even the rolliest boulder...'") player("How is the poem going?") @@ -506,7 +506,7 @@ suspend fun CharacterContext.writePoem() { } } -suspend fun CharacterContext.stuckOnWord() { +suspend fun CharacterContext.stuckOnWord() { npc("I'm stuck on a word. By the colossus of King Alvis! I can't find the words!") player("Maybe I can help. What sort of word?") npc("I don't know! I'm not some kind of word scientist. I just feel it out as I go.") @@ -515,7 +515,7 @@ suspend fun CharacterContext.stuckOnWord() { poemMenu() } -suspend fun CharacterContext.poemMenu() { +suspend fun CharacterContext.poemMenu() { choice { option("Cucumber.") { npc("That doesn't really fit. It needs to be one syllable long.") @@ -536,7 +536,7 @@ suspend fun CharacterContext.poemMenu() { } } -suspend fun CharacterContext.syllableMenu() { +suspend fun CharacterContext.syllableMenu() { choice { option("Ham.") { npc("That doesn't really fit. It needs to rhyme with the word 'day'.") @@ -560,7 +560,7 @@ suspend fun CharacterContext.syllableMenu() { } } -suspend fun CharacterContext.syllableMenu2() { +suspend fun CharacterContext.syllableMenu2() { choice { option("Roam.") { npc("That doesn't really fit. It needs to rhyme with the word 'day'.") @@ -583,7 +583,7 @@ suspend fun CharacterContext.syllableMenu2() { } } -suspend fun CharacterContext.wordsMenu() { +suspend fun CharacterContext.wordsMenu() { choice { option("Deviate.") { npc("That doesn't really fit. It needs to be one syllable long.") @@ -607,7 +607,7 @@ suspend fun CharacterContext.wordsMenu() { } } -suspend fun CharacterContext.wordsMenu2() { +suspend fun CharacterContext.wordsMenu2() { choice { option("Meander.") { npc("That doesn't really fit. It needs to be one syllable long.") @@ -630,7 +630,7 @@ suspend fun CharacterContext.wordsMenu2() { } } -suspend fun CharacterContext.rhymeMenu() { +suspend fun CharacterContext.rhymeMenu() { choice { option("Lay.") { npc("That doesn't really fit. It needs to mean something like 'wandering aimlessly'.") @@ -654,7 +654,7 @@ suspend fun CharacterContext.rhymeMenu() { } } -suspend fun CharacterContext.rhymeMenu2() { +suspend fun CharacterContext.rhymeMenu2() { choice { option("Stray.") { stray() @@ -677,20 +677,20 @@ suspend fun CharacterContext.rhymeMenu2() { } } -suspend fun CharacterContext.stray() { +suspend fun CharacterContext.stray() { npc("'And from his righteous purpose never stray.'") npc("That fits! It fits perfectly. Right meaning, right length, right rhyme. Well done!") player["gunnars_ground"] = "more_poem" morePoem() } -suspend fun CharacterContext.meetChieftain() { +suspend fun CharacterContext.meetChieftain() { npc("Did you give Gudrun the ring? What did she think?") player("She liked it, but there's a problem. I'm dealing with it.") npc("Oh no!") } -suspend fun CharacterContext.showGudrun() { +suspend fun CharacterContext.showGudrun() { if (!player.ownsItem("dororans_engraved_ring")) { npc("I know. I found it on the ground.") if (!giveRing()) { @@ -708,7 +708,7 @@ suspend fun CharacterContext.showGudrun() { } } -suspend fun CharacterContext.engravedRing() { +suspend fun CharacterContext.engravedRing() { npc("Is it done? Have you created a work of magnificent beauty?") if (!player.ownsItem("dororans_engraved_ring")) { player("I did engrave it. but I seem to have lost it.") @@ -742,7 +742,7 @@ suspend fun CharacterContext.engravedRing() { } } -suspend fun CharacterContext.oneMoreThing() { +suspend fun CharacterContext.oneMoreThing() { choice { option("Of course.") { veryWell() @@ -753,7 +753,7 @@ suspend fun CharacterContext.oneMoreThing() { } } -suspend fun CharacterContext.veryWell() { +suspend fun CharacterContext.veryWell() { npc("I fear she will only judge this poor book by its cover. Would you take the ring to Gudrun for me?") choice { option("Very well.") { @@ -765,7 +765,7 @@ suspend fun CharacterContext.veryWell() { } } -suspend fun CharacterContext.whereIsShe() { +suspend fun CharacterContext.whereIsShe() { npc("Please don't tell her I'm a dwarf just yet.") player["gunnars_ground"] = "show_gudrun" choice { @@ -776,7 +776,7 @@ suspend fun CharacterContext.whereIsShe() { } } -suspend fun CharacterContext.unstarted() { +suspend fun CharacterContext.unstarted() { npc("'My heart with burdens heavy does it lie.'") npc("'For never did I...'") npc("Um...") @@ -793,7 +793,7 @@ suspend fun CharacterContext.unstarted() { } } -suspend fun CharacterContext.started() { +suspend fun CharacterContext.started() { npc("I need a ring of purest gold. Then we can engrave it with the words of my heart.") player.refreshQuestJournal() npc("Oh! I know the perfect place to get a gold ring.") @@ -816,7 +816,7 @@ suspend fun CharacterContext.started() { } } -suspend fun CharacterContext.somethingElse() { +suspend fun CharacterContext.somethingElse() { choice { option("I want to ask about something else.") { npc("By all means.") @@ -826,7 +826,7 @@ suspend fun CharacterContext.somethingElse() { } } -suspend fun CharacterContext.lovePoemMenu() { +suspend fun CharacterContext.lovePoemMenu() { choice { option("Does it have to be a ring from Jeffery?") { npc("Yes! Jeffery's rings are timeless works of incomparable romantic splendour.") @@ -852,7 +852,7 @@ suspend fun CharacterContext.lovePoemMenu() { } } -suspend fun CharacterContext.lovePoem() { +suspend fun CharacterContext.lovePoem() { npc("'I await in eagerness for a loop of lustrous grandeur.' No, that just sounds ridiculous. Have you brought me a ring from Jeffery?'") if (!player.ownsItem("ring_from_jeffery") && player.quest("gunnars_ground") == "jeffery_ring") { player("I did get a ring from jeffery, but I seem to have lost it.") @@ -906,7 +906,7 @@ suspend fun CharacterContext.lovePoem() { } } -suspend fun CharacterContext.engrave() { +suspend fun CharacterContext.engrave() { npc("Now, would you engrave something on it for me?") choice { option("What do you want me to engrave?") { @@ -918,7 +918,7 @@ suspend fun CharacterContext.engrave() { } } -suspend fun CharacterContext.engraveSomething() { +suspend fun CharacterContext.engraveSomething() { npc("I've given this some thought.") npc("'Gudrun the Fair, Gudrun the Fiery.'") choice { @@ -935,7 +935,7 @@ suspend fun CharacterContext.engraveSomething() { } } -suspend fun CharacterContext.engraveMenu() { +suspend fun CharacterContext.engraveMenu() { choice { option("Do you have a chisel I can use?") { haveChisel() @@ -947,7 +947,7 @@ suspend fun CharacterContext.engraveMenu() { } } -suspend fun CharacterContext.haveChisel() { +suspend fun CharacterContext.haveChisel() { npc("Yes, here you go.") if (player.inventory.isFull()) { statement("You don't have room for the chisel. Speak to Dororan again when you have room.") @@ -964,7 +964,7 @@ suspend fun CharacterContext.haveChisel() { } } -suspend fun CharacterContext.chiselBitClumsy() { +suspend fun CharacterContext.chiselBitClumsy() { npc("I've seen jewelcrafters use them for all sorts of precise work.") choice { option("Do you have a chisel I can use?") { @@ -974,7 +974,7 @@ suspend fun CharacterContext.chiselBitClumsy() { } } -suspend fun CharacterContext.poet() { +suspend fun CharacterContext.poet() { npc("You're a poet too?") choice { option("Yes.") { @@ -992,7 +992,7 @@ suspend fun CharacterContext.poet() { } } -suspend fun CharacterContext.identify() { +suspend fun CharacterContext.identify() { npc("My heart is stricken with that most audacious of maladies!") choice { option("Angina?") { @@ -1007,7 +1007,7 @@ suspend fun CharacterContext.identify() { } } -suspend fun CharacterContext.love() { +suspend fun CharacterContext.love() { npc("Love!") npc("The walls of my heart are besieged by love's armies, and those walls begin to tumble!") npc("In the barbarian village lives the fairest maiden I have witnessed in all my life.") @@ -1029,7 +1029,7 @@ suspend fun CharacterContext.love() { } } -suspend fun CharacterContext.getToThePoint() { +suspend fun CharacterContext.getToThePoint() { npc("The people of this village value strength, stature and riches. I have none of these things.") npc("My people are indomitable warriors, dripping with gold and precious gems, but not I.") npc("I am not built for combat, and poetry has proven a life of poverty!") @@ -1044,7 +1044,7 @@ suspend fun CharacterContext.getToThePoint() { } } -suspend fun CharacterContext.helpMe() { +suspend fun CharacterContext.helpMe() { npc("If Gudrun could ever love a dwarf, surely she would need to see my artisanry.") npc("Will you help me? I am no crafter of metal.") if (player.levels.get(Skill.Crafting) < 5) { @@ -1167,7 +1167,7 @@ npcOperate("Talk-to", "dororan_after_quest") { } } -suspend fun CharacterContext.someThingElse() { +suspend fun CharacterContext.someThingElse() { choice { option("How are things?") { npc("Every morning I wake to sunshine and birdsong! Life is marvellous!") @@ -1206,7 +1206,7 @@ suspend fun CharacterContext.someThingElse() { } } -suspend fun CharacterContext.giveRing(): Boolean { +suspend fun CharacterContext.giveRing(): Boolean { if (player.inventory.isFull()) { statement("You don't have room for the ring. Speak to Dororan again when you have room.") return false @@ -1217,7 +1217,7 @@ suspend fun CharacterContext.giveRing(): Boolean { return true } -suspend fun CharacterContext.elseGoodbye() { +suspend fun CharacterContext.elseGoodbye() { choice { option("I want to talk about something else.") { npc("What can I do for you?") diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/barbarian_village/Gudrun.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/barbarian_village/Gudrun.kts index f60f94847b..17deb5d4fd 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/barbarian_village/Gudrun.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/barbarian_village/Gudrun.kts @@ -13,6 +13,7 @@ import world.gregs.voidps.engine.entity.character.move.tele import world.gregs.voidps.engine.entity.character.npc.NPCOption import world.gregs.voidps.engine.entity.character.npc.NPCs import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.character.player.skill.Skill import world.gregs.voidps.engine.entity.character.setAnimation import world.gregs.voidps.engine.entity.item.Item @@ -58,7 +59,7 @@ npcOperate("Talk-to", "gudrun*") { } } -suspend fun CharacterContext.recital() { +suspend fun CharacterContext.recital() { npc("Are you ready for the recital?") choice { option("Yes.") { @@ -72,7 +73,7 @@ suspend fun CharacterContext.recital() { val npcs: NPCs by inject() val region = Region(12341) -suspend fun CharacterContext.cutscene() { +suspend fun CharacterContext.cutscene() { player.open("fade_out") val instance = startCutscene(region) val offset = instance.offset(region) @@ -100,7 +101,7 @@ suspend fun CharacterContext.cutscene() { } } -suspend fun CharacterContext.cutsceneMenu(instance: Region) { +suspend fun CharacterContext.cutsceneMenu(instance: Region) { npc("dororan_cutscene", "This isn't going to work.") choice { option("Why's that?") { @@ -114,7 +115,7 @@ suspend fun CharacterContext.cutsceneMenu(instance: Region) { } } -suspend fun CharacterContext.cutsceneMenu2(instance: Region) { +suspend fun CharacterContext.cutsceneMenu2(instance: Region) { npc("dororan_cutscene", "What was I thinking? You should go in there and stop them before Gudrun makes a fool of herself.") choice { option("Okay, I will.") { @@ -130,7 +131,7 @@ suspend fun CharacterContext.cutsceneMenu2(instance: Region) { } } -suspend fun CharacterContext.cutsceneMenu3(instance: Region) { +suspend fun CharacterContext.cutsceneMenu3(instance: Region) { npc("dororan_cutscene", "I can't hear what's happening. Can you hear what's happening?") player.setAnimation("player_calm_doroan") player("Gunthor is laughing at something.") @@ -146,7 +147,7 @@ suspend fun CharacterContext.cutsceneMenu3(instance: Region) { } } -suspend fun CharacterContext.cutsceneMenu4(instance: Region) { +suspend fun CharacterContext.cutsceneMenu4(instance: Region) { npc("dororan_cutscene", "The poem says you can honour your ancestors by settling peacefully on the land they conquered.") npc("dororan_cutscene", "He'll probably just find it insulting.") player.setAnimation("player_calm_doroan") @@ -160,7 +161,7 @@ suspend fun CharacterContext.cutsceneMenu4(instance: Region) { } } -suspend fun CharacterContext.cutscenePart2(instance: Region) { +suspend fun CharacterContext.cutscenePart2(instance: Region) { player.open("fade_out") delay(3) npcs.clear(instance.toLevel(0)) @@ -229,7 +230,7 @@ suspend fun CharacterContext.cutscenePart2(instance: Region) { } } -suspend fun CharacterContext.gunnarsGround() { +suspend fun CharacterContext.gunnarsGround() { npc("Papa was so impressed by Dororan's poem, he's made him the village poet!") npc("dororan_after_cutscene2", "I'm more then a little surprised! He even gave me a house to live in!") npc("Our people's tradition is that the tribe provides lodging for the poet.") @@ -251,13 +252,13 @@ suspend fun CharacterContext.gunnarsGround() { } } -fun CharacterContext.setCutsceneEnd(instance: Region) { +fun CharacterContext.setCutsceneEnd(instance: Region) { player.queue("gunnars_ground_cutscene_end", 1, LogoutBehaviour.Accelerate) { endCutscene(instance) } } -suspend fun CharacterContext.endCutscene(instance: Region) { +suspend fun CharacterContext.endCutscene(instance: Region) { player.open("fade_out") delay(3) player.tele(3081, 3416) @@ -266,7 +267,7 @@ suspend fun CharacterContext.endCutscene(instance: Region) { player.clearAnimation() } -suspend fun CharacterContext.poem() { +suspend fun CharacterContext.poem() { if (player.holdsItem("gunnars_ground")) { npc("What have you got there?") player("Another gift from your mysterious suitor.") @@ -286,7 +287,7 @@ suspend fun CharacterContext.poem() { } } -suspend fun CharacterContext.whatHeSay() { +suspend fun CharacterContext.whatHeSay() { npc("What did he say?") player("He mentioned someone called Gunnar, and that you should think about his feelings.") npc("By the eyeballs of Guthix! Always Gunnar!") @@ -303,7 +304,7 @@ suspend fun CharacterContext.whatHeSay() { } } -suspend fun CharacterContext.fathersAttitude() { +suspend fun CharacterContext.fathersAttitude() { choice { option("You don't seem to share your father's attitude towards him.") { npc("I think there's a difference between respecting my ancestors and obsessing over them. Papa thinks whatever stupid war Gunnar fought is still going on.") @@ -319,7 +320,7 @@ suspend fun CharacterContext.fathersAttitude() { } } -suspend fun CharacterContext.meetChieftain() { +suspend fun CharacterContext.meetChieftain() { choice { option("Where is he?") { npc("In the longhouse at the north end of the village, drinking and shouting.") @@ -329,7 +330,7 @@ suspend fun CharacterContext.meetChieftain() { } } -suspend fun CharacterContext.showGudrun() { +suspend fun CharacterContext.showGudrun() { npc("kjell_sword", "Gudrun! You caught enough fish?") npc("Yes! I have plenty of fish!") npc("kjell_sword", "Your father needs many fish to feed the freemen!") @@ -362,7 +363,7 @@ suspend fun CharacterContext.showGudrun() { } } -suspend fun CharacterContext.aboutRing() { +suspend fun CharacterContext.aboutRing() { npc("This is beautiful gift, stranger. Thank you.") choice { option("The ring isn't from me!") { @@ -375,7 +376,7 @@ suspend fun CharacterContext.aboutRing() { } } -suspend fun CharacterContext.thatsRight() { +suspend fun CharacterContext.thatsRight() { choice { option("That's right.") { npc("I'm sorry, I could never get involved with an adventurer.") @@ -388,7 +389,7 @@ suspend fun CharacterContext.thatsRight() { } } -suspend fun CharacterContext.whoFrom() { +suspend fun CharacterContext.whoFrom() { npc("Oh! Who is it from?") choice { option("A great poet.") { @@ -409,7 +410,7 @@ suspend fun CharacterContext.whoFrom() { } } -suspend fun CharacterContext.outsideVillage() { +suspend fun CharacterContext.outsideVillage() { npc("This man, he is from outside the village?") player("Yes.") npc("I would love to leave the village and be romanced by exotic, handsome, outerlander men. There's a problem, though.") @@ -429,14 +430,14 @@ suspend fun CharacterContext.outsideVillage() { } } -suspend fun CharacterContext.reasonWithHim() { +suspend fun CharacterContext.reasonWithHim() { npc("I've tried to reason with him, but he's impossible! Maybe he'll listen to you. I know some of the others feel the same, but they're loyal to papa.") player["gunnars_ground"] = "meet_chieftain" player.inventory.remove("dororans_engraved_ring") meetChieftain() } -suspend fun CharacterContext.unstarted() { +suspend fun CharacterContext.unstarted() { npc("Can I help you, stranger?") npc("kjell_sword", "Why are you talking to that outerlander?") npc("It's none of your business, Kjell! Just guard the hut!") @@ -453,7 +454,7 @@ suspend fun CharacterContext.unstarted() { } } -suspend fun CharacterContext.whoAreYou() { +suspend fun CharacterContext.whoAreYou() { npc("My name is Gudrun. My father, Gunthor, is chieftain of the village.") choice { option("What is this place?") { @@ -464,7 +465,7 @@ suspend fun CharacterContext.whoAreYou() { } } -suspend fun CharacterContext.whatIsThisPlace() { +suspend fun CharacterContext.whatIsThisPlace() { npc("Outerlanders call this the barbarian village. It doesn't have a name because...it's complicated.") npc("if you want to know more, you should talk to Hunding. He's up in the tower at the east entrance.") choice { @@ -476,7 +477,7 @@ suspend fun CharacterContext.whatIsThisPlace() { } } -suspend fun CharacterContext.finishQuest() { +suspend fun CharacterContext.finishQuest() { npc("dororan_after_cutscene2", "Goodbye!") npc("Goodbye!") if (player.inventory.spaces < 2) { @@ -493,7 +494,7 @@ suspend fun CharacterContext.finishQuest() { questComplete() } -fun CharacterContext.questComplete() { +fun CharacterContext.questComplete() { player.playJingle("quest_complete_3") player["gunnars_ground"] = "completed" player.inc("quest_points", 5) @@ -528,7 +529,7 @@ npcOperate("Talk-to", "gudrun_after_quest") { } } -suspend fun CharacterContext.menu() { +suspend fun CharacterContext.menu() { choice { option("How are things with Dororan?") { npc("I really like him. he's funny, vulnerable and nothing like my people.") @@ -556,7 +557,7 @@ suspend fun CharacterContext.menu() { } } -suspend fun CharacterContext.theory() { +suspend fun CharacterContext.theory() { choice { option("Do you have a theory?") { npc("Gunnar always said 'A warrior does not barter; he simply takes!'. I think papa bought the house, but doesn't want anyone to know.") @@ -572,7 +573,7 @@ suspend fun CharacterContext.theory() { } } -suspend fun CharacterContext.elseGoodbye() { +suspend fun CharacterContext.elseGoodbye() { choice { option("I want to ask about something else.") { npc("Of course, what is it?") diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/barbarian_village/Haakon.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/barbarian_village/Haakon.kts index d5c86767ab..c5597ed88e 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/barbarian_village/Haakon.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/barbarian_village/Haakon.kts @@ -3,6 +3,7 @@ package world.gregs.voidps.world.map.barbarian_village import world.gregs.voidps.engine.entity.character.mode.interact.Interact import world.gregs.voidps.engine.entity.character.mode.interact.TargetNPCContext import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.character.player.PlayerOption import world.gregs.voidps.world.activity.quest.quest import world.gregs.voidps.world.interact.dialogue.* @@ -15,7 +16,7 @@ npcOperate("Talk-to", "haakon_the_champion") { val validStages = setOf("tell_gudrun", "write_poem", "more_poem", "one_more_poem", "poem_done", "poem", "recital", "gunnars_ground") -suspend fun TargetNPCContext.menu() { +suspend fun TargetNPCContext.menu() { npc("I am Haakon, champion of this village. Do you seek to challenge me?") choice { option("I challenge you!") { @@ -45,7 +46,7 @@ suspend fun TargetNPCContext.menu() { } } -suspend fun TargetNPCContext.attack() { +suspend fun TargetNPCContext.attack() { npc("Make peace with your god, outerlander!") target.mode = Interact(target, player, PlayerOption(target, player, "Attack")) } \ No newline at end of file diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/barbarian_village/Kjell.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/barbarian_village/Kjell.kts index 01d4ff22e1..20235d93ee 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/barbarian_village/Kjell.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/barbarian_village/Kjell.kts @@ -2,6 +2,7 @@ package world.gregs.voidps.world.map.barbarian_village import world.gregs.voidps.engine.entity.character.CharacterContext import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.type.random import world.gregs.voidps.world.activity.quest.quest import world.gregs.voidps.world.interact.dialogue.Angry @@ -20,7 +21,7 @@ npcOperate("Talk-to", "kjell") { } } -suspend fun CharacterContext.completed() { +suspend fun CharacterContext.completed() { npc(when (random.nextInt(0, 9)) { 0 -> "...there's a place for us..." 1 -> "...but I'd do anything for you..." @@ -43,7 +44,7 @@ suspend fun CharacterContext.completed() { } } -suspend fun CharacterContext.advice() { +suspend fun CharacterContext.advice() { choice { option("This music isn't very restful.") { npc("Get out of here!") @@ -57,7 +58,7 @@ suspend fun CharacterContext.advice() { } } -suspend fun CharacterContext.unstarted() { +suspend fun CharacterContext.unstarted() { npc("Get out of here, outerlander!") choice { option("What is this place?") { diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/barbarian_village/Sigurd.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/barbarian_village/Sigurd.kts index e6add4ae66..e5fc3c1b16 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/barbarian_village/Sigurd.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/barbarian_village/Sigurd.kts @@ -2,6 +2,7 @@ package world.gregs.voidps.world.map.barbarian_village import world.gregs.voidps.engine.entity.character.CharacterContext import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.character.player.skill.Skill import world.gregs.voidps.world.interact.dialogue.* import world.gregs.voidps.world.interact.dialogue.type.choice @@ -41,7 +42,7 @@ npcOperate("Talk-To", "sigurd") { } } -suspend fun CharacterContext.canoeing() { +suspend fun CharacterContext.canoeing() { if (minimumCanoeLevel()) { return } diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/edgeville/Hari.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/edgeville/Hari.kts index 3f550aab99..4f5922e277 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/edgeville/Hari.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/edgeville/Hari.kts @@ -2,6 +2,7 @@ package world.gregs.voidps.world.map.edgeville import world.gregs.voidps.engine.entity.character.CharacterContext import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.character.player.skill.Skill import world.gregs.voidps.world.interact.dialogue.* import world.gregs.voidps.world.interact.dialogue.type.choice @@ -36,7 +37,7 @@ npcOperate("Talk-To", "hari") { } } -suspend fun CharacterContext.canoeing() { +suspend fun CharacterContext.canoeing() { if (minimumCanoeLevel()) { return } diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/edgeville/Jeffery.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/edgeville/Jeffery.kts index 5672c35947..55ba13ef50 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/edgeville/Jeffery.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/edgeville/Jeffery.kts @@ -2,6 +2,7 @@ package world.gregs.voidps.world.map.edgeville import world.gregs.voidps.engine.entity.character.mode.interact.TargetNPCContext import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.character.setAnimation import world.gregs.voidps.engine.inv.equipment import world.gregs.voidps.engine.inv.holdsItem @@ -90,7 +91,7 @@ npcOperate("Talk-to", "jeffery") { } } -suspend fun TargetNPCContext.lovePoem() { +suspend fun TargetNPCContext.lovePoem() { npc("A love poem? What?") npc("Wait...that dwarf put you up to this, didn't he?") choice { @@ -104,7 +105,7 @@ suspend fun TargetNPCContext.lovePoem() { } } -suspend fun TargetNPCContext.cheekyLittle() { +suspend fun TargetNPCContext.cheekyLittle() { npc("That cheeky little...") npc("He just can't leave it alone, can he? Fine! I'll trade you for the poem. What is it you want?") choice { @@ -119,7 +120,7 @@ suspend fun TargetNPCContext.cheekyLittle() { } } -suspend fun TargetNPCContext.goldRing() { +suspend fun TargetNPCContext.goldRing() { player.inventory.replace("love_poem", "ring_from_jeffery") player["gunnars_ground"] = "jeffery_ring" player.setAnimation("hand_over_item") diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/falador/BarmaidsRisingSunInn.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/falador/BarmaidsRisingSunInn.kts index 5dbb56df25..36bfc89b6a 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/falador/BarmaidsRisingSunInn.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/falador/BarmaidsRisingSunInn.kts @@ -10,6 +10,7 @@ import world.gregs.voidps.engine.entity.character.mode.interact.TargetNPCContext import world.gregs.voidps.engine.entity.character.npc.NPCOption import world.gregs.voidps.engine.entity.character.npc.npcApproach import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.character.player.chat.inventoryFull import world.gregs.voidps.engine.entity.character.player.chat.noInterest import world.gregs.voidps.engine.entity.character.player.skill.Skill @@ -73,7 +74,7 @@ itemOnNPCApproach("beer_glass", "barmaid_emily", handler = emptyGlass) itemOnNPCApproach("beer_glass", "barmaid_kaylee", handler = emptyGlass) itemOnNPCApproach("beer_glass", "barmaid_tina", handler = emptyGlass) -suspend fun NPCOption.menu() { +suspend fun NPCOption.menu() { npc("Heya! What can I get you?") choice { option("What ales are you serving?") { @@ -107,7 +108,7 @@ suspend fun NPCOption.menu() { val itemDefinitions: ItemDefinitions by inject() -suspend fun NPCOption.buyBeer(beer: String) { +suspend fun NPCOption.buyBeer(beer: String) { player.inventory.transaction { remove("coin", 3) add(beer) @@ -126,7 +127,7 @@ suspend fun NPCOption.buyBeer(beer: String) { } } -suspend fun NPCOption.buyEmptyGlasses() { +suspend fun NPCOption.buyEmptyGlasses() { choice { option("Okay, sure.") { player.inventory.transaction { @@ -140,7 +141,7 @@ suspend fun NPCOption.buyEmptyGlasses() { } } -suspend fun TargetNPCContext.barCrawl() = barCrawlDrink( +suspend fun TargetNPCContext.barCrawl() = barCrawlDrink( start = { npc("Heehee, this'll be fun!") npc("You'll be after our Hand of Death cocktail, then. Lots of expensive parts to the cocktail, though, so it will cost you 70 coins.") diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/falador/DressingRoom.kt b/game/src/main/kotlin/world/gregs/voidps/world/map/falador/DressingRoom.kt index 4ac66fe199..e91ffd5cc3 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/falador/DressingRoom.kt +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/falador/DressingRoom.kt @@ -3,10 +3,11 @@ package world.gregs.voidps.world.map.falador import world.gregs.voidps.engine.client.ui.closeDialogue import world.gregs.voidps.engine.client.ui.open import world.gregs.voidps.engine.entity.character.CharacterContext +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.character.setGraphic import world.gregs.voidps.engine.suspend.pause -internal suspend fun CharacterContext.openDressingRoom(id: String) { +internal suspend fun CharacterContext.openDressingRoom(id: String) { player.closeDialogue() pause(1) player.setGraphic("dressing_room_start") diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/falador/Hairdresser.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/falador/Hairdresser.kts index 88e15d27f2..8bfd98efb9 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/falador/Hairdresser.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/falador/Hairdresser.kts @@ -8,6 +8,7 @@ import world.gregs.voidps.engine.client.ui.interfaceOption import world.gregs.voidps.engine.data.definition.EnumDefinitions import world.gregs.voidps.engine.entity.character.npc.NPCOption import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.character.player.equip.equipped import world.gregs.voidps.engine.entity.character.player.flagAppearance import world.gregs.voidps.engine.entity.character.player.male @@ -39,7 +40,7 @@ npcOperate("Hair-cut", "hairdresser") { startHairdressing() } -suspend fun NPCOption.startHairdressing() { +suspend fun NPCOption.startHairdressing() { player.closeDialogue() if (player.equipped(EquipSlot.Weapon).isNotEmpty() || player.equipped(EquipSlot.Shield).isNotEmpty()) { npc("I don't feel comfortable cutting hair when you are wielding something. Please remove what you are holding first.") diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/falador/Iconis.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/falador/Iconis.kts index 0bd79932b4..8ef29b1f02 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/falador/Iconis.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/falador/Iconis.kts @@ -3,6 +3,7 @@ package world.gregs.voidps.world.map.falador import world.gregs.voidps.engine.entity.World import world.gregs.voidps.engine.entity.character.npc.NPCOption import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.world.interact.dialogue.Talk import world.gregs.voidps.world.interact.dialogue.type.npc @@ -20,6 +21,6 @@ npcOperate("Take-picture", "iconis") { } } -suspend fun NPCOption.nonMember() { +suspend fun NPCOption.nonMember() { npc("Good day! I'm afraid you can't use the booth's services on a non-members world. Film costs a lot you know!") } \ No newline at end of file diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/falador/MakeoverMage.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/falador/MakeoverMage.kts index 538f9d2e2a..51aecdc260 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/falador/MakeoverMage.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/falador/MakeoverMage.kts @@ -60,7 +60,7 @@ suspend fun PlayerChoice.more(): Unit = option("Tell me more about this 'm whatDoYouSay() } -suspend fun CharacterContext.whatDoYouSay() { +suspend fun CharacterContext.whatDoYouSay() { npc("So, what do you say? Feel like a change?") choice { start() @@ -108,7 +108,7 @@ suspend fun PlayerChoice.amulet(): Unit = option("Cool amulet! Can I ha } } -suspend fun CharacterContext.explain() { +suspend fun CharacterContext.explain() { npc("I can alter your physical form if you wish. Would you like me to perform my magicks on you?") choice { more() diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/falador/SquireAsrol.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/falador/SquireAsrol.kts index 4d2feffae8..0a4c37b6b6 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/falador/SquireAsrol.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/falador/SquireAsrol.kts @@ -3,6 +3,7 @@ package world.gregs.voidps.world.map.falador import world.gregs.voidps.engine.client.message import world.gregs.voidps.engine.entity.character.CharacterContext import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.character.player.combatLevel import world.gregs.voidps.engine.entity.character.player.skill.Skill import world.gregs.voidps.engine.entity.item.Item @@ -36,13 +37,13 @@ npcOperate("Talk-to", "squire_asrol") { } } -suspend fun CharacterContext.started() { +suspend fun CharacterContext.started() { npc("So how are you doing getting a sword?") player("I'm looking for Imcando dwarves to help me.") npc("Please try and find them quickly... I am scared Sir Vyvin will find out!") } -suspend fun CharacterContext.askAboutPicture() { +suspend fun CharacterContext.askAboutPicture() { npc("So how are you doing getting a sword?") player("I've found an Imcando dwarf but he needs a picture of the sword before he can make it.") npc("A picture eh? Hmmm.... The only one I can think of is in a small portrait of Sir Vyvin's father... Sir Vyvin keeps it in a cupboard in his room I think.") @@ -51,7 +52,7 @@ suspend fun CharacterContext.askAboutPicture() { npc("Please don't let him catch you! He MUSTN'T know what happened!") } -suspend fun CharacterContext.checkPicture() { +suspend fun CharacterContext.checkPicture() { npc("So how are you doing getting a sword?") if (player.holdsItem("portrait")) { player("I have the picture. I'll just take it to the dwarf now!") @@ -62,7 +63,7 @@ suspend fun CharacterContext.checkPicture() { npc("Please try and get it quickly... I am scared Sir Vyvin will find out!") } -suspend fun CharacterContext.bluriteSword() { +suspend fun CharacterContext.bluriteSword() { if (player.equipment.contains("blurite_sword")) { player("I have retrieved your sword for you.") npc("So can you un-equip it and hand it over to me now please?") @@ -124,7 +125,7 @@ suspend fun PlayerChoice.abundantWithSwords() = option("Well the kingdo } -suspend fun CharacterContext.heirloom() { +suspend fun CharacterContext.heirloom() { npc("The thing is, this sword is a family heirloom. It has been passed down through Vyvin's family for five generations! It was originally made by the Imcando dwarves, who were") npc("a particularly skilled tribe of dwarven smiths. I doubt anyone could make it in the style they do.") choice { @@ -162,7 +163,7 @@ suspend fun PlayerChoice.squireForMe() = option("Wouldn't you prefer to be npc("No, sorry, I'm loyal to Sir Vyvin.") } -suspend fun CharacterContext.startQuest() { +suspend fun CharacterContext.startQuest() { if (player.levels.get(Skill.Mining) < 10 && player.combatLevel < 20) { statement("Before starting this quest, be aware that one or more of your skill levels are lower than what is required to fully complete it. Your combat level is also lower than the recommended level of 20.") } else if (player.levels.get(Skill.Mining) < 10) { @@ -182,12 +183,12 @@ suspend fun CharacterContext.startQuest() { } } -suspend fun CharacterContext.completed() { +suspend fun CharacterContext.completed() { npc("Hello friend! Many thanks for all of your help! Vyvin never even realised it was a different sword, and I still have my job!") player("I'm glad the new sword worked out alright.") } -fun CharacterContext.questComplete() { +fun CharacterContext.questComplete() { player["the_knights_sword"] = "completed" player.playJingle("quest_complete_1") player.experience.add(Skill.Smithing, 12725.0) diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/karamja/BartenderDeadMansChest.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/karamja/BartenderDeadMansChest.kts index a827b6b591..bbd7845dcb 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/karamja/BartenderDeadMansChest.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/karamja/BartenderDeadMansChest.kts @@ -4,6 +4,7 @@ import world.gregs.voidps.engine.client.message import world.gregs.voidps.engine.client.ui.interact.itemOnNPCOperate import world.gregs.voidps.engine.entity.character.mode.interact.TargetNPCContext import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.character.player.chat.noInterest import world.gregs.voidps.engine.entity.character.player.skill.Skill import world.gregs.voidps.world.interact.dialogue.Chuckle @@ -45,7 +46,7 @@ itemOnNPCOperate("barcrawl_card", "bartender_dead_mans_chest") { barCrawl() } -suspend fun TargetNPCContext.barCrawl() = barCrawlDrink( +suspend fun TargetNPCContext.barCrawl() = barCrawlDrink( start = { npc("Haha time to be breaking out the old Supergrog. That'll be 15 coins please.") }, effects = { player.levels.drain(Skill.Attack, 7) diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/karamja/BartenderZambo.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/karamja/BartenderZambo.kts index 5add645598..82f04c07ff 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/karamja/BartenderZambo.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/karamja/BartenderZambo.kts @@ -4,6 +4,7 @@ import world.gregs.voidps.engine.client.ui.interact.itemOnNPCOperate import world.gregs.voidps.engine.entity.character.forceChat import world.gregs.voidps.engine.entity.character.mode.interact.TargetNPCContext import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.character.player.chat.noInterest import world.gregs.voidps.world.interact.dialogue.Talk import world.gregs.voidps.world.interact.dialogue.type.choice @@ -33,7 +34,7 @@ itemOnNPCOperate("barcrawl_card", "bartender_zambo") { barCrawl() } -suspend fun TargetNPCContext.barCrawl() = barCrawlDrink( +suspend fun TargetNPCContext.barCrawl() = barCrawlDrink( effects = { player.forceChat = "Mmmmm, dat was luverly..." } diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/BarfyBill.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/BarfyBill.kts index 6a9eb1a802..009776cc30 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/BarfyBill.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/BarfyBill.kts @@ -2,6 +2,7 @@ package world.gregs.voidps.world.map.lumbridge import world.gregs.voidps.engine.entity.character.CharacterContext import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.character.player.skill.Skill import world.gregs.voidps.world.interact.dialogue.* import world.gregs.voidps.world.interact.dialogue.type.choice @@ -40,7 +41,7 @@ npcOperate("Talk-To", "barfy_bill") { } } -suspend fun CharacterContext.canoeing() { +suspend fun CharacterContext.canoeing() { if (minimumCanoeLevel()) { return } diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/Cook.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/Cook.kts index b1541f3c4b..0df013a82e 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/Cook.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/Cook.kts @@ -4,6 +4,7 @@ import world.gregs.voidps.engine.client.message import world.gregs.voidps.engine.entity.character.CharacterContext import world.gregs.voidps.engine.entity.character.npc.NPCOption import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.character.player.skill.Skill import world.gregs.voidps.engine.entity.item.Item import world.gregs.voidps.engine.inv.add @@ -42,7 +43,7 @@ npcOperate("Talk-to", "cook_lumbridge") { } } -suspend fun CharacterContext.started() { +suspend fun CharacterContext.started() { npc("how are you getting on with finding the ingredients?") if (player.holdsItem("top_quality_milk")) { item("top_quality_milk", 500, "You give the top-quality milk to the cook.") @@ -95,7 +96,7 @@ suspend fun CharacterContext.started() { } } -suspend fun CharacterContext.completed() { +suspend fun CharacterContext.completed() { npc("Hello, friend, how is the adventuring going?") choice { option("I'm getting strong and mighty.") { @@ -111,7 +112,7 @@ suspend fun CharacterContext.completed() { } } -fun CharacterContext.questComplete() { +fun CharacterContext.questComplete() { player["cooks_assistant"] = "completed" player.playJingle("quest_complete_1") player.inventory.add("sardine_noted", 20) @@ -130,7 +131,7 @@ fun CharacterContext.questComplete() { player.sendQuestComplete("cook's assistant", lines, Item("cake")) } -suspend fun CharacterContext.startQuest() { +suspend fun CharacterContext.startQuest() { player("What's wrong?") npc("Oh dear, oh dear, oh dear, I'm in a terrible terrible mess! It's the Duke's birthday today, and I should be making him a lovely big birthday cake using special ingredients...") npc("...but I've forgotten to get the ingredients. I'll never get them in time now. He'll sack me! What will I do? I have four children and a goat to look after. Would you help me? Please?") @@ -151,12 +152,12 @@ suspend fun CharacterContext.startQuest() { } } -suspend fun CharacterContext.whereToFind() { +suspend fun CharacterContext.whereToFind() { npc("That's the problem: I don't exactly know. I usually send my assistant to get them for me but he quit.") npc("I've marked some places on your world map in red. You might want to consider investigating them.") } -suspend fun CharacterContext.stillNeed() { +suspend fun CharacterContext.stillNeed() { statement("You still need to get: ${if (player["cooks_assistant_milk", 0] == 0) "Some top-quality milk." else ""}${if (player["cooks_assistant_flour", 0] == 0) " Some extra fine flour." else ""}${if (player["cooks_assistant_egg", 0] == 0) " A super large egg." else ""}") choice { option("I'll get right on it.") @@ -166,7 +167,7 @@ suspend fun CharacterContext.stillNeed() { } } -suspend fun CharacterContext.niceHat() { +suspend fun CharacterContext.niceHat() { npc("Err thank you. It's a pretty ordinary cooks hat really.") player("Still, suits you. The trousers are pretty special too. ") npc("Its all standard cook's issue uniform...") @@ -175,7 +176,7 @@ suspend fun CharacterContext.niceHat() { startQuest() } -suspend fun CharacterContext.canIUseRange() { +suspend fun CharacterContext.canIUseRange() { npc("Go ahead! It's very good range; it's better than most other ranges.") npc("It's called the Cook-o-Matic 25 and it uses a combination of state-of-the-art temperature regulation and magic.") player("Will it mean my food will burn less often?") @@ -192,7 +193,7 @@ suspend fun CharacterContext.canIUseRange() { player("Thanks!") } -suspend fun NPCOption.dontLookHappy() { +suspend fun NPCOption.dontLookHappy() { npc("No, I'm not. The world is caving in around me - I am overcome by dark feelings of impending doom.") choice { option("What's wrong?") { diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/DukeHoracio.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/DukeHoracio.kts index 39c9b1e232..230ca93175 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/DukeHoracio.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/DukeHoracio.kts @@ -3,6 +3,7 @@ package world.gregs.voidps.world.map.lumbridge import world.gregs.voidps.engine.entity.character.CharacterContext import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.inv.add import world.gregs.voidps.engine.inv.inventory import world.gregs.voidps.world.activity.bank.ownsItem @@ -21,7 +22,7 @@ npcOperate("Talk-to", "duke_horacio") { } } -suspend fun CharacterContext.started() { +suspend fun CharacterContext.started() { choice { option("What did you want me to do again?") { if (player.ownsItem("air_talisman")) { @@ -44,7 +45,7 @@ suspend fun CharacterContext.started() { } } -suspend fun CharacterContext.unstarted() { +suspend fun CharacterContext.unstarted() { choice { option("Have you any quests for me?") { npc("Well, I wouldn't describe it as a quest, but there is something I could use some help with.") @@ -59,7 +60,7 @@ suspend fun CharacterContext.unstarted() { } } -suspend fun CharacterContext.completed() { +suspend fun CharacterContext.completed() { choice { option("Have you any quests for me?") { npc("The only job I had was the delivery of that talisman, so I'm afraid not.") @@ -72,7 +73,7 @@ suspend fun PlayerChoice.findMoney() : Unit = option("Where can I find mon npc("I've heard that the blacksmiths are prosperous amongst the peasantry. Maybe you could try your hand at that?") } -suspend fun CharacterContext.startQuest() { +suspend fun CharacterContext.startQuest() { choice("Start the Rune Mysteries quest?") { option("Sure, no problem.") { if (player.inventory.isFull()) { diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/FatherAereck.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/FatherAereck.kts index 68857e4338..ec5e312d65 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/FatherAereck.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/FatherAereck.kts @@ -2,6 +2,7 @@ package world.gregs.voidps.world.map.lumbridge import world.gregs.voidps.engine.entity.character.CharacterContext import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.inv.holdsItem import world.gregs.voidps.world.activity.quest.quest import world.gregs.voidps.world.activity.quest.refreshQuestJournal @@ -72,20 +73,20 @@ npcOperate("Talk-to", "father_aereck") { } } -suspend fun CharacterContext.started() { +suspend fun CharacterContext.started() { npc("Have you got rid of the ghost yet?") player("I can't find Father Urhney at the moment.") npc("Well, you can get to the swamp he lives in by going south through the cemetery.") npc("You'll have to go right into the far western depths of the swamp, near the coastline. That is where his house is.") } -suspend fun CharacterContext.ghost() { +suspend fun CharacterContext.ghost() { npc("Have you got rid of the ghost yet?") player("I had a talk with Father Urhney. He has given me this funny amulet to talk to the ghost with.") npc("I always wondered what that amulet was... Well, I hope it's useful. Tell me when you get rid of the ghost!") } -suspend fun CharacterContext.miningSpot() { +suspend fun CharacterContext.miningSpot() { npc("Have you got rid of the ghost yet?") player("I've found out that the ghost's corpse has lost its skull. If I can find the skull, the ghost should leave.") npc("That WOULD explain it.") @@ -95,7 +96,7 @@ suspend fun CharacterContext.miningSpot() { npc("Ah well, good luck!") } -suspend fun CharacterContext.foundSkull() { +suspend fun CharacterContext.foundSkull() { if (player.holdsItem("ghostspeak_amulet")) { npc("Have you got rid of the ghost yet?") player("I've finally found the ghost's skull!") @@ -107,7 +108,7 @@ suspend fun CharacterContext.foundSkull() { } } -suspend fun CharacterContext.completed() { +suspend fun CharacterContext.completed() { npc("Thank you for getting rid of that awful ghost for me! May Saradomin always smile upon you!") player("I'm looking for a new quest.") npc("Sorry, I only had the one quest.") diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/FatherUrhney.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/FatherUrhney.kts index 645a907951..fd504a3fb2 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/FatherUrhney.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/FatherUrhney.kts @@ -3,6 +3,7 @@ package world.gregs.voidps.world.map.lumbridge import world.gregs.voidps.engine.client.message import world.gregs.voidps.engine.entity.character.CharacterContext import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.item.floor.FloorItems import world.gregs.voidps.engine.inject import world.gregs.voidps.engine.inv.add @@ -76,10 +77,9 @@ npcOperate("Talk-to", "father_urhney") { } } - val floorItems: FloorItems by inject() -suspend fun CharacterContext.ghost() { +suspend fun CharacterContext.ghost() { npc("Oh, the silly fool.") npc("I leave town for just five months, and ALREADY he can't manage.") npc("(sigh)") diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/GillieGroats.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/GillieGroats.kts index 75ad22939e..59177e9f2f 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/GillieGroats.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/GillieGroats.kts @@ -2,6 +2,7 @@ package world.gregs.voidps.world.map.lumbridge import world.gregs.voidps.engine.entity.character.CharacterContext import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.inv.holdsItem import world.gregs.voidps.world.activity.quest.quest import world.gregs.voidps.world.interact.dialogue.Happy @@ -27,14 +28,14 @@ npcOperate("Talk-to", "gillie_groats") { } } -suspend fun CharacterContext.whoAreYou() { +suspend fun CharacterContext.whoAreYou() { npc("My name's Gillie Groats. My father is a farmer and I milk the cows for him.") player("Do you have any buckets of milk spare?") npc("I'm afraid not. We need all of our milk to sell to market, but you can milk the cow yourself if you need milk.") player("Thanks.") } -suspend fun CharacterContext.howToMilkCow() { +suspend fun CharacterContext.howToMilkCow() { player("So how do you get milk from a cow then?") npc("It's very easy. First you need an empty bucket to hold the milk.") npc("Then find a dairy cow to milk - you can't milk just any cow.") @@ -45,7 +46,7 @@ suspend fun CharacterContext.howToMilkCow() { } -suspend fun CharacterContext.topQualityMilk() { +suspend fun CharacterContext.topQualityMilk() { npc("Really? Is it for something special?") player("Most certainly! It's for the cook to make a cake foe Duke Horacio!") npc("Wow, it's quite an honour that you'd pick my cows. I'd suggest you get some milk from my prized cow.") diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/LumbridgeChurch.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/LumbridgeChurch.kts index e6b121b19d..7ecc8bba5f 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/LumbridgeChurch.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/LumbridgeChurch.kts @@ -10,6 +10,7 @@ import world.gregs.voidps.engine.entity.character.face import world.gregs.voidps.engine.entity.character.forceChat import world.gregs.voidps.engine.entity.character.move.tele import world.gregs.voidps.engine.entity.character.npc.NPCs +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.character.player.skill.Skill import world.gregs.voidps.engine.entity.character.setAnimation import world.gregs.voidps.engine.entity.item.Item @@ -78,7 +79,7 @@ itemOnObjectOperate("muddy_skull", "coffin_restless_ghost_2") { val ghostSpawn = Tile(3250, 3195) -suspend fun CharacterContext.returnSkull() { +suspend fun CharacterContext.returnSkull() { player.message("You put the skull in the coffin.") val region = Region(12849) val instance = startCutscene(region) @@ -116,7 +117,7 @@ suspend fun CharacterContext.returnSkull() { questComplete() } -fun CharacterContext.questComplete() { +fun CharacterContext.questComplete() { player["restless_ghost_coffin"] = "skull" player["the_restless_ghost"] = "completed" player.playJingle("quest_complete_1") @@ -158,7 +159,7 @@ objectOperate("Search", "restless_ghost_coffin_closed") { } } -suspend fun CharacterContext.spawnGhost() { +suspend fun CharacterContext.spawnGhost() { val ghostExists = npcs[ghostSpawn.zone].any { it.id == "restless_ghost" } if (!ghostExists) { player.playSound("coffin_open") @@ -182,13 +183,13 @@ playerSpawn { player -> player.sendVariable("restless_ghost_coffin") } -fun CharacterContext.setCutsceneEnd(instance: Region) { +fun CharacterContext.setCutsceneEnd(instance: Region) { player.queue("restless_ghost_cutscene_end", 1, LogoutBehaviour.Accelerate) { endCutscene(instance) } } -fun CharacterContext.endCutscene(instance: Region) { +fun CharacterContext.endCutscene(instance: Region) { npcs.clear(instance.toLevel(0)) player.clearCamera() player.tele(3247, 3193) diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/MillieMiller.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/MillieMiller.kts index d998870e1d..eb8fe0d7b9 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/MillieMiller.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/MillieMiller.kts @@ -2,6 +2,7 @@ package world.gregs.voidps.world.map.lumbridge import world.gregs.voidps.engine.entity.character.CharacterContext import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.inv.holdsItem import world.gregs.voidps.world.activity.quest.quest import world.gregs.voidps.world.interact.dialogue.Happy @@ -17,7 +18,7 @@ npcOperate("Talk-to", "millie_miller") { menu() } -suspend fun CharacterContext.menu() { +suspend fun CharacterContext.menu() { choice { option("I'm looking for extra fine flour.", { player.quest("cooks_assistant") == "started" && !player.holdsItem("extra_fine_flour") }) { npc("What's wrong with ordinary flour?") diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/RestlessGhost.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/RestlessGhost.kts index 7ad56b42cc..1897a2ae7a 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/RestlessGhost.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/RestlessGhost.kts @@ -3,6 +3,7 @@ package world.gregs.voidps.world.map.lumbridge import world.gregs.voidps.engine.client.message import world.gregs.voidps.engine.entity.character.CharacterContext import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.inv.equipment import world.gregs.voidps.engine.inv.inventory import world.gregs.voidps.world.activity.quest.quest @@ -21,7 +22,7 @@ npcOperate("Talk-to", "restless_ghost") { } } -suspend fun CharacterContext.ghost() { +suspend fun CharacterContext.ghost() { if (player.equipment.contains("ghostspeak_amulet")) { player("Hello ghost, how are you?") npc("Not very good actually.") @@ -64,7 +65,7 @@ suspend fun CharacterContext.ghost() { } } -suspend fun CharacterContext.noGhostAmulet() { +suspend fun CharacterContext.noGhostAmulet() { player("Hello ghost, how are you?") npc("Wooo wooo wooooo!") choice { @@ -130,14 +131,14 @@ suspend fun CharacterContext.noGhostAmulet() { } -suspend fun CharacterContext.dontSpeakGhost() { +suspend fun CharacterContext.dontSpeakGhost() { npc("Woo woo?") player("Nope, still don't understand you.") npc("WOOOOOOOOO!") player("Never mind.") } -suspend fun CharacterContext.notSoSure() { +suspend fun CharacterContext.notSoSure() { npc("Wooo woo?") player("Well, if you INSIST.") npc("Wooooooooo!") @@ -146,7 +147,7 @@ suspend fun CharacterContext.notSoSure() { player("Bye.") } -suspend fun CharacterContext.task() { +suspend fun CharacterContext.task() { npc("I should think it's because I've lost my head.") player("What? I can see your head perfectly fine well, see through it at least.") npc("No, no, I mean from my REAL body. If you look in my coffin you'll see my corpse is without its skull. Last thing I remember was being attacked by a warlock while I was mining. It was at the mine just south of this") @@ -155,7 +156,7 @@ suspend fun CharacterContext.task() { player["the_restless_ghost"] = "mining_spot" } -suspend fun CharacterContext.helpMe() { +suspend fun CharacterContext.helpMe() { choice { option("Yes, ok. Do you know WHY you're a ghost?") { task() @@ -168,7 +169,7 @@ suspend fun CharacterContext.helpMe() { } } -suspend fun CharacterContext.miningSpot() { +suspend fun CharacterContext.miningSpot() { if (player.equipment.contains("ghostspeak_amulet")) { if (player.inventory.contains("muddy_skull")) { player("Hello ghost, how are you?") diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/combat_hall/MagicTutor.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/combat_hall/MagicTutor.kts index 2f54e84154..c9a6c1a5f4 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/combat_hall/MagicTutor.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/combat_hall/MagicTutor.kts @@ -4,6 +4,7 @@ import world.gregs.voidps.engine.client.variable.remaining import world.gregs.voidps.engine.client.variable.start import world.gregs.voidps.engine.entity.character.CharacterContext import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.character.player.chat.inventoryFull import world.gregs.voidps.engine.entity.character.player.name import world.gregs.voidps.engine.entity.character.player.skill.Skill @@ -25,7 +26,7 @@ npcOperate("Talk-to", "mikasi") { menu() } -suspend fun CharacterContext.menu(followUp: String = "") { +suspend fun CharacterContext.menu(followUp: String = "") { if (followUp.isNotEmpty()) { npc(followUp) } @@ -92,7 +93,7 @@ suspend fun PlayerChoice.claimRunes(): Unit = option("I'd like some air and mind player.inventory.add("mind_rune", 30) } -suspend fun CharacterContext.hasRunes() { +suspend fun CharacterContext.hasRunes() { var banked = false if (player.bank.contains("mind_rune")) { npc("You have some mind runes in your bank.") diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/combat_hall/MeleeTutor.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/combat_hall/MeleeTutor.kts index 8f53aada90..df3e57d137 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/combat_hall/MeleeTutor.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/combat_hall/MeleeTutor.kts @@ -2,6 +2,7 @@ package world.gregs.voidps.world.map.lumbridge.combat_hall import world.gregs.voidps.engine.entity.character.CharacterContext import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.character.player.skill.Skill import world.gregs.voidps.engine.entity.character.player.skill.level.Level import world.gregs.voidps.engine.inv.add @@ -19,7 +20,7 @@ npcOperate("Talk-to", "harlan") { menu() } -suspend fun CharacterContext.menu(followUp: String = "") { +suspend fun CharacterContext.menu(followUp: String = "") { if (followUp.isNotEmpty()) { npc(followUp) } @@ -109,7 +110,7 @@ suspend fun PlayerChoice.skillcapes(): Unit = option("Tell me about ski } } -suspend fun CharacterContext.buySkillcape() { +suspend fun CharacterContext.buySkillcape() { player("May I buy a Skillcape of Defence, please?") npc("You wish to join the elite defenders of this world? I'm afraid such things do not come cheaply - in fact they cost 99000 coins, to be precise!") choice { diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/combat_hall/RangeTutor.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/combat_hall/RangeTutor.kts index 3c92eb2649..61e99159c1 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/combat_hall/RangeTutor.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/lumbridge/combat_hall/RangeTutor.kts @@ -4,6 +4,7 @@ import world.gregs.voidps.engine.client.variable.remaining import world.gregs.voidps.engine.client.variable.start import world.gregs.voidps.engine.entity.character.CharacterContext import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.character.player.chat.inventoryFull import world.gregs.voidps.engine.inv.add import world.gregs.voidps.engine.inv.equipment @@ -20,7 +21,7 @@ npcOperate("Talk-to", "nemarti") { menu() } -suspend fun CharacterContext.menu(followUp: String = "") { +suspend fun CharacterContext.menu(followUp: String = "") { if (followUp.isNotEmpty()) { npc(followUp) } @@ -66,7 +67,7 @@ suspend fun PlayerChoice.arrowMaking(): Unit = option("How do I create a b menu("Is there anything else you want to know?") } -suspend fun CharacterContext.claimBow() { +suspend fun CharacterContext.claimBow() { if (player.remaining("claimed_tutor_consumables", epochSeconds()) > 0) { npc("I work with the Magic tutor to give out consumable items that you may need for combat such as arrows and runes. However we have had some cheeky people try to take both!") npc("So, every half an hour, you may come back and claim either arrows OR runes, but not both. Come back in a while for arrows, or simply make your own.") @@ -99,7 +100,7 @@ suspend fun CharacterContext.claimBow() { player.start("claimed_tutor_consumables", TimeUnit.MINUTES.toSeconds(30).toInt(), epochSeconds()) } -suspend fun CharacterContext.hasEquipment() { +suspend fun CharacterContext.hasEquipment() { var banked = false if (player.bank.contains("training_arrows")) { npc("You have some training arrows in your bank.") diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/musicians/DrunkenMusician.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/musicians/DrunkenMusician.kts index 7f90a5c971..9218d60c09 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/musicians/DrunkenMusician.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/musicians/DrunkenMusician.kts @@ -2,6 +2,7 @@ package world.gregs.voidps.world.map.musicians import world.gregs.voidps.engine.entity.character.CharacterContext import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.world.interact.dialogue.Drunk import world.gregs.voidps.world.interact.dialogue.Pleased import world.gregs.voidps.world.interact.dialogue.Quiz @@ -15,7 +16,7 @@ npcOperate("Talk-to", "drunken_musician") { choice() } -suspend fun CharacterContext.choice() { +suspend fun CharacterContext.choice() { choice { option("Who are you?") { npc("Me? I'sh mooshian! Lemme her help youse relaxsh: sit down, reshst your weery limz an' stuff. You'll feel mush better. Like me, I ffeel great!") @@ -33,7 +34,7 @@ suspend fun CharacterContext.choice() { } } -suspend fun CharacterContext.resting() { +suspend fun CharacterContext.resting() { choice("Can I ask you some questions about resting?") { option("How does resting work?") { player("So how does resting work?") diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/musicians/GhostlyPiper.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/musicians/GhostlyPiper.kts index db21f2c763..7dbc62889e 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/musicians/GhostlyPiper.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/musicians/GhostlyPiper.kts @@ -3,6 +3,7 @@ package world.gregs.voidps.world.map.musicians import world.gregs.voidps.engine.client.message import world.gregs.voidps.engine.entity.character.CharacterContext import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.character.player.equip.equipped import world.gregs.voidps.network.login.protocol.visual.update.player.EquipSlot import world.gregs.voidps.world.interact.dialogue.* @@ -20,7 +21,7 @@ npcOperate("Talk-to", "ghostly_piper") { choice() } -suspend fun CharacterContext.choice() { +suspend fun CharacterContext.choice() { choice { option("Who are you?") { npc("I play the pipes, to rouse the brave warriors of Saradomin for the fight!") diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/musicians/GoblinMusician.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/musicians/GoblinMusician.kts index 32a1da2cd7..6e3ae947d2 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/musicians/GoblinMusician.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/musicians/GoblinMusician.kts @@ -2,6 +2,7 @@ package world.gregs.voidps.world.map.musicians import world.gregs.voidps.engine.entity.character.CharacterContext import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.world.interact.dialogue.HappyOld import world.gregs.voidps.world.interact.dialogue.NeutralOld import world.gregs.voidps.world.interact.dialogue.Pleased @@ -14,7 +15,7 @@ npcOperate("Talk-to", "goblin_musician") { choice() } -suspend fun CharacterContext.choice() { +suspend fun CharacterContext.choice() { choice { option("Who are you?") { npc("Me? Thump-Thump. Me make thump-thumps with thump-thump drum. Other goblins listen.") @@ -27,7 +28,7 @@ suspend fun CharacterContext.choice() { } } -suspend fun CharacterContext.resting() { +suspend fun CharacterContext.resting() { choice("Can I ask you some questions about resting?") { option("How does resting work?") { npc("You stoopid. Goblin sit down, goblin rest, goblin feel better.") diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/musicians/Musician.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/musicians/Musician.kts index e73a371b90..664601d4f7 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/musicians/Musician.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/musicians/Musician.kts @@ -2,6 +2,7 @@ package world.gregs.voidps.world.map.musicians import world.gregs.voidps.engine.entity.character.CharacterContext import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.world.interact.dialogue.Happy import world.gregs.voidps.world.interact.dialogue.Pleased import world.gregs.voidps.world.interact.dialogue.Quiz @@ -15,7 +16,7 @@ npcOperate("Talk-to", "musician*") { choice() } -suspend fun CharacterContext.choice() { +suspend fun CharacterContext.choice() { choice { option("Who are you?") { npc("Me? I'm a musician Let me help you relax: sit down, rest your weary limbs and allow me to wash away the troubles of the day.") @@ -29,7 +30,7 @@ suspend fun CharacterContext.choice() { } } -suspend fun CharacterContext.resting() { +suspend fun CharacterContext.resting() { choice("Can I ask you some questions about resting?") { option("How does resting work?") { player("So how does resting work?") diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/neitiznot/ThakkradSigmundson.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/neitiznot/ThakkradSigmundson.kts index 30e8db0d0a..9f57d29647 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/neitiznot/ThakkradSigmundson.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/neitiznot/ThakkradSigmundson.kts @@ -3,6 +3,7 @@ package world.gregs.voidps.world.map.neitiznot import world.gregs.voidps.engine.client.ui.interact.itemOnNPCOperate import world.gregs.voidps.engine.entity.character.CharacterContext import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.inv.inventory import world.gregs.voidps.engine.inv.transact.TransactionError import world.gregs.voidps.engine.inv.transact.operation.AddItem.add @@ -36,7 +37,7 @@ itemOnNPCOperate("yak_hide", "thakkrad_sigmundson") { cureHide() } -suspend fun CharacterContext.cureHide() { +suspend fun CharacterContext.cureHide() { player("Cure my yak hide please.") npc("I will cure yak-hide for a fee of 5 gp per hide.") choice("How many hides do you want cured?") { @@ -56,7 +57,7 @@ suspend fun CharacterContext.cureHide() { } } -suspend fun CharacterContext.cure(amount: Int) { +suspend fun CharacterContext.cure(amount: Int) { if (!player.inventory.contains("yak_hide")) { npc("You have no yak-hide to cure.") return diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/ourania/Eniola.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/ourania/Eniola.kts index fc26d13bdf..20a4d9f49a 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/ourania/Eniola.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/ourania/Eniola.kts @@ -8,6 +8,7 @@ import world.gregs.voidps.engine.client.ui.open import world.gregs.voidps.engine.entity.character.CharacterContext import world.gregs.voidps.engine.entity.character.npc.NPCOption import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.inv.inventory import world.gregs.voidps.engine.inv.remove import world.gregs.voidps.engine.queue.queue @@ -78,31 +79,31 @@ npcOperate("Collect", "eniola") { openCollection() } -fun ChoiceBuilder.accessBank() { +fun ChoiceBuilder>.accessBank() { option("I'd like to access my bank account, please.") { openBank() } } -fun ChoiceBuilder.collectionBox() { +fun ChoiceBuilder>.collectionBox() { option("I'd like to see my collection box.") { openCollection() } } -fun ChoiceBuilder.pinSettings() { +fun ChoiceBuilder>.pinSettings() { option("I'd like to check my PIN settings.") { } } -suspend fun NPCOption.openCollection() { +suspend fun NPCOption.openCollection() { if (runePayment()) { player.open("collection_box") } } -suspend fun NPCOption.openBank() { +suspend fun NPCOption.openBank() { if (runePayment()) { player.open("bank") } @@ -124,7 +125,7 @@ val runes = listOf("air_rune", "soul_rune" ) -suspend fun CharacterContext.runePayment(): Boolean { +suspend fun CharacterContext.runePayment(): Boolean { player.open("ourania_bank_charge") val rune = StringSuspension() player.close("ourania_bank_charge") diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/port_sarim/BartenderRustyAnchor.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/port_sarim/BartenderRustyAnchor.kts index a45a03aac1..84728f53b1 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/port_sarim/BartenderRustyAnchor.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/port_sarim/BartenderRustyAnchor.kts @@ -5,6 +5,7 @@ import world.gregs.voidps.engine.client.ui.interact.itemOnNPCOperate import world.gregs.voidps.engine.entity.character.forceChat import world.gregs.voidps.engine.entity.character.mode.interact.TargetNPCContext import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.character.player.chat.noInterest import world.gregs.voidps.world.interact.dialogue.Quiz import world.gregs.voidps.world.interact.dialogue.Talk @@ -40,7 +41,7 @@ itemOnNPCOperate("barcrawl_card", "bartender_rusty_anchor") { barCrawl() } -suspend fun TargetNPCContext.barCrawl() = barCrawlDrink( +suspend fun TargetNPCContext.barCrawl() = barCrawlDrink( start = { npc("Are you sure? You look a bit skinny for that.") player("Just give me whatever I need to drink here.") diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/port_sarim/Thurgo.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/port_sarim/Thurgo.kts index ec2c163176..eae5d017c4 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/port_sarim/Thurgo.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/port_sarim/Thurgo.kts @@ -4,6 +4,7 @@ import world.gregs.voidps.engine.client.ui.interact.itemOnNPCOperate import world.gregs.voidps.engine.entity.character.CharacterContext import world.gregs.voidps.engine.entity.character.mode.interact.Interaction import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.item.Item import world.gregs.voidps.engine.inv.contains import world.gregs.voidps.engine.inv.holdsItem @@ -25,7 +26,7 @@ npcOperate("Talk-to", "thurgo") { } } -suspend fun Interaction.menuReplacementSword() { +suspend fun Interaction.menuReplacementSword() { choice { madeSword() replacementSword() @@ -76,7 +77,7 @@ suspend fun PlayerChoice.replacementSword() = option( npc("Well, I need a blurite ore and two iron bars. The only place I know to get blurite is under this cliff here, but it is guarded by a very powerful ice giant.") } -suspend fun Interaction.menuAboutSword() { +suspend fun Interaction.menuAboutSword() { choice { aboutSword() redberryPie() @@ -84,7 +85,7 @@ suspend fun Interaction.menuAboutSword() { } } -suspend fun Interaction.menuSword() { +suspend fun Interaction.menuSword() { choice { specialSword() redberryPie() @@ -92,7 +93,7 @@ suspend fun Interaction.menuSword() { } } -suspend fun Interaction.menu() { +suspend fun Interaction.menu() { choice { imcandoDwarf() redberryPie() @@ -155,7 +156,7 @@ suspend fun PlayerChoice.whatCape() = option("What is that cape you're wearing?" thatCape() } -suspend fun CharacterContext.thatCape() { +suspend fun CharacterContext.thatCape() { player("What is that cape you're wearing?") npc("It's a Skillcape of Smithing. It shows that I'm a master blacksmith, but that's only to be expected - after all, my ancestors were the greatest blacksmiths in dwarven history.") npc("If you ever achieve level 99 Smithing you'll be able to wear a cape like this, and receive more experience when smelting gold ore.") diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/rellekka/Yrsa.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/rellekka/Yrsa.kts index fb35496968..cdeded3010 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/rellekka/Yrsa.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/rellekka/Yrsa.kts @@ -8,6 +8,7 @@ import world.gregs.voidps.engine.client.ui.interfaceOption import world.gregs.voidps.engine.data.definition.EnumDefinitions import world.gregs.voidps.engine.entity.character.CharacterContext import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.character.player.equip.equipped import world.gregs.voidps.engine.entity.character.player.flagAppearance import world.gregs.voidps.engine.entity.character.player.sex @@ -42,7 +43,7 @@ npcOperate("Change-shoes", "yrsa") { startShoeShopping() } -suspend fun CharacterContext.startShoeShopping() { +suspend fun CharacterContext.startShoeShopping() { player.closeDialogue() if (player.equipped(EquipSlot.Weapon).isNotEmpty() || player.equipped(EquipSlot.Shield).isNotEmpty()) { npc("I don't feel comfortable showing you shoes when you are wielding something. Please remove what you are holding first.") diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/seers_village/BartenderForestersArms.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/seers_village/BartenderForestersArms.kts index 775ee767f5..3e5b3b0d83 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/seers_village/BartenderForestersArms.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/seers_village/BartenderForestersArms.kts @@ -4,6 +4,7 @@ import world.gregs.voidps.engine.client.message import world.gregs.voidps.engine.client.ui.interact.itemOnNPCOperate import world.gregs.voidps.engine.entity.character.mode.interact.TargetNPCContext import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.character.player.chat.noInterest import world.gregs.voidps.engine.entity.character.player.skill.Skill import world.gregs.voidps.world.interact.dialogue.Quiz @@ -62,7 +63,7 @@ itemOnNPCOperate("barcrawl_card", "bartender_foresters_arms") { barCrawl() } -suspend fun TargetNPCContext.barCrawl() = barCrawlDrink( +suspend fun TargetNPCContext.barCrawl() = barCrawlDrink( effects = { player.levels.drain(Skill.Attack, 6) player.levels.drain(Skill.Defence, 6) diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/sophanem/GuardianMummy.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/sophanem/GuardianMummy.kts index 7e07a529e1..8fbd0bcb31 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/sophanem/GuardianMummy.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/sophanem/GuardianMummy.kts @@ -4,6 +4,7 @@ import world.gregs.voidps.engine.client.message import world.gregs.voidps.engine.client.ui.interact.itemOnNPCOperate import world.gregs.voidps.engine.entity.character.CharacterContext import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.inv.Inventory import world.gregs.voidps.engine.inv.holdsItem import world.gregs.voidps.engine.inv.inventory @@ -45,7 +46,7 @@ itemOnNPCOperate("pharaohs_sceptre", "guardian_mummy") { sceptreRecharging() } -suspend fun CharacterContext.notAnother() { +suspend fun CharacterContext.notAnother() { npc("*sigh* Not another one.") player("Another what?") npc("Another 'archaeologist'.") @@ -56,7 +57,7 @@ suspend fun CharacterContext.notAnother() { playPyramidPlunder() } -suspend fun CharacterContext.playPyramidPlunder() { +suspend fun CharacterContext.playPyramidPlunder() { choice("Play the 'Pyramid Plunder' minigame?") { option("That sounds like fun, what do I do?") { soundsLikeFun() @@ -77,12 +78,12 @@ suspend fun CharacterContext.playPyramidPlunder() { } } -suspend fun CharacterContext.itIsDone() { +suspend fun CharacterContext.itIsDone() { npc("It is done.") playPyramidPlunder() } -suspend fun CharacterContext.sceptreRecharging() { +suspend fun CharacterContext.sceptreRecharging() { player("This sceptre seems to have run out of charges.") npc("You shouldn't have that thing in the first place, thief!") player("If I gave you back some of the artefacts I've taken from the tomb, would you recharge the sceptre for me.") @@ -115,7 +116,7 @@ suspend fun CharacterContext.sceptreRecharging() { } } -suspend fun CharacterContext.sceptreDischarging() { +suspend fun CharacterContext.sceptreDischarging() { val count = player.inventory.items.count { it.id.startsWith("pharaohs_sceptre_") } if (count < 0) { player("I want to charge my sceptre.") @@ -166,7 +167,7 @@ itemOnNPCOperate("*", "guardian_mummy") { player.message("The Mummy is not interested in this") } -suspend fun CharacterContext.soundsLikeFun() { +suspend fun CharacterContext.soundsLikeFun() { npc("You have five minutes to explore the treasure rooms and collect as many artefacts as you can.") npc("The artefacts are in the urns, chests and sarcophagi found in each room.") npc("There are eight treasure rooms, each subsequent room requires higher thieving skills to both enter the room and thieve from the urns and other containers.") @@ -178,7 +179,7 @@ suspend fun CharacterContext.soundsLikeFun() { anymoreQuestions("How do I get the artefacts?") } -suspend fun CharacterContext.anymoreQuestions(option: String) { +suspend fun CharacterContext.anymoreQuestions(option: String) { choice("Do you have any more questions?") { option("How do I leave the game?") { howDoILeave() @@ -195,18 +196,18 @@ suspend fun CharacterContext.anymoreQuestions(option: String) { } } -suspend fun CharacterContext.iKnowWhatImDoing() { +suspend fun CharacterContext.iKnowWhatImDoing() { statement("Pyramid Plunder is not currently implemented.") // npc("Fine, I'll take you to the first room now...") } -suspend fun CharacterContext.howDoILeave() { +suspend fun CharacterContext.howDoILeave() { npc("If at any point you decide you need to leave just use a glowing door.") npc("The game will end and you will be taken out of the pyramid.") anymoreQuestions("What about the chests and sarcophagi?") } -suspend fun CharacterContext.howToGetArtefacts() { +suspend fun CharacterContext.howToGetArtefacts() { npc("The artefacts are in the urns, chests and sarcophagi.") npc("Urns contain snakes that guard them.") npc("The sarcophagi take some strength to open. They take a while to open.") @@ -215,7 +216,7 @@ suspend fun CharacterContext.howToGetArtefacts() { anymoreQuestions("What about the chests and sarcophagi?") } -suspend fun CharacterContext.whatToDoWithArtefacts() { +suspend fun CharacterContext.whatToDoWithArtefacts() { npc("There are a number of different artefacts, of three main types. The least valuable are the pottery statuettes and scarabs, and the ivory combs.") npc("Next are the stone scarabs, statuettes and seals, and finally the gold versions of those artefacts.") npc("They are not old, but are well made.") @@ -227,7 +228,7 @@ suspend fun CharacterContext.whatToDoWithArtefacts() { anymoreQuestionsSceptre() } -suspend fun CharacterContext.anymoreQuestionsSceptre() { +suspend fun CharacterContext.anymoreQuestionsSceptre() { choice("Do you have any more questions?") { option("How do I leave the game?") { howDoILeave() @@ -244,14 +245,14 @@ suspend fun CharacterContext.anymoreQuestionsSceptre() { } } -suspend fun CharacterContext.leaveTheTomb() { +suspend fun CharacterContext.leaveTheTomb() { choice("Leave the Tomb?") { option("Yes, I'm out of here.") option("Ah, I think I'll stay a little longer.") } } -suspend fun CharacterContext.whereDidYouHearAboutThat() { +suspend fun CharacterContext.whereDidYouHearAboutThat() { npc("Where did you hear about that?") player("I couldn't possibly say.") npc("It's the only genuinely valuable artefact in this place.") @@ -261,7 +262,7 @@ suspend fun CharacterContext.whereDidYouHearAboutThat() { anymoreQuestions("What about the chests and sarcophagi?") } -suspend fun CharacterContext.discharge(index: Int) { +suspend fun CharacterContext.discharge(index: Int) { if (player.inventory.replace(index, player.inventory[index].id, "pharaohs_sceptre")) { itIsDone() } diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/taverley/Kaqemeex.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/taverley/Kaqemeex.kts index 34e3abc4e9..c13e94b5a9 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/taverley/Kaqemeex.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/taverley/Kaqemeex.kts @@ -2,6 +2,7 @@ package world.gregs.voidps.world.map.taverley import world.gregs.voidps.engine.entity.character.CharacterContext import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.character.player.name import world.gregs.voidps.engine.entity.character.player.skill.Skill import world.gregs.voidps.engine.entity.character.player.skill.level.Level.hasMax @@ -72,7 +73,7 @@ npcOperate("Talk-to", "kaqemeex") { } -suspend fun CharacterContext.startedQuest() { +suspend fun CharacterContext.startedQuest() { npc("That used to be OUR stone circle. Unfortunately, many many years ago, dark wizards cast a wicked spell upon it so that they could corrupt its power for their own evil ends.") npc("When they cursed the rocks for their rituals they made them useless to us and our magics. We require a brave adventurer to go on a quest for us to help purify the circle of Varrock.") choice("Start the Druidic Ritual quest?") { @@ -91,19 +92,19 @@ suspend fun CharacterContext.startedQuest() { } } -suspend fun CharacterContext.started() { +suspend fun CharacterContext.started() { player("Hello there.") npc("Hello again, adventurer. You will need to speak to my fellow druid Sanfew in the village south of here to continue in your quest.") player("Okay, thanks.") } -suspend fun CharacterContext.kaqemeex() { +suspend fun CharacterContext.kaqemeex() { player("Hello there.") npc("I have word from Sanfew that you have been very helpful in assisting him with his preparations for the purification ritual. As promised I will now teach you the ancient arts of Herblore.") questComplete() } -suspend fun CharacterContext.completed() { +suspend fun CharacterContext.completed() { player("Hello there.") npc("Hello again. How is the Herblore going?") choice { @@ -169,7 +170,7 @@ suspend fun CharacterContext.completed() { } } -fun CharacterContext.questComplete() { +fun CharacterContext.questComplete() { player["druidic_ritual"] = "completed" player.playJingle("quest_complete_1") player.experience.add(Skill.Herblore, 250.0) diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/taverley/Sanfew.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/taverley/Sanfew.kts index 299f2b9068..5acbb44440 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/taverley/Sanfew.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/taverley/Sanfew.kts @@ -2,6 +2,7 @@ package world.gregs.voidps.world.map.taverley import world.gregs.voidps.engine.entity.character.CharacterContext import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.item.Item import world.gregs.voidps.engine.inv.contains import world.gregs.voidps.engine.inv.inventory @@ -41,7 +42,7 @@ npcOperate("Talk-to", "sanfew") { } } -suspend fun CharacterContext.started() { +suspend fun CharacterContext.started() { npc("What can I do for you young 'un?") choice { option("I've been sent to help purify the Varrock stone circle.") { @@ -64,7 +65,7 @@ suspend fun CharacterContext.started() { } } -suspend fun CharacterContext.cauldron() { +suspend fun CharacterContext.cauldron() { npc("Did you bring me the required ingredients for the potion?") if (!player.inventory.contains(enchantedMeat)) { noMeat() @@ -78,7 +79,7 @@ suspend fun CharacterContext.cauldron() { npc("Now go and talk to Kaqemeex and he will introduce you to the wonderful world of herblore and potion making!") } -suspend fun CharacterContext.noMeat() { +suspend fun CharacterContext.noMeat() { player("No, not yet...") npc("Well let me know when you do young 'un.") choice { @@ -100,7 +101,7 @@ suspend fun CharacterContext.noMeat() { } } -suspend fun CharacterContext.eadgarsRuse() { +suspend fun CharacterContext.eadgarsRuse() { npc("What can I do for you young 'un?") choice { option("Have you any more work for me, to help reclaim the circle?") { diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/tree_gnome_stronghold/Blurberry.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/tree_gnome_stronghold/Blurberry.kts index d1f9490cfd..4a52889ea8 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/tree_gnome_stronghold/Blurberry.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/tree_gnome_stronghold/Blurberry.kts @@ -3,6 +3,7 @@ package world.gregs.voidps.world.map.tree_gnome_stronghold import world.gregs.voidps.engine.client.ui.interact.itemOnNPCOperate import world.gregs.voidps.engine.entity.character.mode.interact.TargetNPCContext import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.character.player.chat.noInterest import world.gregs.voidps.world.interact.dialogue.HappyOld import world.gregs.voidps.world.interact.dialogue.NeutralOld @@ -34,7 +35,7 @@ itemOnNPCOperate("barcrawl_card", "blurberry") { barCrawl() } -suspend fun TargetNPCContext.barCrawl() = barCrawlDrink( +suspend fun TargetNPCContext.barCrawl() = barCrawlDrink( start = { npc("Ah, you've come to the best stop on your list! I'll give you my famous Fire Toad Blast! It'll cost you 10 coins.") }, effects = { player.damage(10) } ) \ No newline at end of file diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/Aubury.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/Aubury.kts index 4a3ac52ca6..1db1a54cf1 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/Aubury.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/Aubury.kts @@ -3,6 +3,7 @@ package world.gregs.voidps.world.map.varrock import world.gregs.voidps.engine.entity.character.CharacterContext import world.gregs.voidps.engine.entity.character.npc.NPC import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.inv.add import world.gregs.voidps.engine.inv.inventory import world.gregs.voidps.engine.inv.remove @@ -76,7 +77,7 @@ suspend fun PlayerChoice.packageForYou(): Unit = option( } } -suspend fun CharacterContext.researchPackage() { +suspend fun CharacterContext.researchPackage() { item("research_package_rune_mysteries", 600, "Aubury goes through the package of research notes.") npc("This... this is incredible.") npc("My gratitude to you adventurer for bringing me these research notes. Thanks to you, I think we finally have it.") @@ -93,7 +94,7 @@ suspend fun CharacterContext.researchPackage() { item("research_notes_rune_mysteries", 600, "Aubury hands you some research notes.") } -suspend fun CharacterContext.checkNotes() { +suspend fun CharacterContext.checkNotes() { npc("Hello. Did you take those notes back to Sedridor?") if (player.inventory.contains("research_notes_rune_mysteries")) { player("I'm still working on it.") diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/Baraek.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/Baraek.kts index eb7c0db5fb..0b241c57b4 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/Baraek.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/Baraek.kts @@ -2,6 +2,7 @@ package world.gregs.voidps.world.map.varrock import world.gregs.voidps.engine.entity.character.CharacterContext import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.inv.add import world.gregs.voidps.engine.inv.holdsItem import world.gregs.voidps.engine.inv.inventory @@ -38,7 +39,7 @@ npcOperate("Talk-to", "baraek") { } -suspend fun CharacterContext.sellFur() { +suspend fun CharacterContext.sellFur() { npc("Yeah, sure. They're 20 gold coins each.") choice { option("Yeah, OK, here you go.") { @@ -71,7 +72,7 @@ suspend fun CharacterContext.sellFur() { } } -suspend fun CharacterContext.buyFur() { +suspend fun CharacterContext.buyFur() { npc("Let's have a look at it.") item("bear_fur", 645, "You hand Baraek your fur to look at.") //wait 4sec and cant move diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/BartenderBlueMoonInn.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/BartenderBlueMoonInn.kts index 12e77c82b4..f31dbeda83 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/BartenderBlueMoonInn.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/BartenderBlueMoonInn.kts @@ -6,6 +6,7 @@ import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.entity.character.forceChat import world.gregs.voidps.engine.entity.character.mode.interact.TargetNPCContext import world.gregs.voidps.engine.entity.character.npc.npcApproach +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.character.player.chat.noInterest import world.gregs.voidps.engine.entity.character.player.skill.Skill import world.gregs.voidps.engine.suspend.approachRange @@ -65,7 +66,7 @@ itemOnNPCApproach("barcrawl_card", "bartender_blue_moon_inn") { barCrawl() } -suspend fun TargetNPCContext.barCrawl() = barCrawlDrink( +suspend fun TargetNPCContext.barCrawl() = barCrawlDrink( start = { npc("Oh no not another of you guys. These barbarian barcrawls cause too much damage to my bar.") npc("You're going to have to pay 50 gold for the Uncle Humphrey's Gutrot.") diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/BartenderJollyBoarInn.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/BartenderJollyBoarInn.kts index 7d44539e9b..901cc8b3e5 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/BartenderJollyBoarInn.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/BartenderJollyBoarInn.kts @@ -4,6 +4,7 @@ import world.gregs.voidps.engine.client.message import world.gregs.voidps.engine.client.ui.interact.itemOnNPCOperate import world.gregs.voidps.engine.entity.character.mode.interact.TargetNPCContext import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.character.player.chat.noInterest import world.gregs.voidps.engine.entity.character.player.skill.Skill import world.gregs.voidps.world.interact.dialogue.Drunk @@ -51,7 +52,7 @@ itemOnNPCOperate("barcrawl_card", "bartender_jolly_boar_inn") { barCrawl() } -suspend fun TargetNPCContext.barCrawl() = barCrawlDrink( +suspend fun TargetNPCContext.barCrawl() = barCrawlDrink( effects = { player.levels.drain(Skill.Attack, 6) player.levels.drain(Skill.Defence, 6) diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/Delrith.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/Delrith.kts index 1b3b422e68..24c58fdab5 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/Delrith.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/Delrith.kts @@ -69,13 +69,13 @@ enterArea("demon_slayer_stone_circle") { } } -fun CharacterContext.setCutsceneEnd(instance: Region) { +fun CharacterContext.setCutsceneEnd(instance: Region) { player.queue("demon_slayer_delrith_cutscene_end", 1, LogoutBehaviour.Accelerate) { endCutscene(instance, defaultTile) } } -fun CharacterContext.endCutscene(instance: Region, tile: Tile? = null) { +fun CharacterContext.endCutscene(instance: Region, tile: Tile? = null) { val offset: Delta = player["demon_slayer_offset"] ?: return player.tele(tile ?: player.tile.minus(offset)) stopCutscene(instance) @@ -114,7 +114,7 @@ fun destroyInstance(player: Player) { } } -suspend fun CharacterContext.cutscene() { +suspend fun CharacterContext.cutscene() { val region = Region(12852) val instance = startCutscene(region) val offset = instance.offset(region) @@ -289,7 +289,7 @@ npcLevelChange("delrith", Skill.Constitution) { npc -> npc.mode = PauseMode } -fun CharacterContext.questComplete() { +fun CharacterContext.questComplete() { player.setAnimation("silverlight_showoff") player.setGraphic("silverlight_sparkle") player.playSound("equip_silverlight") diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/GypsyAris.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/GypsyAris.kts index 78c659ad52..1b6c5095da 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/GypsyAris.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/GypsyAris.kts @@ -14,6 +14,7 @@ import world.gregs.voidps.engine.entity.character.move.tele import world.gregs.voidps.engine.entity.character.move.walkTo import world.gregs.voidps.engine.entity.character.npc.NPCOption import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.character.player.combatLevel import world.gregs.voidps.engine.entity.character.setAnimation import world.gregs.voidps.engine.entity.character.setGraphic @@ -75,7 +76,7 @@ npcOperate("Talk-to", "gypsy_aris") { } } -suspend fun NPCOption.whatToDo() { +suspend fun CharacterContext.whatToDo() { choice { cityDestroyer { wallyQuestions() @@ -85,7 +86,7 @@ suspend fun NPCOption.whatToDo() { } } -suspend fun CharacterContext.howToDo() { +suspend fun CharacterContext.howToDo() { choice { cityDestroyer { wallyQuestions() @@ -100,7 +101,7 @@ suspend fun PlayerChoice.howWallyWon(): Unit = option("So, how did Wally k cutscene() } -suspend fun CharacterContext.finalQuestions() { +suspend fun CharacterContext.finalQuestions() { choice { cityDestroyer { otherQuestions() @@ -115,7 +116,7 @@ suspend fun CharacterContext.finalQuestions() { } } -suspend fun CharacterContext.otherQuestions() { +suspend fun CharacterContext.otherQuestions() { choice { whereIsHe() notVeryHeroicName() @@ -131,7 +132,7 @@ suspend fun CharacterContext.otherQuestions() { } } -suspend fun PlayerChoice.cityDestroyer(end: suspend CharacterContext.() -> Unit): Unit = option("How am I meant to fight a demon who can destroy cities?") { +suspend fun PlayerChoice.cityDestroyer(end: suspend CharacterContext.() -> Unit): Unit = option("How am I meant to fight a demon who can destroy cities?") { npc("If you face Delrith while he is still weak from being summoned, and use the correct weapon, you will not find the task too arduous.") npc("Do not fear. If you follow the path of the great hero Wally, then you are sure to defeat the demon.") end.invoke(this) @@ -150,7 +151,7 @@ suspend fun PlayerChoice.notVeryHeroicName(): Unit = option("Wally doesn' howToDo() } -suspend fun CharacterContext.incantation() { +suspend fun CharacterContext.incantation() { player("What is the magical incantation?") npc("Oh yes, let me think a second.") npc("Aright, I think I've got it now, it goes... ${getWord(player, 1)}... ${getWord(player, 2)}... ${getWord(player, 3)}.,. ${getWord(player, 4)}.,. ${getWord(player, 5)}. Have you got that?") @@ -173,7 +174,7 @@ npcTimerTick("demon_slayer_crystal_ball") { npc -> areaSound("demon_slayer_crystal_ball_anim", npc.tile) } -suspend fun ChoiceBuilder.hereYouGo(): Unit = option("Okay, here you go.") { +suspend fun ChoiceBuilder>.hereYouGo(): Unit = option("Okay, here you go.") { player.inventory.remove("coins", 1) npc("Come closer and listen carefully to what the future holds, as I peer into the swirling mists o the crystal ball.") player.playSound("demon_slayer_crystal_ball_start") @@ -196,7 +197,7 @@ suspend fun ChoiceBuilder.hereYouGo(): Unit = option("Okay, her whatToDo() } -suspend fun ChoiceBuilder.whoYouCallingYoung(): Unit = option("Who are you called 'young one'?") { +suspend fun ChoiceBuilder>.whoYouCallingYoung(): Unit = option("Who are you called 'young one'?") { npc("You have been on this world a relatively short time. At least compared to me.") npc("So, do you want your fortune told or not?") choice { @@ -209,7 +210,7 @@ suspend fun ChoiceBuilder.whoYouCallingYoung(): Unit = option.cutscene() { val region = Region(12852) player.open("fade_out") statement("", clickToContinue = false) @@ -282,13 +283,13 @@ suspend fun CharacterContext.cutscene() { delrithWillCome() } -fun CharacterContext.setCutsceneEnd(instance: Region) { +fun CharacterContext.setCutsceneEnd(instance: Region) { player.queue("demon_slayer_wally_cutscene_end", 1, LogoutBehaviour.Accelerate) { endCutscene(instance) } } -suspend fun CharacterContext.endCutscene(instance: Region) { +suspend fun CharacterContext.endCutscene(instance: Region) { player.open("fade_out") delay(3) player.tele(3203, 3424) @@ -298,7 +299,7 @@ suspend fun CharacterContext.endCutscene(instance: Region) { player.clearTransform() } -suspend fun ChoiceBuilder.withSilver(): Unit = option("With silver?") { +suspend fun ChoiceBuilder>.withSilver(): Unit = option("With silver?") { npc("Oh, sorry, I forgot. With gold, I mean. They haven't used silver coins since before you were born! So, do you want your fortune told?") choice { hereYouGo() @@ -306,7 +307,7 @@ suspend fun ChoiceBuilder.withSilver(): Unit = option("With sil } } -suspend fun CharacterContext.delrithWillCome() { +suspend fun CharacterContext.delrithWillCome() { npc("Delrith will come forth from the stone circle again.") npc("I would imagine an evil sorcerer is already beginning the rituals to summon Delrith as we speak.") choice { @@ -325,13 +326,13 @@ suspend fun CharacterContext.delrithWillCome() { } } -suspend fun CharacterContext.whereSilverlight() { +suspend fun CharacterContext.whereSilverlight() { player("Where can I find Silverlight?") npc("Silverlight has been passed down by Wally's descendants. I believe it is currently in the care of one of the king's knights called Sir Prysin.") npc("He shouldn't be too hard to find. He lives in the royal palace in this city. Tell him Gypsy Aris sent you.") } -suspend fun NPCOption.howGoesQuest() { +suspend fun NPCOption.howGoesQuest() { npc("Greetings. How goes thy quest?") player("I'm still working on it.") npc("Well if you need any advice I'm always here, young one.") @@ -378,7 +379,7 @@ suspend fun PlayerChoice.stopCallingMeThat(): Unit = option("Stop calling } } -suspend fun CharacterContext.wallyQuestions() { +suspend fun CharacterContext.wallyQuestions() { choice { whereIsHe() notVeryHeroicName() diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/Tarquin.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/Tarquin.kts index ffe92f01c3..c615e39049 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/Tarquin.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/Tarquin.kts @@ -2,6 +2,7 @@ package world.gregs.voidps.world.map.varrock import world.gregs.voidps.engine.entity.character.CharacterContext import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.character.player.skill.Skill import world.gregs.voidps.world.interact.dialogue.* import world.gregs.voidps.world.interact.dialogue.type.choice @@ -39,7 +40,7 @@ npcOperate("Talk-To", "tarquin") { } } -suspend fun CharacterContext.canoeing() { +suspend fun CharacterContext.canoeing() { if (minimumCanoeLevel()) { return } diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/Thessalia.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/Thessalia.kts index 0930aa9b85..4a6ef27b43 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/Thessalia.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/Thessalia.kts @@ -60,7 +60,7 @@ fun PlayerChoice.openShop(): Unit = option("I'd just like to buy some clothes.") player.openShop("thessalias_fine_clothes") } -suspend fun CharacterContext.startMakeover() { +suspend fun CharacterContext.startMakeover() { player.closeDialogue() if (!player.equipment.isEmpty()) { npc("You're not able to try on my clothes with all that armour. Take it off and then speak to me again.") diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/abyss/DarkMage.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/abyss/DarkMage.kts index 461bc531d4..6a96b1ec46 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/abyss/DarkMage.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/abyss/DarkMage.kts @@ -2,6 +2,7 @@ package world.gregs.voidps.world.map.varrock.abyss import world.gregs.voidps.engine.entity.character.npc.NPCOption import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.inv.add import world.gregs.voidps.engine.inv.inventory import world.gregs.voidps.engine.inv.transact.operation.ReplaceItem.replace @@ -38,7 +39,7 @@ npcOperate("Repair-pouches", "dark_mage") { } } -fun ChoiceBuilder.whyNot() { +fun ChoiceBuilder>.whyNot() { option("Why not?") { npc("Well, if my concentration is broken while keeping this rift open, the results won't be pretty.") player("In what way?") @@ -54,7 +55,7 @@ fun ChoiceBuilder.whyNot() { } } -fun ChoiceBuilder.whyAreYouHere() { +fun ChoiceBuilder>.whyAreYouHere() { option("What are you doing here?") { npc("Do you mean what am I doing here in the Abyss? Or are you asking me what I consider my ultimate role to be in this voyage that we call life?") player("Err... The first one.") @@ -69,7 +70,7 @@ fun ChoiceBuilder.whyAreYouHere() { } } -fun ChoiceBuilder.needHelp() { +fun ChoiceBuilder>.needHelp() { option("I need your help with something.") { npc("What? Oh... very well. What did you want?") choice { @@ -101,13 +102,13 @@ fun ChoiceBuilder.needHelp() { } } -fun ChoiceBuilder.illGo() { +fun ChoiceBuilder>.illGo() { option("Sorry, I'll go.") { npc("Good. I'm attempting to subdue the elemental mechanisms of the universe to my will. Inane chatter from random idiots is not helping me achieve this!") } } -fun ChoiceBuilder.askForPouch() { +fun ChoiceBuilder>.askForPouch() { option("Can I have a new essence pouch?") { if (player.ownsItem("small_pouch")) { npc("You already have a Pouch. Are you aware of the dimensional turmoil you can cause by using too many pouches at the same time?") diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/abyss/MageOfZamorak.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/abyss/MageOfZamorak.kts index f675708d35..96f4ac9141 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/abyss/MageOfZamorak.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/abyss/MageOfZamorak.kts @@ -135,7 +135,7 @@ npcOperate("Talk-to", "mage_of_zamorak_varrock") { } } -fun ChoiceBuilder.aboutGroup() { +fun ChoiceBuilder>.aboutGroup() { option("Can you tell me more about your group?") { npc("I suppose you have proven yourself trustworthy. We are a group of mages in service to Zamorak. Our group is called the Zamorak Magical Institute, or Z.M.I. for short.") npc("Few actually know of us. Saradominist groups like the Order of Wizards hold sway over these lands, so we are forced to work in the shadows. However, make no mistake, our power far exceeds theirs.") @@ -158,7 +158,7 @@ fun ChoiceBuilder.aboutGroup() { } } -fun ChoiceBuilder.aboutAbyss() { +fun ChoiceBuilder>.aboutAbyss() { option("Can you tell me more about the Abyss?") { npc("It is a hard place to describe. We often refer to it as another plane, but that isn't quite accurate. If anything, it is more like a plane that sits between all other planes.") player("Right... And what does it have to do with runecrafting?") @@ -182,7 +182,7 @@ fun ChoiceBuilder.aboutAbyss() { } } -suspend fun NPCOption.takenOrb() { +suspend fun NPCOption.takenOrb() { npc("You have done well. Now, time for us to uphold our end of the bargin.") npc("The reason we are able to craft so many runes is because we do not visit the runic altars in the traditional way. Instead, we have found a way to teleport to them directly.") player("How?") @@ -204,7 +204,7 @@ suspend fun NPCOption.takenOrb() { player.exp(Skill.Runecrafting, 1000.0) } -fun ChoiceBuilder.whereRunes() { +fun ChoiceBuilder>.whereRunes() { option("Where do you get your runes from?") { npc("Well we craft them of course.") player("We?") @@ -232,7 +232,7 @@ fun ChoiceBuilder.whereRunes() { } } -suspend fun NPCOption.accessLostMine() { +suspend fun NPCOption.accessLostMine() { npc("Until recently, our runecrafting secrets allowed us to produce runes at a far superior rate compared to the inept Order of Wizards, but something has changed.") npc("From what we can gather, they've somehow rediscovered how to access the lost Rune Essence Mine.") player("Ah, well I know all about that. I was actually the one to help them do it!") @@ -262,7 +262,7 @@ suspend fun NPCOption.accessLostMine() { } } -suspend fun NPCOption.deal() { +suspend fun NPCOption.deal() { npc("Alright, if you help us access the Rune Essence Mine, we will share our runecrafting secrets with you in return.") player["enter_abyss_offer"] = true offer() @@ -296,7 +296,7 @@ fun teleport(player: Player, target: NPC) { } } -suspend fun NPCOption.offer() { +suspend fun NPCOption.offer() { choice { option("Deal.") { npc("Good. Now, all I need from you is the spell that will teleport me to the Rune Essence Mine.") diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/palace/CaptainRovin.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/palace/CaptainRovin.kts index 6f47783b88..3b2131fd2a 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/palace/CaptainRovin.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/palace/CaptainRovin.kts @@ -2,6 +2,7 @@ package world.gregs.voidps.world.map.varrock.palace import world.gregs.voidps.engine.entity.character.CharacterContext import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.inv.add import world.gregs.voidps.engine.inv.holdsItem import world.gregs.voidps.engine.inv.inventory @@ -76,7 +77,7 @@ suspend fun PlayerChoice.aleDelivery(): Unit = option("The castle has j npc("Now that is important. However I'm the wrong person to speak to about it. Go talk to the kitchen staff.") } -suspend fun CharacterContext.haveYouNotKilledIt() { +suspend fun CharacterContext.haveYouNotKilledIt() { npc("Yes, you said before, haven't you killed it yet?") player("I'm going to use the powerful sword Silverlight, which I believe you have one of the keys for?") if (player.holdsItem("silverlight_key_captain_rovin")) { @@ -86,7 +87,7 @@ suspend fun CharacterContext.haveYouNotKilledIt() { } } -suspend fun CharacterContext.isItPowerful() { +suspend fun CharacterContext.isItPowerful() { npc("Is it a powerful demon?") choice { notReallyPowerful() diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/palace/SirPrysin.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/palace/SirPrysin.kts index dfe86a3be0..f6aed1d5f0 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/palace/SirPrysin.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/palace/SirPrysin.kts @@ -5,6 +5,7 @@ import world.gregs.voidps.engine.entity.character.mode.PauseMode import world.gregs.voidps.engine.entity.character.move.tele import world.gregs.voidps.engine.entity.character.npc.NPCOption import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.obj.GameObjects import world.gregs.voidps.engine.inject import world.gregs.voidps.engine.inv.add @@ -76,7 +77,7 @@ suspend fun PlayerChoice.arisWantsToTalk(): Unit = option( } } -suspend fun CharacterContext.findSilverlight() { +suspend fun CharacterContext.findSilverlight() { player("I need to find Silverlight.") npc("What do you need to find that for?") player("I need it to fight Delrith.") @@ -95,7 +96,7 @@ suspend fun CharacterContext.findSilverlight() { } } -suspend fun CharacterContext.problemIs() { +suspend fun CharacterContext.problemIs() { npc("The problem is getting Silverlight.") player("You mean you don't have it?") npc("Oh I do have it, but it is so powerful that the king made me put it in a special box which needs three different keys to open it. That way it won't fall into the wrong hands.") @@ -112,7 +113,7 @@ suspend fun CharacterContext.problemIs() { } } -suspend fun CharacterContext.theKeys() { +suspend fun CharacterContext.theKeys() { npc("I kept one of the keys. I gave the other two to other people for safe keeping.") npc("One I gave to Rovin, the captain of the palace guard.") npc("I gave the other to the wizard Traiborn.") @@ -144,7 +145,7 @@ suspend fun PlayerChoice.wheresCaptainRovin(): Unit = option("Where can I find C } } -suspend fun NPCOption.keyProgressCheck() { +suspend fun NPCOption.keyProgressCheck() { npc("So how are you doing with getting the keys?") val rovin = player.holdsItem("silverlight_key_captain_rovin") val prysin = player.holdsItem("silverlight_key_sir_prysin") @@ -219,7 +220,7 @@ suspend fun PlayerChoice.stillLooking(): Unit = option("I'm still looking.") { val objects: GameObjects by inject() val cupboardTile = Tile(3204, 3469) -suspend fun NPCOption.giveSilverlight() { +suspend fun NPCOption.giveSilverlight() { player("I've got all three keys!") npc("Excellent! Now I can give you Silverlight.") player.inventory.remove("silverlight_key_wizard_traiborn", "silverlight_key_captain_rovin", "silverlight_key_sir_prysin") diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/wilderness/WildernessLevers.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/wilderness/WildernessLevers.kts index 284ce29636..bdfba34294 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/wilderness/WildernessLevers.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/wilderness/WildernessLevers.kts @@ -8,6 +8,7 @@ import world.gregs.voidps.engine.entity.character.player.chat.ChatType import world.gregs.voidps.engine.entity.character.setAnimation import world.gregs.voidps.engine.entity.character.setGraphic import world.gregs.voidps.engine.entity.obj.objectOperate +import world.gregs.voidps.engine.suspend.InfiniteSuspension.cancel import world.gregs.voidps.engine.suspend.delay import world.gregs.voidps.world.interact.dialogue.type.choice import world.gregs.voidps.world.interact.dialogue.type.statement @@ -36,7 +37,7 @@ objectOperate("Pull", "lever_*", override = false) { pullLever(player) } -suspend fun CharacterContext.pullLever(player: Player) { +suspend fun CharacterContext.pullLever(player: Player) { player.message("You pull the lever...", ChatType.Filter) player.setAnimation("pull_lever") player.start("movement_delay", 3) diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/wizards_tower/Sedridor.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/wizards_tower/Sedridor.kts index 3bcaabd84f..2c3378c821 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/wizards_tower/Sedridor.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/wizards_tower/Sedridor.kts @@ -4,6 +4,7 @@ import world.gregs.voidps.engine.client.message import world.gregs.voidps.engine.entity.character.CharacterContext import world.gregs.voidps.engine.entity.character.npc.NPCOption import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.character.player.name import world.gregs.voidps.engine.entity.item.Item import world.gregs.voidps.engine.inv.add @@ -42,7 +43,7 @@ npcOperate("Teleport", "sedridor") { EssenceMine.teleport(target, player) } -suspend fun CharacterContext.started() { +suspend fun CharacterContext.started() { npc("Welcome adventurer, to the world renowned Wizards' Tower, home to the Order of Wizards. We are the oldest and most prestigious group of wizards around. Now, how may I help you?") player("Are you Sedridor?") npc("Sedridor? What is it you want with him?") @@ -71,7 +72,7 @@ suspend fun CharacterContext.started() { } } -suspend fun CharacterContext.okHere() { +suspend fun CharacterContext.okHere() { player("Okay, here you are.") if (player.inventory.contains("air_talisman")) { player["rune_mysteries"] = "talisman_delivered" @@ -120,7 +121,7 @@ suspend fun CharacterContext.okHere() { } } -suspend fun CharacterContext.discovery() { +suspend fun CharacterContext.discovery() { npc("It is critical I share this discovery with my associate, Aubury, as soon as possible. He's not much of a wizard, but he's an expert on runecrafting, and his insight will be essential.") npc("Would you be willing to visit him for me? I would go myself, but I wish to study this talisman some more.") choice { @@ -129,7 +130,7 @@ suspend fun CharacterContext.discovery() { } } -suspend fun CharacterContext.visitAubury() { +suspend fun CharacterContext.visitAubury() { npc("Hello again, adventurer. You have already done so much, but I would really appreciate it if you were to visit my associate, Aubury. Would you be willing to?") choice { yesCertainly() @@ -137,7 +138,7 @@ suspend fun CharacterContext.visitAubury() { } } -suspend fun CharacterContext.checkPackageDelivered() { +suspend fun CharacterContext.checkPackageDelivered() { npc("Hello again, adventurer. Did you take that package to Aubury?") if (player.ownsItem("research_package_rune_mysteries")) { player("Not yet.") @@ -158,7 +159,7 @@ suspend fun CharacterContext.checkPackageDelivered() { } } -suspend fun CharacterContext.checkResearchDelivered() { +suspend fun CharacterContext.checkResearchDelivered() { npc("Ah, ${player.name}. How goes your quest? Have you delivered my research to Aubury yet?") player("Yes, I have. He gave me some notes to give to you.") npc("Wonderful! Let's have a look then.") @@ -201,7 +202,7 @@ suspend fun PlayerChoice.yesCertainly(): Unit = option("Yes, certainly. npc("Best of luck, ${player.name}.") } -suspend fun NPCOption.completed() { +suspend fun NPCOption.completed() { player("Hello there.") npc("Hello again, ${player.name}. What can I do for you?") choice { @@ -214,12 +215,12 @@ suspend fun NPCOption.completed() { } } -fun ChoiceBuilder.teleportEssenceMine(): Unit = option("Can you teleport me to the Rune Essence Mine?") { +fun ChoiceBuilder>.teleportEssenceMine(): Unit = option("Can you teleport me to the Rune Essence Mine?") { player["what_is_this_place_task"] = true EssenceMine.teleport(target, player) } -suspend fun ChoiceBuilder.whoElseKnows(): Unit = option("Who else knows the teleport to the Rune Essence Mine?") { +suspend fun ChoiceBuilder>.whoElseKnows(): Unit = option("Who else knows the teleport to the Rune Essence Mine?") { npc("Apart from myself, there's also Aubury in Varrock, Wizard Cromperty in East Ardougne, Brimstail in the Tree Gnome Stronghold and Wizard Distentor in Yanille's Wizards' Guild.") player["enter_abyss_knows_mages"] = true choice { @@ -229,7 +230,7 @@ suspend fun ChoiceBuilder.whoElseKnows(): Unit = option("Who el } } -suspend fun ChoiceBuilder.oldWizardsTower(): Unit = option("Could you tell me about the old Wizards' Tower?") { +suspend fun ChoiceBuilder>.oldWizardsTower(): Unit = option("Could you tell me about the old Wizards' Tower?") { npc("Of course. The first Wizards' Tower was built at the same time the Order of Wizards was founded. It was at the dawn of the Fifth Age, when the secrets of runecrafting were rediscovered.") npc("For years, the tower was a hub of magical research. Wizards of all races and religions were welcomed into our order.") npc("Alas, that openness is what ultimately led to disaster. The wizards who served Zamorak, the evil god of chaos, tried to claim our magical discoveries in his name.") @@ -248,7 +249,7 @@ suspend fun PlayerChoice.thanksForInformation(): Unit = option("Thanks fo npc("My pleasure.") } -fun CharacterContext.questComplete() { +fun CharacterContext.questComplete() { player["rune_mysteries"] = "completed" player.playJingle("quest_complete_1") if (player.inventory.isFull()) { diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/wizards_tower/Traiborn.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/wizards_tower/Traiborn.kts index 1414a2ec95..f65e4b743f 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/wizards_tower/Traiborn.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/wizards_tower/Traiborn.kts @@ -111,7 +111,7 @@ suspend fun PlayerChoice.needAKey(): Unit = option("I need to get a key gi } } -suspend fun CharacterContext.betterBeOffChoice() { +suspend fun CharacterContext.betterBeOffChoice() { choice { betterBeOff() option("They're right, you are mad.") { @@ -131,7 +131,7 @@ suspend fun PlayerChoice.kingsKnight(): Unit = option("He's one of the Kin } } -suspend fun CharacterContext.spinachRoll() { +suspend fun CharacterContext.spinachRoll() { player.inventory.add("spinach_roll") if (player.inventory.transaction.error != TransactionError.None) { floorItems.add(player.tile, "spinach_roll") @@ -182,7 +182,7 @@ suspend fun PlayerChoice.justTellMe(): Unit = option("Just tell me if you } } -suspend fun TargetNPCContext.startSpell() { +suspend fun TargetNPCContext.startSpell() { npc("Hurrah! That's all 25 sets of bones.") target.setAnimation("traiborn_bone_spell") target.setGraphic("traiborn_bone_spell") @@ -207,12 +207,12 @@ suspend fun TargetNPCContext.startSpell() { npc("Not a problem for a friend of Sir What's-his-face.") } -suspend fun CharacterContext.somewhereToBe() { +suspend fun CharacterContext.somewhereToBe() { npc("Don't you have somewhere to be, young thingummywut? You still have that key you asked me for.") player("You're right. I've got a demon to slay.") } -suspend fun NPCOption.bonesCheck() { +suspend fun NPCOption.bonesCheck() { when (player.bonesRequired) { 0 -> lostKey() -1 -> choice { @@ -235,13 +235,13 @@ suspend fun NPCOption.bonesCheck() { } } -suspend fun CharacterContext.lostKey() { +suspend fun CharacterContext.lostKey() { player("I've lost the key you gave to me.") npc("Yes I know, it was returned to me. If you want it back you're going to have to collect another 25 sets of bones.") player.bonesRequired = 25 } -suspend fun TargetNPCContext.giveBones() { +suspend fun TargetNPCContext.giveBones() { val removed = player.inventory.removeToLimit("bones", player.bonesRequired) statement("You give Traiborn $removed ${"set".plural(removed)} of bones.") player.bonesRequired -= removed diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/yanille/BartenderDragonInn.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/yanille/BartenderDragonInn.kts index f5db52f585..0a312b4460 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/yanille/BartenderDragonInn.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/yanille/BartenderDragonInn.kts @@ -4,6 +4,7 @@ import world.gregs.voidps.engine.client.message import world.gregs.voidps.engine.client.ui.interact.itemOnNPCOperate import world.gregs.voidps.engine.entity.character.mode.interact.TargetNPCContext import world.gregs.voidps.engine.entity.character.npc.npcOperate +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.entity.character.player.chat.noInterest import world.gregs.voidps.engine.entity.character.player.skill.Skill import world.gregs.voidps.world.activity.quest.mini.barCrawlDrink @@ -58,7 +59,7 @@ itemOnNPCOperate("barcrawl_card", "bartender_dragon_inn") { barCrawl() } -suspend fun TargetNPCContext.barCrawl() = barCrawlDrink( +suspend fun TargetNPCContext.barCrawl() = barCrawlDrink( effects = { player.levels.drain(Skill.Attack, 6) player.levels.drain(Skill.Defence, 6) diff --git a/game/src/test/kotlin/world/gregs/voidps/world/interact/dialogue/ChoiceTest.kt b/game/src/test/kotlin/world/gregs/voidps/world/interact/dialogue/ChoiceTest.kt index adac892769..c4f918c369 100644 --- a/game/src/test/kotlin/world/gregs/voidps/world/interact/dialogue/ChoiceTest.kt +++ b/game/src/test/kotlin/world/gregs/voidps/world/interact/dialogue/ChoiceTest.kt @@ -8,6 +8,7 @@ import org.junit.jupiter.api.TestFactory import org.junit.jupiter.api.assertThrows import world.gregs.voidps.engine.client.ui.open import world.gregs.voidps.engine.entity.character.CharacterContext +import world.gregs.voidps.engine.entity.character.player.Player import world.gregs.voidps.engine.suspend.dialogue.IntSuspension import world.gregs.voidps.world.interact.dialogue.type.choice import world.gregs.voidps.world.interact.dialogue.type.player @@ -182,7 +183,7 @@ internal class ChoiceTest : DialogueTest() { } } - private suspend fun CharacterContext.choice(text: String, title: String? = null): Int { + private suspend fun CharacterContext.choice(text: String, title: String? = null): Int { val lines = text.trimIndent().lines() return choice(lines, title) } diff --git a/game/src/test/kotlin/world/gregs/voidps/world/interact/dialogue/DialogueTest.kt b/game/src/test/kotlin/world/gregs/voidps/world/interact/dialogue/DialogueTest.kt index db40a46724..d1048a037f 100644 --- a/game/src/test/kotlin/world/gregs/voidps/world/interact/dialogue/DialogueTest.kt +++ b/game/src/test/kotlin/world/gregs/voidps/world/interact/dialogue/DialogueTest.kt @@ -31,19 +31,19 @@ abstract class DialogueTest : KoinMock() { lateinit var interfaces: Interfaces lateinit var player: Player - lateinit var context: CharacterContext + lateinit var context: CharacterContext lateinit var continuation: Continuation lateinit var interfaceDefinitions: InterfaceDefinitions lateinit var fontDefinitions: FontDefinitions lateinit var clientScriptDefinitions: ClientScriptDefinitions - fun dialogueBlocking(block: suspend CharacterContext.() -> Unit) { + fun dialogueBlocking(block: suspend CharacterContext.() -> Unit) { runTest { block.invoke(context) } } - fun dialogue(block: suspend CharacterContext.() -> Unit) { + fun dialogue(block: suspend CharacterContext.() -> Unit) { GlobalScope.launch(Dispatchers.Unconfined) { block.invoke(context) } @@ -65,8 +65,8 @@ abstract class DialogueTest : KoinMock() { override fun resumeWith(result: Result) { } } - context = spyk(object : CharacterContext { - override val character: Character = this@DialogueTest.player + context = spyk(object : CharacterContext { + override val character = this@DialogueTest.player override var onCancel: (() -> Unit)? = null }) every { clientScriptDefinitions.get("string_entry") } returns ClientScriptDefinition(id = 109) diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/dialogue/DialogueConverter.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/dialogue/DialogueConverter.kt index 6ad31ffff7..f0ab87e90a 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/dialogue/DialogueConverter.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/dialogue/DialogueConverter.kt @@ -214,7 +214,7 @@ object DialogueConverter { if (parent != previousParent) { val function = branchToFunction[parent] if (function != null) { - builder.append("suspend fun CharacterContext.").append(function).append("() {\n") + builder.append("suspend fun CharacterContext.").append(function).append("() {\n") } } if (front.isNPCDialogue) { @@ -249,7 +249,7 @@ object DialogueConverter { } else { val function = branchToFunction[parent] if (function != null) { - builder.append("suspend fun CharacterContext.").append(function).append("() {\n") + builder.append("suspend fun CharacterContext.").append(function).append("() {\n") } return } diff --git a/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/dialogue/DialogueParsing.kt b/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/dialogue/DialogueParsing.kt index 5a3e40c3dd..299136f984 100644 --- a/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/dialogue/DialogueParsing.kt +++ b/tools/src/main/kotlin/world/gregs/voidps/tools/wiki/dialogue/DialogueParsing.kt @@ -68,7 +68,7 @@ object DialogueParsing { if (npcName.isBlank() && dialogue.type == "DIALOGUE_NPC") { npcName = dialogue.name } - println("\nsuspend fun CharacterContext.${dialogue.methodName()} {") + println("\nsuspend fun CharacterContext.${dialogue.methodName()} {") val options = print(content, id, name = npcName, skip = skip) println("}") if (options != null && printed.add(options.id)) { @@ -110,7 +110,7 @@ object DialogueParsing { } private fun printOptions(content: Map, dialogue: Dialogue, printIds: Boolean, name: String) { - println("\nsuspend fun CharacterContext.${dialogue.methodName()} {") + println("\nsuspend fun CharacterContext.${dialogue.methodName()} {") println(" choice(\"${dialogue.options.first()}\") {${if (printIds) " // ${dialogue.id}" else ""}") for (option in dialogue.options.drop(1)) { val match =