RuneHive-Game
Loading...
Searching...
No Matches
ZulrahPhase.java
Go to the documentation of this file.
1package com.runehive.content.activity.impl.zulrah;
2
3import com.runehive.game.Animation;
4import com.runehive.game.Projectile;
5import com.runehive.game.UpdatePriority;
6import com.runehive.game.task.impl.ObjectPlacementEvent;
7import com.runehive.game.world.World;
8import com.runehive.game.world.entity.mob.npc.Npc;
9import com.runehive.game.world.entity.mob.player.Player;
10import com.runehive.game.world.object.CustomGameObject;
11import com.runehive.game.world.position.Position;
12import com.runehive.net.packet.out.SendCameraReset;
13import com.runehive.net.packet.out.SendMessage;
14import com.runehive.util.RandomUtils;
15import com.runehive.util.Utility;
16
17import java.util.concurrent.TimeUnit;
18
19/**
20 * Handles all the activity phases for zulrah.
21 *
22 * @author Daniel
23 */
26 @Override
27 public void execute(ZulrahActivity activity) {
28 Player player = activity.player;
29 int count = activity.count;
30
31 if (count == 0) {
32 player.send(new SendCameraReset());
33 } else if (count == 1) {
34 activity.zulrah = new Npc(2042, new Position(2266, 3073));
35 activity.add(activity.zulrah);
36 activity.zulrah.definition.setRetaliate(false);
37 activity.zulrah.definition.setAggressive(false);
38 activity.zulrah.canAttack = false;
39 activity.zulrah.blockInteract = true;
40 activity.zulrah.owner = player;
41 activity.zulrah.face(player.getPosition());
42 activity.zulrah.animate(5071);
43 activity.cooldown(1);
44 } else if (count == 2) {
45 activity.zulrah.blockInteract = false;
46 activity.zulrah.resetFace();
47 activity.count = -1;
48 activity.phase = INITIAL_CLOUDS;
49 activity.cooldown(3);
50 return;
51 }
52
53 activity.increment();
54 }
55 },
57 @Override
58 public void execute(ZulrahActivity activity) {
59 Npc zulrah = activity.zulrah;
60
61 int index = activity.count / 3;
62 int stage = activity.count % 3;
63
64 if (index >= ZulrahConstants.CLOUD_POSITIONS.length) {
65 activity.count = 0;
66 activity.phase = DIVE;
67 activity.reset();
68 activity.cooldown(2);
69 return;
70 }
71
72 if (stage == 0) {
74 } else if (stage == 1) {
75 zulrah.animate(new Animation(5069, UpdatePriority.VERY_HIGH));
76 World.sendProjectile(zulrah, ZulrahConstants.CLOUD_POSITIONS[index], new Projectile(1045, 1, 35, 85, 40));
77 } else if (stage == 2) {
78 CustomGameObject cloud = new CustomGameObject(11700, activity.getInstance(), ZulrahConstants.CLOUD_POSITIONS[index]);
79 World.schedule(new ObjectPlacementEvent(cloud, 35, () -> activity.clouds.remove(cloud)));
80 activity.clouds.add(cloud);
81 }
82
83 activity.increment();
84 }
85 },
86 DIVE() {
87 @Override
88 public void execute(ZulrahActivity activity) {
89 Npc zulrah = activity.zulrah;
90 int count = activity.count;
91
92 if (count == 0) {
93 zulrah.animate(new Animation(5072, UpdatePriority.VERY_HIGH), true);
94 activity.player.send(new SendMessage("Zulrah dives into the swamp..."));
95 } else if (count == 3) {
96 zulrah.setVisible(false);
97 zulrah.transform(activity.nextForm());
99 } else if (count == 5) {
100 zulrah.locking.unlock();
101 zulrah.setVisible(true);
102 zulrah.animate(new Animation(5071, UpdatePriority.VERY_HIGH));
103 activity.count = -1;
104 activity.phase = activity.nextPhase();
105 activity.reset();
106 activity.cooldown(2);
107 return;
108 }
109
110 activity.increment();
111 }
112 },
114 @Override
115 public void execute(ZulrahActivity activity) {
116 Npc zulrah = activity.zulrah;
117
118 if (!zulrah.definition.isAggressive() || !zulrah.definition.isRetaliate() || !zulrah.canAttack) {
119 zulrah.definition.setAggressive(true);
120 zulrah.canAttack = true;
121 zulrah.definition.setRetaliate(true);
122 }
123
124 if (activity.stopwatch.elapsedTime(TimeUnit.SECONDS) >= 10 && Utility.random(5) == 0) {
125 activity.reset();
126 activity.phase = DIVE;
127 zulrah.definition.setAggressive(false);
128 activity.zulrah.definition.setRetaliate(false);
129 zulrah.canAttack = false;
130 activity.cooldown(2);
131 return;
132 }
133
134 activity.increment();
135 activity.cooldown(2);
136 }
137 },
139 @Override
140 public void execute(ZulrahActivity activity) {
141 Npc zulrah = activity.zulrah;
142
143 if (activity.target == null) {
144 activity.target = activity.getCloudPosition();
145 }
146
147 if (activity.clouds.size() >= ZulrahConstants.MAXIMUM_CLOUDS) {
148 activity.reset();
149 activity.phase = DIVE;
150 activity.cooldown(2);
151 return;
152 }
153
154 int stage = activity.count % 3;
155
156 if (stage == 0) {
157 zulrah.face(activity.target);
158 } else if (stage == 1) {
159 zulrah.animate(new Animation(5069, UpdatePriority.VERY_HIGH));
160 World.sendProjectile(zulrah, activity.target, new Projectile(1045, 1, 35, 85, 40));
161 } else if (stage == 2) {
162 CustomGameObject cloud = new CustomGameObject(11700, activity.getInstance(), activity.target);
163 activity.clouds.add(cloud);
164 World.schedule(new ObjectPlacementEvent(cloud, 150, () -> activity.clouds.remove(cloud)));
165 activity.target = null;
166 }
167
168 activity.increment();
169 activity.cooldown(1);
170 }
171 },
173 @Override
174 public void execute(ZulrahActivity activity) {
175 Npc zulrah = activity.zulrah;
176
177 if (activity.target == null) {
178 activity.target = activity.getSnakelingPosition();
179 }
180
181 if (activity.snakes.size() >= ZulrahConstants.MAXIMUM_SNAKELINGS) {
182 activity.reset();
183 activity.phase = DIVE;
184 activity.cooldown(2);
185 return;
186 }
187
188 int stage = activity.count % 3;
189
190 if (stage == 0) {
191 zulrah.face(activity.target);
192 } else if (stage == 1) {
193 zulrah.animate(new Animation(5068, UpdatePriority.VERY_HIGH));
194 World.sendProjectile(zulrah, activity.target, new Projectile(1047, 1, 35, 85, 40));
195 } else if (stage == 2) {
196 Npc snake = new Npc(2045, activity.target);
197 activity.add(snake);
198 snake.getCombat().attack(activity.player);
199 activity.snakes.add(snake);
200 activity.target = null;
201 }
202
203 activity.increment();
204 activity.cooldown(1);
205 }
206 },
207}
static final Position[] CLOUD_POSITIONS
All the possible positions zulrah can spawn his clouds for.
static final int MAXIMUM_CLOUDS
The maximum amount of clouds that zulrah can spawn at a time.
static final Position[] LOCATIONS
All the possible positions zulrah can move to.
static final int MAXIMUM_SNAKELINGS
The maximum amount of snakelings that zulrah can spawn at a time.
Class that models a single animation used by an entity.
An randomevent which places a temporary object.
Represents the game world.
Definition World.java:46
static void schedule(Task task)
Submits a new event.
Definition World.java:247
static void sendProjectile(Projectile projectile, Position position, int instance, int lock, byte offsetX, byte offsetY)
Sends a world projectile.
Definition World.java:295
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
This class represents a character controlled by a player.
Definition Player.java:125
Represents a static game object loaded from the map fs.
Represents a single tile on the game world.
Definition Position.java:14
The OutgoingPacket resets the camera position for Player.
The OutgoingPacket that sends a message to a Players chatbox in the client.
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...
Handles miscellaneous methods.
Definition Utility.java:27
static int random(int bound)
Definition Utility.java:239
Handles all the activity phases for zulrah.
Represents different priorities for updating.