1package com.runehive.content.activity.impl.pestcontrol;
3import com.runehive.content.ActivityLog;
4import com.runehive.content.achievement.AchievementHandler;
5import com.runehive.content.achievement.AchievementKey;
6import com.runehive.content.activity.Activity;
7import com.runehive.content.activity.ActivityDeathType;
8import com.runehive.content.activity.ActivityType;
9import com.runehive.content.activity.lobby.LobbyManager;
10import com.runehive.content.activity.lobby.LobbyNode;
11import com.runehive.content.activity.panel.Activity_Panel;
12import com.runehive.content.event.impl.ObjectInteractionEvent;
13import com.runehive.game.Animation;
14import com.runehive.game.Graphic;
15import com.runehive.game.world.World;
16import com.runehive.game.world.entity.Entity;
17import com.runehive.game.world.entity.mob.Mob;
18import com.runehive.game.world.entity.mob.npc.Npc;
19import com.runehive.game.world.entity.mob.npc.NpcDeath;
20import com.runehive.game.world.entity.mob.player.Player;
21import com.runehive.game.world.entity.mob.player.PlayerRight;
22import com.runehive.game.world.items.Item;
23import com.runehive.game.world.pathfinding.TraversalMap;
24import com.runehive.game.world.position.Area;
25import com.runehive.game.world.position.Position;
26import com.runehive.net.packet.out.SendMessage;
27import com.runehive.util.RandomUtils;
28import com.runehive.util.Utility;
30import java.util.HashSet;
31import java.util.Optional;
34import static com.runehive.game.world.entity.combat.attack.listener.SimplifiedListener.CANT_ATTACK;
72 private static final int[]
RAVAGERS = {1704, 1705, 1706, 1707, 1708};
73 private static final int[]
SPLATTERS = {1691, 1692};
74 private static final int[]
SHIFTERS = {1698, 1699, 1700, 1701};
75 private static final int[]
DEFILERS = {1728, 1729};
76 private static final int[]
TORCHERS = {1728, 1729};
81 "Take down the portals",
82 "The Void Knights will not fall!",
83 "Hail the Void Knights!",
84 "We are beating these scum!"
123 if (mob.isPlayer()) {
124 mob.getPlayer().playerAssistant.restore();
129 voidKnight.blockFace =
true;
136 groupMessage(
"Protect the void knight at all costs, good luck!");
145 if (npc.
id >= 1739 && npc.
id <= 1742) {
168 player.
message(
"You cannot log out during a Pest Control game.");
181 if (
event.getObject().getId() == 14314) {
242 for (
int index = 0; index < 5; index++) {
245 for (
int index = 0; index < 5; index++) {
248 for (
int index = 0; index < 5; index++) {
251 for (
int index = 0; index < 5; index++) {
254 for (
int index = 0; index < 2; index++) {
261 Npc monster =
new Npc(
id, target);
272 if (monster.getCombat().inCombat())
274 if (monster.getPosition().isWithinDistance(
voidKnight.getPosition(), 10)) {
281 if (monster.getPosition().isWithinDistance(mob.getPosition(), 8))
282 monster.getCombat().attack(mob);
309 player.dialogueFactory.sendNpcChat(1756,
"Go with strength!",
"Defend the void knight and destroy the portals!",
"You are our only hope!").execute();
320 player.playerAssistant.restore();
329 player.dialogueFactory.sendNpcChat(1756,
"You let the Void Knight die!",
"Keep him alive you noobs...").execute();
335 player.dialogueFactory.sendNpcChat(1756,
"You have disgraced your squad by not dealing any damage.",
"As punishment, you get no points! Teamwork next time!").execute();
340 player.dialogueFactory.sendNpcChat(1756,
"You only dealt " +
damage +
" damage this round.",
"You need to deal at least 50 damage to receive a reward.").execute();
347 player.pestPoints += points;
348 player.dialogueFactory.sendNpcChat(1756,
"You have beaten the minigame!",
"You were rewarded with " + points +
" pest control points.",
"You now have: " +
player.pestPoints +
".").execute();
350 player.dialogueFactory.sendNpcChat(1756,
"You have run out of time!",
"You failed the mission and don't get any points.").execute();
365 player.
send(
new SendMessage(
"Talk to the void-knight next to the boat to leave."));
373 super(
player,
"Pest Control");
381 set(1,
"Players Ready: <col=FF5500>" +
getActiveSize() +
"</col>");
382 set(2,
"(Need <col=FF5500>" +
manager.getMinimumRequired() +
"</col> to " +
manager.getPlayerCapacity() +
" players)");
383 set(3,
"Points: <col=FF5500>" + node.player.pestPoints +
"</col>");
388 set(1,
"Knight's health: <col=FF5500>" +
voidKnight.getCurrentHealth() +
"</col>");
389 set(2,
"Damage: <col=FF5500>" + node.damage +
"</col>");
391 for (
int index = 0; index <= 3; index++) {
392 String value =
"dead";
399 set(3 + index,
PORTAL_NAMES[index] +
": <col=FF5500>" + value +
"</col>");
Handles the achievements.
static void activate(Player player, AchievementKey achievement)
Activates the achievement for the individual player.
A Activity object constructs an in-game activity and sequences it through the start() and finish() me...
Activity(int cooldown, int instance)
Constructs a new SequencedMinigame object.
static final int FINISH
The 'finish' cooldown id.
int getTicks()
Gets the current ticks.
void add(Mob mob)
Adds a mob to the activity.
final void finishCooldown()
Sets the cooldown flag to FINISH.
Activity_Panel panel
The panel for this activity.
void setInstance(int instance)
Optional< Activity_Panel > getPanel()
Gets an optional of the activity panel.
final void removeActivity(Mob mob)
Removes an activity from the activities group.
final void groupMessage(String message)
Sends a message to all the players in the group.
final Map< Mob, Activity > activities
A map of activities that handles each mob individually.
void forEachActivity(BiConsumer< Mob, Activity > activity)
Loops through all the activities.
int getActiveSize()
Gets the size of the activities in this group.
void start()
Starts the next activity stage.
PestControlNode(Player player)
void cleanup()
Cleans up the activity when finished.
void finish()
Finishes the activity.
int damage
The amount of damage the player has dealt.
final PestControlNode node
PestControlPanel(Player player, PestControlNode node)
Portal(int id, Position position)
static final String[] PORTAL_NAMES
The portal names.
Set< Npc > portalSet
The active portals.
static final Position OUTSIDE_BOAT_POSITION
The position outside the pest control boat.
Optional< PestControlListener > getListener()
Gets an Optional of the ActivityListener for this activity.
final Npc voidKnight
The void knight.
Set< Npc > monsters
The active monsters.
static final Position BOAT
The position of the pest control boat.
static final int[] DEFILERS
final Portal[] portals
The portals.
PestControlGame(LobbyManager manager)
static final Position BLUE_BOUNDS
boolean canLogout(Player player)
static final String[] VOID_KNIGHT_MESSAGES
The void knight messages that he will chant.
void finish()
Finishes the activity.
void spawn(int id, Position southWest, int size)
boolean canTeleport(Player player)
Called when the player attempts to teleport.
static final int[] SPLATTERS
static final int[] SHIFTERS
final PestControlListener listener
The Pest control activity listener.
void onDeath(Mob mob)
Called when the player die.
static final int[] RAVAGERS
static final int[] TORCHERS
void sequence()
Sequences the activity.
static final Position YELLOW_BOUNDS
static final Position PURPLE_BOUNDS
Activity createActivity(Player player)
ActivityDeathType deathType()
static final Position RED_BOUNDS
void onLogout(Player player)
Called when the player logs out.
static final Position KNIGHT_BOUNDS
boolean clickObject(Player player, ObjectInteractionEvent event)
void onRegionChange(Player player)
Called when the player changes region.
LobbyNode(LobbyManager manager)
final LobbyManager manager
Activity_Panel(Player player, String header)
void setFooter(String footer)
void setProgress(int progress)
Class that models a single animation used by an entity.
static final Animation RESET
Represents a single graphic that can be used by entities.
static final Graphic RESET
Represents the game world.
static void schedule(Task task)
Submits a new event.
Represents a character in the game world, i.e.
static final int DEFAULT_INSTANCE
void animate(int animation)
void move(Position position)
Moves the mob to a set position.
final boolean isNpc()
Check if an entity is an npc.
Optional< Graphic > graphic
Represents a non-player character in the in-game world.
Npc(int id, Position position)
Combat< Npc > getCombat()
The combat of the mob.
This class represents a character controlled by a player.
void message(String message)
void send(OutgoingPacket encoder)
The container class that represents an item that can be interacted with.
Contains traversal data for a set of regions.
static List< Position > getTraversableTiles(Position southWest, int width, int length)
Returns a List of positions that are traversable from the specified position.
Handles checking if mobs are in a certain area.
static boolean inPestControl(Interactable entity)
Represents a single tile on the game world.
static Position create(int x, int y, int z)
Creates a location.
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.
static int random(int bound)
static double getPercentageAmount(int progress, int total)
Gets a percentage amount.
static< T > T randomElement(Collection< T > collection)
Picks a random element out of any array type.
static String getTime()
Gets the current server time and formats it.
Created by Daniel on 2018-01-28.
Holds all activity types that are timed.
Holds all the player right data.
static int getBloodMoney(Player player)