Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion data/area/karamja/brimhaven/brimhaven.objs.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,8 @@ examine = "Handy for boarding the ship."

[gangplank_brimhaven_exit]
id = 2088
examine = "Handy for boarding the ship."
examine = "Handy for boarding the ship."

[travel_cart_brimhaven]
id = 2230
examine = "A sturdy cart for travelling in."
2 changes: 2 additions & 0 deletions data/area/karamja/shilo_village/shilo_village.npcs.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ examine = "Yanni Salika; he buys and sells antiques."

[obli_shilo_village]
id = 516
shop = "oblis_general_store"
examine = "An intelligent-looking shop owner."

[fernahei_shilo_village]
id = 517
shop = "fernaheis_fishing_hut"
examine = "This is Fernahei; he owns the local fishing tackle shop."

[undead_one_shilo_village_3]
Expand Down
4 changes: 4 additions & 0 deletions data/area/karamja/shilo_village/shilo_village.objs.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ examine = "A rocky outcrop from the running water."
[shilo_river_stepping_stone]
id = 10536
examine = "Handy for crossing rivers."

[travel_cart_shilo_village]
id = 2265
examine = "A sturdy cart for travelling in."
45 changes: 45 additions & 0 deletions game/src/main/kotlin/content/area/karamja/brimhaven/Hajedy.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package content.area.karamja.brimhaven

import content.area.karamja.shilo_village.Vigroy
import content.entity.player.dialogue.Neutral
import content.entity.player.dialogue.type.choice
import content.entity.player.dialogue.type.npc
import world.gregs.voidps.engine.Script
import world.gregs.voidps.engine.client.ui.dialogue.talkWith
import world.gregs.voidps.engine.entity.character.npc.NPCs
import world.gregs.voidps.engine.entity.character.player.Player
import world.gregs.voidps.type.Tile

