RuneHive-Game
Loading...
Searching...
No Matches
PlayerAssistant.java
Go to the documentation of this file.
1package com.runehive.game.world.entity.mob.player;
2
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;
59
60import java.util.Arrays;
61import java.util.HashMap;
62import java.util.Map;
63import java.util.function.Consumer;
64
65/**
66 * Method handles small methods for players that do not have any parent class.
67 *
68 * @author Daniel | Obey
69 */
70public class PlayerAssistant {
71
72 /** The player instance. */
73 private final Player player;
74
75 /** Holds itemcontainer strings. */
76 private Map<Integer, TinterfaceText> interfaceText = new HashMap<>();
77
78 /** Creates a new <code>PlayerAssistant<code> */
80 this.player = player;
81 }
82
83 /** Handles initializing all the player assistant methods on login. */
84 public final void login() {
85 reset();
87 setPrayer();
88 initialize();
89 setSidebar(false, true);
92 setEffects();
96 player.setCollectionLog(CollectionLogSaving.load(player));
97 player.runePouch.refresh();
98 }
99
100 /** Sets the effects for the player. */
101 private void setEffects() {
102 if (player.getPoisonImmunity().get() > 0) {
104 }
105 if (player.skulling.getSkullRemoveTask().getSkullTime() > 0) {
106 player.skulling.skull();
107 }
108
109 if (player.teleblockTimer.get() > 0) {
110 player.send(new SendWidget(SendWidget.WidgetType.TELEBLOCK, (int) ((double) player.teleblockTimer.get() / 1000D * 600D)));
112 }
113
114 }
115
116 /** initializes the player's random bs. */
117 private void initialize() {
118 player.getCombat().resetTimers(-CombatConstants.COMBAT_LOGOUT_COOLDOWN);
119 player.send(new SendEntityFeed());
120 player.send(new SendSpecialAmount());
123 }
124
125 /** Handles the method that will occur on sequence. */
126 public void sequence() {
127 skillRestore();
129 prayerDrain();
130 run();
131 runRestore();
132 player.getCombat().tick();
134 if (!(it instanceof GroupActivity))
135 it.sequence();
136 });
137
139
140 if (player.sequence % 20 == 0) {
142 }
143 }
144
145 /** Handles getting the combat strategy. */
147 if (player.isSingleCast())
148 return new PlayerMagicStrategy(player.getSingleCastSpell());
149 if (player.isAutocast())
150 return new PlayerMagicStrategy(player.getAutocastSpell());
151 if (player.isSpecialActivated()) {
152 if (player.getCombatSpecial() == null) {
153 player.setSpecialActivated(false);
154 player.send(new SendSpecialEnabled(0));
155 } else {
156 return player.getCombatSpecial().getStrategy();
157 }
158 }
159 Item item = player.equipment.get(Equipment.WEAPON_SLOT);
160 if (item != null) {
161 if(item.getId() == 22325) {
162 return ScytheOfViturStrategy.get();
163 }
164 if (item.getId() == 11907) {
166 }
167 if (item.getId() == 27275) {
168 return TumekenStrategy.get();
169 }
170
171 if (item.getId() == 12899) {
173 }
174
175 if (item.getId() == 12926) {
176 return ToxicBlowpipeStrategy.get();
177 }
178
179 if (item.getRangedDefinition().isPresent()) {
180 return PlayerRangedStrategy.get();
181 }
182 }
183 return PlayerMeleeStrategy.get();
184 }
185
186 /** Updates the special amount. */
187 private void updateSpecial() {
188 if (player.getSpecialPercentage().get() < 100 && player.sequence % 60 == 0)
190 }
191
192 /** Sends all the side-bar identifications to the {@code Player}'s client. **/
193 public final void setSidebar(boolean disabled) {
194 setSidebar(disabled, false);
195 }
196
197 public final void setSidebar(boolean disabled, boolean login) {
198 for (int index = 0; index < Config.SIDEBAR_INTERFACE.length; index++) {
199 player.interfaceManager.setSidebar(Config.SIDEBAR_INTERFACE[index][0], disabled ? -1 : Config.SIDEBAR_INTERFACE[index][1]);
200 }
201 player.interfaceManager.setSidebar(Config.MAGIC_TAB, disabled ? -1 : player.spellbook.getInterfaceId());
202 if (!disabled) {
203 WeaponInterface.execute(player, player.equipment.getWeapon(), login);
204 player.send(new SendConfig(980, 0));
205 }
206 }
207
208 /** Sets all the player attributes. */
209 private void setAttribute() {
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);
221 player.attributes.set("TELEPORT_TYPE_KEY", TeleportType.FAVORITES);
222 }
223
224 /** Sets the activity for the player. */
225 private void setActivity() {
226
227 if (player.punishment.isJailed()) {
229 } else if (player.needsStarter) {
231 } else if (Area.inGodwars(player)) {
233 } else if (Area.inWarriorGuild(player)) {
235 } else if (Area.inBarrows(player)) {
237 } else if (Area.inVorkath(player)) {
239 } else if (Area.inKraken(player)) {
241 } else if (Area.inCerberus(player)) {
243 } else if (Area.inWilderness(player)) {
244 player.valueIcon = getValueIcon(player).getCode();
245 player.updateFlags.add(UpdateFlag.APPEARANCE);
246 }
247 }
248
249 /** Sends the context menu to the {@code Player}'s context. */
250 private void setContextMenu() {
253 player.send(new SendPlayerOption(PlayerOption.ATTACK, false, true));
254 /* } else if (Area.inWilderness(player) || Area.inEventArena(player)) {
255 player.send(new SendPlayerOption(PlayerOption.ATTACK, true));
256 player.send(new SendPlayerOption(PlayerOption.DUEL_REQUEST, false, true));*/
259 player.send(new SendPlayerOption(PlayerOption.DUEL_REQUEST, false, true));
260 } else {
261 player.send(new SendPlayerOption(PlayerOption.ATTACK, false, true));
262 player.send(new SendPlayerOption(PlayerOption.DUEL_REQUEST, false, true));
263 }
264 player.send(new SendPlayerOption(PlayerOption.FOLLOW, false));
267 }
268
269 /** Sets the prayer book. */
270 public void setPrayer() {
271 Consumer<Prayer> enable = prayer -> {
272 if (player.prayer.anyActive(Prayer.RETRIBUTION, Prayer.REDEMPTION, Prayer.SMITE)) {
273 player.getCombat().addListener(PrayerListener.get());
274 }
275 player.send(new SendConfig(prayer.getConfig(), 1));
276 prayer.getListener().ifPresent(listener -> player.getCombat().addListener(listener));
277 };
278 Consumer<Prayer> disable = prayer -> {
280 player.getCombat().removeListener(PrayerListener.get());
281 }
282 player.send(new SendConfig(prayer.getConfig(), 0));
283 prayer.getListener().ifPresent(listener -> player.getCombat().removeListener(listener));
284 };
285 Consumer<Prayer> overhead = prayer -> {
286 player.headIcon = prayer.getHeadIcon();
287 player.updateFlags.add(UpdateFlag.APPEARANCE);
288 };
289 Consumer<Prayer> noOverhead = prayer -> {
290 player.headIcon = -1;
291 player.updateFlags.add(UpdateFlag.APPEARANCE);
292 };
293 player.prayer.setOnChange(enable, disable, overhead, noOverhead);
294 Consumer<Prayer> qEnable = prayer -> player.send(new SendConfig(prayer.getQConfig(), 0));
295 Consumer<Prayer> qDisable = prayer -> player.send(new SendConfig(prayer.getQConfig(), 1));
296 player.quickPrayers.setOnChange(qEnable, qDisable, null, null);
297 Arrays.stream(Prayer.values()).forEach(prayer -> {
298 disable.accept(prayer);
299
300 if (player.quickPrayers.isActive(prayer)) {
301 qEnable.accept(prayer);
302 } else {
303 qDisable.accept(prayer);
304 }
305 });
306 }
307
308 /** Resets the player's variables. */
309 public void restore() {
310 reset();
311 player.runEnergy = 100;
312 player.skulling.unskull();
313 player.skills.restoreAll();
314 player.inventory.refresh();
315 player.equipment.login();
316 player.action.reset();
317 player.interfaceManager.close();
318 player.setSpecialActivated(false);
319 player.send(new SendSpecialEnabled(0));
320 player.getCombat().getDamageCache().clear();
321 player.send(new SendRunEnergy());
322 player.movement.reset();
323 player.teleblockTimer.set(0);
324 player.spellCasting.castingDelay.reset();
325 player.spellCasting.vengeanceDelay.reset();
326
327 if (player.venged) {
328 player.venged = false;
329 player.getCombat().removeListener(VengeanceListener.get());
330 }
331
333 }
334
335 /** Resets the player's variables. */
336 public void reset() {
337 player.unpoison();
338 player.unvenom();
339 resetEffects();
340 setWidget();
341 player.movement.reset();
342 player.getCombat().reset();
343 player.prayer.reset();
344 player.headIcon = -1;
345 player.updateFlags.add(UpdateFlag.APPEARANCE);
346 }
347
348 /** Reset's all the player's activated effects. */
355
356 /** Sends all the widget data to the client. */
357 public void setWidget() {
358 for (WidgetType widget : WidgetType.values()) {
359 player.send(new SendWidget(widget, 0));
360 }
361 }
362
363 /** Handles the running. */
364 private void run() {
365 if (player.movement.isRunning() && player.movement.isMoving() && !player.isBot && !PlayerRight.isDeveloper(player)) {
366 player.runEnergy--;
367 if (player.runEnergy < 0)
368 player.runEnergy = 0;
369 if (player.runEnergy == 0)
370 player.movement.setRunningToggled(false);
371 player.send(new SendRunEnergy());
372 }
373 }
374
375 /** Handles restoring the run energy. */
376 private void runRestore() {
377 if (player.resting && player.sequence % 50 == 0) {
378 player.animate(player.right.getRestAnimation());
379 }
380 if (player.runEnergy < 100) {
381 int rate = player.energyRate > 0 ? 2 : player.resting || SkillCape.isEquipped(player, SkillCape.AGILITY) ? 3 : 4;
382 if (player.sequence % rate == 0) {
383 player.runEnergy++;
384 player.send(new SendRunEnergy());
385 }
386 }
387 if (player.energyRate > 0) {
388 player.energyRate--;
389 }
390 }
391
392 public void activateSkilling(int amount) {
393 if (Utility.hasOneOutOf(30)) {
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) + ".");
396 }
397 }
398
399 /** Handles restoration of skills. */
400 private void skillRestore() {
401 if (player.sequence % 120 != 0 && player.sequence % 50 != 0)
402 return;
403 if (player.sequence % (SkillCape.isEquipped(player, SkillCape.HITPOINTS) ? 50 : 100) == 0) {
404 player.skills.regress(Skill.HITPOINTS);
405 } else if (player.sequence % 50 == 0 && player.prayer.isActive(Prayer.RAPID_HEAL)) {
406 player.skills.regress(Skill.HITPOINTS);
407 }
408 for (int index = 0; index <= 6; index++) {
409 if (index == Skill.HITPOINTS || index == Skill.PRAYER) continue;
410 int amount = 100;
411 Skill skill = player.skills.get(index);
412 if (skill.getLevel() < skill.getMaxLevel() && player.prayer.isActive(Prayer.RAPID_RESTORE))
413 amount = 50;
414 if (skill.getLevel() > skill.getMaxLevel() && player.prayer.isActive(Prayer.PRESERVE))
415 amount = 150;
416 if (player.sequence % amount == 0)
417 player.skills.regress(index);
418 }
419 }
420
421 /** Handles draining prayer. */
422 private void prayerDrain() {
423 if (!player.prayer.isActive()) {
424 return;
425 }
426 int bonus = player.getBonus(Equipment.PRAYER_BONUS);
427 int rate = player.prayer.drainAmount(bonus);
428 drainPrayer(rate);
429 }
430
431 public void drainPrayer(int amount) {
432 if (amount > 0) {
433 Skill skill = player.skills.get(Skill.PRAYER);
434 skill.modifyLevel(level -> level - amount, 0, skill.getLevel());
435 player.skills.refresh(Skill.PRAYER);
436
437 if (skill.getLevel() == 0) {
438 player.send(new SendMessage("You have run out of prayer points; you must recharge at an altar."));
439 player.prayer.reset();
440 player.getPlayer().send(new SendConfig(659, 0));
441 }
442 }
443 }
444
445 public void claimIronmanArmour() {
446 if (player.right == PlayerRight.IRONMAN) {
447 player.inventory.addOrDrop(new Item(12810), new Item(12811), new Item(12812));
448 } else if (player.right == PlayerRight.ULTIMATE_IRONMAN) {
449 player.inventory.addOrDrop(new Item(12813), new Item(12814), new Item(12815));
450 } else if (player.right == PlayerRight.HARDCORE_IRONMAN) {
451 player.inventory.addOrDrop(new Item(20792), new Item(20794), new Item(20796));
452 }
453 else {
454 player.message("You must be an ironman to claim this armour.");
455 }
456 }
457
458 /** Copy's the inventory and equipment of another player. */
459 public void copy(Player other) {
460 Item[] inventory = other.inventory.toArray();
461 Item[] equipment = other.equipment.toArray();
462 player.inventory.clear(false);
463 player.equipment.clear(false);
464 player.inventory.addAll(inventory);
465 player.equipment.manualWearAll(equipment);
466 player.inventory.refresh();
467 player.equipment.login();
468 }
469
470 /** Tranforms player into npc. */
471 public void transform(int npc) {
472 if (npc == -1) {
473 player.mobAnimation.reset();
474 player.setWidth(1);
475 player.setLength(1);
476 } else {
478 if (def != null) {
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());
486 }
487 }
488 player.id = npc;
489 player.updateFlags.add(UpdateFlag.APPEARANCE);
490 }
491
492 /** Handles displaying the welcome itemcontainer. */
494 player.setVisible(true);
495
496// boolean wants = player.settings.welcomeScreen;
497// if (!wants || Area.inWilderness(player) || player.getCombat().inCombat() || player.newPlayer || player.needsStarter) {
498// player.setVisible(true);
499// player.send(new SendScreenMode(player.settings.clientWidth, player.settings.clientHeight));
500// return;
501// }
502// if (player.settings.clientWidth > 765 || player.settings.clientWidth > 503) {
503// player.settings.clientWidth = 765;
504// player.settings.clientHeight = 503;
505// player.send(new SendScreenMode(765, 503));
506// }
507// for (int index = 0; index < 3; index++) {
508// player.send(new SendString(Config.WELCOME_DIALOGUE[index], 21315 + index));
509// }
510// player.send(new SendInterfaceAnimation(21310, Expression.HAPPY.getId()));
511// player.send(new SendMarquee(21319, Config.WELCOME_MARQUEE));
512// player.send(new SendString("You last logged in <col=EB4646>earlier today</col>.", 21318));//TODO
513// //black marks
514// player.send(new SendString("", 21320));
515// player.send(new SendString("You have 0 black marks!", 21321));
516// player.send(new SendString("Keep up the good work!", 21322));
517// player.send(new SendString("", 21323));
518// //bank pins
519// player.send(new SendString("You do not have a bank", 21324));
520// player.send(new SendString("pin set! Speak to any", 21325));
521// player.send(new SendString("banker to set one.", 21326));
522// player.send(new SendString("Bank pins are security!", 21327));
523// //other
524// player.send(new SendString("Click to vote", 21328));
525// player.send(new SendString("Click to donate", 21329));
526// player.send(new SendString("Click change e-mail", 21330));
527// player.send(new SendString("Click to change pass", 21331));
528// //announcement
529// player.send(new SendString(Config.WELCOME_ANNOUNCEMENT[0], 21332));
530// player.send(new SendString(Config.WELCOME_ANNOUNCEMENT[1], 21333));
531// player.send(new SendString(Config.WELCOME_ANNOUNCEMENT[2], 21334));
532// player.send(new SendString(Config.WELCOME_ANNOUNCEMENT[3], 21335));
533// player.send(new SendString(Config.WELCOME_ANNOUNCEMENT[4], 21336));
534// //update
535// player.send(new SendString(Config.WELCOME_UPDATE[0], 21337));
536// player.send(new SendString(Config.WELCOME_UPDATE[1], 21338));
537// player.send(new SendString(Config.WELCOME_UPDATE[2], 21339));
538// player.send(new SendString(Config.WELCOME_UPDATE[3], 21340));
539// player.send(new SendString(Config.WELCOME_UPDATE[4], 21341));
540// player.interfaceManager.open(450);
541 }
542
543 /** Handles sending the destroy item dialogue. */
544 public void destroyItem(Item item, int slot) {
545 player.send(new SendItemOnInterfaceSlot(14171, item, 0));
546 player.send(new SendString("Are you sure you want to destroy this item?", 14174));
547 player.send(new SendString("Yes.", 14175));
548 player.send(new SendString("No.", 14176));
549 player.send(new SendString("", 14177));
550 player.send(new SendString(/*item.getDestroyMessage()*/"Doing this action is permanent!", 14182));
551 player.send(new SendString("", 14183));
552 player.send(new SendString(item.getName(), 14184));
553 player.send(new SendChatBoxInterface(14170));
554 player.attributes.set("DESTROY_ITEM_KEY", slot);
555 }
556
557 /** Handles destroying the item. */
558 public void handleDestroyItem() {
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);
563 player.send(new SendMessage("You have dismantled your " + item.getName() + "."));
564 player.attributes.remove("UNCHARGE_HELM_KEY");
565 return;
566 }
567
568 if (player.attributes.has("RESTORE_HELM_KEY")) {
569 Item item = player.attributes.get("RESTORE_HELM_KEY");
570 player.dialogueFactory.clear();
571 if (item.matchesId(13_197)) {
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;
577 }
578 player.inventory.replace(item, new Item(player.serpentineHelmCharges <= 0 ? 12_929 : 12_931), true);
579 } else if (item.matchesId(13_199)) {
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;
585 }
586 }
587 player.inventory.replace(item, new Item(player.serpentineHelmCharges <= 0 ? 12_929 : 12_931), true);
588 player.send(new SendMessage("You have restored your " + item.getName() + "."));
589 player.attributes.remove("RESTORE_HELM_KEY");
590 return;
591 }
592
593 int index = player.attributes.get("DESTROY_ITEM_KEY", Integer.class);
594 if (index == -1)
595 return;
596 Item item = player.inventory.get(index);
597 if (item == null)
598 return;
599 player.dialogueFactory.clear();
600 player.inventory.remove(item, index);
601 player.send(new SendMessage("You have destroyed your " + item.getName() + "."));
602 player.attributes.remove("DESTROY_ITEM_KEY");
603 }
604
605 public boolean contains(Item item) {
606 return player.inventory.contains(item) || player.equipment.contains(item) || player.bank.contains(item);
607 }
608
609 /** Gets the KDR of the player. */
610 public String kdr() {
611 double KDR = (player.kill / (double) player.death);
612 return Double.isNaN(KDR) ? "0.0" : String.format("%.2f", KDR);
613 }
614
615 /** Gets the max hit of a combat type. */
616 public int getMaxHit(Mob defender, CombatType type) {
617 player.getCombat().addFirst(player.getStrategy());
618 int max = FormulaFactory.getModifiedMaxHit(player, defender, type);
619 player.getCombat().removeFirst();
620 return max;
621 }
622
623 /** Gets the instanced height for player. */
624 public int instance() {
625 return player.getIndex() << 2;
626 }
627
628 /** Gets the total amount of 99s the player has. */
629 public int getMaxSkillCount() {
630 int count = 0;
631 for (int index = 0; index < Skill.SKILL_COUNT; index++) {
632 if (player.skills.getMaxLevel(index) == 99)
633 count++;
634 }
635 return count;
636 }
637
638 public long networth() {
639 return networth(player.inventory, player.equipment, player.bank);
640 }
641
642 /** Gets the net worth of the player. */
643 public long networth(ItemContainer... containers) {
644 long networth = 0;
645 for (ItemContainer container : containers) {
646 networth += container.containerValue(PriceType.VALUE);
647 }
648 return networth;
649 }
650
651 /** Gets the total carried weight of the player. */
652 public double weight() {
653 double weight = player.inventory.getWeight();
654 weight += player.equipment.getWeight();
655 return weight;
656 }
657
659 ValueIcon icon = ValueIcon.NONE;
660 long carrying = networth(player.inventory, player.equipment);
661
662 if (carrying < 500_000)
663 icon = ValueIcon.BRONZE;
664 if (carrying > 500_000 && carrying < 1_500_000)
665 icon = ValueIcon.SILVER;
666 if (carrying > 1_500_000 && carrying < 5_000_000)
667 icon = ValueIcon.GREEN;
668 if (carrying > 5_000_000 && carrying < 25_000_000)
669 icon = ValueIcon.BLUE;
670 if (carrying > 25_000_000)
671 icon = ValueIcon.RED;
672
673 return icon;
674 }
675
676 public void setValueIcon() {
678
679 final int currentIcon = player.valueIcon;
680
681 if (icon.getCode() == currentIcon) {
682 return;
683 }
684
685 player.valueIcon = icon.getCode();
686 player.updateFlags.add(UpdateFlag.APPEARANCE);
687 }
688
689 String getCombatRange() {
690 return (player.skills.getCombatLevel() - 10 < 3 ? 3 : player.skills.getCombatLevel() - 10) + " - " + (player.skills.getCombatLevel() + 10 > 126 ? 126 : player.skills.getCombatLevel() + 10);
691 }
692
693 /** Checks if player is busy. */
694 public boolean busy() {
695 return !player.interfaceManager.isMainClear() || player.isDead() || player.newPlayer ||
696 player.needsStarter || player.locking.locked() || player.inActivity(ActivityType.DUEL_ARENA);
697 }
698
699 public void moveCamera(Position position, int resetDelay) {
700 player.send(new SendCameraTurn(position.getChunkX(), position.getChunkY(), position.getHeight(), 5, 5));
701 World.schedule(resetDelay, () -> player.send(new SendCameraReset()));
702 }
703
704 private static final int[] RING_OF_WEALTH = {
705 2572, 11988, 11986, 11984, 11982, 11980
706 };
707
708 private int getROWIndex(int item) {
709 int index = -1;
710 for (int amulet = 0; amulet < RING_OF_WEALTH.length; amulet++) {
711 if (item == RING_OF_WEALTH[amulet]) {
712 return amulet;
713 }
714 }
715 return index;
716 }
717
718 public void useROW() {
719 for (int row : RING_OF_WEALTH) {
720 int index = getROWIndex(row);
721 if (player.equipment.contains(row)) {
722 player.equipment.set(Equipment.RING_SLOT, new Item(RING_OF_WEALTH[index]), true);
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."));
724 break;
725 }
726 }
727 }
728
729 /** Checks if the string is already stored in the list. */
730 public boolean checkSendString(String text, int id) {
731 if (!interfaceText.containsKey(id)) {
732 interfaceText.put(id, new TinterfaceText(text, id));
733 return true;
734 }
735 TinterfaceText t = interfaceText.get(id);
736 if (t.currentState.equals(text))
737 return false;
738 t.currentState = text;
739 return true;
740 }
741
742 /** Clears the send strings */
743 public void clearSendStrings() {
744 interfaceText.clear();
745 }
746}
The class that contains setting-related constants for the server.
Definition Config.java:24
static final int MAGIC_TAB
Definition Config.java:194
static final int[][] SIDEBAR_INTERFACE
Holds the array of all the side-bar identification and their corresponding itemcontainer identificati...
Definition Config.java:234
Handles the starter kits.
static void open(Player player)
Handles opening the starter kit interface.
A Activity object constructs an in-game activity and sequences it through the start() and finish() me...
Definition Activity.java:31
static void forActivity(Mob mob, Consumer< Activity > consumer)
Definition Activity.java:78
A GroupActivity is an extension of Activity that holds a list of active activities.
static CerberusActivity create(Player player)
static JailActivity create(Player player)
static VorkathActivity create(Player player)
Creates a new Vorkath activity for the player.
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.
static void onLogin(Player player)
Handles logging into the server.
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.
Definition Pets.java:27
static void onLogin(Player player)
Handles what happens to a pet when a player logs in.
Definition Pets.java:224
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.
Definition World.java:46
static void schedule(Task task)
Submits a new event.
Definition World.java:247
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.
Supplies factory methods useful for combat.
static int getModifiedMaxHit(Mob attacker, Mob defender, CombatType type)
Handles the mob class.
Definition Mob.java:66
static NpcDefinition get(int id)
Gets a npc definition from the definition array.
double weight()
Gets the total carried weight of the player.
void setWidget()
Sends all the widget data to the client.
void setContextMenu()
Sends the context menu to the Player's context.
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.
CombatStrategy< Player > getStrategy()
Handles getting the combat strategy.
final void setSidebar(boolean disabled, boolean login)
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.
void setActivity()
Sets the activity for the player.
int getMaxSkillCount()
Gets the total amount of 99s the player has.
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
This class represents a character controlled by a player.
Definition Player.java:125
Represents a trainable and usable skill.
Definition Skill.java:18
static final int PRAYER
The prayer skill id.
Definition Skill.java:36
static final int SKILL_COUNT
The amount of available skills.
Definition Skill.java:90
static final int HITPOINTS
The hitpoints skill id.
Definition Skill.java:30
The container class that represents an item that can be interacted with.
Definition Item.java:21
Optional< RangedWeaponDefinition > getRangedDefinition()
Definition Item.java:445
final int getId()
Gets the identification of this item.
Definition Item.java:324
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.
Handles checking if mobs are in a certain area.
Definition Area.java:13
static boolean inVorkath(Interactable entity)
Definition Area.java:183
static boolean inBarrows(Entity entity)
Definition Area.java:254
static boolean inDuelArenaLobby(Entity entity)
Definition Area.java:293
static boolean inKraken(Interactable entity)
Definition Area.java:237
static boolean inDuelArena(Interactable entity)
Definition Area.java:311
static boolean inWilderness(Position position)
Definition Area.java:272
static boolean inGodwars(Interactable entity)
Definition Area.java:133
static boolean inCerberus(Interactable entity)
Definition Area.java:125
static boolean inDuelObsticleArena(Interactable entity)
Definition Area.java:302
static boolean inWarriorGuild(Interactable entity)
Definition Area.java:136
Represents a single tile on the game world.
Definition Position.java:14
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.
Definition Utility.java:27
static boolean hasOneOutOf(double chance)
Definition Utility.java:257
static String formatDigits(final int amount)
Formats digits for integers.
Definition Utility.java:41
static String convertWord(int amount)
Converts an integer into words.
Definition Utility.java:136
Holds all activity types that are timed.
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.
static boolean isDeveloper(Player player)
Checks if the player has developer status.