Fixed antipoison not working in some scenarios

Added new ::timers admin command
This commit is contained in:
Avi Weinstock
2023-09-01 12:29:12 +00:00
committed by Ryan
parent 3b0360eb01
commit 12eaa1e05a
5 changed files with 17 additions and 5 deletions
@@ -1,12 +1,14 @@
package content.data.consumables.effects
import core.api.registerTimer
import core.api.removeTimer
import core.api.spawnTimer
import core.game.consumable.ConsumableEffect
import core.game.node.entity.player.Player
class AddTimerEffect (val identifier: String, vararg val args: Any) : ConsumableEffect() {
override fun activate (p: Player) {
removeTimer (p, identifier)
val timer = spawnTimer (identifier, *args) ?: return
registerTimer (p, timer)
}
+3
View File
@@ -2831,6 +2831,9 @@ fun isStunned(entity: Entity) : Boolean {
* @see To those whe ask "why severity instead of plain damage?" to which the answer is: severity is how it works authentically, and allows for scenarios where, e.g. a poison should hit 6 once, and then drop to 5 immediately.
**/
fun applyPoison (entity: Entity, source: Entity, severity: Int) {
if(hasTimerActive<PoisonImmunity>(entity)) {
return
}
val existingTimer = getTimer<Poison>(entity)
if (existingTimer != null) {
@@ -279,5 +279,16 @@ class DevelopmentCommandSet : CommandSet(Privilege.ADMIN) {
val id = args[1].toIntOrNull() ?: 9804
player.dialogueInterpreter.sendDialogues(player, id, "Expression ID: $id")
}
define("timers", Privilege.ADMIN, "::timers", "Print out timers") { player, args ->
player.sendMessage("Active timers:")
for(timer in player.timers.activeTimers) {
player.sendMessage(" ${timer.identifier} ${timer.nextExecution}")
}
player.sendMessage("New timers:")
for(timer in player.timers.newTimers) {
player.sendMessage(" ${timer.identifier}")
}
}
}
}
@@ -40,10 +40,6 @@ class Poison : PersistTimer (30, "poison", flags = arrayOf(TimerFlag.ClearOnDeat
}
override fun onRegister (entity: Entity) {
if (hasTimerActive<PoisonImmunity>(entity)) {
removeTimer<Poison>(entity)
return
}
if (entity is Player) {
sendMessage(entity, "You have been poisoned.")
entity.debug ("[Poison] -> Received for $severity severity.")
@@ -114,4 +114,4 @@ class BloodDrainTests {
Assertions.assertEquals(false, hasTimerActive<Disease>(p))
}
}
}
}