RuneHive-Game
Loading...
Searching...
No Matches
MagicShortbow.java
Go to the documentation of this file.
1package com.runehive.game.world.entity.combat.strategy.player.special.range;
2
3import com.runehive.game.Animation;
4import com.runehive.game.Graphic;
5import com.runehive.game.Projectile;
6import com.runehive.game.UpdatePriority;
7import com.runehive.game.world.entity.combat.hit.CombatHit;
8import com.runehive.game.world.entity.combat.projectile.CombatProjectile;
9import com.runehive.game.world.entity.combat.strategy.player.PlayerRangedStrategy;
10import com.runehive.game.world.entity.mob.Mob;
11import com.runehive.game.world.entity.mob.player.Player;
12
13/**
14 * Handles the magic shortbow weapon special attack.
15 *
16 * @author Daniel
17 * @author Michaael | Chex
18 */
19public class MagicShortbow extends PlayerRangedStrategy {
20
21 private static final MagicShortbow INSTANCE = new MagicShortbow();
22 private static final Animation ANIMATION = new Animation(1074, UpdatePriority.HIGH);
23 private static Projectile PROJECTILE_1;
24 private static Projectile PROJECTILE_2;
25
26 static {
27 try {
29 } catch (Exception e) {
30 e.printStackTrace();
31 }
32 }
33
34 private MagicShortbow() {
35 }
36
37 @Override
38 protected void sendStuff(Player attacker, Mob defender) {
39 attacker.animate(ANIMATION, true);
40 attacker.graphic(new Graphic(256, 30, 92));
41 PROJECTILE_1.send(attacker, defender);
42 PROJECTILE_2.send(attacker, defender);
43 }
44
45 @Override
46 public CombatHit[] getHits(Player attacker, Mob defender) {
47 return new CombatHit[] { nextRangedHit(attacker, defender), nextRangedHit(attacker, defender) };
48 }
49
50 @Override
51 public int modifyAccuracy(Player attacker, Mob defender, int roll) {
52 return roll - roll / 4;
53 }
54
56 if (!projectile.getProjectile().isPresent())
57 throw new NullPointerException("No Magic Shortbow projectile found.");
58 PROJECTILE_1 = projectile.getProjectile().get();
60 final int delay = 30 + PROJECTILE_1.getDelay();
61 PROJECTILE_2.setDelay(delay);
62 PROJECTILE_2.setDuration(20 + PROJECTILE_1.getDuration());
63 }
64
65 public static MagicShortbow get() {
66 return INSTANCE;
67 }
68
69}
Class that models a single animation used by an entity.
Represents a single graphic that can be used by entities.
Definition Graphic.java:10
A wrapper for a Hit object, adding additional variables for hit and hitsplat delays.
final CombatHit nextRangedHit(T attacker, Mob defender)
Handles the mob class.
Definition Mob.java:66
Optional< Graphic > graphic
Definition Mob.java:91
This class represents a character controlled by a player.
Definition Player.java:125
Represents different priorities for updating.