1package com.osroyale.game.world.entity.combat.strategy.npc;
3import com.osroyale.game.Animation;
4import com.osroyale.game.UpdatePriority;
5import com.osroyale.game.world.entity.combat.CombatType;
6import com.osroyale.game.world.entity.combat.attack.FightType;
7import com.osroyale.game.world.entity.combat.effect.impl.CombatPoisonEffect;
8import com.osroyale.game.world.entity.combat.effect.impl.CombatVenomEffect;
9import com.osroyale.game.world.entity.combat.hit.CombatHit;
10import com.osroyale.game.world.entity.combat.hit.Hit;
11import com.osroyale.game.world.entity.combat.strategy.basic.MeleeStrategy;
12import com.osroyale.game.world.entity.mob.Mob;
13import com.osroyale.game.world.entity.mob.npc.Npc;
14import com.osroyale.util.RandomUtils;
18 private static final NpcMeleeStrategy INSTANCE =
new NpcMeleeStrategy();
20 protected NpcMeleeStrategy() {
24 public void start(Npc attacker, Mob defender, Hit[] hits) {
25 attacker.animate(getAttackAnimation(attacker, defender),
true);
29 public void attack(Npc attacker, Mob defender, Hit
hit) {
30 if (!attacker.definition.isPoisonous()) {
34 if (CombatVenomEffect.isVenomous(attacker) && RandomUtils.success(0.25)) {
37 CombatPoisonEffect.getPoisonType(attacker.id).ifPresent(defender::poison);
42 public int getAttackDelay(Npc attacker, Mob defender, FightType fightType) {
43 return attacker.definition.getAttackDelay();
47 public int getAttackDistance(Npc attacker, FightType fightType) {
54 public CombatHit[] getHits(Npc attacker, Mob defender) {
55 return new CombatHit[]{nextMeleeHit(attacker, defender)};
59 public Animation getAttackAnimation(Npc attacker, Mob defender) {
60 return new Animation(attacker.definition.getAttackAnimation(), UpdatePriority.HIGH);
64 public boolean canAttack(Npc attacker, Mob defender) {
69 public CombatType getCombatType() {
70 return CombatType.MELEE;
73 public static NpcMeleeStrategy
get() {
void hit(T attacker, Mob defender, Hit hit)