RuneHive-Game
Loading...
Searching...
No Matches
Blowpipe.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.Projectile;
5import com.runehive.game.world.entity.combat.CombatType;
6import com.runehive.game.world.entity.combat.attack.FightType;
7import com.runehive.game.world.entity.combat.hit.CombatHit;
8import com.runehive.game.world.entity.combat.hit.Hit;
9import com.runehive.game.world.entity.combat.strategy.basic.RangedStrategy;
10import com.runehive.game.world.entity.combat.strategy.player.custom.ToxicBlowpipeStrategy;
11import com.runehive.game.world.entity.mob.Mob;
12import com.runehive.game.world.entity.mob.player.Player;
13import com.runehive.game.world.entity.mob.player.PlayerRight;
14
15public class Blowpipe extends RangedStrategy<Player> {
16 private static final Blowpipe INSTANCE = new Blowpipe();
17 private static final Projectile SPECIAL_PROJ = new Projectile(1043);
18
19 @Override
20 public boolean canAttack(Player attacker, Mob defender) {
21 return ToxicBlowpipeStrategy.get().canAttack(attacker, defender);
22 }
23
24 @Override
25 public void start(Player attacker, Mob defender, Hit[] hits) {
26 attacker.animate(getAttackAnimation(attacker, defender), true);
27 SPECIAL_PROJ.send(attacker, defender);
28
29 if (!defender.isPlayer() || !PlayerRight.isIronman(attacker)) {
30 addCombatExperience(attacker, hits);
31 }
32
33 attacker.getCombatSpecial().drain(attacker);
34 for (Hit hit : hits) {
35 attacker.heal((int) Math.floor(hit.getDamage() / 2));
36 }
37 }
38
39 @Override
40 public void attack(Player attacker, Mob defender, Hit hit) {
41 ToxicBlowpipeStrategy.get().attack(attacker, defender, hit);
42 }
43
44 @Override
45 public Animation getAttackAnimation(Player attacker, Mob defender) {
46 return ToxicBlowpipeStrategy.get().getAttackAnimation(attacker, defender);
47 }
48
49 @Override
50 public int getAttackDelay(Player attacker, Mob defender, FightType fightType) {
51 return ToxicBlowpipeStrategy.get().getAttackDelay(attacker, defender, fightType);
52 }
53
54 @Override
55 public int getAttackDistance(Player attacker, FightType fightType) {
56 return ToxicBlowpipeStrategy.get().getAttackDistance(attacker, fightType);
57 }
58
59 @Override
60 public CombatHit[] getHits(Player attacker, Mob defender) {
61 return new CombatHit[]{nextRangedHit(attacker, defender)};
62 }
63
64 @Override
66 return CombatType.RANGED;
67 }
68
69 public static Blowpipe get() {
70 return INSTANCE;
71 }
72
73}
Class that models a single animation used by an entity.
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
final CombatHit nextRangedHit(T attacker, Mob defender)
void hit(T attacker, Mob defender, Hit hit)
Called when the attacking mob performs an attack on the defender.
int getAttackDelay(Player attacker, Mob defender, FightType fightType)
Definition Blowpipe.java:50
Handles the mob class.
Definition Mob.java:66
final boolean isPlayer()
Check if an entity is a player.
Definition Mob.java:564
This class represents a character controlled by a player.
Definition Player.java:125
The enumerated type whose elements represent the fighting types.
void drain(Player player)
Drains the special bar for player.
static boolean isIronman(Player player)
Checks if the player is an ironman.