diff --git a/Server/src/main/content/global/ame/RandomEventNPC.kt b/Server/src/main/content/global/ame/RandomEventNPC.kt index a4f3072f7..e31b5f36d 100644 --- a/Server/src/main/content/global/ame/RandomEventNPC.kt +++ b/Server/src/main/content/global/ame/RandomEventNPC.kt @@ -1,10 +1,8 @@ package content.global.ame import content.global.ame.events.surpriseexam.MysteriousOldManNPC -import core.api.getAttribute import core.api.playGlobalAudio import core.api.poofClear -import core.api.removeAttribute import core.api.sendMessage import core.api.setAttribute import core.api.utils.WeightBasedTable @@ -27,6 +25,8 @@ import core.tools.secondsToTicks import core.tools.ticksToCycles import org.rs09.consts.NPCs import org.rs09.consts.Sounds +import kotlin.math.ceil +import kotlin.math.min import kotlin.random.Random import kotlin.reflect.full.createInstance @@ -37,6 +37,7 @@ abstract class RandomEventNPC(id: Int) : NPC(id) { val SMOKE_GRAPHICS = Graphics(86) var initialized = false var finalized = false + var timerPaused = false var ticksLeft = secondsToTicks(180) private val combatBracket = intArrayOf(10, 20, 40, 60, 90) @@ -56,7 +57,6 @@ abstract class RandomEventNPC(id: Int) : NPC(id) { poofClear(this) playGlobalAudio(this.location, Sounds.SMOKEPUFF_1930, ticksToCycles(1)) } - removeAttribute(player, "random:pause") finalized = true } @@ -93,6 +93,7 @@ abstract class RandomEventNPC(id: Int) : NPC(id) { override fun init() { initialized = true finalized = false + timerPaused = false spawnLocation ?: terminate() location = spawnLocation player.setAttribute("re-npc", this) @@ -149,8 +150,7 @@ abstract class RandomEventNPC(id: Int) : NPC(id) { } fun sayLine(npc: NPC, phrases: Array, hasOpeningPhrase: Boolean, hasOverTimePhrase: Boolean) { - val inInteraction = getAttribute(player, "random:pause", false) //used by Certer - if ((ticksLeft % 20 == 0 || ticksLeft <= 2) && !inInteraction) { //speak every 20 ticks, or in the 2nd-to-last tick before attack/note-&-teleport + if (!timerPaused && (ticksLeft % 20 == 0 || ticksLeft <= 2)) { //unless the Certer interface is up, speak every 20 ticks, or in the 2nd-to-last tick before attack/note-&-teleport var playDwarfWhistle = true if (ticksLeft == secondsToTicks(180) && hasOpeningPhrase) { sendChat(phrases[0]) diff --git a/Server/src/main/content/global/ame/events/certer/CerterNPC.kt b/Server/src/main/content/global/ame/events/certer/CerterNPC.kt index dee88ed3a..20b172404 100644 --- a/Server/src/main/content/global/ame/events/certer/CerterNPC.kt +++ b/Server/src/main/content/global/ame/events/certer/CerterNPC.kt @@ -6,7 +6,6 @@ import org.rs09.consts.NPCs import content.global.ame.RandomEventNPC import core.api.animate import core.api.lock -import core.api.setAttribute import core.api.utils.WeightBasedTable class CerterNPC(override var loot: WeightBasedTable? = null) : RandomEventNPC(NPCs.GILES_2538) { @@ -34,7 +33,8 @@ class CerterNPC(override var loot: WeightBasedTable? = null) : RandomEventNPC(NP "It's really rude to ignore someone, ${player.username}!", "No-one ignores me!" ) - setAttribute(player, "certer:reward", false) + player.setAttribute("random:pause", false) + player.setAttribute("certer:reward", false) animate(this, Emotes.BOW.animation, true) } @@ -42,4 +42,4 @@ class CerterNPC(override var loot: WeightBasedTable? = null) : RandomEventNPC(NP noteAndTeleport() terminate() } -} +} \ No newline at end of file