mirror of
https://github.com/2006-Scape/2006Scape.git
synced 2026-07-02 16:49:03 +00:00
Replace a bunch of magic numbers & Fix Mackerel Spelling (#559)
* Convert Some NPCActions Magic Numbers * IntelliJ Reformat NpcActions.java * Convert Magic Numbers In Dye.java * Convert More Magic Numbers In NpcActions.java * Convert More NpcActions.java Magic Numbers * Plugins: Replace Magic Numbers * Skills: Cooking: Replaced all Item/Object Magic Numbers & Fixed Mackerel spelling * Food: Fixed Mackerel spelling * Skills: Fishing: Replace Magic Numbers * Skills: Mining: Replace Magic Numbers * IntelliJ Code Reformat Changed Files
This commit is contained in:
@@ -4,6 +4,7 @@ import com.rs2.event.EventContext
|
||||
import com.rs2.event.EventSubscriber
|
||||
import com.rs2.event.SubscribesTo
|
||||
import com.rs2.event.impl.ItemFirstClickEvent
|
||||
import com.rs2.game.content.StaticItemList.YOYO
|
||||
import com.rs2.game.players.Player
|
||||
|
||||
|
||||
@@ -18,7 +19,7 @@ class ItemFirstClick : EventSubscriber<ItemFirstClickEvent> {
|
||||
|
||||
when(event.item) {
|
||||
|
||||
4079 -> player.startAnimation(1457) // yo-yo
|
||||
YOYO -> player.startAnimation(1457)
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.rs2.event.EventContext
|
||||
import com.rs2.event.EventSubscriber
|
||||
import com.rs2.event.SubscribesTo
|
||||
import com.rs2.event.impl.ItemOnItemEvent
|
||||
import com.rs2.game.content.StaticItemList.*
|
||||
import com.rs2.game.players.Player
|
||||
|
||||
@SubscribesTo(ItemOnItemEvent::class)
|
||||
@@ -15,9 +16,9 @@ class ItemOnItem : EventSubscriber<ItemOnItemEvent> {
|
||||
player.packetSender.sendMessage("[ItemOnItem] - used: ${event.used} with: ${event.usedWith}")
|
||||
}
|
||||
|
||||
if (event.used == 38 && event.usedWith == 590) {
|
||||
player.itemAssistant.addItem(32, 1)
|
||||
player.itemAssistant.deleteItem(38, 1)
|
||||
if (event.used == BLACK_CANDLE && event.usedWith == TINDERBOX) {
|
||||
player.itemAssistant.addItem(LIT_BLACK_CANDLE, 1)
|
||||
player.itemAssistant.deleteItem(BLACK_CANDLE, 1)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.rs2.event.EventContext
|
||||
import com.rs2.event.EventSubscriber
|
||||
import com.rs2.event.SubscribesTo
|
||||
import com.rs2.event.impl.ItemSecondClickEvent
|
||||
import com.rs2.game.content.StaticItemList.YOYO
|
||||
import com.rs2.game.players.Player
|
||||
|
||||
@SubscribesTo(ItemSecondClickEvent::class)
|
||||
@@ -17,7 +18,7 @@ class ItemSecondClick : EventSubscriber<ItemSecondClickEvent> {
|
||||
|
||||
when(event.id) {
|
||||
|
||||
4079 -> player.startAnimation(1459) //yo-yo
|
||||
YOYO -> player.startAnimation(1459)
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.rs2.event.EventContext
|
||||
import com.rs2.event.EventSubscriber
|
||||
import com.rs2.event.SubscribesTo
|
||||
import com.rs2.event.impl.ItemThirdClickEvent
|
||||
import com.rs2.game.content.StaticItemList.YOYO
|
||||
import com.rs2.game.players.Player
|
||||
|
||||
@SubscribesTo(ItemThirdClickEvent::class)
|
||||
@@ -17,7 +18,7 @@ class ItemThirdClick : EventSubscriber<ItemThirdClickEvent> {
|
||||
|
||||
when(event.id) {
|
||||
|
||||
4079 -> player.startAnimation(1460) //yo-yo
|
||||
YOYO -> player.startAnimation(1460)
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package plugin.click.npc
|
||||
|
||||
import com.rs2.GameConstants
|
||||
import com.rs2.event.EventContext
|
||||
import com.rs2.event.EventSubscriber
|
||||
import com.rs2.event.SubscribesTo
|
||||
import com.rs2.event.impl.NpcFirstClickEvent
|
||||
import com.rs2.game.npcs.Npc
|
||||
import com.rs2.game.content.StaticNpcList.*
|
||||
import com.rs2.game.players.Player
|
||||
import com.rs2.util.Misc
|
||||
|
||||
@@ -21,7 +20,7 @@ class NpcFirstClick : EventSubscriber<NpcFirstClickEvent> {
|
||||
|
||||
when(event.npc) {
|
||||
|
||||
1,2,3,4,5,6 -> if (Misc.random(10) <= 5) {
|
||||
MAN,MAN_2,MAN_3,WOMAN,WOMAN_5,WOMAN_6 -> if (Misc.random(10) <= 5) {
|
||||
player.dialogueHandler.sendDialogues(3869, player.npcType)
|
||||
} else {
|
||||
player.dialogueHandler.sendDialogues(3872, player.npcType)
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.rs2.event.SubscribesTo
|
||||
import com.rs2.event.impl.ObjectFirstClickEvent
|
||||
import com.rs2.game.content.skills.core.Mining
|
||||
import com.rs2.game.players.Player
|
||||
import com.rs2.world.clip.Region
|
||||
|
||||
@SubscribesTo(ObjectFirstClickEvent::class)
|
||||
class ObjectFirstClick : EventSubscriber<ObjectFirstClickEvent> {
|
||||
@@ -16,6 +17,10 @@ class ObjectFirstClick : EventSubscriber<ObjectFirstClickEvent> {
|
||||
player.packetSender.sendMessage("[click= object], [type= first], [id= ${player.objectId}], [location= x:${player.objectX} y:${player.objectY} ]")
|
||||
}
|
||||
|
||||
if (!Region.objectExists(player.objectId, player.objectX, player.objectY, player.heightLevel)) {
|
||||
return
|
||||
}
|
||||
|
||||
// if its a rock we can mine, mine it
|
||||
if (Mining.rockExists(event.gameObject)) {
|
||||
player.mining.startMining(player, event.gameObject, player.objectX, player.objectY, player.clickObjectType)
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.rs2.event.SubscribesTo
|
||||
import com.rs2.event.impl.ObjectSecondClickEvent
|
||||
import com.rs2.game.content.skills.thieving.Stalls
|
||||
import com.rs2.game.players.Player
|
||||
import com.rs2.world.clip.Region
|
||||
|
||||
@SubscribesTo(ObjectSecondClickEvent::class)
|
||||
class ObjectSecondClick : EventSubscriber<ObjectSecondClickEvent> {
|
||||
@@ -16,6 +17,10 @@ class ObjectSecondClick : EventSubscriber<ObjectSecondClickEvent> {
|
||||
player.packetSender.sendMessage("[click= object], [type= second], [id= ${player.objectId}], [location= x:${player.objectX} y:${player.objectY} ]");
|
||||
}
|
||||
|
||||
if (!Region.objectExists(player.objectId, player.objectX, player.objectY, player.heightLevel)) {
|
||||
return
|
||||
}
|
||||
|
||||
if (Stalls.isObject(event.gameObject)) {
|
||||
Stalls.attemptStall(player, event.gameObject, player.objectX, player.objectY)
|
||||
return
|
||||
|
||||
@@ -4,8 +4,10 @@ import com.rs2.event.EventContext
|
||||
import com.rs2.event.EventSubscriber
|
||||
import com.rs2.event.SubscribesTo
|
||||
import com.rs2.event.impl.ObjectThirdClickEvent
|
||||
import com.rs2.game.content.StaticObjectList.IRON_LADDER_10177
|
||||
import com.rs2.game.content.skills.thieving.Stalls
|
||||
import com.rs2.game.players.Player
|
||||
import com.rs2.world.clip.Region
|
||||
|
||||
@SubscribesTo(ObjectThirdClickEvent::class)
|
||||
class ObjectThirdClick : EventSubscriber<ObjectThirdClickEvent> {
|
||||
@@ -16,13 +18,17 @@ class ObjectThirdClick : EventSubscriber<ObjectThirdClickEvent> {
|
||||
player.packetSender.sendMessage("[click= object], [type= third], [id= ${player.objectId}], [location= x:${player.objectX} y:${player.objectY} ], [PLUGIN]");
|
||||
}
|
||||
|
||||
if (!Region.objectExists(player.objectId, player.objectX, player.objectY, player.heightLevel)) {
|
||||
return
|
||||
}
|
||||
|
||||
if (Stalls.isObject(event.gameObject)) {
|
||||
Stalls.attemptStall(player, event.gameObject, player.objectX, player.objectY)
|
||||
return
|
||||
}
|
||||
|
||||
when (event.gameObject) {
|
||||
10177 -> player.playerAssistant.movePlayer(1798, 4407, 3);
|
||||
IRON_LADDER_10177 -> player.playerAssistant.movePlayer(1798, 4407, 3);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,12 +5,13 @@ import com.rs2.event.EventSubscriber
|
||||
import com.rs2.event.SubscribesTo
|
||||
import com.rs2.event.impl.NpcSecondClickEvent
|
||||
import com.rs2.game.players.Player
|
||||
import com.rs2.game.content.StaticNpcList.FADLI
|
||||
|
||||
@SubscribesTo(NpcSecondClickEvent::class)
|
||||
class SecondClick : EventSubscriber<NpcSecondClickEvent> {
|
||||
|
||||
override fun subscribe(context: EventContext, player: Player, event: NpcSecondClickEvent) {
|
||||
if (event.npc == 958) {
|
||||
if (event.npc == FADLI) {
|
||||
player.packetSender.openUpBank()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ public class Food {
|
||||
PINEAPPLE(2114, 2, "Pineapple", 0, "Food", false),
|
||||
CHOCOLATE_BAR(1973, 2, "Chocolate Bar", 0, "Food", false),
|
||||
Wine(1993, 11, "Wine", 1935, "Drink", false),
|
||||
MACKERAL(355, 6, "Mackeral", 0, "Food", false),
|
||||
MACKEREL(355, 6, "Mackerel", 0, "Food", false),
|
||||
MANTA(391, 22, "Manta Ray", 0, "Food", false),
|
||||
SHARK(385, 20, "Shark", 0, "Food", false),
|
||||
LOBSTER(379, 12, "Lobster", 0, "Food", false),
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package com.rs2.game.content.skills.cooking;
|
||||
|
||||
import java.security.SecureRandom;
|
||||
import com.rs2.GameConstants;
|
||||
import com.rs2.event.CycleEvent;
|
||||
import com.rs2.event.CycleEventContainer;
|
||||
import com.rs2.event.CycleEventHandler;
|
||||
import com.rs2.game.content.StaticItemList;
|
||||
import com.rs2.game.content.StaticObjectList;
|
||||
import com.rs2.game.content.music.sound.SoundList;
|
||||
import com.rs2.game.content.randomevents.RandomEventHandler;
|
||||
import com.rs2.game.content.skills.SkillHandler;
|
||||
@@ -13,261 +14,263 @@ import com.rs2.game.items.ItemConstants;
|
||||
import com.rs2.game.players.Player;
|
||||
import com.rs2.util.Misc;
|
||||
|
||||
import java.security.SecureRandom;
|
||||
|
||||
public class Cooking extends SkillHandler {
|
||||
|
||||
private static SecureRandom cookingRandom = new SecureRandom(); // The random factor
|
||||
private static SecureRandom cookingRandom = new SecureRandom(); // The random factor
|
||||
|
||||
private static enum CookingItems {
|
||||
//raw, cooked, burnt, levelreq, exp, stopburn, stopburn w/gloves, name
|
||||
SHRIMP(317, 315, 7954, 1, 30, 34, 30, "shrimp"),
|
||||
SARDINE(327, 325, 369, 1, 40, 38, 38, "sardine"),
|
||||
HERRING(345, 347, 357, 5, 50, 41, 41, "herring"),
|
||||
TROUT(335, 333, 343, 15, 70, 50, 50, "trout"),
|
||||
TUNA(359, 361, 367, 30, 100, 64, 63, "tuna"),
|
||||
ANCHOVIES(321, 319, 323, 5, 45, 34, 34, "anchovies"),
|
||||
RAW_BEEF(2132, 2142, 2146, 1, 30, 33, 33, "raw beef"),
|
||||
RAW_RAT(2134, 2142, 2146, 1, 30, 33, 33, "raw rat meat"),
|
||||
BURNT_MEAT(2142, 2146, 2146, 1, 1, 100, 100, "cooked meat"),
|
||||
RAW_CHICKEN(2138, 2140, 2144, 1, 30, 33, 33, "raw chicken"),
|
||||
RAW_BEAR_MEAT(2136, 2142, 2146, 1, 30, 33, 33, "raw bear meat"),
|
||||
MACKERAL(353, 355, 357, 10, 60, 45, 45, "mackeral"),
|
||||
SALMON(331, 329, 343, 25, 90, 58, 55, "salmon"),
|
||||
UNCOOKED_BERRY_PIE(2321, 2325, 2329, 10, 78, 50, 50, "uncooked pie"),
|
||||
PIKE(349, 351, 343, 20, 80, 59, 59, "pike"),
|
||||
KARAMBWAN(3142, 3144, 3146, 1, 80, 20, 20, "karambwan"),
|
||||
LOBSTER(377, 379, 381, 40, 120, 74, 68, "lobster"),
|
||||
SWORDFISH(371, 373, 375, 50, 140, 86, 81, "swordfish"),
|
||||
MONKFISH(7944, 7946, 7948, 62, 150, 92, 90, "monkfish"),
|
||||
SHARK(383, 385, 387, 76, 210, 100, 94, "shark"),
|
||||
SEA_TURTLE(395, 397, 399, 82, 211, 100, 100, "sea turtle"),
|
||||
MANTA_RAY(389, 391, 393, 91, 216, 100, 100, "manta ray"),
|
||||
SEAWEED(401, 1781, 1781, 1, 1, 1, 1, "sea weed"),
|
||||
CURRY(2009, 2011, 2013, 60, 280, 74, 74, "curry");
|
||||
private static enum CookingItems {
|
||||
//raw, cooked, burnt, levelreq, exp, stopburn, stopburn w/gloves, name
|
||||
SHRIMP(StaticItemList.RAW_SHRIMPS, StaticItemList.SHRIMPS, StaticItemList.BURNT_SHRIMP, 1, 30, 34, 30, "shrimp"),
|
||||
SARDINE(StaticItemList.RAW_SARDINE, StaticItemList.SARDINE, StaticItemList.BURNT_FISH_369, 1, 40, 38, 38, "sardine"),
|
||||
HERRING(StaticItemList.RAW_HERRING, StaticItemList.HERRING, StaticItemList.BURNT_FISH_357, 5, 50, 41, 41, "herring"),
|
||||
TROUT(StaticItemList.RAW_TROUT, StaticItemList.TROUT, StaticItemList.BURNT_FISH_343, 15, 70, 50, 50, "trout"),
|
||||
TUNA(StaticItemList.RAW_TUNA, StaticItemList.TUNA, StaticItemList.BURNT_FISH_367, 30, 100, 64, 63, "tuna"),
|
||||
ANCHOVIES(StaticItemList.RAW_ANCHOVIES, StaticItemList.ANCHOVIES, StaticItemList.BURNT_FISH, 5, 45, 34, 34, "anchovies"),
|
||||
RAW_BEEF(StaticItemList.RAW_BEEF, StaticItemList.COOKED_MEAT, StaticItemList.BURNT_MEAT, 1, 30, 33, 33, "raw beef"),
|
||||
RAW_RAT(StaticItemList.RAW_RAT_MEAT, StaticItemList.COOKED_MEAT, StaticItemList.BURNT_MEAT, 1, 30, 33, 33, "raw rat meat"),
|
||||
BURNT_MEAT(StaticItemList.COOKED_MEAT, StaticItemList.BURNT_MEAT, StaticItemList.BURNT_MEAT, 1, 1, 100, 100, "cooked meat"),
|
||||
RAW_CHICKEN(StaticItemList.RAW_CHICKEN, StaticItemList.COOKED_CHICKEN, StaticItemList.BURNT_CHICKEN, 1, 30, 33, 33, "raw chicken"),
|
||||
RAW_BEAR_MEAT(StaticItemList.RAW_BEAR_MEAT, StaticItemList.COOKED_MEAT, StaticItemList.BURNT_MEAT, 1, 30, 33, 33, "raw bear meat"),
|
||||
MACKEREL(StaticItemList.RAW_MACKEREL, StaticItemList.MACKEREL, StaticItemList.BURNT_FISH_357, 10, 60, 45, 45, "mackerel"),
|
||||
SALMON(StaticItemList.RAW_SALMON, StaticItemList.SALMON, StaticItemList.BURNT_FISH_343, 25, 90, 58, 55, "salmon"),
|
||||
UNCOOKED_BERRY_PIE(StaticItemList.UNCOOKED_BERRY_PIE, StaticItemList.REDBERRY_PIE, StaticItemList.BURNT_PIE, 10, 78, 50, 50, "uncooked pie"),
|
||||
PIKE(StaticItemList.RAW_PIKE, StaticItemList.PIKE, StaticItemList.BURNT_FISH_343, 20, 80, 59, 59, "pike"),
|
||||
KARAMBWAN(StaticItemList.RAW_KARAMBWAN, StaticItemList.COOKED_KARAMBWAN, StaticItemList.COOKED_KARAMBWAN_3146, 1, 80, 20, 20, "karambwan"),
|
||||
LOBSTER(StaticItemList.RAW_LOBSTER, StaticItemList.LOBSTER, StaticItemList.BURNT_LOBSTER, 40, 120, 74, 68, "lobster"),
|
||||
SWORDFISH(StaticItemList.RAW_SWORDFISH, StaticItemList.SWORDFISH, StaticItemList.BURNT_SWORDFISH, 50, 140, 86, 81, "swordfish"),
|
||||
MONKFISH(StaticItemList.RAW_MONKFISH, StaticItemList.MONKFISH, StaticItemList.BURNT_MONKFISH, 62, 150, 92, 90, "monkfish"),
|
||||
SHARK(StaticItemList.RAW_SHARK, StaticItemList.SHARK, StaticItemList.BURNT_SHARK, 76, 210, 100, 94, "shark"),
|
||||
SEA_TURTLE(StaticItemList.RAW_SEA_TURTLE, StaticItemList.SEA_TURTLE, StaticItemList.BURNT_SEA_TURTLE, 82, 211, 100, 100, "sea turtle"),
|
||||
MANTA_RAY(StaticItemList.RAW_MANTA_RAY, StaticItemList.MANTA_RAY, StaticItemList.BURNT_MANTA_RAY, 91, 216, 100, 100, "manta ray"),
|
||||
SEAWEED(StaticItemList.SEAWEED, StaticItemList.SODA_ASH, StaticItemList.SODA_ASH, 1, 1, 1, 1, "sea weed"),
|
||||
CURRY(StaticItemList.UNCOOKED_CURRY, StaticItemList.CURRY, StaticItemList.BURNT_CURRY, 60, 280, 74, 74, "curry");
|
||||
|
||||
int rawItem, cookedItem, burntItem, levelReq, xp, stopBurn, stopBurnGloves;
|
||||
String name;
|
||||
int rawItem, cookedItem, burntItem, levelReq, xp, stopBurn, stopBurnGloves;
|
||||
String name;
|
||||
|
||||
private CookingItems(int rawItem, int cookedItem, int burntItem, int levelReq, int xp, int stopBurn, int stopBurnGloves, String name) {
|
||||
this.rawItem = rawItem;
|
||||
this.cookedItem = cookedItem;
|
||||
this.burntItem = burntItem;
|
||||
this.levelReq = levelReq;
|
||||
this.xp = xp;
|
||||
this.stopBurn = stopBurn;
|
||||
this.name = name;
|
||||
}
|
||||
private CookingItems(int rawItem, int cookedItem, int burntItem, int levelReq, int xp, int stopBurn, int stopBurnGloves, String name) {
|
||||
this.rawItem = rawItem;
|
||||
this.cookedItem = cookedItem;
|
||||
this.burntItem = burntItem;
|
||||
this.levelReq = levelReq;
|
||||
this.xp = xp;
|
||||
this.stopBurn = stopBurn;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
private int getRawItem() {
|
||||
return rawItem;
|
||||
}
|
||||
private int getRawItem() {
|
||||
return rawItem;
|
||||
}
|
||||
|
||||
private int getCookedItem() {
|
||||
return cookedItem;
|
||||
}
|
||||
private int getCookedItem() {
|
||||
return cookedItem;
|
||||
}
|
||||
|
||||
private int getBurntItem() {
|
||||
return burntItem;
|
||||
}
|
||||
private int getBurntItem() {
|
||||
return burntItem;
|
||||
}
|
||||
|
||||
private int getLevelReq() {
|
||||
return levelReq;
|
||||
}
|
||||
private int getLevelReq() {
|
||||
return levelReq;
|
||||
}
|
||||
|
||||
private int getXp() {
|
||||
return xp;
|
||||
}
|
||||
private int getXp() {
|
||||
return xp;
|
||||
}
|
||||
|
||||
private int getStopBurn() {
|
||||
return stopBurn;
|
||||
}
|
||||
private int getStopBurn() {
|
||||
return stopBurn;
|
||||
}
|
||||
|
||||
private int getStopBurnGloves() {
|
||||
return stopBurnGloves;
|
||||
}
|
||||
private int getStopBurnGloves() {
|
||||
return stopBurnGloves;
|
||||
}
|
||||
|
||||
private String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
private String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
public static CookingItems forId(int itemId) {
|
||||
for (CookingItems item : CookingItems.values()) {
|
||||
if (itemId == item.getRawItem()) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static CookingItems forId(int itemId) {
|
||||
for (CookingItems item : CookingItems.values()) {
|
||||
if (itemId == item.getRawItem()) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void makeBreadOptions(Player c, int item) {
|
||||
if (c.getItemAssistant().playerHasItem(1929) && c.getItemAssistant().playerHasItem(1933) && item == c.breadID) {
|
||||
c.getItemAssistant().deleteItem(1929, 1);
|
||||
c.getItemAssistant().deleteItem(1933, 1);
|
||||
c.getItemAssistant().addItem(1925, 1);
|
||||
c.getItemAssistant().addItem(1931, 1);
|
||||
c.getItemAssistant().addItem(item, 1);
|
||||
c.getPacketSender().sendMessage("You mix the water and flour to make some " + ItemAssistant.getItemName(item) + ".");
|
||||
}
|
||||
c.getPacketSender().closeAllWindows();
|
||||
}
|
||||
public static void makeBreadOptions(Player c, int item) {
|
||||
if (c.getItemAssistant().playerHasItem(StaticItemList.BUCKET_OF_WATER) && c.getItemAssistant().playerHasItem(StaticItemList.POT_OF_FLOUR) && item == c.breadID) {
|
||||
c.getItemAssistant().deleteItem(StaticItemList.BUCKET_OF_WATER, 1);
|
||||
c.getItemAssistant().deleteItem(StaticItemList.POT_OF_FLOUR, 1);
|
||||
c.getItemAssistant().addItem(StaticItemList.BUCKET, 1);
|
||||
c.getItemAssistant().addItem(StaticItemList.POT, 1);
|
||||
c.getItemAssistant().addItem(item, 1);
|
||||
c.getPacketSender().sendMessage("You mix the water and flour to make some " + ItemAssistant.getItemName(item) + ".");
|
||||
}
|
||||
c.getPacketSender().closeAllWindows();
|
||||
}
|
||||
|
||||
public static void pastryCreation(Player c, int itemID1, int itemID2, int giveItem, String message) {
|
||||
if (c.getItemAssistant().playerHasItem(itemID1) && c.getItemAssistant().playerHasItem(itemID2)) {
|
||||
c.getItemAssistant().deleteItem(itemID1, 1);
|
||||
c.getItemAssistant().deleteItem(itemID2, 1);
|
||||
c.getItemAssistant().addItem(giveItem, 1);
|
||||
if (message.equalsIgnoreCase("")) {
|
||||
c.getPacketSender().sendMessage("You mix the two ingredients and get an " + ItemAssistant.getItemName(giveItem) + ".");
|
||||
} else {
|
||||
c.getPacketSender().sendMessage(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void pastryCreation(Player c, int itemID1, int itemID2, int giveItem, String message) {
|
||||
if (c.getItemAssistant().playerHasItem(itemID1) && c.getItemAssistant().playerHasItem(itemID2)) {
|
||||
c.getItemAssistant().deleteItem(itemID1, 1);
|
||||
c.getItemAssistant().deleteItem(itemID2, 1);
|
||||
c.getItemAssistant().addItem(giveItem, 1);
|
||||
if (message.equalsIgnoreCase("")) {
|
||||
c.getPacketSender().sendMessage("You mix the two ingredients and get an " + ItemAssistant.getItemName(giveItem) + ".");
|
||||
} else {
|
||||
c.getPacketSender().sendMessage(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void cookingAddon(Player c, int itemID1, int itemID2, int giveItem, int requiredLevel, int expGained) {
|
||||
if (c.playerLevel[GameConstants.COOKING] >= requiredLevel) {
|
||||
if (c.getItemAssistant().playerHasItem(itemID1) && c.getItemAssistant().playerHasItem(itemID2)) {
|
||||
c.getItemAssistant().deleteItem(itemID1, 1);
|
||||
c.getItemAssistant().deleteItem(itemID2, 1);
|
||||
c.getItemAssistant().addItem(giveItem, 1);
|
||||
c.getPlayerAssistant().addSkillXP(expGained, 7);
|
||||
c.getPacketSender().sendMessage("You create a " + ItemAssistant.getItemName(giveItem) + ".");
|
||||
}
|
||||
} else {
|
||||
c.getPacketSender().sendMessage("You don't have the required level to make an " + ItemAssistant.getItemName(giveItem));
|
||||
}
|
||||
}
|
||||
public static void cookingAddon(Player c, int itemID1, int itemID2, int giveItem, int requiredLevel, int expGained) {
|
||||
if (c.playerLevel[GameConstants.COOKING] >= requiredLevel) {
|
||||
if (c.getItemAssistant().playerHasItem(itemID1) && c.getItemAssistant().playerHasItem(itemID2)) {
|
||||
c.getItemAssistant().deleteItem(itemID1, 1);
|
||||
c.getItemAssistant().deleteItem(itemID2, 1);
|
||||
c.getItemAssistant().addItem(giveItem, 1);
|
||||
c.getPlayerAssistant().addSkillXP(expGained, 7);
|
||||
c.getPacketSender().sendMessage("You create a " + ItemAssistant.getItemName(giveItem) + ".");
|
||||
}
|
||||
} else {
|
||||
c.getPacketSender().sendMessage("You don't have the required level to make an " + ItemAssistant.getItemName(giveItem));
|
||||
}
|
||||
}
|
||||
|
||||
public static void setCooking(Player player, boolean isCooking) {
|
||||
player.playerIsCooking = isCooking;
|
||||
player.stopPlayerSkill = isCooking;
|
||||
}
|
||||
|
||||
private static void viewCookInterface(Player c, int item) {
|
||||
c.getPacketSender().sendChatInterface(1743);
|
||||
c.getPacketSender().sendFrame246(13716, view190 ? 190 : 170, item);
|
||||
c.getPacketSender().sendString(getLine(c) + "" + ItemAssistant.getItemName(item) + "", 13717);
|
||||
}
|
||||
public static void setCooking(Player player, boolean isCooking) {
|
||||
player.playerIsCooking = isCooking;
|
||||
player.stopPlayerSkill = isCooking;
|
||||
}
|
||||
|
||||
public static boolean startCooking(Player c, int itemId, int objectId) {
|
||||
CookingItems item = forId(itemId);
|
||||
if (item != null) {
|
||||
if (c.playerLevel[GameConstants.COOKING] < item.getLevelReq()) {
|
||||
c.getPacketSender().closeAllWindows();
|
||||
c.getDialogueHandler().sendStatement("You need a Cooking level of " + item.getLevelReq() + " to cook this.");
|
||||
c.nextChat = 0;
|
||||
return false;
|
||||
}
|
||||
if (c.playerIsCooking) {
|
||||
c.getPacketSender().closeAllWindows();
|
||||
return false;
|
||||
}
|
||||
if (!COOKING) {
|
||||
c.getPacketSender().sendMessage("This skill is currently disabled.");
|
||||
return false;
|
||||
}
|
||||
// save the id of the item and object for the cooking interface.
|
||||
c.cookingItem = itemId;
|
||||
c.cookingObject = objectId;
|
||||
viewCookInterface(c, item.getRawItem());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private static void viewCookInterface(Player c, int item) {
|
||||
c.getPacketSender().sendChatInterface(1743);
|
||||
c.getPacketSender().sendFrame246(13716, view190 ? 190 : 170, item);
|
||||
c.getPacketSender().sendString(getLine(c) + "" + ItemAssistant.getItemName(item) + "", 13717);
|
||||
}
|
||||
|
||||
private static boolean getSuccess(Player c, int burnBonus, int levelReq, int stopBurn) {
|
||||
if (c.playerLevel[GameConstants.COOKING] >= stopBurn) {
|
||||
return true;
|
||||
}
|
||||
double burn_chance = 55.0 - burnBonus;
|
||||
double cook_level = c.playerLevel[GameConstants.COOKING];
|
||||
double lev_needed = levelReq;
|
||||
double burn_stop = stopBurn;
|
||||
double multi_a = burn_stop - lev_needed;
|
||||
double burn_dec = burn_chance / multi_a;
|
||||
double multi_b = cook_level - lev_needed;
|
||||
burn_chance -= multi_b * burn_dec;
|
||||
double randNum = cookingRandom.nextDouble() * 100.0;
|
||||
return burn_chance <= randNum;
|
||||
}
|
||||
public static boolean startCooking(Player c, int itemId, int objectId) {
|
||||
CookingItems item = forId(itemId);
|
||||
if (item != null) {
|
||||
if (c.playerLevel[GameConstants.COOKING] < item.getLevelReq()) {
|
||||
c.getPacketSender().closeAllWindows();
|
||||
c.getDialogueHandler().sendStatement("You need a Cooking level of " + item.getLevelReq() + " to cook this.");
|
||||
c.nextChat = 0;
|
||||
return false;
|
||||
}
|
||||
if (c.playerIsCooking) {
|
||||
c.getPacketSender().closeAllWindows();
|
||||
return false;
|
||||
}
|
||||
if (!COOKING) {
|
||||
c.getPacketSender().sendMessage("This skill is currently disabled.");
|
||||
return false;
|
||||
}
|
||||
// save the id of the item and object for the cooking interface.
|
||||
c.cookingItem = itemId;
|
||||
c.cookingObject = objectId;
|
||||
viewCookInterface(c, item.getRawItem());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void cookItem(final Player player, final int itemId, final int amount, final int objectId) {
|
||||
CycleEventHandler.getSingleton().stopEvents(player, "cookingEvent".hashCode());
|
||||
final CookingItems item = forId(itemId);
|
||||
if (item != null) {
|
||||
setCooking(player, true);
|
||||
RandomEventHandler.addRandom(player);
|
||||
player.getPacketSender().closeAllWindows();
|
||||
player.doAmount = amount;
|
||||
if (player.doAmount > player.getItemAssistant().getItemAmount(itemId)) {
|
||||
player.doAmount = player.getItemAssistant().getItemAmount(itemId);
|
||||
}
|
||||
if (objectId > 0) {
|
||||
player.startAnimation(objectId == 2732 ? 897 : 896);
|
||||
}
|
||||
CycleEventHandler.getSingleton().addEvent("cookingEvent".hashCode(), player, new CycleEvent() {
|
||||
@Override
|
||||
public void execute(CycleEventContainer container) {
|
||||
if (!player.playerIsCooking) {
|
||||
setCooking(player, false);
|
||||
container.stop();
|
||||
return;
|
||||
}
|
||||
if (!player.getItemAssistant().playerHasItem(item.getRawItem(), 1)) {
|
||||
player.getPacketSender().sendMessage("You have run out of " + item.getName() + " to cook.");
|
||||
setCooking(player, false);
|
||||
container.stop();
|
||||
return;
|
||||
}
|
||||
boolean burn;
|
||||
if (player.playerEquipment[ItemConstants.HANDS] == 775) {
|
||||
burn = !getSuccess(player, 3, item.getLevelReq(), item.getStopBurnGloves());
|
||||
} else {
|
||||
burn = !getSuccess(player, 3, item.getLevelReq(), item.getStopBurn());
|
||||
}
|
||||
player.getItemAssistant().deleteItem(item.getRawItem(),
|
||||
player.getItemAssistant().getItemSlot(itemId), 1);
|
||||
if (!burn) {
|
||||
player.getPacketSender().sendMessage("You successfully cook the " + item.getName().toLowerCase() + ".");
|
||||
if (GameConstants.SOUND) {
|
||||
player.getPacketSender().sendSound(SoundList.COOK_ITEM, 100, 0);
|
||||
}
|
||||
player.getPlayerAssistant().addSkillXP(item.getXp(), GameConstants.COOKING);
|
||||
player.getItemAssistant().addItem(item.getCookedItem(), 1);
|
||||
} else {
|
||||
player.getPacketSender().sendMessage(
|
||||
"Oops! You accidentally burnt the "
|
||||
+ item.getName().toLowerCase() + "!");
|
||||
player.getItemAssistant().addItem(item.getBurntItem(), 1);
|
||||
}
|
||||
player.doAmount--;
|
||||
if (player.disconnected) {
|
||||
container.stop();
|
||||
return;
|
||||
}
|
||||
if (objectId < 0) {
|
||||
container.stop();
|
||||
return;
|
||||
}
|
||||
if (player.playerIsCooking && !Misc.goodDistance(player.objectX, player.objectY, player.absX, player.absY, 2)) {
|
||||
container.stop();
|
||||
return;
|
||||
}
|
||||
if (player.doAmount > 0) {
|
||||
if (objectId > 0) {
|
||||
player.startAnimation(objectId == 2732 ? 897 : 896);
|
||||
}
|
||||
} else if (player.doAmount == 0) {
|
||||
setCooking(player, false);
|
||||
container.stop();
|
||||
}
|
||||
}
|
||||
private static boolean getSuccess(Player c, int burnBonus, int levelReq, int stopBurn) {
|
||||
if (c.playerLevel[GameConstants.COOKING] >= stopBurn) {
|
||||
return true;
|
||||
}
|
||||
double burn_chance = 55.0 - burnBonus;
|
||||
double cook_level = c.playerLevel[GameConstants.COOKING];
|
||||
double lev_needed = levelReq;
|
||||
double burn_stop = stopBurn;
|
||||
double multi_a = burn_stop - lev_needed;
|
||||
double burn_dec = burn_chance / multi_a;
|
||||
double multi_b = cook_level - lev_needed;
|
||||
burn_chance -= multi_b * burn_dec;
|
||||
double randNum = cookingRandom.nextDouble() * 100.0;
|
||||
return burn_chance <= randNum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
|
||||
}
|
||||
}, 4);
|
||||
}
|
||||
}
|
||||
public static void cookItem(final Player player, final int itemId, final int amount, final int objectId) {
|
||||
CycleEventHandler.getSingleton().stopEvents(player, "cookingEvent".hashCode());
|
||||
final CookingItems item = forId(itemId);
|
||||
if (item != null) {
|
||||
setCooking(player, true);
|
||||
RandomEventHandler.addRandom(player);
|
||||
player.getPacketSender().closeAllWindows();
|
||||
player.doAmount = amount;
|
||||
if (player.doAmount > player.getItemAssistant().getItemAmount(itemId)) {
|
||||
player.doAmount = player.getItemAssistant().getItemAmount(itemId);
|
||||
}
|
||||
if (objectId > 0) {
|
||||
player.startAnimation(objectId == StaticObjectList.FIRE ? 897 : 896);
|
||||
}
|
||||
CycleEventHandler.getSingleton().addEvent("cookingEvent".hashCode(), player, new CycleEvent() {
|
||||
@Override
|
||||
public void execute(CycleEventContainer container) {
|
||||
if (!player.playerIsCooking) {
|
||||
setCooking(player, false);
|
||||
container.stop();
|
||||
return;
|
||||
}
|
||||
if (!player.getItemAssistant().playerHasItem(item.getRawItem(), 1)) {
|
||||
player.getPacketSender().sendMessage("You have run out of " + item.getName() + " to cook.");
|
||||
setCooking(player, false);
|
||||
container.stop();
|
||||
return;
|
||||
}
|
||||
boolean burn;
|
||||
if (player.playerEquipment[ItemConstants.HANDS] == StaticItemList.COOKING_GAUNTLETS) {
|
||||
burn = !getSuccess(player, 3, item.getLevelReq(), item.getStopBurnGloves());
|
||||
} else {
|
||||
burn = !getSuccess(player, 3, item.getLevelReq(), item.getStopBurn());
|
||||
}
|
||||
player.getItemAssistant().deleteItem(item.getRawItem(),
|
||||
player.getItemAssistant().getItemSlot(itemId), 1);
|
||||
if (!burn) {
|
||||
player.getPacketSender().sendMessage("You successfully cook the " + item.getName().toLowerCase() + ".");
|
||||
if (GameConstants.SOUND) {
|
||||
player.getPacketSender().sendSound(SoundList.COOK_ITEM, 100, 0);
|
||||
}
|
||||
player.getPlayerAssistant().addSkillXP(item.getXp(), GameConstants.COOKING);
|
||||
player.getItemAssistant().addItem(item.getCookedItem(), 1);
|
||||
} else {
|
||||
player.getPacketSender().sendMessage(
|
||||
"Oops! You accidentally burnt the "
|
||||
+ item.getName().toLowerCase() + "!");
|
||||
player.getItemAssistant().addItem(item.getBurntItem(), 1);
|
||||
}
|
||||
player.doAmount--;
|
||||
if (player.disconnected) {
|
||||
container.stop();
|
||||
return;
|
||||
}
|
||||
if (objectId < 0) {
|
||||
container.stop();
|
||||
return;
|
||||
}
|
||||
if (player.playerIsCooking && !Misc.goodDistance(player.objectX, player.objectY, player.absX, player.absY, 2)) {
|
||||
container.stop();
|
||||
return;
|
||||
}
|
||||
if (player.doAmount > 0) {
|
||||
if (objectId > 0) {
|
||||
player.startAnimation(objectId == StaticObjectList.FIRE ? 897 : 896);
|
||||
}
|
||||
} else if (player.doAmount == 0) {
|
||||
setCooking(player, false);
|
||||
container.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
|
||||
}
|
||||
}, 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+157
-155
@@ -4,6 +4,8 @@ import com.rs2.GameConstants;
|
||||
import com.rs2.event.CycleEvent;
|
||||
import com.rs2.event.CycleEventContainer;
|
||||
import com.rs2.event.CycleEventHandler;
|
||||
import com.rs2.game.content.StaticItemList;
|
||||
import com.rs2.game.content.StaticObjectList;
|
||||
import com.rs2.game.content.music.sound.SoundList;
|
||||
import com.rs2.game.content.skills.SkillHandler;
|
||||
import com.rs2.game.items.ItemAssistant;
|
||||
@@ -12,170 +14,170 @@ import com.rs2.util.Misc;
|
||||
|
||||
public class CookingTutorialIsland extends SkillHandler {
|
||||
|
||||
public static void cookThisFood(Player p, int i, int object) {
|
||||
switch (i) {
|
||||
case 317:
|
||||
cookFish(p, i, 30, 1, 323, 315, object);
|
||||
break;
|
||||
default:
|
||||
p.getPacketSender().sendMessage("Nothing interesting happens.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
public static void cookThisFood(Player p, int i, int object) {
|
||||
switch (i) {
|
||||
case StaticItemList.RAW_SHRIMPS:
|
||||
cookFish(p, i, 30, 1, StaticItemList.BURNT_FISH, StaticItemList.SHRIMPS, object);
|
||||
break;
|
||||
default:
|
||||
p.getPacketSender().sendMessage("Nothing interesting happens.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static void cookFish(Player c, int itemID, int xpRecieved,
|
||||
int levelRequired, int burntFish, int cookedFish, int object) {
|
||||
if (!COOKING) {
|
||||
c.getPacketSender().sendMessage(
|
||||
"Cooking is currently disabled.");
|
||||
return;
|
||||
}
|
||||
if (!hasRequiredLevel(c, 7, levelRequired, "cooking", "cook this")) {
|
||||
return;
|
||||
}
|
||||
int chance = c.playerLevel[GameConstants.COOKING];
|
||||
if (c.playerEquipment[c.playerHands] == 775) {
|
||||
chance = c.playerLevel[GameConstants.COOKING] + 8;
|
||||
}
|
||||
if (chance <= 0) {
|
||||
chance = Misc.random(5);
|
||||
}
|
||||
c.playerSkillProp[GameConstants.COOKING][0] = itemID;
|
||||
c.playerSkillProp[GameConstants.COOKING][1] = xpRecieved;
|
||||
c.playerSkillProp[GameConstants.COOKING][2] = levelRequired;
|
||||
c.playerSkillProp[GameConstants.COOKING][3] = burntFish;
|
||||
c.playerSkillProp[GameConstants.COOKING][4] = cookedFish;
|
||||
c.playerSkillProp[GameConstants.COOKING][5] = object;
|
||||
c.playerSkillProp[GameConstants.COOKING][6] = chance;
|
||||
c.stopPlayerSkill = false;
|
||||
int item = c.getItemAssistant().getItemAmount(c.playerSkillProp[GameConstants.COOKING][0]);
|
||||
if (item == 1) {
|
||||
c.doAmount = 1;
|
||||
cookTutFish(c);
|
||||
return;
|
||||
}
|
||||
viewCookInterface(c, itemID);
|
||||
}
|
||||
private static void cookFish(Player c, int itemID, int xpRecieved,
|
||||
int levelRequired, int burntFish, int cookedFish, int object) {
|
||||
if (!COOKING) {
|
||||
c.getPacketSender().sendMessage(
|
||||
"Cooking is currently disabled.");
|
||||
return;
|
||||
}
|
||||
if (!hasRequiredLevel(c, 7, levelRequired, "cooking", "cook this")) {
|
||||
return;
|
||||
}
|
||||
int chance = c.playerLevel[GameConstants.COOKING];
|
||||
if (c.playerEquipment[c.playerHands] == StaticItemList.COOKING_GAUNTLETS) {
|
||||
chance = c.playerLevel[GameConstants.COOKING] + 8;
|
||||
}
|
||||
if (chance <= 0) {
|
||||
chance = Misc.random(5);
|
||||
}
|
||||
c.playerSkillProp[GameConstants.COOKING][0] = itemID;
|
||||
c.playerSkillProp[GameConstants.COOKING][1] = xpRecieved;
|
||||
c.playerSkillProp[GameConstants.COOKING][2] = levelRequired;
|
||||
c.playerSkillProp[GameConstants.COOKING][3] = burntFish;
|
||||
c.playerSkillProp[GameConstants.COOKING][4] = cookedFish;
|
||||
c.playerSkillProp[GameConstants.COOKING][5] = object;
|
||||
c.playerSkillProp[GameConstants.COOKING][6] = chance;
|
||||
c.stopPlayerSkill = false;
|
||||
int item = c.getItemAssistant().getItemAmount(c.playerSkillProp[GameConstants.COOKING][0]);
|
||||
if (item == 1) {
|
||||
c.doAmount = 1;
|
||||
cookTutFish(c);
|
||||
return;
|
||||
}
|
||||
viewCookInterface(c, itemID);
|
||||
}
|
||||
|
||||
public static void getAmount(Player player, int amount) {
|
||||
int item = player.getItemAssistant().getItemAmount(player.playerSkillProp[GameConstants.COOKING][0]);
|
||||
if (amount > item) {
|
||||
amount = item;
|
||||
}
|
||||
player.doAmount = amount;
|
||||
cookTutFish(player);
|
||||
}
|
||||
public static void getAmount(Player player, int amount) {
|
||||
int item = player.getItemAssistant().getItemAmount(player.playerSkillProp[GameConstants.COOKING][0]);
|
||||
if (amount > item) {
|
||||
amount = item;
|
||||
}
|
||||
player.doAmount = amount;
|
||||
cookTutFish(player);
|
||||
}
|
||||
|
||||
public static void resetCooking(Player c) {
|
||||
c.playerSkilling[GameConstants.COOKING] = false;
|
||||
c.stopPlayerSkill = false;
|
||||
for (int i = 0; i < 6; i++) {
|
||||
c.playerSkillProp[GameConstants.COOKING][i] = -1;
|
||||
}
|
||||
}
|
||||
public static void resetCooking(Player c) {
|
||||
c.playerSkilling[GameConstants.COOKING] = false;
|
||||
c.stopPlayerSkill = false;
|
||||
for (int i = 0; i < 6; i++) {
|
||||
c.playerSkillProp[GameConstants.COOKING][i] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
private static void viewCookInterface(Player c, int item) {
|
||||
c.getPacketSender().sendChatInterface(1743);
|
||||
c.getPacketSender().sendFrame246(13716, 190, item);
|
||||
c.getPacketSender().sendString(
|
||||
"" + ItemAssistant.getItemName(item) + "", 13717);
|
||||
}
|
||||
private static void viewCookInterface(Player c, int item) {
|
||||
c.getPacketSender().sendChatInterface(1743);
|
||||
c.getPacketSender().sendFrame246(13716, 190, item);
|
||||
c.getPacketSender().sendString(
|
||||
"" + ItemAssistant.getItemName(item) + "", 13717);
|
||||
}
|
||||
|
||||
private static void cookTutFish(final Player c) {
|
||||
if (c.playerSkilling[GameConstants.COOKING]) {
|
||||
return;
|
||||
}
|
||||
if (c.tutorialProgress == 6) {
|
||||
c.playerSkilling[GameConstants.COOKING] = true;
|
||||
c.stopPlayerSkill = true;
|
||||
c.getPacketSender().closeAllWindows();
|
||||
if (c.playerSkillProp[GameConstants.COOKING][5] > 0) {
|
||||
// c.startAnimation(c.playerSkillProp[GameConstants.COOKING][5] == 2732 ? 897 :
|
||||
// 896);
|
||||
c.startAnimation(c.playerSkillProp[GameConstants.COOKING][5] == 2732 ? 897
|
||||
: c.playerSkillProp[GameConstants.COOKING][5] == 12269 ? 897 : 896);
|
||||
if (GameConstants.SOUND) {
|
||||
c.getPacketSender().sendSound(SoundList.COOK_ITEM, 100,
|
||||
0);
|
||||
}
|
||||
private static void cookTutFish(final Player c) {
|
||||
if (c.playerSkilling[GameConstants.COOKING]) {
|
||||
return;
|
||||
}
|
||||
if (c.tutorialProgress == 6) {
|
||||
c.playerSkilling[GameConstants.COOKING] = true;
|
||||
c.stopPlayerSkill = true;
|
||||
c.getPacketSender().closeAllWindows();
|
||||
if (c.playerSkillProp[GameConstants.COOKING][5] > 0) {
|
||||
// c.startAnimation(c.playerSkillProp[GameConstants.COOKING][5] == StaticObjectList.FIRE ? 897 :
|
||||
// 896);
|
||||
c.startAnimation(c.playerSkillProp[GameConstants.COOKING][5] == StaticObjectList.FIRE ? 897
|
||||
: c.playerSkillProp[GameConstants.COOKING][5] == StaticObjectList.STOVE_12269 ? 897 : 896);
|
||||
if (GameConstants.SOUND) {
|
||||
c.getPacketSender().sendSound(SoundList.COOK_ITEM, 100,
|
||||
0);
|
||||
}
|
||||
|
||||
}
|
||||
CycleEventHandler.getSingleton().addEvent(c, new CycleEvent() {
|
||||
}
|
||||
CycleEventHandler.getSingleton().addEvent(c, new CycleEvent() {
|
||||
|
||||
@Override
|
||||
public void execute(CycleEventContainer container) {
|
||||
c.getItemAssistant().deleteItem(
|
||||
c.playerSkillProp[GameConstants.COOKING][0],
|
||||
c.getItemAssistant().getItemSlot(
|
||||
c.playerSkillProp[GameConstants.COOKING][0]), 1);
|
||||
if (c.cookStage1 == 1) {
|
||||
c.getPacketSender().chatbox(6180);
|
||||
c.getDialogueHandler()
|
||||
.chatboxText(
|
||||
"You have just burned your first shrimp. This is normal. As you",
|
||||
"get more experience in Cooking, you will burn stuff less often.",
|
||||
"Let's try cooking without burning it this time. First catch some",
|
||||
"more shrimp then use them on a fire.",
|
||||
"Burning your shrimp.");
|
||||
c.getPacketSender().chatbox(6179);
|
||||
c.cookStage1 = 0;
|
||||
c.getItemAssistant()
|
||||
.addItem(c.playerSkillProp[GameConstants.COOKING][3], 1);
|
||||
} else {
|
||||
c.getPacketSender().chatbox(6180);
|
||||
c.getDialogueHandler()
|
||||
.chatboxText(
|
||||
"If you'd like a recap on anything you've learnt so far, speak to",
|
||||
"the Survival Expert. You can now move on to the next",
|
||||
"instructor. Click on the gate shown and follow the path.",
|
||||
"Remember, you can move the camera with the arrow keys.",
|
||||
"Well done, you've just cooked your first RuneScape meal");
|
||||
c.getPacketSender().chatbox(6179);
|
||||
c.getPacketSender().createArrow(3089, 3092,
|
||||
c.getH(), 2);
|
||||
c.getPlayerAssistant().addSkillXP(
|
||||
c.playerSkillProp[GameConstants.COOKING][1], 7);
|
||||
c.getItemAssistant()
|
||||
.addItem(c.playerSkillProp[GameConstants.COOKING][4], 1);
|
||||
c.tutorialProgress = 7;
|
||||
}
|
||||
deleteTime(c);
|
||||
if (!c.getItemAssistant().playerHasItem(
|
||||
c.playerSkillProp[GameConstants.COOKING][0], 1)
|
||||
|| c.doAmount <= 0) {
|
||||
container.stop();
|
||||
}
|
||||
if (!c.stopPlayerSkill) {
|
||||
container.stop();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void execute(CycleEventContainer container) {
|
||||
c.getItemAssistant().deleteItem(
|
||||
c.playerSkillProp[GameConstants.COOKING][0],
|
||||
c.getItemAssistant().getItemSlot(
|
||||
c.playerSkillProp[GameConstants.COOKING][0]), 1);
|
||||
if (c.cookStage1 == 1) {
|
||||
c.getPacketSender().chatbox(6180);
|
||||
c.getDialogueHandler()
|
||||
.chatboxText(
|
||||
"You have just burned your first shrimp. This is normal. As you",
|
||||
"get more experience in Cooking, you will burn stuff less often.",
|
||||
"Let's try cooking without burning it this time. First catch some",
|
||||
"more shrimp then use them on a fire.",
|
||||
"Burning your shrimp.");
|
||||
c.getPacketSender().chatbox(6179);
|
||||
c.cookStage1 = 0;
|
||||
c.getItemAssistant()
|
||||
.addItem(c.playerSkillProp[GameConstants.COOKING][3], 1);
|
||||
} else {
|
||||
c.getPacketSender().chatbox(6180);
|
||||
c.getDialogueHandler()
|
||||
.chatboxText(
|
||||
"If you'd like a recap on anything you've learnt so far, speak to",
|
||||
"the Survival Expert. You can now move on to the next",
|
||||
"instructor. Click on the gate shown and follow the path.",
|
||||
"Remember, you can move the camera with the arrow keys.",
|
||||
"Well done, you've just cooked your first RuneScape meal");
|
||||
c.getPacketSender().chatbox(6179);
|
||||
c.getPacketSender().createArrow(3089, 3092,
|
||||
c.getH(), 2);
|
||||
c.getPlayerAssistant().addSkillXP(
|
||||
c.playerSkillProp[GameConstants.COOKING][1], 7);
|
||||
c.getItemAssistant()
|
||||
.addItem(c.playerSkillProp[GameConstants.COOKING][4], 1);
|
||||
c.tutorialProgress = 7;
|
||||
}
|
||||
deleteTime(c);
|
||||
if (!c.getItemAssistant().playerHasItem(
|
||||
c.playerSkillProp[GameConstants.COOKING][0], 1)
|
||||
|| c.doAmount <= 0) {
|
||||
container.stop();
|
||||
}
|
||||
if (!c.stopPlayerSkill) {
|
||||
container.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
resetCooking(c);
|
||||
}
|
||||
}, 4);
|
||||
CycleEventHandler.getSingleton().addEvent(c, new CycleEvent() {
|
||||
@Override
|
||||
public void stop() {
|
||||
resetCooking(c);
|
||||
}
|
||||
}, 4);
|
||||
CycleEventHandler.getSingleton().addEvent(c, new CycleEvent() {
|
||||
|
||||
@Override
|
||||
public void execute(CycleEventContainer container) {
|
||||
if (c.playerSkillProp[GameConstants.COOKING][5] > 0) {
|
||||
// c.getPacketSender().sendSound(357, 100, 1); //
|
||||
// cook sound
|
||||
c.startAnimation(c.playerSkillProp[GameConstants.COOKING][5] == 2732 ? 897
|
||||
: 896);
|
||||
}
|
||||
if (!c.stopPlayerSkill) {
|
||||
container.stop();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void execute(CycleEventContainer container) {
|
||||
if (c.playerSkillProp[GameConstants.COOKING][5] > 0) {
|
||||
// c.getPacketSender().sendSound(357, 100, 1); //
|
||||
// cook sound
|
||||
c.startAnimation(c.playerSkillProp[GameConstants.COOKING][5] == StaticObjectList.FIRE ? 897
|
||||
: 896);
|
||||
}
|
||||
if (!c.stopPlayerSkill) {
|
||||
container.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
@Override
|
||||
public void stop() {
|
||||
|
||||
}
|
||||
}, 4);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 4);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+88
-86
@@ -1,115 +1,117 @@
|
||||
package com.rs2.game.content.skills.cooking;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.rs2.GameConstants;
|
||||
import com.rs2.event.CycleEvent;
|
||||
import com.rs2.event.CycleEventContainer;
|
||||
import com.rs2.event.CycleEventHandler;
|
||||
import com.rs2.game.content.StaticItemList;
|
||||
import com.rs2.game.items.ItemAssistant;
|
||||
import com.rs2.game.players.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA. User: vayken Date: 23/12/11 Time: 20:42 To change
|
||||
* this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class DairyChurn {
|
||||
private static final int CHURN_ANIMATION = 894;
|
||||
private static final int CHURN_ANIMATION = 894;
|
||||
|
||||
public static enum ChurnData {
|
||||
CREAM(59238, new int[] { 1927 }, 2130, 21, 18), BUTTER(59239,
|
||||
new int[] { 1927, 2130 }, 6697, 38, 40), CHEESE(59240,
|
||||
new int[] { 1927, 2130, 6697 }, 1985, 48, 64);
|
||||
public static enum ChurnData {
|
||||
CREAM(59238, new int[]{StaticItemList.BUCKET_OF_MILK}, StaticItemList.POT_OF_CREAM, 21, 18),
|
||||
BUTTER(59239, new int[]{StaticItemList.BUCKET_OF_MILK, StaticItemList.POT_OF_CREAM}, StaticItemList.PAT_OF_BUTTER, 38, 40),
|
||||
CHEESE(59240, new int[]{StaticItemList.BUCKET_OF_MILK, StaticItemList.POT_OF_CREAM, StaticItemList.PAT_OF_BUTTER}, StaticItemList.CHEESE, 48, 64);
|
||||
|
||||
private int buttonId;
|
||||
private int[] used;
|
||||
private int result;
|
||||
private int level;
|
||||
private double experience;
|
||||
private int buttonId;
|
||||
private int[] used;
|
||||
private int result;
|
||||
private int level;
|
||||
private double experience;
|
||||
|
||||
public static HashMap<Integer, ChurnData> churnItems = new HashMap<Integer, ChurnData>();
|
||||
public static HashMap<Integer, ChurnData> churnItems = new HashMap<Integer, ChurnData>();
|
||||
|
||||
public static ChurnData forId(int id) {
|
||||
return churnItems.get(id);
|
||||
}
|
||||
public static ChurnData forId(int id) {
|
||||
return churnItems.get(id);
|
||||
}
|
||||
|
||||
static {
|
||||
for (ChurnData data : ChurnData.values()) {
|
||||
churnItems.put(data.buttonId, data);
|
||||
}
|
||||
}
|
||||
static {
|
||||
for (ChurnData data : ChurnData.values()) {
|
||||
churnItems.put(data.buttonId, data);
|
||||
}
|
||||
}
|
||||
|
||||
private ChurnData(int buttonId, int[] used, int result, int level,
|
||||
double experience) {
|
||||
this.buttonId = buttonId;
|
||||
this.used = used;
|
||||
this.result = result;
|
||||
this.level = level;
|
||||
this.experience = experience;
|
||||
}
|
||||
private ChurnData(int buttonId, int[] used, int result, int level,
|
||||
double experience) {
|
||||
this.buttonId = buttonId;
|
||||
this.used = used;
|
||||
this.result = result;
|
||||
this.level = level;
|
||||
this.experience = experience;
|
||||
}
|
||||
|
||||
public int getButtonId() {
|
||||
return buttonId;
|
||||
}
|
||||
public int getButtonId() {
|
||||
return buttonId;
|
||||
}
|
||||
|
||||
public int[] getUsed() {
|
||||
return used;
|
||||
}
|
||||
public int[] getUsed() {
|
||||
return used;
|
||||
}
|
||||
|
||||
public int getResult() {
|
||||
return result;
|
||||
}
|
||||
public int getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public double getExperience() {
|
||||
return experience;
|
||||
}
|
||||
public double getExperience() {
|
||||
return experience;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void churnItem(final Player player, int buttonId) {
|
||||
final ChurnData churnData = ChurnData.forId(buttonId);
|
||||
if (churnData == null || player.getStatedInterface() != "dairyChurn") {
|
||||
return;
|
||||
}
|
||||
if (player.playerLevel[GameConstants.COOKING] < churnData.getLevel()) {
|
||||
player.getDialogueHandler().sendStatement("You need a cooking level of " + churnData.getLevel() + " to make this.");
|
||||
return;
|
||||
}
|
||||
public static void churnItem(final Player player, int buttonId) {
|
||||
final ChurnData churnData = ChurnData.forId(buttonId);
|
||||
if (churnData == null || player.getStatedInterface() != "dairyChurn") {
|
||||
return;
|
||||
}
|
||||
if (player.playerLevel[GameConstants.COOKING] < churnData.getLevel()) {
|
||||
player.getDialogueHandler().sendStatement("You need a cooking level of " + churnData.getLevel() + " to make this.");
|
||||
return;
|
||||
}
|
||||
|
||||
player.playerIsCooking = true;
|
||||
player.getPacketSender().closeAllWindows();
|
||||
|
||||
CycleEventHandler.getSingleton().addEvent(player, new CycleEvent() {
|
||||
@Override
|
||||
public void execute(CycleEventContainer container) {
|
||||
for (int i = 0; i <= churnData.getUsed().length - 1; i++) {
|
||||
if (!player.getItemAssistant().playerHasItem(churnData.getUsed()[i])) {
|
||||
player.getDialogueHandler().sendStatement("You don't have the required items to use the churn.");
|
||||
container.stop();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!player.playerIsCooking) {
|
||||
container.stop();
|
||||
return;
|
||||
}
|
||||
container.setTick(5);
|
||||
player.startAnimation(CHURN_ANIMATION);
|
||||
player.getPacketSender().sendMessage("You make a " + ItemAssistant.getItemName(churnData.getResult()).toLowerCase() + ".");
|
||||
for (int i = 0; i < churnData.getUsed().length; i++)
|
||||
player.getItemAssistant().deleteItem(churnData.getUsed()[i], 1);
|
||||
player.getItemAssistant().addItem(churnData.getResult(), 1);
|
||||
player.getItemAssistant().addItem(1925, 1);
|
||||
player.getPlayerAssistant().addSkillXP(churnData.getExperience(), GameConstants.COOKING);
|
||||
}
|
||||
player.playerIsCooking = true;
|
||||
player.getPacketSender().closeAllWindows();
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
player.getPlayerAssistant().resetAnimation();
|
||||
}
|
||||
}, 1);
|
||||
}
|
||||
CycleEventHandler.getSingleton().addEvent(player, new CycleEvent() {
|
||||
@Override
|
||||
public void execute(CycleEventContainer container) {
|
||||
for (int i = 0; i <= churnData.getUsed().length - 1; i++) {
|
||||
if (!player.getItemAssistant().playerHasItem(churnData.getUsed()[i])) {
|
||||
player.getDialogueHandler().sendStatement("You don't have the required items to use the churn.");
|
||||
container.stop();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!player.playerIsCooking) {
|
||||
container.stop();
|
||||
return;
|
||||
}
|
||||
container.setTick(5);
|
||||
player.startAnimation(CHURN_ANIMATION);
|
||||
player.getPacketSender().sendMessage("You make a " + ItemAssistant.getItemName(churnData.getResult()).toLowerCase() + ".");
|
||||
for (int i = 0; i < churnData.getUsed().length; i++)
|
||||
player.getItemAssistant().deleteItem(churnData.getUsed()[i], 1);
|
||||
player.getItemAssistant().addItem(churnData.getResult(), 1);
|
||||
player.getItemAssistant().addItem(StaticItemList.BUCKET, 1);
|
||||
player.getPlayerAssistant().addSkillXP(churnData.getExperience(), GameConstants.COOKING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
player.getPlayerAssistant().resetAnimation();
|
||||
}
|
||||
}, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,115 +1,118 @@
|
||||
package com.rs2.game.content.skills.cooking;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.rs2.GameConstants;
|
||||
import com.rs2.game.content.StaticItemList;
|
||||
import com.rs2.game.content.randomevents.RandomEventHandler;
|
||||
import com.rs2.game.content.skills.SkillHandler;
|
||||
import com.rs2.game.players.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class Potatoes extends SkillHandler {
|
||||
|
||||
Player c;
|
||||
Player c;
|
||||
|
||||
public Potatoes(Player player) {
|
||||
this.c = player;
|
||||
}
|
||||
public Potatoes(Player player) {
|
||||
this.c = player;
|
||||
}
|
||||
|
||||
public enum PotatoMaking {
|
||||
// first item, new item, xp, level required
|
||||
// BUTTERED(6701, 6703, 6697, 95, 39),
|
||||
CHILLI(7062, 7054, 165, 41), CHEESE(1985, 6705, 199, 47), EGG(7064,
|
||||
7056, 195, 51), MUSHROOM(7066, 7058, 27, 64), TUNA(7068, 7060,
|
||||
309, 68);
|
||||
public enum PotatoMaking {
|
||||
// first item, new item, xp, level required
|
||||
// BUTTERED(6701, 6703, 6697, 95, 39),
|
||||
CHILLI(StaticItemList.CHILLI_CON_CARNE, StaticItemList.CHILLI_POTATO, 165, 41),
|
||||
CHEESE(StaticItemList.CHEESE, StaticItemList.POTATO_WITH_CHEESE, 199, 47),
|
||||
EGG(StaticItemList.EGG_AND_TOMATO, StaticItemList.EGG_POTATO, 195, 51),
|
||||
MUSHROOM(StaticItemList.MUSHROOM__ONION, StaticItemList.MUSHROOM_POTATO, 27, 64),
|
||||
TUNA(StaticItemList.TUNA_AND_CORN, StaticItemList.TUNA_POTATO, 309, 68);
|
||||
|
||||
/**
|
||||
* Seperate integers for the id's.
|
||||
*/
|
||||
private int newPotatoID, ingredient, XP, levelReq;
|
||||
/**
|
||||
* Seperate integers for the id's.
|
||||
*/
|
||||
private int newPotatoID, ingredient, XP, levelReq;
|
||||
|
||||
/**
|
||||
* @param ingredient
|
||||
* @param newPotatoID
|
||||
* @param XP
|
||||
* @param levelReq
|
||||
*/
|
||||
private PotatoMaking(int ingredient, int newPotatoID, int XP,
|
||||
int levelReq) {
|
||||
// this.potatoID = potatoID;
|
||||
this.ingredient = ingredient;
|
||||
this.newPotatoID = newPotatoID;
|
||||
this.levelReq = levelReq;
|
||||
this.XP = XP;
|
||||
}
|
||||
/**
|
||||
* @param ingredient
|
||||
* @param newPotatoID
|
||||
* @param XP
|
||||
* @param levelReq
|
||||
*/
|
||||
private PotatoMaking(int ingredient, int newPotatoID, int XP,
|
||||
int levelReq) {
|
||||
// this.potatoID = potatoID;
|
||||
this.ingredient = ingredient;
|
||||
this.newPotatoID = newPotatoID;
|
||||
this.levelReq = levelReq;
|
||||
this.XP = XP;
|
||||
}
|
||||
|
||||
public int getNewPotatoID() {
|
||||
return newPotatoID;
|
||||
}
|
||||
public int getNewPotatoID() {
|
||||
return newPotatoID;
|
||||
}
|
||||
|
||||
public int getIngredient() {
|
||||
return ingredient;
|
||||
}
|
||||
public int getIngredient() {
|
||||
return ingredient;
|
||||
}
|
||||
|
||||
public int getReq() {
|
||||
return levelReq;
|
||||
}
|
||||
public int getReq() {
|
||||
return levelReq;
|
||||
}
|
||||
|
||||
public int getXP() {
|
||||
return XP;
|
||||
}
|
||||
public int getXP() {
|
||||
return XP;
|
||||
}
|
||||
|
||||
private static final Map<Integer, PotatoMaking> potato = new HashMap<Integer, PotatoMaking>();
|
||||
private static final Map<Integer, PotatoMaking> potato = new HashMap<Integer, PotatoMaking>();
|
||||
|
||||
public static PotatoMaking forId(int id) {
|
||||
return potato.get(id);
|
||||
}
|
||||
public static PotatoMaking forId(int id) {
|
||||
return potato.get(id);
|
||||
}
|
||||
|
||||
static {
|
||||
for (PotatoMaking p : PotatoMaking.values()) {
|
||||
potato.put(p.getIngredient(), p);
|
||||
}
|
||||
}
|
||||
}
|
||||
static {
|
||||
for (PotatoMaking p : PotatoMaking.values()) {
|
||||
potato.put(p.getIngredient(), p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Id used with one or the other
|
||||
*
|
||||
* @param id1
|
||||
* @param id2
|
||||
*/
|
||||
public void handlePotato(int id1, int id2) {
|
||||
makePotato(id1 == 6703 ? id2 : id1);
|
||||
}
|
||||
/**
|
||||
* Id used with one or the other
|
||||
*
|
||||
* @param id1
|
||||
* @param id2
|
||||
*/
|
||||
public void handlePotato(int id1, int id2) {
|
||||
makePotato(id1 == StaticItemList.POTATO_WITH_BUTTER ? id2 : id1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creating the actual item and replacing the id's
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public boolean makePotato(int id) {
|
||||
PotatoMaking potato = PotatoMaking.forId(id);
|
||||
if (potato == null) {
|
||||
return false;
|
||||
}
|
||||
if (!COOKING) {
|
||||
c.getPacketSender().sendMessage("This skill is currently disabled.");
|
||||
return false;
|
||||
}
|
||||
if (c.getItemAssistant().playerHasItem(potato.getIngredient(), 1)) {
|
||||
if (c.playerLevel[GameConstants.COOKING] >= potato.getReq()) {
|
||||
c.getItemAssistant().deleteItem(potato.getIngredient(), 1);
|
||||
c.getItemAssistant().deleteItem(6703, 1);
|
||||
c.getPacketSender().sendMessage("You put the topping on.");
|
||||
c.getItemAssistant().addItem(potato.getNewPotatoID(), 1);
|
||||
c.getPlayerAssistant().addSkillXP(potato.getXP(), GameConstants.COOKING);
|
||||
RandomEventHandler.addRandom(c);
|
||||
} else {
|
||||
c.getPacketSender().sendMessage("You need a cooking level of " + potato.getReq() + " to make this potato.");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Creating the actual item and replacing the id's
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public boolean makePotato(int id) {
|
||||
PotatoMaking potato = PotatoMaking.forId(id);
|
||||
if (potato == null) {
|
||||
return false;
|
||||
}
|
||||
if (!COOKING) {
|
||||
c.getPacketSender().sendMessage("This skill is currently disabled.");
|
||||
return false;
|
||||
}
|
||||
if (c.getItemAssistant().playerHasItem(potato.getIngredient(), 1)) {
|
||||
if (c.playerLevel[GameConstants.COOKING] >= potato.getReq()) {
|
||||
c.getItemAssistant().deleteItem(potato.getIngredient(), 1);
|
||||
c.getItemAssistant().deleteItem(StaticItemList.POTATO_WITH_BUTTER, 1);
|
||||
c.getPacketSender().sendMessage("You put the topping on.");
|
||||
c.getItemAssistant().addItem(potato.getNewPotatoID(), 1);
|
||||
c.getPlayerAssistant().addSkillXP(potato.getXP(), GameConstants.COOKING);
|
||||
RandomEventHandler.addRandom(c);
|
||||
} else {
|
||||
c.getPacketSender().sendMessage("You need a cooking level of " + potato.getReq() + " to make this potato.");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,11 @@
|
||||
package com.rs2.game.content.skills.core;
|
||||
|
||||
import com.rs2.GameConstants;
|
||||
import com.rs2.event.*;
|
||||
import com.rs2.event.CycleEvent;
|
||||
import com.rs2.event.CycleEventContainer;
|
||||
import com.rs2.event.CycleEventHandler;
|
||||
import com.rs2.game.content.StaticItemList;
|
||||
import com.rs2.game.content.StaticObjectList;
|
||||
import com.rs2.game.items.ItemAssistant;
|
||||
import com.rs2.game.objects.Object;
|
||||
import com.rs2.game.players.Player;
|
||||
@@ -10,404 +14,408 @@ import com.rs2.util.Misc;
|
||||
import com.rs2.world.clip.Region;
|
||||
|
||||
public class Mining {
|
||||
|
||||
/**
|
||||
* Andrew (Mr Extremez)
|
||||
*/
|
||||
private static final int[] RANDOM_GEMS = {1617, 1619, 1621, 1623};
|
||||
private static final int[] GLORIES = {1706, 1708, 1710, 1712};
|
||||
|
||||
public boolean giveGem(Player player) {
|
||||
int chance = 256;
|
||||
for (int i = 0; i < GLORIES.length; i++) {
|
||||
if (player.playerEquipment[player.playerAmulet] == GLORIES[i]) {
|
||||
chance = 86;
|
||||
}
|
||||
}
|
||||
return Misc.random(chance) == 1;
|
||||
}
|
||||
|
||||
public void obtainGem(Player player) {
|
||||
int reward = RANDOM_GEMS[(int)(RANDOM_GEMS.length * Math.random())];
|
||||
player.getItemAssistant().addItem(reward, 1);
|
||||
player.getPacketSender().sendMessage("You found an " + ItemAssistant.getItemName(reward) + ".");
|
||||
}
|
||||
|
||||
public final int[][] Pick_Settings = {
|
||||
{1265, 1, 1, 625}, //Bronze
|
||||
{1267, 1, 2, 626}, //Iron
|
||||
{1269, 6, 3, 627}, //Steel
|
||||
{1273, 21, 4, 629}, //Mithril
|
||||
{1271, 31, 5, 628}, //Addy
|
||||
{1275, 41, 6, 624}, //Rune
|
||||
};
|
||||
/**
|
||||
* Andrew (Mr Extremez)
|
||||
*/
|
||||
private static final int[] RANDOM_GEMS = {StaticItemList.UNCUT_DIAMOND, StaticItemList.UNCUT_RUBY, StaticItemList.UNCUT_EMERALD, StaticItemList.UNCUT_SAPPHIRE};
|
||||
private static final int[] GLORIES = {StaticItemList.AMULET_OF_GLORY1, StaticItemList.AMULET_OF_GLORY2, StaticItemList.AMULET_OF_GLORY3, StaticItemList.AMULET_OF_GLORY4};
|
||||
|
||||
public static enum gems {
|
||||
OPAL(1625, 60),
|
||||
JADE(1627, 30),
|
||||
RED_TOPAZ(1629, 15),
|
||||
SAPHIRE(1623, 9),
|
||||
EMERALD(1621, 5),
|
||||
RUBY(1619, 5),
|
||||
DIAMOND(1617, 4);
|
||||
public boolean giveGem(Player player) {
|
||||
int chance = 256;
|
||||
for (int i = 0; i < GLORIES.length; i++) {
|
||||
if (player.playerEquipment[player.playerAmulet] == GLORIES[i]) {
|
||||
chance = 86;
|
||||
}
|
||||
}
|
||||
return Misc.random(chance) == 1;
|
||||
}
|
||||
|
||||
public final int itemID;
|
||||
public final int chance;
|
||||
public void obtainGem(Player player) {
|
||||
int reward = RANDOM_GEMS[(int) (RANDOM_GEMS.length * Math.random())];
|
||||
player.getItemAssistant().addItem(reward, 1);
|
||||
player.getPacketSender().sendMessage("You found an " + ItemAssistant.getItemName(reward) + ".");
|
||||
}
|
||||
|
||||
gems(int itemID, int chance){
|
||||
this.itemID = itemID;
|
||||
this.chance = chance;
|
||||
}
|
||||
public final int[][] Pick_Settings = {
|
||||
{StaticItemList.BRONZE_PICKAXE, 1, 1, 625}, //Bronze
|
||||
{StaticItemList.IRON_PICKAXE, 1, 2, 626}, //Iron
|
||||
{StaticItemList.STEEL_PICKAXE, 6, 3, 627}, //Steel
|
||||
{StaticItemList.MITHRIL_PICKAXE, 21, 4, 629}, //Mithril
|
||||
{StaticItemList.ADAMANT_PICKAXE, 31, 5, 628}, //Addy
|
||||
{StaticItemList.RUNE_PICKAXE, 41, 6, 624}, //Rune
|
||||
};
|
||||
|
||||
public static enum gems {
|
||||
OPAL(StaticItemList.UNCUT_OPAL, 60),
|
||||
JADE(StaticItemList.UNCUT_JADE, 30),
|
||||
RED_TOPAZ(StaticItemList.UNCUT_RED_TOPAZ, 15),
|
||||
SAPHIRE(StaticItemList.UNCUT_SAPPHIRE, 9),
|
||||
EMERALD(StaticItemList.UNCUT_EMERALD, 5),
|
||||
RUBY(StaticItemList.UNCUT_RUBY, 5),
|
||||
DIAMOND(StaticItemList.UNCUT_DIAMOND, 4);
|
||||
|
||||
public final int itemID;
|
||||
public final int chance;
|
||||
|
||||
gems(int itemID, int chance) {
|
||||
this.itemID = itemID;
|
||||
this.chance = chance;
|
||||
}
|
||||
|
||||
|
||||
public static int getRandom(){
|
||||
final int maxChance = 128;
|
||||
int random = (int) Math.floor(Math.random() * maxChance);
|
||||
int index = 0;
|
||||
for (gems gem: gems.values()){
|
||||
index += gem.chance;
|
||||
if (index >= random)
|
||||
return gem.itemID;
|
||||
}
|
||||
return gems.OPAL.itemID;
|
||||
}
|
||||
}
|
||||
public static int getRandom() {
|
||||
final int maxChance = 128;
|
||||
int random = (int) Math.floor(Math.random() * maxChance);
|
||||
int index = 0;
|
||||
for (gems gem : gems.values()) {
|
||||
index += gem.chance;
|
||||
if (index >= random)
|
||||
return gem.itemID;
|
||||
}
|
||||
return gems.OPAL.itemID;
|
||||
}
|
||||
}
|
||||
|
||||
public static enum rockData {
|
||||
ESSENCE(new int[] { 2491 }, 1, 5, 2, 0, new int[] { 1436, 7936 }),
|
||||
CLAY(new int[] { 2108, 2109, 11189, 11190, 11191, 9713, 9711, 14905, 14904 }, 1, 5, 1, 2, new int[] { 434 }),
|
||||
COPPER(new int[] { 3042, 2091, 2090, 9708, 9709, 9710, 11960, 14906, 14907 }, 1, 18, 1, 4, new int[] { 436 }),
|
||||
TIN(new int[] { 2094, 2095, 3043, 9716, 9714, 11958, 11957, 11959, 11933, 11934, 11935, 14903, 14902 }, 1, 18, 1, 4, new int[] { 438 }),
|
||||
BLURITE(new int[] { 10574, 10583, 10584, 2110 }, 10, 20, 1, 42, new int[] { 668 }),
|
||||
IRON(new int[] { 450, 2093, 2092, 9717, 9718, 9719, 11962, 11956, 11954, 14856, 14857, 14858, 14914, 14913 }, 15, 35, 2, 9, new int[] { 440 }),
|
||||
SILVER(new int[] { 2101, 11186, 11187, 11188, 2100 }, 20, 40, 3, 100, new int[] { 442 }),
|
||||
COAL(new int[] { 2096, 2097, 11963, 11964, 14850, 14851, 14852, 11930, 11931, 11932 }, 30, 50, 4, 50, new int[] { 453 }),
|
||||
GOLD(new int[] { 2099, 2098, 11183, 11184, 11185, 9720, 9722 }, 40, 65, 6, 100, new int[] { 444 }),
|
||||
MITHRIL(new int[] { 2103, 2102, 14853, 14854, 14855 }, 55, 80, 8, 200, new int[] { 447 }),
|
||||
ADAMANT(new int[] { 2104, 2105, 14862, 14863, 14864 }, 70, 95, 10, 400, new int[] { 449 }),
|
||||
RUNE(new int[] { 14859, 14860, 2106, 2107 }, 85, 125, 20, 1200, new int[] { 451 }),
|
||||
GRANITE(new int[] { 10947 }, 45, 75, 10, 8, new int[] { 6979, 6981, 6983 }),
|
||||
SANDSTONE(new int[] { 10946 }, 35, 60, 5, 8, new int[] { 6971, 6973, 6975, 6977 }),
|
||||
GEM(new int[] {2111}, 40, 65, 6, 175, new int[] {});
|
||||
//Rock ID's, Level Req, XP, mineTimer, respawnTimer, Ore ID's
|
||||
public static enum rockData {
|
||||
ESSENCE(new int[]{StaticObjectList.RUNE_ESSENCE}, 1, 5, 2, 0, new int[]{StaticItemList.RUNE_ESSENCE, StaticItemList.PURE_ESSENCE}),
|
||||
CLAY(new int[]{StaticObjectList.ROCKS_2108, StaticObjectList.ROCKS_2109, StaticObjectList.ROCKS_11189, StaticObjectList.ROCKS_11190, StaticObjectList.ROCKS_11191, StaticObjectList.ROCKS_9713, StaticObjectList.ROCKS_9711, StaticObjectList.ROCKS_14905, StaticObjectList.ROCKS_14904}, 1, 5, 1, 2, new int[]{StaticItemList.CLAY}),
|
||||
COPPER(new int[]{StaticObjectList.ROCKS_3042, StaticObjectList.ROCKS_2091, StaticObjectList.ROCKS_2090, StaticObjectList.ROCKS_9708, StaticObjectList.ROCKS_9709, StaticObjectList.ROCKS_9710, StaticObjectList.ROCKS_11960, StaticObjectList.ROCKS_14906, StaticObjectList.ROCKS_14907}, 1, 18, 1, 4, new int[]{StaticItemList.COPPER_ORE}),
|
||||
TIN(new int[]{StaticObjectList.ROCKS_2094, StaticObjectList.ROCKS_2095, StaticObjectList.ROCKS_3043, StaticObjectList.ROCKS_9716, StaticObjectList.ROCKS_9714, StaticObjectList.ROCKS_11958, StaticObjectList.ROCKS_11957, StaticObjectList.ROCKS_11959, StaticObjectList.ROCKS_11933, StaticObjectList.ROCKS_11934, StaticObjectList.ROCKS_11935, StaticObjectList.ROCKS_14903, StaticObjectList.ROCKS_14902}, 1, 18, 1, 4, new int[]{StaticItemList.TIN_ORE}),
|
||||
BLURITE(new int[]{StaticObjectList.ROCKS_10583, StaticObjectList.ROCKS_10584, StaticObjectList.ROCKS_2110}, 10, 20, 1, 42, new int[]{StaticItemList.BLURITE_ORE}),
|
||||
IRON(new int[]{StaticObjectList.ROCKS, StaticObjectList.ROCKS_2093, StaticObjectList.ROCKS_2092, StaticObjectList.ROCKS_9717, StaticObjectList.ROCKS_9718, StaticObjectList.ROCKS_9719, StaticObjectList.ROCKS_11962, StaticObjectList.ROCKS_11956, StaticObjectList.ROCKS_11954, StaticObjectList.ROCKS_14856, StaticObjectList.ROCKS_14857, StaticObjectList.ROCKS_14858, StaticObjectList.ROCKS_14914, StaticObjectList.ROCKS_14913}, 15, 35, 2, 9, new int[]{StaticItemList.IRON_ORE}),
|
||||
SILVER(new int[]{StaticObjectList.ROCKS_2101, StaticObjectList.ROCKS_11186, StaticObjectList.ROCKS_11187, StaticObjectList.ROCKS_11188, StaticObjectList.ROCKS_2100}, 20, 40, 3, 100, new int[]{StaticItemList.SILVER_ORE}),
|
||||
COAL(new int[]{StaticObjectList.ROCKS_2096, StaticObjectList.ROCKS_2097, StaticObjectList.ROCKS_11963, StaticObjectList.ROCKS_11964, StaticObjectList.ROCKS_14850, StaticObjectList.ROCKS_14851, StaticObjectList.ROCKS_14852, StaticObjectList.ROCKS_11930, StaticObjectList.ROCKS_11931, StaticObjectList.ROCKS_11932}, 30, 50, 4, 50, new int[]{StaticItemList.COAL}),
|
||||
GOLD(new int[]{StaticObjectList.ROCKS_2099, StaticObjectList.ROCKS_2098, StaticObjectList.ROCKS_11183, StaticObjectList.ROCKS_11184, StaticObjectList.ROCKS_11185, StaticObjectList.ROCKS_9720, StaticObjectList.ROCKS_9722}, 40, 65, 6, 100, new int[]{StaticItemList.GOLD_ORE}),
|
||||
MITHRIL(new int[]{StaticObjectList.ROCKS_2103, StaticObjectList.ROCKS_2102, StaticObjectList.ROCKS_14853, StaticObjectList.ROCKS_14854, StaticObjectList.ROCKS_14855}, 55, 80, 8, 200, new int[]{StaticItemList.MITHRIL_ORE}),
|
||||
ADAMANT(new int[]{StaticObjectList.ROCKS_2104, StaticObjectList.ROCKS_2105, StaticObjectList.ROCKS_14862, StaticObjectList.ROCKS_14863, StaticObjectList.ROCKS_14864}, 70, 95, 10, 400, new int[]{StaticItemList.ADAMANTITE_ORE}),
|
||||
RUNE(new int[]{StaticObjectList.ROCKS_14859, StaticObjectList.ROCKS_14860, StaticObjectList.ROCKS_2106, StaticObjectList.ROCKS_2107}, 85, 125, 20, 1200, new int[]{StaticItemList.RUNITE_ORE}),
|
||||
GRANITE(new int[]{StaticObjectList.ROCKS_10947}, 45, 75, 10, 8, new int[]{StaticItemList.GRANITE_500G, StaticItemList.GRANITE_2KG, StaticItemList.GRANITE_5KG}),
|
||||
SANDSTONE(new int[]{StaticObjectList.ROCKS_10946}, 35, 60, 5, 8, new int[]{StaticItemList.SANDSTONE_1KG, StaticItemList.SANDSTONE_2KG, StaticItemList.SANDSTONE_5KG, StaticItemList.SANDSTONE_10KG}),
|
||||
GEM(new int[]{StaticObjectList.ROCKS_2111}, 40, 65, 6, 175, new int[]{});
|
||||
|
||||
private final int levelReq, mineTimer, respawnTimer, xp;
|
||||
private final int[] oreIds;
|
||||
private final int[] objectId;
|
||||
private final int levelReq, mineTimer, respawnTimer, xp;
|
||||
private final int[] oreIds;
|
||||
private final int[] objectId;
|
||||
|
||||
private rockData(final int[] objectId, final int levelReq, final int xp, final int mineTimer, final int respawnTimer, final int... oreIds) {
|
||||
this.objectId = objectId;
|
||||
this.levelReq = levelReq;
|
||||
this.xp = xp;
|
||||
this.mineTimer = mineTimer;
|
||||
this.respawnTimer = respawnTimer;
|
||||
this.oreIds = oreIds;
|
||||
}
|
||||
private rockData(final int[] objectId, final int levelReq, final int xp, final int mineTimer, final int respawnTimer, final int... oreIds) {
|
||||
this.objectId = objectId;
|
||||
this.levelReq = levelReq;
|
||||
this.xp = xp;
|
||||
this.mineTimer = mineTimer;
|
||||
this.respawnTimer = respawnTimer;
|
||||
this.oreIds = oreIds;
|
||||
}
|
||||
|
||||
public int getObject(final int object) {
|
||||
for (int element : objectId) {
|
||||
if (object == element) {
|
||||
return element;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
public int getObject(final int object) {
|
||||
for (int element : objectId) {
|
||||
if (object == element) {
|
||||
return element;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static rockData getRock(final int object) {
|
||||
for (final rockData rock : rockData.values()) {
|
||||
if (object == rock.getObject(object)) {
|
||||
return rock;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static rockData getRock(final int object) {
|
||||
for (final rockData rock : rockData.values()) {
|
||||
if (object == rock.getObject(object)) {
|
||||
return rock;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getRequiredLevel() {
|
||||
return levelReq;
|
||||
}
|
||||
public int getRequiredLevel() {
|
||||
return levelReq;
|
||||
}
|
||||
|
||||
public int getXp() {
|
||||
return xp;
|
||||
}
|
||||
public int getXp() {
|
||||
return xp;
|
||||
}
|
||||
|
||||
public int getTimer() {
|
||||
return mineTimer;
|
||||
}
|
||||
public int getTimer() {
|
||||
return mineTimer;
|
||||
}
|
||||
|
||||
public int getRespawnTimer() {
|
||||
return respawnTimer;
|
||||
}
|
||||
public int getRespawnTimer() {
|
||||
return respawnTimer;
|
||||
}
|
||||
|
||||
public int[] getOreIds() {
|
||||
return oreIds;
|
||||
}
|
||||
public int[] getOreIds() {
|
||||
return oreIds;
|
||||
}
|
||||
|
||||
public int getOre(int playerLevel){
|
||||
if (this == rockData.ESSENCE)
|
||||
return playerLevel < 30 ? oreIds[0] : oreIds[1];
|
||||
if (this == rockData.GEM)
|
||||
return gems.getRandom();
|
||||
public int getOre(int playerLevel) {
|
||||
if (this == rockData.ESSENCE)
|
||||
return playerLevel < 30 ? oreIds[0] : oreIds[1];
|
||||
if (this == rockData.GEM)
|
||||
return gems.getRandom();
|
||||
|
||||
// return a random ore from the possibilities
|
||||
return oreIds[(int) Math.floor(Math.random() * oreIds.length)];
|
||||
}
|
||||
}
|
||||
|
||||
public void repeatAnimation(final Player c) {
|
||||
CycleEventHandler.getSingleton().addEvent(c, new CycleEvent() {
|
||||
@Override
|
||||
public void execute(CycleEventContainer container) {
|
||||
if (c.isMining) {
|
||||
c.startAnimation(Pick_Settings[c.miningAxe][3]);
|
||||
c.getPacketSender().sendSound(432, 100, 0);
|
||||
} else {
|
||||
container.stop();
|
||||
}
|
||||
}
|
||||
// return a random ore from the possibilities
|
||||
return oreIds[(int) Math.floor(Math.random() * oreIds.length)];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
c.startAnimation(65535);
|
||||
c.isMining = false;
|
||||
}
|
||||
}, 3);
|
||||
}
|
||||
|
||||
public void startMining(final Player player, final int objectID, final int objectX, final int objectY, final int type) {
|
||||
CycleEventHandler.getSingleton().stopEvents(player, "miningEvent".hashCode());
|
||||
if (player.isMining || player.miningRock)
|
||||
return;
|
||||
int miningLevel = player.playerLevel[GameConstants.MINING];
|
||||
rockData rock = rockData.getRock(objectID);
|
||||
player.miningAxe = -1;
|
||||
player.turnPlayerTo(objectX, objectY);
|
||||
// check if the player has required level for this rock
|
||||
if (rock.getRequiredLevel() > miningLevel) {
|
||||
player.getPacketSender().sendMessage("You need a Mining level of " + rock.getRequiredLevel() + " to mine this rock.");
|
||||
return;
|
||||
}
|
||||
// check id the player has a pickaxe they can use on them
|
||||
for (int i = 0; i < Pick_Settings.length; i++) {
|
||||
if (player.getItemAssistant().playerHasItem(Pick_Settings[i][0]) || player.playerEquipment[player.playerWeapon] == Pick_Settings[i][0]) {
|
||||
if (Pick_Settings[i][1] <= miningLevel) {
|
||||
player.miningAxe = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (player.miningAxe == -1) {
|
||||
player.getPacketSender().sendMessage("You need a pickaxe to mine this rock.");
|
||||
return;
|
||||
}
|
||||
if (player.getItemAssistant().freeSlots() < 1) {
|
||||
player.getPacketSender().sendMessage("You do not have enough inventory slots to do that.");
|
||||
return;
|
||||
}
|
||||
public void repeatAnimation(final Player c) {
|
||||
CycleEventHandler.getSingleton().addEvent(c, new CycleEvent() {
|
||||
@Override
|
||||
public void execute(CycleEventContainer container) {
|
||||
if (c.isMining) {
|
||||
c.startAnimation(Pick_Settings[c.miningAxe][3]);
|
||||
c.getPacketSender().sendSound(432, 100, 0);
|
||||
} else {
|
||||
container.stop();
|
||||
}
|
||||
}
|
||||
|
||||
player.startAnimation(Pick_Settings[player.miningAxe][3]);
|
||||
player.getPacketSender().sendSound(432, 100, 0);
|
||||
player.isMining = true;
|
||||
repeatAnimation(player);
|
||||
player.rockX = objectX;
|
||||
player.rockY = objectY;
|
||||
player.miningRock = true;
|
||||
@Override
|
||||
public void stop() {
|
||||
c.startAnimation(65535);
|
||||
c.isMining = false;
|
||||
}
|
||||
}, 3);
|
||||
}
|
||||
|
||||
// Tutorial only stuff
|
||||
if (player.tutorialProgress == 17 || player.tutorialProgress == 18) {
|
||||
player.getPacketSender().chatbox(6180);
|
||||
player.getDialogueHandler().chatboxText("", "Your character is now attempting to mine the rock.", "This should only take a few seconds.", "", "Please wait");
|
||||
player.getPacketSender().chatbox(6179);
|
||||
} else {
|
||||
player.getPacketSender().sendMessage("You swing your pick at the rock.");
|
||||
}
|
||||
public void startMining(final Player player, final int objectID, final int objectX, final int objectY, final int type) {
|
||||
CycleEventHandler.getSingleton().stopEvents(player, "miningEvent".hashCode());
|
||||
if (player.isMining || player.miningRock)
|
||||
return;
|
||||
int miningLevel = player.playerLevel[GameConstants.MINING];
|
||||
rockData rock = rockData.getRock(objectID);
|
||||
player.miningAxe = -1;
|
||||
player.turnPlayerTo(objectX, objectY);
|
||||
// check if the player has required level for this rock
|
||||
if (rock.getRequiredLevel() > miningLevel) {
|
||||
player.getPacketSender().sendMessage("You need a Mining level of " + rock.getRequiredLevel() + " to mine this rock.");
|
||||
return;
|
||||
}
|
||||
// check id the player has a pickaxe they can use on them
|
||||
for (int i = 0; i < Pick_Settings.length; i++) {
|
||||
if (player.getItemAssistant().playerHasItem(Pick_Settings[i][0]) || player.playerEquipment[player.playerWeapon] == Pick_Settings[i][0]) {
|
||||
if (Pick_Settings[i][1] <= miningLevel) {
|
||||
player.miningAxe = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (player.miningAxe == -1) {
|
||||
player.getPacketSender().sendMessage("You need a pickaxe to mine this rock.");
|
||||
return;
|
||||
}
|
||||
if (player.getItemAssistant().freeSlots() < 1) {
|
||||
player.getPacketSender().sendMessage("You do not have enough inventory slots to do that.");
|
||||
return;
|
||||
}
|
||||
|
||||
CycleEventHandler.getSingleton().addEvent("miningEvent".hashCode(), player, new CycleEvent() {
|
||||
@Override
|
||||
public void execute(CycleEventContainer container) {
|
||||
int oreID = rock.getOre(miningLevel);
|
||||
if (!player.isMining) {
|
||||
container.stop();
|
||||
player.startAnimation(65535);
|
||||
return;
|
||||
}
|
||||
if (player.isMining) {
|
||||
if (!giveGem(player)) {
|
||||
player.getItemAssistant().addItem(oreID, 1);
|
||||
player.getPlayerAssistant().addSkillXP(rock.getXp(), GameConstants.MINING);
|
||||
player.getPacketSender().sendMessage("You manage to mine some " + ItemAssistant.getItemName(oreID).toLowerCase() + ".");
|
||||
} else {
|
||||
obtainGem(player);
|
||||
}
|
||||
}
|
||||
if (player.tutorialProgress == 17) {
|
||||
if (rock != rockData.TIN) {
|
||||
player.getDialogueHandler().sendStatement("You should mine tin first.");
|
||||
resetMining(player);
|
||||
return;
|
||||
}
|
||||
if (player.getItemAssistant().playerHasItem(438)) {
|
||||
player.getPacketSender().createArrow(3086, 9501, player.getH(), 2);
|
||||
player.getDialogueHandler().chatboxText("Now you have some tin ore you must need some copper ore, then", "you'll have all you need to create a bronze bar. As you did before", "riger click on the copper rock and select 'mine'.", "", "Mining");
|
||||
player.tutorialProgress = 18;
|
||||
}
|
||||
} else if (player.tutorialProgress == 18) {
|
||||
if (rock != rockData.COPPER) {
|
||||
player.getDialogueHandler().sendStatement("You have already mined this type of ore, now try the other.");
|
||||
resetMining(player);
|
||||
return;
|
||||
}
|
||||
if (player.getItemAssistant().playerHasItem(436)) {
|
||||
player.getPacketSender().createArrow(3078, 9495, 0, 2);
|
||||
player.getDialogueHandler().sendDialogues(3061, -1);
|
||||
}
|
||||
}
|
||||
if (player.getItemAssistant().freeSlots() < 1) {
|
||||
player.getPacketSender().sendMessage("You have ran out of inventory slots.");
|
||||
container.stop();
|
||||
}
|
||||
mineRock(rock.getRespawnTimer(), objectX, objectY, type, objectID);
|
||||
container.stop();
|
||||
if (rock == rockData.ESSENCE) {
|
||||
startMining(player, objectID, objectX, objectY, type);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void stop() {
|
||||
player.getPacketSender().closeAllWindows();
|
||||
player.startAnimation(65535);
|
||||
player.isMining = false;
|
||||
player.rockX = 0;
|
||||
player.rockY = 0;
|
||||
player.miningRock = false;
|
||||
return;
|
||||
}
|
||||
}, getTimer(rock, player.miningAxe, miningLevel));
|
||||
}
|
||||
|
||||
public static void resetMining(Player player) {
|
||||
player.getPacketSender().closeAllWindows();
|
||||
player.startAnimation(65535);
|
||||
player.isMining = false;
|
||||
player.rockX = 0;
|
||||
player.rockY = 0;
|
||||
player.miningRock = false;
|
||||
}
|
||||
player.startAnimation(Pick_Settings[player.miningAxe][3]);
|
||||
player.getPacketSender().sendSound(432, 100, 0);
|
||||
player.isMining = true;
|
||||
repeatAnimation(player);
|
||||
player.rockX = objectX;
|
||||
player.rockY = objectY;
|
||||
player.miningRock = true;
|
||||
|
||||
public int getTimer(rockData rock, int pick, int level) {
|
||||
double timer = (int)((rock.getRequiredLevel() * 2) + 20 + Misc.random(20))-((Pick_Settings[pick][2] * (Pick_Settings[pick][2] * 0.75)) + level);
|
||||
if (timer < 2.0) {
|
||||
return 2;
|
||||
} else {
|
||||
return (int)timer;
|
||||
}
|
||||
}
|
||||
// Tutorial only stuff
|
||||
if (player.tutorialProgress == 17 || player.tutorialProgress == 18) {
|
||||
player.getPacketSender().chatbox(6180);
|
||||
player.getDialogueHandler().chatboxText("", "Your character is now attempting to mine the rock.", "This should only take a few seconds.", "", "Please wait");
|
||||
player.getPacketSender().chatbox(6179);
|
||||
} else {
|
||||
player.getPacketSender().sendMessage("You swing your pick at the rock.");
|
||||
}
|
||||
|
||||
public void mineRock(int respawnTime, int x, int y, int type, int i) {
|
||||
if (i != 2491) {
|
||||
new Object(452, x, y, 0, type, 10, i, respawnTime);
|
||||
Region.addObject(452, x, y, 0, 10, type, false);
|
||||
CycleEventHandler.getSingleton().addEvent("miningEvent".hashCode(), player, new CycleEvent() {
|
||||
@Override
|
||||
public void execute(CycleEventContainer container) {
|
||||
int oreID = rock.getOre(miningLevel);
|
||||
if (!player.isMining) {
|
||||
container.stop();
|
||||
player.startAnimation(65535);
|
||||
return;
|
||||
}
|
||||
if (player.isMining) {
|
||||
if (!giveGem(player)) {
|
||||
player.getItemAssistant().addItem(oreID, 1);
|
||||
player.getPlayerAssistant().addSkillXP(rock.getXp(), GameConstants.MINING);
|
||||
player.getPacketSender().sendMessage("You manage to mine some " + ItemAssistant.getItemName(oreID).toLowerCase() + ".");
|
||||
} else {
|
||||
obtainGem(player);
|
||||
}
|
||||
}
|
||||
if (player.tutorialProgress == 17) {
|
||||
if (rock != rockData.TIN) {
|
||||
player.getDialogueHandler().sendStatement("You should mine tin first.");
|
||||
resetMining(player);
|
||||
return;
|
||||
}
|
||||
if (player.getItemAssistant().playerHasItem(StaticItemList.TIN_ORE)) {
|
||||
player.getPacketSender().createArrow(3086, 9501, player.getH(), 2);
|
||||
player.getDialogueHandler().chatboxText("Now you have some tin ore you must need some copper ore, then", "you'll have all you need to create a bronze bar. As you did before", "right click on the copper rock and select 'mine'.", "", "Mining");
|
||||
player.tutorialProgress = 18;
|
||||
}
|
||||
} else if (player.tutorialProgress == 18) {
|
||||
if (rock != rockData.COPPER) {
|
||||
player.getDialogueHandler().sendStatement("You have already mined this type of ore, now try the other.");
|
||||
resetMining(player);
|
||||
return;
|
||||
}
|
||||
if (player.getItemAssistant().playerHasItem(StaticItemList.COPPER_ORE)) {
|
||||
player.getPacketSender().createArrow(3078, 9495, 0, 2);
|
||||
player.getDialogueHandler().sendDialogues(3061, -1);
|
||||
}
|
||||
}
|
||||
if (player.getItemAssistant().freeSlots() < 1) {
|
||||
player.getPacketSender().sendMessage("You have ran out of inventory slots.");
|
||||
container.stop();
|
||||
}
|
||||
mineRock(rock.getRespawnTimer(), objectX, objectY, type, objectID);
|
||||
container.stop();
|
||||
if (rock == rockData.ESSENCE) {
|
||||
startMining(player, objectID, objectX, objectY, type);
|
||||
}
|
||||
}
|
||||
|
||||
for (int t = 0; t < PlayerHandler.players.length; t++) {
|
||||
if (PlayerHandler.players[t] != null) {
|
||||
if (PlayerHandler.players[t].rockX == x && PlayerHandler.players[t].rockY == y) {
|
||||
PlayerHandler.players[t].isMining = false;
|
||||
PlayerHandler.players[t].startAnimation(65535);
|
||||
PlayerHandler.players[t].rockX = 0;
|
||||
PlayerHandler.players[t].rockY = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void prospectRock(final Player player, final String itemName) {
|
||||
if (player.tutorialProgress == 15 || player.tutorialProgress == 16) {
|
||||
player.getPacketSender().closeAllWindows();
|
||||
player.getPacketSender().chatbox(6180);
|
||||
player.getDialogueHandler()
|
||||
.chatboxText(
|
||||
"Please wait.",
|
||||
"Your character is now attempting to prospect the rock. This should",
|
||||
"only take a few seconds.", "", "");
|
||||
player.getPacketSender().chatbox(6179);
|
||||
CycleEventHandler.getSingleton().addEvent(player, new CycleEvent() {
|
||||
@Override
|
||||
public void execute(CycleEventContainer container) {
|
||||
if (player.tutorialProgress == 15) {
|
||||
player.getPacketSender().sendMessage("This rock contains " + itemName.toLowerCase() + ".");
|
||||
player.getPacketSender().chatbox(6180);
|
||||
player.getDialogueHandler()
|
||||
.chatboxText(
|
||||
"",
|
||||
"So now you know there's tin in the grey rocks. Try prospecting",
|
||||
"the brown ones next.", "",
|
||||
"It's tin");
|
||||
player.getPacketSender().createArrow(3086, 9501,
|
||||
player.getH(), 2);
|
||||
player.getPacketSender().chatbox(6179);
|
||||
player.tutorialProgress = 16;
|
||||
container.stop();
|
||||
return;
|
||||
} else if (player.tutorialProgress == 16) {
|
||||
player.getPacketSender().sendMessage("This rock contains " + itemName.toLowerCase() + ".");
|
||||
player.getPacketSender().chatbox(6180);
|
||||
player.getDialogueHandler()
|
||||
.chatboxText(
|
||||
"Talk to the Mining Instructor to find out about these types of",
|
||||
"ore and how you can mine them. He'll even give you the",
|
||||
"required tools.", "",
|
||||
"It's copper");
|
||||
player.getPacketSender().createArrow(1, 5);
|
||||
player.getPacketSender().chatbox(6179);
|
||||
container.stop();
|
||||
return;
|
||||
}
|
||||
player.getPacketSender().sendMessage("This rock contains " + itemName.toLowerCase() + ".");
|
||||
container.stop();
|
||||
}
|
||||
@Override
|
||||
public void stop() {
|
||||
player.getPacketSender().closeAllWindows();
|
||||
player.startAnimation(65535);
|
||||
player.isMining = false;
|
||||
player.rockX = 0;
|
||||
player.rockY = 0;
|
||||
player.miningRock = false;
|
||||
return;
|
||||
}
|
||||
}, getTimer(rock, player.miningAxe, miningLevel));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
|
||||
}
|
||||
public static void resetMining(Player player) {
|
||||
player.getPacketSender().closeAllWindows();
|
||||
player.startAnimation(65535);
|
||||
player.isMining = false;
|
||||
player.rockX = 0;
|
||||
player.rockY = 0;
|
||||
player.miningRock = false;
|
||||
}
|
||||
|
||||
}, 3);
|
||||
return;
|
||||
}
|
||||
player.getPacketSender().sendMessage("You examine the rock for ores...");
|
||||
CycleEventHandler.getSingleton().addEvent(player, new CycleEvent() {
|
||||
@Override
|
||||
public void execute(CycleEventContainer container) {
|
||||
player.getPacketSender().sendMessage("This rock contains " + itemName + ".");
|
||||
container.stop();
|
||||
}
|
||||
@Override
|
||||
public void stop() {
|
||||
|
||||
}
|
||||
}, 3);
|
||||
}
|
||||
public int getTimer(rockData rock, int pick, int level) {
|
||||
double timer = (int) ((rock.getRequiredLevel() * 2) + 20 + Misc.random(20)) - ((Pick_Settings[pick][2] * (Pick_Settings[pick][2] * 0.75)) + level);
|
||||
if (timer < 2.0) {
|
||||
return 2;
|
||||
} else {
|
||||
return (int) timer;
|
||||
}
|
||||
}
|
||||
|
||||
public static void prospectNothing(final Player c) {
|
||||
c.getPacketSender().sendMessage("You examine the rock for ores...");
|
||||
CycleEventHandler.getSingleton().addEvent(c, new CycleEvent() {
|
||||
@Override
|
||||
public void execute(CycleEventContainer container) {
|
||||
c.getPacketSender().sendMessage("There is no ore left in this rock.");
|
||||
container.stop();
|
||||
}
|
||||
@Override
|
||||
public void stop() {
|
||||
|
||||
}
|
||||
}, 2);
|
||||
}
|
||||
public void mineRock(int respawnTime, int x, int y, int type, int i) {
|
||||
if (i != StaticObjectList.RUNE_ESSENCE) {
|
||||
new Object(StaticObjectList.ROCKS_452, x, y, 0, type, 10, i, respawnTime);
|
||||
Region.addObject(StaticObjectList.ROCKS_452, x, y, 0, 10, type, false);
|
||||
|
||||
public static boolean rockExists(int rockID) {
|
||||
for (final rockData rock : rockData.values()) {
|
||||
if (rockID == rock.getObject(rockID)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
for (int t = 0; t < PlayerHandler.players.length; t++) {
|
||||
if (PlayerHandler.players[t] != null) {
|
||||
if (PlayerHandler.players[t].rockX == x && PlayerHandler.players[t].rockY == y) {
|
||||
PlayerHandler.players[t].isMining = false;
|
||||
PlayerHandler.players[t].startAnimation(65535);
|
||||
PlayerHandler.players[t].rockX = 0;
|
||||
PlayerHandler.players[t].rockY = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void prospectRock(final Player player, final String itemName) {
|
||||
if (player.tutorialProgress == 15 || player.tutorialProgress == 16) {
|
||||
player.getPacketSender().closeAllWindows();
|
||||
player.getPacketSender().chatbox(6180);
|
||||
player.getDialogueHandler()
|
||||
.chatboxText(
|
||||
"Please wait.",
|
||||
"Your character is now attempting to prospect the rock. This should",
|
||||
"only take a few seconds.", "", "");
|
||||
player.getPacketSender().chatbox(6179);
|
||||
CycleEventHandler.getSingleton().addEvent(player, new CycleEvent() {
|
||||
@Override
|
||||
public void execute(CycleEventContainer container) {
|
||||
if (player.tutorialProgress == 15) {
|
||||
player.getPacketSender().sendMessage("This rock contains " + itemName.toLowerCase() + ".");
|
||||
player.getPacketSender().chatbox(6180);
|
||||
player.getDialogueHandler()
|
||||
.chatboxText(
|
||||
"",
|
||||
"So now you know there's tin in the grey rocks. Try prospecting",
|
||||
"the brown ones next.", "",
|
||||
"It's tin");
|
||||
player.getPacketSender().createArrow(3086, 9501,
|
||||
player.getH(), 2);
|
||||
player.getPacketSender().chatbox(6179);
|
||||
player.tutorialProgress = 16;
|
||||
container.stop();
|
||||
return;
|
||||
} else if (player.tutorialProgress == 16) {
|
||||
player.getPacketSender().sendMessage("This rock contains " + itemName.toLowerCase() + ".");
|
||||
player.getPacketSender().chatbox(6180);
|
||||
player.getDialogueHandler()
|
||||
.chatboxText(
|
||||
"Talk to the Mining Instructor to find out about these types of",
|
||||
"ore and how you can mine them. He'll even give you the",
|
||||
"required tools.", "",
|
||||
"It's copper");
|
||||
player.getPacketSender().createArrow(1, 5);
|
||||
player.getPacketSender().chatbox(6179);
|
||||
container.stop();
|
||||
return;
|
||||
}
|
||||
player.getPacketSender().sendMessage("This rock contains " + itemName.toLowerCase() + ".");
|
||||
container.stop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
|
||||
}
|
||||
|
||||
}, 3);
|
||||
return;
|
||||
}
|
||||
player.getPacketSender().sendMessage("You examine the rock for ores...");
|
||||
CycleEventHandler.getSingleton().addEvent(player, new CycleEvent() {
|
||||
@Override
|
||||
public void execute(CycleEventContainer container) {
|
||||
player.getPacketSender().sendMessage("This rock contains " + itemName + ".");
|
||||
container.stop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
|
||||
}
|
||||
}, 3);
|
||||
}
|
||||
|
||||
public static void prospectNothing(final Player c) {
|
||||
c.getPacketSender().sendMessage("You examine the rock for ores...");
|
||||
CycleEventHandler.getSingleton().addEvent(c, new CycleEvent() {
|
||||
@Override
|
||||
public void execute(CycleEventContainer container) {
|
||||
c.getPacketSender().sendMessage("There is no ore left in this rock.");
|
||||
container.stop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
|
||||
}
|
||||
}, 2);
|
||||
}
|
||||
|
||||
public static boolean rockExists(int rockID) {
|
||||
for (final rockData rock : rockData.values()) {
|
||||
if (rockID == rock.getObject(rockID)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,77 +1,80 @@
|
||||
package com.rs2.game.items.impl;
|
||||
|
||||
import com.rs2.game.items.ItemData;
|
||||
import com.rs2.GameConstants;
|
||||
import com.rs2.game.items.ItemAssistant;
|
||||
import com.rs2.game.items.ItemData;
|
||||
import com.rs2.game.players.Player;
|
||||
|
||||
import static com.rs2.game.content.StaticItemList.*;
|
||||
|
||||
/**
|
||||
* Dye.java
|
||||
*
|
||||
* @author Andrew (Mr Extremez)
|
||||
*/
|
||||
|
||||
|
||||
public enum Dye {
|
||||
|
||||
RED_CAPE(1763, 1007),
|
||||
BLUE_CAPE(1767, 1021),
|
||||
GREEN_CAPE(1771, 1027),
|
||||
PINK_CAPE(6955, 6959),
|
||||
ORANGE_CAPE(1769, 1031),
|
||||
YELLOW_CAPE(1765, 1023),
|
||||
PURPLE_CAPE(1773, 1029);
|
||||
|
||||
int reward, itemUsed;
|
||||
|
||||
private Dye(int itemUsed, int reward) {
|
||||
this.itemUsed = itemUsed;
|
||||
this.reward = reward;
|
||||
}
|
||||
|
||||
private int getItemUsed() {
|
||||
return itemUsed;
|
||||
}
|
||||
|
||||
private int getReward() {
|
||||
return reward;
|
||||
}
|
||||
|
||||
//blue+yellow =green
|
||||
//red+blue = purple
|
||||
|
||||
public static final int[][] MAIL_DATA = {
|
||||
{1769, 288, 286},
|
||||
{1769, 287, 286},
|
||||
{1767, 288, 287},
|
||||
{1767, 286, 287},
|
||||
{1767, 1765, 1771},
|
||||
{1763, 1767, 1773}
|
||||
};
|
||||
|
||||
public static boolean blockDye(Player player, Dye dye, int itemUsed, int useWith) {
|
||||
if (itemUsed == dye.getItemUsed() && ItemAssistant.getItemName(useWith).equalsIgnoreCase("Cape") && ItemData.itemIsNote[useWith]) {
|
||||
player.getPacketSender().sendMessage("You can't dye a noted cape.");
|
||||
return true;
|
||||
} else if (itemUsed == dye.getItemUsed() && ItemAssistant.getItemName(useWith).equalsIgnoreCase("Cape") && useWith == dye.getReward() && !ItemData.itemIsNote[useWith]) {
|
||||
player.getPacketSender().sendMessage("That cape is already that color.");
|
||||
return true;
|
||||
} else if (itemUsed == dye.getItemUsed() && !ItemAssistant.getItemName(useWith).equalsIgnoreCase("Cape")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void dyeItem(Player player, int itemUsed, int useWith) {
|
||||
for (Dye cape: Dye.values()) {
|
||||
if (blockDye(player, cape, itemUsed, useWith)) {
|
||||
return;
|
||||
}
|
||||
if (itemUsed == cape.getItemUsed() && ItemAssistant.getItemName(useWith).equalsIgnoreCase("Cape") && !ItemData.itemIsNote[useWith] && useWith != cape.getReward()) {
|
||||
player.getItemAssistant().deleteItem(itemUsed, 1);
|
||||
player.getItemAssistant().deleteItem(useWith, 1);
|
||||
player.getItemAssistant().addItem(cape.getReward(), 1);
|
||||
player.getPlayerAssistant().addSkillXP(2.5, GameConstants.CRAFTING);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RED_CAPE(RED_DYE, CAPE),
|
||||
BLUE_CAPE(BLUE_DYE, CAPE_1021),
|
||||
GREEN_CAPE(GREEN_DYE, CAPE_1027),
|
||||
PINK_CAPE(PINK_DYE, CAPE_6959),
|
||||
ORANGE_CAPE(ORANGE_DYE, CAPE_1031),
|
||||
YELLOW_CAPE(YELLOW_DYE, CAPE_1023),
|
||||
PURPLE_CAPE(PURPLE_DYE, CAPE_1029);
|
||||
|
||||
int reward, itemUsed;
|
||||
|
||||
private Dye(int itemUsed, int reward) {
|
||||
this.itemUsed = itemUsed;
|
||||
this.reward = reward;
|
||||
}
|
||||
|
||||
private int getItemUsed() {
|
||||
return itemUsed;
|
||||
}
|
||||
|
||||
private int getReward() {
|
||||
return reward;
|
||||
}
|
||||
|
||||
//blue+yellow =green
|
||||
//red+blue = purple
|
||||
|
||||
public static final int[][] MAIL_DATA = {
|
||||
{ORANGE_DYE, GOBLIN_MAIL, ORANGE_GOBLIN_MAIL},
|
||||
{ORANGE_DYE, BLUE_GOBLIN_MAIL, ORANGE_GOBLIN_MAIL},
|
||||
{BLUE_DYE, GOBLIN_MAIL, BLUE_GOBLIN_MAIL},
|
||||
{BLUE_DYE, ORANGE_GOBLIN_MAIL, BLUE_GOBLIN_MAIL},
|
||||
{BLUE_DYE, YELLOW_DYE, GREEN_DYE},
|
||||
{RED_DYE, BLUE_DYE, PURPLE_DYE}
|
||||
};
|
||||
|
||||
public static boolean blockDye(Player player, Dye dye, int itemUsed, int useWith) {
|
||||
if (itemUsed == dye.getItemUsed() && ItemAssistant.getItemName(useWith).equalsIgnoreCase("Cape") && ItemData.itemIsNote[useWith]) {
|
||||
player.getPacketSender().sendMessage("You can't dye a noted cape.");
|
||||
return true;
|
||||
} else if (itemUsed == dye.getItemUsed() && ItemAssistant.getItemName(useWith).equalsIgnoreCase("Cape") && useWith == dye.getReward() && !ItemData.itemIsNote[useWith]) {
|
||||
player.getPacketSender().sendMessage("That cape is already that color.");
|
||||
return true;
|
||||
} else if (itemUsed == dye.getItemUsed() && !ItemAssistant.getItemName(useWith).equalsIgnoreCase("Cape")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void dyeItem(Player player, int itemUsed, int useWith) {
|
||||
for (Dye cape : Dye.values()) {
|
||||
if (blockDye(player, cape, itemUsed, useWith)) {
|
||||
return;
|
||||
}
|
||||
if (itemUsed == cape.getItemUsed() && ItemAssistant.getItemName(useWith).equalsIgnoreCase("Cape") && !ItemData.itemIsNote[useWith] && useWith != cape.getReward()) {
|
||||
player.getItemAssistant().deleteItem(itemUsed, 1);
|
||||
player.getItemAssistant().deleteItem(useWith, 1);
|
||||
player.getItemAssistant().addItem(cape.getReward(), 1);
|
||||
player.getPlayerAssistant().addSkillXP(2.5, GameConstants.CRAFTING);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user