RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
DragonSpear.java
1package com.osroyale.game.world.entity.combat.strategy.player.special.melee;
2
3import com.osroyale.game.Animation;
4import com.osroyale.game.Graphic;
5import com.osroyale.game.UpdatePriority;
6import com.osroyale.game.world.entity.combat.hit.CombatHit;
7import com.osroyale.game.world.entity.combat.hit.Hit;
8import com.osroyale.game.world.entity.combat.strategy.player.PlayerMeleeStrategy;
9import com.osroyale.game.world.entity.mob.Direction;
10import com.osroyale.game.world.entity.mob.Mob;
11import com.osroyale.game.world.entity.mob.data.LockType;
12import com.osroyale.game.world.entity.mob.player.Player;
13import com.osroyale.game.world.pathfinding.TraversalMap;
14import com.osroyale.game.world.position.Position;
15import com.osroyale.net.packet.out.SendMessage;
16
48
49public class DragonSpear extends PlayerMeleeStrategy {
50 private static final DragonSpear INSTANCE = new DragonSpear();
51 private static final Animation ANIMATION = new Animation(1064, UpdatePriority.HIGH);
52 private static final Graphic GRAPHIC = new Graphic(253, true, UpdatePriority.HIGH);
53
54 @Override
55 public boolean canAttack(Player attacker, Mob defender) {
56 if (defender.isPlayer() && defender.width() > 1 && defender.length() > 1) {
57 attacker.send(new SendMessage("That creature is too large to knock back!"));
58 return false;
59 }
60
61 Direction direction = Direction.getDirection(attacker.getPosition(), defender.getPosition());
62
63 if (!TraversalMap.isTraversable(defender.getPosition(), direction, false)) {
64 attacker.send(new SendMessage("That entity can not be knocked back as something is blocking it!"));
65 return false;
66 }
67
68 return super.canAttack(attacker, defender);
69 }
70
71 @Override
72 public void hit(Player attacker, Mob defender, Hit hit) {
73 super.hit(attacker, defender, hit);
74
75 Direction direction = Direction.getDirection(attacker.getPosition(), defender.getPosition());
76 Position position = defender.getPosition().transform(direction.getFaceLocation());
77
78 hit.setDamage(-1);
79 attacker.graphic(GRAPHIC);
80 defender.movement.reset();
81 defender.getCombat().clearIncoming();
82
83 defender.locking.lock(3, LockType.STUN);
84 defender.movement.walkTo(position);
85 }
86
87 @Override
88 public CombatHit[] getHits(Player attacker, Mob defender) {
89 return new CombatHit[] { nextMeleeHit(attacker, defender) };
90 }
91
92 @Override
93 public Animation getAttackAnimation(Player attacker, Mob defender) {
94 return ANIMATION;
95 }
96
97 public static DragonSpear get() {
98 return INSTANCE;
99 }
100
101}
abstract Combat<? extends Mob > getCombat()
static boolean isTraversable(Position from, Direction direction, int size)
Position transform(int diffX, int diffY, int diffZ)
static Direction getDirection(int deltaX, int deltaY)