1package com.osroyale.game.world.entity.combat.strategy.player.custom;
3import com.osroyale.game.Animation;
4import com.osroyale.game.UpdatePriority;
5import com.osroyale.game.world.entity.combat.CombatType;
6import com.osroyale.game.world.entity.combat.attack.FightType;
7import com.osroyale.game.world.entity.combat.effect.impl.CombatPoisonEffect;
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.ranged.RangedAmmunition;
11import com.osroyale.game.world.entity.combat.strategy.basic.RangedStrategy;
12import com.osroyale.game.world.entity.mob.Mob;
13import com.osroyale.game.world.entity.mob.player.Player;
14import com.osroyale.game.world.entity.mob.player.PlayerRight;
15import com.osroyale.game.world.items.Item;
16import com.osroyale.game.world.items.containers.equipment.Equipment;
17import com.osroyale.game.world.items.ground.GroundItem;
18import com.osroyale.game.world.position.Area;
19import com.osroyale.game.world.position.Position;
20import com.osroyale.net.packet.out.SendMessage;
21import com.osroyale.util.RandomUtils;
25 private static final ToxicBlowpipeStrategy INSTANCE =
new ToxicBlowpipeStrategy();
28 public boolean canAttack(Player attacker, Mob defender) {
29 Item weapon = attacker.equipment.get(Equipment.WEAPON_SLOT);
32 attacker.getCombat().reset();
36 Item ammo = attacker.blowpipeDarts;
42 RangedAmmunition ammu = RangedAmmunition.find(
null, ammo);
43 if (ammu ==
null || !ammu.isDart()) {
44 attacker.message(
"Your blowpipe is not using darts for ammunition!");
48 if (ammo.getAmount() >= 1) {
49 if (attacker.blowpipeScales >= 3) {
52 attacker.send(
new SendMessage(
"Your blowpipe requires more scales!"));
54 attacker.send(
new SendMessage(
"You need some ammunition to use this weapon!"));
57 attacker.getCombat().reset();
62 public void start(Player attacker, Mob defender, Hit[] hits) {
63 if (attacker.isSpecialActivated()) {
64 attacker.getCombatSpecial().drain(attacker);
67 if (attacker.getCombat().getDefender() == defender) {
68 attacker.animate(getAttackAnimation(attacker, defender),
true);
69 attacker.rangedAmmo.sendProjectile(attacker, defender);
71 if (!defender.isPlayer() || !PlayerRight.isIronman(attacker)) {
72 addCombatExperience(attacker, hits);
78 public void attack(Player attacker, Mob defender, Hit
hit) {
79 Item darts = attacker.blowpipeDarts;
80 removeAmmunition(attacker, defender);
82 if (
hit.getDamage() > 1) {
83 if (RandomUtils.success(0.25)) {
86 CombatPoisonEffect.getPoisonType(darts).ifPresent(defender::poison);
92 public Animation getAttackAnimation(Player attacker, Mob defender) {
93 int animation = attacker.getCombat().getFightType().getAnimation();
94 return new Animation(animation, UpdatePriority.HIGH);
98 public int getAttackDelay(Player attacker, Mob defender, FightType fightType) {
99 int delay = attacker.getCombat().getFightType().getDelay();
100 if (defender.isNpc())
106 public int getAttackDistance(Player attacker, FightType fightType) {
107 return fightType.getDistance();
111 public CombatHit[] getHits(Player attacker, Mob defender) {
112 return new CombatHit[]{nextRangedHit(attacker, defender)};
116 public CombatType getCombatType() {
117 return CombatType.RANGED;
120 private void removeAmmunition(Player attacker, Mob defender) {
121 Item darts = attacker.blowpipeDarts;
122 attacker.blowpipeScales -= 1.5f;
123 if (RandomUtils.success(0.80)) {
124 if (Equipment.hasAssembler(attacker)) {
128 else if (Equipment.hasAccumulator(attacker) && RandomUtils.success(0.90)) {
132 if (Equipment.hasAttractor(attacker) && RandomUtils.success(0.80)) {
136 Position dropPoisition = defender.getPosition();
138 if (Area.inKraken(attacker) || Area.inZulrah(attacker)) {
139 dropPoisition = attacker.getPosition();
141 darts.decrementAmount();
142 GroundItem.create(attacker, darts.createWithAmount(1), dropPoisition);
145 if (darts.getAmount() == 0) {
146 attacker.send(
new SendMessage(
"That was the last of your ammunition!"));
147 attacker.blowpipeDarts =
null;
150 if (attacker.blowpipeScales == 0) {
151 attacker.send(
new SendMessage(
"Your blowpipe has run out of charges!"));
155 public static ToxicBlowpipeStrategy
get() {
void hit(T attacker, Mob defender, Hit hit)