RuneHive-Game
Loading...
Searching...
No Matches
ToragListener.java
Go to the documentation of this file.
1package com.runehive.game.world.entity.combat.attack.listener.item;
2
3import com.runehive.net.packet.out.SendMessage;
4import com.runehive.game.Graphic;
5import com.runehive.game.UpdatePriority;
6import com.runehive.game.world.entity.combat.attack.listener.ItemCombatListenerSignature;
7import com.runehive.game.world.entity.combat.attack.listener.NpcCombatListenerSignature;
8import com.runehive.game.world.entity.combat.attack.listener.SimplifiedListener;
9import com.runehive.game.world.entity.combat.hit.Hit;
10import com.runehive.game.world.entity.mob.Mob;
11import com.runehive.game.world.entity.mob.player.Player;
12import com.runehive.util.Utility;
13
14/**
15 * Handles the Torag's armor effects to the assigned npc and item ids.
16 *
17 * @author Daniel
18 */
19@NpcCombatListenerSignature(npcs = {1676})
20@ItemCombatListenerSignature(requireAll = true, items = {4745, 4747, 4749, 4751})
22
23 @Override
24 public void hit(Mob attacker, Mob defender, Hit hit) {
25 if (defender.isPlayer() && hit.getDamage() > 1) {
26 boolean success = Utility.random(100) <= 25;
27
28 if (!success)
29 return;
30
31 Player player = defender.getPlayer();
32 int energy = player.runEnergy;
33 int drain = energy < 50 ? 10 : 20;
34
35 energy -= drain;
36
37 if (energy < 0)
38 energy = 0;
39
40 player.runEnergy = energy;
41 player.send(new SendMessage(drain + "% run energy has been drained by " + attacker.getName() + "."));
42 player.graphic(new Graphic(399, UpdatePriority.VERY_HIGH));
43
44 if (attacker.isPlayer()) {
45 attacker.getPlayer().send(new SendMessage("You have drained " + drain +"% of " + defender.getName() + "'s run energy."));
46 }
47 }
48
49 super.hit(attacker, defender, hit);
50 }
51}
Represents a single graphic that can be used by entities.
Definition Graphic.java:10
abstract String getName()
Gets the name of this entity.
Handles the Torag's armor effects to the assigned npc and item ids.
A Hit object holds the damage amount and hitsplat data.
Definition Hit.java:10
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
This class represents a character controlled by a player.
Definition Player.java:125
The OutgoingPacket that sends a message to a Players chatbox in the client.
Handles miscellaneous methods.
Definition Utility.java:27
static int random(int bound)
Definition Utility.java:239
Represents different priorities for updating.