RuneHive-Game
Loading...
Searching...
No Matches
GraniteMaul.java
Go to the documentation of this file.
1package com.runehive.game.world.entity.combat.strategy.player.special.melee;
2
3import com.runehive.content.achievement.AchievementHandler;
4import com.runehive.content.achievement.AchievementKey;
5import com.runehive.game.Animation;
6import com.runehive.game.Graphic;
7import com.runehive.game.UpdatePriority;
8import com.runehive.game.world.entity.combat.attack.FightType;
9import com.runehive.game.world.entity.combat.hit.CombatHit;
10import com.runehive.game.world.entity.combat.hit.Hit;
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
15public class GraniteMaul extends PlayerMeleeStrategy {
16 private static final Animation ANIMATION = new Animation(1667, UpdatePriority.HIGH);
17 private static final Graphic GRAPHIC = new Graphic(340);
18 private static final GraniteMaul INSTANCE = new GraniteMaul();
19
20 private GraniteMaul() { }
21
22 @Override
23 public void start(Player attacker, Mob defender, Hit[] hits) {
24 super.start(attacker, defender, hits);
25
26 if (attacker.attributes.is("granite-maul-spec")) {
27 CombatHit damage = nextMeleeHit(attacker, defender);
28 defender.damage(damage);
29 defender.getCombat().getDamageCache().add(attacker, damage);
30 attacker.getCombatSpecial().drain(attacker);
31 attacker.attributes.remove("granite-maul-spec");
32 }
33
34 attacker.graphic(GRAPHIC);
35 }
36
37 @Override
38 public CombatHit[] getHits(Player attacker, Mob defender) {
39 return new CombatHit[] { nextMeleeHit(attacker, defender) };
40 }
41
42 @Override
43 public void onKill(Player attacker, Mob defender, Hit hit) {
44 if (defender.isPlayer()) {
46 }
47 }
48
49 @Override
50 public Animation getAttackAnimation(Player attacker, Mob defender) {
51 return ANIMATION;
52 }
53
54 @Override
55 public int getAttackDelay(Player attacker, Mob defender, FightType fightType) {
56 return attacker.attributes.has("granite-maul-spec") ? 0 : 1;
57 }
58
59 public static GraniteMaul get() {
60 return INSTANCE;
61 }
62
63}
static void activate(Player player, AchievementKey achievement)
Activates the achievement for the individual player.
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 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
int getAttackDelay(Player attacker, Mob defender, FightType fightType)
Handles the mob class.
Definition Mob.java:66
abstract Combat<? extends Mob > getCombat()
The combat of the mob.
final GenericAttributes attributes
Definition Mob.java:95
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
public< K > boolean is(K key)
Gets the state of a key.
public< K > void remove(K key)
Removes a generic attribute.
public< K > boolean has(K key)
Checks if a key is in the list of generic attribute.
Represents different priorities for updating.
The enumerated type whose elements represent the fighting types.
void drain(Player player)
Drains the special bar for player.