Jump to content

kareemloser

Member
  • Content count

    404
  • Joined

  • Last visited

About kareemloser

  • Rank
    Mithril Member
  • Birthday 04/05/1992
  1. [quote name='Fuzen Seth']Another contribrution for me to the project insanity. This is a proper Equipment class. Client.java [code] private Equipment equipment = new Equipment(this); [/code] Add this too with the other getters at Client.java [CODE]public Equipment getEquipment() { return equipment; }[/CODE] Equipment.java [CODE]package server.model.players; import server.Config; import server.Server; import server.model.items.Item; import server.model.items.ItemAssistant; import server.model.players.Client; import server.model.players.PlayerSave; /** * @author Fuzen Seth * [MENTION=98951]infor[/MENTION]mation Represents a proper equipment class. * [MENTION=3199]Sin[/MENTION]ce 23.7.2014 */ public class Equipment { private Client c; public Equipment(Client c) { this.c = c; } /** * slot shield */ public static final String[] SHIELDS = {"spirit shield", "defender", "farseer"}; /** * slot weapon */ public static final String[] WEAPONS = {"rapier", "maul", "staff", "longsword"}; /** * Gets the bonus' of an item. */ public void writeBonus() { int offset = 0; String send = ""; for (int i = 0; i < c.playerBonus.length; i++) { if (c.playerBonus[i] >= 0) { send = BONUS_NAMES[i]+": +"+c.playerBonus[i]; } else { send = BONUS_NAMES[i]+": -"+java.lang.Math.abs(c.playerBonus[i]); } if (i == 10) { offset = 1; } c.getPA().sendFrame126(send, (1675+i+offset)); } } /** * Gets the item name from the item.cfg */ public static String getItemName(int ItemID) { for (int i = 0; i < Config.ITEM_LIMIT; i++) { if (Server.itemHandler.ItemList[i] != null) { if (Server.itemHandler.ItemList[i].itemId == ItemID) { return Server.itemHandler.ItemList[i].itemName; } } } return "Unarmed"; } /** * Gets the item type. */ public String itemType(int item) { for (int i = 0; i < Item.capes.length; i++) { if (item == Item.capes[i]) return "cape"; } for (int i = 0; i < Item.hats.length; i++) { if (item == Item.hats[i]) return "hat"; } for (int i = 0; i < Item.boots.length; i++) { if (item == Item.boots[i]) return "boots"; } for (int i = 0; i < Item.gloves.length; i++) { if (item == Item.gloves[i]) return "gloves"; } for (int i = 0; i < Item.shields.length; i++) { if (item == Item.shields[i]) return "shield"; } for (int i = 0; i < Item.amulets.length; i++) { if (item == Item.amulets[i]) return "amulet"; } for (int i = 0; i < Item.arrows.length; i++) { if (item == Item.arrows[i]) return "arrows"; } for (int i = 0; i < Item.rings.length; i++) { if (item == Item.rings[i]) return "ring"; } for (int i = 0; i < Item.body.length; i++) { if (item == Item.body[i]) return "body"; } for (int i = 0; i < Item.legs.length; i++) { if (item == Item.legs[i]) return "legs"; } return "weapon"; } /** * Item bonuses. **/ public final String[] BONUS_NAMES = { "Stab", "Slash", "Crush", "Magic", "Range", "Stab", "Slash", "Crush", "Magic", "Range", "Strength", "Prayer" }; /** * Resets item bonuses. */ public void resetBonus() { for (int i = 0; i < c.playerBonus.length; i++) { c.playerBonus[i] = 0; } } /** * Weapon requirements. **/ public void getRequirements(String itemName, int itemId) { c.attackLevelReq = c.defenceLevelReq = c.strengthLevelReq = c.rangeLevelReq = c.magicLevelReq = 0; if (itemName.contains("mystic") || itemName.contains("nchanted")) { if (itemName.contains("staff")) { c.magicLevelReq = 20; c.attackLevelReq = 40; } else { c.magicLevelReq = 20; c.defenceLevelReq = 20; } } if (itemName.contains("slayer helmet")) { c.defenceLevelReq = 10; } if (itemName.contains("initiate")) { c.defenceLevelReq = 20; } if (itemName.contains("infinity")) { c.magicLevelReq = 50; c.defenceLevelReq = 25; } if (itemName.contains("splitbark")) { c.magicLevelReq = 40; c.defenceLevelReq = 40; } if (itemName.contains("Black")) { if (itemName.contains("d'hide")) { c.rangeLevelReq = 70; if (itemName.contains("body")) c.defenceLevelReq = 40; return; } } if (itemName.contains("Green")) { if (itemName.contains("hide")) { c.rangeLevelReq = 40; if (itemName.contains("body")) c.defenceLevelReq = 40; return; } } if (itemName.contains("Blue")) { if (itemName.contains("hide")) { c.rangeLevelReq = 50; if (itemName.contains("body")) c.defenceLevelReq = 40; return; } } if (itemName.contains("Red")) { if (itemName.contains("hide")) { c.rangeLevelReq = 60; if (itemName.contains("body")) c.defenceLevelReq = 40; return; } } if (itemName.contains("Black")) { if (itemName.contains("hide")) { c.rangeLevelReq = 70; if (itemName.contains("body")) c.defenceLevelReq = 40; return; } } if (itemName.contains("bronze")) { if (!itemName.contains("knife") && !itemName.contains("dart") && !itemName.contains("javelin") && !itemName.contains("thrownaxe")) { c.attackLevelReq = c.defenceLevelReq = 1; } return; } if (itemName.contains("iron")) { if (!itemName.contains("knife") && !itemName.contains("dart") && !itemName.contains("javelin") && !itemName.contains("thrownaxe")) { c.attackLevelReq = c.defenceLevelReq = 1; } return; } if (itemName.contains("steel")) { if (!itemName.contains("knife") && !itemName.contains("dart") && !itemName.contains("javelin") && !itemName.contains("thrownaxe")) { c.attackLevelReq = c.defenceLevelReq = 5; } return; } if (itemName.contains("black")) { if (!itemName.contains("cavalier") && !itemName.contains("knife") && !itemName.contains("dart") && !itemName.contains("javelin") && !itemName.contains("thrownaxe") && !itemName.contains("vamb") && !itemName.contains("chap")) { c.attackLevelReq = c.defenceLevelReq = 10; } return; } if (itemName.contains("mithril")) { if (!itemName.contains("knife") && !itemName.contains("dart") && !itemName.contains("javelin") && !itemName.contains("thrownaxe")) { c.attackLevelReq = c.defenceLevelReq = 20; } return; } if (itemName.contains("adamant") || itemName.contains("adam")) { if (!itemName.contains("knife") && !itemName.contains("dart") && !itemName.contains("javelin") && !itemName.contains("thrownaxe")) { c.attackLevelReq = c.defenceLevelReq = 30; } return; } if (itemName.contains("rock-shell")) { c.defenceLevelReq = 40; } if (itemName.contains("zamorak")) { if (!itemName.contains("robe") && !itemName.contains("mitre") && !itemName.contains("stole") && !itemName.contains("godsword")) { c.defenceLevelReq = 40; } return; } if (itemName.contains("saradomin")) { if (!itemName.contains("robe") && !itemName.contains("mitre") && !itemName.contains("stole") && !itemName.contains("godsword")) { c.defenceLevelReq = 40; } return; } if (itemName.contains("guthix")) { if (!itemName.contains("robe") && !itemName.contains("mitre") && !itemName.contains("stole") && !itemName.contains("godsword")) { c.defenceLevelReq = 40; } return; } if (itemName.contains("rune")) { if (!itemName.contains("gloves") && !itemName.contains("knife") && !itemName.contains("dart") && !itemName.contains("javelin") && !itemName.contains("thrownaxe") && !itemName.contains("'bow")) { c.attackLevelReq = c.defenceLevelReq = 40; } return; } if (itemName.contains("dragon")) { if (!itemName.contains("nti-") && !itemName.contains("fire")) { c.attackLevelReq = c.defenceLevelReq = 60; return; } } if (itemName.contains("crystal")) { if (itemName.contains("shield")) { c.defenceLevelReq = 70; } else { c.rangeLevelReq = 70; } return; } if (itemName.contains("ahrim")) { if (itemName.contains("staff")) { c.magicLevelReq = 70; c.attackLevelReq = 70; } else { c.magicLevelReq = 70; c.defenceLevelReq = 70; } } if (itemName.contains("karil")) { if (itemName.contains("crossbow")) { c.rangeLevelReq = 70; } else { c.rangeLevelReq = 70; c.defenceLevelReq = 70; } } if (itemName.contains("godsword")) { c.attackLevelReq = 75; } if (itemName.contains("3rd age") && !itemName.contains("amulet")) { c.defenceLevelReq = 60; } if (itemName.contains("Initiate")) { c.defenceLevelReq = 20; } if (itemName.contains("verac") || itemName.contains("guthan") || itemName.contains("dharok") || itemName.contains("torag")) { if (itemName.contains("hammers")) { c.attackLevelReq = 70; c.strengthLevelReq = 70; } else if (itemName.contains("axe")) { c.attackLevelReq = 70; c.strengthLevelReq = 70; } else if (itemName.contains("warspear")) { c.attackLevelReq = 70; c.strengthLevelReq = 70; } else if (itemName.contains("flail")) { c.attackLevelReq = 70; c.strengthLevelReq = 70; } else { c.defenceLevelReq = 70; } } switch (itemId) { case 11720: case 11718: case 11722: c.defenceLevelReq = 70; c.rangeLevelReq = 70; return; case 10887: c.strengthLevelReq = 60; return; case 2497: case 2491: c.rangeLevelReq = 70; return; case 6528: c.strengthLevelReq = 60; return; case 8839: case 8840: case 8842: case 11663: case 11664: case 11665: c.attackLevelReq = 42; c.rangeLevelReq = 42; c.strengthLevelReq = 42; c.magicLevelReq = 42; c.defenceLevelReq = 42; return; case 10551: case 2503: case 2501: case 2499: case 1135: c.defenceLevelReq = 40; return; case 11235: case 6522: c.rangeLevelReq = 60; break; case 6524: c.defenceLevelReq = 60; break; case 11284: c.defenceLevelReq = 75; return; case 6889: case 6914: c.magicLevelReq = 60; break; case 861: c.rangeLevelReq = 50; break; case 10828: c.defenceLevelReq = 55; break; case 11724: case 11726: case 11728: c.defenceLevelReq = 65; break; case 3751: case 3749: case 3755: c.defenceLevelReq = 40; break; case 11283: c.defenceLevelReq = 75; break; case 851: case 853: c.rangeLevelReq = 30; break; case 847: case 849: c.rangeLevelReq = 20; break; case 845: case 843: c.rangeLevelReq = 5; break; case 5698: c.attackLevelReq = 60; break; case 7462: case 7461: c.defenceLevelReq = 40; break; case 8846: c.defenceLevelReq = 5; break; case 8847: c.defenceLevelReq = 10; break; case 8848: c.defenceLevelReq = 20; break; case 8849: c.defenceLevelReq = 30; break; case 8850: c.defenceLevelReq = 40; break; case 7460: c.defenceLevelReq = 40; break; case 837: c.rangeLevelReq = 61; break; case 4151: c.attackLevelReq = 70; return; case 14004: c.attackLevelReq = 75; case 6724: c.rangeLevelReq = 60; return; case 4153: c.attackLevelReq = 50; c.strengthLevelReq = 50; return; } } /** * Finds the item. * */ public int findItem(int id, int[] items, int[] amounts) { for (int i = 0; i < c.playerItems.length; i++) { if (((items[i] - 1) == id) && (amounts[i] > 0)) { return i; } } return -1; } /** * Updates the slot when wielding an item. * * [MENTION=75098]Para[/MENTION]m slot */ public void updateSlot(int slot) { synchronized (c) { if (c.getOutStream() != null && c != null) { c.getOutStream().createFrameVarSizeWord(34); c.getOutStream().writeWord(1688); c.getOutStream().writeByte(slot); c.getOutStream().writeWord(c.playerEquipment[slot] + 1); if (c.playerEquipmentN[slot] > 254) { c.getOutStream().writeByte(255); c.getOutStream().writeDWord(c.playerEquipmentN[slot]); } else { c.getOutStream().writeByte(c.playerEquipmentN[slot]); } c.getOutStream().endFrameVarSizeWord(); c.flushOutStream(); } } } /** * sendEquip **/ public boolean equip(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]; /** * String[] items */ for (String shields : SHIELDS) { if (itemType(wearID).toLowerCase().contains(shields)) { targetSlot = 5; } } for (String weapons : WEAPONS) { if (itemType(wearID).toLowerCase().contains(weapons)) { targetSlot = 0; } } 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; } switch (wearID) { /* Gloves */ case 10336: case 9922: case 8842: targetSlot = 9; break; /* Arrows */ case 9144: targetSlot = 13; break; /* Capes */ case 19111: case 15008: case 9813: case 9747: case 9748: case 9750: case 9790: case 9751: case 9753: case 9754: case 9756: case 9757: case 9759: case 9760: case 9762: case 9763: case 9765: case 9766: case 9768: case 9769: case 9771: case 9772: case 9774: case 9775: case 10446: case 10448: case 10450: case 9777: case 9778: case 9780: case 9781: case 9783: case 9784: case 9786: case 9787: case 9792: case 9793: case 9795: case 9796: case 9798: case 9799: case 9801: case 9802: case 9804: case 9805: case 9807: case 9808: case 9810: case 9811: case 10499: targetSlot = 1; break; /* Arrows */ case 9244: targetSlot = 13; break; /* Boots */ case 15037: case 14605: case 11019: case 9921: case 11728: case 10839: targetSlot = 10; break; /* Legs */ case 11726: case 11722: case 9678: case 9923: case 9676: case 10394: case 8840: case 15035: case 10332: case 15036: case 14603: case 14938: case 14077: case 10346: case 10372: case 10838: case 11022: case 10388: case 10380: case 10340: case 15425: case 13360: case 13352: case 13346: targetSlot = 7; break; /* Amulets */ case 6861: case 6859: case 6863: case 9470: case 14000: case 6857: case 10344: case 11128: targetSlot = 2; break; /* Shields */ case 14502: case 14503: case 8850: case 8849: case 8848: case 8847: case 8846: case 8845: case 8844: case 11283: case 10352: targetSlot = 5; break; /* Bodies */ case 10551: case 10348: case 9674: case 10837: case 14936: case 15034: case 10386: case 10370: case 11720: case 10330: case 15423: case 14076: case 11020: case 14595: case 8839: case 10338: case 13348: case 13354: case 13358: case 9924: case 11724: targetSlot = 4; break; /* Helms */ case 13263: case 9920: case 10507: case 10836: case 10828: case 9672: case 10334: case 10350: case 10390: case 11718: case 10374: case 11021: case 15422: case 15033: case 9925: case 13362: case 11663: case 11664: case 11665: case 13355: case 13350: case 10342: case 1037: case 11335: case 10548: case 9749: case 9752: case 9755: case 9758: case 9761: case 9764: case 9767: case 9770: case 9773: case 9776: case 9779: case 9782: case 9785: case 9788: case 9791: case 9794: case 9797: case 9800: case 9803: case 9806: case 9809: case 9812: targetSlot = 0; break; /* Boots */ case 11732: targetSlot = 10; break; } 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]) .toLowerCase(), 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; } } c.isFullHelm = Item .isFullHelm(c.playerEquipment[c.playerHat]); c.isFullMask = Item .isFullMask(c.playerEquipment[c.playerHat]); c.isFullBody = Item .isFullBody(c.playerEquipment[c.playerChest]); 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.playerEquipment[c.playerWeapon]) .toLowerCase()); c.getPA().requestUpdates(); return true; } else { return false; } } } public void deleteItem(int id, int amount) { deleteItem(id, getItemSlot(id), amount); } public void deleteItem(int id, int slot, int amount) { if (id <= 0 || slot < 0) { return; } if (c.playerItems[slot] == (id + 1)) { if (c.playerItemsN[slot] > amount) { c.playerItemsN[slot] -= amount; } else { c.playerItemsN[slot] = 0; c.playerItems[slot] = 0; } PlayerSave.saveGame(c); resetItems(3214); } } /** * Gets the item slot. * * [MENTION=75098]Para[/MENTION]m ItemID * [MENTION=184045]return[/MENTION] */ public int getItemSlot(int ItemID) { for (int i = 0; i < c.playerItems.length; i++) { if ((c.playerItems[i] - 1) == ItemID) { return i; } } return -1; } /** * Two handed weapon check. **/ public boolean is2handed(String itemName, int itemId) { if (itemName.contains("ahrim") || itemName.contains("karil") || itemName.contains("verac") || itemName.contains("guthan") || itemName.contains("dharok") || itemName.contains("torag")) { return true; } if (itemName.contains("longbow") || itemName.contains("shortbow") || itemName.contains("ark bow")) { return true; } if (itemName.contains("crystal")) { return true; } if (itemName.contains("godsword") || itemName.contains("aradomin sword") || itemName.contains("2h") || itemName.contains("spear")) { return true; } switch (itemId) { case 6724: case 11730: case 4153: case 6528: case 10887: case 11777: return true; } return false; } /** * Checks if you have a free slot. * * [MENTION=184045]return[/MENTION] */ public int freeSlots() { int freeS = 0; for (int i = 0; i < c.playerItems.length; i++) { if (c.playerItems[i] <= 0) { freeS++; } } return freeS; } /** * Gets the item bonus from the item.cfg. */ public void getBonus() { for (int i = 0; i < c.playerEquipment.length; i++) { if (c.playerEquipment[i] > -1) { for (int j = 0; j < Config.ITEM_LIMIT; j++) { if (Server.itemHandler.ItemList[j] != null) { if (Server.itemHandler.ItemList[j].itemId == c.playerEquipment[i]) { for (int k = 0; k < c.playerBonus.length; k++) { c.playerBonus[k] += Server.itemHandler.ItemList[j].Bonuses[k]; } break; } } } } } } /** * Weapon type. **/ public void sendWeapon(int Weapon, String WeaponName) { String WeaponName2 = WeaponName.replaceAll("Bronze", ""); WeaponName2 = WeaponName2.replaceAll("Iron", ""); WeaponName2 = WeaponName2.replaceAll("Steel", ""); WeaponName2 = WeaponName2.replaceAll("Black", ""); WeaponName2 = WeaponName2.replaceAll("Mithril", ""); WeaponName2 = WeaponName2.replaceAll("Adamant", ""); WeaponName2 = WeaponName2.replaceAll("Rune", ""); WeaponName2 = WeaponName2.replaceAll("Granite", ""); WeaponName2 = WeaponName2.replaceAll("Dragon", ""); WeaponName2 = WeaponName2.replaceAll("Drag", ""); WeaponName2 = WeaponName2.replaceAll("Crystal", ""); WeaponName2 = WeaponName2.trim(); /** * Attack styles. */ if (WeaponName.equals("Unarmed")) { c.setSidebarInterface(0, 5855); // punch, kick, block c.getPA().sendFrame126(WeaponName, 5857); } else if (WeaponName.endsWith("whip") || WeaponName.contains("tentacle")) { c.setSidebarInterface(0, 12290); // flick, lash, deflect c.getPA().sendFrame246(12291, 200, Weapon); c.getPA().sendFrame126(WeaponName, 12293); } else if (WeaponName.endsWith("bow") || WeaponName.endsWith("10") || WeaponName.endsWith("full") || WeaponName.startsWith("seercull")) { c.setSidebarInterface(0, 1764); // accurate, rapid, longrange c.getPA().sendFrame246(1765, 200, Weapon); c.getPA().sendFrame126(WeaponName, 1767); } else if (WeaponName.startsWith("Staff") || WeaponName.endsWith("seas") || WeaponName.endsWith("staff") || WeaponName.endsWith("wand")) { c.setSidebarInterface(0, 328); // spike, impale, smash, block c.getPA().sendFrame246(329, 200, Weapon); c.getPA().sendFrame126(WeaponName, 331); } else if (WeaponName2.startsWith("dart") || WeaponName2.startsWith("knife") || WeaponName2.startsWith("javelin") || WeaponName.equalsIgnoreCase("toktz-xil-ul")) { c.setSidebarInterface(0, 4446); // accurate, rapid, longrange c.getPA().sendFrame246(4447, 200, Weapon); c.getPA().sendFrame126(WeaponName, 4449); } else if (WeaponName2.startsWith("dagger") || WeaponName2.contains("anchor") || WeaponName2.contains("sword")) { c.setSidebarInterface(0, 2276); // stab, lunge, slash, block c.getPA().sendFrame246(2277, 200, Weapon); c.getPA().sendFrame126(WeaponName, 2279); } else if (WeaponName2.startsWith("pickaxe")) { c.setSidebarInterface(0, 5570); // spike, impale, smash, block c.getPA().sendFrame246(5571, 200, Weapon); c.getPA().sendFrame126(WeaponName, 5573); } else if (WeaponName2.startsWith("axe") || WeaponName2.startsWith("battleaxe")) { c.setSidebarInterface(0, 1698); // chop, hack, smash, block c.getPA().sendFrame246(1699, 200, Weapon); c.getPA().sendFrame126(WeaponName, 1701); } else if (WeaponName2.startsWith("halberd")) { c.setSidebarInterface(0, 8460); // jab, swipe, fend c.getPA().sendFrame246(8461, 200, Weapon); c.getPA().sendFrame126(WeaponName, 8463); } else if (WeaponName2.startsWith("Scythe")) { c.setSidebarInterface(0, 8460); // jab, swipe, fend c.getPA().sendFrame246(8461, 200, Weapon); c.getPA().sendFrame126(WeaponName, 8463); } else if (WeaponName2.startsWith("spear")) { c.setSidebarInterface(0, 4679); // lunge, swipe, pound, block c.getPA().sendFrame246(4680, 200, Weapon); c.getPA().sendFrame126(WeaponName, 4682); } else if (WeaponName2.toLowerCase().contains("mace")) { c.setSidebarInterface(0, 3796); c.getPA().sendFrame246(3797, 200, Weapon); c.getPA().sendFrame126(WeaponName, 3799); } else if (c.playerEquipment[c.playerWeapon] == 4153) { c.setSidebarInterface(0, 425); // war hammer equip. c.getPA().sendFrame246(426, 200, Weapon); c.getPA().sendFrame126(WeaponName, 428); } else { c.setSidebarInterface(0, 2423); // chop, slash, lunge, block c.getPA().sendFrame246(2424, 200, Weapon); c.getPA().sendFrame126(WeaponName, 2426); } } /** * Removes a wielded item. **/ public void removeItem(int wearID, int slot) { // synchronized(c) { if (c.getOutStream() != null && c != null) { if (c.playerEquipment[slot] > -1) { if (addItem(c.playerEquipment[slot], c.playerEquipmentN[slot])) { c.playerEquipment[slot] = -1; c.playerEquipmentN[slot] = 0; sendWeapon(c.playerEquipment[c.playerWeapon], getItemName(c.playerEquipment[c.playerWeapon])); resetBonus(); getBonus(); writeBonus(); c.getCombat().getPlayerAnimIndex( ItemAssistant .getItemName( c.playerEquipment[c.playerWeapon]) .toLowerCase()); c.getOutStream().createFrame(34); c.getOutStream().writeWord(6); c.getOutStream().writeWord(1688); c.getOutStream().writeByte(slot); c.getOutStream().writeWord(0); c.getOutStream().writeByte(0); c.flushOutStream(); c.updateRequired = true; c.setAppearanceUpdateRequired(true); c.isFullHelm = Item .isFullHelm(c.playerEquipment[c.playerHat]); c.isFullMask = Item .isFullMask(c.playerEquipment[c.playerHat]); c.isFullBody = Item .isFullBody(c.playerEquipment[c.playerChest]); } } } } public boolean playerHasItem(int itemID, int amt, int slot) { itemID++; int found = 0; if (c.playerItems[slot] == (itemID)) { for (int i = 0; i < c.playerItems.length; i++) { if (c.playerItems[i] == itemID) { if (c.playerItemsN[i] >= amt) { return true; } else { found++; } } } if (found >= amt) { return true; } return false; } return false; } public boolean playerHasItem(int itemID) { itemID++; for (int i = 0; i < c.playerItems.length; i++) { if (c.playerItems[i] == itemID) return true; } return false; } public boolean playerHasItem(int itemID, int amt) { itemID++; int found = 0; for (int i = 0; i < c.playerItems.length; i++) { if (c.playerItems[i] == itemID) { if (c.playerItemsN[i] >= amt) { return true; } else { found++; } } } if (found >= amt) { return true; } return false; } public boolean addItem(int item, int amount) { // synchronized(c) { if (amount < 1) { amount = 1; } if (item <= 0) { return false; } if ((((freeSlots() >= 1) || playerHasItem(item, 1)) && Item.itemStackable[item]) || ((freeSlots() > 0) && !Item.itemStackable[item])) { for (int i = 0; i < c.playerItems.length; i++) { if ((c.playerItems[i] == (item + 1)) && Item.itemStackable[item] && (c.playerItems[i] > 0)) { c.playerItems[i] = (item + 1); if (((c.playerItemsN[i] + amount) < Config.MAXITEM_AMOUNT) && ((c.playerItemsN[i] + amount) > -1)) { c.playerItemsN[i] += amount; } else { c.playerItemsN[i] = Config.MAXITEM_AMOUNT; } if (c.getOutStream() != null && c != null) { c.getOutStream().createFrameVarSizeWord(34); c.getOutStream().writeWord(3214); c.getOutStream().writeByte(i); c.getOutStream().writeWord(c.playerItems[i]); if (c.playerItemsN[i] > 254) { c.getOutStream().writeByte(255); c.getOutStream().writeDWord(c.playerItemsN[i]); } else { c.getOutStream().writeByte(c.playerItemsN[i]); } c.getOutStream().endFrameVarSizeWord(); c.flushOutStream(); } i = 30; return true; } } for (int i = 0; i < c.playerItems.length; i++) { if (c.playerItems[i] <= 0) { c.playerItems[i] = item + 1; if ((amount < Config.MAXITEM_AMOUNT) && (amount > -1)) { c.playerItemsN[i] = 1; if (amount > 1) { c.getItems().addItem(item, amount - 1); return true; } } else { c.playerItemsN[i] = Config.MAXITEM_AMOUNT; } resetItems(3214); i = 30; return true; } } return false; } else { resetItems(3214); c.sendMessage("Not enough space in your inventory."); return false; } // } } /** * Empties all of (a) player's items. */ public void resetItems(int WriteFrame) { synchronized (c) { if (c.getOutStream() != null && c != null) { c.getOutStream().createFrameVarSizeWord(53); c.getOutStream().writeWord(WriteFrame); c.getOutStream().writeWord(c.playerItems.length); for (int i = 0; i < c.playerItems.length; i++) { if (c.playerItemsN[i] > 254) { c.getOutStream().writeByte(255); c.getOutStream().writeDWord_v2(c.playerItemsN[i]); } else { c.getOutStream().writeByte(c.playerItemsN[i]); } c.getOutStream().writeWordBigEndianA(c.playerItems[i]); } c.getOutStream().endFrameVarSizeWord(); c.flushOutStream(); } } } /** * Adds special attack bar to special attack weapons. Removes special attack * bar to weapons that do not have special attacks. **/ public void addSpecialBar(int weapon) { switch (weapon) { case 4151: // whip case 14004: c.getPA().sendFrame171(0, 12323); specialAmount(weapon, c.specAmount, 12335); break; case 859: // magic bows case 861: case 11235: c.getPA().sendFrame171(0, 7549); specialAmount(weapon, c.specAmount, 7561); break; case 4587: // dscimmy c.getPA().sendFrame171(0, 7599); specialAmount(weapon, c.specAmount, 7611); break; case 3204: // d hally c.getPA().sendFrame171(0, 8493); specialAmount(weapon, c.specAmount, 8505); break; case 1377: // d battleaxe c.getPA().sendFrame171(0, 7499); specialAmount(weapon, c.specAmount, 7511); break; case 4153: // gmaul c.getPA().sendFrame171(0, 7474); specialAmount(weapon, c.specAmount, 7486); break; case 1249: // dspear c.getPA().sendFrame171(0, 7674); specialAmount(weapon, c.specAmount, 7686); break; case 1215:// dragon dagger case 1231: case 5680: case 5698: case 1305: // dragon long case 11694: case 11698: case 11700: case 11730: case 11696: case 10887: c.getPA().sendFrame171(0, 7574); specialAmount(weapon, c.specAmount, 7586); break; case 1434: // dragon mace c.getPA().sendFrame171(0, 7624); specialAmount(weapon, c.specAmount, 7636); break; default: c.getPA().sendFrame171(1, 7624); // mace interface c.getPA().sendFrame171(1, 7474); // hammer, gmaul c.getPA().sendFrame171(1, 7499); // axe c.getPA().sendFrame171(1, 7549); // bow interface c.getPA().sendFrame171(1, 7574); // sword interface c.getPA().sendFrame171(1, 7599); // scimmy sword interface, for most // swords c.getPA().sendFrame171(1, 8493); c.getPA().sendFrame171(1, 12323); // whip interface break; } } /** * Special attack bar filling amount. **/ public void specialAmount(int weapon, double specAmount, int barId) { c.specBarId = barId; c.getPA().sendFrame70(specAmount >= 10 ? 500 : 0, 0, (--barId)); c.getPA().sendFrame70(specAmount >= 9 ? 500 : 0, 0, (--barId)); c.getPA().sendFrame70(specAmount >= 8 ? 500 : 0, 0, (--barId)); c.getPA().sendFrame70(specAmount >= 7 ? 500 : 0, 0, (--barId)); c.getPA().sendFrame70(specAmount >= 6 ? 500 : 0, 0, (--barId)); c.getPA().sendFrame70(specAmount >= 5 ? 500 : 0, 0, (--barId)); c.getPA().sendFrame70(specAmount >= 4 ? 500 : 0, 0, (--barId)); c.getPA().sendFrame70(specAmount >= 3 ? 500 : 0, 0, (--barId)); c.getPA().sendFrame70(specAmount >= 2 ? 500 : 0, 0, (--barId)); c.getPA().sendFrame70(specAmount >= 1 ? 500 : 0, 0, (--barId)); updateSpecialBar(); sendWeapon(weapon, getItemName(weapon)); } /** * Special attack text. **/ public void updateSpecialBar() { String percent = Double.toString(c.specAmount); if (percent.contains(".")) { percent = percent.replace(".", ""); } if (percent.startsWith("0") && !percent.equals("00")) { percent = percent.replace("0", ""); } if (percent.startsWith("0") && percent.equals("00")) { percent = percent.replace("00", "0"); } c.getPA() .sendFrame126( c.usingSpecial ? "@[email protected] Attack (" + percent + "%)" : "@[email protected] Attack (" + percent + "%)", c.specBarId); } } [/CODE][/QUOTE] hey there, im back to runelocus since a long quit, can you give me the link for the latest project insanity source and client? and the ones with the less bugs and the most completed things and features. thanks!
  2. [quote name='djking96']Il be happy to code for you. Send me a PM if interested. And send me your source+client.[/QUOTE] he dont need to send u the source.. u ask him what he want to do and then u tell him which files u need and then done.. well.... GL :)
  3. [quote name='thefree3']and you was telling me to do not bump ...[/QUOTE] i was telling u u sad dumbass ITS ALLOWED EVERY FREAKING 24 HOURS!!!!!!!!!!!!!!!!!1' WHAT FROM THE SAD THING ABOVE U DONT UNDERSTAND!!!! JUST GTFO!!!!!!!!!!!!!!! U WAS BUMPING EVERY 5 MINS SO SMFD NERD... GTFO MY THREAD. and i dont care if u are my friend irl... ill kick ur ass!
  4. hey, i wanna change my PC protals to spawn ONLY when the game starts! this is what i changed in NPCHandler.java [CODE]case 6142: case 6143: case 6144: case 6145: return 500;[/CODE] what to change here?? like to make a case that if its this npc id is #### so respawn will be started (dunno how to say it ) from the PestControl.java here is my code for the portals in the PestControl.java (the respawn npc) please tell me what to change to make it respawn only when the game starts [CODE]public void spawnNpcs() { Server.npcHandler.spawnNpc2(6142,2628,2591,0,0,200,0,0,100); Server.npcHandler.spawnNpc2(6143,2680,2588,0,0,200,0,0,100); Server.npcHandler.spawnNpc2(6144,2669,2570,0,0,200,0,0,100); Server.npcHandler.spawnNpc2(6145,2645,2569,0,0,200,0,0,100); }[/CODE] what to do so it will be respawned when the Minigame Start?? Please HELP! thanks for help thanks for trying to help... KareemLoser
  5. Still need a LINK to a cache editor that can open a bigger cache!!! please!!!!!
  6. kareemloser

    compiling

    so u fixed it?? ohh and u checked the version in the compiler?
  7. kareemloser

    compiling

    maybe u added it wrong? try doing it again. OR. right click on ur compiler and then click EDIT after that u should see the jdk version in the compiler. change it to ur version. hope i helped :):)
  8. [quote name='jordiee']Erased PK is a PI, Right? EDIT: Okay for a PI, you don't need to have a Cache Editor, If it auto downloaded the cache, go to your C:\ Drive open it and go to "Sprites" If its in the client, just open the Cache file and press "Sprites". Simple.[/QUOTE] thanks but i already did that.. and i didnt find what i want... i can only find it in a cache editor.. like... that login box... i just found the background in the sprites and changed it and i almost changed all of it... only cant find the login box... and i searched in the client for titlebox or somthing like that.. and i got a name and found nothing in the cache.. so please give me a link !!! ty again
  9. hi. i need a cache editor.. NOT A NORMAL 1 CUZ I ALREADY HAVE 2 OF THEM.... i dont need Tom's cache editor cuz i already have it. i need a cache editor that opens bigger caches! im using erasedPkz cache and it wont be opened in a normal cache editor so please help me and give me a LINK FOR A WORKING 1!!! and tell me if u have tested it on erasedpkz cache.... THANKS !!1 KareemLoser,
×