RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
DragonfireShieldStrategy.java
1package com.osroyale.game.world.entity.combat.strategy.player.custom;
2
3import com.osroyale.Config;
4import com.osroyale.game.Animation;
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.projectile.CombatProjectile;
12import com.osroyale.game.world.entity.combat.strategy.basic.MagicStrategy;
13import com.osroyale.game.world.entity.mob.Mob;
14import com.osroyale.game.world.entity.mob.player.Player;
15import com.osroyale.game.world.entity.skill.Skill;
16
17import static com.osroyale.game.world.entity.combat.CombatUtil.getHitDelay;
18
19public class DragonfireShieldStrategy extends MagicStrategy<Player> {
20 private static final DragonfireShieldStrategy INSTANCE = new DragonfireShieldStrategy();
21 private static CombatProjectile PROJECTILE;
22
23 static {
24 try {
25 PROJECTILE = CombatProjectile.getDefinition("Dragonfire Shield");
26 } catch (Exception e) {
27 e.printStackTrace();
28 }
29 }
30
31 @Override
32 public CombatHit[] getHits(Player attacker, Mob defender) {
33 int hitDelay = getHitDelay(attacker, defender, CombatType.MAGIC) + 2;
34 int hitsplatDelay = 1;
35 return new CombatHit[] { CombatUtil.generateDragonfire(attacker, defender, 25, hitDelay, hitsplatDelay, false) };
36 }
37
38 @Override
39 public boolean canAttack(Player attacker, Mob defender) {
40 if (attacker.dragonfireCharges == 0) {
41 attacker.message("You have no charges to do this!");
42 return false;
43 }
44 return true;
45 }
46
47 @Override
48 public void start(Player attacker, Mob defender, Hit[] hits) {
49 PROJECTILE.getAnimation().ifPresent(animation -> attacker.animate(animation, true));
50 PROJECTILE.getStart().ifPresent(attacker::graphic);
51
52 int damage = 0;
53 for (Hit hit : hits) {
54 damage += hit.getDamage();
55 }
56
57 if (damage > 0) {
58 damage *= Config.COMBAT_MODIFICATION;
59 attacker.skills.addExperience(Skill.DEFENCE, damage / 2);
60 if (defender.isNpc()) {
61 attacker.skills.addExperience(Skill.HITPOINTS, damage / 3);
62 attacker.skills.addExperience(Skill.MAGIC, damage / 2);
63 }
64 }
65 attacker.interact(defender);
66 }
67
68 @Override
69 public void attack(Player attacker, Mob defender, Hit hit) {
70 PROJECTILE.sendProjectile(attacker, defender);
71 attacker.dragonfireCharges--;
72 }
73
74 @Override
75 public void hit(Player attacker, Mob defender, Hit hit) {
76 PROJECTILE.getEnd().ifPresent(defender::graphic);
77 attacker.resetFace();
78 }
79
80 @Override
81 public void hitsplat(Player attacker, Mob defender, Hit hit) {
82 }
83
84 @Override
85 public Animation getAttackAnimation(Player attacker, Mob defender) {
86 return new Animation(6696, UpdatePriority.HIGH);
87 }
88
89 @Override
90 public int getAttackDelay(Player attacker, Mob defender, FightType fightType) {
91 return 5;
92 }
93
94 @Override
95 public int getAttackDistance(Player attacker, FightType fightType) {
96 return 10;
97 }
98
99 @Override
100 public CombatType getCombatType() {
101 return CombatType.MAGIC;
102 }
103
104 public static DragonfireShieldStrategy get() {
105 return INSTANCE;
106 }
107
108}