Skip to content

Commit

Permalink
Add task hint world map marking and fix tab pinning
Browse files Browse the repository at this point in the history
  • Loading branch information
GregHib committed May 30, 2024
1 parent 8d428c0 commit acc9056
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 13 deletions.
4 changes: 4 additions & 0 deletions data/definitions/interfaces.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2372,6 +2372,7 @@ task_list:
hint_2: 4
hint_3: 6
hint_4: 8
hint_5: 10
tasks:
id: 94
options:
Expand Down Expand Up @@ -2609,6 +2610,9 @@ task_system:
summary_overlay: 122
message_overlay: 171
ok: 130
hint_1: 77
hint_2: 79
hint_3: 81
warriors_guild: 1057
fade_out:
id: 120
Expand Down
12 changes: 6 additions & 6 deletions data/definitions/parameters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -370,12 +370,12 @@ task_hint_4: 1277
task_hint_5: 1278
task_hint_6: 1279
task_text_rol: 1280
task_selectable_1: 1282
task_selectable_2: 1283
task_selectable_3: 1284
task_selectable_4: 1285
task_selectable_5: 1286
task_selectable_6: 1287
task_hint_tile_1: 1282
task_hint_tile_2: 1283
task_hint_tile_3: 1284
task_hint_tile_4: 1285
task_hint_tile_5: 1286
task_hint_tile_6: 1287
task_members: 1290
task_set: 1292
task_sprite_offset: 1293
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ class EnumDefinitions(
return structs.get(struct)[param]
}

fun <T : Any?> getStructOrNull(id: String, index: Int, param: String): T? {
val enum = get(id)
val struct = enum.getInt(index)
return structs.getOrNull(struct)?.getOrNull(param)
}

fun <T : Any> getStruct(id: String, index: Int, param: String, default: T): T {
val enum = get(id)
val struct = enum.getInt(index)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import world.gregs.voidps.engine.client.sendScript
import world.gregs.voidps.engine.client.ui.close
import world.gregs.voidps.engine.client.ui.event.interfaceOpen
import world.gregs.voidps.engine.client.ui.interfaceOption
import world.gregs.voidps.engine.client.ui.open
import world.gregs.voidps.engine.client.variable.variableSet
import world.gregs.voidps.engine.data.definition.EnumDefinitions
import world.gregs.voidps.engine.data.definition.VariableDefinitions
import world.gregs.voidps.engine.entity.character.player.Player
import world.gregs.voidps.engine.entity.playerSpawn
Expand Down Expand Up @@ -132,4 +134,20 @@ fun refreshCompletedCount(player: Player) {
}
player["task_progress_current"] = completed
player["task_progress_total"] = total
}

/*
Hints
*/

val enumDefinitions: EnumDefinitions by inject()

interfaceOption("Hint", "hint_*", "task_list") {
val selected = player["task_selected", 0]
val index = indexOfSlot(player, selected) ?: return@interfaceOption
val tile: Int = enumDefinitions.getStructOrNull("task_structs", index, component.replace("hint_", "task_hint_tile_")) ?: return@interfaceOption
// TODO I expect the functionality is actually minimap highlights not world map
player["world_map_marker_1"] = tile
player["world_map_marker_text_1"] = ""
player.open("world_map")
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,20 @@ interfaceOption("Pin/Unpin Task", "task_*", "task_system") {
fun indexOfSlot(player: Player, slot: Int): Int? {
var count = 1
return Tasks.forEach(areaId(player)) {
count++
val hideCompleted = player["task_hide_completed", false] && Tasks.isCompleted(player, definition.stringId)
val hideCompleted = Tasks.isCompleted(player, definition.stringId)
val hideMembers = definition["task_members", 0] == 1 && !World.members
if (hideCompleted || hideMembers) {
return@forEach null
}
if (count - 1 == slot) {
return@forEach this.index
if (count == player["task_pin_index", -1]) {
val pinned = player["task_pinned", 4091]
if (count == slot) {
return@forEach pinned
}
skip = pinned != index
}
val skipPinned = player["task_pin_index", -1] == count
if (skipPinned) {
skip = true
if (count++ == slot) {
return@forEach index
}
null
}
Expand Down Expand Up @@ -196,4 +198,18 @@ fun completeTask(player: Player, id: String) {
}
player.message("set. Speak to $npc to claim your reward.")
}
}

/*
Hints
*/

interfaceOption("Hint", "hint_*", "task_system") {
val selected = player["task_selected", 0]
val index = indexOfSlot(player, selected) ?: return@interfaceOption
val tile: Int = enumDefinitions.getStructOrNull("task_structs", index, component.replace("hint_", "task_hint_tile_")) ?: return@interfaceOption
// TODO I expect the functionality is actually minimap highlights not world map
player["world_map_marker_1"] = tile
player["world_map_marker_text_1"] = ""
player.open("world_map")
}

0 comments on commit acc9056

Please sign in to comment.