RuneHive-Game
Loading...
Searching...
No Matches
AhrimListener.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.game.world.entity.skill.Skill;
13import com.runehive.util.Utility;
14
15/**
16 * Handles the Ahrim's armor effects to the assigned npc and item ids.
17 *
18 * @author Daniel
19 */
20@NpcCombatListenerSignature(npcs = {1672})
21@ItemCombatListenerSignature(requireAll = true, items = {4745, 4747, 4749, 4751})
23
24 @Override
25 public void hit(Mob attacker, Mob defender, Hit hit) {
26 if (defender.isPlayer() && hit.getDamage() > 0) {
27 boolean success = Utility.random(100) <= /*20*/95;
28
29 if (!success)
30 return;
31
32 Player player = defender.getPlayer();
33 int strength = player.skills.getLevel(Skill.STRENGTH);
34 int drain = 5;
35
36 strength -= drain;
37
38 if (strength < 0)
39 strength = 0;
40
41 player.skills.setLevel(Skill.STRENGTH, strength);
42 player.send(new SendMessage(drain + "% strength has been drained by " + attacker.getName() + "."));
43 player.graphic(new Graphic(400, UpdatePriority.VERY_HIGH));
44
45 if (attacker.isPlayer()) {
46 attacker.getPlayer().send(new SendMessage("You have drained " + drain +"% of " + defender.getName() + "'s strength level."));
47 }
48 }
49 }
50}
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 Ahrim'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
Represents a trainable and usable skill.
Definition Skill.java:18
static final int STRENGTH
The strength skill id.
Definition Skill.java:27
int getLevel(int id)
Gets the level of a skill.
void setLevel(int id, int level)
Sets the level of a skill.
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.