RuneHive-Game
Loading...
Searching...
No Matches
TutorialActivity.java
Go to the documentation of this file.
1package com.runehive.game.action.impl;
2
3
4import com.runehive.Config;
5import com.runehive.content.StarterKit;
6import com.runehive.content.achievement.AchievementHandler;
7import com.runehive.content.achievement.AchievementKey;
8import com.runehive.content.activity.Activity;
9import com.runehive.content.activity.ActivityType;
10import com.runehive.content.activity.panel.ActivityPanel;
11import com.runehive.content.dialogue.DialogueFactory;
12import com.runehive.content.event.impl.ClickButtonInteractionEvent;
13import com.runehive.content.skill.impl.magic.teleport.TeleportType;
14import com.runehive.content.skill.impl.magic.teleport.Teleportation;
15import com.runehive.content.teleport.TeleportHandler;
16import com.runehive.game.Animation;
17import com.runehive.game.Graphic;
18import com.runehive.game.world.entity.mob.Direction;
19import com.runehive.game.world.entity.mob.Mob;
20import com.runehive.game.world.entity.mob.npc.Npc;
21import com.runehive.game.world.entity.mob.player.Player;
22import com.runehive.game.world.position.Position;
23import com.runehive.net.packet.out.SendConfig;
24import com.runehive.net.packet.out.SendForceTab;
25import com.runehive.net.packet.out.SendMessage;
26import com.runehive.net.packet.out.SendSpecialAmount;
27import com.runehive.util.Utility;
28
29import static com.runehive.content.skill.impl.magic.teleport.TeleportationData.MODERN;
30
31/**
32 * Handles the tutorial activity.
33 *
34 * @author Daniel
35 */
36public class TutorialActivity extends Activity {
37
38 /** The player doing the tutorial activity. */
39 private final Player player;
40
41 /** The guide npc for the activity. */
42 private Npc guide;
43
44 /** The current activity stage. */
45 private int stage;
46
47 /** The dialogue factory for this activity. */
48 private final DialogueFactory factory;
49
50 private boolean completed = false;
51
52 /** Constructs a new <code>TutorialActivity</code>. */
54 super(2, player.playerAssistant.instance());
55 this.stage = 0;
56 this.player = player;
57 this.factory = player.dialogueFactory;
58 }
59
60 /** Creates the tutorial activity for the player. */
63 player.runEnergy = 100;
64 player.send(new SendSpecialAmount());
65 player.movement.setRunningToggled(false);
66 player.playerAssistant.setSidebar(true);
67 player.setVisible(false);
69 activity.cooldown(3);
70 activity.add(player);
71 player.locking.lock();
72 return activity;
73 }
74
75 /** Updates the activity panel. */
76 private void update(String... strings) {
77 ActivityPanel.update(player, (int) Utility.getPercentageAmount(stage, 27), "Tutorial", "Progress", strings);
78 }
79
80 @Override
81 public void cooldown(int cooldown) {
82 super.cooldown(cooldown);
83 factory.clear();
84 }
85
86 private void next() {
87 update();
88 cooldown(1);
89 }
90
91 @Override
92 protected void start() {
93// System.out.println(stage);
94 switch (stage) {
95 case 0:
96 guide = new Npc(306, new Position(3222, 3223));
97 add(guide);
98 guide.graphic(new Graphic(86, true));
99 cooldown(2);
100 break;
101 case 1:
102 guide.face(player.getPosition());
103 guide.animate(new Animation(863));
104 guide.speak("Hello, " + player.getName() + "!");
105 cooldown(2);
106 break;
107 case 2:
108 guide.walk(new Position(3222, 3218));
109 cooldown(1);
110 break;
111 case 3:
112 player.face(guide.getPosition());
113 factory.sendNpcChat(306, "Welcome to <col=D63E3E>Augury</col>, " + player.getName(),
114 "Would you like a tutorial of our lands?");
115 factory.sendOption("Yes", () -> cooldown(1), "No", this::finish);
116 factory.execute();
117 pause();
118 break;
119 case 4:
120 update("This is the activity panel.", "The activity panel replaces a lot", "of interfaces so be sure",
121 "to get acquainted to it.");
122 factory.sendNpcChat(306, "Wise choice my friend! Let's get started.",
123 "The first thing you need to know about is the", "activity panel. When you are doing an activity,",
124 "like this tutorial for example; a panel will be available to you.");
125 factory.sendNpcChat(306, "You can access this panel by clicking the red tab icon.",
126 "The activity panel is disabled by default but will", "automatically enable when in a activity.");
127 factory.onAction(() -> cooldown(1));
128 factory.execute();
129 pause();
130 break;
131 case 5:
132 factory.sendNpcChat(306, "Before I show you around I want to show you",
133 "useful content for your adventures.");
134 factory.onAction(() -> {
135 player.interfaceManager.setSidebar(Config.QUEST_TAB, 29400);
137 next();
138 });
139 factory.execute();
140 pause();
141 break;
142 case 6:
143 factory.sendNpcChat(306, "This is your quest tab. Inside contains information about",
144 "the world and yourself. On the top right corner of the",
145 "tab you will see a bunch of different buttons.");
146 factory.sendNpcChat(306, "The blue button will show you the quest tab",
147 "The green button will provide you with various options.");
148 factory.sendNpcChat(306, "Some of these options include - npc drop viwer,",
149 "log drop simulator, log kill logs, title manager and more!");
150 factory.sendNpcChat(306, "Lastly, the scroll button will open a menu where you can",
151 "change game related options. For example: welcome screen,",
152 " triviabot, drop notification, and more! These options",
153 "are not to be confused with the client options.");
154 factory.onAction(() -> {
155 player.interfaceManager.setSidebar(Config.QUEST_TAB, -1);
156 player.interfaceManager.setSidebar(Config.WRENCH_TAB, 50020);
157 next();
158 });
159 factory.execute();
160 pause();
161 break;
162 case 7:
164 factory.sendNpcChat(306, "This is your settings tab. Here you can change all options",
165 "that are for your client. The interface has different tabs.",
166 "You are currently in the display tab. You can change all", " display settings here.");
167 factory.onAction(this::next);
168 factory.execute();
169 pause();
170 break;
171 case 8:
173 player.instance = Mob.DEFAULT_INSTANCE;
174 player.loadRegion();
175 factory.sendNpcChat(306, "Let's move on.");
176 factory.sendNpcChat(306, "Edgeville will be your primary home, however you",
177 "can change it later on as you progress", "in the game.").onAction(this::next);
178 factory.execute();
179 pause();
180 break;
181 case 9:
182 Teleportation.teleport(player, new Position(3089, 3492), MODERN, () -> {
183 player.face(Direction.EAST);
184 next();
185 player.locking.lock();
186 });
187 pause();
188 break;
189 case 10:
190 factory.sendNpcChat(306, "Throughout your adventures you will find key halves.",
191 "When using the right halves together you will be able",
192 "to form a Crystal key. With that key you can unlock this chest.",
193 "This chest contains various high valued items.").onAction(this::next).execute();
194 pause();
195 break;
196 case 11:
197 Teleportation.teleport(player, new Position(3091, 3494), MODERN, () -> {
198 player.face(Direction.WEST);
199 next();
200 player.locking.lock();
201 });
202 pause();
203 break;
204 case 12:
205 factory.sendNpcChat(306, "This is our market place. You can put any items you",
206 "would like to sell in your store. You can also", "purchase items from other players.")
207 .onAction(this::next);
208 factory.execute();
209 pause();
210 break;
211 case 13:
212 Teleportation.teleport(player, new Position(3093, 3500), MODERN, () -> {
213 player.face(Direction.EAST);
214 next();
215 player.locking.lock();
216 });
217 pause();
218 break;
219 case 14:
220 factory.sendNpcChat(306, "These thieving stalls are a very good for making", "quick money.")
221 .onAction(this::next).execute();
222 pause();
223 break;
224 case 15:
225 Teleportation.teleport(player, new Position(3080, 3491), MODERN, () -> {
226 player.face(Direction.WEST);
227 next();
228 player.locking.lock();
229 });
230 pause();
231 break;
232 case 16:
233 factory.sendNpcChat(306, "Here are shops that will sell you all the supplies you may need,",
234 " aswell as gear/food/potions/misc items and more.").onAction(this::next).execute();
235 pause();
236 break;
237 case 17:
238 Teleportation.teleport(player, new Position(3080, 3491), MODERN, () -> {
239 player.face(Direction.WEST);
240 next();
241 player.locking.lock();
242 });
243 pause();
244 break;
245 case 18:
246 factory.sendNpcChat(306, "These npcs can really help you out, anywhere from",
247 "mass decanting potions, changing appearances,", "buying skillcapes and more!").onAction(this::next)
248 .execute();
249 pause();
250 break;
251 case 19:
252 Teleportation.teleport(player, new Position(3086, 3500), MODERN, () -> {
253 player.face(Direction.WEST);
254 next();
255 player.locking.lock();
256 });
257 pause();
258 break;
259 case 20:
260 factory.sendNpcChat(306, "This is the Well of goodwill,",
261 "you will be able to contribute gold for a server wide",
262 "experience bonus that will last 30 Minutes.").onAction(this::next).execute();
263 pause();
264 break;
265 case 21:
266 Teleportation.teleport(player, new Position(3078, 3509), MODERN, () -> {
267 player.face(Direction.SOUTH);
268 next();
269 player.locking.lock();
270 });
271 pause();
272 break;
273 case 22:
274 factory.sendNpcChat(306, "This is the fun pk arena.",
275 "Here you can fight players in multi-combat and lose nothing", "on death!").onAction(this::next)
276 .execute();
277 pause();
278 break;
279 case 23:
280 Teleportation.teleport(player, new Position(3090, 3474), MODERN, () -> {
281 player.face(Direction.SOUTH);
282 next();
283 player.onStep();
284 player.locking.lock();
285 });
286 pause();
287 break;
288 case 24:
289 factory.sendNpcChat(306, "This is the skilling area for members with",
290 "Extreme Donator status.");
291 factory.onAction(() -> {
292 player.face(Direction.SOUTH);
293 next();
294 player.locking.lock();
295 });
296 factory.execute();
297 pause();
298 break;
299 case 25:
300 Teleportation.teleport(player, new Position(3097, 3498), MODERN, () -> {
301 player.face(Direction.NORTH);
302 next();
303 player.locking.lock();
304 });
305 pause();
306 break;
307 case 26:
308 factory.sendNpcChat(1143, "Hello #name.", "I am the clan master.");
309 factory.sendNpcChat(1143, "Clans are going to be extremely useful for your adventures.",
310 "Joining a clan can give you extra experience rewards,",
311 "experience and drop modifiers, and much more!", "It is also a great way to make new friends!");
312 factory.sendNpcChat(1143, "There are heavily enforced rules for being in a clan.",
313 "Check out the rules on our forums ::clanrules");
314 factory.onAction(this::next).execute();
315 pause();
316 break;
317 case 27:
319 player.face(Direction.SOUTH);
320 next();
321 player.locking.lock();
322 });
323 pause();
324 break;
325 case 28:
326 factory.sendNpcChat(306, "That's the end of the tutorial! If you have any more questions",
327 "Check out our forums for detail guides or ask a moderator.", "Good luck #name!")
328 .onAction(this::next).execute();
329 pause();
330 break;
331 case 29:
332 completed = true;
333 finish();
334 break;
335 }
336 stage++;
337 }
338
339 @Override
340 public void cleanup() {
341 remove(guide);
342 }
343
344 @Override
345 public void finish() {
346 player.setVisible(true);
347 player.playerAssistant.setSidebar(false);
348 cleanup();
349 remove(player);
350 factory.clear();
351 player.locking.unlock();
353 if (completed) {
355 }
356 if (player.needsStarter) {
358 }
359
360 }
361
362 @Override
364 int button = event.getButton();
365 switch (stage) {
366 case 8:
367 if (button == -15496) {
368 factory.lock(false);
369 player.send(new SendMessage(":settingupdate:"));
370 player.interfaceManager.open(28_500);
371 start();
372 }
373 return true;
374 case 9:
375 if (button == 28502) {
376 factory.lock(false);
377 player.interfaceManager.close();
378 start();
379 }
380 return true;
381 case 10:
382 if (button == -15531) {
383 factory.lock(false);
384 player.interfaceManager.setSidebar(Config.WRENCH_TAB, 50300);
385 player.send(new SendConfig(980, 3));
386 next();
387 }
388 return true;
389 case 12:
390 if (button == 850) {
391 factory.lock(false);
393 start();
394 }
395 return true;
396 case 13:
397 if (button == -7534) {
398 factory.lock(false);
399 player.interfaceManager.close();
400 start();
401 }
402 return true;
403 }
404 return false;
405 }
406
407 @Override
409 }
410
411 @Override
412 public void onLogout(Player player) {
413 cleanup();
414 remove(player);
416
417 if (player.needsStarter) {
418 player.newPlayer = true;
419 }
420 }
421
422 @Override
424 return ActivityType.TUTORIAL;
425 }
426}
The class that contains setting-related constants for the server.
Definition Config.java:24
static final int WRENCH_TAB
Definition Config.java:194
static final Position DEFAULT_POSITION
The default, i.e.
Definition Config.java:197
static final int QUEST_TAB
Definition Config.java:194
Handles the starter kits.
static void open(Player player)
Handles opening the starter kit interface.
static void activate(Player player, AchievementKey achievement)
Activates the achievement for the individual player.
final int cooldown
The sequencing cooldown.
Definition Activity.java:43
Activity(int cooldown, int instance)
Constructs a new SequencedMinigame object.
Definition Activity.java:55
final void pause()
Sets the cooldown flag to PAUSE.
void add(Mob mob)
Adds a mob to the activity.
void update()
The update method.
static void update(Player player, int amount, String title, String footer, String... strings)
Sends all the information for the activity panel.
static void clear(Player player)
Clears the activity panel.
Represents a factory class that contains important functions for building dialogues.
static boolean teleport(Player player, Position position)
Handles teleporting to various locations around OS Royale.
static void open(Player player)
Opens the teleport itemcontainer.
Class that models a single animation used by an entity.
Represents a single graphic that can be used by entities.
Definition Graphic.java:10
boolean clickButton(Player player, ClickButtonInteractionEvent event)
void start()
Starts the next activity stage.
void onLogout(Player player)
Called when the player logs out.
Npc guide
The guide npc for the activity.
final Player player
The player doing the tutorial activity.
final DialogueFactory factory
The dialogue factory for this activity.
void cooldown(int cooldown)
Applies a cooldown.
static TutorialActivity create(Player player)
Creates the tutorial activity for the player.
TutorialActivity(Player player)
Constructs a new TutorialActivity.
void update(String... strings)
Updates the activity panel.
void onRegionChange(Player player)
Called when the player changes region.
void cleanup()
Cleans up the activity when finished.
Handles the mob class.
Definition Mob.java:66
Represents a non-player character in the in-game world.
Definition Npc.java:29
This class represents a character controlled by a player.
Definition Player.java:125
Represents a single tile on the game world.
Definition Position.java:14
The OutgoingPacket responsible for changing settings on a client.
The OutgoingPacket that sends a message to a Players chatbox in the client.
Handles sending the special attack amount (used for the orb).
Handles miscellaneous methods.
Definition Utility.java:27
static double getPercentageAmount(int progress, int total)
Gets a percentage amount.
Definition Utility.java:36
Holds all activity types that are timed.
Represents the enumerated directions an entity can walk or face.