RuneHive-Game
Loading...
Searching...
No Matches
SaradominGodsword.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.CombatHit;
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
13import static com.runehive.game.world.entity.skill.Skill.HITPOINTS;
14import static com.runehive.game.world.entity.skill.Skill.PRAYER;
15
16/**
17 * Handles the saradomin sword weapon special attack.
18 *
19 * @author Daniel
20 */
22
23 //SGS(normal): 7640, SGS(OR): 7641
24 private static final Animation ANIMATION = new Animation(7640, UpdatePriority.HIGH);
25 private static final Graphic GRAPHIC = new Graphic(1209, UpdatePriority.HIGH);
26
27 private static final SaradominGodsword INSTANCE = new SaradominGodsword();
28
29 @Override
30 public void attack(Player attacker, Mob defender, Hit hit) {
31 super.attack(attacker, defender, hit);
32 attacker.graphic(GRAPHIC);
33 int heal = hit.getDamage() / 2;
34 int prayerRestore = hit.getDamage() / 4;
35
36 Skill skill = attacker.skills.get(HITPOINTS);
37 if (skill.getLevel() < skill.getMaxLevel()) {
38 int level = skill.getLevel() + heal;
39 if (skill.getLevel() + heal > skill.getMaxLevel())
40 level = skill.getMaxLevel();
41 attacker.skills.setLevel(HITPOINTS, level);
42 System.out.println("here");
43 System.out.println("healed " + heal + " hp");
44 }
45
46 skill = attacker.skills.get(PRAYER);
47 if (skill.getLevel() < skill.getMaxLevel()) {
48 int level = skill.getLevel() + prayerRestore;
49 if (skill.getLevel() + prayerRestore > skill.getMaxLevel())
50 level = skill.getMaxLevel();
51 attacker.skills.setLevel(PRAYER, level);
52 System.out.println("here");
53 System.out.println("restored " + prayerRestore + " prayer");
54 }
55 }
56
57 @Override
58 public void hit(Player attacker, Mob defender, Hit hit) {
59 super.hit(attacker, defender, hit);
60 }
61
62 @Override
63 public CombatHit[] getHits(Player attacker, Mob defender) {
64 return new CombatHit[]{nextMeleeHit(attacker, defender)};
65 }
66
67 @Override
68 public Animation getAttackAnimation(Player attacker, Mob defender) {
69 return ANIMATION;
70 }
71
72 @Override
73 public int modifyAccuracy(Player attacker, Mob defender, int roll) {
74 return roll * 2;
75 }
76
77 @Override
78 public int modifyDamage(Player attacker, Mob defender, int damage) {
79 return damage * 11 / 10;
80 }
81
82 public static SaradominGodsword get() {
83 return INSTANCE;
84 }
85
86}
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
Handles the mob class.
Definition Mob.java:66
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
Skill get(int id)
Gets the skill for an id.
void setLevel(int id, int level)
Sets the level of a skill.
Represents different priorities for updating.