Created
April 12, 2020 09:19
-
-
Save riftrsps/c88566073c23e4d3a3500ab0a31a8ce1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package clean.skilling.herblore.potion; | |
import clean.packet.button.ChatMakeAmountButton; | |
import clean.skilling.util.Skilling; | |
import core.ServerConstants; | |
import game.content.interfaces.InterfaceAssistant; | |
import game.content.skilling.misc.SkillingStatistics; | |
import game.item.ItemAssistant; | |
import game.player.Player; | |
import game.player.event.CycleEvent; | |
import game.player.event.CycleEventContainer; | |
import game.player.event.CycleEventHandler; | |
import static utility.ItemIdentifiers.*; | |
/** | |
* Finished potion data, unfinished potion + ingredient = attack potion (3) etc.. | |
* | |
* @author Joshua Barry <Ares>, (MGT Madness created on 06-10-2015). | |
*/ | |
public enum Potion { | |
ATTACK(3, 25, EYE_OF_NEWT, GUAM_POTION_UNF_, ATTACK_POTION_3_), | |
ANTIPOISON(5, 37, UNICORN_HORN_DUST, MARRENTILL_POTION_UNF_, ANTIPOISON_3_), | |
STRENGTH(12, 50, LIMPWURT_ROOT, TARROMIN_POTION_UNF_, STRENGTH_POTION_3_), | |
RESTORE(22, 62, RED_SPIDERS_EGGS, HARRALANDER_POTION_UNF_, RESTORE_POTION_3_), | |
ENERGY(26, 67, CHOCOLATE_DUST, HARRALANDER_POTION_UNF_, ENERGY_POTION_3_), | |
DEFENCE(30, 75, WHITE_BERRIES, RANARR_POTION_UNF_, DEFENCE_POTION_3_), | |
AGILITY_POTION(34, 80, TOADS_LEGS, TOADFLAX_POTION_UNF_, AGILITY_POTION_3_), | |
/** | |
* Snape Grass - Prayer Potion - Ranarr (unf). | |
*/ | |
PRAYER(38, 87, 231, 99, 139), | |
/** | |
* Goat Horn Dust - Combat potion - Harrelander (unf). | |
*/ | |
COMBAT_POTION(36, 84, 9736, 97, 9741), | |
/** | |
* Unicorn horn dust - Superantipoison - Irit (unf). | |
*/ | |
SUPERANTIPOISON(48, 106, 235, 99, 181), | |
/** | |
* Snape grass - fishing potion - Avantoe (unf). | |
*/ | |
FISHING_POTION(50, 113, 231, 103, 9741), | |
/** | |
* kebbit teeth dust - hunter potion - Avantoe (unf). | |
*/ | |
HUNTER_POTION(53, 120, 10111, 103, 10000), | |
/** | |
* Gorak claw powder - magic essence potion - Avantoe (unf). | |
*/ | |
MAGIC_ESSENCE(57, 130, 9018, 9019, 9022), | |
/** | |
* Dragon scale dust - weapon posion - Kwuarm (unf). | |
*/ | |
WEAPON_POISON(60, 138, 241, 105, 187), | |
/** | |
* amylse crystals - stamina - super energy potion. | |
*/ | |
STAMINA(77, 102, 12640, 3018, 12627), | |
/** | |
* lava scale shard - extended antifre- Kwuarm (unf). | |
*/ | |
EXTENDED_ANTIFIRE(84, 110, 11994, 2454, 11953), | |
/** | |
* zulrah's scales - antivenom - antidote++. | |
*/ | |
ANTIVENOM(87, 120, 12934, 5954, 12907), | |
/** | |
* torstel - antivenom+ - antitvenom. | |
*/ | |
ANTIVENOMPLUS(94, 125, 269, 12907, 12915), | |
/** | |
* Eye of Newt - Super Attack Potion - Irit (unf). | |
*/ | |
SUPER_ATTACK(45, 100, 221, 101, 145), | |
/** | |
* Mort Myre Fungi - Super Energy Potion - Avantoe (unf). | |
*/ | |
SUPER_ENERGY(52, 117, 2970, 103, 3018), | |
/** | |
* Limpwurt Root - Super Strength Potion - Kwuarm (unf). | |
*/ | |
SUPER_STRENGTH(55, 125, 225, 105, 157), | |
/** | |
* Red Spider's Eggs - Super Restore Potion - Snapdragon (unf). | |
*/ | |
SUPER_RESTORE(63, 142, 223, 3004, 3026), | |
/** | |
* White Berries - Super Defence Potion - Cadantine (unf). | |
*/ | |
SUPER_DEFENCE(66, 150, 239, 107, 163), | |
/** | |
* Antidote+ step 1. | |
*/ | |
ANTIDOTEPLUS1(68, 0, 2998, 5935, 5942), | |
/** | |
* Antidote+ step 2. | |
*/ | |
ANTIDOTEPLUS2(68, 155, 6049, 5942, 5945), | |
/** | |
* Weapon poison+ step 1. | |
*/ | |
WEAPONPLUS1(73, 0, 6016, 5935, 5936), | |
/** | |
* Weapon poison+ step 2. | |
*/ | |
WEAPONPLUS2(73, 165, 223, 5936, 5973), | |
/** | |
* Antidote++ step 1. | |
*/ | |
ANTIDOTEPLUSPLUS1(79, 0, 259, 5935, 5951), | |
/** | |
* Antidote++ step 2. | |
*/ | |
ANTIDOTEPLUSPLUS2(79, 178, 6051, 5951, 5954), | |
/** | |
* BASTION step 1. | |
*/ | |
BASTION1(80, 0, 265, 22405, 22443), | |
/** | |
* BASTION step 2. | |
*/ | |
BASTION2(80, 155, 245, 22443, 22464), | |
/** | |
* BATTLEMAGE step 1. | |
*/ | |
BATTLEMAGE1(80, 0, 265, 22405, 22443), | |
/** | |
* BATTLEMAGE step 2. | |
*/ | |
BATTLEMAGE2(80, 155, 3138, 22443, 22452), | |
/** | |
* SANFEW POTS | |
*/ | |
SANFEW1(65, 0, 235, 3026, 10911), | |
SANFEW2(65, 0, 1526, 10911, 10919), | |
SANFEW3(65, 160, 10937, 10919, 10927), | |
/** | |
* GUTHIX REST | |
*/ | |
GUTHIX1(18, 14, 4460, 249, 4464), | |
ANTIFIRE(69, 158, DRAGON_SCALE_DUST, LANTADYME_POTION_UNF_, 2454), | |
RANGING(72, 162, WINE_OF_ZAMORAK, DWARF_WEED_POTION_UNF_, 169), | |
MAGIC(76, 172, POTATO_CACTUS, LANTADYME_POTION_UNF_, 3042), | |
ZAMORAK_BREW(78, 175, JANGERBERRIES, TORSTOL_POTION_UNF_, 2450), | |
SARADOMIN_BREW(81, 180, CRUSHED_NEST, TOADFLAX_POTION_UNF_, 6687), | |
UNFINISHED_GUAM(3, 91, 249), | |
UNFINISHED_MARRENTILL(5, 93, 251), | |
UNFINISHED_TARROMIN(12, 95, 253), | |
UNFINISHED_HARRALANDER(22, 97, 255), | |
UNFINISHED_RANARR(30, 99, 257), | |
UNFINISHED_TOADFLAX(34, 3002, 2998), | |
UNFINISHED_IRIT(45, 101, 259), | |
UNFINISHED_AVANTOE(50, 103, 261), | |
UNFINISHED_KWUARM(55, 105, 263), | |
UNFINISHED_SNAPDRAGON(63, 3004, 3000), | |
UNFINISHED_CADANTINE(66, 107, 265), | |
UNFINISHED_DWARF_WEED(72, 109, 267), | |
UNFINISHED_LANTADYME(69, 2483, 2481), | |
UNFINISHED_STAR(69, 9019, 9017), | |
UNFINISHED_TORSTOL(78, 111, 269); | |
private int ingredient; | |
private int unfinishedPotion; | |
private int itemGiven; | |
private int levelRequired; | |
private int xpGiven; | |
Potion(int levelRequired, int xpGiven, int ingredient, int unfinishedPotion, int itemGiven) { | |
this.levelRequired = levelRequired; | |
this.xpGiven = xpGiven; | |
this.ingredient = ingredient; | |
this.unfinishedPotion = unfinishedPotion; | |
this.itemGiven = itemGiven; | |
} | |
Potion(int levelRequired, int itemGiven, int herbRequired) { | |
this(levelRequired, 0, herbRequired, VIAL_OF_WATER, itemGiven); | |
} | |
private static Potion forId(int firstItem, int secondItem) { | |
for(Potion potion : values()) { | |
boolean hasFirstItem = firstItem == potion.ingredient || firstItem == potion.unfinishedPotion; | |
boolean hasSecondItem = secondItem == potion.ingredient || secondItem == potion.unfinishedPotion; | |
if(hasFirstItem && hasSecondItem) | |
return potion; | |
} | |
return null; | |
} | |
public static boolean handleItemOnItem(Player player, int usedWith, int itemUsed) { | |
Potion potion = Potion.forId(usedWith, itemUsed); | |
if(potion == null) | |
return false; | |
if (Skilling.bannedFromSkilling(player)) | |
return true; | |
Skilling.disableForcedStopEventIfSkilling(player); | |
if (Skilling.cannotSkill(player)) | |
return true; | |
CycleEventHandler.getSingleton().addEvent(player, potion.showMakeInterface(player), 1); | |
return true; | |
} | |
public static boolean handleButtonClick(Player player, int buttonId) { | |
boolean notHerbloreButton = !player.skillingInterface.equals(ServerConstants.SKILL_NAME[ServerConstants.HERBLORE]); | |
if(notHerbloreButton) | |
return false; | |
if(Skilling.disableForcedStopEventIfSkilling(player) || Skilling.cannotSkill(player)) | |
return true; | |
ChatMakeAmountButton button = ChatMakeAmountButton.forId(buttonId); | |
if(button == null) | |
return false; | |
Potion potion = Potion.forId(player.skillingData[1], player.skillingData[2]); | |
if(potion == null) | |
return false; | |
int cycles = potion.isUnfinished() ? 1 : 2; // Finished potions take 2 ticks to make | |
CycleEventHandler.getSingleton().addEvent(player, potion.makePotion(player, button.amount()), cycles); | |
return true; | |
} | |
public static boolean handleXAmount(Player player, int amount) { | |
if(!player.skillingInterface.equals(ServerConstants.SKILL_NAME[ServerConstants.HERBLORE])) | |
return false; | |
Potion potion = forId(player.skillingData[1], player.skillingData[2]); | |
if(potion == null) | |
return false; | |
if (Skilling.cannotSkill(player)) | |
return true; | |
int cycles = potion.isUnfinished() ? 1 : 2; // Finished potions take 2 ticks to make | |
CycleEventHandler.getSingleton().addEvent(player, potion.makePotion(player, amount), cycles); | |
return true; | |
} | |
private CycleEvent<Object> showMakeInterface(Player player) { | |
return new CycleEvent<Object>() { | |
public void stop() { | |
Skilling.endSkillingEvent(player); | |
} | |
public void execute(CycleEventContainer<Object> container) { | |
if (player.baseSkillLevel[ServerConstants.HERBLORE] < levelRequired) { | |
player.playerAssistant.sendMessage("You need a herblore level of " + levelRequired + " to make this potion."); | |
return; | |
} | |
player.skillingInterface = ServerConstants.SKILL_NAME[ServerConstants.HERBLORE]; | |
InterfaceAssistant.showSkillingInterface(player, "How many would you like to make?", 200, itemGiven, 20, 0); | |
player.skillingData[0] = itemGiven; | |
player.skillingData[1] = ingredient; | |
player.skillingData[2] = unfinishedPotion; | |
player.skillingData[3] = xpGiven; | |
} | |
}; | |
} | |
private CycleEvent<Object> makePotion(Player player, int amount) { | |
return new CycleEvent<Object>() { | |
public void stop() { Skilling.endSkillingEvent(player); } | |
public void execute(CycleEventContainer container) { | |
if (Skilling.forceStopSkillingEvent(player)) { | |
container.stop(); | |
return; | |
} | |
int experience = xpGiven; | |
player.skillingData[4] = amount; | |
if (ItemAssistant.hasItemInInventory(player, ingredient) && ItemAssistant.hasItemInInventory(player, unfinishedPotion) && player.skillingData[4] > 0) { | |
ItemAssistant.deleteItemFromInventory(player, ingredient, 1); | |
ItemAssistant.deleteItemFromInventory(player, unfinishedPotion, 1); | |
ItemAssistant.addItem(player, itemGiven, 1); | |
Skilling.addHarvestedResource(player, itemGiven, 1); | |
player.playerAssistant.sendFilterableMessage("You make a " + ItemAssistant.getItemName(itemGiven) + "."); | |
if (!ItemAssistant.getItemName(itemGiven).contains("unf")) { | |
player.skillingStatistics[SkillingStatistics.POTIONS_MADE]++; | |
} | |
player.startAnimation(363); | |
if (experience > 0) { | |
Skilling.addSkillExperience(player, experience, ServerConstants.HERBLORE, false); | |
Skilling.petChance(player, experience, 200, 13000, ServerConstants.HERBLORE, null); | |
} | |
player.skillingData[4] -= 1; | |
} else { | |
container.stop(); | |
} | |
} | |
}; | |
} | |
public boolean isUnfinished() { | |
return unfinishedPotion == VIAL_OF_WATER && xpGiven == 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment