RuneHive-Game
Loading...
Searching...
No Matches
TutorialActivity.java
Go to the documentation of this file.
1/*
2
3package com.runehive.content.activity.impl;
4
5import com.runehive.Config;
6import com.runehive.content.StarterKit;
7import com.runehive.content.achievement.AchievementHandler;
8import com.runehive.content.achievement.AchievementKey;
9import com.runehive.content.activity.Activity;
10import com.runehive.content.activity.ActivityType;
11import com.runehive.content.activity.panel.ActivityPanel;
12import com.runehive.content.dialogue.DialogueFactory;
13import com.runehive.content.event.impl.ClickButtonInteractionEvent;
14import com.runehive.content.skill.impl.magic.teleport.TeleportType;
15import com.runehive.content.skill.impl.magic.teleport.Teleportation;
16import com.runehive.content.teleport.TeleportHandler;
17import com.runehive.game.Animation;
18import com.runehive.game.Graphic;
19import com.runehive.game.world.entity.combat.strategy.player.special.CombatSpecial;
20import com.runehive.game.world.entity.mob.Direction;
21import com.runehive.game.world.entity.mob.Mob;
22import com.runehive.game.world.entity.mob.npc.Npc;
23import com.runehive.game.world.entity.mob.player.Player;
24import com.runehive.game.world.position.Position;
25import com.runehive.net.packet.out.SendConfig;
26import com.runehive.net.packet.out.SendForceTab;
27import com.runehive.net.packet.out.SendMessage;
28import com.runehive.net.packet.out.SendSpecialAmount;
29import com.runehive.util.Utility;
30
31import static com.runehive.content.skill.impl.magic.teleport.TeleportationData.MODERN;
32
33
34
35
36public class TutorialActivity extends Activity {
37
38
39 private final Player player;
40
41
42
43 private Npc guide;
44
45
46
47 private int stage;
48
49
50
51 private final DialogueFactory factory;
52
53 private boolean completed = false;
54
55
56
57 private TutorialActivity(Player player) {
58 super(2, player.playerAssistant.instance());
59 this.stage = 0;
60 this.player = player;
61 this.factory = player.dialogueFactory;
62 }
63
64
65 public static TutorialActivity create(Player player) {
66 TutorialActivity activity = new TutorialActivity(player);
67 player.runEnergy = 100;
68 CombatSpecial.restore(player, 100);
69 player.send(new SendSpecialAmount());
70 player.movement.setRunningToggled(false);
71 player.playerAssistant.setSidebar(true);
72 player.setVisible(false);
73 player.move(Config.DEFAULT_POSITION);
74 activity.cooldown(3);
75 activity.add(player);
76 player.locking.lock();
77 return activity;
78 }
79
80
81
82 private void update(String... strings) {
83 ActivityPanel.update(player, (int) Utility.getPercentageAmount(stage, 27), "Tutorial", "Progress", strings);
84 }
85
86 @Override
87 public void cooldown(int cooldown) {
88 super.cooldown(cooldown);
89 factory.clear();
90 }
91
92 private void next() {
93 update();
94 cooldown(1);
95 }
96
97 @Override
98 protected void start() {
99 switch (stage) {
100 case 0:
101 guide = new Npc(306, new Position(3086, 3492));
102 add(guide);
103 guide.graphic(new Graphic(86, true));
104 cooldown(2);
105 break;
106 case 1:
107 guide.face(player.getPosition());
108 guide.animate(new Animation(863));
109 guide.speak("Hello, " + player.getName() + "!");
110 cooldown(2);
111 break;
112 case 2:
113 guide.walkExactlyTo(new Position(3086, 3490));
114 cooldown(1);
115 break;
116 case 3:
117 player.face(guide.getPosition());
118 factory.sendNpcChat(306, "Welcome to <col=D63E3E>osroyale</col>, " + player.getName(), "Would you like a tutorial of our lands?");
119 factory.sendOption("Yes", () -> cooldown(1), "No", this::finish);
120 factory.execute();
121 pause();
122 break;
123 case 4:
124 update("This is the activity panel.", "The activity panel replaces a lot", "of interfaces so be sure", "to get acquainted to it.");
125 factory.sendNpcChat(306, "Wise choice my friend! Let's get started.", "The first thing you need to know about is the", "activity panel. When you are doing an activity,", "like this tutorial for example; a panel will be available to you.");
126 factory.sendNpcChat(306, "You can access this panel by clicking the red tab icon.", "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", "useful content for your adventures.");
133 factory.onAction(() -> {
134 player.interfaceManager.setSidebar(Config.QUEST_TAB, 29400);
135 player.send(new SendForceTab(Config.QUEST_TAB));
136 next();
137 });
138 factory.execute();
139 pause();
140 break;
141 case 6:
142 factory.sendNpcChat(306, "This is your quest tab. Inside contains information about", "the world and yourself. On the top right corner of the", "tab you will see a bunch of different buttons.");
143 factory.sendNpcChat(306, "The blue button will show you the quest tab", "and the green button will show you the achievement tab.");
144 factory.sendNpcChat(306, "The red button will provide you with various options.", "Some of these options include - npc drop viwer,", "log drop simulator, log kill logs, title manager and more!");
145 factory.sendNpcChat(306, "Lastly, the scroll button will open a menu where you can", "change game related options. For example: welcome screen,", " triviabot, drop notification, and more! These options", "are not to be confused with the client options.");
146 factory.onAction(() -> {
147 player.interfaceManager.setSidebar(Config.QUEST_TAB, -1);
148 player.interfaceManager.setSidebar(Config.WRENCH_TAB, 50020);
149 next();
150 });
151 factory.execute();
152 pause();
153 break;
154 case 7:
155 player.send(new SendForceTab(Config.WRENCH_TAB));
156 factory.sendNpcChat(306, "This is your wrench tab. Here you can change all options", "that are for your client. The interface has different tabs.", "You are currently in the display tab. You can change all", " display settings here.");
157 factory.onAction(this::next);
158 factory.execute();
159 pause();
160 break;
161 case 8:
162 setInstance(Mob.DEFAULT_INSTANCE);
163 player.instance = Mob.DEFAULT_INSTANCE;
164 player.loadRegion();
165 factory.sendNpcChat(306, "Let's move on.");
166 factory.sendNpcChat(306, "Edgeville will be your primary home, however you", "can change it later on as you progress", "in the game.").onAction(this::next);
167 factory.execute();
168 pause();
169 break;
170 case 9:
171 Teleportation.teleport(player, new Position(3091, 3494), MODERN, () -> {
172 player.face(Direction.WEST);
173 next();
174 player.locking.lock();
175 factory.sendNpcChat(306, "This is our market place. You can put any items you", "would like to sell in your store. You can also", "purchase items from other players.").onAction(this::next);
176 factory.execute();
177 });
178 pause();
179 break;
180 case 10:
181 Teleportation.teleport(player, new Position(3086, 3485), MODERN, () -> {
182 player.face(Direction.EAST);
183 next();
184 player.locking.lock();
185 factory.sendNpcChat(306, "These thieving stalls are a very good for making", "quick money.").onAction(this::next).execute();
186 });
187 pause();
188 break;
189 case 11:
190 Teleportation.teleport(player, new Position(3079, 3494), MODERN, () -> {
191 player.face(Direction.NORTH);
192 next();
193 player.locking.lock();
194 factory.sendNpcChat(306, "Here are shops that will sell you all the", "general items you will need in your adventure.", "The bounty hunter npc has a wide variety of", "high end items which he will sell for pvp points.").onAction(this::next).execute();
195 });
196 pause();
197 break;
198 case 12:
199 Teleportation.teleport(player, new Position(3085, 3501), MODERN, () -> {
200 player.face(Direction.SOUTH);
201 next();
202 player.locking.lock();
203 factory.sendNpcChat(306, "This is the Well of goodwill,", "you will be able to contribute gold for a server wide", "experience bonus that will last 1 hour.").onAction(this::next).execute();
204 });
205 pause();
206 break;
207 case 13:
208 Teleportation.teleport(player, new Position(3089, 3499), MODERN, () -> {
209 player.face(Direction.EAST);
210 next();
211 player.locking.lock();
212 });
213 pause();
214 break;
215 case 14:
216 factory.sendNpcChat(1143, "Hello #name.", "I am the clan master.");
217 factory.sendNpcChat(1143, "Clans are going to be extremely useful for your adventures.", "Joining a clan can give you extra experience rewards,", "experience and drop modifiers, and much more!", "It is also a great way to make new friends!");
218 factory.onAction(this::next).execute();
219 pause();
220 break;
221 case 15:
222 Teleportation.teleport(player, Config.DEFAULT_POSITION, MODERN, () -> {
223 player.face(Direction.SOUTH);
224 next();
225 player.locking.lock();
226 });
227 pause();
228 break;
229 case 16:
230 factory.sendNpcChat(306, "That's the end of the tutorial! If you have any more questions", "Check out our forums for detail guides or ask a moderator.", "Good luck #name!").onAction(this::next).execute();
231 pause();
232 break;
233 case 17:
234 completed = true;
235 finish();
236 break;
237 }
238 stage++;
239 }
240
241 @Override
242 public void cleanup() {
243 remove(guide);
244 }
245
246 @Override
247 public void finish() {
248 player.setVisible(true);
249 player.playerAssistant.setSidebar(false);
250 cleanup();
251 remove(player);
252 factory.clear();
253 player.locking.unlock();
254 ActivityPanel.clear(player);
255 if (completed) {
256 AchievementHandler.activate(player, AchievementKey.COMPLETE_TUTORIAL);
257 }
258 if (player.needsStarter) {
259 StarterKit.open(player);
260 }
261 }
262
263 @Override
264 protected boolean clickButton(Player player, ClickButtonInteractionEvent event) {
265 int button = event.getButton();
266 switch (stage) {
267 case 8:
268 if (button == -15496) {
269 factory.lock(false);
270 player.send(new SendMessage(":settingupdate:"));
271 player.interfaceManager.open(28_500);
272 start();
273 }
274 return true;
275 case 9:
276 if (button == 28502) {
277 factory.lock(false);
278 player.interfaceManager.close();
279 start();
280 }
281 return true;
282 case 10:
283 if (button == -15531) {
284 factory.lock(false);
285 player.interfaceManager.setSidebar(Config.WRENCH_TAB, 50300);
286 player.send(new SendConfig(980, 3));
287 next();
288 }
289 return true;
290 case 12:
291 if (button == 850) {
292 factory.lock(false);
293 TeleportHandler.open(player, TeleportType.FAVORITES);
294 start();
295 }
296 return true;
297 case 13:
298 if (button == -7534) {
299 factory.lock(false);
300 player.interfaceManager.close();
301 start();
302 }
303 return true;
304 }
305 return false;
306 }
307
308 @Override
309 public void onRegionChange(Player player) {
310 }
311
312 @Override
313 public void onLogout(Player player) {
314 cleanup();
315 remove(player);
316 player.move(Config.DEFAULT_POSITION);
317
318 if (player.needsStarter) {
319 player.newPlayer = true;
320 }
321 }
322
323 @Override
324 public ActivityType getType() {
325 return ActivityType.TUTORIAL;
326 }
327 }*/