RuneHive-Game
Loading...
Searching...
No Matches
Skotizo.java
Go to the documentation of this file.
1package com.runehive.game.world.entity.combat.strategy.npc.boss.skotizo;
2
3import com.runehive.game.Animation;
4import com.runehive.game.Graphic;
5import com.runehive.game.Projectile;
6import com.runehive.game.UpdatePriority;
7import com.runehive.game.world.World;
8import com.runehive.game.world.entity.combat.CombatType;
9import com.runehive.game.world.entity.combat.attack.FightType;
10import com.runehive.game.world.entity.combat.hit.CombatHit;
11import com.runehive.game.world.entity.combat.hit.Hit;
12import com.runehive.game.world.entity.combat.projectile.CombatProjectile;
13import com.runehive.game.world.entity.combat.strategy.CombatStrategy;
14import com.runehive.game.world.entity.combat.strategy.npc.MultiStrategy;
15import com.runehive.game.world.entity.combat.strategy.npc.NpcMagicStrategy;
16import com.runehive.game.world.entity.combat.strategy.npc.NpcMeleeStrategy;
17import com.runehive.game.world.entity.mob.Mob;
18import com.runehive.game.world.entity.mob.npc.Npc;
19import com.runehive.game.world.position.Position;
20import com.runehive.game.world.region.RegionManager;
21import com.runehive.util.RandomUtils;
22import com.runehive.util.Utility;
23
24import static com.runehive.game.world.entity.combat.CombatUtil.createStrategyArray;
25import static com.runehive.game.world.entity.combat.CombatUtil.randomStrategy;
26
27/**
28 * Handles Skotizo's stategy.
29 *
30 * @author Daniel
31 */
32public class Skotizo extends MultiStrategy {
33 private static Magic MAGIC = new Magic();
35 private static TeleGrab TELE_GRAB = new TeleGrab();
36
37 private static final CombatStrategy<Npc>[] FULL_STRATEGIES = createStrategyArray(NpcMeleeStrategy.get(), MAGIC, TELE_GRAB, LIGHTNING_RAIN);
38 private static final CombatStrategy<Npc>[] MAGIC_STRATEGIES = createStrategyArray(MAGIC, MAGIC, MAGIC,TELE_GRAB, LIGHTNING_RAIN);
39
40 private static final String[] SHOUTS = {
41 "Feel the wrath of Skotizo!",
42 "The dark times have come for you all!"
43 };
44
45 /** Constructs a new <code>Skotizo</code>. */
46 public Skotizo() {
48 }
49
50 @Override
51 public boolean canAttack(Npc attacker, Mob defender) {
52 if (!currentStrategy.withinDistance(attacker, defender)) {
53 currentStrategy = randomStrategy(MAGIC_STRATEGIES);
54 }
55 return currentStrategy.canAttack(attacker, defender);
56 }
57
58 @Override
59 public void block(Mob attacker, Npc defender, Hit hit, CombatType combatType) {
60 currentStrategy.block(attacker, defender, hit, combatType);
61 defender.getCombat().attack(attacker);
62
63 if (!defender.getCombat().isAttacking()) {
64 defender.animate(new Animation(69, UpdatePriority.VERY_HIGH));
65 defender.graphic(481);
66 defender.speak("ARHHHH! TIME TO SWITCH IT UP!!");
67 }
68 }
69
70 @Override
71 public void finishOutgoing(Npc attacker, Mob defender) {
72 currentStrategy.finishOutgoing(attacker, defender);
73 if (NpcMeleeStrategy.get().withinDistance(attacker, defender)) {
74 currentStrategy = randomStrategy(FULL_STRATEGIES);
75 } else {
76 currentStrategy = randomStrategy(MAGIC_STRATEGIES);
77 }
78 }
79
80 @Override
81 public int getAttackDelay(Npc attacker, Mob defender, FightType fightType) {
82 return attacker.definition.getAttackDelay();
83 }
84
85 /** Skotizo's magic strategy. */
86 private static class Magic extends NpcMagicStrategy {
87 public Magic() {
88 super(CombatProjectile.getDefinition("EMPTY"));
89 }
90
91 @Override
92 public void hit(Npc attacker, Mob defender, Hit hit) {
93 }
94
95 @Override
96 public void attack(Npc attacker, Mob defender, Hit hit) {
97 }
98
99 @Override
100 public void start(Npc attacker, Mob defender, Hit[] hits) {
101 Projectile projectile = new Projectile(1242, 50, 80, 85, 25);
102 attacker.animate(new Animation(69, UpdatePriority.VERY_HIGH));
103 RegionManager.forNearbyPlayer(attacker, 16, other -> {
104 projectile.send(attacker, other);
105 World.schedule(2, () -> other.damage(nextMagicHit(attacker, other, 38)));
106 });
107
108 if (Utility.random(0, 2) == 1)
110 }
111
112 @Override
113 public CombatHit[] getHits(Npc attacker, Mob defender) {
114 CombatHit hit = nextMagicHit(attacker, defender, 38);
115 hit.setAccurate(false);
116 return new CombatHit[]{hit};
117 }
118
119 @Override
120 public int modifyAccuracy(Npc attacker, Mob defender, int roll) {
121 return roll + 50_000;
122 }
123 }
124
125 private static class TeleGrab extends NpcMagicStrategy {
127 super(CombatProjectile.getDefinition("EMPTY"));
128 }
129
130 @Override
131 public void hit(Npc attacker, Mob defender, Hit hit) {
132 }
133
134 @Override
135 public void attack(Npc attacker, Mob defender, Hit hit) {
136 }
137
138 @Override
139 public void start(Npc attacker, Mob defender, Hit[] hits) {
140 attacker.animate(new Animation(69, UpdatePriority.VERY_HIGH));
141 attacker.graphic(481);
142 attacker.speak("ARHHHH! TIME TO SWITCH IT UP!!");
143 }
144
145 @Override
146 public CombatHit[] getHits(Npc attacker, Mob defender) {
147 CombatHit hit = nextMagicHit(attacker, defender, 38);
148 hit.setAccurate(false);
149 return new CombatHit[]{hit};
150 }
151 }
152
153 private static class LightingRain extends NpcMagicStrategy {
155 super(CombatProjectile.getDefinition("Vet'ion"));
156 }
157
158 @Override
159 public void hit(Npc attacker, Mob defender, Hit hit) {
160 }
161
162 @Override
163 public void attack(Npc attacker, Mob defender, Hit hit) {
164 }
165
166 @Override
167 public void start(Npc attacker, Mob defender, Hit[] hits) {
168 attacker.animate(new Animation(69, UpdatePriority.VERY_HIGH));
169 attacker.speak("YOU WILL NOW FEEL THE TRUE WRATH OF SKOTIZO!");
170
171 RegionManager.forNearbyPlayer(attacker, 16, other -> {
172 Position position = other.getPosition();
173 combatProjectile.getProjectile().ifPresent(projectile -> World.sendProjectile(attacker, position, projectile));
174
175 World.schedule(2, () -> {
176 World.sendGraphic(new Graphic(775), position, attacker.instance);
177 if (other.getPosition().equals(position)) {
178 other.damage(new Hit(Utility.random(20, 50)));
179 other.speak("OUCH!");
180 other.message("Skotizo has just electrocuted your entire body! Don't stay in one spot!");
181 }
182 });
183 });
184 }
185
186 @Override
187 public CombatHit[] getHits(Npc attacker, Mob defender) {
188 CombatHit hit = nextMagicHit(attacker, defender, 38);
189 hit.setAccurate(false);
190 return new CombatHit[]{hit};
191 }
192 }
193}
Class that models a single animation used by an entity.
Represents a single graphic that can be used by entities.
Definition Graphic.java:10
Represents the game world.
Definition World.java:46
static void schedule(Task task)
Submits a new event.
Definition World.java:247
static void sendGraphic(Graphic graphic, Position position, int instance)
Sends a graphic to the world.
Definition World.java:268
static void sendProjectile(Projectile projectile, Position position, int instance, int lock, byte offsetX, byte offsetY)
Sends a world projectile.
Definition World.java:295
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 nextMagicHit(T attacker, Mob defender)
void block(Mob attacker, Npc defender, Hit hit, CombatType combatType)
Definition Skotizo.java:59
int getAttackDelay(Npc attacker, Mob defender, FightType fightType)
Definition Skotizo.java:81
Handles the mob class.
Definition Mob.java:66
void speak(String forceChat)
Sets the mob's forced chat.
Definition Mob.java:127
Optional< Graphic > graphic
Definition Mob.java:91
Represents a non-player character in the in-game world.
Definition Npc.java:29
Combat< Npc > getCombat()
The combat of the mob.
Definition Npc.java:156
Represents a single tile on the game world.
Definition Position.java:14
static void forNearbyPlayer(Mob mob, int distance, Consumer< Player > action)
Sends an action to Mob instance which is within a distance.
Handles miscellaneous methods.
Definition Utility.java:27
static int random(int bound)
Definition Utility.java:239
static< T > T randomElement(Collection< T > collection)
Picks a random element out of any array type.
Definition Utility.java:248
Represents different priorities for updating.
The enumerated type whose elements represent the fighting types.