1package com.runehive.game.world.entity.combat.strategy;
3import com.runehive.game.Animation;
4import com.runehive.game.Graphic;
5import com.runehive.game.Projectile;
6import com.runehive.game.world.entity.combat.CombatType;
7import com.runehive.game.world.entity.combat.attack.FightType;
8import com.runehive.game.world.entity.combat.attack.FormulaFactory;
9import com.runehive.game.world.entity.combat.attack.listener.CombatListener;
10import com.runehive.game.world.entity.combat.hit.CombatHit;
11import com.runehive.game.world.entity.combat.hit.Hit;
12import com.runehive.game.world.entity.combat.projectile.CombatProjectile;
13import com.runehive.game.world.entity.mob.Mob;
15import java.util.Optional;
17import static com.runehive.game.world.entity.combat.CombatUtil.getHitDelay;
18import static com.runehive.game.world.entity.combat.CombatUtil.getHitsplatDelay;
19import static com.runehive.game.world.entity.combat.attack.FormulaFactory.getMaxHit;
107 return nextMeleeHit(attacker, defender, max, hitDelay, hitsplatDelay,
false);
113 return nextMeleeHit(attacker, defender, max, hitDelay, hitsplatDelay, multipleHitsAllowed);
119 return nextRangedHit(attacker, defender, max, hitDelay, hitsplatDelay);
125 return nextMagicHit(attacker, defender, max, hitDelay, hitsplatDelay);
133 hitDelay =
projectile.getHitDelay().orElse(hitDelay);
134 hitsplatDelay =
projectile.getHitsplatDelay().orElse(hitsplatDelay);
135 return nextRangedHit(attacker, defender, max, hitDelay, hitsplatDelay);
141 hitDelay =
projectile.getHitDelay().orElse(hitDelay);
142 hitsplatDelay =
projectile.getHitsplatDelay().orElse(hitsplatDelay);
143 return nextMagicHit(attacker, defender, max, hitDelay, hitsplatDelay);
161 return nextMeleeHit(attacker, defender, max, hitDelay, hitsplatDelay,
false);
164 protected CombatHit nextMeleeHit(T attacker,
Mob defender,
int max,
int hitDelay,
int hitsplatDelay,
boolean multipleHitsAllowed) {
167 if(
hit.getMultipleHits() !=
null)
168 return new CombatHit(
hit.getMultipleHits(), hitDelay, hitsplatDelay);
187 final Optional<Projectile> optProjectile = combatProjectile.
getProjectile();
188 if (optProjectile.isPresent()) {
196 final boolean splash,
final Graphic splashGraphic) {
202 final boolean splash,
final Graphic splashGraphic,
203 final int duration) {
208 final boolean splash,
final Graphic splashGraphic,
209 final int duration) {
210 final Graphic base = splash ? splashGraphic : end.orElse(
null);
215 for (
final Hit hit : hits) {
216 if (
hit.isAccurate()) {
Class that models a single animation used by an entity.
Represents a single graphic that can be used by entities.
int getId()
Gets the id of this graphic.
int getHeight()
Gets the height of this graphic.
A wrapper for a Hit object, adding additional variables for hit and hitsplat delays.
A Hit object holds the damage amount and hitsplat data.
Optional< Projectile > getProjectile()
Optional< Graphic > getEnd()
void preKill(Mob attacker, Mob defender, Hit hit)
Called before attacker killed defender.
void finishOutgoing(T attacker, Mob defender)
Called when the defending mob finishes their strategy's attack.
abstract int getAttackDelay(T attacker, Mob defender, FightType fightType)
abstract Animation getAttackAnimation(T attacker, Mob defender)
boolean canOtherAttack(Mob attacker, T defender)
Checks if the attacker can attack the defender.
CombatHit nextMeleeHit(T attacker, Mob defender, int max, int hitDelay, int hitsplatDelay)
boolean isAlwaysAccurate()
abstract CombatType getCombatType()
void onDeath(Mob attacker, T defender, Hit hit)
Called when the defending mob dies.
CombatHit nextMeleeHit(T attacker, Mob defender, int max, int hitDelay, int hitsplatDelay, boolean multipleHitsAllowed)
final CombatHit nextMagicHit(T attacker, Mob defender, int max, int hitDelay, int hitsplatDelay)
CombatHit nextMeleeHit(T attacker, Mob defender, int max)
CombatHit nextMeleeHit(T attacker, Mob defender, int max, boolean multipleHitsAllowed)
CombatHit nextMagicHit(T attacker, Mob defender, int max, CombatProjectile projectile)
void preDeath(Mob attacker, T defender, Hit hit)
Called right before the defending mob dies.
final CombatHit nextRangedHit(T attacker, Mob defender, int max)
abstract int getAttackDistance(T attacker, FightType fightType)
static Graphic getEndGraphic(final Optional< Graphic > end, final boolean splash, final Graphic splashGraphic, final int duration)
final CombatHit nextRangedHit(T attacker, Mob defender, CombatProjectile projectile)
void attack(T attacker, Mob defender, Hit hit)
Called when the attacking hit executes on the defender.
static Graphic getEndGraphic(final CombatProjectile combatProjectile, final boolean splash, final Graphic splashGraphic, final int duration)
final CombatHit nextRangedHit(T attacker, Mob defender, int max, CombatProjectile projectile)
void onDamage(T defender, Hit hit)
void start(T attacker, Mob defender, Hit[] hits)
Called when the strategy starts.
final CombatHit nextMagicHit(T attacker, Mob defender, int max)
CombatProjectile getCombatProjectile()
final CombatHit nextRangedHit(T attacker, Mob defender)
static boolean missed(final Hit... hits)
CombatHit nextMeleeHit(T attacker, Mob defender)
abstract boolean canAttack(T attacker, Mob defender)
Checks if the attacker can attack the defender.
void block(Mob attacker, T defender, Hit hit, CombatType combatType)
Called when the defending mob blocks a hit from the attacker.
void finishIncoming(Mob attacker, T defender)
Called when the attacking mob finishes their strategy's attack.
final CombatHit nextMagicHit(T attacker, Mob defender)
void hitsplat(T attacker, Mob defender, Hit hit)
Called when attacker does the hitsplat.
void hit(T attacker, Mob defender, Hit hit)
Called when the attacking mob performs an attack on the defender.
CombatHit nextRangedHit(T attacker, Mob defender, int max, int hitDelay, int hitsplatDelay)
void onKill(T attacker, Mob defender, Hit hit)
Called when attacker killed defender.
CombatHit nextMagicHit(T attacker, Mob defender, CombatProjectile projectile)
static int getProjectileDuration(final CombatProjectile combatProjectile)
abstract CombatHit[] getHits(T attacker, Mob defender)
static Graphic getEndGraphic(final CombatProjectile combatProjectile, final boolean splash, final Graphic splashGraphic)
The enumerated type whose elements represent the fighting types.
A combat attack is used to describe what the attacking and defending mobs should do in each stage of ...