RuneHive-Game
Loading...
Searching...
No Matches
TridentOfTheSwampStrategy.java
Go to the documentation of this file.
1package com.runehive.game.world.entity.combat.strategy.player.custom;
2
3import com.runehive.Config;
4import com.runehive.game.Animation;
5import com.runehive.game.Graphic;
6import com.runehive.game.UpdatePriority;
7import com.runehive.game.world.entity.combat.CombatType;
8import com.runehive.game.world.entity.combat.attack.FightType;
9import com.runehive.game.world.entity.combat.hit.CombatHit;
10import com.runehive.game.world.entity.combat.hit.Hit;
11import com.runehive.game.world.entity.combat.projectile.CombatProjectile;
12import com.runehive.game.world.entity.combat.strategy.basic.MagicStrategy;
13import com.runehive.game.world.entity.mob.Mob;
14import com.runehive.game.world.entity.mob.player.Player;
15import com.runehive.game.world.entity.mob.player.PlayerRight;
16import com.runehive.game.world.entity.skill.Skill;
17import com.runehive.game.world.items.Item;
18import com.runehive.game.world.items.containers.equipment.Equipment;
19import com.runehive.net.packet.out.SendMessage;
20import com.runehive.util.RandomUtils;
21
22public class TridentOfTheSwampStrategy extends MagicStrategy<Player> {
25
26 static {
27 try {
28 PROJECTILE = CombatProjectile.getDefinition("Trident of the Swamp");
29 } catch (Exception e) {
30 e.printStackTrace();
31 }
32 }
33
34 @Override
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."));
38 return false;
39 }
40
42
43 if (weapon == null) {
44 attacker.getCombat().reset();
45 return false;
46 }
47
48 if (weapon.getId() == 12899 && attacker.tridentSwampCharges < 1) {
49 attacker.send(new SendMessage("Your trident is out of charges!"));
50 attacker.getCombat().reset();
51 return false;
52 }
53
54 return true;
55 }
56
57 @Override
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);
65 }
66
67 if (!defender.isPlayer() || !PlayerRight.isIronman(attacker)) {
68 for (Hit hit : hits) {
69 int exp = 2 * hit.getDamage();
72 }
73 }
74 }
75
76 @Override
77 public void attack(Player attacker, Mob defender, Hit hit) {
78 attacker.tridentSwampCharges--;
79 }
80
81 @Override
82 public void hit(Player attacker, Mob defender, Hit hit) {
83 if (RandomUtils.success(0.25)) {
84 defender.venom();
85 }
86 }
87
88 @Override
89 public Animation getAttackAnimation(Player attacker, Mob defender) {
90 int animation = attacker.getCombat().getFightType().getAnimation();
91 return new Animation(animation, UpdatePriority.HIGH);
92 }
93
94 @Override
95 public int getAttackDelay(Player attacker, Mob defender, FightType fightType) {
96 return attacker.getCombat().getFightType().getDelay();
97 }
98
99 @Override
100 public int getAttackDistance(Player attacker, FightType fightType) {
101 return 10;
102 }
103
104 @Override
105 public CombatHit[] getHits(Player attacker, Mob defender) {
106 int max = 23;
107 int level = attacker.skills.getLevel(Skill.MAGIC);
108 if (level - 75 > 0) {
109 max += (level - 75) / 3;
110 }
111 return new CombatHit[] { nextMagicHit(attacker, defender, max, PROJECTILE) };
112 }
113
114 @Override
116 return CombatType.MAGIC;
117 }
118
119 public static TridentOfTheSwampStrategy get() {
120 return INSTANCE;
121 }
122
123}
The class that contains setting-related constants for the server.
Definition Config.java:24
static final double COMBAT_MODIFICATION
The experience modification for combat.
Definition Config.java:244
Class that models a single animation used by an entity.
Represents a single graphic that can be used by entities.
Definition Graphic.java:10
A wrapper for a Hit object, adding additional variables for hit and hitsplat delays.
A Hit object holds the damage amount and hitsplat data.
Definition Hit.java:10
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.
Handles the mob class.
Definition Mob.java:66
final boolean isPlayer()
Check if an entity is a player.
Definition Mob.java:564
Optional< Graphic > graphic
Definition Mob.java:91
void venom()
Applies venom to the entity.
Definition Mob.java:508
This class represents a character controlled by a player.
Definition Player.java:125
Combat< Player > getCombat()
The combat of the mob.
Definition Player.java:759
Represents a trainable and usable skill.
Definition Skill.java:18
static final int MAGIC
The magic skill id.
Definition Skill.java:39
static final int HITPOINTS
The hitpoints skill id.
Definition Skill.java:30
void addExperience(int id, double experience)
Adds experience to a given skill.
int getLevel(int id)
Gets the level of a skill.
The container class that represents an item that can be interacted with.
Definition Item.java:21
final Item get(int index)
Gets the Item located on index.
The container that manages the equipment for a player.
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.
static boolean isIronman(Player player)
Checks if the player is an ironman.