RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
TutorialActivity.java
1/*
2
3package com.osroyale.content.activity.impl;
4
5import com.osroyale.Config;
6import com.osroyale.content.StarterKit;
7import com.osroyale.content.achievement.AchievementHandler;
8import com.osroyale.content.achievement.AchievementKey;
9import com.osroyale.content.activity.Activity;
10import com.osroyale.content.activity.ActivityType;
11import com.osroyale.content.activity.panel.ActivityPanel;
12import com.osroyale.content.dialogue.DialogueFactory;
13import com.osroyale.content.event.impl.ClickButtonInteractionEvent;
14import com.osroyale.content.skill.impl.magic.teleport.TeleportType;
15import com.osroyale.content.skill.impl.magic.teleport.Teleportation;
16import com.osroyale.content.teleport.TeleportHandler;
17import com.osroyale.game.Animation;
18import com.osroyale.game.Graphic;
19import com.osroyale.game.world.entity.combat.strategy.player.special.CombatSpecial;
20import com.osroyale.game.world.entity.mob.Direction;
21import com.osroyale.game.world.entity.mob.Mob;
22import com.osroyale.game.world.entity.mob.npc.Npc;
23import com.osroyale.game.world.entity.mob.player.Player;
24import com.osroyale.game.world.position.Position;
25import com.osroyale.net.packet.out.SendConfig;
26import com.osroyale.net.packet.out.SendForceTab;
27import com.osroyale.net.packet.out.SendMessage;
28import com.osroyale.net.packet.out.SendSpecialAmount;
29import com.osroyale.util.Utility;
30
31import static com.osroyale.content.skill.impl.magic.teleport.TeleportationData.MODERN;
32
33
34
35
67
68public class TutorialActivity extends Activity {
69
70
71 private final Player player;
72
73
74
75 private Npc guide;
76
77
78
79 private int stage;
80
81
82
83 private final DialogueFactory factory;
84
85 private boolean completed = false;
86
87
88
89 private TutorialActivity(Player player) {
90 super(2, player.playerAssistant.instance());
91 this.stage = 0;
92 this.player = player;
93 this.factory = player.dialogueFactory;
94 }
95
96
97 public static TutorialActivity create(Player player) {
98 TutorialActivity activity = new TutorialActivity(player);
99 player.runEnergy = 100;
100 CombatSpecial.restore(player, 100);
101 player.send(new SendSpecialAmount());
102 player.movement.setRunningToggled(false);
103 player.playerAssistant.setSidebar(true);
104 player.setVisible(false);
105 player.move(Config.DEFAULT_POSITION);
106 activity.cooldown(3);
107 activity.add(player);
108 player.locking.lock();
109 return activity;
110 }
111
112
113
114 private void update(String... strings) {
115 ActivityPanel.update(player, (int) Utility.getPercentageAmount(stage, 27), "Tutorial", "Progress", strings);
116 }
117
118 @Override
119 public void cooldown(int cooldown) {
120 super.cooldown(cooldown);
121 factory.clear();
122 }
123
124 private void next() {
125 update();
126 cooldown(1);
127 }
128
129 @Override
130 protected void start() {
131 switch (stage) {
132 case 0:
133 guide = new Npc(306, new Position(3086, 3492));
134 add(guide);
135 guide.graphic(new Graphic(86, true));
136 cooldown(2);
137 break;
138 case 1:
139 guide.face(player.getPosition());
140 guide.animate(new Animation(863));
141 guide.speak("Hello, " + player.getName() + "!");
142 cooldown(2);
143 break;
144 case 2:
145 guide.walkExactlyTo(new Position(3086, 3490));
146 cooldown(1);
147 break;
148 case 3:
149 player.face(guide.getPosition());
150 factory.sendNpcChat(306, "Welcome to <col=D63E3E>Tarnish</col>, " + player.getName(), "Would you like a tutorial of our lands?");
151 factory.sendOption("Yes", () -> cooldown(1), "No", this::finish);
152 factory.execute();
153 pause();
154 break;
155 case 4:
156 update("This is the activity panel.", "The activity panel replaces a lot", "of interfaces so be sure", "to get acquainted to it.");
157 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.");
158 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.");
159 factory.onAction(() -> cooldown(1));
160 factory.execute();
161 pause();
162 break;
163 case 5:
164 factory.sendNpcChat(306, "Before I show you around I want to show you", "useful content for your adventures.");
165 factory.onAction(() -> {
166 player.interfaceManager.setSidebar(Config.QUEST_TAB, 29400);
167 player.send(new SendForceTab(Config.QUEST_TAB));
168 next();
169 });
170 factory.execute();
171 pause();
172 break;
173 case 6:
174 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.");
175 factory.sendNpcChat(306, "The blue button will show you the quest tab", "and the green button will show you the achievement tab.");
176 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!");
177 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.");
178 factory.onAction(() -> {
179 player.interfaceManager.setSidebar(Config.QUEST_TAB, -1);
180 player.interfaceManager.setSidebar(Config.WRENCH_TAB, 50020);
181 next();
182 });
183 factory.execute();
184 pause();
185 break;
186 case 7:
187 player.send(new SendForceTab(Config.WRENCH_TAB));
188 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.");
189 factory.onAction(this::next);
190 factory.execute();
191 pause();
192 break;
193 case 8:
194 setInstance(Mob.DEFAULT_INSTANCE);
195 player.instance = Mob.DEFAULT_INSTANCE;
196 player.loadRegion();
197 factory.sendNpcChat(306, "Let's move on.");
198 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);
199 factory.execute();
200 pause();
201 break;
202 case 9:
203 Teleportation.teleport(player, new Position(3091, 3494), MODERN, () -> {
204 player.face(Direction.WEST);
205 next();
206 player.locking.lock();
207 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);
208 factory.execute();
209 });
210 pause();
211 break;
212 case 10:
213 Teleportation.teleport(player, new Position(3086, 3485), MODERN, () -> {
214 player.face(Direction.EAST);
215 next();
216 player.locking.lock();
217 factory.sendNpcChat(306, "These thieving stalls are a very good for making", "quick money.").onAction(this::next).execute();
218 });
219 pause();
220 break;
221 case 11:
222 Teleportation.teleport(player, new Position(3079, 3494), MODERN, () -> {
223 player.face(Direction.NORTH);
224 next();
225 player.locking.lock();
226 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();
227 });
228 pause();
229 break;
230 case 12:
231 Teleportation.teleport(player, new Position(3085, 3501), MODERN, () -> {
232 player.face(Direction.SOUTH);
233 next();
234 player.locking.lock();
235 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();
236 });
237 pause();
238 break;
239 case 13:
240 Teleportation.teleport(player, new Position(3089, 3499), MODERN, () -> {
241 player.face(Direction.EAST);
242 next();
243 player.locking.lock();
244 });
245 pause();
246 break;
247 case 14:
248 factory.sendNpcChat(1143, "Hello #name.", "I am the clan master.");
249 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!");
250 factory.onAction(this::next).execute();
251 pause();
252 break;
253 case 15:
254 Teleportation.teleport(player, Config.DEFAULT_POSITION, MODERN, () -> {
255 player.face(Direction.SOUTH);
256 next();
257 player.locking.lock();
258 });
259 pause();
260 break;
261 case 16:
262 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();
263 pause();
264 break;
265 case 17:
266 completed = true;
267 finish();
268 break;
269 }
270 stage++;
271 }
272
273 @Override
274 public void cleanup() {
275 remove(guide);
276 }
277
278 @Override
279 public void finish() {
280 player.setVisible(true);
281 player.playerAssistant.setSidebar(false);
282 cleanup();
283 remove(player);
284 factory.clear();
285 player.locking.unlock();
286 ActivityPanel.clear(player);
287 if (completed) {
288 AchievementHandler.activate(player, AchievementKey.COMPLETE_TUTORIAL);
289 }
290 if (player.needsStarter) {
291 StarterKit.open(player);
292 }
293 }
294
295 @Override
296 protected boolean clickButton(Player player, ClickButtonInteractionEvent event) {
297 int button = event.getButton();
298 switch (stage) {
299 case 8:
300 if (button == -15496) {
301 factory.lock(false);
302 player.send(new SendMessage(":settingupdate:"));
303 player.interfaceManager.open(28_500);
304 start();
305 }
306 return true;
307 case 9:
308 if (button == 28502) {
309 factory.lock(false);
310 player.interfaceManager.close();
311 start();
312 }
313 return true;
314 case 10:
315 if (button == -15531) {
316 factory.lock(false);
317 player.interfaceManager.setSidebar(Config.WRENCH_TAB, 50300);
318 player.send(new SendConfig(980, 3));
319 next();
320 }
321 return true;
322 case 12:
323 if (button == 850) {
324 factory.lock(false);
325 TeleportHandler.open(player, TeleportType.FAVORITES);
326 start();
327 }
328 return true;
329 case 13:
330 if (button == -7534) {
331 factory.lock(false);
332 player.interfaceManager.close();
333 start();
334 }
335 return true;
336 }
337 return false;
338 }
339
340 @Override
341 public void onRegionChange(Player player) {
342 }
343
344 @Override
345 public void onLogout(Player player) {
346 cleanup();
347 remove(player);
348 player.move(Config.DEFAULT_POSITION);
349
350 if (player.needsStarter) {
351 player.newPlayer = true;
352 }
353 }
354
355 @Override
356 public ActivityType getType() {
357 return ActivityType.TUTORIAL;
358 }
359 }*/