Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package dragonkk.rs2rsps.model.player;
- import java.io.Serializable;
- import dragonkk.rs2rsps.model.Container;
- import dragonkk.rs2rsps.model.Item;
- import dragonkk.rs2rsps.rscache.ItemDefinitions;
- public class Equipment implements Serializable{
- private static final long serialVersionUID = -2934091862414178786L;
- private transient Player player;
- public static final byte SLOT_HAT = 0, SLOT_CAPE = 1, SLOT_AMULET = 2, SLOT_WEAPON = 3, SLOT_CHEST = 4, SLOT_SHIELD = 5, SLOT_LEGS = 7, SLOT_HANDS = 9, SLOT_FEET = 10, SLOT_RING = 12, SLOT_ARROWS = 13;
- private Container<Item> equipment = new Container<Item>(15, false);
- public Container<Item> getEquipment() {
- return equipment;
- }
- public void setPlayer(Player player) {
- for(Item item : getEquipment().getItems())
- if(item != null)
- item.setDefinition(ItemDefinitions.forID(item.getId()));
- this.player = player;
- }
- public boolean contains(int item) {
- return equipment.containsOne(new Item(item));
- }
- public void deleteItem(int item, int amount) {
- equipment.remove(new Item(item, amount));
- refresh();
- }
- public Item get(int slot) {
- return equipment.get(slot);
- }
- public void set(int slot, Item item) {
- equipment.set(slot, item);
- //if (slot == 3)
- //reset spec
- refresh();
- }
- public void clear() {
- equipment.clear();
- refresh();
- }
- public void refresh() {
- //if (player.isOnline())
- //player.getActionSender().SendSound(2248,100,0);
- player.getMask().setApperanceUpdate(true);
- player.getFrames().sendItems(94, equipment, false);
- player.getCombatDefinitions().refreshBonuses();
- player.getCombat().removeTarget();
- player.getCombatDefinitions().setSpecialOff();
- }
- private static String[] CAPES = {"druidic cloak", "cape","Cape","Ava's accumulator"};
- private static String[] HATS = {"Air tiara", "tiara", "druidic wreath", "halo", "Royal", "crown", "sallet","helm","hood","coif","Coif","hat","partyhat","Hat","full helm (t)","full helm (g)","hat (t)","hat (g)","cav","boater","helmet","mask","Helm of neitiznot"};
- private static String[] BOOTS = {"boots","Boots", "shoes", "Shoes"};
- private static String[] GLOVES = {"gloves","gauntlets","Gloves","vambraces","vamb","bracers"};
- private static String[] SHIELDS = {"kiteshield","sq shield","Toktz-ket","books","book","kiteshield (t)","kiteshield (g)","kiteshield(h)","defender","shield","Divine spirit shield"};
- private static String[] AMULETS = {"amulet","necklace","Amulet of", "scarf"};
- private static String[] ARROWS = {"Hand cannon shot", "arrow","arrows","arrow(p)","arrow(+)","arrow(s)","bolt","Bolt rack","Opal bolts","Dragon bolts", "bolts (e)", "bolts"};
- private static String[] RINGS = {"ring","Ring"};
- private static String[] BODY = {"Royal shirt", "armour", "hauberk","platebody","chainbody","robetop","leathertop","platemail","top","brassard","Robe top","body","platebody (t)","platebody (g)","body(g)","body_(g)","chestplate","torso","shirt"};
- private static String[] LEGS = {"Royal leggings", "druidic robe", "cuisse", "pants","platelegs","plateskirt","skirt","bottoms","chaps","platelegs (t)","platelegs (g)","bottom","skirt","skirt (g)","skirt (t)","chaps (g)","chaps (t)","tassets","legs", "trousers", "robe bottom"};
- private static String[] WEAPONS = {"Royal sceptre", "Chaotic rapier", "Dragon dagger (p++)", "(p++)", "dagger", "dagger p++", "bow", "Hand cannon","inferno adze", "Dragon","Darklight","wand", "Statius's warhammer", "anchor","spear.", "Vesta's longsword.", "scimitar","longsword","sword","longbow","shortbow","dagger","mace","halberd","spear",
- "Abyssal whip","axe","flail","crossbow","Torags hammers","dagger(p)","dagger(+)","dagger(s)","spear(p)","spear(+)","Dharok's greataxe","Silverlight","dragon axe","dragon hatchet",
- "spear(s)","spear(kp)","maul","dart","dart(p)","javelin","javelin(p)","knife","knife(p)","Longbow","Shortbow",
- "Crossbow","Toktz-xil","Toktz-mej","Tzhaar-ket","staff","Staff","godsword","c'bow","Crystal bow","Dark bow","claws", "warhammer", "adze", "hand", "hatchet"};
- private static String[] FULL_BODY = {"Investigator's coat", "armour", "hauberk", "top","shirt","platebody","Ahrims robetop","Karils leathertop","brassard","Robe top","robetop","platebody (t)","platebody (g)","chestplate","torso", "Morrigan's", "leather body", "chainbody", "Zuriel's", "robe top"};
- private static String[] FULL_HAT = {"sallet", "med helm","coif","Dharoks helm","hood","Initiate helm","Coif","Helm of neitiznot"};
- private static String[] FULL_MASK = {"Christmas ghost hood", "Dragon full helm (or)", "sallet","full helm","mask","Veracs helm","Guthans helm","Torags helm","Karils coif","full helm (t)","full helm (g)","mask"};
- public static int getItemType(int wearId) {
- try {
- String weapon = ItemDefinitions.forID(wearId).name;
- for(int i = 0; i < CAPES.length; i++) {
- if(weapon.contains(CAPES[i]))
- return 1;
- }
- for(int i = 0; i < HATS.length; i++) {
- if(weapon.contains(HATS[i]))
- return 0;
- }
- for(int i = 0; i < BOOTS.length; i++) {
- if(weapon.endsWith(BOOTS[i]) || weapon.startsWith(BOOTS[i]))
- return 10;
- }
- for(int i = 0; i < GLOVES.length; i++) {
- if(weapon.endsWith(GLOVES[i]) || weapon.startsWith(GLOVES[i]))
- return 9;
- }
- for(int i = 0; i < SHIELDS.length; i++) {
- if(weapon.contains(SHIELDS[i]))
- return 5;
- }
- for(int i = 0; i < AMULETS.length; i++) {
- if(weapon.endsWith(AMULETS[i]) || weapon.startsWith(AMULETS[i]))
- return 2;
- }
- for(int i = 0; i < ARROWS.length; i++) {
- if(weapon.endsWith(ARROWS[i]) || weapon.startsWith(ARROWS[i]))
- return 13;
- }
- for(int i = 0; i < RINGS.length; i++) {
- if(weapon.endsWith(RINGS[i]) || weapon.startsWith(RINGS[i]))
- return 12;
- }
- for(int i = 0; i < BODY.length; i++) {
- if(weapon.contains(BODY[i]))
- return 4;
- }
- for(int i = 0; i < LEGS.length; i++) {
- if(weapon.contains(LEGS[i]))
- return 7;
- }
- for(int i = 0; i < WEAPONS.length; i++) {
- if(weapon.endsWith(WEAPONS[i]) || weapon.startsWith(WEAPONS[i]))
- return 3;
- }
- return -1;
- } catch(Exception e) {
- return -1;
- }
- }
- public static boolean isFullBody(ItemDefinitions def) {
- String weapon = def.name;
- for (int i = 0; i < FULL_BODY.length; i++) {
- if (weapon.contains(FULL_BODY[i])) {
- return true;
- }
- }
- return false;
- }
- public static boolean isFullHat(ItemDefinitions def) {
- String weapon = def.name;
- for (int i = 0; i < FULL_HAT.length; i++) {
- if (weapon.endsWith(FULL_HAT[i])) {
- return true;
- }
- }
- return false;
- }
- public static boolean isFullMask(ItemDefinitions def) {
- String weapon = def.name;
- for (int i = 0; i < FULL_MASK.length; i++) {
- if (weapon.endsWith(FULL_MASK[i])) {
- return true;
- }
- }
- return false;
- }
- public static boolean isTwoHanded(ItemDefinitions def) {
- String wepEquiped = def.name;
- int itemId = def.getId();
- if (itemId == 4212)
- return true;
- else if (itemId == 4214)
- return true;
- else if (wepEquiped.endsWith("claws"))
- return true;
- else if (wepEquiped.endsWith("anchor"))
- return true;
- else if (wepEquiped.endsWith("2h sword"))
- return true;
- else if (wepEquiped.endsWith("longbow"))
- return true;
- else if (wepEquiped.equals("Seercull"))
- return true;
- else if (wepEquiped.endsWith("shortbow"))
- return true;
- else if (wepEquiped.endsWith("Longbow"))
- return true;
- else if (wepEquiped.endsWith("Shortbow"))
- return true;
- else if (wepEquiped.endsWith("bow full"))
- return true;
- else if (wepEquiped.equals("Dark bow"))
- return true;
- else if (wepEquiped.endsWith("halberd"))
- return true;
- else if (wepEquiped.equals("Granite maul"))
- return true;
- else if (wepEquiped.equals("Chaotic maul"))
- return true;
- else if (wepEquiped.equals("Karils crossbow"))
- return true;
- else if (wepEquiped.equals("Torags hammers"))
- return true;
- else if (wepEquiped.equals("Veracs flail"))
- return true;
- else if (wepEquiped.equals("Dharok's greataxe"))
- return true;
- else if (wepEquiped.equals("Guthans warspear"))
- return true;
- else if (wepEquiped.equals("Dragon axe"))
- return true;
- else if (wepEquiped.equals("Tzhaar-ket-om"))
- return true;
- else if (wepEquiped.endsWith("godsword"))
- return true;
- else if (wepEquiped.equals("Saradomin sword"))
- return true;
- else
- return false;
- }
- public int getRenderAnim() { //TODO cache sided
- if(get(3) == null)
- return 1426;
- int renderEmote = get(3).getDefinition().renderEmote;
- if(renderEmote != 0)
- return renderEmote;
- return 1426;
- }
- public void setAttStyle() {
- int MaxSize = 3;
- if(player.getEquipment().get(3) == null) {
- MaxSize = 2;
- }else if(player.getEquipment().get(3) != null) {
- } if (player.getCombatDefinitions().getAttackStyle() > MaxSize)
- player.getCombatDefinitions().setAttackStyle((byte) MaxSize);
- player.getFrames().sendConfig(43, player.getAttackStyle());
- }
- public String getAttStyle(ItemDefinitions def) {
- String style = null;
- String wepEquiped = def.name;
- if(player.getEquipment().get(3) == null) {
- switch(player.getAttackStyle()) {
- case 0:
- style = "Attack";
- break;
- case 1:
- style = "Strength";
- break;
- case 2:
- style = "Defence";
- break;
- }
- } else if(player.getEquipment().get(3) != null) {
- if (wepEquiped.endsWith("bow")) {
- switch(player.getCombatDefinitions().getAttackStyle()) {
- case 0:
- style = "Ranged";
- break;
- case 1:
- style = "Ranged";
- break;
- case 2:
- style = "RangedDefence";
- break;
- }
- }else{
- switch(player.getCombatDefinitions().getAttackStyle()) {
- case 0:
- style = "Attack";
- if (wepEquiped.contains("halberd"))
- style = "Shared";
- break;
- case 1:
- style = "Strength";
- if (wepEquiped.contains("whip"))
- style = "Shared";
- break;
- case 2:
- style = "Shared";
- if (wepEquiped.contains("whip") || wepEquiped.contains("Staff") || wepEquiped.contains("staff") || wepEquiped.contains("halberd"))
- style = "Defence";
- else if (wepEquiped.contains("godsword") || wepEquiped.contains("2h sword") || wepEquiped.contains("greataxe"))
- style = "Strength";
- break;
- case 3:
- style = "Defence";
- break;
- }
- }
- }
- return style;
- }
- public void setWeapon() {
- try {
- setAttStyle();
- if(player.getEquipment().get(3) == null) {
- player.getFrames().sendTab(85, 92);
- player.getFrames().sendString("Unarmed", 92, 0);
- return;
- }
- } catch(Exception e) {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement