1package com.osroyale.game.world.entity.combat.strategy.player.custom;
3import com.osroyale.Config;
4import com.osroyale.game.Animation;
5import com.osroyale.game.Graphic;
6import com.osroyale.game.UpdatePriority;
7import com.osroyale.game.world.entity.combat.CombatType;
8import com.osroyale.game.world.entity.combat.attack.FightType;
9import com.osroyale.game.world.entity.combat.hit.CombatHit;
10import com.osroyale.game.world.entity.combat.hit.Hit;
11import com.osroyale.game.world.entity.combat.projectile.CombatProjectile;
12import com.osroyale.game.world.entity.combat.strategy.basic.MagicStrategy;
13import com.osroyale.game.world.entity.mob.Mob;
14import com.osroyale.game.world.entity.mob.player.Player;
15import com.osroyale.game.world.entity.mob.player.PlayerRight;
16import com.osroyale.game.world.entity.skill.Skill;
17import com.osroyale.game.world.items.Item;
18import com.osroyale.game.world.items.containers.equipment.Equipment;
19import com.osroyale.net.packet.out.SendMessage;
20import com.osroyale.util.RandomUtils;
22public class TridentOfTheSwampStrategy
extends MagicStrategy<Player> {
23 private static final TridentOfTheSwampStrategy INSTANCE =
new TridentOfTheSwampStrategy();
24 private static CombatProjectile PROJECTILE;
28 PROJECTILE = CombatProjectile.getDefinition(
"Trident of the Swamp");
29 }
catch (Exception e) {
35 public boolean canAttack(Player attacker, Mob defender) {
36 if (defender.isPlayer() && !PlayerRight.isOwner(defender.getPlayer())) {
37 attacker.send(
new SendMessage(
"You can't attack players with this weapon."));
41 Item weapon = attacker.equipment.get(Equipment.WEAPON_SLOT);
44 attacker.getCombat().reset();
48 if (weapon.getId() == 12899 && attacker.tridentSwampCharges < 1) {
49 attacker.send(
new SendMessage(
"Your trident is out of charges!"));
50 attacker.getCombat().reset();
58 public void start(Player attacker, Mob defender, Hit[] hits) {
59 PROJECTILE.getAnimation().ifPresent(animation -> attacker.animate(animation,
true));
60 PROJECTILE.getStart().ifPresent(attacker::graphic);
61 int projectileDuration = PROJECTILE.sendProjectile(attacker, defender);
62 final Graphic endGraphic = getEndGraphic(PROJECTILE.getEnd(), missed(hits),
SPLASH, projectileDuration);
63 if (endGraphic !=
null) {
64 defender.graphic(endGraphic);
67 if (!defender.isPlayer() || !PlayerRight.isIronman(attacker)) {
68 for (Hit hit : hits) {
69 int exp = 2 * hit.getDamage();
70 attacker.skills.addExperience(Skill.MAGIC, exp * Config.COMBAT_MODIFICATION);
71 attacker.skills.addExperience(Skill.HITPOINTS, exp / 3 * Config.COMBAT_MODIFICATION);
77 public void attack(Player attacker, Mob defender, Hit hit) {
78 attacker.tridentSwampCharges--;
82 public void hit(Player attacker, Mob defender, Hit hit) {
83 if (RandomUtils.success(0.25)) {
89 public Animation getAttackAnimation(Player attacker, Mob defender) {
90 int animation = attacker.getCombat().getFightType().getAnimation();
91 return new Animation(animation, UpdatePriority.HIGH);
95 public int getAttackDelay(Player attacker, Mob defender, FightType fightType) {
96 return attacker.getCombat().getFightType().getDelay();
100 public int getAttackDistance(Player attacker, FightType fightType) {
105 public CombatHit[] getHits(Player attacker, Mob defender) {
107 int level = attacker.skills.getLevel(Skill.MAGIC);
108 if (level - 75 > 0) {
109 max += (level - 75) / 3;
111 return new CombatHit[] { nextMagicHit(attacker, defender, max, PROJECTILE) };
115 public CombatType getCombatType() {
116 return CombatType.MAGIC;
119 public static TridentOfTheSwampStrategy
get() {
static final Graphic SPLASH