RuneHive-Game
Loading...
Searching...
No Matches
DemonicGorillas.java
Go to the documentation of this file.
1package com.runehive.game.world.entity.combat.strategy.npc.boss;
2
3import com.runehive.game.Animation;
4import com.runehive.game.UpdatePriority;
5import com.runehive.game.world.entity.combat.CombatType;
6import com.runehive.game.world.entity.combat.attack.FightType;
7import com.runehive.game.world.entity.combat.hit.CombatHit;
8import com.runehive.game.world.entity.combat.hit.Hit;
9import com.runehive.game.world.entity.combat.strategy.CombatStrategy;
10import com.runehive.game.world.entity.combat.strategy.npc.MultiStrategy;
11import com.runehive.game.world.entity.combat.strategy.npc.NpcMagicStrategy;
12import com.runehive.game.world.entity.combat.strategy.npc.NpcMeleeStrategy;
13import com.runehive.game.world.entity.combat.strategy.npc.NpcRangedStrategy;
14import com.runehive.game.world.entity.mob.Mob;
15import com.runehive.game.world.entity.mob.npc.Npc;
16import com.runehive.game.world.entity.mob.prayer.Prayer;
17import com.runehive.util.RandomUtils;
18import com.runehive.util.Utility;
19
20import java.util.HashSet;
21import java.util.Set;
22
23import static com.runehive.game.world.entity.combat.CombatUtil.createStrategyArray;
24import static com.runehive.game.world.entity.combat.CombatUtil.randomStrategy;
25import static com.runehive.game.world.entity.combat.projectile.CombatProjectile.getDefinition;
26
27/**
28 * Created by Daniel on 2017-11-29.
29 */
30public class DemonicGorillas extends MultiStrategy {
31 private static final Melee MELEE = new Melee();
32 private static final Magic MAGIC = new Magic();
33 private static final Ranged RANGED = new Ranged();
34 private static final CombatStrategy<Npc>[] STRATEGIES = createStrategyArray(MAGIC, MELEE, RANGED);
35 private static final Integer[] FORMS = { 7147, 7148, 7149 };
36 private int attackCount = 0;
37 private int damageDealt = 0;
38 private int form = -1;
39
40 public DemonicGorillas() {
41 this.currentStrategy = randomStrategy(STRATEGIES);
42 }
43
47
48 private int getNextForm() {
50 }
51
52 @Override
53 public void block(Mob attacker, Npc defender, Hit hit, CombatType combatType) {
54 int nextForm = -1;
55
56 if (form == -1) {
57 nextForm = defender.id;
58 }
59
60 damageDealt += hit.getDamage();
61 if (damageDealt >= 50) {
62 nextForm = getNextForm();
63 damageDealt = 0;
64 attackCount = 0;
65 }
66
67 if (nextForm > -1) {
68 defender.transform(nextForm);
69 form = nextForm;
70
71 if (form == 7147 && !defender.prayer.isActive(Prayer.PROTECT_FROM_MELEE)) {
73 } else if (form == 7148 && !defender.prayer.isActive(Prayer.PROTECT_FROM_RANGE)) {
75 } else if (form == 7149 && !defender.prayer.isActive(Prayer.PROTECT_FROM_MAGIC)) {
77 }
78 }
79 }
80
81 @Override
82 public void hit(Npc attacker, Mob defender, Hit hit) {
83 super.hit(attacker, defender, hit);
84 if (hit.getDamage() == 0) {
86 if (attackCount >= 3) {
88 attackCount = 0;
89 }
90 }
91 }
92
93 @Override
94 public int modifyDefensive(Mob attacker, Npc defender, int roll) {
95 return (int) (roll * 2.3);
96 }
97
98 private static final class Melee extends NpcMeleeStrategy {
99 private static final Animation ANIMATION = new Animation(7226, UpdatePriority.HIGH);
100
101 @Override
102 public int getAttackDistance(Npc attacker, FightType fightType) {
103 return 2;
104 }
105
106 @Override
107 public Animation getAttackAnimation(Npc attacker, Mob defender) {
108 return ANIMATION;
109 }
110
111 @Override
112 public CombatHit[] getHits(Npc attacker, Mob defender) {
113 return new CombatHit[]{nextMeleeHit(attacker, defender)};
114 }
115 }
116
117 private static class Magic extends NpcMagicStrategy {
118 private static final Animation ANIMATION = new Animation(7238, UpdatePriority.HIGH);
119
120 private Magic() {
121 super(getDefinition("Demonic Gorilla Magic"));
122 }
123
124 @Override
125 public CombatHit[] getHits(Npc attacker, Mob defender) {
126 CombatHit combatHit = nextMagicHit(attacker, defender, 31);
127 combatHit.setAccurate(true);
128 return new CombatHit[]{combatHit};
129 }
130
131 @Override
132 public Animation getAttackAnimation(Npc attacker, Mob defender) {
133 return ANIMATION;
134 }
135
136 @Override
137 public int getAttackDistance(Npc attacker, FightType fightType) {
138 return 10;
139 }
140 }
141
142 private static class Ranged extends NpcRangedStrategy {
143 private static final Animation ANIMATION = new Animation(7227, UpdatePriority.HIGH);
144
145 private Ranged() {
146 super(getDefinition("Demonic Gorilla Ranged"));
147 }
148
149 @Override
150 public CombatHit[] getHits(Npc attacker, Mob defender) {
151 return new CombatHit[]{nextRangedHit(attacker, defender, 31)};
152 }
153
154 @Override
155 public Animation getAttackAnimation(Npc attacker, Mob defender) {
156 return ANIMATION;
157 }
158
159 @Override
160 public int getAttackDistance(Npc attacker, FightType fightType) {
161 return 10;
162 }
163 }
164
165}
Class that models a single animation used by an entity.
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
final CombatHit nextRangedHit(T attacker, Mob defender)
final CombatHit nextMagicHit(T attacker, Mob defender)
void block(Mob attacker, Npc defender, Hit hit, CombatType combatType)
Handles the mob class.
Definition Mob.java:66
void transform(int transformId)
Definition Mob.java:201
Represents a non-player character in the in-game world.
Definition Npc.java:29
boolean isActive(Prayer... prayers)
Checks if all given prayers are active.
void toggle(Prayer... prayers)
Inverts a prayer's active state.
A static-util class that provides additional functionality for generating pseudo-random numbers.
static< T > T randomExclude(T[] array, T exclude)
Returns a pseudo-random int value between inclusive min and inclusive max excluding the specified num...
Represents different priorities for updating.
The enumerated type whose elements represent the fighting types.