RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
TridentOfTheSeasStrategy.java
1package com.osroyale.game.world.entity.combat.strategy.player.custom;
2
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;
20
21public class TridentOfTheSeasStrategy extends MagicStrategy<Player> {
22 private static final TridentOfTheSeasStrategy INSTANCE = new TridentOfTheSeasStrategy();
23 private static CombatProjectile PROJECTILE;
24
25 static {
26 try {
27 PROJECTILE = CombatProjectile.getDefinition("Trident of the Seas");
28 } catch (Exception e) {
29 e.printStackTrace();
30 }
31 }
32
33 @Override
34 public boolean canAttack(Player attacker, Mob defender) {
35 if (defender.isPlayer() && !PlayerRight.isOwner(defender.getPlayer())) {
36 attacker.send(new SendMessage("You can't attack players with this weapon."));
37 return false;
38 }
39
40 Item weapon = attacker.equipment.get(Equipment.WEAPON_SLOT);
41
42 if (weapon == null) {
43 attacker.getCombat().reset();
44 return false;
45 }
46
47 if (weapon.getId() == 11907 && attacker.tridentSeasCharges < 1) {
48 attacker.send(new SendMessage("Your trident is out of charges!"));
49 attacker.getCombat().reset();
50 return false;
51 }
52
53 return true;
54 }
55
56 @Override
57 public void start(Player attacker, Mob defender, Hit[] hits) {
58 PROJECTILE.getAnimation().ifPresent(animation -> attacker.animate(animation, true));
59 PROJECTILE.getStart().ifPresent(attacker::graphic);
60 int projectileDuration = PROJECTILE.sendProjectile(attacker, defender);
61 final Graphic endGraphic = getEndGraphic(PROJECTILE.getEnd(), missed(hits), SPLASH, projectileDuration);
62 if (endGraphic != null) {
63 defender.graphic(endGraphic);
64 }
65
66 if (!defender.isPlayer() || !PlayerRight.isIronman(attacker)) {
67 for (Hit hit : hits) {
68 int exp = 2 * hit.getDamage();
69 attacker.skills.addExperience(Skill.MAGIC, exp * Config.COMBAT_MODIFICATION);
70 attacker.skills.addExperience(Skill.HITPOINTS, exp / 3 * Config.COMBAT_MODIFICATION);
71 }
72 }
73 }
74
75 @Override
76 public void attack(Player attacker, Mob defender, Hit hit) {
77 attacker.tridentSeasCharges--;
78 }
79
80 @Override
81 public void hit(Player attacker, Mob defender, Hit hit) {
82 }
83
84 @Override
85 public Animation getAttackAnimation(Player attacker, Mob defender) {
86 int animation = attacker.getCombat().getFightType().getAnimation();
87 return new Animation(animation, UpdatePriority.HIGH);
88 }
89
90 @Override
91 public int getAttackDelay(Player attacker, Mob defender, FightType fightType) {
92 return attacker.getCombat().getFightType().getDelay();
93 }
94
95 @Override
96 public int getAttackDistance(Player attacker, FightType fightType) {
97 return 10;
98 }
99
100 @Override
101 public CombatHit[] getHits(Player attacker, Mob defender) {
102 int max = 23;
103 int level = attacker.skills.getLevel(Skill.MAGIC);
104 if (level - 75 > 0) {
105 max += (level - 75) / 3;
106 }
107 return new CombatHit[]{nextMagicHit(attacker, defender, max, PROJECTILE)};
108 }
109
110 @Override
111 public CombatType getCombatType() {
112 return CombatType.MAGIC;
113 }
114
115 public static TridentOfTheSeasStrategy get() {
116 return INSTANCE;
117 }
118
119}