RuneHive-Game
Loading...
Searching...
No Matches
ScytheOfViturStrategy.java
Go to the documentation of this file.
1package com.runehive.game.world.entity.combat.strategy.player.custom;
2
3import com.runehive.game.Animation;
4import com.runehive.game.Graphic;
5import com.runehive.game.UpdatePriority;
6import com.runehive.game.world.entity.combat.CombatType;
7import com.runehive.game.world.entity.combat.CombatUtil;
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.basic.MeleeStrategy;
12import com.runehive.game.world.entity.mob.Mob;
13import com.runehive.game.world.entity.mob.player.Player;
14import com.runehive.game.world.items.Item;
15import com.runehive.game.world.items.containers.equipment.Equipment;
16import com.runehive.game.world.position.Position;
17
18public class ScytheOfViturStrategy extends MeleeStrategy<Player> {
19
21
22 private static final Animation ANIMATION = new Animation(8056, UpdatePriority.HIGH);
23 private static final Graphic GRAPHIC = new Graphic(506);
24
25 @Override
26 public boolean canAttack(Player attacker, Mob defender) {
28
29 if (weapon == null) {
30 attacker.getCombat().reset();
31 return false;
32 }
33
34 return true;
35 }
36
37 @Override
38 public void start(Player attacker, Mob defender, Hit[] hits) {
39 super.start(attacker, defender, hits);
40 attacker.animate(ANIMATION, true);
41
42 CombatUtil.areaAction(attacker, 3, 1, other -> hitEvent(attacker, defender, other));
43 //attacker.graphic(GRAPHIC);
44 }
45
46 @Override
47 public void attack(Player attacker, Mob defender, Hit hit) { }
48
49 @Override
50 public Animation getAttackAnimation(Player attacker, Mob defender) {
51 return ANIMATION;
52 }
53
54 @Override
56 return CombatType.MELEE;
57 }
58
59 @Override
60 public int getAttackDistance(Player attacker, FightType fightType) {
61 return 1;
62 }
63
64 @Override
65 public CombatHit[] getHits(Player attacker, Mob defender) {
66 return new CombatHit[]{ nextMeleeHit(attacker, defender) };
67 }
68
69 @Override
70 public int getAttackDelay(Player attacker, Mob defender, FightType fightType) {
71 return attacker.getCombat().getFightType().getDelay();
72 }
73
74 public static ScytheOfViturStrategy get() {
75 return INSTANCE;
76 }
77
78 private void hitEvent(Player attacker, Mob defender, Mob other) {
79 if (!CombatUtil.canBasicAttack(attacker, other)) {
80 return;
81 }
82
83 if (attacker.equals(other) || defender.equals(other)) {
84 return;
85 }
86
87 if(!Position.isWithinDiagonalDistance(attacker, other, 1) || defender.getPosition().equals(other.getPosition())) {
88 return;
89 }
90
91 CombatHit hit = nextMeleeHit(attacker, other);
92 other.damage(hit);
93 other.getCombat().attack(attacker);
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
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 hit(T attacker, Mob defender, Hit hit)
Called when the attacking mob performs an attack on the defender.
Handles the mob class.
Definition Mob.java:66
abstract Combat<? extends Mob > getCombat()
The combat of the mob.
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
The container class that represents an item that can be interacted with.
Definition Item.java:21
final Item get(int index)
Gets the Item located on index.
The container that manages the equipment for a player.
Represents a single tile on the game world.
Definition Position.java:14
static boolean isWithinDiagonalDistance(Mob attacker, Mob defender, int distance)
Represents different priorities for updating.
The enumerated type whose elements represent the fighting types.