RuneHive-Game
Loading...
Searching...
No Matches
Dragon2h.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.hit.CombatHit;
8import com.runehive.game.world.entity.combat.hit.Hit;
9import com.runehive.game.world.entity.combat.strategy.player.PlayerMeleeStrategy;
10import com.runehive.game.world.entity.mob.Mob;
11import com.runehive.game.world.entity.mob.player.Player;
12import com.runehive.game.world.entity.mob.player.PlayerRight;
13
14import java.util.Arrays;
15import java.util.LinkedList;
16import java.util.List;
17
18/** @author Daniel | Obey */
19public class Dragon2h extends PlayerMeleeStrategy {
20 private static final Animation ANIMATION = new Animation(3157, UpdatePriority.HIGH);
21 private static final Graphic GRAPHIC = new Graphic(559, UpdatePriority.HIGH);
22 private static final Dragon2h INSTANCE = new Dragon2h();
23
24 private Dragon2h() { }
25
26 @Override
27 public void start(Player attacker, Mob defender, Hit[] hits) {
28 attacker.getCombatSpecial().drain(attacker);
29 attacker.animate(getAttackAnimation(attacker, defender), true);
30
31 List<Hit> extra = new LinkedList<>();
32 CombatUtil.areaAction(attacker, 11, 1, other -> hitEvent(attacker, defender, other, extra));
33
34 if (!defender.isPlayer() || !PlayerRight.isIronman(attacker)) {
35 extra.addAll(Arrays.asList(hits));
36 addCombatExperience(attacker, extra.toArray(new Hit[extra.size()]));
37 }
38
39 attacker.graphic(GRAPHIC);
40 }
41
42 @Override
43 public Animation getAttackAnimation(Player attacker, Mob defender) {
44 return ANIMATION;
45 }
46
47 public static Dragon2h get() {
48 return INSTANCE;
49 }
50
51 private void hitEvent(Player attacker, Mob defender, Mob other, List<Hit> extra) {
52 if (!CombatUtil.canBasicAttack(attacker, other)) {
53 return;
54 }
55
56 if (attacker.equals(other) || defender.equals(other)) {
57 return;
58 }
59
60 CombatHit hit = nextMeleeHit(attacker, defender);
61 attacker.getCombat().submitHits(other, hit);
62 if (extra != null) extra.add(hit);
63 }
64
65}
Class that models a single animation used by an entity.
Represents a single graphic that can be used by entities.
Definition Graphic.java:10
abstract boolean equals(Object obj)
A collection of util methods and constants related to combat.
static boolean canBasicAttack(Mob attacker, Mob defender)
static void areaAction(Mob mob, Consumer< Mob > action)
Executes an action for mobs within a 3x3 square, including the source mob.
A wrapper for a Hit object, adding additional variables for hit and hitsplat delays.
A Hit object holds the damage amount and hitsplat data.
Definition Hit.java:10
void hitEvent(Player attacker, Mob defender, Mob other, List< Hit > extra)
Definition Dragon2h.java:51
Handles the mob class.
Definition Mob.java:66
final boolean isPlayer()
Check if an entity is a player.
Definition Mob.java:564
Optional< Graphic > graphic
Definition Mob.java:91
This class represents a character controlled by a player.
Definition Player.java:125
Combat< Player > getCombat()
The combat of the mob.
Definition Player.java:759
Represents different priorities for updating.
void drain(Player player)
Drains the special bar for player.
static boolean isIronman(Player player)
Checks if the player is an ironman.