RuneHive-Game
Loading...
Searching...
No Matches
DragonWarhammer.java
Go to the documentation of this file.
1package com.runehive.game.world.entity.combat.strategy.player.special.melee;
2
3import com.runehive.game.Animation;
4import com.runehive.game.Graphic;
5import com.runehive.game.UpdatePriority;
6import com.runehive.game.world.entity.combat.attack.FightType;
7import com.runehive.game.world.entity.combat.hit.Hit;
8import com.runehive.game.world.entity.combat.strategy.player.PlayerMeleeStrategy;
9import com.runehive.game.world.entity.mob.Mob;
10import com.runehive.game.world.entity.mob.player.Player;
11import com.runehive.game.world.entity.skill.Skill;
12
13/** @author Daniel | Obey */
15 private static final Animation ANIMATION = new Animation(1378, UpdatePriority.HIGH);
16 private static final Graphic GRAPHIC = new Graphic(1292);
17 private static final DragonWarhammer INSTANCE = new DragonWarhammer();
18
19 private DragonWarhammer() {
20 }
21
22 @Override
23 public void start(Player attacker, Mob defender, Hit[] hits) {
24 super.start(attacker, defender, hits);
25 attacker.graphic(GRAPHIC);
26 }
27
28 @Override
29 public void attack(Player attacker, Mob defender, Hit h) {
30 super.attack(attacker, defender, h);
31
32 if (h.getDamage() > 0) {
33 Skill skill = defender.skills.get(Skill.DEFENCE);
34 int level = skill.getLevel();
35 int reduction = (int) (level * 0.30);
36
37 defender.skills.get(skill.getSkill()).removeLevel(reduction);
38 defender.skills.refresh(skill.getSkill());
39
40 attacker.message("You've drained " + defender.getName() + "'s defence level by 30%.");
41
42 if (defender.isPlayer()) {
43 defender.getPlayer().message("Your defence level has been drained by 30%.");
44 }
45 }
46 }
47
48 @Override
49 public int getAttackDelay(Player attacker, Mob defender, FightType fightType) {
50 return 4;
51 }
52
53 @Override
54 public Animation getAttackAnimation(Player attacker, Mob defender) {
55 return ANIMATION;
56 }
57
58 @Override
59 public int modifyDamage(Player attacker, Mob defender, int damage) {
60 return damage * 3 / 2;
61 }
62
63 public static DragonWarhammer get() {
64 return INSTANCE;
65 }
66
67}
Class that models a single animation used by an entity.
Represents a single graphic that can be used by entities.
Definition Graphic.java:10
abstract String getName()
Gets the name of this entity.
A Hit object holds the damage amount and hitsplat data.
Definition Hit.java:10
int getDamage()
Gets the damage amount.
Definition Hit.java:121
int getAttackDelay(Player attacker, Mob defender, FightType fightType)
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 DEFENCE
The defence skill id.
Definition Skill.java:24
void removeLevel(int amount)
Removes levels from this skill by the given amount.
Definition Skill.java:325
Skill get(int id)
Gets the skill for an id.
void refresh()
Refreshes all the skills for the mob.
Represents different priorities for updating.
The enumerated type whose elements represent the fighting types.