Skip to content
Draft
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/.gradle/
.vscode/
build/
g=out/
gen/
Expand Down
2 changes: 2 additions & 0 deletions cache/src/main/kotlin/org/alter/CacheTools.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import org.alter.codegen.startGeneration
import org.alter.gamevals.GameValProvider
import org.alter.gamevals.GamevalDumper
import org.alter.impl.GameframeTable
import org.alter.impl.skills.Cooking
import org.alter.impl.skills.Firemaking
import org.alter.impl.misc.FoodTable
import org.alter.impl.skills.PrayerTable
Expand All @@ -43,6 +44,7 @@ fun tablesToPack() = listOf(
TeleTabs.teleTabs(),
StatComponents.statsComponents(),
FoodTable.consumableFood(),
Cooking.recipes(),
Firemaking.logs(),
Woodcutting.trees(),
Woodcutting.axes(),
Expand Down
147 changes: 147 additions & 0 deletions cache/src/main/kotlin/org/alter/impl/skills/Cooking.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
package org.alter.impl.skills

import dev.openrune.definition.dbtables.dbTable
import dev.openrune.definition.util.VarType

object Cooking {

const val COL_RAW = 0
const val COL_COOKED = 1
const val COL_BURNT = 2
const val COL_LEVEL = 3
const val COL_XP = 4
const val COL_STOP_BURN_FIRE = 5
const val COL_STOP_BURN_RANGE = 6

fun recipes() = dbTable("tables.cooking_recipes") {

column("raw", COL_RAW, VarType.OBJ)
column("cooked", COL_COOKED, VarType.OBJ)
column("burnt", COL_BURNT, VarType.OBJ)
column("level", COL_LEVEL, VarType.INT)
column("xp", COL_XP, VarType.INT)
column("stop_burn_fire", COL_STOP_BURN_FIRE, VarType.INT)
column("stop_burn_range", COL_STOP_BURN_RANGE, VarType.INT)

// Basic fish & meat (initial skill implementation)
row("dbrows.cooking_shrimps") {
columnRSCM(COL_RAW, "items.raw_shrimp")
columnRSCM(COL_COOKED, "items.shrimp")
columnRSCM(COL_BURNT, "items.burnt_shrimp")
column(COL_LEVEL, 1)
column(COL_XP, 30)
column(COL_STOP_BURN_FIRE, 34)
column(COL_STOP_BURN_RANGE, 33)
}

row("dbrows.cooking_anchovies") {
columnRSCM(COL_RAW, "items.raw_anchovies")
columnRSCM(COL_COOKED, "items.anchovies")
columnRSCM(COL_BURNT, "items.burntfish1")
column(COL_LEVEL, 1)
column(COL_XP, 30)
column(COL_STOP_BURN_FIRE, 34)
column(COL_STOP_BURN_RANGE, 33)
}

row("dbrows.cooking_sardine") {
columnRSCM(COL_RAW, "items.raw_sardine")
columnRSCM(COL_COOKED, "items.sardine")
columnRSCM(COL_BURNT, "items.burntfish5")
column(COL_LEVEL, 1)
column(COL_XP, 40)
column(COL_STOP_BURN_FIRE, 38)
column(COL_STOP_BURN_RANGE, 37)
}

row("dbrows.cooking_herring") {
columnRSCM(COL_RAW, "items.raw_herring")
columnRSCM(COL_COOKED, "items.herring")
columnRSCM(COL_BURNT, "items.burntfish3")
column(COL_LEVEL, 5)
column(COL_XP, 50)
column(COL_STOP_BURN_FIRE, 41)
column(COL_STOP_BURN_RANGE, 40)
}

row("dbrows.cooking_mackerel") {
columnRSCM(COL_RAW, "items.raw_mackerel")
columnRSCM(COL_COOKED, "items.mackerel")
columnRSCM(COL_BURNT, "items.burntfish3")
column(COL_LEVEL, 10)
column(COL_XP, 60)
column(COL_STOP_BURN_FIRE, 44)
column(COL_STOP_BURN_RANGE, 43)
}

row("dbrows.cooking_trout") {
columnRSCM(COL_RAW, "items.raw_trout")
columnRSCM(COL_COOKED, "items.trout")
columnRSCM(COL_BURNT, "items.burntfish2")
column(COL_LEVEL, 15)
column(COL_XP, 70)
column(COL_STOP_BURN_FIRE, 50)
column(COL_STOP_BURN_RANGE, 49)
}

row("dbrows.cooking_salmon") {
columnRSCM(COL_RAW, "items.raw_salmon")
columnRSCM(COL_COOKED, "items.salmon")
columnRSCM(COL_BURNT, "items.burntfish2")
column(COL_LEVEL, 25)
column(COL_XP, 90)
column(COL_STOP_BURN_FIRE, 58)
column(COL_STOP_BURN_RANGE, 57)
}

row("dbrows.cooking_lobster") {
columnRSCM(COL_RAW, "items.raw_lobster")
columnRSCM(COL_COOKED, "items.lobster")
columnRSCM(COL_BURNT, "items.burnt_lobster")
column(COL_LEVEL, 40)
column(COL_XP, 120)
column(COL_STOP_BURN_FIRE, 74)
column(COL_STOP_BURN_RANGE, 64)
}

row("dbrows.cooking_swordfish") {
columnRSCM(COL_RAW, "items.raw_swordfish")
columnRSCM(COL_COOKED, "items.swordfish")
columnRSCM(COL_BURNT, "items.burnt_swordfish")
column(COL_LEVEL, 45)
column(COL_XP, 140)
column(COL_STOP_BURN_FIRE, 86)
column(COL_STOP_BURN_RANGE, 80)
}

row("dbrows.cooking_shark") {
columnRSCM(COL_RAW, "items.raw_shark")
columnRSCM(COL_COOKED, "items.shark")
columnRSCM(COL_BURNT, "items.burnt_shark")
column(COL_LEVEL, 80)
column(COL_XP, 210)
column(COL_STOP_BURN_FIRE, 99)
column(COL_STOP_BURN_RANGE, 94)
}

row("dbrows.cooking_beef") {
columnRSCM(COL_RAW, "items.raw_beef")
columnRSCM(COL_COOKED, "items.cooked_meat")
columnRSCM(COL_BURNT, "items.burnt_meat")
column(COL_LEVEL, 1)
column(COL_XP, 30)
column(COL_STOP_BURN_FIRE, 33)
column(COL_STOP_BURN_RANGE, 32)
}

row("dbrows.cooking_chicken") {
columnRSCM(COL_RAW, "items.raw_chicken")
columnRSCM(COL_COOKED, "items.cooked_chicken")
columnRSCM(COL_BURNT, "items.burnt_chicken")
column(COL_LEVEL, 1)
column(COL_XP, 30)
column(COL_STOP_BURN_FIRE, 33)
column(COL_STOP_BURN_RANGE, 32)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
package org.alter.commands.developer

import org.alter.api.Skills
import org.alter.api.ext.message
import org.alter.game.model.priv.Privilege
import org.alter.game.model.Tile
import org.alter.game.model.move.moveTo
import org.alter.game.pluginnew.PluginEvent
import org.alter.game.pluginnew.event.impl.CommandEvent
import org.alter.rscm.RSCM.asRSCM

class CookingTestCommandsPlugin : PluginEvent() {

private enum class CookTestSet(val key: String) {
LOW("low"),
MID("mid"),
HIGH("high"),
MEAT("meat"),
ALL("all")
}

private data class CookTestPreset(
val key: String,
val set: CookTestSet,
val level: Int,
val qty: Int,
)

private val presets = listOf(
CookTestPreset(key = "low", set = CookTestSet.LOW, level = 1, qty = 5),
CookTestPreset(key = "mid", set = CookTestSet.MID, level = 25, qty = 5),
CookTestPreset(key = "high", set = CookTestSet.HIGH, level = 80, qty = 3),
CookTestPreset(key = "meat", set = CookTestSet.MEAT, level = 1, qty = 10),
CookTestPreset(key = "all", set = CookTestSet.ALL, level = 80, qty = 1),
)

override fun init() {
on<CommandEvent> {
where {
command.equals("cooktest", ignoreCase = true) &&
player.world.privileges.isEligible(player.privilege, Privilege.DEV_POWER)
}
then {
val args = args.orEmpty().map { it.trim() }.filter { it.isNotEmpty() }

val preset = parseCookTestPreset(player, args)
if (preset == null) {
sendCookTestHelp(player)
return@then
}

player.getSkills().setBaseLevel(Skills.COOKING, preset.level)

val keys = keysFor(preset.set)
if (keys.isEmpty()) {
player.message("No items configured for preset '${preset.key}'.")
return@then
}

var addedAny = false
var failed = 0
for (key in keys) {
val id = runCatching { key.asRSCM() }.getOrNull() ?: continue
val result = player.inventory.add(id, preset.qty)
if (result.hasSucceeded()) {
addedAny = true
} else {
failed++
}
}

if (!addedAny) {
player.message("Couldn't add any items (inventory full?).")
} else if (failed > 0) {
player.message("Added cooking test items (some didn't fit: $failed).")
} else {
player.message("Applied cooktest preset '${preset.key}' (x${preset.qty} each, Cooking=${preset.level}).")
}
}
}
}

private fun parseCookTestPreset(player: org.alter.game.model.entity.Player, args: List<String>): CookTestPreset? {
if (args.isEmpty() || args.any { it.equals("help", ignoreCase = true) || it == "-h" || it == "--help" }) {
return null
}

val token = args.first().removePrefix("--").trim().lowercase()
return presets.firstOrNull { it.key == token }
}

private fun keysFor(set: CookTestSet): List<String> =
when (set) {
CookTestSet.LOW -> listOf(
"items.raw_shrimp",
"items.raw_anchovies",
"items.raw_sardine",
"items.raw_herring"
)

CookTestSet.MID -> listOf(
"items.raw_mackerel",
"items.raw_trout",
"items.raw_salmon"
)

CookTestSet.HIGH -> listOf(
"items.raw_lobster",
"items.raw_swordfish",
"items.raw_shark"
)

CookTestSet.MEAT -> listOf(
"items.raw_beef",
"items.raw_chicken"
)

CookTestSet.ALL -> keysFor(CookTestSet.LOW) + keysFor(CookTestSet.MID) + keysFor(CookTestSet.HIGH) + keysFor(CookTestSet.MEAT)
}

private fun sendCookTestHelp(player: org.alter.game.model.entity.Player) {
player.message("Usage: ::cooktest <preset>")
player.message("Presets: ${presets.joinToString(", ") { it.key }}")
player.message("Examples: ::cooktest low | ::cooktest mid | ::cooktest high | ::cooktest meat | ::cooktest all")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import org.alter.game.model.entity.Player
import org.alter.game.pluginnew.PluginEvent
import org.alter.game.pluginnew.event.impl.onButton
import org.alter.game.pluginnew.event.impl.onIfOpen
import org.alter.interfaces.ifCloseOverlay
import org.alter.interfaces.ifOpenOverlay
import org.alter.interfaces.ifSetEvents
import org.alter.interfaces.settings.configs.setting_components
Expand All @@ -16,6 +17,11 @@ class SettingsSideScript : PluginEvent() {
override fun init() {
onIfOpen("interfaces.settings_side") { player.updateIfEvents() }

onIfOpen("interfaces.settings") {
player.ifSetEvents("components.settings:close", 0..0, IfEvent.Op1)
player.ifSetEvents("components.settings:dropdown_close", 0..0, IfEvent.Op1)
}

SettingsTabView.entries.forEach {
onButton(it.component) {
player.setVarbit("varbits.settings_side_panel_tab",it.varValue)
Expand All @@ -25,6 +31,14 @@ class SettingsSideScript : PluginEvent() {
onButton(setting_components.settings_open) {
player.ifOpenOverlay("interfaces.settings")
}

onButton("components.settings:close") {
player.ifCloseOverlay("interfaces.settings")
}

onButton("components.settings:dropdown_close") {
player.ifCloseOverlay("interfaces.settings")
}
}

private fun Player.updateIfEvents() {
Expand Down
Loading