RuneHive-Game
Loading...
Searching...
No Matches
BandosGodsword.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.hit.Hit;
7import com.runehive.game.world.entity.combat.strategy.player.PlayerMeleeStrategy;
8import com.runehive.game.world.entity.mob.Mob;
9import com.runehive.game.world.entity.mob.player.Player;
10import com.runehive.game.world.entity.skill.Skill;
11
12/**
13 * @author Michael | Chex
14 */
15public class BandosGodsword extends PlayerMeleeStrategy {
16
17 //BGS(normal): 7642, BGS(OR): 7643
18 private static final Animation ANIMATION = new Animation(7642, UpdatePriority.HIGH);
19 private static final Graphic GRAPHIC = new Graphic(1212);
20
21 private static final BandosGodsword INSTANCE = new BandosGodsword();
22
23 private BandosGodsword() { }
24
25 @Override
26 public void start(Player attacker, Mob defender, Hit[] hits) {
27 super.start(attacker, defender, hits);
28 }
29
30 @Override
31 public void attack(Player attacker, Mob defender, Hit h) {
32 super.attack(attacker, defender, h);
33 attacker.graphic(GRAPHIC);
34
35 if (h.isAccurate()) {
36 int damage = h.getDamage();
38
39 for (int s : skillOrder) {
40
41 //Getting the skill value to decrease.
42 int removeFromSkill;
43
44 if (h.getDamage() > defender.skills.getLevel(s)) {
45 int difference = damage - defender.skills.getLevel(s);
46 removeFromSkill = damage - difference;
47 } else
48 removeFromSkill = damage;
49
50 //Decreasing the skill.
51 defender.skills.get(s).removeLevel(removeFromSkill);
52 defender.skills.refresh(s);
53
54 //Changing the damage left to decrease.
55 damage -= removeFromSkill;
56 String skill = Skill.getName(s);
57
58 if (defender.isPlayer()) {
59 defender.getPlayer().message("Your " + skill + " level has been drained.");
60 }
61 }
62 }
63 }
64
65 @Override
66 public Animation getAttackAnimation(Player attacker, Mob defender) {
67 return ANIMATION;
68 }
69
70 @Override
71 public int modifyAccuracy(Player attacker, Mob defender, int roll) {
72 return 2 * roll;
73 }
74
75 @Override
76 public int modifyDamage(Player attacker, Mob defender, int damage) {
77 return (int) (damage * 1.21);
78 }
79
80 public static BandosGodsword get() {
81 return INSTANCE;
82 }
83
84}
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 Hit object holds the damage amount and hitsplat data.
Definition Hit.java:10
int getDamage()
Gets the damage amount.
Definition Hit.java:121
boolean isAccurate()
Checks if the hit is accurate.
Definition Hit.java:148
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 String getName(int skill)
Gets the name for a skill id.
Definition Skill.java:465
static final int PRAYER
The prayer skill id.
Definition Skill.java:36
static final int RANGED
The ranged skill id.
Definition Skill.java:33
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
static final int MAGIC
The magic skill id.
Definition Skill.java:39
static final int ATTACK
The attack skill id.
Definition Skill.java:21
static final int STRENGTH
The strength skill id.
Definition Skill.java:27
int getLevel(int id)
Gets the level of a skill.
Skill get(int id)
Gets the skill for an id.
void refresh()
Refreshes all the skills for the mob.
Represents different priorities for updating.