RuneHive-Game
Loading...
Searching...
No Matches
DinhsBulwark.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.Collections;
15import java.util.LinkedList;
16import java.util.List;
17
18/** @author Daniel | Obey */
19public class DinhsBulwark extends PlayerMeleeStrategy {
20 private static final Graphic GRAPHIC = new Graphic(1336, UpdatePriority.HIGH);
21 private static final Animation ANIMATION = new Animation(7511, UpdatePriority.HIGH);
22 private static final DinhsBulwark INSTANCE = new DinhsBulwark();
23
24 private DinhsBulwark() { }
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, 10, 11, other -> hitEvent(attacker, defender, other, extra));
33
34 if (!defender.isPlayer() || !PlayerRight.isIronman(attacker)) {
35 Collections.addAll(extra, hits);
36 addCombatExperience(attacker, extra.toArray(new Hit[extra.size()]));
37 }
38
39 attacker.graphic(GRAPHIC);
40 attacker.animate(ANIMATION, true);
41 }
42
43 @Override
44 public int modifyAccuracy(Player attacker, Mob defender, int roll) {
45 return roll * 6 / 5;
46 }
47
48 private void hitEvent(Player attacker, Mob defender, Mob other, List<Hit> extra) {
49 if (!CombatUtil.canBasicAttack(attacker, other)) {
50 return;
51 }
52
53 if (attacker.equals(other) || defender.equals(other)) {
54 return;
55 }
56
57 CombatHit hit = nextMeleeHit(attacker, defender);
58 attacker.getCombat().submitHits(other, hit);
59 if (extra != null) extra.add(hit);
60 }
61
62 public static DinhsBulwark get() {
63 return INSTANCE;
64 }
65
66}
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)
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.