Skip to content

Instantly share code, notes, and snippets.

Created April 28, 2017 03:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/2a887215f72e3a7f001b939947e91464 to your computer and use it in GitHub Desktop.
Save anonymous/2a887215f72e3a7f001b939947e91464 to your computer and use it in GitHub Desktop.
Nbness/WeaponConstants
/**
* arrayContains checks if the int[] array contains the item.
*
* @param array
* The int[] array you are checking if it contains the item.
*
* @param item
* The item you are checking if it is contained in the int[] array.
*
* @return boolean
*/
public static boolean arrayContains(int[] array, int item){
for (int i: array){
if (item == i){
return true;
}
}
return false;
}
package com....combat;
import com....Misc;
/**
* Nbness, 4/2017
*/
public class WeaponConstants {
public enum ARROWS{
BRONZE_ARROWS(0, new int[] {882, 883, 5616, 5622, 598, 942}),
IRON_ARROWS(0, new int[] {884, 885, 5617, 5623, 2532, 2533}),
STEEL_ARROWS(1, new int[] {886, 886, 5618, 5624, 2534, 2535}),
MITHRIL_ARROWS(2, new int[] {888, 889, 5619, 5625, 2536, 2537}),
ADAMANT_ARROWS(3, new int[] {890, 891, 5620, 5626, 2538, 2539}),
RUNE_ARROWS(4, new int[] {892, 893, 5621, 5627, 2540, 2541}),
DRAGON_ARROWS(5, new int[] {11212, 11227, 11228, 11229, 11217, 11222});
private final int arrowTier;
private final int[] arrowIds;
/**
* ARROWS is an arrow type for a specific tier of arrows.
*
* @param arrowTier
* The arrows within tier X can only be used with a bow with tier X or higher.
*
* @param arrowIds
* The array containing the item ids of arrows in that tier
*/
ARROWS(int arrowTier, int[] arrowIds){
this.arrowTier = arrowTier;
this.arrowIds = arrowIds;
}
}
private final static ARROWS[] ARROW_TYPES = {
ARROWS.BRONZE_ARROWS, ARROWS.IRON_ARROWS, ARROWS.STEEL_ARROWS, ARROWS.MITHRIL_ARROWS, ARROWS.ADAMANT_ARROWS,
ARROWS.RUNE_ARROWS, ARROWS.DRAGON_ARROWS
};
/**
* isItemArrow checks to see if the item corresponding to the item id given is an arrow.
*
* @param itemId
* The id of the item being tested to see if it is an arrow.
*
* @return boolean
*/
public static boolean isItemArrow(int itemId){
for (ARROWS arrowType: ARROW_TYPES){
if (Misc.arrayContains(arrowType.arrowIds, itemId)) return true;
}
return false;
}
/**
* getArrowTier accesses the arrow types and if the item corresponding to the item id given is classified as an arrow
* by isItemArrow, it will return the tier of the arrow.
*
* @param itemId
* The id of the item that you are trying to get the arrow tier of.
*
* @return int
*/
public static int getArrowTier(int itemId){
for (ARROWS arrowType: ARROW_TYPES){
if (Misc.arrayContains(arrowType.arrowIds, itemId)) return arrowType.arrowTier;
}
return -1;
}
public enum BOLTS{
BRONZE_BOLTS(0, new int[] {877, 878, 6061, 6062, 879, 9236}),
BLURITE_BOLTS(1, new int[] {9139, 9286, 9293, 9300, 9237, 9335}),
SILVER_BOLTS(1, new int[] {9145, 9292, 9299, 9306}),
IRON_BOLTS(2, new int[] {9140, 9287, 9294, 9301, 880, 9238}),
STEEL_BOLTS(3, new int[] {9141, 9288, 9295, 9302, 9239, 9336}),
BLACK_BOLTS(4, new int[] {13083, 13084, 13085, 13086}),
MITHRIL_BOLTS(5, new int[] {9142, 9289, 9296, 9303, 9240, 9337, 9241, 9338}),
ADAMANT_BOLTS(6, new int[] {9143, 9290, 9297, 9304, 9339, 9242, 9243, 9340}),
RUNE_BOLTS(7, new int[] {9144, 9291, 9298, 9305, 9244, 9341, 9245, 9342});
private final int boltTier;
private final int[] boltIds;
/**
* BOLTS is an bolt type for a specific tier of bolts.
*
* @param boltTier
* The bolts within tier X can only be used with a crossbow with tier X or higher.
*
* @param boltIds
* The array containing the item ids of bolts in that tier
*/
BOLTS(int boltTier, int[] boltIds){
this.boltTier = boltTier;
this.boltIds = boltIds;
}
}
private final static BOLTS[] BOLT_TYPES = {
BOLTS.BRONZE_BOLTS, BOLTS.BLURITE_BOLTS, BOLTS.SILVER_BOLTS, BOLTS.IRON_BOLTS, BOLTS.STEEL_BOLTS,
BOLTS.BLACK_BOLTS, BOLTS.MITHRIL_BOLTS, BOLTS.ADAMANT_BOLTS, BOLTS.RUNE_BOLTS
};
/**
* isItemBolt checks to see if the item corresponding to the item id given is a bolt.
*
* @param itemId
* The id of the item being tested to see if it is a bolt.
*
* @return boolean
*/
public static boolean isItemBolt(int itemId){
for (BOLTS boltType: BOLT_TYPES){
if (Misc.arrayContains(boltType.boltIds, itemId)) return true;
}
return false;
}
/**
* getArrowTier accesses the bolt types and if the item corresponding to the item id given is classified as a bolt
* by isItemBolt, it will return the tier of the bolt.
*
* @param itemId
* The id of the item that you are trying to get the bolt tier of.
*
* @return int
*/
public static int getBoltTier(int itemId){
for (BOLTS boltType: BOLT_TYPES){
if (Misc.arrayContains(boltType.boltIds, itemId)) return boltType.boltTier;
}
return -1;
}
public enum BOWS{
REGULAR_BOWS(0, new int[] {839, 841}),
OAK_BOWS(1, new int[] {843, 845}),
WILLOW_BOWS(2, new int[] {847, 849, 10280, 13541}),
MAPLE_BOWS(3, new int[] {851, 853, 18331}),
YEW_BOWS(4, new int[] {855, 857, 10282, 13542}),
MAGIC_BOWS(4, new int[] {859, 861, 10284, 13543, 18332}),
DARK_BOWS(5, new int[] {11235, 13405, 15701, 15702, 15703, 15704}),
NO_AMMO_BOWS(6, new int[] {4212, 4214, 4215, 4216, 4217, 4218, 4219, 4220, 4221, 4222, 4223, 20171, 20172});
private final int bowTier;
private final int[] bowIds;
/**
* BOWS is a bow type for a specific wood type of bows.
*
* @param bowTier
* The tier of the bows contained in BOWS.X_BOWS.bowIds
* Bows with tier X can only be used with arrows of tier X or lower.
*
* @param bowIds
* The array containing the item ids of bows in X_BOWS
*/
BOWS(int bowTier, int[] bowIds){
this.bowTier = bowTier;
this.bowIds = bowIds;
}
}
private static BOWS[] BOW_TYPES = {
BOWS.REGULAR_BOWS, BOWS.OAK_BOWS, BOWS.WILLOW_BOWS, BOWS.MAPLE_BOWS, BOWS.YEW_BOWS, BOWS.MAGIC_BOWS,
BOWS.DARK_BOWS, BOWS.NO_AMMO_BOWS
};
/**
* isItemBow checks if the item corresponding to the given itemId is a bow.
*
* @param itemId
* Item ID of the item being tested to check if it is a bow.
*
* @return boolean
*/
public static boolean isItemBow(int itemId){
for (BOWS bowType: BOW_TYPES){
if (Misc.arrayContains(bowType.bowIds, itemId)) return true;
}
return false;
}
/**
* getBowTier accesses the bow types and if the item corresponding to the item id given is classified as a bow
* by isItemBow, it will return the tier of the bow.
* @param itemId
* Item ID of the item that you are trying to get the bow tier of.
*
* @return int
*/
public static int getBowTier(int itemId){
for (BOWS bowType: BOW_TYPES){
if (Misc.arrayContains(bowType.bowIds, itemId)) return bowType.bowTier;
}
return -1;
}
public enum CROSSBOWS{
TIER_0_CBOWS(0, new int[] {767, 837, 9174, 11165, 11167}),
TIER_1_CBOWS(1, new int[] {9176}),
TIER_2_CBOWS(2, new int[] {9177, 8880}),
TIER_3_CBOWS(3, new int[] {9179, 10156}),
TIER_4_CBOWS(4, new int[] {13081}),
TIER_5_CBOWS(5, new int[] {9181}),
TIER_6_CBOWS(6, new int[] {9183, 14684}),
TIER_7_CBOWS(7, new int[] {9185, 18357});
private int cbowTier;
private int[] cbowIds;
/**
* CROSSBOWS is a crossbow type for a specific tier of crossbows.
*
* @param cbowTier
* The tier of the crossbows contained in TIER_X_CBOWS.cbowIds
* Crossbows with tier X can only be used with bolts of tier X or lower.
*
* @param cbowIds
* The array containing the item ids of crossbows in TIER_X_CBOWS
*/
CROSSBOWS(int cbowTier, int[] cbowIds){
this.cbowTier = cbowTier;
this.cbowIds = cbowIds;
}
}
private static CROSSBOWS[] CROSSBOW_TYPES = {
CROSSBOWS.TIER_0_CBOWS, CROSSBOWS.TIER_1_CBOWS, CROSSBOWS.TIER_2_CBOWS, CROSSBOWS.TIER_3_CBOWS,
CROSSBOWS.TIER_4_CBOWS, CROSSBOWS.TIER_5_CBOWS, CROSSBOWS.TIER_6_CBOWS, CROSSBOWS.TIER_7_CBOWS
};
/**
* isItemCBow checks if the item corresponding to the given itemId is a crossbow.
*
* @param itemId
* Item ID of the item being tested to check if it is a crossbow.
*
* @return boolean
*/
public static boolean isItemCbow(int itemId){
for (CROSSBOWS cbowType: CROSSBOW_TYPES){
if (Misc.arrayContains(cbowType.cbowIds, itemId)) return true;
}
return false;
}
/**
* getCbowTier accesses the bow types and if the item corresponding to the item id given is classified as a crossbow
* by isItemCbow, it will return the tier of the crossbow.
* @param itemId
* Item ID of the item that you are trying to get the crossbow tier of.
*
* @return int
*/
public static int getCbowTier(int itemId){
for (CROSSBOWS cbowType: CROSSBOW_TYPES){
if (Misc.arrayContains(cbowType.cbowIds, itemId)) return cbowType.cbowTier;
}
return -1;
}
public enum OTHER_RANGED{
DARTS(0, new int[] {806, 807, 808, 809, 810, 811, 812, 813, 814, 815, 816, 817, 818, 3093, 3094, 5628, 5629, 5630,
5631, 5632, 5633, 5634, 5635, 5636, 5637, 5638, 5639, 5640, 5641, 11230, 11231, 11232, 11233, 11234}),
THROWING_KNIVES(1, new int[] {863, 864, 856, 866, 867, 868, 869, 870, 871, 862, 863, 864, 865, 866, 5654, 5655,
5656, 5657, 5658, 5659, 5660, 5661, 5662, 5663, 5664, 5665, 5666, 5667}),
JAVELINS(2, new int[] {825, 826, 827, 828, 829, 830, 831, 832, 833, 834, 835, 836, 5642, 5643, 5644, 5645, 5646,
5647, 5648, 5649, 5650, 5651, 5652, 5653, 13879, 13880, 13881, 13882, 13953, 13954, 13955, 13956}),
THROWNAXES(3, new int[] {800, 801, 802, 803, 804, 805, 13883, 13957}),
TOKTZ(4, new int[] {6522});
private int otherRangedWeaponType;
private int[] itemIds;
/**
* OTHER_RANGED is a ranged weapon type for a specific type of "other" ranged weapons such as Darts, knives, etc.
*
* @param otherType
* Type of the "other" ranged weapon.
* Mainly an easy way to differentiate for the purposes of attack delays, animations, etc.
*
* @param itemIds
* The array containing the item ids of other ranged weapon types in OTHER_RANGED.X
*/
OTHER_RANGED(int otherType, int[] itemIds){
this.otherRangedWeaponType = otherType;
this.itemIds = itemIds;
}
}
private static OTHER_RANGED[] OTHER_TYPES = {
OTHER_RANGED.DARTS, OTHER_RANGED.THROWING_KNIVES, OTHER_RANGED.JAVELINS, OTHER_RANGED.THROWNAXES
};
/**
* isItemOtherRanged checks if the item corresponding to the given itemId is an "other" ranged weapon.
*
* @param itemId
* Item ID of the item being tested to check if it is an "other" ranged weapon.
*
* @return boolean
*/
public static boolean isItemOtherRanged(int itemId){
for (OTHER_RANGED otherType: OTHER_TYPES){
if (Misc.arrayContains(otherType.itemIds, itemId)) return true;
}
return false;
}
/**
* getOtherType accesses the bow types and if the item corresponding to the item id given is classified as an
* "other" ranged weapon by isItemOtherRanged, it will return the tier of the "other" ranged weapon.
*
* @param itemId
* Item ID of the item that you are trying to get the "other" ranged weapon type of.
*
* @return int
*/
public static int getOtherType(int itemId){
for (OTHER_RANGED otherType: OTHER_TYPES){
if (Misc.arrayContains(otherType.itemIds, itemId)) return otherType.otherRangedWeaponType;
}
return -1;
}
private static int[] NO_AMMO = {4212, 4214, 4215, 4216, 4217, 4218, 4219, 4220, 4221, 4222, 4223, 20171, 20172};
/**
* weaponUsesAmmo checks if the weapon corresponding to the id given uses ammo.
* OTHER_TYPES weapons use ammo, just not bolts/arrows. They use themselves!
*
* @param itemId
* Item ID of the item that you are checking if it uses ammo or not.
*
* @return boolean
*/
public static boolean weaponUsesAmmo(int itemId){
if (Misc.arrayContains(NO_AMMO, itemId)){
return false;
}
return true;
}
/**
* isItemRanged checks if the item corresponding to the id given is classified as a ranged weapon.
*
* @param itemId
* Item ID of the item that you are checking if it is ranged or not.
*
* @return boolean
*/
public static boolean isItemRanged(int itemId){
if (isItemBow(itemId) || isItemCbow(itemId) || isItemOtherRanged(itemId)){
return true;
}
return false;
}
/**
* canUseWeaponWithAmmo checks to see if the weapon corresponding to the id weaponId can be used with the ammo
* corresponding to the id ammoId
*
* @param weaponId
* Item ID of the weapon that you are checking the type of and checking if you can use it with the ammo
* corresponding to the id ammoId
*
* @param ammoId
* Item ID of the ammo that you are checking the type of and checking if you can use it with the weapon
* corresponding to the id weaponId
*
* @return boolean
*/
public static boolean canUseWeaponWithAmmo(int weaponId, int ammoId){
if (isItemRanged(weaponId)){
if (!weaponUsesAmmo(weaponId)){
return true;
}
if (isItemBow(weaponId) && isItemArrow(ammoId)){
return (getBowTier(weaponId) >= getArrowTier(ammoId));
}
if (isItemCbow(weaponId) && isItemBolt(ammoId)){
return (getCbowTier(weaponId) >= getBoltTier(ammoId));
}
}
return false;
}
/*Example ids, not real venemous item ids*/
private static int VENOMOUS_WEP_1 = 1;
private static int VENOMOUS_WEP_2 = 2;
private static int VENOMOUS_WEP_3 = 3;
private static int ETC = 4;
private static int[] VENOMOUS_IDS = {
VENOMOUS_WEP_1, VENOMOUS_WEP_2, VENOMOUS_WEP_3, ETC
};
/**
* isItemVenomous checks if the item has venomous properties.
*
* @param itemId
* Item ID of the item that you are checking if it is venomous.
*
* @return boolean
*/
public static boolean isItemVenomous(int itemId){
if (Misc.arrayContains(VENOMOUS_IDS, itemId)){
return true;
}
return false;
}
private static int[] KP_POISON = {
// Weapons with (kp), cant be cured by antipoison
3170, 3171, 3172, 3173, 3174, 3175, 1376, 4584, 11381, 11388, 11395, 11402, 11409, 11416
};
private static int[] LEVEL_0_POISON = {
// Add custom stuff here
};
private static int[] LEVEL_1_POISON = {
// Add custom stuff here
};
private static int[] LEVEL_2_POISON = {
// Ranged (p) ammo
812, 813, 814, 815, 816, 817, 818, 831, 832, 833, 834, 835, 836, 870, 871, 872, 873, 874, 875, 876, 878, 883,
885, 887, 889, 891, 893, 9287, 9288, 9289, 9290, 9291, 9292, 11227, 11231, 13880, 15958, 15959, 15960, 15961,
15962, 15963, 15964, 15965, 15966, 15967, 15968, 16482, 16487, 16492, 16497, 16502, 16507, 16512, 16517, 16522,
16527, 16532, 21680, 21687, 21694, 21701, 21712, 21719, 21726, 21733
};
private static int[] LEVEL_3_POISON = {
// Ranged (p+) ammo
5616, 5617, 5618, 5619, 5620, 5621, 5628, 5629, 5630, 5631, 5632, 5633, 5634, 5642, 5643, 5644, 5645, 5646,
5647, 5654, 5655, 5656, 5657, 5658, 5660, 5668, 6061, 9293, 9294, 9295, 9296, 9297, 9298, 9299, 11228, 11233,
13881, 13955, 15970, 15971, 15972, 15973, 15974, 15975, 15976, 15977, 15978, 15979, 16537, 16542, 16547, 16552,
16557, 16562, 16567, 16572, 16577, 16582, 16587, 21681, 21688, 21695, 21702, 21713, 21720, 21727, 21734
};
private static int[] LEVEL_4_POISON = {
// Ranged (p++)/(s) ammo
5622, 5623, 5624, 5625, 5626, 5627, 5635, 5636, 5637, 5638, 5639, 5640, 5641, 5648, 5649, 5650, 5651, 5652,
5653, 5661, 5662, 5663, 5664, 5665, 5666, 5667, 6062, 9300, 9301, 9302, 9393, 9304, 9305, 9306, 11229, 11234, 13882,
13956, 15980, 15981, 15982, 15983, 15984, 15985, 15986, 15988, 15988, 15989, 15990, 16592, 16597, 16602, 16607,
16612, 16617, 16622, 16627, 16632, 16637, 16642, 21682, 21689, 21696, 21703, 21714, 21721, 21728, 21735,
// Melee (p) weapons
1219, 1221, 1223, 1225, 1227, 1229, 1231, 1233, 1235, 1251, 1253, 1255, 1257, 1259, 1261, 1263, 4582, 6593, 8874,
11379, 11386, 11393, 11400, 11407, 11414, 13466, 13766, 13771, 13772, 15849, 15853, 15857, 15861, 15865, 15869,
15873, 15877, 15881, 15885, 15889, 16219, 16223, 16227, 16231, 16235, 16239, 16243, 16247, 16251, 16255, 16259,
16759, 16767, 1676775, 16783, 16791, 16799, 16807, 16815, 16816, 16823, 16831, 16839, 17065, 17073, 17081, 17089,
17097, 17105, 17113, 17121, 17129, 17137, 17145
};
private static int[] LEVEL_5_POISON = {
// Melee (p+) weapons
5668, 5670, 5672, 5674, 5676, 5678, 5680, 5682, 5684, 5704, 5706, 5708, 5710, 5712, 5714, 5716, 5734, 6061,
6595, 8876, 11228, 11233, 11382, 11382, 11387, 11392, 11397, 11402, 11407, 11412, 11417, 13467, 13767, 13773,
13774, 15850, 15854, 15858, 15862, 15866, 15870, 15874, 15878, 15882, 15886, 15890, 16220, 16224, 16228, 16232,
16236, 16240, 16244, 16248, 16252, 16256, 16260, 16761, 16769, 16777, 16785, 16793, 16801, 16809, 16817, 16825,
16833, 16841, 17067, 17075, 17083, 17091, 17099, 17107, 17115, 17123, 17131, 17139, 17147
};
private static int[] LEVEL_6_POISON = {
// Melee (p++)/(s) weapons
5686, 5688, 5690, 5692, 5694, 5696, 5698, 5700, 5718, 5720, 5722, 5724, 5726, 5728, 5730, 5732, 5734, 5736,
8878, 10584, 11384, 11391, 11398, 11405, 11412, 11419, 13468, 13768, 13775, 13776, 15851, 15855, 15859, 15863,
15867, 15871, 15875, 15879, 15883, 15887, 15891, 16221, 16225, 16229, 16233, 16237, 16241, 16245, 16249, 16253,
16257, 16261, 16763, 16771, 16779, 16787, 16795, 16803, 16811, 16819, 16827, 16835, 16843, 17069, 17076, 17083,
17090, 17097, 17104, 17111, 17118, 17125, 17132, 17139, 17146,
// (kp) weapons
3170, 3171, 3172, 3173, 3174, 1376, 4584, 11381, 11388, 11395, 11402, 11409, 11416
};
/**
* getItemPoisonLevel gets the item corresponding to itemId's poison level.
* Poison damage applied is equal to the item's poison level.
*
* @param itemId
* Item ID of the item that you are getting the poison level for.
*
* @return int
*/
public static int getItemPoisonLevel(int itemId){
int poisonLevel = 0;
for (int[] poisonArray: new int[][] {LEVEL_0_POISON, LEVEL_1_POISON, LEVEL_2_POISON, LEVEL_3_POISON, LEVEL_4_POISON, LEVEL_5_POISON, LEVEL_6_POISON}){
if (Misc.arrayContains(poisonArray, itemId)){
return poisonLevel;
}
poisonLevel++;
}
return 0;
}
/**
* isItemPoisonous checks if the item has poisonous properties.
*
* @param itemId
* Item ID of the item that you are checking if it is poisonous.
*
* @return boolean
*/
public static boolean isItemPoisonous(int itemId){
for (int[] poisonArray: new int[][] {LEVEL_0_POISON, LEVEL_1_POISON, LEVEL_2_POISON, LEVEL_3_POISON, LEVEL_4_POISON, LEVEL_5_POISON, LEVEL_6_POISON}){
if (Misc.arrayContains(poisonArray, itemId)){
return true;
}
}
return false;
}
/**
* isItemPoisonous checks if the item has karambwan poison applied to it.
*
* @param itemId
* Item ID of the item that you are checking if it has karambwan poison applied to it.
*
* @return boolean
*/
public static boolean isItemKp(int itemId){
return Misc.arrayContains(KP_POISON, itemId);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment