RuneHive-Game
Loading...
Searching...
No Matches
DragonClaws.java
Go to the documentation of this file.
1package com.runehive.game.world.entity.combat.strategy.player.special.melee;
2
3import com.runehive.game.Animation;
4import com.runehive.game.Graphic;
5import com.runehive.game.UpdatePriority;
6import com.runehive.game.world.entity.combat.CombatUtil;
7import com.runehive.game.world.entity.combat.attack.FormulaFactory;
8import com.runehive.game.world.entity.combat.hit.CombatHit;
9import com.runehive.game.world.entity.combat.hit.Hit;
10import com.runehive.game.world.entity.combat.hit.HitIcon;
11import com.runehive.game.world.entity.combat.strategy.player.PlayerMeleeStrategy;
12import com.runehive.game.world.entity.mob.Mob;
13import com.runehive.game.world.entity.mob.player.Player;
14
15/**
16 * @author Michael | Chex
17 */
18public class DragonClaws extends PlayerMeleeStrategy {
19 private static final Animation ANIMATION = new Animation(7527, UpdatePriority.HIGH);
20 private static final Graphic GRAPHIC = new Graphic(1171, 50);
21
22 private static final DragonClaws INSTANCE = new DragonClaws();
23
24 @Override
25 public void start(Player attacker, Mob defender, Hit[] hits) {
26 super.start(attacker, defender, hits);
27 attacker.graphic(GRAPHIC);
28 }
29
30 @Override
31 public CombatHit[] getHits(Player attacker, Mob defender) {
32 CombatHit first = nextMeleeHit(attacker, defender);
33
34 if (first.getDamage() < 1) {
35 return secondOption(attacker, defender, first);
36 }
37
38 CombatHit second = first.copyAndModify(damage -> damage / 2);
39 CombatHit third = second.copyAndModify(damage -> damage / 2);
40 CombatHit fourth = second.copyAndModify(damage -> first.getDamage() - second.getDamage() - third.getDamage());
41 return new CombatHit[]{first, second, third, fourth};
42 }
43
44 @Override
45 public Animation getAttackAnimation(Player attacker, Mob defender) {
46 return ANIMATION;
47 }
48
49 private CombatHit[] secondOption(Player attacker, Mob defender, CombatHit inaccurate) {
50 CombatHit second = nextMeleeHit(attacker, defender);
51
52 if (second.getDamage() < 1) {
53 return thirdOption(attacker, defender, inaccurate, second);
54 }
55
56 CombatHit third = second.copyAndModify(damage -> damage / 2);
57 return new CombatHit[]{inaccurate, second, third, third};
58 }
59
60 private CombatHit[] thirdOption(Player attacker, Mob defender, CombatHit inaccurate, CombatHit inaccurate2) {
61 CombatHit third = nextMeleeHit(attacker, defender);
62
63 if (third.getDamage() < 1) {
64 return fourthOption(attacker, defender, inaccurate, inaccurate2);
65 }
66
67 int maxHit = FormulaFactory.getModifiedMaxHit(attacker, defender, getCombatType()) * 3 / 4;
68 third.setDamage(maxHit);
69 CombatHit fourth = third.copyAndModify(damage -> third.getDamage());
70 return new CombatHit[]{inaccurate, inaccurate2, third, fourth};
71 }
72
73 private CombatHit[] fourthOption(Player attacker, Mob defender, CombatHit inaccurate, CombatHit inaccurate2) {
74 CombatHit fourth = nextMeleeHit(attacker, defender);
75
76 if (fourth.getDamage() < 1) {
77 int hitDelay = CombatUtil.getHitDelay(attacker, defender, getCombatType());
78 CombatHit hit = new CombatHit(new Hit(10, HitIcon.MELEE), hitDelay, 0);
79 return new CombatHit[]{inaccurate, inaccurate2, hit, hit};
80 }
81
82 fourth.modifyDamage(damage -> (int) (damage * 1.50));
83 return new CombatHit[]{inaccurate, inaccurate2, fourth, fourth};
84 }
85
86 @Override
87 public int modifyAccuracy(Player attacker, Mob defender, int roll) {
88 return roll * 7 / 4;
89 }
90
91 public static DragonClaws get() {
92 return INSTANCE;
93 }
94
95}
Class that models a single animation used by an entity.
Represents a single graphic that can be used by entities.
Definition Graphic.java:10
A collection of util methods and constants related to combat.
static int getHitDelay(final Mob attacker, final Mob defender, final CombatType type)
Gets the hit delay for the specified type.
Supplies factory methods useful for combat.
static int getModifiedMaxHit(Mob attacker, Mob defender, CombatType type)
A wrapper for a Hit object, adding additional variables for hit and hitsplat delays.
CombatHit copyAndModify(Function< Integer, Integer > modifier)
Copies and modifies this combat hit.
A Hit object holds the damage amount and hitsplat data.
Definition Hit.java:10
int getDamage()
Gets the damage amount.
Definition Hit.java:121
void setDamage(int damage)
Sets the hit damage.
Definition Hit.java:98
void modifyDamage(Function< Integer, Integer > modifier)
Sets the hit damage with a function.
Definition Hit.java:108
CombatHit[] fourthOption(Player attacker, Mob defender, CombatHit inaccurate, CombatHit inaccurate2)
CombatHit[] thirdOption(Player attacker, Mob defender, CombatHit inaccurate, CombatHit inaccurate2)
CombatHit[] secondOption(Player attacker, Mob defender, CombatHit inaccurate)
Handles the mob class.
Definition Mob.java:66
Optional< Graphic > graphic
Definition Mob.java:91
This class represents a character controlled by a player.
Definition Player.java:125
Represents different priorities for updating.
The enumerated type whose elements represent the hit icon of a Hit.
Definition HitIcon.java:8
MELEE
Represents the melee sword hit icon.
Definition HitIcon.java:14