1package com.runehive.game.world.entity.combat.strategy.player;
3import com.runehive.content.itemaction.impl.ThammaronsSceptre;
4import com.runehive.game.Animation;
5import com.runehive.game.Graphic;
6import com.runehive.game.UpdatePriority;
7import com.runehive.game.world.entity.combat.CombatImpact;
8import com.runehive.game.world.entity.combat.CombatType;
9import com.runehive.game.world.entity.combat.attack.FightType;
10import com.runehive.game.world.entity.combat.hit.CombatHit;
11import com.runehive.game.world.entity.combat.hit.Hit;
12import com.runehive.game.world.entity.combat.magic.CombatSpell;
13import com.runehive.game.world.entity.combat.magic.MagicRune;
14import com.runehive.game.world.entity.combat.strategy.basic.MagicStrategy;
15import com.runehive.game.world.entity.mob.Mob;
16import com.runehive.game.world.entity.mob.player.Player;
17import com.runehive.game.world.entity.mob.player.PlayerRight;
18import com.runehive.game.world.entity.skill.Skill;
19import com.runehive.game.world.items.Item;
20import com.runehive.game.world.items.containers.equipment.Equipment;
21import com.runehive.net.packet.out.SendMessage;
22import com.runehive.util.RandomUtils;
24import java.util.Collections;
25import java.util.LinkedList;
27import java.util.function.Consumer;
28import java.util.function.Predicate;
30import static com.runehive.game.world.items.containers.equipment.Equipment.WEAPON_SLOT;
45 attacker.
message(
"You can't attack bots with magic.");
52 attacker.
message(
"This player is already affected by this spell!");
55 }
else if (defender.
isNpc()) {
56 attacker.
message(
"You can't teleblock a npc!");
63 attacker.
message(
"You can not use the crumble undead spell on a player!");
67 if (defender.
isNpc()) {
68 String name = defender.
getName().toLowerCase();
70 if (!(name.contains(
"zombified") || name.contains(
"undead") || name.contains(
"zombie") || name.contains(
"skeleton") || name.contains(
"ghost") || name.contains(
"shade"))) {
71 attacker.
message(
"This spell only affects skeletons, zombies, ghosts and shades");
77 if (
spell.canCast(attacker, defender)) {
81 attacker.
send(
new SendMessage(
"You need some runes to cast this spell."));
88 if (attacker.
getCombat().getDefender() == defender) {
90 spell.getStart().ifPresent(attacker::graphic);
92 int projectileDuration =
spell.sendProjectile(attacker, defender);
93 if (projectileDuration == 0) {
95 final int duration = distance * 10;
96 projectileDuration = 51 + duration;
100 if (endGraphic !=
null) {
104 if (
spell.getEffect().isPresent()) {
105 List<Hit> extra =
new LinkedList<>();
107 Predicate<CombatImpact> filter =
effect ->
effect.canAffect(attacker, defender,
hit);
108 Consumer<CombatImpact> execute =
effect ->
effect.impact(attacker, defender,
hit, extra);
109 spell.getEffect().filter(filter).ifPresent(execute);
113 if (extra.isEmpty()) {
114 Collections.addAll(extra, hits);
155 if (
hit.isAccurate()) {
189 if (
spell.getAnimation().isPresent()) {
190 return spell.getAnimation().get();
198 animation =
weapon.getAttackAnimation(fightType).orElse(animation);
203 animation =
weapon.getAttackAnimation(fightType).orElse(animation);
static final short THAMMARONS_SCEPTRE_CHARGED_ID
Class that models a single animation used by an entity.
Represents a single graphic that can be used by entities.
abstract String getName()
Gets the name of this 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.
void setDamage(int damage)
Sets the hit damage.
static boolean missed(final Hit... hits)
final CombatHit nextMagicHit(T attacker, Mob defender)
static Graphic getEndGraphic(final CombatProjectile combatProjectile, final boolean splash, final Graphic splashGraphic)
static final Graphic SPLASH
The spell splash graphic.
static void addCombatExperience(Player player, double base, Hit... hits)
void hitsplat(Player attacker, Mob defender, Hit hit)
void hit(Player attacker, Mob defender, Hit hit)
boolean canAttack(Player attacker, Mob defender)
int getAttackDistance(Player attacker, FightType fightType)
Animation getAttackAnimation(Player attacker, Mob defender)
CombatType getCombatType()
CombatHit[] getHits(Player attacker, Mob defender)
final CombatSpell spell
The magic spell definition.
void start(Player attacker, Mob defender, Hit[] hits)
PlayerMagicStrategy(CombatSpell spell)
Constructs a new SpellStrategy from a CombatSpell.
int getAttackDelay(Player attacker, Mob defender, FightType fightType)
final SkillManager skills
void interact(Mob mob)
Sets the mob interacting with another mob.
void animate(int animation)
final boolean isNpc()
Check if an entity is an npc.
final boolean isPlayer()
Check if an entity is a player.
void resetFace()
Resets the mob's face location.
Optional< Graphic > graphic
void venom()
Applies venom to the entity.
This class represents a character controlled by a player.
void message(String message)
final Equipment equipment
void setSingleCast(CombatSpell singleCast)
int thammoranSceptreCharges
void send(OutgoingPacket encoder)
Combat< Player > getCombat()
The combat of the mob.
Represents a trainable and usable skill.
static final int MAGIC
The magic skill id.
void addExperience(int id, double experience)
Adds experience to a given skill.
The container class that represents an item that can be interacted with.
final Item get(int index)
Gets the Item located on index.
final Optional< Item > retrieve(int index)
Retrieves the item located on index.
final boolean containsAny(int... identifiers)
Determines if this container contains any identifiers.
The container that manages the equipment for a player.
static final int WEAPON_SLOT
int getChebyshevDistance(Position other)
The OutgoingPacket that sends a message to a Players chatbox in the client.
A static-util class that provides additional functionality for generating pseudo-random numbers.
static boolean success(double value)
Determines if a pseudorandomly generated double rounded to two decimal places is below or equal to va...
Represents different priorities for updating.
The enumerated type whose elements represent the fighting types.
final int getAnimation()
Gets the animation executed when this type is active.
static void remove(Player player, Item[] required)
Holds all the player right data.
static boolean isOwner(Player player)
static boolean isIronman(Player player)
Checks if the player is an ironman.