1package com.runehive.content.consume;
3import com.google.common.collect.ImmutableSet;
4import com.google.common.collect.Sets;
5import com.runehive.game.task.impl.AntiVenomTask;
6import com.runehive.game.task.impl.SuperAntipoisonTask;
7import com.runehive.game.world.World;
8import com.runehive.game.world.entity.combat.CombatUtil;
9import com.runehive.game.world.entity.combat.PoisonType;
10import com.runehive.game.world.entity.combat.effect.CombatEffectType;
11import com.runehive.game.world.entity.combat.hit.Hit;
12import com.runehive.game.world.entity.mob.player.Player;
13import com.runehive.game.world.entity.skill.Skill;
14import com.runehive.game.world.items.Item;
15import com.runehive.net.packet.out.SendConfig;
16import com.runehive.net.packet.out.SendMessage;
17import com.runehive.net.packet.out.SendPoison;
18import com.runehive.net.packet.out.SendRunEnergy;
20import java.util.EnumSet;
21import java.util.Optional;
34 player.energyRate = 200;
60 PotionData.onAntiPoisonEffect(player,
true, 1000);
66 PotionData.onAntiPoisonEffect(player,
true, 1200);
183 PotionData.onAntiPoisonEffect(player,
false, 0);
189 PotionData.onAntiPoisonEffect(player,
true, 500);
199 player.
send(
new SendMessage(
"You have been granted immunity against poison."));
202 player.
send(
new SendMessage(
"Your immunity against poison has been restored!"));
207 player.
send(
new SendMessage(
"You have been granted immunity against venom."));
210 player.
send(
new SendMessage(
"Your immunity against venom has been restored!"));
215 ANTI_VENOM_PLUS(12913, 12915, 12917, 12919) {
217 public void onEffect(
Player player) {
222 player.
send(
new SendMessage(
"You have been granted immunity against poison."));
225 player.
send(
new SendMessage(
"Your immunity against poison has been restored!"));
230 player.
send(
new SendMessage(
"You have been granted immunity against venom."));
233 player.
send(
new SendMessage(
"Your immunity against venom has been restored!"));
242 private static final ImmutableSet<PotionData>
VALUES = Sets.immutableEnumSet(EnumSet.allOf(
PotionData.class));
349 player.
send(
new SendMessage(
"You have been granted immunity against poison."));
353 player.
send(
new SendMessage(
"Your immunity against poison has been restored!"));
367 int amount = superPotion ? 20 : 10;
370 if (amount + energy > 100) {
371 player.runEnergy = 100;
373 player.runEnergy += amount;
385 for (
int index = 0; index <= 6; index++) {
391 int realLevel =
skill.getMaxLevel();
393 if (
skill.getLevel() >= realLevel) {
397 int formula = superRestore ? (int) Math.floor(8 + (realLevel * 0.25)) : (int) Math.floor(10 + (realLevel * 0.30));
437 final int boostLevel = (int) (realLevel * percentage + base);
440 if (cap < realLevel + boostLevel) {
441 cap = realLevel + boostLevel;
445 int damage = boostLevel;
463 Optional<PotionData> potion =
forId(item.
getId());
464 if (potion.isPresent()) {
465 int length = potion.get().getIds().length;
466 for (
int index = 0; index < length; index++) {
467 if (potion.get().getIds()[index] == item.
getId() && index + 1 < length) {
468 return new Item(potion.get().getIds()[index + 1]);
482 public static Optional<PotionData>
forId(
int id) {
484 for (
int potionId : potion.getIds()) {
485 if (
id == potionId) {
486 return Optional.of(potion);
490 return Optional.empty();
525 return ids[ids.length - dose];
557 this.amount = boostAmount;
Represents the game world.
static void schedule(Task task)
Submits a new event.
A collection of util methods and constants related to combat.
static boolean cancelEffect(Mob mob, CombatEffectType effect)
Cancels the effect in any context.
static boolean effect(Mob mob, CombatEffectType effect)
Applies the effect in any context.
A Hit object holds the damage amount and hitsplat data.
void poison(PoisonType type)
Applies poison with an intensity of type to the entity.
final SkillManager skills
final MutableNumber getPoisonDamage()
final boolean isPoisoned()
final boolean isVenomed()
MutableNumber getVenomDamage()
This class represents a character controlled by a player.
final MutableNumber getPoisonImmunity()
final MutableNumber getVenomImmunity()
void send(OutgoingPacket encoder)
Represents a trainable and usable skill.
void modifyLevel(Function< Integer, Integer > function)
Modifies the current level with a given function.
static final int PRAYER
The prayer skill id.
static final int RANGED
The ranged skill id.
static final int FISHING
The fishing skill id.
static final int DEFENCE
The defence skill id.
int getLevel()
Gets the current skill level.
static final int MAGIC
The magic skill id.
static final int ATTACK
The attack skill id.
static final int AGILITY
The agility skill id.
static final int STRENGTH
The strength skill id.
int getMaxLevel()
Gets the maximum skill level.
static final int HITPOINTS
The hitpoints skill id.
int getMaxLevel(int id)
Gets the highest possible level of a skill.
Skill get(int id)
Gets the skill for an id.
void refresh()
Refreshes all the skills for the mob.
The container class that represents an item that can be interacted with.
final int getId()
Gets the identification of this item.
The OutgoingPacket responsible for changing settings on a client.
The OutgoingPacket that sends a message to a Players chatbox in the client.
int incrementAndGet(int amount, int maximum)
Increments the value within this counter by amount to a maximum of maximum and then returns it.
void set(int value)
Sets the value within this container to rarity.
int get()
Gets the value present within this counter.
The enumerated type whose elements represent the boost types for potions.
final float getAmount()
Gets the amount this type will boost by.
final float amount
The amount this type will boost by.
final int base
The base which we will append by.
final int getBase()
Gets the base this type will boost by.
BoostType(int base, float boostAmount)
Creates a new BoostType.
abstract void onEffect(Player player)
The method executed when this potion type activated.
static void onPrayerEffect(Player player, boolean superPrayer)
The method that executes the prayer potion action.
static void onRestoreEffect(Player player, boolean superRestore)
The method that executes the restore potion action.
static Item getReplacementItem(Item item)
Retrieves the replacement item for item.
PotionData(int... ids)
Create a new PotionData.
final int[] getIds()
Gets the identifiers which represent this potion type.
static final ImmutableSet< PotionData > VALUES
Caches our enum values.
int getIdForDose(int dose)
Gets the item id for the specified dose.
static final Item VIAL
The default item representing the final potion dose.
static void onFishingEffect(Player player)
The method that executes the fishing potion action.
static void onSaradominEffect(Player player)
The method that executes the Saradomin brew action.
static Optional< PotionData > forId(int id)
Retrieves the potion consumable element for id.
static void onAgilityEffect(Player player)
The method that executes the agility potion action.
static void onAntiPoisonEffect(Player player, boolean superPotion, int length)
The method that executes the anti-poison potion action.
boolean canDrink(Player player)
The method which determines if the player can drink the potion.
static void onBasicEffect(Player player, int skill, BoostType type)
The method that executes the basic effect potion action that will append the level of skill.
static void onAntiFireEffect(Player player, boolean superVariant)
The method that executes the anti-fireRunes potion action.
static void modifySkill(Player player, int skill, double percentage, int base)
The method that executes the basic effect potion action that will append the level of skill.
final int[] ids
The identifiers which represent this potion type.
static void onZamorakEffect(Player player)
The method that executes the Zamorak brew action.
static void onEnergyEffect(Player player, boolean superPotion)
The method that executes the energy potion action.
The enumerated type whose elements represent the different levels of poison.
WEAK_NPC
The default poison type for poisonous NPCs.
The enumerated type whose values represent the collection of different combat effect types.