King Black Dragon breath effects now trigger on impact instead of attack launch
This commit is contained in:
@@ -14,6 +14,7 @@ import core.game.node.entity.impl.Animator.Priority;
|
||||
import core.game.node.entity.npc.AbstractNPC;
|
||||
import core.game.node.entity.npc.NPC;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.world.GameWorld;
|
||||
import core.game.world.map.Location;
|
||||
import core.game.world.update.flag.context.Animation;
|
||||
import core.plugin.Initializable;
|
||||
@@ -127,7 +128,6 @@ public final class KingBlackDragonNPC extends AbstractNPC {
|
||||
@Override
|
||||
public void adjustBattleState(Entity entity, Entity victim, BattleState state) {
|
||||
if (style == CombatStyle.RANGE) {
|
||||
fireType.getTask().exec(victim, entity);
|
||||
state.setStyle(null);
|
||||
DRAGONFIRE.adjustBattleState(entity, victim, state);
|
||||
state.setStyle(CombatStyle.RANGE);
|
||||
@@ -184,6 +184,9 @@ public final class KingBlackDragonNPC extends AbstractNPC {
|
||||
|
||||
@Override
|
||||
public void impact(Entity entity, Entity victim, BattleState state) {
|
||||
if (style != CombatStyle.MELEE && victim.getImpactHandler().getDisabledTicks() <= GameWorld.getTicks()) {
|
||||
fireType.getTask().exec(victim, entity);
|
||||
}
|
||||
style.getSwingHandler().impact(entity, victim, state);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
package content.region.wilderness.handlers
|
||||
|
||||
import TestUtils
|
||||
import core.api.getTimer
|
||||
import core.game.node.entity.combat.BattleState
|
||||
import core.game.node.entity.combat.equipment.FireType
|
||||
import core.game.system.timer.impl.Poison
|
||||
import core.game.world.map.Location
|
||||
import org.junit.jupiter.api.Assertions
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class KBDBreathEffectTests {
|
||||
init {
|
||||
TestUtils.preTestSetup()
|
||||
}
|
||||
|
||||
@Test fun toxicBreathShouldPoisonOnImpactNotOnLaunch() {
|
||||
val kbd = KingBlackDragonNPC(50, Location.create(2273, 4698, 0))
|
||||
val handler = kbd.getSwingHandler(false)
|
||||
// KBD rolls a random FireType per swing, force toxic breath for determinism
|
||||
val fireTypeField = handler.javaClass.getDeclaredField("fireType")
|
||||
fireTypeField.isAccessible = true
|
||||
fireTypeField.set(handler, FireType.TOXIC_BREATH)
|
||||
|
||||
TestUtils.getMockPlayer("kbdbreathtiming").use { player ->
|
||||
val state = BattleState(kbd, player)
|
||||
state.estimatedHit = 0
|
||||
|
||||
handler.adjustBattleState(kbd, player, state)
|
||||
Assertions.assertNull(getTimer<Poison>(player), "Breath effect must not apply on the launch tick.")
|
||||
|
||||
handler.impact(kbd, player, state)
|
||||
Assertions.assertNotNull(getTimer<Poison>(player), "Breath effect must apply when the attack lands.")
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun toxicBreathShouldNotPoisonVictimWhoTeleportedMidFlight() {
|
||||
val kbd = KingBlackDragonNPC(50, Location.create(2273, 4698, 0))
|
||||
val handler = kbd.getSwingHandler(false)
|
||||
val fireTypeField = handler.javaClass.getDeclaredField("fireType")
|
||||
fireTypeField.isAccessible = true
|
||||
fireTypeField.set(handler, FireType.TOXIC_BREATH)
|
||||
|
||||
TestUtils.getMockPlayer("kbdbreathteleport").use { player ->
|
||||
val state = BattleState(kbd, player)
|
||||
state.estimatedHit = 0
|
||||
|
||||
handler.adjustBattleState(kbd, player, state)
|
||||
// Disable impacts like TeleportManager.send does for a real teleport
|
||||
player.impactHandler.setDisabledTicks(12)
|
||||
|
||||
handler.impact(kbd, player, state)
|
||||
Assertions.assertNull(getTimer<Poison>(player), "Breath effect must not apply to a victim whose impacts are disabled (teleported away).")
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user