DIR Return Create A Forum - Home
---------------------------------------------------------
RunePalace
HTML https://runepalaceforums.createaforum.com
---------------------------------------------------------
*****************************************************
DIR Return to: Runescape Private Servers Help and Tutorials
*****************************************************
#Post#: 1400--------------------------------------------------
[TUT][PI] Fixing items wield to head [PI][TUT]
By: Hybrid Date: January 7, 2011, 10:47 pm
---------------------------------------------------------
Ok so here is a tutorial to fix Project Insanity's item's
wielding to head bug. Enjoy
Replace your item Class with this
[code]package server.model.items;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import server.Config;
import server.Server;
public class Item {
public static boolean playerCape(int itemId) {
String[] data = {
"cloak", "cape", "Ava's",
};
String item = getItemName(itemId);
if (item == null) {
return false;
}
boolean item1 = false;
for(int i = 0; i < data.length; i++ ) {
if(item.endsWith(data[i]) || item.contains(data[i])) {
item1 = true;
}
}
return item1;
}
public static boolean playerBoots(int itemId) {
String[] data = {
"Shoes", "shoes", "boots", "Boots"
};
String item = getItemName(itemId);
if (item == null) {
return false;
}
boolean item1 = false;
for(int i = 0; i < data.length; i++ ) {
if(item.endsWith(data[i]) || item.contains(data[i])) {
item1 = true;
}
}
return item1;
}
public static boolean playerGloves(int itemId) {
String[] data = {
"Gloves", "gloves", "glove", "Glove", "gauntlets",
"Gauntlets"
};
String item = getItemName(itemId);
if (item == null) {
return false;
}
boolean item1 = false;
for(int i = 0; i < data.length; i++ ) {
if(item.endsWith(data[i]) || item.contains(data[i])) {
item1 = true;
}
}
return item1;
}
public static boolean playerShield(int itemId) {
String[] data = {
"kiteshield", "book", "Kiteshield", "shield", "Shield",
"Kite", "kite", "defender", "xil"
};
String item = getItemName(itemId);
if (item == null) {
return false;
}
boolean item1 = false;
for(int i = 0; i < data.length; i++ ) {
if(item.endsWith(data[i]) || item.contains(data[i])) {
item1 = true;
}
}
return item1;
}
public static boolean playerAmulet(int itemId) {
String[] data = {
"amulet", "Amulet", "necklace", "Necklace", "Pendant",
"pendant", "Symbol", "symbol"
};
String item = getItemName(itemId);
if (item == null) {
return false;
}
boolean item1 = false;
for(int i = 0; i < data.length; i++ ) {
if(item.endsWith(data[i]) || item.contains(data[i])) {
item1 = true;
}
}
return item1;
}
public static boolean playerArrows(int itemId) {
String[] data = {
"Arrows", "arrows", "Arrow", "arrow", "Bolts", "bolts",
"Bolt", "bolt"
};
String item = getItemName(itemId);
if (item == null) {
return false;
}
boolean item1 = false;
for(int i = 0; i < data.length; i++ ) {
if(item.endsWith(data[i]) || item.contains(data[i])) {
item1 = true;
}
}
return item1;
}
public static boolean playerRings(int itemId) {
String[] data = {
"ring", "rings", "Ring", "Rings",
};
String item = getItemName(itemId);
if (item == null) {
return false;
}
boolean item1 = false;
for(int i = 0; i < data.length; i++ ) {
if(item.endsWith(data[i]) || item.contains(data[i])) {
item1 = true;
}
}
return item1;
}
public static boolean playerHats(int itemId) {
String[] data = {
"boater", "cowl", "peg", "coif", "helm",
"coif", "mask", "hat", "headband", "hood",
"disguise", "cavalier", "full helm", "tiara",
"helmet", "Hat", "ears", "partyhat", "helm(t)",
"helm(g)", "beret", "facemask", "sallet",
"hat(g)", "hat(t)", "bandana", "Helm",
};
String item = getItemName(itemId);
if (item == null) {
return false;
}
boolean item1 = false;
for(int i = 0; i < data.length; i++ ) {
if((item.endsWith(data[i]) || item.contains(data[i])) &&
itemId != 4214) {
item1 = true;
}
}
return item1;
}
public static boolean playerLegs(int itemId) {
String[] data = {
"tassets", "chaps", "bottoms", "gown", "trousers",
"platelegs", "robe", "plateskirt", "legs", "leggings",
"shorts", "Skirt", "skirt", "cuisse", "Trousers",
};
String item = getItemName(itemId);
if (item == null) {
return false;
}
boolean item1 = false;
for(int i = 0; i < data.length; i++ ) {
if((item.endsWith(data[i]) || item.contains(data[i])) &&
(!item.contains("top") && (!item.contains("robe (g)") &&
(!item.contains("robe (t)"))))) {
item1 = true;
}
}
return item1;
}
public static boolean playerBody(int itemId) {
String[] data = {
"body", "top", "Priest gown", "apron", "shirt",
"platebody", "robetop", "body(g)", "body(t)",
"Wizard robe (g)", "Wizard robe (t)", "body", "brassard",
"blouse",
"tunic", "leathertop", "Saradomin plate", "chainbody",
"hauberk", "Shirt", "torso", "chestplate",
};
String item = getItemName(itemId);
if (item == null) {
return false;
}
boolean item1 = false;
for(int i = 0; i < data.length; i++ ) {
if(item.endsWith(data[i]) || item.contains(data[i])) {
item1 = true;
}
}
return item1;
}
private static String[] fullbody = {
"top", "chestplate", "shirt","platebody","Ahrims robetop",
"Karils leathertop","brassard","Robe top","robetop",
"platebody (t)","platebody (g)","chestplate",
"torso", "hauberk", "Dragon chainbody"
};
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"
};
private static String[] fullmask = {
"full helm", "mask", "Verac's helm", "Guthan's helm", "Karil's
coif", "mask", "Torag's helm", "sallet", "Saradomin helm",
};
public static boolean isFullBody(int itemId) {
String weapon = getItemName(itemId);
if (weapon == null)
return false;
for (int i = 0; i < fullbody.length; i++) {
if (weapon.endsWith(fullbody[i]) ||
weapon.contains(fullbody[i])) {
return true;
}
}
return false;
}
public static boolean isFullHelm(int itemId) {
String weapon = getItemName(itemId);
if (weapon == null)
return false;
for (int i = 0; i < fullhat.length; i++) {
if (weapon.endsWith(fullhat[i]) && itemId != 2631) {
return true;
}
}
return false;
}
public static boolean isFullMask(int itemId) {
String weapon = getItemName(itemId);
if (weapon == null)
return false;
for (int i = 0; i < fullmask.length; i++) {
if (weapon.endsWith(fullmask[i]) && itemId != 2631) {
return true;
}
}
return false;
}
public static String getItemName(int id) {
for (int j = 0; j < Server.itemHandler.ItemList.length; j++) {
if (Server.itemHandler.ItemList[j] != null)
if (Server.itemHandler.ItemList[j].itemId == id)
return Server.itemHandler.ItemList[j].itemName;
}
return null;
}
public static boolean[] itemStackable = new
boolean[Config.ITEM_LIMIT];
public static boolean[] itemIsNote = new
boolean[Config.ITEM_LIMIT];
public static int[] targetSlots = new
int[Config.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;
} 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) {
if (c == 0) {
itemIsNote[counter] = true;
} else {
itemIsNote[counter] = false;
}
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) {
targetSlots[counter++] = c;
}
dataIn.close();
} catch (IOException e) {
System.out.println("Critical error while loading notedata!
Trace:");
e.printStackTrace();
}
}
}[/code]
Now open ItemAssistant.java and Replace your ItemType method
with this one
[code]public String itemType(int item) {
if(Item.playerCape(item)) {
return "cape";
}
if(Item.playerBoots(item)) {
return "boots";
}
if(Item.playerGloves(item)) {
return "gloves";
}
if(Item.playerShield(item)) {
return "shield";
}
if(Item.playerAmulet(item)) {
return "amulet";
}
if(Item.playerArrows(item)) {
return "arrows";
}
if(Item.playerRings(item)) {
return "ring";
}
if(Item.playerHats(item)) {
return "hat";
}
if(Item.playerLegs(item)) {
return "legs";
}
if(Item.playerBody(item)) {
return "body";
}
return "weapon";
}[/code]
Finally replace the main boolean wear method with this
[code]public boolean wearItem(int wearID, int slot) {
synchronized(c) {
int targetSlot=0;
boolean canWearItem = true;
if(c.playerItems[slot] == (wearID+1)) {
getRequirements(getItemName(wearID).toLowerCase(), wearID);
targetSlot = Item.targetSlots[wearID];
if(itemType(wearID).equalsIgnoreCase("cape")) {
targetSlot=1;
} else if(itemType(wearID).equalsIgnoreCase("hat")) {
targetSlot=0;
} else if(itemType(wearID).equalsIgnoreCase("amulet")) {
targetSlot=2;
} else if(itemType(wearID).equalsIgnoreCase("arrows")) {
targetSlot=13;
} else if(itemType(wearID).equalsIgnoreCase("body")) {
targetSlot=4;
} else if(itemType(wearID).equalsIgnoreCase("shield")) {
targetSlot=5;
} else if(itemType(wearID).equalsIgnoreCase("legs")) {
targetSlot=7;
} else if(itemType(wearID).equalsIgnoreCase("gloves")) {
targetSlot=9;
} else if(itemType(wearID).equalsIgnoreCase("boots")) {
targetSlot=10;
} else if(itemType(wearID).equalsIgnoreCase("ring")) {
targetSlot=12;
} else {
targetSlot = 3;
}
if(c.duelRule[11] && targetSlot == 0) {
c.sendMessage("Wearing hats has been disabled in this
duel!");
return false;
}
if(c.duelRule[12] && targetSlot == 1) {
c.sendMessage("Wearing capes has been disabled in this
duel!");
return false;
}
if(c.duelRule[13] && targetSlot == 2) {
c.sendMessage("Wearing amulets has been disabled in this
duel!");
return false;
}
if(c.duelRule[14] && targetSlot == 3) {
c.sendMessage("Wielding weapons has been disabled in this
duel!");
return false;
}
if(c.duelRule[15] && targetSlot == 4) {
c.sendMessage("Wearing bodies has been disabled in this
duel!");
return false;
}
if((c.duelRule[16] && targetSlot == 5) || (c.duelRule[16] &&
is2handed(getItemName(wearID).toLowerCase(), wearID))) {
c.sendMessage("Wearing shield has been disabled in this
duel!");
return false;
}
if(c.duelRule[17] && targetSlot == 7) {
c.sendMessage("Wearing legs has been disabled in this
duel!");
return false;
}
if(c.duelRule[18] && targetSlot == 9) {
c.sendMessage("Wearing gloves has been disabled in this
duel!");
return false;
}
if(c.duelRule[19] && targetSlot == 10) {
c.sendMessage("Wearing boots has been disabled in this
duel!");
return false;
}
if(c.duelRule[20] && targetSlot == 12) {
c.sendMessage("Wearing rings has been disabled in this
duel!");
return false;
}
if(c.duelRule[21] && targetSlot == 13) {
c.sendMessage("Wearing arrows has been disabled in this
duel!");
return false;
}
if(Config.itemRequirements) {
if(targetSlot == 10 || targetSlot == 7 || targetSlot == 5
|| targetSlot == 4 || targetSlot == 0 || targetSlot == 9 ||
targetSlot == 10) {
if(c.defenceLevelReq > 0) {
if(c.getPA().getLevelForXP(c.playerXP[1]) <
c.defenceLevelReq) {
c.sendMessage("You need a defence level of
"+c.defenceLevelReq+" to wear this item.");
canWearItem = false;
}
}
if(c.rangeLevelReq > 0) {
if(c.getPA().getLevelForXP(c.playerXP[4]) <
c.rangeLevelReq) {
c.sendMessage("You need a range level of
"+c.rangeLevelReq+" to wear this item.");
canWearItem = false;
}
}
if(c.magicLevelReq > 0) {
if(c.getPA().getLevelForXP(c.playerXP[6]) <
c.magicLevelReq) {
c.sendMessage("You need a magic level of
"+c.magicLevelReq+" to wear this item.");
canWearItem = false;
}
}
}
if(targetSlot == 3) {
if(c.attackLevelReq > 0) {
if(c.getPA().getLevelForXP(c.playerXP[0]) <
c.attackLevelReq) {
c.sendMessage("You need an attack level of
"+c.attackLevelReq+" to wield this weapon.");
canWearItem = false;
}
}
if(c.rangeLevelReq > 0) {
if(c.getPA().getLevelForXP(c.playerXP[4]) <
c.rangeLevelReq) {
c.sendMessage("You need a range level of
"+c.rangeLevelReq+" to wield this weapon.");
canWearItem = false;
}
}
if(c.magicLevelReq > 0) {
if(c.getPA().getLevelForXP(c.playerXP[6]) <
c.magicLevelReq) {
c.sendMessage("You need a magic level of
"+c.magicLevelReq+" to wield this weapon.");
canWearItem = false;
}
}
}
}
if(!canWearItem) {
return false;
}
int wearAmount = c.playerItemsN[slot];
if (wearAmount < 1) {
return false;
}
if (targetSlot == c.playerWeapon) {
c.autocasting = false;
c.autocastId = 0;
c.getPA().sendFrame36(108, 0);
}
if(slot >= 0 && wearID >= 0) {
int toEquip = c.playerItems[slot];
int toEquipN = c.playerItemsN[slot];
int toRemove = c.playerEquipment[targetSlot];
int toRemoveN = c.playerEquipmentN[targetSlot];
if (toEquip == toRemove + 1 &&
Item.itemStackable[toRemove]) {
deleteItem(toRemove, getItemSlot(toRemove), toEquipN);
c.playerEquipmentN[targetSlot] += toEquipN;
} else if (targetSlot != 5 && targetSlot != 3) {
c.playerItems[slot] = toRemove + 1;
c.playerItemsN[slot] = toRemoveN;
c.playerEquipment[targetSlot] = toEquip - 1;
c.playerEquipmentN[targetSlot] = toEquipN;
} else if (targetSlot == 5) {
boolean wearing2h =
is2handed(getItemName(c.playerEquipment[c.playerWeapon]).toLower
Case(),
c.playerEquipment[c.playerWeapon]);
boolean wearingShield = c.playerEquipment[c.playerShield]
> 0;
if (wearing2h) {
toRemove = c.playerEquipment[c.playerWeapon];
toRemoveN = c.playerEquipmentN[c.playerWeapon];
c.playerEquipment[c.playerWeapon] = -1;
c.playerEquipmentN[c.playerWeapon] = 0;
updateSlot(c.playerWeapon);
}
c.playerItems[slot] = toRemove + 1;
c.playerItemsN[slot] = toRemoveN;
c.playerEquipment[targetSlot] = toEquip - 1;
c.playerEquipmentN[targetSlot] = toEquipN;
} else if (targetSlot == 3) {
boolean is2h =
is2handed(getItemName(wearID).toLowerCase(), wearID);
boolean wearingShield = c.playerEquipment[c.playerShield]
> 0;
boolean wearingWeapon = c.playerEquipment[c.playerWeapon]
> 0;
if (is2h) {
if (wearingShield && wearingWeapon) {
if (freeSlots() > 0) {
c.playerItems[slot] = toRemove + 1;
c.playerItemsN[slot] = toRemoveN;
c.playerEquipment[targetSlot] = toEquip - 1;
c.playerEquipmentN[targetSlot] = toEquipN;
removeItem(c.playerEquipment[c.playerShield],
c.playerShield);
} else {
c.sendMessage("You do not have enough inventory space
to do this.");
return false;
}
} else if (wearingShield && !wearingWeapon) {
c.playerItems[slot] = c.playerEquipment[c.playerShield]
+ 1;
c.playerItemsN[slot] =
c.playerEquipmentN[c.playerShield];
c.playerEquipment[targetSlot] = toEquip - 1;
c.playerEquipmentN[targetSlot] = toEquipN;
c.playerEquipment[c.playerShield] = -1;
c.playerEquipmentN[c.playerShield] = 0;
updateSlot(c.playerShield);
} else {
c.playerItems[slot] = toRemove + 1;
c.playerItemsN[slot] = toRemoveN;
c.playerEquipment[targetSlot] = toEquip - 1;
c.playerEquipmentN[targetSlot] = toEquipN;
}
} else {
c.playerItems[slot] = toRemove + 1;
c.playerItemsN[slot] = toRemoveN;
c.playerEquipment[targetSlot] = toEquip - 1;
c.playerEquipmentN[targetSlot] = toEquipN;
}
}
resetItems(3214);
}
if(targetSlot == 3) {
c.usingSpecial = false;
addSpecialBar(wearID);
}
if(c.getOutStream() != null && c != null ) {
c.getOutStream().createFrameVarSizeWord(34);
c.getOutStream().writeWord(1688);
c.getOutStream().writeByte(targetSlot);
c.getOutStream().writeWord(wearID+1);
if (c.playerEquipmentN[targetSlot] > 254) {
c.getOutStream().writeByte(255);
c.getOutStream().writeDWord(c.playerEquipmentN[targetSlot]);
} else {
c.getOutStream().writeByte(c.playerEquipmentN[targetSlot]);
}
c.getOutStream().endFrameVarSizeWord();
c.flushOutStream();
}
sendWeapon(c.playerEquipment[c.playerWeapon],
getItemName(c.playerEquipment[c.playerWeapon]));
resetBonus();
getBonus();
writeBonus();
c.getCombat().getPlayerAnimIndex(c.getItems().getItemName(c.play
erEquipment[c.playerWeapon]).toLowerCase());
c.getPA().requestUpdates();
return true;
} else {
return false;
}
}
}[/code]
Hybrid
*****************************************************