Rename & Repackage

This commit is contained in:
dark98
2021-03-11 00:21:56 +00:00
parent caa4625efa
commit 3bf473129d
1921 changed files with 2017 additions and 2010 deletions
@@ -0,0 +1,16 @@
package com.rs2.game.items;
public class GameItem {
public int id, amount;
public boolean stackable = false;
public GameItem(int id, int amount) {
if (ItemData.itemStackable[id]) {
stackable = true;
}
this.id = id;
this.amount = amount;
}
}
@@ -0,0 +1,44 @@
package com.rs2.game.items;
public class GroundItem {
public int itemId, itemX, itemY, itemAmount, itemController, hideTicks, removeTicks;
public String ownerName;
public GroundItem(int id, int x, int y, int h, int amount, int controller,
int hideTicks, String name) {
itemId = id;
itemX = x;
itemY = y;
itemAmount = amount;
itemController = controller;
this.hideTicks = hideTicks;
ownerName = name;
}
public int getItemId() {
return itemId;
}
public int getItemX() {
return itemX;
}
public int getItemY() {
return itemY;
}
public int getItemAmount() {
return itemAmount;
}
public int getItemController() {
return itemController;
}
public String getName() {
return ownerName;
}
}
@@ -0,0 +1,149 @@
package com.rs2.game.items;
import com.rs2.GameConstants;
import com.rs2.GameEngine;
import com.rs2.game.players.Player;
/**
*
* @author ArrowzFtw
* @note itemId+1 is the playerItems
* @note playerItems-1 = normalItemId
*/
public class Inventory {
Player player;
public Inventory(Player player) {
this.player = player;
}
public void removeItem(Item i) {
player.getItemAssistant().deleteItem(i.getId(), i.getCount());
}
public void addItemToSlot(Item i, int slot) {
if (get(slot) != i.getId() + 1) {
player.playerItems[slot] = i.getId() + 1;
player.playerItemsN[slot] = i.getCount();
} else {
player.playerItemsN[slot] += i.getCount();
}
update();
}
public int get(int slot) {
return player.playerItems[slot];
}
public void update() {
player.getItemAssistant().resetItems(3214);
}
public boolean contains(int id) {
return player.getItemAssistant().playerHasItem(id);
}
public boolean contains(Item item) {
return player.getItemAssistant().playerHasItem(item.getId(), item.getCount());
}
public boolean contains(int id, int amount) {
return player.getItemAssistant().playerHasItem(id, amount);
}
public Inventory getItemContainer() {
return this;
}
public void addItem(Item item) {
player.getItemAssistant().addItem(item.getId(), item.getCount());
}
public int getItemAmount(int id) {
return player.getItemAssistant().getItemAmount(id);
}
public void replace(int item, int newItem) {
player.getItemAssistant().deleteItem(item, 1);
player.getItemAssistant().addItem(newItem, 1);
}
public int getCount(int i) {
return player.getItemAssistant().getItemAmount(i);
}
public void set(int slot, Item item) {
player.playerItems[slot] = item.getId() + 1;
player.playerItemsN[slot] = item.getCount();
update();
}
public int freeSlots() {
return player.getItemAssistant().freeSlots();
}
public void add(int id) {
player.getItemAssistant().addItem(id, 1);
}
public boolean add(int id, int amount) {
if (player.getItemAssistant().isStackable(id)) {
int allAmount = getStackedGroundAmount(id, amount, getCount(id));
if (allAmount > 0) {
GameEngine.itemHandler.createGroundItem(player, id, player.getX(), player
.getY(), allAmount, player
.getId());
player.getItemAssistant().deleteItem(id, Integer.MAX_VALUE);
player.getItemAssistant().addItem(id, Integer.MAX_VALUE);
return true;
}
}
return player.getItemAssistant().addItem(id, amount);
}
public int getStackedGroundAmount(int itemId, int addItemAmount,
int itemAmount) {
long x = 0;
x += itemAmount;
x += addItemAmount;
if (x > 2147483647) {
x -= 2147483647;
return (int) x;
}
return -1;
}
public boolean canAddItem(Item item) {
return item.getCount() <= freeSlots();
}
public void addItem(Item item, boolean drop) {
if (!drop) {
addItem(item);
} else {
GameEngine.itemHandler.createGroundItem(player, item.getId(), player.getX(), player.getY(), item.getCount(), player.playerId);
}
}
public boolean ownsItem(String itemName) {
for (int i = 0; i < GameConstants.ITEM_LIMIT; i++) {
if (GameEngine.itemHandler.itemList[i] != null) {
if (GameEngine.itemHandler.itemList[i].itemName
.equalsIgnoreCase(itemName)) {
return true;
}
}
}
return false;
}
public boolean playerHasItem(int item) {
return player.getItemAssistant().playerHasItem(item);
}
public void removeItemSlot(Item item, int slot) {
player.getItemAssistant().deleteItem(item.getId(), slot, item.getCount());
}
}
@@ -0,0 +1,105 @@
package com.rs2.game.items;
import com.rs2.GameEngine;
/**
* Represents a single item.
*
* @author Graham Edgecombe
*
*/
public class Item {
/**
* The id.
*/
private int id;
/**
* The number of items.
*/
private int count;
/**
* Creates a single item.
*
* @param id
* The id.
*/
public Item(int id) {
this(id, 1);
}
public void setCount(int count) {
this.count = count;
}
/**
* Creates a stacked item.
*
* @param id
* The id.
* @param count
* The number of items.
* @throws IllegalArgumentException
* if count is negative.
*/
public Item(int id, int count) {
if (count < 0) {
throw new IllegalArgumentException("Count cannot be negative.");
}
this.id = id;
this.count = count;
}
/**
* Creates a stacked item.
*
* @param id
* The id.
* @param count
* The number of items.
* @param timer
* The timer assigned.
* @throws IllegalArgumentException
* if count is negative.
*/
public Item(int id, int count, int timer) {
if (count < 0) {
throw new IllegalArgumentException("Count cannot be negative.");
}
this.id = id;
this.count = count;
}
/**
* Gets the item id.
*
* @return The item id.
*/
public int getId() {
return id;
}
/**
* Gets the count.
*
* @return The count.
*/
public int getCount() {
return count;
}
@Override
public String toString() {
return Item.class.getName() + " [id=" + id + ", count=" + count + "]";
}
public boolean equals(Item item) {
return item.getId() == id && count == item.getCount();
}
public ItemList getDefinition() {
return GameEngine.itemHandler.itemList[id];
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,134 @@
package com.rs2.game.items;
/**
* Aug 14, 2017 : 2:03:05 AM
* ItemConstants.java
* @author Andrew (Mr Extremez)
*/
public class ItemConstants {
public static int BANK_SIZE = 352;
public final static boolean itemRequirements = true;
public final static int HAT = 0, CAPE = 1, AMULET = 2, WEAPON = 3,
CHEST = 4, SHIELD = 5, LEGS = 7, HANDS = 9, FEET = 10, RING = 12,
ARROWS = 13, ITEM_LIMIT = 15000, MAX_ITEM_AMOUNT = Integer.MAX_VALUE;
public final static int[] COMBAT_RELATED_ITEMS = { 35, 39, 40, 41, 42, 43,
44, 50, 53, 54, 60, 64, 75, 76, 78, 88, 546, 548, 577, 581, 598,
626, 628, 630, 632, 634, 667, 687, 746, 747, 767, 772, 775, 776,
777, 778, 818, 837, 839, 841, 843, 845, 847, 849, 851, 853, 855,
857, 859, 861, 863, 864, 865, 866, 867, 868, 869, 870, 871, 872,
873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 883, 884, 885,
886, 887, 888, 889, 890, 891, 892, 893, 942, 975, 1007, 1019, 1021,
1023, 1027, 1029, 1031, 1033, 1035, 1052, 1059, 1061, 1063, 1065,
1067, 1069, 1071, 1073, 1075, 1077, 1079, 1081, 1083, 1085, 1087,
1089, 1091, 1093, 1095, 1097, 1099, 1101, 1103, 1105, 1107, 1109,
1111, 1113, 1115, 1117, 1119, 1121, 1123, 1125, 1127, 1129, 1131,
1133, 1135, 1137, 1139, 1141, 1143, 1145, 1147, 1149, 1151, 1153,
1155, 1157, 1159, 1161, 1163, 1165, 1167, 1169, 1171, 1173, 1175,
1177, 1179, 1181, 1183, 1185, 1187, 1189, 1191, 1193, 1195, 1197,
1199, 1201, 1203, 1205, 1207, 1209, 1211, 1213, 1215, 1217, 1219,
1221, 1223, 1225, 1227, 1229, 1231, 1233, 1237, 1239, 1241, 1243,
1245, 1247, 1249, 1251, 1253, 1255, 1257, 1259, 1261, 1263, 1265,
1267, 1269, 1271, 1273, 1275, 1277, 1279, 1281, 1283, 1285, 1287,
1289, 1291, 1293, 1295, 1297, 1299, 1301, 1303, 1305, 1307, 1309,
1311, 1313, 1315, 1317, 1319, 1321, 1323, 1325, 1327, 1329, 1331,
1333, 1335, 1337, 1339, 1341, 1343, 1345, 1347, 1349, 1351, 1353,
1355, 1357, 1359, 1361, 1363, 1365, 1367, 1369, 1371, 1373, 1375,
1377, 1379, 1381, 1383, 1385, 1387, 1389, 1391, 1393, 1395, 1397,
1399, 1401, 1403, 1405, 1407, 1409, 1419, 1420, 1422, 1424, 1426,
1428, 1430, 1432, 1434, 1540, 1718, 1724, 2402, 2412, 2413, 2414,
2415, 2416, 2417, 2487, 2489, 2491, 2493, 2495, 2497, 2499, 2501,
2503, 2513, 2532, 2533, 2534, 2535, 2536, 2537, 2538, 2539, 2540,
2541, 2577, 2579, 2581, 2583, 2585, 2587, 2589, 2591, 2593, 2595,
2597, 2599, 2601, 2603, 2605, 2607, 2609, 2611, 2613, 2615, 2617,
2619, 2621, 2623, 2625, 2627, 2629, 2653, 2655, 2659, 2661, 2663,
2667, 2669, 2671, 2673, 2861, 2864, 2865, 2866, 2890, 2896, 2906,
2916, 2926, 2936, 2961, 2963, 3053, 3054, 3095, 3096, 3097, 3098,
3099, 3100, 3101, 3105, 3107, 3122, 3140, 3170, 3171, 3172, 3173,
3174, 3175, 3176, 3190, 3192, 3194, 3196, 3198, 3200, 3202, 3204,
3327, 3329, 3331, 3333, 3335, 3337, 3339, 3341, 3343, 3385, 3387,
3389, 3391, 3393, 3472, 3473, 3474, 3475, 3476, 3477, 3479, 3481,
3483, 3485, 3486, 3488, 3748, 3749, 3751, 3753, 3755, 3757, 3758,
3759, 3761, 3763, 3765, 3767, 3769, 3771, 3773, 3775, 3777, 3779,
3781, 3783, 3785, 3787, 3789, 3791, 3797, 3840, 3841, 3842, 3843,
3844, 4087, 4089, 4091, 4093, 4095, 4097, 4099, 4101, 4103, 4105,
4107, 4109, 4111, 4113, 4115, 4117, 4119, 4121, 4123, 4125, 4127,
4129, 4131, 4150, 4151, 4153, 4156, 4158, 4160, 4170, 4172, 4173,
4174, 4175, 4212, 4214, 4215, 4216, 4217, 4218, 4219, 4220, 4221,
4222, 4223, 4224, 4226, 4227, 4228, 4229, 4230, 4231, 4232, 4233,
4234, 4298, 4300, 4302, 4304, 4308, 4310, 4502, 4503, 4504, 4505,
4506, 4507, 4508, 4509, 4510, 4511, 4512, 4580, 4582, 4585, 4587,
4600, 4675, 4708, 4710, 4712, 4714, 4716, 4718, 4720, 4722, 4724,
4726, 4728, 4730, 4732, 4734, 4736, 4738, 4740, 4745, 4747, 4749,
4751, 4753, 4755, 4757, 4759, 4778, 4783, 4788, 4793, 4803, 4827,
4860, 4866, 4872, 4878, 4884, 4890, 4896, 4902, 4908, 4914, 4920,
4926, 4932, 4938, 4944, 4950, 4956, 4962, 4968, 4974, 4980, 4986,
4992, 4998, 5014, 5016, 5018, 5553, 5554, 5555, 5556, 5557, 5574,
5575, 5576, 5616, 5617, 5618, 5619, 5620, 5621, 5622, 5623, 5624,
5625, 5626, 5627, 5648, 5654, 5655, 5656, 5657, 5658, 5659, 5660,
5661, 5662, 5663, 5664, 5665, 5666, 5667, 5668, 5670, 5672, 5674,
5676, 5678, 5680, 5682, 5686, 5688, 5690, 5692, 5694, 5696, 5698,
5700, 5704, 5706, 5708, 5710, 5712, 5714, 5716, 5718, 5720, 5722,
5724, 5726, 5728, 5730, 5734, 5736, 6061, 6062, 6106, 6107, 6108,
6109, 6110, 6111, 6128, 6129, 6130, 6131, 6133, 6135, 6137, 6139,
6141, 6143, 6145, 6147, 6149, 6151, 6153, 6235, 6257, 6279, 6313,
6315, 6317, 6322, 6324, 6326, 6328, 6330, 6416, 6522, 6523, 6524,
6525, 6526, 6527, 6528, 6562, 6563, 6568, 6570, 6587, 6589, 6591,
6593, 6595, 6597, 6599, 6601, 6603, 6605, 6607, 6609, 6611, 6613,
6615, 6617, 6619, 6621, 6623, 6625, 6627, 6629, 6631, 6633, 6720,
6724, 6726, 6739, 6745, 6746, 6760, 6762, 6764, 6809, 6889, 6893,
6894, 6895, 6897, 6908, 6910, 6912, 6914, 6916, 6918, 6920, 6922,
6924, 6959, 7158, 7159, 7332, 7334, 7336, 7338, 7340, 7342, 7344,
7346, 7348, 7350, 7352, 7354, 7356, 7358, 7360, 7362, 7364, 7366,
7368, 7374, 7390, 7392, 7394, 7396, 7398, 7399, 7400, 7410, 7433,
7435, 7437, 7439, 7441, 7443, 7445, 7447, 7449, 7451, 7453, 7454,
7455, 7456, 7457, 7458, 7459, 7460, 7461, 7462, 7539, 7552, 7553,
7639, 7640, 7641, 7642, 7643, 7644, 7645, 7646, 7647, 7648, 7668,
7686, 7687, 7806, 7807, 7808, 7809 };
public final static int[] ALCOHOL_RELATED_ITEMS = { 8940, 3803, 3712, 3711,
2092, 2074, 3801 };
public final static int[] ITEM_SELLABLE = { 3842, 3844, 3840, 8844, 8845,
8846, 8847, 8848, 8849, 8850, 10551, 6570, 7462, 7461, 7460, 7459,
7458, 7457, 7456, 7455, 7454, 8839, 8840, 8842, 11663, 11664, 11666,
10499, 9748, 9754, 9751, 9769, 9757, 9760, 9763, 9802, 9808, 9784,
9799, 9805, 9781, 9796, 9793, 9775, 9772, 9778, 9787, 9811, 9766,
9749, 9755, 9752, 9770, 9758, 9761, 9764, 9803, 9809, 9785, 9800,
9806, 9782, 9797, 9794, 9776, 9773, 9779, 9788, 9812, 9767, 9747,
9753, 9750, 9768, 9756, 9759, 9762, 9801, 9807, 9783, 9798, 9804,
9780, 9795, 9792, 9774, 9771, 9777, 9786, 9810, 9765, 995, 2415,
2416, 2417, 88, 1540, 2714, 432, 433, 1555, 1556, 1557, 1558, 1559,
1560, 1561, 1562, 1563, 1564, 1565, 7585, 7584, 300, 775, 776, 777,
6180, 6181, 6182, 6183, 6184, 6185, 6186, 6187, 6188, 2528, 4447,
290, 666, 667 };
public final static int[] ITEM_TRADEABLE = { 5317, 3842, 3844, 3840, 8844, 8845,
8846, 8847, 8848, 8849, 8850, 10551, 6570, 7462, 7461, 7460, 7459,
7458, 7457, 7456, 7455, 7454, 8839, 8840, 8842, 11663, 11664,
11665, 10499, 9748, 9754, 9751, 9769, 9757, 9760, 9763, 9802, 9808,
9784, 9799, 9805, 9781, 9796, 9793, 9775, 9772, 9778, 9787, 9811,
9766, 9749, 9755, 9752, 9770, 9758, 9761, 9764, 9803, 9809, 9785,
9800, 9806, 9782, 9797, 9794, 9776, 9773, 9779, 9788, 9812, 9767,
9747, 9753, 9750, 9768, 9756, 9759, 9762, 9801, 9807, 9783, 9798,
9804, 9780, 9795, 9792, 9774, 9771, 9777, 9786, 9810, 9765, 2528,
4447, 772, 6180, 6181, 6182, 6183, 6184, 6185, 6186, 6187, 6188,
775, 776, 777, 300, 88, 2415, 2416, 2417, 4214, 4215, 4216, 4217,
4218, 4219, 4220, 4221, 4222, 4223, 4224, 1555, 1556, 1557, 1558,
1559, 1560, 1561, 1562, 1563, 1564, 1565, 7585, 7584, 2714, 432,
433, 290, 5075, 5074, 5073, 5071, 5070, 7413, 6529, 4067, 2996, 1464, 666, 667,
2412, 2413, 2414, 771, 772};
public final static int[] ITEM_UNALCHABLE = { 995, 1555, 1556, 1557, 1558,
1559, 1560, 1561, 1562, 1563, 1564, 1565, 7583, 1566, 7585, 2528,
4214, 4212, 2714, 432, 433, 300, 775, 776, 777, 6180, 6181, 6182,
6183, 6184, 6185, 6186, 6187, 6188, 2528, 4447, 290, 666, 667};
public final static int[] ITEM_BANKABLE = {2528, 4447};
public final static int[] DESTROYABLE_ITEMS = {775, 776, 777, 2528, 6570, 2714, 432, 433, 300, 666};
}
@@ -0,0 +1,377 @@
package com.rs2.game.items;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import com.rs2.GameConstants;
import com.rs2.GameEngine;
public class ItemData {
public static int capes[] = { 2731, 2677, 2683, 2680, 2701, 2686, 2689,
2692, 2737, 2734, 2716, 2728, 2695, 2713, 2725, 2722, 2707, 2704,
2710, 2719, 2737, 2698, 14590, 2701, 8102, 8075, 8044, 8045, 8042,
8043, 8037, 8038, 8025, 8026, 8018, 7858, 7994, 7983, 7984, 7985,
7986, 7987, 7982, 7978, 3781, 3783, 3785, 3787, 3789, 3777, 3779,
3759, 3761, 3763, 3765, 6111, 6570, 6568, 1007, 1019, 1021, 1023,
1027, 1029, 1031, 1052, 2412, 2413, 2414, 4304, 4315, 4317, 4319,
4321, 4323, 4325, 4327, 4329, 4331, 4333, 4335, 4337, 4339, 4341,
4343, 4345, 4347, 4349, 4351, 4353, 4355, 4357, 4359, 4361, 4363,
4365, 4367, 4369, 4371, 4373, 4375, 4377, 4379, 4381, 4383, 4385,
4387, 4389, 4391, 4393, 4395, 4397, 4399, 4401, 4403, 4405, 4407,
4409, 4411, 4413, 4514, 4516, 6070, 6568, 6570, 4304, 3759, 3761,
3763, 3765, 3777, 3779, 3781, 3783, 3785, 3787, 3789 };
public static int boots[] = { 7596, 8029, 6619, 8017, 7159, 7991, 6666,
6061, 6106, 88, 89, 626, 628, 630, 632, 634, 1061, 1837, 1846,
2577, 2579, 2894, 2904, 2914, 2924, 2934, 3061, 3105, 3107, 3791,
4097, 4107, 4117, 4119, 4121, 4123, 4125, 4127, 4129, 4131, 4310,
5064, 5345, 5557, 6069, 6106, 6143, 6145, 6147, 6328, 6920, 6349,
6357, 3393 };
public static int gloves[] = { 7595, 6629, 8021, 8016, 7964, 2491, 1065,
2487, 2489, 3060, 1495, 775, 777, 778, 6708, 1059, 1063, 1065,
1580, 2487, 2489, 2491, 2902, 2912, 2922, 2932, 2942, 3060, 3799,
4095, 4105, 4115, 4308, 5556, 6068, 6110, 6149, 6151, 6153, 6922,
7454, 7455, 7456, 7457, 7458, 7459, 7460, 7461, 7462, 6330, 3391,
776 };
public static int shields[] = { 7676, 7342, 7348, 7354, 7360, 7334, 7340,
7347, 7352, 7358, 7356, 7350, 7344, 8087, 8058, 8059, 8060, 8061,
8062, 8063, 6633, 7977, 7976, 7972, 7959, 6591, 7332, 7338, 7336,
7360, 1171, 1173, 1175, 1177, 1179, 1181, 1183, 1185, 1187, 1189,
1191, 1193, 1195, 1197, 1199, 1201, 1540, 2589, 2597, 2603, 2611,
2621, 2629, 2659, 2667, 2675, 2890, 3122, 3488, 3758, 3839, 3840,
3841, 3842, 3843, 3844, 4072, 4156, 4224, 4225, 4226, 4227, 4228,
4229, 4230, 4231, 4232, 4233, 4234, 4302, 4507, 4512, 6215, 6217,
6219, 6221, 6223, 6225, 6227, 6229, 6231, 6233, 6235, 6237, 6239,
6241, 6243, 6245, 6247, 6249, 6251, 6253, 6255, 6257, 6259, 6261,
6263, 6265, 6267, 6269, 6271, 6273, 6275, 6277, 6279, 6524, 6889,
7051, 7053 };
public static int hats[] = { 2679, 1025, 2685, 4166, 2682, 2703, 2688,
2691, 2691, 2733, 2736, 2718, 2730, 2697, 2715, 2727, 2724, 2709,
2706, 2712, 2721, 2739, 2700, 2518, 2524, 2526, 7319, 7321, 7323,
7325, 7327, 1167, 8077, 8076, 8074, 4168, 1169, 8034, 8035, 8036,
8030, 6623, 8024, 8023, 8022, 8013, 1169, 7594, 7995, 7996, 7997,
7998, 7999, 8000, 8001, 7992, 7990, 7975, 7973, 7971, 7967, 7963,
6665, 6665, 7321, 6886, 6547, 6548, 2645, 2647, 2649, 4856, 4857,
4858, 4859, 4880, 4881, 4882, 4883, 4904, 4905, 4906, 4907, 4928,
4929, 4930, 4931, 4952, 4953, 4954, 4955, 4976, 4977, 4978, 4979,
4732, 4753, 4611, 6188, 6182, 4511, 4056, 4071, 4724, 2639, 2641,
2643, 2665, 6109, 5525, 5527, 5529, 5531, 5533, 5535, 5537, 5539,
5541, 5543, 5545, 5547, 5549, 5551, 74, 579, 656, 658, 660, 662,
664, 740, 1017, 1037, 1040, 1042, 1044, 1046, 1038, 1048, 1050,
1053, 1055, 1057, 1137, 1139, 1141, 1143, 1145, 1147, 1149, 1151,
1153, 1155, 1157, 1159, 1161, 1163, 1165, 1506, 1949, 2422, 2581,
2587, 2595, 2605, 2613, 2619, 2627, 2631, 2633, 2635, 2637, 2651,
2657, 2673, 2900, 2910, 2920, 2930, 2940, 2978, 2979, 2980, 2981,
2982, 2983, 2984, 2985, 2986, 2987, 2988, 2989, 2990, 2991, 2992,
2993, 2994, 2995, 3057, 3385, 3486, 3748, 3749, 3751, 3753, 3797,
4041, 4042, 4071, 4089, 3755, 4099, 4109, 4164, 4302, 4506, 4511,
4513, 4515, 4551, 4567, 4708, 4716, 4724, 4745, 4753, 4857, 4858,
4859, 4880, 4881, 4882, 4883, 4904, 4905, 4906, 4907, 4952, 4953,
4954, 4955, 4976, 4977, 4978, 4979, 5013, 5014, 5554, 5574, 6109,
6128, 6131, 6137, 6182, 6188, 6335, 6337, 6339, 6345, 6355, 6365,
6375, 6382, 6392, 6400, 6918, 6656, 2581, 7539, 7394, 7396, 7534,
5574, 6885, 6858, 6860, 6862, 6856, 6326, 6128, 6137, 7400, 7323,
7325, 7327, 7003, 4168, 7112, 7124, 7130, 7136 };
public static int amulets[] = { 1654, 1656, 1658, 1660, 1662, 1664, 8081,
8033, 7968, 6585, 86, 87, 295, 421, 552, 589, 1478, 1692, 1694,
1696, 1698, 1700, 1702, 1704, 1706, 1708, 1710, 1712, 1725, 1727,
1729, 1731, 4021, 4081, 4250, 4677, 6040, 6041, 6208, 1718, 1722,
6859, 6863, 6857, 3853, 3855, 3857, 3859, 3861, 3863, 3865, 3867,
1718, 4306, 1702 };
public static int arrows[] = { 11212, 8052, 9211, 9010, 9209, 9208, 9207,
9206, 9205, 9203, 9301, 8065, 7919, 7906, 7988, 7989, 78, 598, 877,
878, 879, 880, 881, 882, 883, 884, 885, 886, 887, 888, 889, 890,
891, 892, 893, 942, 2532, 2533, 2534, 2535, 2536, 2537, 2538, 2539,
2540, 2541, 2866, 4160, 4172, 4173, 4174, 4175, 4740, 5616, 5617,
5618, 5619, 5620, 5621, 5622, 5623, 5624, 5625, 5626, 5627, 6061,
6062};
public static int rings[] = { 8082, 773, 1635, 1637, 1639, 1641, 1643,
1645, 2550, 2552, 2554, 2556, 2558, 2560, 2562, 2564, 2566, 2568,
2570, 2572, 4202, 4657, 6465, 6737, 6731, 6735, 6583, 6733 };
public static int body[] = { 7608, 2520, 430, 7362, 7364, 636, 638, 640,
642, 644, 8064, 426, 430, 1005, 1757, 7592, 8031, 8027, 6617, 8019,
8014, 8002, 7376, 544, 7372, 7370, 577, 7974, 7970, 7965, 7961,
7960, 3793, 3775, 3773, 3771, 3769, 3767, 6139, 1135, 2499, 2501,
1035, 540, 5553, 4757, 1833, 6388, 6384, 4111, 4101, 4091, 6186,
6184, 6180, 3058, 4509, 4504, 4069, 4728, 4736, 4712, 6107, 2661,
3140, 1101, 1103, 1105, 1107, 1109, 1111, 1113, 1115, 1117, 1119,
1121, 1123, 1125, 1127, 1129, 1131, 1133, 2583, 2591, 2599, 2607,
2615, 2623, 2653, 2669, 3481, 4712, 4720, 4728, 4749, 4892, 4893,
4894, 4895, 4916, 4917, 4918, 4919, 4964, 4965, 4966, 4967, 6107,
6133, 6322, 6322, 6129, 75, 6916, 6916, 4111, 6654, 6654, 75, 7399, 7374, 5575, 2503, 6341, 6351, 3387, 5030, 5032, 5034, 5030,
5032, 5034,7390 , 7392, 546, 581 };
public static int legs[] = { 7609, 2522, 7378, 7380, 7382, 7368, 7366,
7388, 646, 648, 650, 652, 654, 428, 1097, 1095, 7593, 8032, 8028,
6625, 8020, 8015, 7384, 7969, 7966, 7962, 6141, 538, 1033, 5555,
4759, 6386, 6390, 2497, 2495, 2493, 1099, 4113, 4103, 4093, 6924,
6187, 6185, 6181, 3059, 4510, 4505, 4070, 6108, 542, 548, 1011,
1013, 1015, 1067, 1069, 1071, 1073, 1075, 1077, 1079, 1081, 1083,
1085, 1087, 1089, 1091, 1093, 2585, 2593, 2601, 2609, 2617, 2625,
2655, 2663, 2671, 3059, 3389, 3472, 3473, 3474, 3475, 3476, 3477,
3478, 3479, 3480, 3483, 3485, 3795, 4087, 4585, 4712, 4714, 4722,
4730, 4738, 4751, 4759, 4874, 4875, 4876, 4877, 4898, 4899, 4900,
4901, 4922, 4923, 4924, 4925, 4946, 4947, 4948, 4949, 4970, 4971,
4972, 4973, 4994, 4995, 4996, 4997, 5048, 5050, 5052, 5576, 6107,
6130, 6187, 6390, 6386, 6390, 6394, 6396, 6402, 6404, 6135, 6809, 6916, 4091,
4111, 6655, 6654, 7398, 7398, 7386, 6324, 6343, 6353, 6363, 6373, 3387, 5036,
5038, 5040, 5042, 5044, 5046, 5050, 5052, 4300, 1835, 7116, 7126, 6752,
7132, 7138 };
public static int platebody[] = { 10338, 7608, 2520, 430, 636, 638, 640,
642, 644, 426, 430, 8031, 8027, 6617, 8019, 8014, 8002, 544, 577,
7974, 7970, 7965, 7961, 7960, 3793, 3773, 3775, 3771, 3769, 3767,
6139, 1035, 540, 5553, 4757, 1833, 1835, 6388, 6384, 4111, 4101,
4868, 4869, 4870, 4871, 4892, 4893, 4894, 4895, 4916, 4917, 4918,
4919, 4940, 4941, 4942, 4943, 4964, 4965, 4966, 4967, 4988, 4989,
4990, 0x2f9a0eb, 6186, 6184, 6180, 3058, 4509, 4504, 4069, 4728,
4736, 4712, 6107, 2661, 3140, 1115, 1117, 1119, 1121, 1123, 1125,
1127, 2583, 2591, 2599, 2607, 2615, 6322, 2623, 2653, 2669, 3481,
4720, 4728, 4749, 2661, 6129, 6916, 4091, 6654, 6133, 75, 7399, 5575, 6341, 6351, 7390, 7392, 3387, 5024, 5030, 5032, 5034, 7392, 6786, 6788 };
/* Fullbody is an item that covers your arms. */
private static String[] fullbody = {
"top", "shirt", "platebody", "Wizard robe (g)", "Wizard robe (t)",
"Ahrims robetop", "Karils leathertop", "brassard", "Robe top",
"robetop", "platebody (t)", "platebody (g)", "chestplate", "torso",
"hauberk", "Dragon chainbody", "gown", "Shade robe", "Wizard robe",
"Druid's robe", "Black robe", "Fremennik robe", "Robe of elidinis",
"tunic", "blouse", "Wizard robe(g)", "Wizard robe(t)"
};
/* Fullhat covers your head but not your beard. */
private static String[] fullhat = { "med helm", "coif", "Dharok's helm",
"hood", "Initiate helm", "Coif", "Helm of neitiznot",
"Armadyl helmet", "Berserker helm", "Archer helm", "Farseer helm",
"Warrior helm", "Void"};
/* Fullmask covers your entire head. */
private static String[] fullmask = { "full helm(t)", "full helm(g)", "full helm", "mask", "Verac's helm",
"Guthan's helm", "Karil's coif", "mask", "Torag's helm", "Void", "helmet",
"sallet", "Facemask", "Bearhead"};
public static boolean isFullBody(int itemId) {
String weapon = getItemName(itemId);
if (weapon == null) {
return false;
}
for (String element : fullbody) {
if (weapon.endsWith(element)) {
return true;
}
}
return false;
}
public static boolean isFullHelm(int itemId) {
String weapon = getItemName(itemId);
if (weapon == null) {
return false;
}
for (String element : fullhat) {
if (weapon.endsWith(element)) {
return true;
}
}
return false;
}
public static boolean isFullMask(int itemId) {
String weapon = getItemName(itemId);
if (weapon == null) {
return false;
}
for (String element : fullmask) {
if (weapon.endsWith(element)) {
return true;
}
}
return false;
}
public static String getItemName(int id) {
for (ItemList element : GameEngine.itemHandler.itemList) {
if (element != null) {
if (element.itemId == id) {
return element.itemName;
}
}
}
return null;
}
public static boolean[] itemStackable = new boolean[GameConstants.ITEM_LIMIT];
public static boolean[] itemIsNote = new boolean[GameConstants.ITEM_LIMIT];
public static int[] targetSlots = new int[GameConstants.ITEM_LIMIT];
static {
int counter = 0;
int c;
try {
FileInputStream dataIn = new FileInputStream(new File("./data/data/stackable.dat"));
while ((c = dataIn.read()) != -1) {
if (c == 0) {
itemStackable[counter] = false;
itemStackable[291] = true;
} else {
itemStackable[counter] = true;
}
counter++;
}
dataIn.close();
} catch (IOException e) {
System.out.println("Critical error while loading stackabledata! Trace:");
e.printStackTrace();
}
counter = 0;
try {
FileInputStream dataIn = new FileInputStream(new File("./data/data/notes.dat"));
while ((c = dataIn.read()) != -1) {
itemIsNote[counter] = c == 0;
counter++;
}
dataIn.close();
} catch (IOException e) {
System.out.println("Critical error while loading notedata! Trace:");
e.printStackTrace();
}
counter = 0;
try {
FileInputStream dataIn = new FileInputStream(new File("./data/data/equipment.dat"));
while ((c = dataIn.read()) != -1) {
int slot;
// rebind item equip slot here
switch (counter) {
// Legs
case 6181:
case 428:
case 538:
case 6343:
case 6353:
case 6363:
case 6396:
case 6373:
case 6404:
case 5044:
case 5046:
case 5050:
case 5052:
case 5040:
case 5038:
case 6752:
case 5048:
case 5036:
case 5042:
case 4300:
case 1835:
case 7116:
case 7126:
case 7132:
case 7138:
case 548:
case 6185:
slot = ItemConstants.LEGS;
break;
// Hats
case 4166:
case 1167:
case 5525:
case 4168:
case 4502:
case 1037:
case 1025:
case 7112:
case 7124:
case 7130:
case 7136:
case 4611:
case 5527:
case 5529:
case 5531:
case 5533:
case 5535:
case 5537:
case 5539:
case 5541:
case 5543:
case 5545:
case 5547:
slot = ItemConstants.HAT;
break;
// Cape
case 4304:
case 3759:
case 3761:
case 3763:
case 3765:
case 3777:
case 3779:
case 3781:
case 3783:
case 3785:
case 3787:
case 3789:
case 4514:
case 4516:
case 6111:
slot = ItemConstants.CAPE;
break;
// Shield
case 7051:
case 7053:
slot = ItemConstants.SHIELD;
break;
// Chest
case 577:
case 426:
case 540:
case 430:
case 6786:
case 581:
case 5024:
case 5030:
case 1757:
case 5034:
case 5032:
case 3793:
case 1005:
case 546:
case 6402:
case 6788:
case 6184:
case 7390:
case 7392:
case 6186:
slot = ItemConstants.CHEST;
break;
// Amulet
case 3853:
case 3855:
case 3857:
case 3859:
case 3861:
case 3863:
case 1718:
case 3865:
case 4306:
case 3867:
case 1702:
slot = ItemConstants.AMULET;
break;
// Hands
case 776:
slot = ItemConstants.HANDS;
break;
default:
slot = c;
}
targetSlots[counter] = slot;
counter++;
}
dataIn.close();
} catch (IOException e) {
System.out.println("Critical error while loading equipment data! Trace:");
e.printStackTrace();
}
}
}
@@ -0,0 +1,351 @@
package com.rs2.game.items;
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import org.apache.commons.lang3.ArrayUtils;
import org.json.JSONObject;
public class ItemDefinition {
public static ItemDefinition getDefs()[] {
return definitions;
}
public ItemDefinition() {
name = null;
itemDescription = null;
shopValue = 0;
lowAlch = 0;
highAlch = 0;
isStackable = false;
isNoteable = false;
weight = 0;
bonuses = null;
stand = -1;
walk = -1;
run = -1;
turn90left = -1;
turn90right = -1;
turn180 = -1;
attack = -1;
block = -1;
id = -1;
}
public ItemDefinition(String iname, String idescription, int ishopvalue, int ilowalch, int ihighalch, boolean iisstackable, boolean iisnoteable,
int iweight, double[] ibonuses, int istand, int iwalk, int irun, int iturn90left, int iturn90right, int iturn180,
int iattack, int iblock, int iid) {
this.name = iname;
this.itemDescription = idescription;
this.shopValue = ishopvalue;
this.lowAlch = ilowalch;
this.highAlch = ihighalch;
this.isStackable = iisstackable;
this.isNoteable = iisnoteable;
this.weight = iweight;
this.bonuses = ibonuses;
this.stand = istand;
this.walk = iwalk;
this.run = irun;
this.turn90left = iturn90left;
this.turn90right = iturn90right;
this.turn180 = iturn180;
this.attack = iattack;
this.block = iblock;
this.id = iid;
}
private int id;
public int getId() {
return id;
}
/**
* Reads the definitions from the file.
*/
public static void read() {
ArrayList<ItemDefinition> definitionsAL = new ArrayList<>();
try (BufferedReader br = new BufferedReader(new FileReader("./data/data/itemdef.json"))) {
String line;
while ((line = br.readLine()) != null) {
definitionsAL.add(fromString(line));
}
} catch (Exception e) {
e.printStackTrace();
}
definitions = Arrays.copyOf(definitionsAL.toArray(), definitionsAL.size(), ItemDefinition[].class);
}
/**
* The item definition cache.
*/
public static ItemDefinition[] definitions;
/**
* The total items read from the definitions.
*/
public static int total;
/**
* The item name.
*/
public String name;
/**
* Returns the name of the item.
* @return
*/
public static String getName(int id) {
return definitions[id].name;
}
/**
* The item description.
*/
public String itemDescription;
/**
* Returns the description of an item.
*/
public static String getDescription(int id) {
return definitions[id].itemDescription;
}
/**
* The item price.
*/
public int shopValue;
/**
* Returns the price of an item.
*/
public static int getPrice(int id) {
return definitions[id].shopValue;
}
/**
* The low alch value.
*/
public int lowAlch;
/**
* Returns the low alch value of an item.
*/
public static int getLow(int id) {
return definitions[id].lowAlch;
}
/**
* The high alch value.
*/
public int highAlch;
/**
* Returns the high alch value of an item.
*/
public static int getHigh(int id) {
return definitions[id].highAlch;
}
/**
* Can the item be stacked?
*/
public boolean isStackable;
/**
* Returns whether or not the item can be stacked.
*/
public static boolean canStack(int id) {
return definitions[id].isStackable;
}
/**
* Can the item be noted?
*/
public boolean isNoteable;
/**
* Returns whether or not the item can be noted.
*/
public static boolean canNote(int id) {
return definitions[id].isNoteable;
}
/**
* The weight of an item.
*/
public double weight;
/**
* Returns the weight of an item.
*/
public static double getWeight(int id) {
if (id >= 0 && id < definitions.length)
return definitions[id].weight;
System.out.println("WARNING: id " + id + " doesn't have a definition! 2.147kg is used as weight.");
return 2.147;
}
/**
* The bonuses of an item.
*/
public double[] bonuses;
/**
* Returns the array of bonuses for an item.
*/
public double[] getBonuses(int id) {
return definitions[id].bonuses;
}
/**
* The stand animation of an item.
*/
public int stand;
/**
* Returns the stand animation of an item.
*/
public static int getStand(int id) {
return definitions[id].stand;
}
/**
* The walk animation of an item.
*/
public int walk;
/**
* Returns the walk animation of an item.
*/
public static int getWalk(int id) {
return definitions[id].walk;
}
/**
* The run animation of an item.
*/
public int run;
/**
* Returns the run animation of an item.
*/
public static int getRun(int id) {
return definitions[id].run;
}
/**
* The 90-degree left turn animation of an item.
*/
public int turn90left;
/**
* Returns the 90-degree left turn animation of an item.
*/
public static int get90left(int id) {
return definitions[id].turn90left;
}
/**
* The 90-degree right turn animation of an item.
*/
public int turn90right;
/**
* Returns the 90-degree right turn animation of an item.
*/
public static int get90right(int id) {
return definitions[id].turn90right;
}
/**
* The 180-degree turn animation of an item.
*/
public int turn180;
/**
* Returns the 180-degree turn animation of an item.
*/
public static int get180(int id) {
return definitions[id].turn180;
}
/**
* The attack animation of an item.
*/
public int attack;
/**
* Returns the attack animation of an item
*/
public static int getAttack(int id) {
return definitions[id].attack;
}
/**
* The block animation of an item.
*/
public int block;
/**
* Returns the block animation of an item
*/
public static int getBlock(int id) {
return definitions[id].block;
}
public static ItemDefinition fromString(String idString) {
JSONObject jobj = new JSONObject(idString);
Object[] bonusObjArr = jobj.getJSONArray("bonuses").toList().toArray();
double[] pbonuses = ArrayUtils.toPrimitive(Arrays.copyOf(bonusObjArr, bonusObjArr.length, Double[].class));
return new ItemDefinition(jobj.getString("name"),
jobj.getString("itemDescription"),
jobj.getInt("shopValue"),
jobj.getInt("lowAlch"),
jobj.getInt("highAlch"),
jobj.getBoolean("isStackable"),
jobj.getBoolean("isNoteable"),
jobj.getInt("weight"),
pbonuses,
jobj.getInt("stand"),
jobj.getInt("walk"),
jobj.getInt("run"),
jobj.getInt("turn90left"),
jobj.getInt("turn90right"),
jobj.getInt("turn180"),
jobj.getInt("attack"),
jobj.getInt("block"),
jobj.getInt("id"));
}
@Override
public String toString() {
return "{" +
"name:\"" + name + '\"' +
", itemDescription:\"" + itemDescription + '\"' +
", shopValue:" + shopValue +
", lowAlch:" + lowAlch +
", highAlch:" + highAlch +
", isStackable:" + isStackable +
", isNoteable:" + isNoteable +
", weight:" + weight +
", bonuses:" + Arrays.toString(bonuses) +
", stand:" + stand +
", walk:" + walk +
", run:" + run +
", turn90left:" + turn90left +
", turn90right:" + turn90right +
", turn180:" + turn180 +
", attack:" + attack +
", block:" + block +
", id:" + id +
'}';
}
}
@@ -0,0 +1,16 @@
package com.rs2.game.items;
public class ItemList {
public int itemId;
public String itemName;
public String itemDescription;
public double ShopValue;
public double LowAlch;
public double HighAlch;
public int[] Bonuses = new int[100];
public ItemList(int _itemId) {
itemId = _itemId;
}
}
@@ -0,0 +1,406 @@
package com.rs2.game.items;
import com.rs2.game.content.skills.cooking.Cooking;
import com.rs2.game.content.skills.crafting.BattleStaffs;
import com.rs2.game.content.skills.crafting.GemCutting;
import com.rs2.game.content.skills.crafting.JewelryMaking;
import com.rs2.game.content.skills.crafting.LeatherMaking;
import com.rs2.game.content.skills.crafting.SoftClay;
import com.rs2.game.content.skills.farming.Farming;
import com.rs2.game.content.skills.firemaking.Firemaking;
import com.rs2.game.content.skills.fletching.ArrowMaking;
import com.rs2.game.content.skills.fletching.LogCutting;
import com.rs2.game.content.skills.fletching.LogCuttingInterface;
import com.rs2.game.content.skills.fletching.Stringing;
import com.rs2.game.content.skills.herblore.GrindingAction;
import com.rs2.game.content.skills.herblore.Herblore;
import com.rs2.game.content.skills.prayer.Ectofuntus;
import com.rs2.game.content.skills.prayer.Ectofuntus.EctofuntusData;
import com.rs2.game.content.skills.runecrafting.Tiaras;
import com.rs2.game.items.impl.Dye;
import com.rs2.game.items.impl.GodPages;
import com.rs2.game.items.impl.WeaponPoison;
import com.rs2.game.npcs.impl.MilkCow;
import com.rs2.game.objects.impl.CrystalChest;
import com.rs2.game.objects.impl.FlourMill;
import com.rs2.game.objects.impl.Webs;
import com.rs2.game.players.Player;
import com.rs2.util.Misc;
/**
* @author Ryan / Lmctruck30
*/
public class UseItem {
public static void itemOnObject(Player c, int objectID, int objectX, int objectY, int itemId) {
final int goodPosXType1 = objectX - 5;
final int goodPosXType2 = objectX + 5;
final int goodPosYType1 = objectY - 5;
final int goodPosYType2 = objectY + 5;
if (c.absX >= goodPosXType1 && c.absX <= goodPosXType2 && c.absY >= goodPosYType1 && c.absY <= goodPosYType2) {
c.turnPlayerTo(objectX, objectY);
} else {
c.getPlayerAssistant().playerWalk(objectX, objectY);
}
if (!c.getItemAssistant().playerHasItem(itemId, 1)) {
return;
}
if (itemId == Ectofuntus.BUCKET) {
Ectofuntus.fillBucketWithSlime(c, objectID);
}
if (Farming.prepareCrop(c, itemId, objectID, objectX, objectY)) {
return;
}
for (final EctofuntusData ectofuntus : EctofuntusData.values()) {
if (itemId == ectofuntus.getBoneId()) {
Ectofuntus.boneOnLoader(c, objectID, itemId);
}
}
if (Tiaras.bindTiara(c, itemId, objectID)) {
return;
}
switch (objectID) {
case 733:
if (itemId == 946) {
Webs.slashWeb(c, objectID, objectX, objectY);
}
break;
case 8689:
if (c.milking == false) {
MilkCow.milk(c);
}
break;
case 2783:
c.getSmithingInt().showSmithInterface(itemId);
break;
case 2782:
if (c.doricQuest >= 3) {
c.getSmithingInt().showSmithInterface(itemId);
} else {
c.getPacketSender().sendMessage(
"You need to beat dorics quest to use his anvils");
}
break;
case 879:
case 12279:
case 14868:
if (itemId == SoftClay.CLAY) {
SoftClay.makeClay(c);
}
break;
case 2714:
FlourMill.grainOnHopper(c, objectID, itemId);
break;
case 172:
if (itemId == CrystalChest.KEY) {
CrystalChest.searchChest(c, objectID, objectX, objectY);
}
break;
case 364:
if (itemId == 1919) {
c.getItemAssistant().deleteItem(1919, 1);
c.getItemAssistant().addItem(1917, 1);
c.getPacketSender().sendMessage(
"You refill your beer glass.");
}
break;
default:
if (c.playerRights == 3) {
Misc.println("Player At Object id: " + objectID + " objectX: "
+ objectX + " objectY: " + objectY + " with Item id: "
+ itemId);
}
break;
}
}
public static void itemOnItem(Player player, int itemUsed, int useWith) {
LogCuttingInterface.handleItemOnItem(player, itemUsed, useWith);
ArrowMaking.makeArrow(player, itemUsed, useWith);
Stringing.StringBow(player, itemUsed, useWith);
WeaponPoison.execute(player, itemUsed, useWith);
player.getGlassBlowing().ItemOnItem(itemUsed, useWith);
//CapeDye.execute(c, itemUsed, useWith);
if (ItemAssistant.getItemName(itemUsed).contains("(")
&& ItemAssistant.getItemName(useWith).contains("(")) {
player.getPotMixing().mixPotion2(itemUsed, useWith);
}
BattleStaffs.makeBattleStaff(player, itemUsed, useWith);
GrindingAction.init(player, itemUsed, useWith);
Dye.dyeItem(player, itemUsed, useWith);
for (final int[] element : Dye.MAIL_DATA) {
if (itemUsed == element[0] && useWith == element[1] || itemUsed == element[1] && useWith == element[0]) {
player.getItemAssistant().deleteItem(element[0], 1);
player.getItemAssistant().deleteItem(element[1], 1);
player.getItemAssistant().addItem(element[2], 1);
}
}
GodPages.itemOnItemHandle(player, useWith, itemUsed);
if (Herblore.isIngredient(itemUsed) || Herblore.isIngredient(useWith)) {
Herblore.setupPotion(player, itemUsed, useWith);
}
if (itemUsed == 6703 || useWith == 6703) {
player.getPTS().handlePotato(itemUsed, useWith);
}
if (itemUsed == 1755 || useWith == 1755) {
GemCutting.cutGem(player, itemUsed, useWith);
}
if (itemUsed == 1759 || useWith == 1759) {
JewelryMaking.stringAmulet(player, itemUsed, useWith);
}
if (itemUsed == 946 || useWith == 2862) {
LogCutting.makeShafts(player);
}
if (itemUsed == 2862 || useWith == 946) {
LogCutting.makeShafts(player);
}
if (itemUsed == 314 || useWith == 2864) {
LogCutting.flightedArrow(player);
}
if (itemUsed == 2864 || useWith == 314) {
LogCutting.flightedArrow(player);
}
if (itemUsed == 2861 || useWith == 2865) {
LogCutting.ogreArrow(player);
}
if (itemUsed == 2865 || useWith == 2861) {
LogCutting.ogreArrow(player);
}
if (itemUsed == 2859 || useWith == 1755) {
LogCutting.wolfBoneArrow(player);
}
if (itemUsed == 1755 || useWith == 2859) {
LogCutting.wolfBoneArrow(player);
}
if (itemUsed == 771 && useWith == 946
&& player.playerLevel[player.playerCrafting] > 30) {
player.getItemAssistant().deleteItem(771, 1);
player.getItemAssistant().addItem(772, 1);
} else if (player.playerLevel[player.playerCrafting] < 31 && itemUsed == 771
&& useWith == 946) {
player.getPacketSender().sendMessage(
"You need 31 crafting to make this.");
}
if (itemUsed == 946 && useWith == 771
&& player.playerLevel[player.playerCrafting] > 30) {
player.getItemAssistant().deleteItem(771, 1);
player.getItemAssistant().addItem(772, 1);
} else if (player.playerLevel[player.playerCrafting] < 31 && itemUsed == 946
&& useWith == 771) {
player.getPacketSender().sendMessage(
"You need 31 crafting to make this.");
}
if (useWith == 7051 && itemUsed == 590 || itemUsed == 590
&& useWith == 7051) {
player.getItemAssistant().deleteItem(7051, 1);
player.getItemAssistant().addItem(7053, 1);
}
int firemakingItems[] = {590, 7329, 7330, 7331};
for (int i = 0; i < firemakingItems.length; i++) {
if (itemUsed == firemakingItems[i] || useWith == firemakingItems[i] && player.isFiremaking == false) {
Firemaking.attemptFire(player, itemUsed, useWith, player.absX, player.absY, false);
} else if (itemUsed == firemakingItems[i] || useWith == firemakingItems[i] && player.isFiremaking) {
player.getPacketSender().sendMessage("You can't do that, you are already firemaking.");
}
}
if (itemUsed == 1733 || useWith == 1733) {
LeatherMaking.craftLeatherDialogue(player, itemUsed, useWith);
}
if (itemUsed == 1573 && useWith == 327 || itemUsed == 327 && useWith == 1573) {
player.getItemAssistant().deleteItem(1573, 1);
player.getItemAssistant().deleteItem(327, 1);
player.getItemAssistant().addItem(1552, 1);
}
if (itemUsed == 38 && useWith == 590 || useWith == 38
&& itemUsed == 590) {//
player.getItemAssistant().addItem(32, 1);
player.getItemAssistant().deleteItem(38, 1);
}
if (itemUsed == 36 && useWith == 590 || useWith == 36
&& itemUsed == 590) {
player.getItemAssistant().addItem(33, 1);
player.getItemAssistant().deleteItem(36, 1);
}
if (itemUsed == 596 && useWith == 590 || useWith == 596
&& itemUsed == 590) {
player.getItemAssistant().addItem(594, 1);
player.getItemAssistant().deleteItem(596, 1);
}
if (itemUsed == 4537 && useWith == 590 || useWith == 4537
&& itemUsed == 590) {
player.getItemAssistant().addItem(4539, 1);
player.getItemAssistant().deleteItem(4537, 1);
}
if (itemUsed == 4548 && useWith == 590 || useWith == 4548
&& itemUsed == 590) {
player.getItemAssistant().addItem(4550, 1);
player.getItemAssistant().deleteItem(4548, 1);
}
if (itemUsed == 1095 && useWith == 2370 || itemUsed == 2370
&& useWith == 1095 && player.playerLevel[player.playerCrafting] > 43) {// chaps
player.getItemAssistant().deleteItem(2370, 1);
player.getItemAssistant().deleteItem(1095, 1);
player.getItemAssistant().addItem(1097, 1);
player.getPlayerAssistant().addSkillXP(42, player.playerCrafting);
} else if (itemUsed == 1095 && useWith == 2370 || itemUsed == 2370 && useWith == 1095 && player.playerLevel[player.playerCrafting] < 44) {
player.getPacketSender().sendMessage("You need 44 crafting to make this.");
}
if (itemUsed == 946 && useWith == 1963 || itemUsed == 1963 && useWith == 946) {
player.getItemAssistant().deleteItem(1963, 1);
player.getItemAssistant().addItem(3162, 1);
player.getPacketSender().sendMessage("You slice your banana.");
}
if (itemUsed == 946 && useWith == 1973 || itemUsed == 1973 && useWith == 946) {
player.getItemAssistant().deleteItem(1973, 1);
player.getItemAssistant().addItem(1975, 1);
player.getPacketSender().sendMessage("You slice your chocolate bar.");
}
if (itemUsed == 1129 && useWith == 2370 || itemUsed == 2370 && useWith == 1129 && player.playerLevel[player.playerCrafting] > 40) {// body
player.getItemAssistant().deleteItem(2370, 1);
player.getItemAssistant().deleteItem(1129, 1);
player.getItemAssistant().addItem(1133, 1);
player.getPlayerAssistant().addSkillXP(40, player.playerCrafting);
} else if (itemUsed == 1129 && useWith == 2370 || itemUsed == 2370 && useWith == 1129 && player.playerLevel[player.playerCrafting] < 41) {
player.getPacketSender().sendMessage("You need 41 crafting to make this.");
}
if (itemUsed == 4593 && useWith == 4591 || useWith == 4591 && itemUsed == 4593) {
player.getItemAssistant().deleteItem(4591, 1);
player.getItemAssistant().deleteItem(4593, 1);
player.getItemAssistant().addItem(4611, 1);
}
if (itemUsed == 985 && useWith == 987 || itemUsed == 987 && useWith == 985) {
player.getItemAssistant().deleteItem(985, 1);
player.getItemAssistant().deleteItem(987, 1);
player.getItemAssistant().addItem(989, 1);
}
if (itemUsed == 2313 && useWith == 1953 || itemUsed == 1953 && useWith == 2313) {
player.getItemAssistant().deleteItem(2313, 1);
player.getItemAssistant().deleteItem(1953, 1);
player.getItemAssistant().addItem(2315, 1);
}
/**
* Pizza Creation
*/
if (itemUsed == 1982 && useWith == 2283 || itemUsed == 2283
&& useWith == 1982) {
Cooking.pastryCreation(player, 1982, 2283, 2285, "");
}
if (itemUsed == 2285 && useWith == 1985 || itemUsed == 1985
&& useWith == 2285) {
Cooking.pastryCreation(player, 2285, 1985, 2287, "");
}
if (itemUsed == 2140 && useWith == 2289 || itemUsed == 2289
&& useWith == 2140) {
Cooking.cookingAddon(player, 2140, 2289, 2293, 45, 26);
}
if (itemUsed == 319 && useWith == 2289 || itemUsed == 2289
&& useWith == 319) {
Cooking.cookingAddon(player, 319, 2289, 2297, 55, 39);
}
if (itemUsed == 2116 && useWith == 2289 || itemUsed == 2289
&& useWith == 2116) {
Cooking.cookingAddon(player, 2116, 2289, 2301, 65, 45);
}
/**
* Pie Making
*/
if (itemUsed == 2313 && useWith == 1953 || itemUsed == 1953
&& useWith == 2313) {
Cooking.pastryCreation(player, 2313, 1953, 2315,
"You put the pastry dough into the pie dish to make a pie shell.");
}
if (itemUsed == 2315 && useWith == 1955 || itemUsed == 1955
&& useWith == 2315) {
Cooking.pastryCreation(player, 2315, 1955, 2317,
"You fill the pie with cooking apple.");
}
if (itemUsed == 2315 && useWith == 5504 || itemUsed == 5504
&& useWith == 2315) {
Cooking.pastryCreation(player, 2315, 5504, 7212, "");
}
if (itemUsed == 7212 && useWith == 5982 || itemUsed == 5982
&& useWith == 7212) {
Cooking.pastryCreation(player, 7212, 5982, 7214, "");
}
if (itemUsed == 1955 && useWith == 7214 || itemUsed == 7214
&& useWith == 1955) {
Cooking.pastryCreation(player, 1955, 7214, 7216, "");
}
if (itemUsed == 2315 && useWith == 1951 || itemUsed == 1951 && useWith == 2315) {
Cooking.pastryCreation(player, 1951, 2315, 2321, "");
}
/**
* Pitta/ Ugthanki Kebab
*/
if (itemUsed == 1865 && useWith == 1881 || itemUsed == 1881
&& useWith == 1865) {
Cooking.cookingAddon(player, 1865, 1881, 1883, 0, 40);
}
if (player.tutorialProgress < 36) {
if (itemUsed == 1929 && useWith == 1933 || itemUsed == 1933 && useWith == 1929) {
player.getItemAssistant().deleteItem(1929, 1);
player.getItemAssistant().deleteItem(1933, 1);
player.getItemAssistant().addItem(2307, 1);
player.getItemAssistant().addItem(1925, 1);
player.getItemAssistant().addItem(1931, 1);
if (player.tutorialProgress == 8) {
player.getDialogueHandler().sendDialogues(3026, -1);
}
}
}
if (player.tutorialProgress > 35) {
if (itemUsed == 1929 && useWith == 1933 || itemUsed == 1933 && useWith == 1929) {
player.getDialogueHandler().sendDialogues(3204, -1);
}
}
if (player.tutorialProgress > 35) {
if (itemUsed == 1933 && useWith == 1937 || itemUsed == 1937 && useWith == 1933) {
player.getDialogueHandler().sendDialogues(3205, -1);
}
}
if (itemUsed == 1987 && useWith == 1937 || itemUsed == 1937
&& useWith == 1987) {
if (player.playerLevel[player.playerCooking] >= 35) {
player.getItemAssistant().addItem(1993, 1);
player.getItemAssistant().deleteItem(1937, 1);
player.getItemAssistant().deleteItem(1987, 1);
player.getPlayerAssistant().addSkillXP(200, player.playerCooking);
} else {
player.getPacketSender().sendMessage(
"You need grapes and a jug of water to make wine.");
}
}
switch (itemUsed) {
default:
if (player.playerRights == 3) {
Misc.println("Player used Item id: " + itemUsed
+ " with Item id: " + useWith);
}
break;
}
}
public static void itemOnNpc(final Player c, final int itemId, final int npcId, final int slot) {
switch (itemId) {
default:
if (c.playerRights == 3) {
Misc.println("Player used Item id: " + itemId
+ " with Npc id: " + npcId + " With Slot : " + slot);
}
break;
}
}
}
@@ -0,0 +1,71 @@
package com.rs2.game.items;
import com.rs2.game.players.Player;
/**
* @author somedude, credits to Galkon for item weights
*/
public class Weight extends ItemDefinition {
/**
* Calculates the weight when doing actions
*
* @param c
* @param item
* @param action
* - deleteitem, additem, equip, unequip.
*/
public static void calcWeight(Player c, int item, String action) {
if (action.equalsIgnoreCase("deleteitem")) {
if (getWeight(item) > 99.20) {
c.weight -= getWeight(item) / 100;
if (c.weight < 0) {
c.weight = 0.0;
}
c.getPacketSender().writeWeight((int) c.weight);
return;
}
c.weight -= getWeight(item) / 10;
if (c.weight < 0) {
c.weight = 0.0;
}
c.getPacketSender().writeWeight((int) c.weight);
} else if (action.equalsIgnoreCase("additem")) {
if (getWeight(item) > 99.20) {
c.weight += getWeight(item) / 100;
c.getPacketSender().writeWeight((int) c.weight);
return;
}
c.weight += getWeight(item) / 10;
c.getPacketSender().writeWeight((int) c.weight);
}
}
/**
* Updates the weight for inventory and equipment.
*
* @param player
*/
public static void updateWeight(Player player) {
if (player != null) {
player.weight = 0;
// Inventory items
for (int playerItem : player.playerItems) {
if (playerItem > -1) {// inventory
calcWeight(player, playerItem, "addItem");
}
}
// Equiped items
for (int element : player.playerEquipment) {
if (element > -1) {// equipment
if (element == 88) {
player.weight -= 4.5;
} else {
calcWeight(player, element, "addItem");
}
}
}
}
player.getPacketSender().writeWeight((int) player.weight);
}
}
@@ -0,0 +1,76 @@
package com.rs2.game.items.impl;
import com.rs2.game.items.ItemData;
import com.rs2.game.items.ItemAssistant;
import com.rs2.game.players.Player;
/**
* 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, player.playerCrafting);
}
}
}
}
@@ -0,0 +1,69 @@
package com.rs2.game.items.impl;
import java.util.HashMap;
import com.rs2.game.items.Item;
import com.rs2.game.players.Player;
public class EnchantStaff {
public static boolean staffButtons(Player player, int button) {
final staffData staff = staffData.forId(button);
if (staff != null) {
if(!player.getInventory().playerHasItem(staff.getBattlestaff())){
player.getPacketSender().sendMessage("You need a battlestaff to do this!");
return true;
}
if(!player.getItemAssistant().playerHasItem(995, 40000)) {
player.getPacketSender().sendMessage("You don't have enough coins with you!");
return true;
}
player.getInventory().removeItem(new Item(staff.getBattlestaff(), 1));
player.getInventory().removeItem(new Item(995, 40000));
player.getInventory().addItem(new Item(staff.getMysticstaff(), 1));
player.getPacketSender().sendMessage("Thormac enchants your staff into a mystic staff.");
player.getPacketSender().closeAllWindows();
return true;
}
return false;
}
public static enum staffData {// button, battlestaff, mystic staff
AIR(1734, 1397, 1405), WATER(1735, 1395, 1403), EARTH(1736, 1399, 1407), FIRE(1737, 1393, 1401), LAVA(1738, 3053, 3054), MUD(15348, 6562, 6563);
private int button;
private int battlestaff;
private int mysticstaff;
public static HashMap<Integer, staffData> craftingStaff = new HashMap<Integer, staffData>();
public static staffData forId(int id) {
return craftingStaff.get(id);
}
static {
for (staffData c : staffData.values()) {
craftingStaff.put(c.getButton(), c);
}
}
private staffData(int button, int battlestaff, int mysticstaff) {
this.button = button;
this.battlestaff = battlestaff;
this.mysticstaff = mysticstaff;
}
public int getButton() {
return button;
}
public int getBattlestaff() {
return battlestaff;
}
public int getMysticstaff() {
return mysticstaff;
}
}
}
@@ -0,0 +1,162 @@
package com.rs2.game.items.impl;
import com.rs2.game.players.Player;
public class ExperienceLamp {
public static int LAMP = 4447, LAMP_2 = 2528, SKILL_MENU = 2808,
skill = -1;
/**
* Handles the actionbuttons
*
* @param player
* @param id
*/
public static void buttons(Player player, int id) {
switch (id) {
case 10252:
skill = 0;
player.getPacketSender().sendMessage("You select Attack.");
break;
case 10253:
skill = 2;
player.getPacketSender().sendMessage("You select Strength.");
break;
case 10254:
skill = 4;
player.getPacketSender().sendMessage("You select Ranged.");
break;
case 10255:
skill = 6;
player.getPacketSender().sendMessage("You select Magic.");
break;
case 11000:
skill = 1;
player.getPacketSender().sendMessage("You select Defence.");
break;
case 11001:
skill = 3;
player.getPacketSender().sendMessage("You select Hitpoints.");
break;
case 11002:
skill = 5;
player.getPacketSender().sendMessage("You select Prayer.");
break;
case 11003:
skill = 16;
player.getPacketSender().sendMessage("You select Agility.");
break;
case 11004:
skill = 15;
player.getPacketSender().sendMessage("You select Herblore.");
break;
case 11005:
skill = 17;
player.getPacketSender().sendMessage("You select Thieving.");
break;
case 11006:
skill = 12;
player.getPacketSender().sendMessage("You select Crafting.");
break;
case 11007:
skill = 20;
player.getPacketSender().sendMessage("You select Runecrafting.");
break;
case 47002:
skill = 18;
player.getPacketSender().sendMessage("You select Slayer.");
break;
case 54090:
skill = -1;
player.getPacketSender().sendMessage("You can't select this skill.");
break;
case 11008:
skill = 14;
player.getPacketSender().sendMessage("You select Mining.");
break;
case 11009:
skill = 13;
player.getPacketSender().sendMessage("You select Smithing.");
break;
case 11010:
skill = 10;
player.getPacketSender().sendMessage("You select Fishing.");
break;
case 11011:
skill = 7;
player.getPacketSender().sendMessage("You select Cooking.");
break;
case 11012:
skill = 11;
player.getPacketSender().sendMessage("You select Firemaking.");
break;
case 11013:
skill = 8;
player.getPacketSender().sendMessage("You select Woodcutting.");
break;
case 11014:
skill = 9;
player.getPacketSender().sendMessage("You select Fletching.");
break;
case 11015:
if (skill == -1) {
player.getPacketSender().closeAllWindows();
}
if (player.getItemAssistant().playerHasItem(LAMP, 1) && skill > -1) {// normal
// lamp
int xp = player.getPlayerAssistant()
.getLevelForXP(player.playerXP[skill]) * 10;
player.getPlayerAssistant().addSkillXP(xp, skill);
player.getItemAssistant().deleteItem(LAMP, 1);
player.getPacketSender().sendMessage(
"@blu@Your wish has been granted!");
player.getPacketSender().sendMessage(
"@blu@You have been awarded " + xp
+ " experience in your selected skill!");
player.getPacketSender().closeAllWindows();
} else if (player.getItemAssistant().playerHasItem(LAMP_2, 1)
&& skill > -1) {// vote
// reward
player.getItemAssistant().deleteItem(LAMP_2, 1);
player.getPacketSender().sendMessage(
"@blu@Your wish has been granted!");
addExp(player);
player.getPacketSender().closeAllWindows();
}
break;
}
}
public static void addExp(Player c) {
if (c.getPlayerAssistant().getLevelForXP(c.playerXP[skill]) < 20) {
c.getPlayerAssistant().addSkillXP(1000, skill);
c.getPacketSender()
.sendMessage(
"@blu@You have been awarded 1000 experience in your selected skill!");
} else if (c.getPlayerAssistant().getLevelForXP(c.playerXP[skill]) > 19
&& c.getPlayerAssistant().getLevelForXP(c.playerXP[skill]) < 35) {
c.getPlayerAssistant().addSkillXP(2000, skill);
c.getPacketSender()
.sendMessage(
"@blu@You have been awarded 2000 experience in your selected skill!");
} else {
c.getPlayerAssistant().addSkillXP(3000, skill);
c.getPacketSender()
.sendMessage(
"@blu@You have been awarded 3000 experience in your selected skill!");
}
}
/**
* Rubbing the lamp. ClickItem
*
* @param c
* @param id
*/
public static void rubLamp(Player c, int id) {
c.getPacketSender().sendMessage("You rub the lamp.");
c.getPacketSender().showInterface(SKILL_MENU);
}
}
@@ -0,0 +1,114 @@
package com.rs2.game.items.impl;
public class Fillables {
public static boolean canFill(int id, int oid) {
return counterpart(id) != -1 && !getObjectName(oid).equals("Error");
}
public static String fillMessage(int id, int oid) {
return "You fill the " + getItemName(id) + " from the " + getObjectName(oid) + ".";
}
public static int counterpart(int id) {
switch (id) {
case 1925: // bucket
return 1929;
case 1935: // jug
return 1937;
case 229: // vial
return 227;
case 1923: // bowl
return 1921;
case 1980: // cup
return 4458;
case 5331: // watering can
case 5333:
case 5334:
case 5335:
case 5336:
case 5337:
case 5338:
case 5339:
return 5340;
case 1831: // waterskin
case 1825:
case 1827:
case 1829:
return 1823;
case 6667:
return 6668;
}
return -1;
}
public static String getItemName(int id) {
switch (id) {
case 1925:
return "bucket";
case 1935:
return "jug";
case 229:
return "vial";
case 1923:
return "bowl";
case 1980:
return "cup";
case 5331: // watering can
case 5333:
case 5334:
case 5335:
case 5336:
case 5337:
case 5338:
case 5339:
return "watering can";
case 1831:
case 1825:
case 1827:
case 1829:
return "waterskin";
case 6667:
return "fishbowl";
}
return "There was a problem with your current action, please report this to Mod Andrew.";
}
public static String getObjectName(int id) {
switch (id) {
case 873:
case 874:
case 4063:
case 6151:
case 14917:
return "sink";
case 14918:
return "washbin";
case 884:
case 878:
case 3359:
case 3485:
case 4004:
case 4005:
case 5086:
case 6097:
return "well";
case 2654:
return "Sinclair Family fountain";
case 12809:
return "Fairy fountain";
case 11661:
case 3460:
case 6827:
return "waterpump";
case 879:
case 11759:
case 153:
case 880:
case 6232:
case 2864:
return "fountain";
}
return "Error";
}
}
@@ -0,0 +1,180 @@
package com.rs2.game.items.impl;
import com.rs2.GameEngine;
import com.rs2.event.CycleEvent;
import com.rs2.event.CycleEventContainer;
import com.rs2.event.CycleEventHandler;
import com.rs2.game.players.Player;
import com.rs2.util.Misc;
import com.rs2.world.clip.Region;
/**
* @author Faris
*/
public class Flowers {
/**
* Constants & boolean checker
*/
private final int FLOWER_IDS[] = { 2980, 2981, 2982, 2983, 2984, 2985,
2986, 2987, 2988 };
/**
* Checks weather user is currently interacting with flower
*/
public boolean clientFlowering = false;
/**
* Stores temporary variables for each new instance of flower planted
*/
public static int lastObject;
/**
* algorithm decides which flower to give.
*
* @param flower
* @return
*/
private static int flowerDecoder(final int flower) {
int modifier = flower - 2980;
return modifier + 2460;
}
/**
* Constructor creates the place flower event
*
* @param c
*/
public Flowers(final Player c) {
if (c.checkBusy()) {
return;
}
c.setBusy(true);
executeAction(c);
CycleEventHandler.getSingleton().addEvent(c, new CycleEvent() {
@Override
public void execute(CycleEventContainer container) {
c.setBusy(false);
container.stop();
}
@Override
public void stop() {
}
}, 1);
}
/**
* Main block, Spawns the object & starts animation. Moves player to the
* side Clipped
*
* @param c
*/
private void executeAction(final Player c) {
final int newFlower = getRandom();
final int[] coords = new int[2];
coords[0] = c.absX;
coords[1] = c.absY;
updateConstants(newFlower, c);
GameEngine.objectHandler.createAnObject(c, newFlower, coords[0], coords[1], c.heightLevel,
1);
deleteSeeds(c);
sendOptions(c);
clientFlowering = true;
moveOneStep(c);
c.turnPlayerTo(coords[0], coords[1]);
CycleEventHandler.getSingleton().addEvent(c, new CycleEvent() {
@Override
public void execute(CycleEventContainer container) {
GameEngine.objectHandler.createAnObject(c, -1, coords[0], coords[1], c.heightLevel, 1);
c.getPacketSender().sendMessage( "Your flower is no longer flourishing.");
container.stop();
}
@Override
public void stop() {
}
}, 10);
}
/**
* Handles movement direction.
*
* @param c
*/
private static void moveOneStep(Player c) {
if (Region.getClipping(c.getX() - 1, c.getY(), c.heightLevel, -1, 0)) {
c.getPlayerAssistant().walkTo(-1, 0);
} else if (Region.getClipping(c.getX() + 1, c.getY(), c.heightLevel, 1, 0)) {
c.getPlayerAssistant().walkTo(1, 0);
} else if (Region.getClipping(c.getX(), c.getY() - 1, c.heightLevel, 0, -1)) {
c.getPlayerAssistant().walkTo(0, -1);
} else if (Region.getClipping(c.getX(), c.getY() + 1, c.heightLevel, 0, 1)) {
c.getPlayerAssistant().walkTo(0, 1);
}
}
/**
* Selects a random flower ID
*
* @return
*/
private int getRandom() {
return FLOWER_IDS[Misc.random(FLOWER_IDS.length - 1)];
}
/**
* Sends the client an option to handle flowers
*
* @param c
*/
private void sendOptions(Player c) {
c.getDialogueHandler().sendOption("Leave Flowers", "Harvest Flowers");
}
/**
* Removes the seeds from invent
*
* @param c
*/
private static void deleteSeeds(Player c) {
c.getItemAssistant().deleteItem(299, 1);
}
private void updateConstants(int objectType, Player c) {
lastObject = objectType;
}
/**
* Method harvests flower from ground
*
* @param player
* @param object
* @param oX
* @param oY
*/
public static void harvestFlower(Player player, int object) {
player.getItemAssistant().addItem(flowerDecoder(object), 1);
player.getPacketSender().sendMessage("You receive a random flower.");
player.startAnimation(827);
GameEngine.objectHandler.createAnObject(player, -1, player.getX() + 1, player.getY(), player.getH(), 1);
player.turnPlayerTo(player.getX() + 1, player.getY());
}
/**
* Sends the option action
*
* @param option
*/
public void handleOptions(int option, Player c) {
if (option == 0) {
return;
} else {
harvestFlower(c, lastObject);
}
clientFlowering = false;
}
}
@@ -0,0 +1,127 @@
package com.rs2.game.items.impl;
import java.util.HashMap;
import java.util.Map;
import com.rs2.event.CycleEvent;
import com.rs2.event.CycleEventContainer;
import com.rs2.event.CycleEventHandler;
import com.rs2.game.players.Player;
/**
* Handles the preaching of god books
* @author Final Project
*
*/
public enum GodBooks {
HOLY_BOOK(3840, new String[][] {
{"9178", "In the name of Saradomin,", "Protector of us all,", "I now join you in the eyes of Saradomin.", null},
{"9179", "Thy cause was false, thy skills did lack.", "See you in lumbridge when you get back", null},
{"9180", "Go in peace in the name of Saradomin,", "May his glory shine upon you like the sun.", null},
{"9181", "Walk proud, and show mercy,", "For you carry my name in your heart,", "This is Saradomin's wisdom.", null}
}),
BOOK_OF_BALANCE(3844, new String[][] {
{"9178", "Light and dark, day and night,", "Balance arises from contrast.", "I unify thee in the name of Guthix.", null},
{"9179", "Thy death was not in vain,", "For it brought some balance to the world.", "May Guthix bring you rest.", null},
{"9180", "May you walk the path and never fall,", "For guthix walks beside thee on thy journey.", "May Guthix bring you peace.", null},
{"9181", "A Journey of a single step,", "May take thee over a thousand miles.", "May Guthix bring you balance.", null}
}),
UNHOLY_BOOK(3842, new String[][] {
{"9178", "Two great warriors, joined by hand,", "to spread destruction across the land.", "In Zamorak's name, now two are one.", null},
{"9179", "The weak deserve to die,", "So that the strong may flourish.", "This is the creed of Zamorak.", null},
{"9180", "May your bloodthirst be never sated,", "and may all your battles be glorious.", "Zamorak bring you strength", null},
{"9181", "There is no opinion that cannot be proven true,", "by crushing those who choose to disagree with it.", "Zamorak give me strength!", null}
});
private int itemId;
private String[][] preachData;
private GodBooks(int itemId, String[][] preachData) {
this.itemId = itemId;
this.preachData = preachData;
}
private static Map<Integer, GodBooks> godBooks = new HashMap<Integer, GodBooks>();
static {
for (final GodBooks type : values()) {
godBooks.put(type.itemId, type);
}
}
/**
* Sends the options dialogue with preach options
* @param player
* the player to send the options to
* @param itemId
* the item the player's interacting with
*/
public static void sendPreachOptions(Player player, int itemId) {
player.preaching = true;
switch (itemId) {
case 3840:
player.getDialogueHandler().sendOption("Partnership", "Blessing","Last Rights", "Preach");
player.dialogueAction = 3840;
break;
case 3842:
case 3844:
player.getDialogueHandler().sendOption("Wedding Ceremony", "Blessing", "Last Rights", "Preach");
player.dialogueAction = 3842;
break;
}
}
/**
* Handles the preaching action
* @param player
* the player preaching
* @param itemId
* the item the player's interacting with
* @param actionButtonId
* the button id the player's interacting with
*/
public static void handlePreach(Player player, int itemId, int actionButtonId) {
player.getPacketSender().closeAllWindows();
GodBooks books = godBooks.get(itemId);
if (player.specAmount < 2.5) {
player.getPacketSender().sendMessage("You need at least 25% of special attack to preach!");
return;
}
if (itemId == books.itemId) {
player.specAmount -= 2.5;
player.getItemAssistant().updateSpecialBar();
CycleEventHandler.getSingleton().addEvent(player, new CycleEvent() {
private int currentQuote = 1;
@Override
public void execute(CycleEventContainer container) {
for (int preaches = 0; preaches < books.preachData.length; preaches++) {
if (actionButtonId == Integer.parseInt(books.preachData[preaches][0])) {
if (books.preachData[preaches][currentQuote] == null) {
container.stop();
return;
}
if (books.preachData[preaches][currentQuote] != null) {
player.startAnimation(1670);
player.forcedChat(books.preachData[preaches][currentQuote]);
currentQuote++;
}
break;
}
}
}
@Override
public void stop() {
currentQuote = 1;
player.preaching = false;
}
}, 1);
}
}
}
@@ -0,0 +1,40 @@
package com.rs2.game.items.impl;
import com.rs2.game.players.Player;
public class GodPages {
public static void fillBook(Player player, int oldBook, int newBook, int page1, int page2, int page3) {
if (player.getItemAssistant().playerHasItem(oldBook, 1) && player.getItemAssistant().playerHasItem(page1, 1) && player.getItemAssistant().playerHasItem(page2, 1) && player.getItemAssistant().playerHasItem(page3, 1)) {
player.getItemAssistant().deleteItem(oldBook, player.getItemAssistant().getItemSlot(oldBook), 1);
player.getItemAssistant().deleteItem(page1, player.getItemAssistant().getItemSlot(page1), 1);
player.getItemAssistant().deleteItem(page2, player.getItemAssistant().getItemSlot(page2), 1);
player.getItemAssistant().deleteItem(page3, player.getItemAssistant().getItemSlot(page3), 1);
player.getItemAssistant().addItem(newBook, 1);
} else {
player.getPacketSender().sendMessage("You need all 3 pages to fill the book!");
}
}
public static void itemOnItemHandle(Player player, int useWith, int itemUsed) {
if ((useWith == 3827) || (useWith == 3827) || (useWith == 3827) && (itemUsed == 3839)) { // sara
fillBook(player, 3839, 3840, 3827, 3828, 3829);
}
if ((itemUsed == 3827) || (itemUsed == 3828) || (itemUsed == 3829) || (useWith == 3839)) {// sara
fillBook(player, 3839, 3840, 3827, 3828, 3829);
}
if ((useWith == 3831) || (useWith == 3832) || (useWith == 3833) && (itemUsed == 3841)) { // zam
fillBook(player, 3841, 3842, 3831, 3832, 3833);
}
if ((itemUsed == 3831) || (itemUsed == 3832) || (itemUsed == 3833) || (useWith == 3841)) { // zam
fillBook(player, 3841, 3842, 3831, 3832, 3833);
}
if ((useWith == 3835) || (useWith == 3836) || (useWith == 3837) && (itemUsed == 3843)) { // guth
fillBook(player, 3843, 3844, 3835, 3836, 3837);
}
if ((itemUsed == 3835) || (itemUsed == 3836) || (itemUsed == 3837) || (useWith == 3843)) { // guth
fillBook(player, 3843, 3844, 3835, 3836, 3837);
}
}
}
@@ -0,0 +1,138 @@
package com.rs2.game.items.impl;
import com.rs2.game.items.ItemConstants;
import com.rs2.game.items.ItemData;
import com.rs2.game.players.Player;
import com.rs2.world.Boundary;
public class Greegree {
public static enum MonkeyData {
SMALL_NINJA(4024, 1480, 1386, 1380, 1381, 1383, -1),
LARGE_NINJA(4025, 1481, 1386, 1380, 1381, 1383, -1),
MONKEY_GUARD(4026, 1482, 1401, 1399, 1400, 1402, 1403),
BEARDED_MONKEY_GUARD(4027, 1483, 1401, 1399, 1400, 1402, 1403),
BLUE_FACE_MONKEY_GUARD(4028, 1484, 1401, 1399, 1400, 1402, 1403),
SMALL_ZOMBIE(4029, 1485, 1386, 1382, 1381, 1383,-1),
LARGE_MONKEY(4030, 1486, 1386, 1382, 1381, 1383, -1),
KARAMAJA_MONKEY(4031, 1487, 222, 219, 220, 220, 221);
int greegreeID, npcID, standAnim, walkAnim, runAnim, attackAnim, blockAnim;
private MonkeyData(int greegreeID, int npcID, int standAnim, int walkAnim, int runAnim, int attackAnim, int blockAnim) {
this.greegreeID = greegreeID;
this.npcID = npcID;
this.standAnim = standAnim;
this.walkAnim = walkAnim;
this.runAnim = runAnim;
this.attackAnim = attackAnim;
this.blockAnim = blockAnim;
}
public int getGreegreeID() {
return greegreeID;
}
public int getNpcID() {
return npcID;
}
public int getStandAnim() {
return standAnim;
}
public int getWalkAnim() {
return walkAnim;
}
public int getRunAnim() {
return runAnim;
}
public int getBlockAnim() {
return blockAnim;
}
public int getAttackAnim() {
return attackAnim;
}
public static MonkeyData forId(int id) {
for (MonkeyData data: MonkeyData.values())
if (data.greegreeID == id)
return data;
return null;
}
public static boolean isWearingGreegree(Player p) {
return MonkeyData.forId(p.playerEquipment[ItemConstants.WEAPON]) != null;
}
public static boolean isAnim(int animId) {
for (MonkeyData data: MonkeyData.values())
if (data.attackAnim == animId || data.blockAnim == animId)
return true;
return false;
}
}
public static boolean canWear(Player player) {
return (Boundary.isIn(player, Boundary.APE_ATOLL) || Boundary.isIn(player, Boundary.ARDOUGNE_ZOO));
}
public static boolean attemptGreegree(Player p, int weaponID) {
int targetSlot = ItemData.targetSlots[weaponID];
if (MonkeyData.forId(weaponID) == null && targetSlot != ItemConstants.WEAPON && MonkeyData.isWearingGreegree(p)) {
p.getPacketSender().sendMessage("You can't equip that while wearing a greegree.");
return false;
}
if (weaponID >= 4024 && weaponID <= 4031) {
if (!canWear(p) && !MonkeyData.isWearingGreegree(p)) {
p.getPacketSender().sendMessage("You can't equip that here.");
return false;
}
}
MonkeyData data = MonkeyData.forId(weaponID);
if (MonkeyData.isWearingGreegree(p) || data != null) {
if (data != null) {
setAnimations(p, data);
} else {
resetAnimations(p);
}
p.gfx100(359);
return true;
}
return true;
}
public static void setAnimations(Player p, MonkeyData data) {
p.npcId2 = data.getNpcID();
p.isNpc = true;
p.playerStandIndex = data.getStandAnim();
p.playerWalkIndex = data.getWalkAnim();
p.playerRunIndex = data.getRunAnim();
p.playerTurnIndex = data.getWalkAnim();
p.playerTurn180Index = data.getWalkAnim();
p.playerTurn90CWIndex = data.getWalkAnim();
p.playerTurn90CCWIndex = data.getWalkAnim();
p.getPlayerAssistant().requestUpdates();
}
public static void resetAnimations(Player p) {
p.npcId2 = -1;
p.isNpc = false;
p.getPlayerAssistant().resetAnimation();
p.gfx100(359);
}
public static boolean attemptRemove(Player p, int slot) {
if (slot == ItemConstants.WEAPON && MonkeyData.isWearingGreegree(p)) {
resetAnimations(p);
} else if (slot != ItemConstants.WEAPON && MonkeyData.isWearingGreegree(p)) {
p.getPacketSender().sendMessage("You can't remove items while wearing a greegree.");
return false;
}
return true;
}
}
@@ -0,0 +1,61 @@
package com.rs2.game.items.impl;
import com.rs2.game.content.music.sound.SoundList;
import com.rs2.game.items.ItemAssistant;
import com.rs2.game.players.Player;
/**
* @author Genesis
*/
public class HandleEmpty {
public static boolean canEmpty(Player c, int id) {
return filledToEmpty(c, id) != -1;
}
public static int filledToEmpty(Player c, int id) {
String itemName = ItemAssistant.getItemName(id);
if (!itemName.contains("Ring") && !itemName.contains("necklace")) {
if (itemName.contains("(3)") || itemName.contains("(4)") || itemName.contains("(2)") || itemName.contains("(1)") || itemName.contains("Weapon poison")) {
if (id != 1712 && id != 1710 && id != 1708 && id != 1706) {
c.getItemAssistant().deleteItem(id, c.getItemAssistant().getItemSlot(id), 1);
c.getItemAssistant().addItem(229, 1);
c.getPacketSender().sendMessage("You empty the vial.");
}
}
}
switch (id) {
case 1937: // Jugs
case 1989:
case 1991:
case 1993:
case 3729:
return 1935;
case 227: // Vial of Water
return 229;
case 1927: // Buckets
case 1929:
case 4687:
case 4286:
case 1784:
case 4693:
case 6712:
case 7471:
case 7622:
case 7624:
case 7626:
return 1925;
}
return -1;
}
public static void handleEmptyItem(Player c, int itemId, int giveItem) {
final String name = ItemAssistant.getItemName(itemId);
c.getPacketSender().sendMessage("You empty your " + name + ".");
c.getItemAssistant().deleteItem(itemId, 1);
c.getItemAssistant().addItem(giveItem, 1);
c.getPacketSender().sendSound(SoundList.EMPTY, 100, 0);
}
}
@@ -0,0 +1,84 @@
package com.rs2.game.items.impl;
import com.rs2.game.players.Player;
/**
* Lightsources
* @author Andrew (Mr Extremez)
*/
public class LightSources {
public static void saveBrightness(Player player) {
if (player.brightness == 1) {
brightness1(player);
} else if (player.brightness == 2) {
brightness2(player);
} else if (player.brightness == 4) {
brightness4(player);
} else {
brightness3(player);
}
}
public static void brightness1(Player player) {
player.getPacketSender().sendConfig(505, 1);
player.getPacketSender().sendConfig(506, 0);
player.getPacketSender().sendConfig(507, 0);
player.getPacketSender().sendConfig(508, 0);
player.getPacketSender().sendConfig(166, 1);
player.brightness = 1;
}
public static void brightness2(Player player) {
player.getPacketSender().sendConfig(505, 0);
player.getPacketSender().sendConfig(506, 1);
player.getPacketSender().sendConfig(507, 0);
player.getPacketSender().sendConfig(508, 0);
player.getPacketSender().sendConfig(166, 2);
player.brightness = 2;
}
public static void brightness3(Player player) {
player.getPacketSender().sendConfig(505, 0);
player.getPacketSender().sendConfig(506, 0);
player.getPacketSender().sendConfig(507, 1);
player.getPacketSender().sendConfig(508, 0);
player.getPacketSender().sendConfig(166, 3);
player.brightness = 3;
}
public static void brightness4(Player player) {
player.getPacketSender().sendConfig(505, 0);
player.getPacketSender().sendConfig(506, 0);
player.getPacketSender().sendConfig(507, 0);
player.getPacketSender().sendConfig(508, 1);
player.getPacketSender().sendConfig(166, 4);
player.brightness = 4;
}
public static void setBrightness(Player c) {
if (c.getItemAssistant().playerHasItem(594) || c.getItemAssistant().playerHasItem(32) || c.getItemAssistant().playerHasItem(33)) {
brightness2(c);
} else if (c.getItemAssistant().playerHasItem(4535) || c.getItemAssistant().playerHasItem(4524)) {
brightness3(c);
} else if (c.getItemAssistant().playerHasItem(4550)) {
brightness4(c);
}
}
public static final int[] lightSources = { 594, 32, 33, 4524, 4539, 4550 };
public static boolean playerHasLightSource(Player client) {
for (int lightSource : lightSources) {
if (client.getItemAssistant().playerHasItem(lightSource)) {
setBrightness(client);
return true;
}
}
client.getPacketSender().sendMessage("It's recommended that you get a light source to continue.");
brightness1(client);
return false;
}
}
@@ -0,0 +1,99 @@
package com.rs2.game.items.impl;
import com.rs2.game.items.ItemAssistant;
import com.rs2.game.players.Player;
/**
* @author Sanity
*/
public class PotionMixing {
Player c;
public PotionMixing(Player player) {
this.c = player;
}
public void mixPotion2(int id, int id2) {
String id11 = ItemAssistant.getItemName(id);
String id22 = ItemAssistant.getItemName(id2);
if (id11.substring(0, id11.indexOf("(")).equalsIgnoreCase(
id22.substring(0, id22.indexOf("(")))) {
try {
int amount1 = Integer.parseInt(id11.substring(
id11.indexOf("(") + 1, id11.indexOf("(") + 2));
int amount2 = Integer.parseInt(id22.substring(
id22.indexOf("(") + 1, id22.indexOf("(") + 2));
int totalAmount = amount1 + amount2;
if (totalAmount > 4) {
amount1 = 4;
amount2 = totalAmount - 4;
String item1 = id11.substring(0, id11.indexOf("(") + 1)
+ amount1 + ")";
String item2 = id11.substring(0, id11.indexOf("(") + 1)
+ amount2 + ")";
c.getItemAssistant().deleteItem(id,
c.getItemAssistant().getItemSlot(id), 1);
c.getItemAssistant().deleteItem(id2,
c.getItemAssistant().getItemSlot(id2), 1);
c.getItemAssistant().addItem(
c.getItemAssistant().getItemId(item1), 1);
c.getItemAssistant().addItem(
c.getItemAssistant().getItemId(item2), 1);
} else {
amount1 = totalAmount;
String item1 = id11.substring(0, id11.indexOf("(") + 1)
+ amount1 + ")";
c.getItemAssistant().deleteItem(id,
c.getItemAssistant().getItemSlot(id), 1);
c.getItemAssistant().deleteItem(id2,
c.getItemAssistant().getItemSlot(id2), 1);
c.getItemAssistant().addItem(
c.getItemAssistant().getItemId(item1), 1);
c.getItemAssistant().addItem(229, 1);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
private final int[][] potMixing = { { 117, 117, 113, 227 },
{ 119, 115, 113, 227 }, { 115, 119, 113, 227 },
{ 123, 123, 2428, 227 }, { 121, 125, 2428, 227 },
{ 125, 121, 2428, 227 }, { 133, 133, 2432, 227 },
{ 133, 137, 2432, 227 }, { 137, 133, 2432, 227 },
{ 159, 159, 2440, 227 }, { 157, 161, 2440, 227 },
{ 161, 157, 2440, 227 }, { 147, 147, 2436, 227 },
{ 149, 145, 2436, 227 }, { 145, 149, 2436, 227 },
{ 165, 165, 2442, 227 }, { 163, 167, 2442, 227 },
{ 167, 163, 2442, 227 }, { 6689, 6689, 6685, 227 },
{ 6687, 6691, 2442, 227 }, { 6691, 6687, 2442, 227 },
{ 171, 171, 2444, 227 }, { 169, 173, 2444, 227 },
{ 173, 169, 2444, 227 }, { 177, 177, 2446, 227 },
{ 179, 175, 2446, 227 }, { 175, 179, 2446, 227 },
{ 3028, 3028, 3024, 227 }, { 3030, 3026, 3024, 227 },
{ 3026, 3030, 3024, 227 }, { 141, 141, 2434, 227 },
{ 139, 143, 2434, 227 }, { 143, 139, 2434, 227 },
{ 3044, 3044, 3040, 227 }, { 3042, 3046, 3040, 227 },
{ 3046, 3042, 3040, 227 }, { 2456, 2456, 2452, 227 },
{ 2454, 2458, 2452, 227 }, { 2458, 2454, 2452, 227 } };
// use id, use id2, new id1, new id2
public void mixPotion(int id, int id2) {
for (int[] element : potMixing) {
if (element[0] == id && element[1] == id || element[1] == id
&& element[0] == id2) {
c.getItemAssistant().deleteItem(id,
c.getItemAssistant().getItemSlot(id), 1);
c.getItemAssistant().deleteItem(id2,
c.getItemAssistant().getItemSlot(id2), 1);
c.getItemAssistant().addItem(element[2], 1);
c.getItemAssistant().addItem(element[3], 1);
break;
}
}
}
}
@@ -0,0 +1,73 @@
package com.rs2.game.items.impl;
import com.rs2.game.players.Player;
/**
* Rare Protection
* @author Andrew (Mr Extremez)
*/
public class RareProtection {
public static boolean RARES = false, CRACKERS = false;
private static final int[] RARE_ITEMS = { 1037, 1038, 1039, 1040, 1041,
1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 962, 963, 1959, 1961, 1989 };
private static final int[] EDIBLE_RARES = { 1959, 1961, 1989 };
public static boolean equipItem(Player c) {// check when wearing, removing
for (int element : RARE_ITEMS) {
if (c.wearId == element && (RARES || CRACKERS)) {
c.getPacketSender().sendMessage("You shouldn't have that item!");
int amountToDelete = c.getItemAssistant().getItemAmount(element);
c.getItemAssistant().deleteItem(element, amountToDelete);
return false;
}
}
return true;
}
public static boolean removeItemOtherActions(Player player, int itemId) {
for (int element : RARE_ITEMS) {
if (player.getItemAssistant().playerHasItem(element) && (RARES || CRACKERS)) {
player.getPacketSender().sendMessage("You shouldn't have that item!");
int amountToDelete = player.getItemAssistant().getItemAmount(element);
player.getItemAssistant().deleteItem(element, amountToDelete);
return false;
}
}
return true;
}
public static boolean removeItem(Player c, int itemId) {
for (int element : RARE_ITEMS) {
if (itemId == element && (RARES || CRACKERS)) {
c.getPacketSender().sendMessage("You shouldn't have that item!");
c.getItemAssistant().deleteEquipment(element, 0);
return false;
}
}
return true;
}
public static boolean hasDupedItem(Player c) {// check on login
for (int element : RARE_ITEMS) {
if (c.getItemAssistant().playerHasItem(element)) {
c.getPacketSender().sendMessage("You can't have these items!");
int amountToDelete = c.getItemAssistant().getItemAmount(element);
c.getItemAssistant().deleteItem(element, amountToDelete);
return false;
}
}
return true;
}
public static boolean eatDupedItem(Player c, int itemId) {
for (int element : EDIBLE_RARES) {
if (itemId == element && RARES) {
c.getPacketSender().sendMessage("You can't eat that item!");
int amountToDelete = c.getItemAssistant().getItemAmount(element);
c.getItemAssistant().deleteItem(element, amountToDelete);
return false;
}
}
return true;
}
}
@@ -0,0 +1,56 @@
package com.rs2.game.items.impl;
import com.rs2.game.players.Player;
/**
* Teles
* @author Andrew (Mr Extremez)
*/
public class Teles {
public static void useAOG(Player player) {
player.getDialogueHandler().sendOption("Edgeville", "Al Kharid", "Karamja", "Draynor");
player.dialogueAction = 51;
player.getPacketSender().sendMessage("You rub the Amulet of Glory...");
}
public static void useROD(Player player) {
player.getDialogueHandler().sendOption("Duel Arena", "Castle Wars");
player.dialogueAction = 161;
player.getPacketSender().sendMessage("You rub the Ring of Dueling...");
}
public static void useGN(Player player) {
player.getDialogueHandler().sendOption("Burthrope Games Room", "Barbarian Outpost");
player.dialogueAction = 50;
player.getPacketSender().sendMessage("You rub the Games Necklace...");
}
private static final int[][] JEWELERY = {
{ 3853, 3855, 7 }, { 3855, 3857, 6 }, { 3857, 3859, 5 }, { 3859, 3861, 4 }, { 3861, 3863, 3 },{ 3863, 3865, 2 }, { 3865, 3867, 1 }, { 3867, 0, 0 }, // gn
{ 2552, 2554, 7 }, { 2554, 2556, 6 }, { 2556, 2558, 5 }, { 2558, 2560, 4 }, { 2560, 2562, 3 }, { 2562, 2564, 2 }, { 2564, 2566, 1 }, { 2566, 0, 0 }, // rod
{ 1712, 1710, 3 }, { 1710, 1708, 2 }, { 1708, 1706, 1 }, { 1706, 1704, 0 } //aog
};
public static void necklaces(Player player) {
for (int[] element : JEWELERY) {
if (player.itemUsing == element[0]) {
if (player.isOperate) {
player.playerEquipment[player.playerAmulet] = element[1];
} else {
player.getItemAssistant().deleteItem(element[0], 1);
player.getItemAssistant().addItem(element[1], 1);
}
if (element[2] > 1) {
player.getPacketSender().sendMessage("You have " + element[2] + " charges left.");
} else {
player.getPacketSender().sendMessage("You have " + element[2] + " charge left.");
}
}
}
player.getItemAssistant().updateSlot(player.playerAmulet);
player.isOperate = false;
player.itemUsing = -1;
}
}
@@ -0,0 +1,148 @@
package com.rs2.game.items.impl;
import java.util.HashMap;
import com.rs2.game.items.ItemAssistant;
import com.rs2.game.players.Player;
/**
* Manages weapon poisoning.
* @author Andew added every single weapon to the enum
* @author Hybris writing the system
*/
public class WeaponPoison {
/**
* Represents a weapon that can be poisoned. Stores the initial weapon item
* id, the type of poison used on the weapon and the new poisoned weapon
* that will be obtained.
*/
private enum Weapon {
BRONZE_DAGGER(1205, new int[][] {{ 5940, 5688 }, { 5937, 5670 }, { 187, 1221 }}),
IRON_DAGGER(1203, new int[][] {{ 5940, 5686 }, { 5937, 5668 }, { 187, 1219 }}),
STEEL_DAGGER(1207, new int[][] {{ 5940, 5690 }, { 5937, 5672 }, { 187, 1223 }}),
BLACK_DAGGER(1217, new int[][] {{ 5940, 5700 }, { 5937, 5682 }, { 187, 1233 }}),
MITHRIL_DAGGER(1209, new int[][] {{ 5940, 5692 }, { 5937, 5674 }, { 187, 1225 }}),
ADAMANT_DAGGER(1211, new int[][] {{ 5940, 5694 }, { 5937, 5676 }, { 187, 1227 }}),
RUNE_DAGGER(1213, new int[][] {{ 5940, 5696 }, { 5937, 5678 }, { 187, 1229 }}),
DRAGON_DAGGER(1215, new int[][] {{ 5940, 5698 }, { 5937, 5680 }, { 187, 1231 }}),
BRONZE_DART(806, new int[][] {{ 5940, 5635 }, { 5937, 5628 }, { 187, 812 }}),
IRON_DART(807, new int[][] {{ 5940, 5636 }, { 5937, 5629 }, { 187, 813 }}),
STEEL_DART(808, new int[][] {{ 5940, 5637 }, { 5937, 5630 }, { 187, 814 }}),
BLACK_DART(3093, new int[][] {{ 5940, 5638 }, { 5937, 5631 }, { 187, 815 }}),
MITHRIL_DART(809, new int[][] {{ 5940, 5639 }, { 5937, 5632 }, { 187, 816 }}),
ADAMANT_DART(810, new int[][] {{ 5940, 5640 }, { 5937, 5633 }, { 187, 817 }}),
RUNE_DART(811, new int[][] {{ 5940, 5641 }, { 5937, 5634 }, { 187, 818 }}),
BRONZE_SPEAR(1237, new int[][] {{ 5940, 5718 }, { 5937, 5704 }, { 187, 1251 }}),
IRON_SPEAR(1239, new int[][] {{ 5940, 5720 }, { 5937, 5706 }, { 187, 1253 }}),
STEEL_SPEAR(1241, new int[][] {{ 5940, 5722 }, { 5937, 5708 }, { 187, 1255 }}),
MITHRIL_SPEAR(1243, new int[][] {{ 5940, 5724 }, { 5937, 5710 }, { 187, 1257 }}),
ADAMANT_SPEAR(1245, new int[][] {{ 5940, 5726 }, { 5937, 5712 }, { 187, 1259 }}),
RUNE_SPEAR(1247, new int[][] {{ 5940, 5728 }, { 5937, 5714 }, { 187, 1261 }}),
DRAGON_SPEAR(1249, new int[][] {{ 5940, 5730 }, { 5937, 5716 }, { 187, 1263 }}),
BRONZE_JAVELIN(825, new int[][] { { 5940, 5648 }, { 5937, 5642 }, { 187, 831 }}),
IRON_JAVELIN(826, new int[][] { { 5940, 5648 }, { 5937, 5643 }, { 187, 832 }}),
STEEL_JAVELIN(827, new int[][] {{ 5940, 5648 }, { 5937, 5644 }, { 187, 833 }}),
MITHRIL_JAVELIN(828, new int[][] {{ 5940, 5648 }, { 5937, 5645 }, { 187, 834 }}),
ADAMANT_JAVELIN(829, new int[][] {{ 5940, 5648 }, { 5937, 5646 }, { 187, 835 }}),
RUNE_JAVELIN(830, new int[][] {{ 5940, 5648 }, { 5937, 5647 }, { 187, 836 }}),
BRONZE_ARROW(882, new int[][] {{ 5940, 5622 }, { 5937, 5616 }, { 187, 883 }}),
IRON_ARROW(884, new int[][] {{ 5940, 5623 }, { 5937, 5617 }, { 187, 885 }}),
STEEL_ARROW(886, new int[][] {{ 5940, 5624 }, { 5937, 5618 }, { 187, 887 }}),
MITHRIL_ARROW(888, new int[][] {{ 5940, 5625 }, { 5937, 5619 }, { 187, 889 }}),
ADAMANT_ARROW(890, new int[][] {{ 5940, 5626 }, { 5937, 5620 }, { 187, 891 }}),
RUNE_ARROW(892, new int[][] {{ 5940, 5627 }, { 5937, 5621 }, { 187, 893 }}),
BRONZE_KNIFE(864, new int[][] {{ 5940, 5661 }, { 5937, 5654 }, { 187, 870 }}),
IRON_KNIFE(863, new int[][] {{ 5940, 5662 }, { 5937, 5655 }, { 187, 871}}),
STEEL_KNIFE(865, new int[][] {{ 5940, 5663 }, { 5937, 5656 }, { 187, 872 }}),
BLACK_KNIFE(869, new int[][] {{ 5940, 5665 }, { 5937, 5658 }, { 187, 873 }}),
MITHRIL_KNIFE(866, new int[][] {{ 5940, 5664 }, { 5937, 5657 }, { 187, 874 }}),
ADAMANT_KNIFE(867, new int[][] {{ 5940, 5666 }, { 5937, 5659 }, { 187, 875 }}),
RUNE_KNIFE(868, new int[][] {{ 5940, 5667 }, { 5937, 5660 }, { 187, 876 }});
/**
* Creates the weapon.
*
* @param itemId
* The weapon item id.
* @param newItemId
* The poisoned weapon item id.
*/
private Weapon(int itemId, int[][] newItemId) {
this.itemId = itemId;
this.newItemId = newItemId;
}
/**
* Gets the item id.
*
* @return the itemId
*/
public int getItemId() {
return itemId;
}
/**
* The weapon item id.
*/
private final int itemId;
/**
* The poisoned weapon item id.
*/
private final int[][] newItemId;
/**
* Represents a map for the weapon item ids.
*/
public static HashMap<Integer, Weapon> weapon = new HashMap<Integer, Weapon>();
/**
* @return the newItemId
*/
public int[][] getNewItemId() {
return newItemId;
}
/**
* Populates a map for the weapons.
*/
static {
for (Weapon w : Weapon.values()) {
weapon.put(w.getItemId(), w);
}
}
}
/**
* The item id for Vial.
*/
private final static int VIAL = 229;
/**
* Starts the weapon poison event for each individual weapon item from the
* enumeration <code>Weapon</code>.
*
* @param player
* The Player player.
* @param itemUse
* The first item use.
* @param useWith
* The second item use.
*/
public static void execute(final Player player, int itemUse, int useWith) {
final Weapon weapon = Weapon.weapon.get(useWith);
if (weapon != null) {
for (int element[] : weapon.getNewItemId()) {
if (itemUse == element[0]) {
player.getPacketSender().sendMessage("You make a " + ItemAssistant.getItemName(element[1]) + ".");
player.getItemAssistant().deleteItem(element[0], player.getItemAssistant().getItemSlot(element[0]), 1);
player.getItemAssistant().deleteItem(weapon.getItemId(), player.getItemAssistant().getItemSlot(weapon.getItemId()), 1);
player.getItemAssistant().addItem(VIAL, 1);
player.getItemAssistant().addItem(element[1], 1);
}
}
}
}
}