Some quick patches (#398)

- Bank all should now work for all items again
- Fixed al kharid gate not functioning
- Added unique cabbage pickable for Falador
- Fixed desert disguise wrongly being noted
- Reformatted some of the food code

Closes #397
Closes #395

(I also included @Qweqker changes so that will fix lumbridge bank boundary and adds his new cabbage effect)

Co-authored-by: Daniel Ginovker <dcress01@uoguelph.ca>
This commit is contained in:
Mr Extremez
2020-03-13 19:36:20 -05:00
committed by GitHub
parent f9a9eae356
commit 5706bc9853
19 changed files with 221 additions and 218 deletions
@@ -8,3 +8,9 @@
[2020/01/03] 07:00 andrew5 used command: bank [2020/01/03] 07:00 andrew5 used command: bank
[2020/01/03] 07:00 andrew5 used command: bank [2020/01/03] 07:00 andrew5 used command: bank
[2020/01/03] 07:02 andrew5 used command: bank [2020/01/03] 07:02 andrew5 used command: bank
[2020/03/13] 04:15 andrew5 used command: bank
[2020/03/13] 04:17 andrew5 used command: bank
[2020/03/13] 04:21 andrew5 used command: bank
[2020/03/13] 04:25 andrew5 used command: bank
[2020/03/13] 04:25 andrew5 used command: bank
[2020/03/13] 04:29 andrew5 used command: bank
@@ -8,94 +8,90 @@ import com.rebotted.util.Misc;
public class Food { public class Food {
private final Player c;
public Food(Player player) {
this.c = player;
}
public static enum FoodToEat { public static enum FoodToEat {
Easter_Egg(1961, 12, "Easter Egg", 0, "Food", false), Pumpkin(1959, 14, Easter_Egg(1961, 12, "Easter Egg", 0, "Food", false),
"Pumpkin", 0, "Food", false), Half_Jug_of_Wine(1989, 7, Pumpkin(1959, 14, "Pumpkin", 0, "Food", false),
"Half Full Wine Jug", 1935, "Drink", false), Half_Jug_of_Wine(1989, 7, "Half Full Wine Jug", 1935, "Drink", false),
//GROG(1915, 3, "Grog", 1919, "Drink", true), CUP_OF_TEA(1978, 2 + Misc.random(1), "Cup of Tea", 1980, "Drink", true),
CUP_OF_TEA(1978, 2 + Misc.random(1), "Cup of Tea", 1980, "Drink", true), CUP_OF_TEA2( CUP_OF_TEA2(712, 2 + Misc.random(1), "Cup of Tea", 1980, "Drink", true),
712, 2 + Misc.random(1), "Cup of Tea", 1980, "Drink", true), LEMON(2102, 2,"Lemon", 0, "Food", false), LIME(2120, 2, "Lime", 0, "Food", false),
//WIZARD_MIND(1907, 0, "Wizard Mind Bomb", 0, "Drink", true), PINEAPPLE(2114, 2, "Pineapple", 0, "Food", false),
LEMON(2102, 2,"Lemon", 0, "Food", false), LIME(2120, 2, "Lime", 0, "Food", CHOCOLATE_BAR(1973, 2, "Chocolate Bar", 0, "Food", false),
false), PINEAPPLE(2114, 2, "Pineapple", 0, "Food", false), CHOCOLATE_BAR( Wine(1993, 11, "Wine", 1935, "Drink", false),
1973, 2, "Chocolate Bar", 0, "Food", false), Wine(1993, 11, MACKERAL(355, 6, "Mackeral", 0, "Food", false),
"Wine", 1935, "Drink", false), MACKERAL(355, 6, "Mackeral", 0, MANTA(391, 22, "Manta Ray", 0, "Food", false),
"Food", false), MANTA(391, 22, "Manta Ray", 0, "Food", false), SHARK( SHARK(385, 20, "Shark", 0, "Food", false),
385, 20, "Shark", 0, "Food", false), LOBSTER(379, 12, LOBSTER(379, 12, "Lobster", 0, "Food", false),
"Lobster", 0, "Food", false), KARAMBWAN(3144, 2 + Misc.random(4), "Karambwan", 0, "Food", false), KARAMBWAN(3144, 2 + Misc.random(4), "Karambwan", 0, "Food", false),
//BEER(1917, 1, "Beer", 1919, "Drink", true), TROUT(333, 7, "Trout", 0, "Food", false),
//GREENMANS_ALE(1909, 1, "Greenman's Ale", 1919, "Drink", true), SALMON(329, 9, "Salmon", 0, "Food", false),
TROUT(333, 7, "Trout", SWORDFISH(373, 14, "Swordfish", 0, "Food", false),
0, "Food", false), SALMON(329, 9, "Salmon", 0, "Food", false), SWORDFISH( TUNA(361, 10, "Tuna", 0, "Food", false),
373, 14, "Swordfish", 0, "Food", false), TUNA(361, 10, "Tuna", MONKFISH(7946, 16, "Monkfish", 0, "Food", false),
0, "Food", false), SEA_TURTLE(397, 21, "Sea Turtle", 0, "Food", false),
//MOONLIGHT_MEAD(2955, 4, "Moonlight mead", 1919, "Drink", false), CABBAGE(1965, 1, "Cabbage", 0, "Food", false),
MONKFISH(7946, 16, "Monkfish", 0, CABBAGE_SOUTH_OF_FALADOR(1967, 1, "Cabbage", 0, "Food", false),
"Food", false), SEA_TURTLE(397, 21, "Sea Turtle", 0, "Food", SPINACH(1969, 2, "Spinach Roll", 0, "Food", false),
false), CABBAGE(1965, 1, "Cabbage", 0, "Food", false), CABBAGE_SOUTH_OF_FALADOR(1967, 1, "Cabbage", 0, "Food", false), SPINACH( CAKE(1891, 4, "Cake", 1893, "Food", false),
1969, 2, "Spinach Roll", 0, "Food", false), CAKE(1891, 4, CAKE2(1893, 4, "2/3 Cake", 1895, "Food", false),
"Cake", 1893, "Food", false), CAKE2(1893, 4, "2/3 Cake", 1895, SLICE_OF_CAKE(1895, 4, "2/3 Cake", 0, "Food", false),
"Food", false), SLICE_OF_CAKE(1895, 4, "2/3 Cake", 0, "Food", BASS(365, 13, "Bass", 0, "Food", false),
false), BASS(365, 13, "Bass", 0, "Food", false), COD(339, 7, COD(339, 7, "Cod", 0, "Food", false),
"Cod", 0, "Food", false), POTATO(1942, 1, "Potato", 0, "Food", POTATO(1942, 1, "Potato", 0, "Food", false),
false), BAKED_POTATO(6701, 4, "Baked Potato", 0, "Food", false), POTATO_WITH_CHEESE( BAKED_POTATO(6701, 4, "Baked Potato", 0, "Food", false),
6705, 16, "Potato with Cheese", 0, "Food", false), EGG_POTATO( POTATO_WITH_CHEESE(6705, 16, "Potato with Cheese", 0, "Food", false),
7056, 16, "Egg Potato", 0, "Food", false), CHILLI_POTATO(7054, EGG_POTATO(7056, 16, "Egg Potato", 0, "Food", false),
14, "Chilli Potato", 0, "Food", false), MUSHROOM_POTATO(7058, CHILLI_POTATO(7054, 14, "Chilli Potato", 0, "Food", false),
20, "Mushroom Potato", 0, "Food", false), TUNA_POTATO(7060, 22, MUSHROOM_POTATO(7058, 20, "Mushroom Potato", 0, "Food", false),
"Tuna Potato", 0, "Food", false), SHRIMPS(315, 3, "Shrimps", 0, TUNA_POTATO(7060, 22, "Tuna Potato", 0, "Food", false),
"Food", false), HERRING(347, 5, "Herring", 0, "Food", false), SARDINE( SHRIMPS(315, 3, "Shrimps", 0, "Food", false),
325, 4, "Sardine", 0, "Food", false), CHOCOLATE_CAKE(1897, 5, HERRING(347, 5, "Herring", 0, "Food", false),
"Chocolate Cake", 1899, "Food", false), HALF_CHOCOLATE_CAKE( SARDINE(325, 4, "Sardine", 0, "Food", false),
1899, 5, "2/3 Chocolate Cake", 1901, "Food", false), CHOCOLATE_SLICE( CHOCOLATE_CAKE(1897, 5, "Chocolate Cake", 1899, "Food", false),
1901, 5, "Chocolate Slice", 0, "Food", false), ANCHOVIES(319, HALF_CHOCOLATE_CAKE(1899, 5, "2/3 Chocolate Cake", 1901, "Food", false),
2, "Anchovies", 0, "Food", false), PLAIN_PIZZA(2289, 7, CHOCOLATE_SLICE(1901, 5, "Chocolate Slice", 0, "Food", false),
"Plain Pizza", 2291, "Food", false), HALF_PLAIN_PIZZA(2291, 7, ANCHOVIES(319, 2, "Anchovies", 0, "Food", false),
"1/2 Plain pizza", 0, "Food", false), MEAT_PIZZA(2293, 8, PLAIN_PIZZA(2289, 7, "Plain Pizza", 2291, "Food", false),
"Meat Pizza", 2295, "Food", false), CHICKEN(2140, 3, "Chicken", HALF_PLAIN_PIZZA(2291, 7, "1/2 Plain pizza", 0, "Food", false),
0, "Food", false), MEAT(2142, 2, "Meat", 0, "Food", false), HALF_MEAT_PIZZA( MEAT_PIZZA(2293, 8, "Meat Pizza", 2295, "Food", false),
2295, 8, "1/2 Meat Pizza", 0, "Food", false), ANCHOVY_PIZZA( CHICKEN(2140, 3, "Chicken", 0, "Food", false),
2297, 9, "Anchovy Pizza", 2299, "Food", false), HALF_ANCHOVY_PIZZA( MEAT(2142, 2, "Meat", 0, "Food", false),
2299, 9, "1/2 Anchovy Pizza", 0, "Food", false), PINEAPPLE_PIZZA( HALF_MEAT_PIZZA(2295, 8, "1/2 Meat Pizza", 0, "Food", false),
2301, 11, "Pineapple Pizza", 2303, "Food", false), HALF_PINEAPPLE_PIZZA( ANCHOVY_PIZZA(2297, 9, "Anchovy Pizza", 2299, "Food", false),
2303, 11, "1/2 Pineapple Pizza", 0, "Food", false), BREAD(2309, HALF_ANCHOVY_PIZZA(2299, 9, "1/2 Anchovy Pizza", 0, "Food", false),
5, "Bread", 0, "Food", false), APPLE_PIE(2323, 7, "Apple Pie", PINEAPPLE_PIZZA(2301, 11, "Pineapple Pizza", 2303, "Food", false),
2335, "Food", false), HALF_APPLE_PIE(2335, 7, "Half Apple Pie", HALF_PINEAPPLE_PIZZA(2303, 11, "1/2 Pineapple Pizza", 0, "Food", false),
2313, "Food", false), REDBERRY_PIE(2325, 5, "Redberry Pie", BREAD(2309, 5, "Bread", 0, "Food", false),
2333, "Food", false), HALF_REDBERRY_PIE(2333, 5, APPLE_PIE(2323, 7, "Apple Pie", 2335, "Food", false),
"Half Redberry Pie", 2313, "Food", false), Ugthanki_kebab(1883, HALF_APPLE_PIE(2335, 7, "Half Apple Pie", 2313, "Food", false),
2, "Ugthanki kebab", 0, "Food", false), REDBERRY_PIE(2325, 5, "Redberry Pie", 2333, "Food", false),
// Kebab(1971, 2, "kebab", 0, "food", false), HALF_REDBERRY_PIE(2333, 5, "Half Redberry Pie", 2313, "Food", false),
SEAWEED(403, 4, "Edible Seaweed", 0, "Food", false), Ugthanki_kebab(1883, 2, "Ugthanki kebab", 0, "Food", false),
MEAT_PIE(2327, 6, "Meat Pie", 2331, "Food", false), HALF_MEAT_PIE(2331, SEAWEED(403, 4, "Edible Seaweed", 0, "Food", false),
6, "Half Meat Pie", 2313, "Food", false), SUMMER_PIE(7218, 11, MEAT_PIE(2327, 6, "Meat Pie", 2331, "Food", false),
"Summer Pie", 7220, "Food", false), HALF_SUMMER_PIE(7220, 11, HALF_MEAT_PIE(2331, 6, "Half Meat Pie", 2313, "Food", false),
"Half Summer Pie", 2313, "Food", false), PIKE(351, 8, "Pike", SUMMER_PIE(7218, 11, "Summer Pie", 7220, "Food", false),
0, "Food", false), POTATO_WITH_BUTTER(6703, 14, HALF_SUMMER_PIE(7220, 11, "Half Summer Pie", 2313, "Food", false),
"Potato with Butter", 0, "Food", false), PIKE(351, 8, "Pike", 0, "Food", false),
SLICED_BANANA(3162, 2, "Sliced Banana", 0, "Food", false), POTATO_WITH_BUTTER(6703, 14, "Potato with Butter", 0, "Food", false),
BANANA(1963, 2, "Banana", 0, "Food", false), PEACH(6883, 8, "Peach", 0, "Food", SLICED_BANANA(3162, 2, "Sliced Banana", 0, "Food", false),
false), ORANGE(2108, 2, "Orange", 0, "Food", false), PINEAPPLE_RINGS( BANANA(1963, 2, "Banana", 0, "Food", false),
2118, 2, "Pineapple Rings", 0, "Food", false), PINEAPPLE_CHUNKS( PEACH(6883, 8, "Peach", 0, "Food", false),
2116, 2, "Pineapple Chunks", 0, "Food", false), EASTER_EGG( ORANGE(2108, 2, "Orange", 0, "Food", false),
7928, 1, "Easter Egg", 0, "Food", false), EASTER_EGG2(7929, 1, PINEAPPLE_RINGS(2118, 2, "Pineapple Rings", 0, "Food", false),
"Easter Egg", 0, "Food", false), EASTER_EGG3(7930, 1, PINEAPPLE_CHUNKS(2116, 2, "Pineapple Chunks", 0, "Food", false),
"Easter Egg", 0, "Food", false), EASTER_EGG4(7931, 1, EASTER_EGG(7928, 1, "Easter Egg", 0, "Food", false),
"Easter Egg", 0, "Food", false), EASTER_EGG5(7932, 1, EASTER_EGG2(7929, 1, "Easter Egg", 0, "Food", false),
"Easter Egg", 0, "Food", false), EASTER_EGG6(7933, 1, EASTER_EGG3(7930, 1, "Easter Egg", 0, "Food", false),
"Easter Egg", 0, "Food", false), PURPLE_SWEETS(10476, 9, EASTER_EGG4(7931, 1, "Easter Egg", 0, "Food", false),
"Purple Sweets", 0, "Food", false), POT_OF_CREAM(2130, 1, EASTER_EGG5(7932, 1, "Easter Egg", 0, "Food", false),
"Pot of cream", 0, "Food", false), EASTER_EGG6(7933, 1, "Easter Egg", 0, "Food", false),
FILED_RATION(7934, 9, "Field Ration", 0, "Food", false), PURPLE_SWEETS(10476, 9, "Purple Sweets", 0, "Food", false),
STEW(2003, 11, "Stew", 1923, "Food", false), POT_OF_CREAM(2130, 1, "Pot of cream", 0, "Food", false),
CURRY(2011, 19, "Curry", 1923, "Drink", false), FILED_RATION(7934, 9, "Field Ration", 0, "Food", false),
BANDAGES(4049, 3, "Bandages", 0, "Food", false); STEW(2003, 11, "Stew", 1923, "Food", false),
CURRY(2011, 19, "Curry", 1923, "Drink", false),
BANDAGES(4049, 3, "Bandages", 0, "Food", false);
private int id; private int id;
private int heal; private int heal;
@@ -151,111 +147,101 @@ public class Food {
return Misc.random(r); return Misc.random(r);
} }
public void eat(int id, int slot) { public static void eat(Player player, int id, int slot) {
if (c.isDead || c.playerLevel[3] <= 0) { if (player.isDead || player.playerLevel[3] <= 0) {
return; return;
} }
if (c.duelRule[6]) { if (player.duelRule[6]) {
c.getPacketSender() player.getPacketSender().sendMessage("You may not eat in this duel.");
.sendMessage("You may not eat in this duel.");
return; return;
} }
if (!RareProtection.eatDupedItem(c, id)) { if (!RareProtection.eatDupedItem(player, id)) {
return; return;
} }
if (System.currentTimeMillis() - c.foodDelay >= 1800 if (System.currentTimeMillis() - player.foodDelay >= 1800 && player.playerLevel[3] > 0) {
&& c.playerLevel[3] > 0) { player.getCombatAssistant().resetPlayerAttack();
c.getCombatAssistant().resetPlayerAttack(); player.attackTimer += 2;
c.attackTimer += 2; player.startAnimation(829);
c.startAnimation(829); player.getItemAssistant().deleteItem(id, slot, 1);
c.getItemAssistant().deleteItem(id, slot, 1);
FoodToEat f = FoodToEat.food.get(id); FoodToEat f = FoodToEat.food.get(id);
if (f.hasEffect()) { if (f.hasEffect()) {
foodEffect(id); foodEffect(player, id);
} }
if (f.replaceWith() > 0) { if (f.replaceWith() > 0) {
c.getItemAssistant().addItem(f.replaceWith(), 1); player.getItemAssistant().addItem(f.replaceWith(), 1);
} }
if (f.getType().equalsIgnoreCase("Food")) { if (f.getType().equalsIgnoreCase("Food")) {
if (id == 1965) { if (id == 1965) {
c.getPacketSender().sendMessage( player.getPacketSender().sendMessage("You eat the cabbage. Yuck!");
"You eat the cabbage. Yuck!"); } else if (id == 1967){
} player.getPacketSender().sendMessage("You eat the cabbage. It seems to taste nicer than normal.");
else if (id == 1967){
c.getPacketSender().sendMessage(
"You eat the cabbage. It seems to taste nicer than normal.");
} else { } else {
c.getPacketSender().sendMessage( player.getPacketSender().sendMessage("You eat the " + f.getName() + ".");
"You eat the " + f.getName() + ".");
} }
} } else if (f.getType().equalsIgnoreCase("Drink")) {
else if (f.getType().equalsIgnoreCase("Drink")) {
if (id == 2955) { if (id == 2955) {
c.getPacketSender().sendMessage("It tastes like something just died in your mouth."); player.getPacketSender().sendMessage("It tastes like something just died in your mouth.");
} else { } else {
c.getPacketSender().sendMessage( player.getPacketSender().sendMessage("You drink the " + f.getName() + ".");
"You drink the " + f.getName() + ".");
} }
} }
if (f.getType().equalsIgnoreCase("Food")) { if (f.getType().equalsIgnoreCase("Food")) {
c.getPacketSender().sendSound(SoundList.FOOD_EAT, 100, 0); player.getPacketSender().sendSound(SoundList.FOOD_EAT, 100, 0);
} else if (f.getType().equalsIgnoreCase("Drink")) { } else if (f.getType().equalsIgnoreCase("Drink")) {
c.getPacketSender().sendSound(SoundList.DRINK, 100, 0); player.getPacketSender().sendSound(SoundList.DRINK, 100, 0);
} }
c.foodDelay = System.currentTimeMillis(); player.foodDelay = System.currentTimeMillis();
if (c.playerLevel[3] < c.getLevelForXP(c.playerXP[3])) { if (player.playerLevel[3] < player.getLevelForXP(player.playerXP[3])) {
c.playerLevel[3] += f.getHeal(); player.playerLevel[3] += f.getHeal();
c.getPacketSender().sendMessage("It heals some health."); player.getPacketSender().sendMessage("It heals some health.");
if (c.playerLevel[3] > c.getLevelForXP(c.playerXP[3])) { if (player.playerLevel[3] > player.getLevelForXP(player.playerXP[3])) {
c.playerLevel[3] = c.getLevelForXP(c.playerXP[3]); player.playerLevel[3] = player.getLevelForXP(player.playerXP[3]);
} }
} }
c.getPlayerAssistant().refreshSkill(3); player.getPlayerAssistant().refreshSkill(3);
} }
} }
public void foodEffect(int id) { public static void foodEffect(Player player, int id) {
switch (id) { switch (id) {
case 1978: case 1978:
case 712: case 712:
c.forcedChat("Aaah, nothing like a nice cuppa tea!"); player.forcedChat("Aaah, nothing like a nice cuppa tea!");
break; break;
case 1907: case 1907:
if (c.playerLevel[6] < 50) { if (player.playerLevel[6] < 50) {
c.playerLevel[6] = c.getPlayerAssistant().getLevelForXP( player.playerLevel[6] = player.getPlayerAssistant().getLevelForXP(player.playerXP[6]) + 2;
c.playerXP[6]) + 2;
} else { } else {
c.playerLevel[6] = c.getPlayerAssistant().getLevelForXP( player.playerLevel[6] = player.getPlayerAssistant().getLevelForXP(player.playerXP[6]) + 3;
c.playerXP[6]) + 3;
} }
if (c.playerLevel[2] < 4) { if (player.playerLevel[2] < 4) {
c.playerLevel[2] = 1; player.playerLevel[2] = 1;
} }
if (c.playerLevel[0] < 5) { if (player.playerLevel[0] < 5) {
c.playerLevel[0] = 1; player.playerLevel[0] = 1;
} else { } else {
c.playerLevel[0] = c.getPlayerAssistant().getLevelForXP(c.playerXP[0]) - 4; player.playerLevel[0] = player.getPlayerAssistant().getLevelForXP(player.playerXP[0]) - 4;
} }
if (c.playerLevel[1] < 4) { if (player.playerLevel[1] < 4) {
c.playerLevel[1] = 1; player.playerLevel[1] = 1;
} else { } else {
c.playerLevel[1] = c.getPlayerAssistant().getLevelForXP(c.playerXP[1]) - 3; player.playerLevel[1] = player.getPlayerAssistant().getLevelForXP(player.playerXP[1]) - 3;
} }
if (c.playerLevel[2] < 4) { if (player.playerLevel[2] < 4) {
c.playerLevel[2] = 1; player.playerLevel[2] = 1;
} else { } else {
c.playerLevel[2] = c.getPlayerAssistant().getLevelForXP(c.playerXP[2]) - 3; player.playerLevel[2] = player.getPlayerAssistant().getLevelForXP(player.playerXP[2]) - 3;
} }
c.getPlayerAssistant().refreshSkill(0); player.getPlayerAssistant().refreshSkill(0);
c.getPlayerAssistant().refreshSkill(1); player.getPlayerAssistant().refreshSkill(1);
c.getPlayerAssistant().refreshSkill(2); player.getPlayerAssistant().refreshSkill(2);
c.getPlayerAssistant().refreshSkill(6); player.getPlayerAssistant().refreshSkill(6);
break; break;
} }
} }
public boolean isFood(int id) { public static boolean isFood(int id) {
return FoodToEat.food.containsKey(id); return FoodToEat.food.containsKey(id);
} }
} }
@@ -152,7 +152,7 @@ public class CombatSounds {
} }
public static String getItemName(int ItemID) { public static String getItemName(int ItemID) {
return GameEngine.itemHandler.ItemList[ItemID].itemName; return GameEngine.itemHandler.itemList[ItemID].itemName;
} }
public static int getMagicSound(Player c, int spellId) { public static int getMagicSound(Player c, int spellId) {
@@ -195,7 +195,7 @@ public class Pickpocket extends SkillHandler {
} }
public static int getItemId(String itemName) { public static int getItemId(String itemName) {
for (ItemList i : GameEngine.itemHandler.ItemList) { for (ItemList i : GameEngine.itemHandler.itemList) {
if (i != null) { if (i != null) {
if (i.itemName.equalsIgnoreCase(itemName)) { if (i.itemName.equalsIgnoreCase(itemName)) {
return i.itemId; return i.itemId;
@@ -83,7 +83,7 @@ public class Stalls {
} }
public static int getItemId(String itemName) { public static int getItemId(String itemName) {
for (ItemList i : GameEngine.itemHandler.ItemList) { for (ItemList i : GameEngine.itemHandler.itemList) {
if (i != null) { if (i != null) {
if (i.itemName.equalsIgnoreCase(itemName)) { if (i.itemName.equalsIgnoreCase(itemName)) {
return i.itemId; return i.itemId;
@@ -4023,8 +4023,7 @@ public class DialogueHandler {
break; break;
case 1027: case 1027:
player.getDialogueHandler().sendStatement( player.getDialogueHandler().sendStatement("10 coins are removed from your inventory.");
"10 coins are removed from your inventory.");
OtherObjects.initKharid(player, player.objectId); OtherObjects.initKharid(player, player.objectId);
player.nextChat = 0; player.nextChat = 0;
break; break;
@@ -128,8 +128,8 @@ public class Inventory {
public boolean ownsItem(String itemName) { public boolean ownsItem(String itemName) {
for (int i = 0; i < GameConstants.ITEM_LIMIT; i++) { for (int i = 0; i < GameConstants.ITEM_LIMIT; i++) {
if (GameEngine.itemHandler.ItemList[i] != null) { if (GameEngine.itemHandler.itemList[i] != null) {
if (GameEngine.itemHandler.ItemList[i].itemName if (GameEngine.itemHandler.itemList[i].itemName
.equalsIgnoreCase(itemName)) { .equalsIgnoreCase(itemName)) {
return true; return true;
} }
@@ -100,6 +100,6 @@ public class Item {
} }
public ItemList getDefinition() { public ItemList getDefinition() {
return GameEngine.itemHandler.ItemList[id]; return GameEngine.itemHandler.itemList[id];
} }
} }
@@ -208,6 +208,7 @@ public class ItemAssistant {
} }
} }
//for inv
public int getItemAmount(int itemID) { public int getItemAmount(int itemID) {
int itemCount = 0; int itemCount = 0;
for (int i = 0; i < c.playerItems.length; i++) { for (int i = 0; i < c.playerItems.length; i++) {
@@ -217,6 +218,17 @@ public class ItemAssistant {
} }
return itemCount; return itemCount;
} }
//for bank
public int itemAmount(int itemID) {
int tempAmount = 0;
for (int i = 0; i < c.playerItems.length; i++) {
if (c.playerItems[i] == itemID) {
tempAmount += c.playerItemsN[i];
}
}
return tempAmount;
}
public void writeBonus() { public void writeBonus() {
@@ -540,10 +552,10 @@ public class ItemAssistant {
for (int element : c.playerEquipment) { for (int element : c.playerEquipment) {
if (element > -1) { if (element > -1) {
for (int j = 0; j < GameConstants.ITEM_LIMIT; j++) { for (int j = 0; j < GameConstants.ITEM_LIMIT; j++) {
if (GameEngine.itemHandler.ItemList[j] != null) { if (GameEngine.itemHandler.itemList[j] != null) {
if (GameEngine.itemHandler.ItemList[j].itemId == element) { if (GameEngine.itemHandler.itemList[j].itemId == element) {
for (int k = 0; k < c.playerBonus.length; k++) { for (int k = 0; k < c.playerBonus.length; k++) {
c.playerBonus[k] += GameEngine.itemHandler.ItemList[j].Bonuses[k]; c.playerBonus[k] += GameEngine.itemHandler.itemList[j].Bonuses[k];
} }
break; break;
} }
@@ -2035,22 +2047,17 @@ public class ItemAssistant {
} }
if (amount > 0) { if (amount > 0) {
if (c.bankItems[fromSlot] > 0) { if (c.bankItems[fromSlot] > 0) {
if (c.getItemAssistant().playerHasItem(itemID)) if (c.getItemAssistant().playerHasItem(itemID)) {
{ for (int i = 0; i <= 27; i++) {
for (int i = 0; i <= 27;i++) if (itemID == c.playerItems[i] || (itemID == 995 && c.playerItems[i] - 1 == 995)) {
{ if ((c.playerItemsN[i] + amount + 1) < -1) {
if (itemID == c.playerItems[i] || (itemID == 995 && c.playerItems[i] - 1 == 995))
{
if ((c.playerItemsN[i] + amount + 1) < -1)
{
cantWithdrawCuzMaxStack = true; cantWithdrawCuzMaxStack = true;
break; break;
} }
} }
} }
} }
if (!cantWithdrawCuzMaxStack) if (!cantWithdrawCuzMaxStack) {
{
if (!c.takeAsNote) { if (!c.takeAsNote) {
if (ItemData.itemStackable[c.bankItems[fromSlot] - 1]) { if (ItemData.itemStackable[c.bankItems[fromSlot] - 1]) {
if (c.bankItemsN[fromSlot] > amount) { if (c.bankItemsN[fromSlot] > amount) {
@@ -2060,8 +2067,7 @@ public class ItemAssistant {
resetItems(5064); resetItems(5064);
} }
} else { } else {
if (addItem(c.bankItems[fromSlot] - 1, if (addItem(c.bankItems[fromSlot] - 1, c.bankItemsN[fromSlot])) {
c.bankItemsN[fromSlot])) {
c.bankItems[fromSlot] = 0; c.bankItems[fromSlot] = 0;
c.bankItemsN[fromSlot] = 0; c.bankItemsN[fromSlot] = 0;
resetBank(); resetBank();
@@ -2109,8 +2115,7 @@ public class ItemAssistant {
resetItems(5064); resetItems(5064);
} }
} else { } else {
if (addItem(c.bankItems[fromSlot] - 1, if (addItem(c.bankItems[fromSlot] - 1, c.bankItemsN[fromSlot])) {
c.bankItemsN[fromSlot])) {
c.bankItems[fromSlot] = 0; c.bankItems[fromSlot] = 0;
c.bankItemsN[fromSlot] = 0; c.bankItemsN[fromSlot] = 0;
resetBank(); resetBank();
@@ -2134,9 +2139,7 @@ public class ItemAssistant {
resetItems(5064); resetItems(5064);
} }
} }
} } else {
else
{
c.getPacketSender().sendMessage("Can't withdraw more of that item!"); c.getPacketSender().sendMessage("Can't withdraw more of that item!");
} }
} }
@@ -2450,9 +2453,9 @@ public class ItemAssistant {
public static String getItemName(int ItemID) { public static String getItemName(int ItemID) {
for (int i = 0; i < GameConstants.ITEM_LIMIT; i++) { for (int i = 0; i < GameConstants.ITEM_LIMIT; i++) {
if (GameEngine.itemHandler.ItemList[i] != null) { if (GameEngine.itemHandler.itemList[i] != null) {
if (GameEngine.itemHandler.ItemList[i].itemId == ItemID) { if (GameEngine.itemHandler.itemList[i].itemId == ItemID) {
return GameEngine.itemHandler.ItemList[i].itemName; return GameEngine.itemHandler.itemList[i].itemName;
} }
} }
} }
@@ -2461,10 +2464,10 @@ public class ItemAssistant {
public int getItemId(String itemName) { public int getItemId(String itemName) {
for (int i = 0; i < GameConstants.ITEM_LIMIT; i++) { for (int i = 0; i < GameConstants.ITEM_LIMIT; i++) {
if (GameEngine.itemHandler.ItemList[i] != null) { if (GameEngine.itemHandler.itemList[i] != null) {
if (GameEngine.itemHandler.ItemList[i].itemName if (GameEngine.itemHandler.itemList[i].itemName
.equalsIgnoreCase(itemName)) { .equalsIgnoreCase(itemName)) {
return GameEngine.itemHandler.ItemList[i].itemId; return GameEngine.itemHandler.itemList[i].itemId;
} }
} }
} }
@@ -2530,26 +2533,26 @@ public class ItemAssistant {
} }
public int getUnnotedItem(int ItemID) { public int getUnnotedItem(int ItemID) {
int NewID = ItemID - 1; int newId = ItemID - 1;
String NotedName = ""; String NotedName = "";
for (int i = 0; i < GameConstants.ITEM_LIMIT; i++) { for (int i = 0; i < GameConstants.ITEM_LIMIT; i++) {
if (GameEngine.itemHandler.ItemList[i] != null) { if (GameEngine.itemHandler.itemList[i] != null) {
if (GameEngine.itemHandler.ItemList[i].itemId == ItemID) { if (GameEngine.itemHandler.itemList[i].itemId == ItemID) {
NotedName = GameEngine.itemHandler.ItemList[i].itemName; NotedName = GameEngine.itemHandler.itemList[i].itemName;
} }
} }
} }
for (int i = 0; i < GameConstants.ITEM_LIMIT; i++) { for (int i = 0; i < GameConstants.ITEM_LIMIT; i++) {
if (GameEngine.itemHandler.ItemList[i] != null) { if (GameEngine.itemHandler.itemList[i] != null) {
if (GameEngine.itemHandler.ItemList[i].itemName == NotedName) { if (GameEngine.itemHandler.itemList[i].itemName == NotedName) {
if (GameEngine.itemHandler.ItemList[i].itemDescription.startsWith("Swap this note at any bank for a") == false) { if (GameEngine.itemHandler.itemList[i].itemDescription.startsWith("Swap this note at any bank for a") == false) {
NewID = GameEngine.itemHandler.ItemList[i].itemId; newId = GameEngine.itemHandler.itemList[i].itemId;
break; break;
} }
} }
} }
} }
return NewID; return newId;
} }
} }
@@ -187,7 +187,7 @@ public class ItemData {
} }
public static String getItemName(int id) { public static String getItemName(int id) {
for (ItemList element : GameEngine.itemHandler.ItemList) { for (ItemList element : GameEngine.itemHandler.itemList) {
if (element != null) { if (element != null) {
if (element.itemId == id) { if (element.itemId == id) {
return element.itemName; return element.itemName;
@@ -225,7 +225,12 @@ public class ItemData {
try { try {
FileInputStream dataIn = new FileInputStream(new File("./data/data/notes.dat")); FileInputStream dataIn = new FileInputStream(new File("./data/data/notes.dat"));
while ((c = dataIn.read()) != -1) { while ((c = dataIn.read()) != -1) {
itemIsNote[counter] = c == 0; if (c == 0) {
itemIsNote[counter] = false;
itemIsNote[4611] = false;
} else {
itemIsNote[counter] = true;
}
counter++; counter++;
} }
dataIn.close(); dataIn.close();
@@ -227,7 +227,7 @@ public class NPCDropsHandler {
* @return * @return
*/ */
public static int getItemId(String itemName) { public static int getItemId(String itemName) {
for (ItemList i : GameEngine.itemHandler.ItemList) { for (ItemList i : GameEngine.itemHandler.itemList) {
if (i != null) { if (i != null) {
if (i.itemName.equalsIgnoreCase(itemName)) { if (i.itemName.equalsIgnoreCase(itemName)) {
return i.itemId; return i.itemId;
@@ -48,7 +48,7 @@ public class OtherObjects {
return; return;
} }
if (openKharid(player, objectId)) { if (openKharid(player, objectId)) {
GameEngine.objectHandler.createAnObject(player, -1, player.objectX, player.objectY, -1); //GameEngine.objectHandler.createAnObject(player, -1, player.objectX, player.objectY, -1);
final int[] coords = new int[2]; final int[] coords = new int[2];
if (player.getX() == 3267) { if (player.getX() == 3267) {
player.getPlayerAssistant().movePlayer(player.getX() + 1, player.getY(), 0); player.getPlayerAssistant().movePlayer(player.getX() + 1, player.getY(), 0);
@@ -6,6 +6,7 @@ import com.rebotted.event.CycleEventContainer;
import com.rebotted.event.CycleEventHandler; import com.rebotted.event.CycleEventHandler;
import com.rebotted.game.content.music.sound.SoundList; import com.rebotted.game.content.music.sound.SoundList;
import com.rebotted.game.players.Player; import com.rebotted.game.players.Player;
import com.rebotted.world.Boundary;
/** /**
* Pickables * Pickables
@@ -18,7 +19,10 @@ public class Pickable {
{ 1161, 1965 }, // Cabbage { 1161, 1965 }, // Cabbage
{ 2646, 1779 }, // Flax { 2646, 1779 }, // Flax
{ 313, 1947 }, // Wheat { 313, 1947 }, // Wheat
{ 5585, 1947 }, { 5584, 1947 }, { 5585, 1947 }, { 312, 1942 }, // Potato { 5585, 1947 }, // Wheat
{ 5584, 1947 }, // Wheat
{ 5585, 1947 }, // Wheat
{ 312, 1942 }, // Potato
{ 3366, 1957 }, // Onion { 3366, 1957 }, // Onion
}; };
@@ -30,7 +34,11 @@ public class Pickable {
final int objectId = data[0]; final int objectId = data[0];
int itemId = data[1]; int itemId = data[1];
if (objectType == objectId) { if (objectType == objectId) {
player.getItemAssistant().addItem(itemId, 1); if (objectType == 1161 && Boundary.isIn(player, Boundary.FALADOR)) {//Cabbage falador
player.getItemAssistant().addItem(1967, 1);
} else {
player.getItemAssistant().addItem(itemId, 1);
}
break; break;
} }
} }
@@ -120,7 +120,6 @@ public abstract class Player {
private final Queue<Packet> queuedPackets = new LinkedList<Packet>(); private final Queue<Packet> queuedPackets = new LinkedList<Packet>();
private final Potions potions = new Potions(this); private final Potions potions = new Potions(this);
private final PotionMixing potionMixing = new PotionMixing(this); private final PotionMixing potionMixing = new PotionMixing(this);
private final Food food = new Food(this);
private final EmoteHandler emoteHandler = new EmoteHandler(this); private final EmoteHandler emoteHandler = new EmoteHandler(this);
private final SkillInterfaces skillInterfaces = new SkillInterfaces(this); private final SkillInterfaces skillInterfaces = new SkillInterfaces(this);
private final Enchanting enchanting = new Enchanting(this); private final Enchanting enchanting = new Enchanting(this);
@@ -434,11 +433,6 @@ public abstract class Player {
return potionMixing; return potionMixing;
} }
public Food getFood() {
return food;
}
public Inventory getInventory() { public Inventory getInventory() {
return inventory; return inventory;
} }
@@ -52,7 +52,7 @@ public class BankAll implements PacketType {
return; return;
} }
if (player.inPartyRoom) { if (player.inPartyRoom) {
PartyRoom.depositItem(player, removeId, player.getItemAssistant().getItemAmount(player.playerItems[removeSlot])); PartyRoom.depositItem(player, removeId, player.getItemAssistant().itemAmount(player.playerItems[removeSlot]));
break; break;
} }
if (player.inTrade) { if (player.inTrade) {
@@ -62,7 +62,7 @@ public class BankAll implements PacketType {
if (ItemData.itemStackable[removeId]) { if (ItemData.itemStackable[removeId]) {
player.getItemAssistant().bankItem(player.playerItems[removeSlot], removeSlot, player.playerItemsN[removeSlot]); player.getItemAssistant().bankItem(player.playerItems[removeSlot], removeSlot, player.playerItemsN[removeSlot]);
} else { } else {
player.getItemAssistant().bankItem(player.playerItems[removeSlot], removeSlot, player.getItemAssistant().getItemAmount(player.playerItems[removeSlot])); player.getItemAssistant().bankItem(player.playerItems[removeSlot], removeSlot, player.getItemAssistant().itemAmount(player.playerItems[removeSlot]));
} }
break; break;
@@ -5,6 +5,7 @@ import com.rebotted.GameEngine;
import com.rebotted.game.content.consumables.Beverages; import com.rebotted.game.content.consumables.Beverages;
import com.rebotted.game.content.consumables.Kebabs; import com.rebotted.game.content.consumables.Kebabs;
import com.rebotted.game.content.consumables.Beverages.beverageData; import com.rebotted.game.content.consumables.Beverages.beverageData;
import com.rebotted.game.content.consumables.Food;
import com.rebotted.game.content.minigames.TreasureTrails; import com.rebotted.game.content.minigames.TreasureTrails;
import com.rebotted.game.content.minigames.castlewars.CastleWars; import com.rebotted.game.content.minigames.castlewars.CastleWars;
import com.rebotted.game.content.skills.herblore.Herblore; import com.rebotted.game.content.skills.herblore.Herblore;
@@ -291,8 +292,8 @@ public class ClickItem implements PacketType {
} }
} }
if (player.getFood().isFood(itemId)) { if (Food.isFood(itemId)) {
player.getFood().eat(itemId, itemSlot); Food.eat(player, itemId, itemSlot);
} }
if (Prayer.playerBones(player, itemId)) { if (Prayer.playerBones(player, itemId)) {
Prayer.buryBones(player, itemId, itemSlot); Prayer.buryBones(player, itemId, itemSlot);
@@ -18,16 +18,18 @@ public class InterfaceX implements PacketType {
if (Xamount == 0) { if (Xamount == 0) {
Xamount = 1; Xamount = 1;
} }
if (player.playerIsCooking && player.doAmount > 0) { if (!player.isBanking) {
Cooking.cookItem(player, player.cookingItem, Xamount, player.cookingObject); if (player.playerIsCooking && player.doAmount > 0) {
} Cooking.cookItem(player, player.cookingItem, Xamount, player.cookingObject);
if (player.isSmelting && player.doAmount > 0) { }
Smelting.smeltBar(player, player.smeltingItem); if (player.isSmelting && player.doAmount > 0) {
Smelting.smeltBar(player, player.smeltingItem);
}
} }
switch (player.xInterfaceId) { switch (player.xInterfaceId) {
case 5064: case 5064:
if (player.inPartyRoom) { if (player.inPartyRoom) {
PartyRoom.depositItem(player, player.xRemoveId, player.getItemAssistant().getItemAmount(player.playerItems[player.xRemoveSlot])); PartyRoom.depositItem(player, player.xRemoveId, player.getItemAssistant().itemAmount(player.playerItems[player.xRemoveSlot]));
break; break;
} }
if (player.inTrade) { if (player.inTrade) {
@@ -3,7 +3,6 @@ package com.rebotted.world;
import java.util.Arrays; import java.util.Arrays;
import java.util.Objects; import java.util.Objects;
import java.util.Optional; import java.util.Optional;
import com.rebotted.game.npcs.Npc; import com.rebotted.game.npcs.Npc;
import com.rebotted.game.players.Player; import com.rebotted.game.players.Player;
import com.rebotted.game.players.PlayerHandler; import com.rebotted.game.players.PlayerHandler;
@@ -30,7 +30,7 @@ public class ItemHandler {
public ItemHandler() { public ItemHandler() {
for (int i = 0; i < GameConstants.ITEM_LIMIT; i++) { for (int i = 0; i < GameConstants.ITEM_LIMIT; i++) {
ItemList[i] = null; itemList[i] = null;
} }
loadItemList("item.cfg"); loadItemList("item.cfg");
} }
@@ -302,13 +302,13 @@ public int itemAmount(String name, int itemId, int itemX, int itemY) {
* Item List * Item List
**/ **/
public ItemList ItemList[] = new ItemList[GameConstants.ITEM_LIMIT]; public ItemList itemList[] = new ItemList[GameConstants.ITEM_LIMIT];
public void newItemList(int ItemId, String ItemName, String ItemDescription, double ShopValue, double LowAlch, double HighAlch, int Bonuses[]) { public void newItemList(int ItemId, String ItemName, String ItemDescription, double ShopValue, double LowAlch, double HighAlch, int Bonuses[]) {
// first, search for a free slot // first, search for a free slot
int slot = -1; int slot = -1;
for (int i = 0; i < 11740; i++) { for (int i = 0; i < 11740; i++) {
if (ItemList[i] == null) { if (itemList[i] == null) {
slot = i; slot = i;
break; break;
} }
@@ -324,7 +324,7 @@ public int itemAmount(String name, int itemId, int itemX, int itemY) {
newItemList.LowAlch = LowAlch; newItemList.LowAlch = LowAlch;
newItemList.HighAlch = HighAlch; newItemList.HighAlch = HighAlch;
newItemList.Bonuses = Bonuses; newItemList.Bonuses = Bonuses;
ItemList[slot] = newItemList; itemList[slot] = newItemList;
} }
public void loadItemPrices(String filename) { public void loadItemPrices(String filename) {
@@ -344,7 +344,7 @@ public int itemAmount(String name, int itemId, int itemX, int itemY) {
} }
public ItemList getItemList(int i) { public ItemList getItemList(int i) {
for (com.rebotted.game.items.ItemList element : ItemList) { for (com.rebotted.game.items.ItemList element : itemList) {
if (element != null) { if (element != null) {
if (element.itemId == i) { if (element.itemId == i) {
return element; return element;