class Hajedy : Script {

Check warning on line 13 in game/src/main/kotlin/content/area/karamja/brimhaven/Hajedy.kt

View workflow job for this annotation

GitHub Actions / qodana

Unused symbol

Class "Hajedy" is never used
init {
npcOperate("Talk-to", "hajedy_brimhaven") {
offerCartRide()
}

npcOperate("Pay-fare", "hajedy_brimhaven") {
Vigroy.payFare(this, Tile(2834, 2951))
}

objectOperate("Board", "travel_cart_brimhaven") {
talkWith(NPCs.findBySpawn(Tile(2779, 3211), "hajedy_brimhaven"))
offerCartRide()
}

objectOperate("Pay-fare", "travel_cart_brimhaven") {
talkWith(NPCs.findBySpawn(Tile(2779, 3211), "hajedy_brimhaven"))
Vigroy.payFare(this, Tile(2834, 2951))
}
}

private suspend fun Player.offerCartRide() {
npc<Neutral>("I am offering a cart ride to Shilo Village, if you're interested. It will cost ${Vigroy.CART_FARE} coins. Is that okay?")
choice {
option<Neutral>("Yes please, I'd like to go to Shilo Village.") {
Vigroy.attemptPayment(this, "Shilo Village", Tile(2834, 2951))
}
option<Neutral>("No thanks.") {
npc<Neutral>("Okay, Bwana, let me know if you change your mind.")
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package content.area.karamja.shilo_village

import content.entity.npc.shop.openShop
import content.entity.player.dialogue.Happy
import content.entity.player.dialogue.Neutral
import content.entity.player.dialogue.type.choice
import content.entity.player.dialogue.type.npc
import world.gregs.voidps.engine.Script

class Fernahei : Script {

Check warning on line 10 in game/src/main/kotlin/content/area/karamja/shilo_village/Fernahei.kt

View workflow job for this annotation

GitHub Actions / qodana

Unused symbol

Class "Fernahei" is never used
init {
npcOperate("Talk-to", "fernahei_shilo_village") { (target) ->
npc<Happy>("Welcome to Fernahei's Fishing Shop Bwana! Would you like to see my items?")
choice {
option<Neutral>("Yes please!") {
openShop(target.def["shop"])
}
option<Neutral>("No, but thanks for the offer.") {
npc<Happy>("That's fine and thanks for your interest.")
}
}
}
}
}
24 changes: 24 additions & 0 deletions game/src/main/kotlin/content/area/karamja/shilo_village/Obli.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package content.area.karamja.shilo_village

import content.entity.npc.shop.openShop
import content.entity.player.dialogue.Happy
import content.entity.player.dialogue.Neutral
import content.entity.player.dialogue.type.choice
import content.entity.player.dialogue.type.npc
import world.gregs.voidps.engine.Script

class Obli : Script {

Check warning on line 10 in game/src/main/kotlin/content/area/karamja/shilo_village/Obli.kt

View workflow job for this annotation

GitHub Actions / qodana

Unused symbol

Class "Obli" is never used
init {
npcOperate("Talk-to", "obli_shilo_village") { (target) ->
npc<Happy>("Welcome to Obli's General Store Bwana! Would you like to see my items?")
choice {
option<Neutral>("Yes please!") {
openShop(target.def["shop"])
}
option<Neutral>("No, but thanks for the offer.") {
npc<Happy>("That's fine and thanks for your interest.")
}
}
}
}
}
84 changes: 84 additions & 0 deletions game/src/main/kotlin/content/area/karamja/shilo_village/Vigroy.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package content.area.karamja.shilo_village

import content.entity.player.dialogue.Neutral
import content.entity.player.dialogue.type.choice
import content.entity.player.dialogue.type.npc
import content.entity.player.dialogue.type.statement
import world.gregs.voidps.engine.Script
import world.gregs.voidps.engine.client.message
import world.gregs.voidps.engine.client.ui.dialogue.talkWith
import world.gregs.voidps.engine.client.ui.open
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.chat.ChatType
import world.gregs.voidps.engine.inv.inventory
import world.gregs.voidps.engine.inv.remove
import world.gregs.voidps.type.Tile

class Vigroy : Script {
init {
npcOperate("Talk-to", "vigroy_shilo_village") {
offerCartRide()
}

npcOperate("Pay-fare", "vigroy_shilo_village") {
payFare(this, Tile(2778, 3210))
}

objectOperate("Board", "travel_cart_shilo_village") {
talkWith(NPCs.findBySpawn(Tile(2834, 2954), "vigroy_shilo_village"))
offerCartRide()
}

objectOperate("Pay-fare", "travel_cart_shilo_village") {
talkWith(NPCs.findBySpawn(Tile(2834, 2954), "vigroy_shilo_village"))
payFare(this, Tile(2778, 3210))
}
}

/**
* Talk-to/Board: full dialogue asking whether the player wants to travel.
*/
private suspend fun Player.offerCartRide() {
npc<Neutral>("I am offering a cart ride to Brimhaven, if you're interested. It will cost $CART_FARE coins. Is that okay?")
choice {
option<Neutral>("Yes please, I'd like to go to Brimhaven.") {
attemptPayment(this, "Brimhaven", Tile(2778, 3210))
}
option<Neutral>("No thanks.") {
npc<Neutral>("Okay, Bwana, let me know if you change your mind.")
}
}
}

companion object {

const val CART_FARE = 10

suspend fun payFare(player: Player, tile: Tile) {
if (!player.inventory.remove("coins", CART_FARE)) {
player.npc<Neutral>("Sorry, but it looks as if you don't have enough money. Come and see me when you have enough for the ride.")
return
}
player.open("fade_out")
player.delay(3)
player.tele(tile)
player.open("fade_in")
player.message("You feel tired from the journey, but at least you didn't have to walk all that distance.", ChatType.Filter)
}

suspend fun attemptPayment(player: Player, location: String, tile: Tile) {
if (!player.inventory.remove("coins", CART_FARE)) {
player.npc<Neutral>("Sorry, but it looks as if you don't have enough money. Come and see me when you have enough for the ride.")
return
}
player.statement("You hop into the cart and the driver urges the horses on. You take a taxing journey through the jungle to $location.", clickToContinue = false)
player.open("fade_out")
player.delay(3)
player.tele(tile)
player.open("fade_in")
player.statement("You hop into the cart and the driver urges the horses on. You take a taxing journey through the jungle to $location. You feel tired from the journey, but at least you didn't have to walk all that distance.")
}
}
}
58 changes: 58 additions & 0 deletions game/src/main/kotlin/content/area/karamja/shilo_village/Yohnus.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package content.area.karamja.shilo_village

import content.entity.obj.door.enterDoor
import content.entity.player.dialogue.Happy
import content.entity.player.dialogue.Neutral
import content.entity.player.dialogue.type.choice
import content.entity.player.dialogue.type.npc
import world.gregs.voidps.engine.Script
import world.gregs.voidps.engine.client.ui.dialogue.talkWith
import world.gregs.voidps.engine.entity.character.npc.NPCs
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.inv.transact.operation.RemoveItem.remove

Check warning on line 14 in game/src/main/kotlin/content/area/karamja/shilo_village/Yohnus.kt

View workflow job for this annotation

GitHub Actions / qodana

Unused import directive

Unused import directive
import world.gregs.voidps.type.Tile

class Yohnus : Script {

Check warning on line 17 in game/src/main/kotlin/content/area/karamja/shilo_village/Yohnus.kt

View workflow job for this annotation

GitHub Actions / qodana

Unused symbol

Class "Yohnus" is never used
init {
npcOperate("Talk-to", "yohnus_shilo_village") {
furnace()
}

objectOperate("Open", "blacksmiths_door_closed") { (target) ->
if (tile.y > target.tile.y) {
enterDoor(target)
return@objectOperate
}
if (this["yohnus_paid", false]) {
clear("yohnus_paid")
enterDoor(target)
return@objectOperate
}
talkWith(NPCs.findBySpawn(Tile(2857, 2963), "yohnus_shilo_village"))
furnace()
if (this["yohnus_paid", false]) {
clear("yohnus_paid")
enterDoor(target)
}
}
}
}

private suspend fun Player.furnace() {
npc<Neutral>("Sorry but the blacksmiths is closed. But I can let you use the furnace at the cost of 20 gold pieces.")
choice {
option("Use Furnace - 20 Gold") {
if (!inventory.remove("coins", 20)) {
npc<Neutral>("Sorry, you don't have enough coins.")
return@option
}
this["yohnus_paid"] = true
npc<Happy>("Thanks Bwana! Enjoy the facilities!")
}
option<Neutral>("No thanks!") {
npc<Neutral>("Very well Bwana, have a nice day.")
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package content.area.karamja.shilo_village

import WorldTest
import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.Test
import world.gregs.voidps.engine.client.instruction.handle.interactObject
import world.gregs.voidps.engine.entity.obj.GameObjects
import world.gregs.voidps.engine.inv.add
import world.gregs.voidps.engine.inv.inventory
import world.gregs.voidps.type.Tile

class ShiloVillageCartTest : WorldTest() {
override var loadNpcs: Boolean = true

@Test
fun `Travel from shilo to brimhaven`() {
val player = createPlayer(Tile(2833, 2954))
player.inventory.add("coins", 10)
val cart = GameObjects.find(Tile(2831, 2952), "travel_cart_shilo_village")

player.interactObject(cart, "Pay-fare")

tick(4)
assertEquals(0, player.inventory.count("coins"))
assertEquals(Tile(2778, 3210), player.tile)
}

@Test
fun `Travel from brimhaven to shilo village`() {
val player = createPlayer(Tile(2778, 3210))
player.inventory.add("coins", 10)
val cart = GameObjects.find(Tile(2777, 3211), "travel_cart_brimhaven")

player.interactObject(cart, "Pay-fare")

tick(4)
assertEquals(0, player.inventory.count("coins"))
assertEquals(Tile(2834, 2951), player.tile)
}
}
Loading