RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
MagicShortbow.java
1package com.osroyale.game.world.entity.combat.strategy.player.special.range;
2
3import com.osroyale.game.Animation;
4import com.osroyale.game.Graphic;
5import com.osroyale.game.Projectile;
6import com.osroyale.game.UpdatePriority;
7import com.osroyale.game.world.entity.combat.hit.CombatHit;
8import com.osroyale.game.world.entity.combat.projectile.CombatProjectile;
9import com.osroyale.game.world.entity.combat.strategy.player.PlayerRangedStrategy;
10import com.osroyale.game.world.entity.mob.Mob;
11import com.osroyale.game.world.entity.mob.player.Player;
12
47
48public class MagicShortbow extends PlayerRangedStrategy {
49
50 private static final MagicShortbow INSTANCE = new MagicShortbow();
51 private static final Animation ANIMATION = new Animation(1074, UpdatePriority.HIGH);
52 private static Projectile PROJECTILE_1;
53 private static Projectile PROJECTILE_2;
54
55 static {
56 try {
57 setProjectiles(CombatProjectile.getDefinition("Magic Shortbow"));
58 } catch (Exception e) {
59 e.printStackTrace();
60 }
61 }
62
63 private MagicShortbow() {
64 }
65
66 @Override
67 protected void sendStuff(Player attacker, Mob defender) {
68 attacker.animate(ANIMATION, true);
69 attacker.graphic(new Graphic(256, 30, 92));
70 PROJECTILE_1.send(attacker, defender);
71 PROJECTILE_2.send(attacker, defender);
72 }
73
74 @Override
75 public CombatHit[] getHits(Player attacker, Mob defender) {
76 return new CombatHit[] { nextRangedHit(attacker, defender), nextRangedHit(attacker, defender) };
77 }
78
79 @Override
80 public int modifyAccuracy(Player attacker, Mob defender, int roll) {
81 return roll - roll / 4;
82 }
83
84 private static void setProjectiles(CombatProjectile projectile) {
85 if (!projectile.getProjectile().isPresent())
86 throw new NullPointerException("No Magic Shortbow projectile found.");
87 PROJECTILE_1 = projectile.getProjectile().get();
88 PROJECTILE_2 = PROJECTILE_1.copy();
89 final int delay = 30 + PROJECTILE_1.getDelay();
90 PROJECTILE_2.setDelay(delay);
91 PROJECTILE_2.setDuration(20 + PROJECTILE_1.getDuration());
92 }
93
94 public static MagicShortbow get() {
95 return INSTANCE;
96 }
97
98}