RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
ScytheOfViturStrategy.java
1package com.osroyale.game.world.entity.combat.strategy.player.custom;
2
3import com.osroyale.game.Animation;
4import com.osroyale.game.Graphic;
5import com.osroyale.game.UpdatePriority;
6import com.osroyale.game.world.entity.combat.CombatType;
7import com.osroyale.game.world.entity.combat.CombatUtil;
8import com.osroyale.game.world.entity.combat.attack.FightType;
9import com.osroyale.game.world.entity.combat.hit.CombatHit;
10import com.osroyale.game.world.entity.combat.hit.Hit;
11import com.osroyale.game.world.entity.combat.strategy.basic.MeleeStrategy;
12import com.osroyale.game.world.entity.mob.Mob;
13import com.osroyale.game.world.entity.mob.player.Player;
14import com.osroyale.game.world.items.Item;
15import com.osroyale.game.world.items.containers.equipment.Equipment;
16import com.osroyale.game.world.position.Position;
17
18public class ScytheOfViturStrategy extends MeleeStrategy<Player> {
19
20 private static final ScytheOfViturStrategy INSTANCE = new ScytheOfViturStrategy();
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) {
27 Item weapon = attacker.equipment.get(Equipment.WEAPON_SLOT);
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
55 public CombatType getCombatType() {
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}