Hi, I'm currently redoing some part of combat but I'm stuck, for some reason it doesn't read all the arrows in the int[] so the bow can only use the first arrow (882 in this case), even tho when I print "System.out.println(data.getAmmo().length);" it says 2 (so it reads all of them). I've put in red what I think causes the problem.
Enum:
Code:
TRAINING_BOW(9705, new int[] { 882, 9706 });
private int weaponId;
private int[] ammoId;
private Weapons(int weaponId, int[] ammoId) {
this.weaponId = weaponId;
this.ammoId = ammoId;
}
public int getWeaponId() {
return weaponId;
}
public int[] getAmmo() {
return ammoId;
}
}
Method:
Code:
public static int isRanging(Player player) {
int weaponId = player.getEquipment().getWeaponId();
if (weaponId == -1) {
return 0;
}
String itemName = ItemDefinitions.getItemDefinitions(weaponId).getName();
if (itemName != null) {
if (itemName.contains("knife") || itemName.contains("dart") || itemName.contains("javelin") || itemName.contains("thrownaxe") || itemName.contains("throwing axe") || itemName.contains("crystal bow") || itemName.equalsIgnoreCase("zaryte bow") || itemName.contains("chinchompa") || itemName.contains("Bolas")) {
return 2;
}
}
for (Weapons data : Weapons.values()) {
for (int i = 0; i < data.getAmmo().length; i++) {
System.out.println(data.getAmmo()[i]);
if (player.getEquipment().getAmmoId() == -1) {
return 3;
}
if (player.getEquipment().getAmmoId() == data.getAmmo()[i]) {
return 2;
}
if (player.getEquipment().getWeaponId() == data.getWeaponId()) {
return 1;
}
}
}
return 0;
}
- Thanks.