RuneHive-Game
Loading...
Searching...
No Matches
RecipeForDisaster.java
Go to the documentation of this file.
1package com.runehive.content.activity.impl.recipefordisaster;
2
3import com.runehive.content.activity.Activity;
4import com.runehive.content.activity.ActivityDeathType;
5import com.runehive.content.activity.ActivityType;
6import com.runehive.content.activity.panel.ActivityPanel;
7import com.runehive.game.Animation;
8import com.runehive.game.Graphic;
9import com.runehive.game.world.World;
10import com.runehive.game.world.entity.mob.Mob;
11import com.runehive.game.world.entity.mob.npc.Npc;
12import com.runehive.game.world.entity.mob.npc.NpcDeath;
13import com.runehive.game.world.entity.mob.player.Player;
14import com.runehive.game.world.items.Item;
15import com.runehive.game.world.items.ground.GroundItem;
16import com.runehive.game.world.position.Area;
17import com.runehive.game.world.position.Position;
18import com.runehive.net.packet.out.SendEntityHintArrow;
19import com.runehive.net.packet.out.SendMessage;
20import com.runehive.util.RandomUtils;
21import com.runehive.util.Utility;
22
23/**
24 * Handles the recipe for disaster activity.
25 *
26 * @author Daniel
27 * @author Michael
28 */
29public class RecipeForDisaster extends Activity {
30
31 /** The player instance of this activity. */
32 private final Player player;
33
34 /** The boss monster instance of this activity. */
35 private Npc monster;
36
37 /** The current wave of this activity. */
39
40 /** Constructs a new {@code SequencedMinigame} object. */
42 super(10, instance);
43 this.player = player;
44 }
45
46 /** Handles creating a recipe for disaster activity. */
48 RecipeForDisaster minigame = new RecipeForDisaster(player, player.playerAssistant.instance());
49 ActivityPanel.update(player, -1, "Recipe For Disaster", "Good Luck, " + player.getName() + "!", "Wave starting in 6 seconds");
50 player.move(new Position(1899, 5356, 2));
51 GroundItem.create(player, new Item(1580), player.getPosition());
52 player.message("Ice gloves have been dropped for you to fight Flambleed!");
53 player.gameRecord.start();
54 player.playerAssistant.restore();
55 minigame.add(player);
56 minigame.resetCooldown();
57 GroundItem.create(player, new Item(1580), player.getPosition());
58 return minigame;
59 }
60
61 @Override
62 public void update() {
63 if (wave == null) {
64 ActivityPanel.update(player, 100, "Recipe For Disaster", new Item(7462), "</col>Wave: <col=FF5500>" + RecipeForDisasterData.values().length + "/" + RecipeForDisasterData.values().length, "</col>Boss: <col=FF5500>None!", "</col>Time: <col=FF5500>" + Utility.getTime(System.currentTimeMillis() - player.gameRecord.time));
65 return;
66 }
67 int progress = (int) Utility.getPercentageAmount(wave.ordinal(), RecipeForDisasterData.values().length);
68 int display = 7453 + wave.gloves;
69 String npc = monster == null ? "" : monster.getName();
70 ActivityPanel.update(player, progress, "Recipe For Disaster", new Item(display), "</col>Wave: <col=FF5500>" + wave.ordinal() + "/" + RecipeForDisasterData.values().length, "</col>Boss: <col=FF5500>" + npc, "</col>Time: <col=FF5500>" + Utility.getTime(System.currentTimeMillis() - player.gameRecord.time));
71 }
72
73 @Override
74 protected void start() {
75 if (wave == null) {
77 return;
78 }
79 if (player.locking.locked()) {
80 return;
81 }
82 Position spawn = new Position(1899, 5356, 2);
83 Position[] boundaries = Utility.getInnerBoundaries(spawn, 5, 5);
84
85 Npc npc = new Npc(wave.npc, RandomUtils.random(boundaries));
86 npc.owner = player;
87 add(monster = npc);
88
89 player.send(new SendEntityHintArrow(npc));
90 monster.getCombat().attack(player);
91 pause();
92 }
93
94 @Override
95 public void finish() {
96 cleanup();
97 int reward;
98 if (wave == null) {
99 long time = player.gameRecord.end(ActivityType.RECIPE_FOR_DISASTER);
101 player.send(new SendMessage("You have completed the Recipe For Disaster activity. Final time: @red@" + Utility.getTime(time) + "</col>."));
102 } else {
103 reward = wave.gloves;
104 player.send(new SendMessage("RIP"));
105 }
106 if (reward > player.glovesTier) {
107 player.glovesTier = reward;
108 }
109 player.move(new Position(3080, 3498, 0));
110 player.dialogueFactory.sendNpcChat(6526, "You have been rewarded for your efforts.", "Check my store to see your available gloves.").execute();
111 remove(player);
112 }
113
114 @Override
115 public void cleanup() {
116 if (monster != null) {
117 player.send(new SendEntityHintArrow(monster, true));
118 remove(monster);
119 }
121 }
122
123 @Override
124 public boolean canTeleport(Player player) {
125 return true;
126 }
127
128 @Override
130 if (!Area.inRFD(player)) {
131 cleanup();
132 remove(player);
133 }
134 }
135
136 @Override
137 public boolean canUsePrayer(Player player) {
138 player.message("You can not use prayers here!");
139 return false;
140 }
141
142 @Override
143 public void onLogout(Player player) {
144 finish();
145 }
146
147
148 @Override
152
153 @Override
154 public void onDeath(Mob mob) {
155 if (mob.isPlayer()) {
156 cleanup();
157 remove(mob);
158 mob.move(new Position(3080, 3498, 0));
159 mob.animate(Animation.RESET, true);
160 mob.graphic(Graphic.RESET, true);
161 return;
162 }
163 if (mob.isNpc()) {
164 player.send(new SendEntityHintArrow(mob, true));
165 World.schedule(new NpcDeath(mob.getNpc()));
166 wave = wave.getNext();
168 }
169 }
170
171 @Override
175}
Activity(int cooldown, int instance)
Constructs a new SequencedMinigame object.
Definition Activity.java:55
final void resetCooldown()
Resets the remaining ticks to the cached cooldown ticks.
int instance
The activity instance level.
Definition Activity.java:46
final void pause()
Sets the cooldown flag to PAUSE.
void add(Mob mob)
Adds a mob to the activity.
final void finishCooldown()
Sets the cooldown flag to FINISH.
void onLogout(Player player)
Called when the player logs out.
static RecipeForDisaster create(Player player)
Handles creating a recipe for disaster activity.
boolean canTeleport(Player player)
Called when the player attempts to teleport.
void onRegionChange(Player player)
Called when the player changes region.
RecipeForDisaster(Player player, int instance)
Constructs a new SequencedMinigame object.
RecipeForDisasterData wave
The current wave of this activity.
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.
Class that models a single animation used by an entity.
static final Animation RESET
Represents a single graphic that can be used by entities.
Definition Graphic.java:10
static final Graphic RESET
Definition Graphic.java:17
Represents the game world.
Definition World.java:46
static void schedule(Task task)
Submits a new event.
Definition World.java:247
Handles the mob class.
Definition Mob.java:66
void move(Position position)
Moves the mob to a set position.
Definition Mob.java:340
final boolean isNpc()
Check if an entity is an npc.
Definition Mob.java:550
final boolean isPlayer()
Check if an entity is a player.
Definition Mob.java:564
Optional< Graphic > graphic
Definition Mob.java:91
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
The container class that represents an item that can be interacted with.
Definition Item.java:21
Represents a single Ground item on the world map.
static GroundItem create(Player player, Item item)
Creates a new GroundItem object for a player and an item.
Handles checking if mobs are in a certain area.
Definition Area.java:13
static boolean inRFD(Interactable entity)
Definition Area.java:233
Represents a single tile on the game world.
Definition Position.java:14
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 random(T[] array)
Pseudo-randomly retrieves a element from array.
Handles miscellaneous methods.
Definition Utility.java:27
static double getPercentageAmount(int progress, int total)
Gets a percentage amount.
Definition Utility.java:36
static Position[] getInnerBoundaries(Position position, int width, int length)
Definition Utility.java:621
static String getTime()
Gets the current server time and formats it.
Definition Utility.java:141
Holds all activity types that are timed.