This is starting to get gay seriously
Seriously people this is startin to get mentaly retarded now...
Yours can simply do diffent methods for a wield item what will make ur code alot more cleaner easyer to use and then using XML files for the level req and ****...
Code:
private void wieldItem(Player player, InvItem item) {
String youNeed = "";
for(Entry<Integer, Integer> e : item.getWieldableDef().getStatsRequired()) {
if(player.getMaxStat(e.getKey()) < e.getValue()) {
youNeed += ((Integer)e.getValue()).intValue() + " " + Formulae.statArray[((Integer)e.getKey()).intValue()] + ", ";
}
}
if(!youNeed.equals("")) {
player.getActionSender().sendMessage("You must have at least " + youNeed.substring(0, youNeed.length() - 2) + " to use this item.");
return;
}
if(EntityHandler.getItemWieldableDef(item.getID()).femaleOnly() && player.isMale()) {
player.getActionSender().sendMessage("Quit the cross-dressing.");
return;
}
ArrayList<InvItem> items = player.getInventory().getItems();
for(InvItem i : items) {
if(item.wieldingAffectsItem(i) && i.isWielded()) {
unWieldItem(player, i, false);
}
}
item.setWield(true);
player.getActionSender().sendSound("click");
}
And a formuale.java add a
Code:
public static final String[] statArray = {"attack", "defense", "strength", "hits", "ranged", "prayer", "magic", "cooking", "woodcut", "fletching", "fishing", "firemaking", "crafting", "smithing", "mining", "herblaw", "agility", "thieving", "RuneCrafting", "summoing"};
add the rest i cba
then get the statindex
Code:
public static int getStatIndex(String stat) {
for(int index = 0;index < statArray.length;index++) {
if(stat.equalsIgnoreCase(statArray[index])) {
return index;
}
}
return -1;
}
and set your itemwieldabledef.xml to somthink like this..
that is the id of the item
type of item
Code:
<wieldPos>4</wieldPos>
Body position the item
Code:
<armourPoints>0</armourPoints>
<weaponAimPoints>8</weaponAimPoints>
<weaponPowerPoints>8</weaponPowerPoints>
<magicPoints>0</magicPoints>
<prayerPoints>0</prayerPoints>
<rangePoints>0</rangePoints>
What stats the weapon gives you
Code:
<requiredStats>
</requiredStats>
Required stats is basicly somthink like this
Code:
<requiredStats>
<entry>
<int>17</int>
<int>50</int>
</entry>
</requiredStats>
First one is the stat ID and the section one is the stat level needed
also u will need this
Code:
import java.util.HashMap;
import java.util.Set;
import java.util.Map.Entry;
/**
* The definition wrapper for items
*/
public class ItemWieldableDef {
/**
* Type of item
*/
public int type;
/**
* Body position the item is drawn on
*/
private int wieldPos;
/**
* How many armour points should be given
*/
public int armourPoints;
/**
* How many weapon aim points should be given
*/
public int weaponAimPoints;
/**
* How many weapon power points should be given
*/
public int weaponPowerPoints;
/**
* How many magic points should be given
*/
public int magicPoints;
/**
* How many prayer points should be given
*/
public int prayerPoints;
/**
* How many range points should be given
*/
public int rangePoints;
/**
* The level of each stat required to wield
*/
public HashMap<Integer, Integer> requiredStats;
/**
* If the item can only be worn by females (used for female plates)
*/
private boolean femaleOnly;
public int getType() {
return type;
}
public int[] getAffectedTypes() {
int[] affectedTypes = EntityHandler.getItemAffectedTypes(type);
if(affectedTypes != null) {
return affectedTypes;
}
return new int[0];
}
public int getWieldPos() {
return wieldPos;
}
public int getArmourPoints() {
return armourPoints;
}
public int getWeaponAimPoints() {
return weaponAimPoints;
}
public int getWeaponPowerPoints() {
return weaponPowerPoints;
}
public int getMagicPoints() {
return magicPoints;
}
public int getPrayerPoints() {
return prayerPoints;
}
public int getRangePoints() {
return rangePoints;
}
public Set<Entry<Integer, Integer>> getStatsRequired() {
return requiredStats.entrySet();
}
public boolean femaleOnly() {
return femaleOnly;
}
}
Enjoi your life on geting better lol....
u can also do a simple command checker to :p i.e here
Code:
<ItemDef>
<name>Big Bones</name>
<description>Ew it's a pile of bones</description>
<command>Bury</command>
<sprite>137</sprite>
<basePrice>1</basePrice>
<stackable>false</stackable>
<wieldable>false</wieldable>
<pictureMask>0</pictureMask>
</ItemDef>
What will lead out if you want to do a code to it is this
Code:
if(item.getDef().getCommand().equalsIgnoreCase("bury")) {
player.setBusy(true);
player.getActionSender().sendMessage("You dig a hole in the ground.");
world.getDelayedEventHandler().add(new MiniEvent(player) {
public void action() {
owner.getActionSender().sendMessage("You bury the " + item.getDef().getName() + ".");
owner.getInventory().remove(item);
switch(item.getID()) {
case 20: // Bones
case 604: // Bat bones
owner.incExp(5, 8, true);
break;
case 413: // Big bones
owner.incExp(5, 24, true);
break;
case 814: // Dragon bones
owner.incExp(5, 90, true);
break;
}
owner.getActionSender().sendStat(5);
owner.getActionSender().sendInventory();
owner.setBusy(false);
}
});
}
With a basic command checker from a xml file heres the
itemdef.java
Code:
/**
* The definition wrapper for items
*/
public class ItemDef extends EntityDef {
/**
* The command of the object
*/
public String command;
/**
* The base price of the object
*/
public int basePrice;
/**
* Whether the item is stackable or not
*/
public boolean stackable;
/**
* Whether the item is wieldable or not
*/
public boolean wieldable;
public String getCommand() {
return command;
}
public int getBasePrice() {
return basePrice;
}
public boolean isStackable() {
return stackable;
}
public boolean isWieldable() {
return wieldable;
}
}