1package com.runehive.game.world.entity.mob.player;
3import com.runehive.Config;
4import com.runehive.content.StarterKit;
5import com.runehive.content.ValueIcon;
6import com.runehive.content.achievement.AchievementWriter;
7import com.runehive.content.activity.Activity;
8import com.runehive.content.activity.ActivityType;
9import com.runehive.content.activity.GroupActivity;
10import com.runehive.content.activity.impl.CerberusActivity;
11import com.runehive.content.activity.impl.JailActivity;
12import com.runehive.content.activity.impl.VorkathActivity;
13import com.runehive.content.activity.impl.barrows.Barrows;
14import com.runehive.content.activity.impl.godwars.GodwarsActivity;
15import com.runehive.content.activity.impl.kraken.KrakenActivity;
16import com.runehive.content.activity.impl.warriorguild.WarriorGuild;
17import com.runehive.content.clanchannel.channel.ClanChannelHandler;
18import com.runehive.content.collectionlog.CollectionLogSaving;
19import com.runehive.content.emote.EmoteHandler;
20import com.runehive.content.pet.Pets;
21import com.runehive.content.skill.impl.farming.Farming;
22import com.runehive.content.skill.impl.magic.teleport.TeleportType;
23import com.runehive.content.skillcape.SkillCape;
24import com.runehive.content.writer.InterfaceWriter;
25import com.runehive.content.writer.impl.InformationWriter;
26import com.runehive.game.task.impl.SuperAntipoisonTask;
27import com.runehive.game.task.impl.TeleblockTask;
28import com.runehive.game.world.World;
29import com.runehive.game.world.entity.combat.CombatConstants;
30import com.runehive.game.world.entity.combat.CombatTarget;
31import com.runehive.game.world.entity.combat.CombatType;
32import com.runehive.game.world.entity.combat.CombatUtil;
33import com.runehive.game.world.entity.combat.attack.FormulaFactory;
34import com.runehive.game.world.entity.combat.attack.listener.other.PrayerListener;
35import com.runehive.game.world.entity.combat.attack.listener.other.VengeanceListener;
36import com.runehive.game.world.entity.combat.effect.CombatEffectType;
37import com.runehive.game.world.entity.combat.strategy.CombatStrategy;
38import com.runehive.game.world.entity.combat.strategy.player.PlayerMagicStrategy;
39import com.runehive.game.world.entity.combat.strategy.player.PlayerMeleeStrategy;
40import com.runehive.game.world.entity.combat.strategy.player.PlayerRangedStrategy;
41import com.runehive.game.world.entity.combat.strategy.player.custom.*;
42import com.runehive.game.world.entity.combat.strategy.player.special.CombatSpecial;
43import com.runehive.game.world.entity.combat.weapon.WeaponInterface;
44import com.runehive.game.world.entity.mob.Mob;
45import com.runehive.game.world.entity.mob.UpdateFlag;
46import com.runehive.game.world.entity.mob.npc.definition.NpcDefinition;
47import com.runehive.game.world.entity.mob.prayer.Prayer;
48import com.runehive.game.world.entity.skill.Skill;
49import com.runehive.game.world.items.Item;
50import com.runehive.game.world.items.containers.ItemContainer;
51import com.runehive.game.world.items.containers.equipment.Equipment;
52import com.runehive.game.world.items.containers.pricechecker.PriceType;
53import com.runehive.game.world.position.Area;
54import com.runehive.game.world.position.Position;
55import com.runehive.net.packet.out.*;
56import com.runehive.net.packet.out.SendWidget.WidgetType;
57import com.runehive.util.TinterfaceText;
58import com.runehive.util.Utility;
60import java.util.Arrays;
61import java.util.HashMap;
63import java.util.function.Consumer;
97 player.runePouch.refresh();
102 if (
player.getPoisonImmunity().get() > 0) {
105 if (
player.skulling.getSkullRemoveTask().getSkullTime() > 0) {
109 if (
player.teleblockTimer.get() > 0) {
132 player.getCombat().tick();
140 if (
player.sequence % 20 == 0) {
147 if (
player.isSingleCast())
151 if (
player.isSpecialActivated()) {
152 if (
player.getCombatSpecial() ==
null) {
153 player.setSpecialActivated(
false);
156 return player.getCombatSpecial().getStrategy();
161 if(item.
getId() == 22325) {
164 if (item.
getId() == 11907) {
167 if (item.
getId() == 27275) {
171 if (item.
getId() == 12899) {
175 if (item.
getId() == 12926) {
188 if (
player.getSpecialPercentage().get() < 100 &&
player.sequence % 60 == 0)
210 player.attributes.set(
"OBELISK", -1);
211 player.attributes.set(
"BANK_KEY",
false);
212 player.attributes.set(
"TRADE_KEY",
false);
213 player.attributes.set(
"DUEL_KEY",
false);
214 player.attributes.set(
"RUN_FLAG_KEY", 10);
215 player.attributes.set(
"PLAYER_TITLE_KEY", 0);
216 player.attributes.set(
"FORCE_MOVEMENT",
false);
217 player.attributes.set(
"PRELOADING_SLOT_KEY", 0);
218 player.attributes.set(
"PERSONAL_STORE_KEY",
null);
219 player.attributes.set(
"PRICE_CHECKER_KEY",
false);
220 player.attributes.set(
"DONATOR_DEPOSIT_KEY",
false);
227 if (
player.punishment.isJailed()) {
229 }
else if (
player.needsStarter) {
271 Consumer<Prayer> enable =
prayer -> {
276 prayer.getListener().ifPresent(listener ->
player.getCombat().addListener(listener));
278 Consumer<Prayer> disable =
prayer -> {
283 prayer.getListener().ifPresent(listener ->
player.getCombat().removeListener(listener));
285 Consumer<Prayer> overhead =
prayer -> {
286 player.headIcon =
prayer.getHeadIcon();
289 Consumer<Prayer> noOverhead =
prayer -> {
290 player.headIcon = -1;
293 player.prayer.setOnChange(enable, disable, overhead, noOverhead);
296 player.quickPrayers.setOnChange(qEnable, qDisable,
null,
null);
311 player.runEnergy = 100;
312 player.skulling.unskull();
313 player.skills.restoreAll();
314 player.inventory.refresh();
317 player.interfaceManager.close();
318 player.setSpecialActivated(
false);
320 player.getCombat().getDamageCache().clear();
323 player.teleblockTimer.set(0);
324 player.spellCasting.castingDelay.reset();
325 player.spellCasting.vengeanceDelay.reset();
328 player.venged =
false;
342 player.getCombat().reset();
344 player.headIcon = -1;
368 player.runEnergy = 0;
369 if (
player.runEnergy == 0)
370 player.movement.setRunningToggled(
false);
380 if (
player.runEnergy < 100) {
382 if (
player.sequence % rate == 0) {
387 if (
player.energyRate > 0) {
394 player.skillingPoints += amount;
395 player.message(
"<col=D4379A>You have earned " + amount +
" skilling point" + (amount > 1 ?
"" :
"s") +
". You now have a total of " +
Utility.
formatDigits(
player.skillingPoints) +
".");
401 if (
player.sequence % 120 != 0 &&
player.sequence % 50 != 0)
408 for (
int index = 0; index <= 6; index++) {
416 if (
player.sequence % amount == 0)
417 player.skills.regress(index);
423 if (!
player.prayer.isActive()) {
427 int rate =
player.prayer.drainAmount(bonus);
434 skill.modifyLevel(level -> level - amount, 0,
skill.getLevel());
437 if (
skill.getLevel() == 0) {
438 player.send(
new SendMessage(
"You have run out of prayer points; you must recharge at an altar."));
454 player.message(
"You must be an ironman to claim this armour.");
462 player.inventory.clear(
false);
463 player.equipment.clear(
false);
464 player.inventory.addAll(inventory);
465 player.equipment.manualWearAll(equipment);
466 player.inventory.refresh();
473 player.mobAnimation.reset();
479 player.mobAnimation.setStand(def.getStand());
480 player.mobAnimation.setWalk(def.getWalk());
481 player.mobAnimation.setTurn180(def.getTurn180());
482 player.mobAnimation.setTurn90CW(def.getTurn90CW());
483 player.mobAnimation.setTurn90CCW(def.getTurn90CCW());
484 player.setWidth(def.getSize());
485 player.setLength(def.getSize());
546 player.send(
new SendString(
"Are you sure you want to destroy this item?", 14174));
554 player.attributes.set(
"DESTROY_ITEM_KEY",
slot);
559 if (
player.attributes.has(
"UNCHARGE_HELM_KEY")) {
560 Item item =
player.attributes.get(
"UNCHARGE_HELM_KEY");
561 player.dialogueFactory.clear();
562 player.inventory.replace(item,
new Item(12_934, 20_000),
true);
564 player.attributes.remove(
"UNCHARGE_HELM_KEY");
568 if (
player.attributes.has(
"RESTORE_HELM_KEY")) {
569 Item item =
player.attributes.get(
"RESTORE_HELM_KEY");
570 player.dialogueFactory.clear();
572 player.serpentineHelmCharges +=
player.tanzaniteHelmCharges;
573 player.tanzaniteHelmCharges = 0;
574 if (
player.serpentineHelmCharges > 11_000) {
575 player.inventory.addOrDrop(
new Item(12934,
player.serpentineHelmCharges - 11_000));
576 player.serpentineHelmCharges = 11_000;
578 player.inventory.replace(item,
new Item(
player.serpentineHelmCharges <= 0 ? 12_929 : 12_931),
true);
580 player.serpentineHelmCharges +=
player.magmaHelmCharges;
581 player.magmaHelmCharges = 0;
582 if (
player.serpentineHelmCharges > 11_000) {
583 player.inventory.addOrDrop(
new Item(12934,
player.serpentineHelmCharges - 11_000));
584 player.serpentineHelmCharges = 11_000;
587 player.inventory.replace(item,
new Item(
player.serpentineHelmCharges <= 0 ? 12_929 : 12_931),
true);
589 player.attributes.remove(
"RESTORE_HELM_KEY");
593 int index =
player.attributes.get(
"DESTROY_ITEM_KEY", Integer.class);
599 player.dialogueFactory.clear();
600 player.inventory.remove(item, index);
602 player.attributes.remove(
"DESTROY_ITEM_KEY");
606 return player.inventory.contains(item) ||
player.equipment.contains(item) ||
player.bank.contains(item);
611 double KDR = (player.kill / (double)
player.death);
612 return Double.isNaN(KDR) ?
"0.0" : String.format(
"%.2f", KDR);
619 player.getCombat().removeFirst();
625 return player.getIndex() << 2;
632 if (
player.skills.getMaxLevel(index) == 99)
662 if (carrying < 500_000)
664 if (carrying > 500_000 && carrying < 1_500_000)
666 if (carrying > 1_500_000 && carrying < 5_000_000)
668 if (carrying > 5_000_000 && carrying < 25_000_000)
670 if (carrying > 25_000_000)
679 final int currentIcon =
player.valueIcon;
681 if (icon.
getCode() == currentIcon) {
685 player.valueIcon = icon.
getCode();
690 return (
player.skills.getCombatLevel() - 10 < 3 ? 3 :
player.skills.getCombatLevel() - 10) +
" - " + (
player.skills.getCombatLevel() + 10 > 126 ? 126 :
player.skills.getCombatLevel() + 10);
695 return !
player.interfaceManager.isMainClear() ||
player.isDead() || player.newPlayer ||
705 2572, 11988, 11986, 11984, 11982, 11980
721 if (
player.equipment.contains(row)) {
723 player.message(
"<col=7F007F>" + (index == 0 ?
"You have used your last charge." :
"Your ring of wealth has " +
Utility.
convertWord(index).toLowerCase() +
"charge" + (index == 1 ?
"" :
"s") +
" remaining."));
738 t.currentState = text;
The class that contains setting-related constants for the server.
static final int MAGIC_TAB
static final int[][] SIDEBAR_INTERFACE
Holds the array of all the side-bar identification and their corresponding itemcontainer identificati...
Handles the starter kits.
static void open(Player player)
Handles opening the starter kit interface.
Handles the achievement tab.
A Activity object constructs an in-game activity and sequences it through the start() and finish() me...
static void forActivity(Mob mob, Consumer< Activity > consumer)
A GroupActivity is an extension of Activity that holds a list of active activities.
Created by Daniel on 2018-01-20.
static CerberusActivity create(Player player)
static JailActivity create(Player player)
The activity for Vorkath.
static VorkathActivity create(Player player)
Creates a new Vorkath activity for the player.
static Barrows create(Player player)
Handles the godwars activity.
static GodwarsActivity create(Player player)
Creates the godwars activity for the player.
static KrakenActivity create(Player player)
Creates a new Kraken activity.
This class handles the warrior's guild activity.
static WarriorGuild create(Player player)
Handes creating a new warrior guild activity for the player.
The handler for the clan channel.
static void onLogin(Player player)
Handles logging into the server.
static CollectionLog load(Player player)
This class handles emotes from the emote tab and skill cape.
static void refresh(Player player)
Handles refreshing the emote tab.
Handles spawning, rewarding and picking up of pets.
static void onLogin(Player player)
Handles what happens to a pet when a player logs in.
static void tick(Player player)
Handles writing on an itemcontainer.
static void write(InterfaceWriter writer)
Class handles writing on the quest tab itemcontainer.
This randomevent handles the teleblock counter.
Represents the game world.
static void schedule(Task task)
Submits a new event.
static final int COMBAT_LOGOUT_COOLDOWN
The amount of time it takes in milliseconds it takes to logout.
void checkAggression(Position spawn)
Checks the aggression for this mob if a target is set.
A collection of util methods and constants related to combat.
static boolean cancelEffect(Mob mob, CombatEffectType effect)
Cancels the effect in any context.
static PrayerListener get()
static VengeanceListener get()
static PlayerMeleeStrategy get()
static PlayerRangedStrategy get()
static ScytheOfViturStrategy get()
static ToxicBlowpipeStrategy get()
static TridentOfTheSeasStrategy get()
static TridentOfTheSwampStrategy get()
static TumekenStrategy get()
Contains the npc definitions.
static NpcDefinition get(int id)
Gets a npc definition from the definition array.
boolean busy()
Checks if player is busy.
void setAttribute()
Sets all the player attributes.
void updateSpecial()
Updates the special amount.
void runRestore()
Handles restoring the run energy.
void run()
Handles the running.
double weight()
Gets the total carried weight of the player.
void claimIronmanArmour()
void setWidget()
Sends all the widget data to the client.
void setContextMenu()
Sends the context menu to the Player's context.
void drainPrayer(int amount)
static final int[] RING_OF_WEALTH
void moveCamera(Position position, int resetDelay)
void skillRestore()
Handles restoration of skills.
void clearSendStrings()
Clears the send strings.
void prayerDrain()
Handles draining prayer.
final void setSidebar(boolean disabled)
Sends all the side-bar identifications to the Player's client.
long networth(ItemContainer... containers)
Gets the net worth of the player.
int instance()
Gets the instanced height for player.
void restore()
Resets the player's variables.
boolean contains(Item item)
CombatStrategy< Player > getStrategy()
Handles getting the combat strategy.
ValueIcon getValueIcon(Player player)
void activateSkilling(int amount)
final void setSidebar(boolean disabled, boolean login)
void setEffects()
Sets the effects for the player.
void sequence()
Handles the method that will occur on sequence.
void copy(Player other)
Copy's the inventory and equipment of another player.
void welcomeScreen()
Handles displaying the welcome itemcontainer.
int getMaxHit(Mob defender, CombatType type)
Gets the max hit of a combat type.
void destroyItem(Item item, int slot)
Handles sending the destroy item dialogue.
void initialize()
initializes the player's random bs.
void resetEffects()
Reset's all the player's activated effects.
int getROWIndex(int item)
void setActivity()
Sets the activity for the player.
void setPrayer()
Sets the prayer book.
String kdr()
Gets the KDR of the player.
int getMaxSkillCount()
Gets the total amount of 99s the player has.
void reset()
Resets the player's variables.
Map< Integer, TinterfaceText > interfaceText
Holds itemcontainer strings.
final void login()
Handles initializing all the player assistant methods on login.
boolean checkSendString(String text, int id)
Checks if the string is already stored in the list.
PlayerAssistant(Player player)
Creates a new PlayerAssistant
void handleDestroyItem()
Handles destroying the item.
final Player player
The player instance.
void transform(int npc)
Tranforms player into npc.
This class represents a character controlled by a player.
final Inventory inventory
final Equipment equipment
Represents a trainable and usable skill.
static final int PRAYER
The prayer skill id.
static final int SKILL_COUNT
The amount of available skills.
static final int HITPOINTS
The hitpoints skill id.
The container class that represents an item that can be interacted with.
Optional< RangedWeaponDefinition > getRangedDefinition()
final int getId()
Gets the identification of this item.
boolean matchesId(int id)
An abstraction game representing a group of Items.
final Item[] toArray()
Returns a shallow copy of the backing array.
The container that manages the equipment for a player.
static final int PRAYER_BONUS
static final int RING_SLOT
static final int WEAPON_SLOT
Handles checking if mobs are in a certain area.
static boolean inVorkath(Interactable entity)
static boolean inBarrows(Entity entity)
static boolean inDuelArenaLobby(Entity entity)
static boolean inKraken(Interactable entity)
static boolean inDuelArena(Interactable entity)
static boolean inWilderness(Position position)
static boolean inGodwars(Interactable entity)
static boolean inCerberus(Interactable entity)
static boolean inDuelObsticleArena(Interactable entity)
static boolean inWarriorGuild(Interactable entity)
Represents a single tile on the game world.
The OutgoingPacket resets the camera position for Player.
The OutgoingPacket responsible for changing settings on a client.
The OutgoingPacket that sends a message to a Players chatbox in the client.
Shows a player options such as right clicking a player.
Handles sending the special attack amount (used for the orb).
The OutgoingPacket that sends a string to a Players itemcontainer in the client.
Handles miscellaneous methods.
static boolean hasOneOutOf(double chance)
static String formatDigits(final int amount)
Formats digits for integers.
static String convertWord(int amount)
Converts an integer into words.
Holds all activity types that are timed.
FAVORITES
Favorite teleport.
static boolean isEquipped(Player player, SkillCape cape)
The enumerated type whose values represent the collection of different combat effect types.
The enumerated type whose elements represent the combat special attacks.
static void restore(Player player, int amount)
Restores the special bar for player.
The enumerated type whose elements represent the weapon interfaces.
static void execute(Player player, Item item)
The method executed when weapon item is equipped or unequipped that assigns a weapon interface to pla...
Represents the options for right-clicking players.
DUEL_REQUEST
The option for challenging another player to a duel.
ATTACK
The option for attacking another player.
FOLLOW
The option for following another player.
VIEW_PROFILE
The option for moderators and staff which brings up the report abuse option.
TRADE_REQUEST
The option for trading another player.
Holds all the player right data.
static boolean isDeveloper(Player player)
Checks if the player has developer status.
VALUE
The value price type.