RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
Flambleed.java
1package com.osroyale.game.world.entity.combat.attack.listener.npc;
2
3import com.osroyale.net.packet.out.SendMessage;
4import com.osroyale.game.Animation;
5import com.osroyale.game.UpdatePriority;
6import com.osroyale.game.world.entity.combat.attack.listener.NpcCombatListenerSignature;
7import com.osroyale.game.world.entity.combat.attack.listener.SimplifiedListener;
8import com.osroyale.game.world.entity.combat.hit.CombatHit;
9import com.osroyale.game.world.entity.combat.hit.Hit;
10import com.osroyale.game.world.entity.combat.strategy.CombatStrategy;
11import com.osroyale.game.world.entity.combat.strategy.npc.NpcMagicStrategy;
12import com.osroyale.game.world.entity.combat.strategy.npc.NpcMeleeStrategy;
13import com.osroyale.game.world.entity.mob.Mob;
14import com.osroyale.game.world.entity.mob.npc.Npc;
15import com.osroyale.game.world.entity.mob.player.Player;
16import com.osroyale.game.world.items.Item;
17
18import static com.osroyale.game.world.entity.combat.CombatUtil.createStrategyArray;
19import static com.osroyale.game.world.entity.combat.CombatUtil.randomStrategy;
20import static com.osroyale.game.world.entity.combat.projectile.CombatProjectile.getDefinition;
21
25@NpcCombatListenerSignature(npcs = { 4881 })
55
56public class Flambleed extends SimplifiedListener<Npc> {
57
58 private static MagicAttack MAGIC;
59 private static CombatStrategy<Npc>[] STRATEGIES;
60
61 static {
62 try {
63 MAGIC = new MagicAttack();
64 STRATEGIES = createStrategyArray(NpcMeleeStrategy.get(), MAGIC);
65 } catch(Exception e) {
66 e.printStackTrace();
67 }
68 }
69
70 @Override
71 public boolean canAttack(Npc attacker, Mob defender) {
72 if(!NpcMeleeStrategy.get().withinDistance(attacker, defender)) {
73 attacker.setStrategy(MAGIC);
74 }
75 return attacker.getStrategy().canAttack(attacker, defender);
76 }
77
78 @Override
79 public void start(Npc attacker, Mob defender, Hit[] hits) {
80 if(!NpcMeleeStrategy.get().withinDistance(attacker, defender)) {
81 attacker.setStrategy(MAGIC);
82 } else {
83 attacker.setStrategy(randomStrategy(STRATEGIES));
84 }
85 }
86
87 @Override
88 public void hit(Npc attacker, Mob defender, Hit hit) {
89 if (!defender.isPlayer()) {
90 return;
91 }
92 Player player = defender.getPlayer();
93 if (!player.equipment.hasWeapon()) {
94 return;
95 }
96 if (player.equipment.contains(1580)) {
97 return;
98 }
99 Item weapon = player.equipment.getWeapon();
100 player.equipment.unEquip(weapon);
101 player.send(new SendMessage("Flambeeds has removed your weapon since you are not wearing ice gloves."));
102 }
103
104 private static class MagicAttack extends NpcMagicStrategy {
105 private MagicAttack() {
106 super(getDefinition("Flames Of Zamorak"));
107 }
108
109 @Override
110 public Animation getAttackAnimation(Npc attacker, Mob defender) {
111 return new Animation(1750, UpdatePriority.HIGH);
112 }
113
114 @Override
115 public CombatHit[] getHits(Npc attacker, Mob defender) {
116 return new CombatHit[] { nextMagicHit(attacker, defender, combatProjectile) };
117 }
118 }
119}
CombatStrategy< Npc > getStrategy()
Definition Npc.java:198