Mithril dragons now only use their range attack when outside melee range

This commit is contained in:
Player Name 2025-06-18 13:43:53 +00:00 committed by Ryan
parent 0c425033f3
commit c1d932a6f1

View file

@ -1,8 +1,7 @@
package content.global.skill.slayer; package content.global.skill.slayer;
import core.game.node.entity.Entity; import core.game.node.entity.Entity;
import core.game.node.entity.combat.BattleState; import core.game.node.entity.combat.*;
import core.game.node.entity.combat.CombatStyle;
import core.game.node.entity.combat.equipment.SwitchAttack; import core.game.node.entity.combat.equipment.SwitchAttack;
import content.global.handlers.item.equipment.special.DragonfireSwingHandler; import content.global.handlers.item.equipment.special.DragonfireSwingHandler;
import core.game.node.entity.impl.Animator.Priority; import core.game.node.entity.impl.Animator.Priority;
@ -13,8 +12,6 @@ import core.game.world.update.flag.context.Animation;
import core.game.world.update.flag.context.Graphics; import core.game.world.update.flag.context.Graphics;
import core.plugin.Initializable; import core.plugin.Initializable;
import core.tools.RandomFunction; import core.tools.RandomFunction;
import core.game.node.entity.combat.CombatSwingHandler;
import core.game.node.entity.combat.MultiSwingHandler;
/** /**
* Handles a mithril dragon npc. * Handles a mithril dragon npc.
@ -23,15 +20,23 @@ import core.game.node.entity.combat.MultiSwingHandler;
@Initializable @Initializable
public final class MithrilDragonNPC extends AbstractNPC { public final class MithrilDragonNPC extends AbstractNPC {
/**
* The dragonfire attack.
*/
private static final SwitchAttack DRAGONFIRE = DragonfireSwingHandler.get(false, 52, new Animation(81, Priority.HIGH), Graphics.create(1), null, null);
/** /**
* Handles the combat. * Handles the combat.
*/ */
private final CombatSwingHandler combatAction = new MultiSwingHandler(true, new SwitchAttack(CombatStyle.MELEE.getSwingHandler(), new Animation(80, Priority.HIGH)), new SwitchAttack(CombatStyle.MELEE.getSwingHandler(), new Animation(80, Priority.HIGH)), new SwitchAttack(CombatStyle.MAGIC.getSwingHandler(), new Animation(81, Priority.HIGH), null, null, Projectile.create((Entity) null, null, 500, 20, 20, 41, 40, 18, 255)), DRAGONFIRE, new SwitchAttack(CombatStyle.RANGE.getSwingHandler(), new Animation(81, Priority.HIGH), null, null, Projectile.create((Entity) null, null, 16, 20, 20, 41, 40, 18, 255))); private static final SwitchAttack DRAGONFIRE = DragonfireSwingHandler.get(false, 52, new Animation(81, Priority.HIGH), Graphics.create(1), null, null);
private static final SwitchAttack MELEE = new SwitchAttack(CombatStyle.MELEE.getSwingHandler(), new Animation(80, Priority.HIGH));
private static final SwitchAttack MAGIC = new SwitchAttack(CombatStyle.MAGIC.getSwingHandler(), new Animation(81, Priority.HIGH), null, null, Projectile.create((Entity) null, null, 500, 20, 20, 41, 40, 18, 255));
private static class InRangeSwitchAttack extends SwitchAttack {
public InRangeSwitchAttack(CombatSwingHandler swingHandler, Animation animation, Graphics startGraphic, Graphics endGraphic, Projectile projectile) {
super(swingHandler, animation, startGraphic, endGraphic, projectile);
}
@Override
public boolean canSelect(Entity entity, Entity victim, BattleState state) {
return CombatStyle.MELEE.getSwingHandler().canSwing(entity, victim) == InteractionType.NO_INTERACT; //only select range if not in melee distance
}
};
private static final SwitchAttack RANGE = new InRangeSwitchAttack(CombatStyle.RANGE.getSwingHandler(), new Animation(81, Priority.HIGH), null, null, Projectile.create((Entity) null, null, 16, 20, 20, 41, 40, 18, 255));
private final CombatSwingHandler combatAction = new MultiSwingHandler(true, MELEE, MAGIC, DRAGONFIRE, RANGE);
/** /**
* Constructs a new {@code MithrilDragonNPC} {@code Object}. * Constructs a new {@code MithrilDragonNPC} {@code Object}.