Fixed antipoison not working in some scenarios
Added new ::timers admin command
This commit is contained in:
@@ -1,12 +1,14 @@
|
|||||||
package content.data.consumables.effects
|
package content.data.consumables.effects
|
||||||
|
|
||||||
import core.api.registerTimer
|
import core.api.registerTimer
|
||||||
|
import core.api.removeTimer
|
||||||
import core.api.spawnTimer
|
import core.api.spawnTimer
|
||||||
import core.game.consumable.ConsumableEffect
|
import core.game.consumable.ConsumableEffect
|
||||||
import core.game.node.entity.player.Player
|
import core.game.node.entity.player.Player
|
||||||
|
|
||||||
class AddTimerEffect (val identifier: String, vararg val args: Any) : ConsumableEffect() {
|
class AddTimerEffect (val identifier: String, vararg val args: Any) : ConsumableEffect() {
|
||||||
override fun activate (p: Player) {
|
override fun activate (p: Player) {
|
||||||
|
removeTimer (p, identifier)
|
||||||
val timer = spawnTimer (identifier, *args) ?: return
|
val timer = spawnTimer (identifier, *args) ?: return
|
||||||
registerTimer (p, timer)
|
registerTimer (p, timer)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.
|
* @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) {
|
fun applyPoison (entity: Entity, source: Entity, severity: Int) {
|
||||||
|
if(hasTimerActive<PoisonImmunity>(entity)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
val existingTimer = getTimer<Poison>(entity)
|
val existingTimer = getTimer<Poison>(entity)
|
||||||
|
|
||||||
if (existingTimer != null) {
|
if (existingTimer != null) {
|
||||||
|
|||||||
@@ -279,5 +279,16 @@ class DevelopmentCommandSet : CommandSet(Privilege.ADMIN) {
|
|||||||
val id = args[1].toIntOrNull() ?: 9804
|
val id = args[1].toIntOrNull() ?: 9804
|
||||||
player.dialogueInterpreter.sendDialogues(player, id, "Expression ID: $id")
|
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) {
|
override fun onRegister (entity: Entity) {
|
||||||
if (hasTimerActive<PoisonImmunity>(entity)) {
|
|
||||||
removeTimer<Poison>(entity)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (entity is Player) {
|
if (entity is Player) {
|
||||||
sendMessage(entity, "You have been poisoned.")
|
sendMessage(entity, "You have been poisoned.")
|
||||||
entity.debug ("[Poison] -> Received for $severity severity.")
|
entity.debug ("[Poison] -> Received for $severity severity.")
|
||||||
|
|||||||
@@ -114,4 +114,4 @@ class BloodDrainTests {
|
|||||||
Assertions.assertEquals(false, hasTimerActive<Disease>(p))
|
Assertions.assertEquals(false, hasTimerActive<Disease>(p))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user