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
2 changes: 1 addition & 1 deletion data/minigame/barrows_brothers/barrows.ifaces.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[barrows_overlay]
id = 24
type = "overlay"
type = "game_screen_overlay"

[barrows_puzzle]
id = 25
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@ package world.gregs.voidps.engine.client.update

import world.gregs.voidps.engine.client.update.iterator.TaskIterator
import world.gregs.voidps.engine.client.variable.hasClock
import world.gregs.voidps.engine.entity.Spawn
import world.gregs.voidps.engine.entity.character.mode.EmptyMode
import world.gregs.voidps.engine.entity.character.mode.Wander
import world.gregs.voidps.engine.entity.character.mode.Wander.Companion.wanders
import world.gregs.voidps.engine.entity.character.move.tele
import world.gregs.voidps.engine.entity.character.npc.NPC
import world.gregs.voidps.engine.entity.character.npc.NPCs
import world.gregs.voidps.engine.entity.character.npc.flagTransform
import world.gregs.voidps.engine.entity.character.player.skill.Skill
import world.gregs.voidps.type.Direction
import world.gregs.voidps.type.Tile

class NPCTask(
iterator: TaskIterator<NPC>,
Expand All @@ -16,6 +21,7 @@ class NPCTask(

override fun run(character: NPC) {
checkDelay(character)
lifecycle(character)
if (character.mode == EmptyMode && wanders(character)) {
character.mode = Wander(character)
}
Expand All @@ -26,6 +32,43 @@ class NPCTask(
checkTileFacing(character)
}

private fun lifecycle(npc: NPC) {
if (npc.contains("delay")) {
return
}
if (npc.lifecycle == 0) {
return
}
if (npc.lifecycle > 0) {
if (--npc.lifecycle == 0) {
if (npc.hide) {
// Respawn
reset(npc)
Spawn.npc(npc)
} else {
// Revert
npc.visuals.transform.id = npc.def.id
npc.flagTransform()
}
}
} else if (++npc.lifecycle == 0) {
// Despawn
NPCs.remove(npc)
}
}

private fun reset(npc: NPC) {
npc.clearAnim()
npc.hide = false
npc.clear("dead")
npc.mode = EmptyMode
npc.levels.clear()
val respawn = npc.get<Tile>("respawn_tile") ?: return
npc.tele(respawn)
val dir = npc.get<Direction>("respawn_direction") ?: return
npc.face(dir)
}

private fun healthRegen(character: NPC) {
if (!character.hasClock("under_attack") && character.regenCounter++ >= character.def["regen_rate_ticks", 25] && character.levels.get(Skill.Constitution) < character.levels.getMax(Skill.Constitution)) {
character.levels.restore(Skill.Constitution, 10)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,18 @@ class PlayerVariables(
variable.send(client ?: return, value)
}

override fun sendAll() {
val client = client ?: return
for ((key, value) in data) {
val variable = VariableDefinitions.get(key) ?: continue
if (!variable.transmit) {
continue
}
if (value != variable.defaultValue) {
variable.send(client, value)
}
}
}

override fun data(key: String): MutableMap<String, Any> = if (VariableDefinitions.get(key).persist) data else temp
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ interface VariableStore {

fun clear(key: String, refresh: Boolean = true) = variables.clear(key, refresh)

fun toggle(key: String, refresh: Boolean = true): Boolean {
val value = variables.get(key, false)
fun toggle(key: String, refresh: Boolean = true, default: Boolean = false): Boolean {
val value = variables.get(key, default)
variables.set(key, !value as Any, refresh)
return !value
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,8 @@ open class Variables(
open fun send(key: String) {
}

open fun sendAll() {
}

open fun data(key: String): MutableMap<String, Any> = data
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class AccountManager(
}
loadCallback.invoke(player)
player.open(player.interfaces.gameFrame)
player.variables.sendAll()
Spawn.player(player)
val offset = player.get<Long>("instance_offset")?.let { Delta(it) } ?: Delta.EMPTY
val original = player.tile.minus(offset)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import world.gregs.voidps.type.Delta
import world.gregs.voidps.type.Direction
import world.gregs.voidps.type.Distance
import world.gregs.voidps.type.Tile
import kotlin.coroutines.Continuation
import kotlin.math.round

interface Character :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ data class NPC(
}
}

var lifecycle: Int = 0

override val size = def.size
override var mode: Mode = EmptyMode
set(value) {
Expand Down Expand Up @@ -81,6 +83,28 @@ data class NPC(
return NPCDefinitions.resolve(def, player)
}

/**
* Respawn an npc after [ticks]
*/
fun respawn(ticks: Int) {
hide = true
lifecycle = ticks + 1
}

/**
* Revert the transform of an npc after [ticks]
*/
fun revert(ticks: Int) {
lifecycle = ticks + 1
}

/**
* Remove then npc completely after [ticks]
*/
fun despawn(ticks: Int = 0) {
lifecycle = -(ticks + 1)
}

override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import world.gregs.voidps.engine.entity.character.CharacterSearch
import world.gregs.voidps.engine.entity.character.CharacterIndexMap
import world.gregs.voidps.engine.entity.character.mode.EmptyMode
import world.gregs.voidps.engine.entity.character.mode.Wander
import world.gregs.voidps.engine.entity.character.player.Player
import world.gregs.voidps.engine.entity.character.player.skill.Skill
import world.gregs.voidps.engine.map.collision.CollisionStrategyProvider
import world.gregs.voidps.type.Direction
Expand Down Expand Up @@ -74,6 +75,15 @@ object NPCs : Runnable,
return npc
}

fun add(id: String, tile: Tile, direction: Direction = Direction.SOUTH, ticks: Int, owner: Player? = null): NPC {
val npc = add(id, tile, direction)
npc.despawn(ticks)
if (owner != null) {
npc["owner"] = owner.accountName
}
return npc
}

fun remove(npc: NPC?): Boolean {
if (npc == null || npc.index == -1) {
logger.warn { "Unable to remove npc $npc." }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ object Players : Iterable<Player>, CharacterSearch<Player> {

fun find(name: String): Player? = firstOrNull { it.name == name }

fun findByAccount(name: String): Player? = firstOrNull { it.accountName == name }

fun add(player: Player): Boolean {
if (player.index == -1 || indexArray[player.index] != null) {
return false
Expand Down
11 changes: 3 additions & 8 deletions game/src/main/kotlin/content/achievement/TaskList.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,18 @@ class TaskList : Script {

init {
playerSpawn {
sendVariable("task_disable_popups")
set("task_popup", 0)
set("task_previous_popup", 0)
var total = 0
for (area in 0 until 8) {
Tasks.forEach(area) {
if (Tasks.isCompleted(this@playerSpawn, definition.stringId)) {
sendVariable(definition.stringId)
total++
}
null
}
}
set("task_progress_overall", total)
sendVariable("task_hide_completed")
sendVariable("task_filter_sets")
}

interfaceOpened("task_list") {
Expand Down Expand Up @@ -57,16 +53,15 @@ class TaskList : Script {
}

interfaceOption("Filter-sets", "task_list:filter_sets") {
set("task_filter_sets", !get("task_filter_sets", false))
toggle("task_filter_sets")
}

interfaceOption("Filter-done", "task_list:filter_done") {
set("task_hide_completed", !get("task_hide_completed", false))
toggle("task_hide_completed")
}

interfaceOption("Turn-off", "task_list:toggle_popups") {
val disable = !get("task_disable_popups", false)
set("task_disable_popups", disable)
val disable = !toggle("task_disable_popups")
if (disable) {
set("task_popup", 0)
set("task_previous_popup", 0)
Expand Down
2 changes: 1 addition & 1 deletion game/src/main/kotlin/content/achievement/TaskSystem.kt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class TaskSystem : Script {
}

interfaceOption("Toggle", "task_system:dont_show") {
set("task_dont_show_again", !get("task_dont_show_again", false))
toggle("task_dont_show_again")
}

interfaceOption("Open", "task_system:task_list") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ import world.gregs.voidps.engine.entity.character.move.tele

class CaptainBentley : Script {
init {
playerSpawn {
sendVariable("lunar_diplomacy")
}

npcOperate("Talk-to", "captain_bentley*") {
if (tile in Areas["lunar_isle"]) {
player<Neutral>("Hi.")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package content.area.kandarin.feldip_hills

import content.entity.combat.hit.directHit
import content.entity.combat.inCombat
import content.entity.effect.clearTransform
import content.entity.effect.toxin.poison
import content.entity.effect.transform
Expand All @@ -18,7 +17,6 @@ import world.gregs.voidps.engine.entity.character.mode.PauseMode
import world.gregs.voidps.engine.entity.character.npc.NPC
import world.gregs.voidps.engine.entity.character.player.Player
import world.gregs.voidps.engine.queue.queue
import world.gregs.voidps.engine.timer.Timer
import world.gregs.voidps.engine.timer.toTicks
import world.gregs.voidps.type.random
import java.util.concurrent.TimeUnit
Expand All @@ -30,19 +28,6 @@ class JungleStrykewyrm : Script {
investigate(this, target, "jungle_strykewyrm")
}

npcTimerStart("strykewyrm_revert") { 20 }

npcTimerTick("strykewyrm_revert") {
if (inCombat) {
return@npcTimerTick Timer.CONTINUE
}
anim("strykewyrm_bury")
queue("bury", 3) {
clearTransform()
}
Timer.CANCEL
}

npcAttack("jungle_strykewyrm", "dig") { target ->
burrow(this, target) {
poison(target, 88)
Expand Down Expand Up @@ -94,7 +79,7 @@ class JungleStrykewyrm : Script {
target.start("movement_delay", Int.MAX_VALUE)
target.mode = EmptyMode
target.steps.clear()
target.softTimers.start("strykewyrm_revert")
target.despawn(20)
source.delay(3)
target.mode = EmptyMode
target.transform(to)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class TzhaarFightCave(
exited("tzhaar_fight_cave_multi_area") {
close("tzhaar_fight_cave")
clearInstance()
if (get("logged_out", false)) {
if (get("logged_out", false) && wave != -1) {
// Save the player's relative position in the original region
val offset = tile.delta(tile.region.tile)
tele(region.tile.add(offset))
Expand Down Expand Up @@ -191,7 +191,6 @@ class TzhaarFightCave(
}
strongQueue("fight_cave_start", TimeUnit.SECONDS.toTicks(2)) {
startWave(this, wave, start = true)
sendVariable("fight_cave_wave")
}
}

Expand All @@ -209,6 +208,7 @@ class TzhaarFightCave(
}
}
}
// 2436, 5170

fun Player.leave(wave: Int, defeatedJad: Boolean = false) {
clear("fight_cave_wave")
Expand Down Expand Up @@ -251,7 +251,9 @@ class TzhaarFightCave(
}
player["fight_cave_wave"] = wave
if (player["fight_caves_logout_warning", false]) {
Script.launch { accountManager.logout(player, false) }
Script.launch {
accountManager.logout(player, true)
}
return
}
if (start && wave != 63) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ import world.gregs.voidps.engine.inv.remove

class KalphiteHive : Script {
init {
playerSpawn {
sendVariable("kalphite_tunnel_rope")
sendVariable("kalphite_lair_rope")
}

itemOnObjectOperate("rope", "kalphite_hive_tunnel") {
if (!get("kalphite_tunnel_rope", false) && inventory.remove("rope")) {
set("kalphite_tunnel_rope", true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ import world.gregs.voidps.type.Tile
class StrongholdOfPlayerSafety : Script {

init {
playerSpawn {
sendVariable("stronghold_of_player_safety_poster")
sendVariable("stronghold_of_player_safety_lever")
}

objectOperate("Open", "misthalin_exam_door_closed") { (target) ->
// From wiki: The main door into the Training Centre, which is locked, preventing players from opening it from the outside, until they talk to the Guard in the jail and go through the entire conversation about reporting rule-breakers
if (get("safety_prison_guard_talked", false)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ import world.gregs.voidps.engine.inv.remove
class StrongholdOfPlayerSafetyRewards : Script {

init {
playerSpawn {
sendVariable("stronghold_of_player_safety_chest")
}

objectOperate("Open", "stronghold_of_player_safety_treasure_chest_closed") { (target) ->
if (inventory.isFull()) {
// https://youtu.be/eSZY9zdBAwg?si=UlMwKzgDA51IZ7TF&t=203
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class GravestoneShop : Script {

init {
interfaceOpened("gravestone_shop") { id ->
sendVariable("gravestone_current")
if (questCompleted("the_restless_ghost")) {
addVarbit("unlocked_gravestones", "flag")
addVarbit("unlocked_gravestones", "small_gravestone")
Expand Down
Loading
Loading