Thread: Updated ItemDegrading & repairing

Results 1 to 3 of 3
  1. #1 Updated ItemDegrading & repairing 
    Registered Member

    Join Date
    Mar 2011
    Age
    24
    Posts
    548
    Thanks given
    158
    Thanks received
    163
    Rep Power
    220
    Spoiler for ChargesManager:
    Code:
    package com.rs.game.item.itemdegrading;
    
    import java.io.Serializable;
    import java.util.HashMap;
    
    import com.rs.cache.loaders.ItemDefinitions;
    import com.rs.game.Graphics;
    import com.rs.game.Hit;
    import com.rs.game.item.Item;
    import com.rs.game.item.itemdegrading.ItemDegrade.DegradeType;
    import com.rs.game.item.itemdegrading.ItemDegrade.ItemStore;
    import com.rs.game.player.Player;
    import com.rs.utils.Utils;
    
    /**
     * @author -Andreas 1 feb. 2020 13:58:09
     *  @[Only registered and activated users can see links. ] 1. Avalon
     * 
     */
    
    public class ChargesManager implements Serializable {
    
    	private static final long serialVersionUID = -5978513415281726450L;
    
    	private transient Player player;
    
    	private HashMap<Integer, Integer> charges;
    
    	public ChargesManager() {
    		charges = new HashMap<Integer, Integer>();
    	}
    
    	public void setPlayer(Player player) {
    		this.player = player;
    	}
    
    	private static ItemStore[] data = ItemStore.values();
    
    	public void process() {
    		Item[] items = player.getEquipment().getItems().getContainerItems();
    		for (int slot = 0; slot < items.length; slot++) {
    			Item item = items[slot];
    			if (item == null)
    				continue;
    			int defaultCharges = -1;
    			for (ItemStore data : data) {
    				if (data == null || data.getCurrentItem().getId() != item.getId())
    					continue;
    				defaultCharges = data.getTime() != null ? data.getTime().getTicks() : -1;
    				if (defaultCharges == -1)
    					continue;
    				if (data.getType() == DegradeType.WEAR)
    					degrade(item.getId(), defaultCharges, slot);
    				else if (data.getType() == DegradeType.IN_COMBAT
    						&& player.getAttackedByDelay() > Utils.currentTimeMillis())
    					degrade(item.getId(), defaultCharges, slot);
    			}
    		}
    	}
    
    	public void processOutgoingHit() {
    		Item[] items = player.getEquipment().getItems().getContainerItems();
    		for (int slot = 0; slot < items.length; slot++) {
    			Item item = items[slot];
    			if (item == null)
    				continue;
    			int defaultCharges = -1;
    			for (ItemStore data : data) {
    				if (data == null)
    					continue;
    				if (data.getCurrentItem().getId() != item.getId()) {
    					continue;
    				}
    
    				defaultCharges = data.getHits();
    				if (defaultCharges == -1)
    					continue;
    				if (data.getType() == DegradeType.AT_OUTGOING_HIT)
    					degrade(item.getId(), defaultCharges, slot);
    			}
    		}
    	}
    
    	public void processIncommingHit() {
    		Item[] items = player.getEquipment().getItems().getContainerItems();
    		for (int slot = 0; slot < items.length; slot++) {
    			Item item = items[slot];
    			if (item == null)
    				continue;
    			int defaultCharges = -1;
    			for (ItemStore data : data) {
    				if (data == null || data.getCurrentItem().getId() != item.getId())
    					continue;
    				defaultCharges = data.getHits();
    				if (defaultCharges == -1)
    					continue;
    				if (data.getType() == DegradeType.AT_INCOMMING_HIT)
    					degrade(item.getId(), defaultCharges, slot);
    			}
    		}
    	}
    
    	public void processHit(Hit hit) {
    		Item[] items = player.getEquipment().getItems().getContainerItems();
    		for (int slot = 0; slot < items.length; slot++) {
    			Item item = items[slot];
    			if (item == null)
    				continue;
    			int defaultCharges = -1;
    			for (ItemStore data : data) {
    				if (data == null || data.getCurrentItem().getId() != item.getId())
    					continue;
    				defaultCharges = data.getHits();
    				if (defaultCharges == -1)
    					continue;
    				if (data.getType() == DegradeType.HITS)
    					degrade(item.getId(), defaultCharges, slot, hit);
    			}
    		}
    	}
    
    	public int getCharges(int id) {
    		Integer c = charges.get(id);
    		return c == null ? 0 : c;
    	}
    
    	public void resetCharges(int id) {
    		charges.remove(id);
    	}
    
    	public void setCharges(int id, int amount) {
    		charges.put(id, amount);
    	}
    
    	public boolean degrade(Item item) {
    		int defaultCharges = -1;
    		for (ItemStore data : data) {
    			if (data == null)
    				continue;
    			if (data.getCurrentItem().getId() == item.getId()) {
    				defaultCharges = (data.getType() == DegradeType.AT_INCOMMING_HIT
    						|| data.getType() == DegradeType.AT_OUTGOING_HIT) ? data.getHits() : data.getTime().getTicks();
    				if (defaultCharges == -1)
    					return false;
    				charges.put(item.getId(), 1);
    				int newId = data.getBrokenItem() != null ? data.getBrokenItem().getId()
    						: data.getDegradedItem().getId();
    				if (newId != -1) {
    					item.setId(newId);
    					charges.put(newId, 1);
    				} else
    					return true;
    			}
    		}
    		return false;
    	}
    
    	public static final String REPLACE = "##";
    
    	public void checkPercentage(String message, int id, boolean reverse) {
    		int charges = getCharges(id);
    		int maxCharges = 0;
    		for (ItemStore data : data) {
    			if (data == null)
    				continue;
    			if (data.getCurrentItem().getId() == id) {
    				maxCharges = (data.getType() == DegradeType.AT_INCOMMING_HIT
    						|| data.getType() == DegradeType.AT_OUTGOING_HIT) ? data.getHits() : data.getTime().getTicks();
    			}
    		}
    		int percentage = reverse ? (charges == 0 ? 0 : (100 - (charges * 100 / maxCharges)))
    				: charges == 0 ? 100 : (charges * 100 / maxCharges);
    		player.getPackets().sendGameMessage(message.replace(REPLACE, String.valueOf(percentage)));
    	}
    
    	public int getPercentage(int id, boolean reverse) {
    		int charges = getCharges(id);
    		int maxCharges = 0;
    		for (ItemStore data : data) {
    			if (data == null)
    				continue;
    			if (data.getCurrentItem().getId() == id
    					|| (data.getDegradedItem() != null && data.getDegradedItem().getId() == id)) {
    				maxCharges = (data.getType() == DegradeType.AT_INCOMMING_HIT
    						|| data.getType() == DegradeType.AT_OUTGOING_HIT) ? data.getHits() : data.getTime().getTicks();
    			}
    		}
    		int percentage = reverse ? (charges == 0 ? 0 : (100 - (charges * 100 / maxCharges)))
    				: charges == 0 ? 100 : (charges * 100 / maxCharges);
    		return percentage;
    	}
    
    	public void checkCharges(String message, int id) {
    		player.getPackets().sendGameMessage(message.replace(REPLACE, String.valueOf(getCharges(id))));
    	}
    
    	private void degrade(int itemId, int defaultCharges, int slot, Hit hit) {
    		ItemDefinitions itemDef = ItemDefinitions.getItemDefinitions(itemId);
    		Integer c = charges.remove(itemId);
    		Item newItem = null;
    		for (ItemStore data : data) {
    			if (data == null || data.getCurrentItem().getId() != itemId)
    				continue;
    			if (c == null || c == 0)
    				c = data.getHits();
    			int removeHits = hit.getDamage();
    			if (c - removeHits < 1) {
    				removeHits = hit.getDamage() - c;
    				c = data.getHits();
    			}
    			c -= removeHits;
    			if (c > 0) {
    				charges.put(itemId, c);
    			} else {
    				if (data.getDegradedItem() == null) {
    					if (data.getBrokenItem() != null) {
    						newItem = data.getBrokenItem();
    					}
    				} else {
    					if (itemId != data.getDegradedItem().getId()) {
    						newItem = data.getDegradedItem();
    					}
    				}
    				if (newItem == null) {
    					player.getPackets().sendGameMessage("Your " + itemDef.getName() + " turned into dust.");
    				}
    				player.getEquipment().getItems().set(slot, newItem);
    				player.getEquipment().refresh(slot);
    				player.getAppearence().generateAppearenceData();
    			}
    		}
    	}
    
    	private void degrade(int itemId, int defaultCharges, int slot) {
    		ItemDefinitions itemDef = ItemDefinitions.getItemDefinitions(itemId);
    		Integer c = charges.remove(itemId);
    		Item newItem = null;
    		for (ItemStore data : data) {
    			if (data == null || data.getCurrentItem().getId() != itemId)
    				continue;
    			if (c == null || c == 0)
    				c = (data.getType() == DegradeType.AT_INCOMMING_HIT || data.getType() == DegradeType.AT_OUTGOING_HIT)
    						? data.getHits()
    						: data.getTime().getTicks();
    			c--;
    			if (c > 0) {
    				charges.put(itemId, c);
    				if (itemDef.getName().contains("(deg")) {// pvp equipment
    					if (c % (Math.floor(data.getTime().getTicks() * 0.05)) == 0) {// every 5%
    						player.getCharges().checkPercentage(
    								"Your " + itemDef.getName() + " has degraded " + ChargesManager.REPLACE + "%.", itemId,
    								true);
    					}
    				}
    				if (itemId >= 18349 && itemId <= 18363) {// chaotic equipment
    					if (c % (Math.floor(data.getHits() * 0.05)) == 0) {// every 5%
    						player.getCharges().checkPercentage(
    								"Your " + itemDef.getName() + " has " + ChargesManager.REPLACE + "% charges left.",
    								itemId, false);
    					}
    				}
    				if (itemDef.getName().toLowerCase().contains("crystal")) {// crystal equipment
    					if (c % (Math.floor(data.getHits() * 0.05)) == 0) {// every 5%
    						player.getCharges().checkPercentage(
    								"Your " + itemDef.getName() + " has degraded " + ChargesManager.REPLACE + "%.", itemId,
    								true);
    					}
    				}
    			} else {
    				if (data.getDegradedItem() == null) {
    					if (data.getBrokenItem() != null) {
    						newItem = data.getBrokenItem();
    					}
    				} else {
    					if (itemId != data.getDegradedItem().getId()) {
    						newItem = data.getDegradedItem();
    					}
    				}
    				if (newItem == null) {
    					if (itemDef.getName().contains("(deg)")) {
    						if (slot == 0)
    							player.gfx(new Graphics(1859));
    						if (slot == 4)
    							player.gfx(new Graphics(1861));
    						if (slot == 7)
    							player.gfx(new Graphics(1860));
    					}
    					player.getPackets().sendGameMessage("Your " + itemDef.getName() + " turned into dust.");
    				} else {
    					player.getPackets().sendGameMessage("Your " + itemDef.getName() + " degraded.");
    				}
    				player.getEquipment().getItems().set(slot, newItem);
    				player.getEquipment().refresh(slot);
    				player.getAppearence().generateAppearenceData();
    			}
    		}
    	}
    
    }




    Spoiler for ItemDegrade:
    Code:
    package com.rs.game.item.itemdegrading;
    
    import java.util.concurrent.TimeUnit;
    
    import com.rs.game.item.Item;
    
    /**
     * @author -Andreas 1 feb. 2020 13:58:09
     *  @[Only registered and activated users can see links. ] 1. Avalon
     * 
     */
    
    public class ItemDegrade {
    
    	public enum DegradeType {
    
    		WEAR,
    
    		IN_COMBAT,
    
    		AT_OUTGOING_HIT,
    
    		AT_INCOMMING_HIT,
    		
    		HITS;
    	}
    
    	public enum ItemStore {
    
    		/**
    		 *  @[Only registered and activated users can see links. ]Statius
    		 */
    
    		CORRUPT_STATIUS_HELM(new Item(13920), new Item(13922), new DegradeTime(TimeUnit.SECONDS, 30)),
    		CORRUPT_STATIUS_HELM_DEG(new Item(13922), null, new DegradeTime(TimeUnit.MINUTES, 15)),
    		CORRUPT_STATIUS_BODY(new Item(13908), new Item(13910), new DegradeTime(TimeUnit.SECONDS, 30)),
    		CORRUPT_STATIUS_BODY_DEG(new Item(13910), null, new DegradeTime(TimeUnit.MINUTES, 15)),
    		CORRUPT_STATIUS_LEGS(new Item(13914), new Item(13916), new DegradeTime(TimeUnit.SECONDS, 30)),
    		CORRUPT_STATIUS_LEGS_DEG(new Item(13916), null, new DegradeTime(TimeUnit.MINUTES, 15)),
    
    		CORRUPT_STATIUS_WARHAMMER(new Item(13926), new Item(13928), new DegradeTime(TimeUnit.SECONDS, 30)),
    		CORRUPT_STATIUS_WARHAMMER_DEG(new Item(13928), null, new DegradeTime(TimeUnit.MINUTES, 15)),
    
    		/**
    		 *  @[Only registered and activated users can see links. ]Vesta
    		 */
    
    		CORRUPT_VESTA_LONGSWORD(new Item(13923), new Item(13925), new DegradeTime(TimeUnit.SECONDS, 30)),
    		CORRUPT_VESTA_LONGSWORD_DEG(new Item(13925), null, new DegradeTime(TimeUnit.MINUTES, 15)),
    		CORRUPT_VESTA_SPEAR(new Item(13929), new Item(13931), new DegradeTime(TimeUnit.SECONDS, 30)),
    		CORRUPT_VESTA_SPEAR_DEG(new Item(13931), null, new DegradeTime(TimeUnit.MINUTES, 15)),
    
    		CORRUPT_VESTA_BODY(new Item(13911), new Item(13913), new DegradeTime(TimeUnit.SECONDS, 30)),
    		CORRUPT_VESTA_BODY_DEG(new Item(13913), null, new DegradeTime(TimeUnit.MINUTES, 15)),
    		CORRUPT_VESTA_LEGS(new Item(13917), new Item(13919), new DegradeTime(TimeUnit.SECONDS, 30)),
    		CORRUPT_VESTA_LEGS_DEG(new Item(13919), null, new DegradeTime(TimeUnit.MINUTES, 15)),
    
    		/**
    		 *  @[Only registered and activated users can see links. ]Zuriels
    		 */
    
    		CORRUPT_ZURIELS_HOOD(new Item(13938), new Item(13940), new DegradeTime(TimeUnit.SECONDS, 30)),
    		CORRUPT_ZURIELS_HOOD_DEG(new Item(13940), null, new DegradeTime(TimeUnit.MINUTES, 15)),
    		CORRUPT_ZURIELS_TOP(new Item(13932), new Item(13934), new DegradeTime(TimeUnit.SECONDS, 30)),
    		CORRUPT_ZURIELS_TOP_DEG(new Item(13934), null, new DegradeTime(TimeUnit.MINUTES, 15)),
    		CORRUPT_ZURIELS_LEGS(new Item(13935), new Item(13937), new DegradeTime(TimeUnit.SECONDS, 30)),
    		CORRUPT_ZURIELS_LEGS_DEG(new Item(13937), null, new DegradeTime(TimeUnit.MINUTES, 15)),
    
    		CORRUPT_ZURIELS_STAFF(new Item(13941), new Item(13943), new DegradeTime(TimeUnit.SECONDS, 30)),
    		CORRUPT_ZURIELS_STAFF_DEG(new Item(13943), null, new DegradeTime(TimeUnit.MINUTES, 15)),
    
    		/**
    		 *  @[Only registered and activated users can see links. ]Morrigans
    		 */
    		CORRUPT_MORRIGANS_COIF(new Item(13950), new Item(13952), new DegradeTime(TimeUnit.SECONDS, 30)),
    		CORRUPT_MORRIGANS_COIF_DEG(new Item(13952), null, new DegradeTime(TimeUnit.MINUTES, 15)),
    		CORRUPT_MORRIGANS_TOP(new Item(13944), new Item(13946), new DegradeTime(TimeUnit.SECONDS, 30)),
    		CORRUPT_MORRIGANS_TOP_DEG(new Item(13946), null, new DegradeTime(TimeUnit.MINUTES, 15)),
    		CORRUPT_MORRIGANS_CHAPS(new Item(13947), new Item(13949), new DegradeTime(TimeUnit.SECONDS, 30)),
    		CORRUPT_MORRIGANS_CHAPS_DEG(new Item(13949), null, new DegradeTime(TimeUnit.MINUTES, 15)),
    
    		/**
    		 * @Statius
    		 */
    
    		STATIUS_HELM(new Item(13896), new Item(13898), DegradeType.IN_COMBAT, new DegradeTime(TimeUnit.SECONDS, 30)),
    		STATIUS_HELM_DEG(new Item(13898), null, DegradeType.IN_COMBAT, new DegradeTime(TimeUnit.MINUTES, 30)),
    		STATIUS_PLATEBODY(new Item(13884), new Item(14886), DegradeType.IN_COMBAT,
    				new DegradeTime(TimeUnit.SECONDS, 30)),
    		STATIUS_PLATEBODY_DEG(new Item(14886), null, DegradeType.IN_COMBAT, new DegradeTime(TimeUnit.MINUTES, 30)),
    		STATIUS_PLATELEGS(new Item(13890), new Item(13892), DegradeType.IN_COMBAT,
    				new DegradeTime(TimeUnit.SECONDS, 30)),
    		STATIUS_PLATELEGS_DEG(new Item(13892), null, DegradeType.IN_COMBAT, new DegradeTime(TimeUnit.MINUTES, 30)),
    
    		STATIUS_WARHAMMER(new Item(13902), new Item(13904), DegradeType.IN_COMBAT,
    				new DegradeTime(TimeUnit.SECONDS, 30)),
    		STATIUS_WARHAMMER_DEG(new Item(13904), null, DegradeType.IN_COMBAT, new DegradeTime(TimeUnit.MINUTES, 30)),
    
    		/**
    		 *  @[Only registered and activated users can see links. ]
    		 */
    
    		VESTA_CHAINBODY(new Item(13887), new Item(13889), DegradeType.IN_COMBAT, new DegradeTime(TimeUnit.SECONDS, 30)),
    		VESTA_CHAINBODY_DEG(new Item(13889), null, DegradeType.IN_COMBAT, new DegradeTime(TimeUnit.MINUTES, 30)),
    		VESTA_PLATESKIRT(new Item(13893), new Item(13895), DegradeType.IN_COMBAT,
    				new DegradeTime(TimeUnit.SECONDS, 30)),
    		VESTA_PLATESKIRT_DEG(new Item(13895), null, DegradeType.IN_COMBAT, new DegradeTime(TimeUnit.MINUTES, 30)),
    
    		VESTA_LONGSWORD(new Item(13899), new Item(13901), DegradeType.IN_COMBAT, new DegradeTime(TimeUnit.SECONDS, 30)),
    		VESTA_LONGSWORD_DEG(new Item(13901), null, DegradeType.IN_COMBAT, new DegradeTime(TimeUnit.MINUTES, 30)),
    
    		VESTA_SPEAR(new Item(13905), new Item(13907), DegradeType.IN_COMBAT, new DegradeTime(TimeUnit.SECONDS, 30)),
    		VESTA_SPEAR_DEG(new Item(13907), null, DegradeType.IN_COMBAT, new DegradeTime(TimeUnit.MINUTES, 30)),
    
    		/**
    		 *  @[Only registered and activated users can see links. ]s
    		 */
    
    		ZURIELS_HOOD(new Item(13864), new Item(13866), DegradeType.IN_COMBAT, new DegradeTime(TimeUnit.SECONDS, 30)),
    		ZURIELS_HOOD_DEG(new Item(13866), null, DegradeType.IN_COMBAT, new DegradeTime(TimeUnit.MINUTES, 30)),
    		ZURIELS_TOP(new Item(13858), new Item(13860), DegradeType.IN_COMBAT, new DegradeTime(TimeUnit.SECONDS, 30)),
    		ZURIELS_TOP_DEG(new Item(13860), null, DegradeType.IN_COMBAT, new DegradeTime(TimeUnit.MINUTES, 30)),
    		ZURIELS_LEGS(new Item(13861), new Item(13863), DegradeType.IN_COMBAT, new DegradeTime(TimeUnit.SECONDS, 30)),
    		ZURIELS_LEGS_DEG(new Item(13863), null, DegradeType.IN_COMBAT, new DegradeTime(TimeUnit.MINUTES, 30)),
    
    		ZURIELS_STAFF(new Item(13867), new Item(13869), DegradeType.IN_COMBAT, new DegradeTime(TimeUnit.SECONDS, 30)),
    		ZURIELS_STAFF_DEG(new Item(13869), null, DegradeType.IN_COMBAT, new DegradeTime(TimeUnit.MINUTES, 30)),
    
    		/**
    		 *  @[Only registered and activated users can see links. ]s
    		 */
    
    		MORRIGANS_COIF(new Item(13876), new Item(13878), DegradeType.IN_COMBAT, new DegradeTime(TimeUnit.SECONDS, 30)),
    		MORRIGANS_COIF_DEG(new Item(13878), null, DegradeType.IN_COMBAT, new DegradeTime(TimeUnit.MINUTES, 30)),
    		MORRIGANS_BODY(new Item(13870), new Item(13872), DegradeType.IN_COMBAT, new DegradeTime(TimeUnit.SECONDS, 30)),
    		MORRIGANS_BODY_DEG(new Item(13872), null, DegradeType.IN_COMBAT, new DegradeTime(TimeUnit.MINUTES, 30)),
    		MORRIGANS_CHAPS(new Item(13873), new Item(13875), DegradeType.IN_COMBAT, new DegradeTime(TimeUnit.SECONDS, 30)),
    		MORRIGANS_CHAPS_DEG(new Item(13875), null, DegradeType.IN_COMBAT, new DegradeTime(TimeUnit.MINUTES, 30)),
    
    		/**
    		 *  @[Only registered and activated users can see links. ]
    		 */
    
    		AHRIMS_HOOD(new Item(4708), new Item(4856), DegradeType.IN_COMBAT, new Item(4860),
    				new DegradeTime(TimeUnit.SECONDS, 1)),
    		AHRIMS_HOOD_100(new Item(4856), new Item(4857), DegradeType.IN_COMBAT, new Item(4860),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		AHRIMS_HOOD_75(new Item(4857), new Item(4858), DegradeType.IN_COMBAT, new Item(4860),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		AHRIMS_HOOD_50(new Item(4858), new Item(4859), DegradeType.IN_COMBAT, new Item(4860),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		AHRIMS_HOOD_25(new Item(4859), null, DegradeType.IN_COMBAT, new Item(4860),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    
    		AHRIMS_TOP(new Item(4712), new Item(4868), DegradeType.IN_COMBAT, new Item(4872),
    				new DegradeTime(TimeUnit.SECONDS, 1)),
    		AHRIMS_TOP_100(new Item(4868), new Item(4869), DegradeType.IN_COMBAT, new Item(4872),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		AHRIMS_TOP_75(new Item(4869), new Item(4870), DegradeType.IN_COMBAT, new Item(4872),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		AHRIMS_TOP_50(new Item(4870), new Item(4871), DegradeType.IN_COMBAT, new Item(4872),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		AHRIMS_TOP_25(new Item(4871), null, DegradeType.IN_COMBAT, new Item(4872),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    
    		AHRIMS_BOTTOM(new Item(4714), new Item(4874), DegradeType.IN_COMBAT, new Item(4878),
    				new DegradeTime(TimeUnit.SECONDS, 1)),
    		AHRIMS_BOTTOM_100(new Item(4874), new Item(4875), DegradeType.IN_COMBAT, new Item(4878),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		AHRIMS_BOTTOM_75(new Item(4875), new Item(4876), DegradeType.IN_COMBAT, new Item(4878),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		AHRIMS_BOTTOM_50(new Item(4876), new Item(4877), DegradeType.IN_COMBAT, new Item(4878),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		AHRIMS_BOTTOM_25(new Item(4877), null, DegradeType.IN_COMBAT, new Item(4878),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    
    		AHRIMS_STAFF(new Item(4710), new Item(4862), DegradeType.IN_COMBAT, new Item(4866),
    				new DegradeTime(TimeUnit.SECONDS, 1)),
    		AHRIMS_STAFF_100(new Item(4862), new Item(4863), DegradeType.IN_COMBAT, new Item(4866),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		AHRIMS_STAFF_75(new Item(4863), new Item(4864), DegradeType.IN_COMBAT, new Item(4866),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		AHRIMS_STAFF_50(new Item(4864), new Item(4865), DegradeType.IN_COMBAT, new Item(4866),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		AHRIMS_STAFF_25(new Item(4865), null, DegradeType.IN_COMBAT, new Item(4866),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    
    		/**
    		 *  @[Only registered and activated users can see links. ]
    		 */
    
    		DHAROKS_HELM(new Item(4716), new Item(4880), DegradeType.IN_COMBAT, new Item(4884),
    				new DegradeTime(TimeUnit.SECONDS, 1)),
    		DHAROKS_HELM_100(new Item(4880), new Item(4881), DegradeType.IN_COMBAT, new Item(4884),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		DHAROKS_HELM_75(new Item(4881), new Item(4882), DegradeType.IN_COMBAT, new Item(4884),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		DHAROKS_HELM_50(new Item(4882), new Item(4883), DegradeType.IN_COMBAT, new Item(4884),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		DHAROKS_HELM_25(new Item(4883), null, DegradeType.IN_COMBAT, new Item(4884),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    
    		DHAROKS_AXE(new Item(4718), new Item(4886), DegradeType.IN_COMBAT, new Item(4890),
    				new DegradeTime(TimeUnit.SECONDS, 1)),
    		DHAROKS_AXE_100(new Item(4886), new Item(4887), DegradeType.IN_COMBAT, new Item(4890),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		DHAROKS_AXE_75(new Item(4887), new Item(4888), DegradeType.IN_COMBAT, new Item(4890),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		DHAROKS_AXE_50(new Item(4888), new Item(4889), DegradeType.IN_COMBAT, new Item(4890),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		DHAROKS_AXE_25(new Item(4889), null, DegradeType.IN_COMBAT, new Item(4890),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    
    		DHAROKS_PLATEBODY(new Item(4720), new Item(4892), DegradeType.IN_COMBAT, new Item(4896),
    				new DegradeTime(TimeUnit.SECONDS, 1)),
    		DHAROKS_PLATEBODY_100(new Item(4892), new Item(4893), DegradeType.IN_COMBAT, new Item(4896),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		DHAROKS_PLATEBODY_75(new Item(4893), new Item(4894), DegradeType.IN_COMBAT, new Item(4896),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		DHAROKS_PLATEBODY_50(new Item(4894), new Item(4895), DegradeType.IN_COMBAT, new Item(4896),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		DHAROKS_PLATEBODY_25(new Item(4895), null, DegradeType.IN_COMBAT, new Item(4896),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    
    		DHAROKS_PLATELEGS(new Item(4722), new Item(4898), DegradeType.IN_COMBAT, new Item(4902),
    				new DegradeTime(TimeUnit.SECONDS, 1)),
    		DHAROKS_PLATELEGS_100(new Item(4898), new Item(4899), DegradeType.IN_COMBAT, new Item(4902),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		DHAROKS_PLATELEGS_75(new Item(4899), new Item(4900), DegradeType.IN_COMBAT, new Item(4902),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		DHAROKS_PLATELEGS_50(new Item(4900), new Item(4901), DegradeType.IN_COMBAT, new Item(4902),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		DHAROKS_PLATELEGS_25(new Item(4901), null, DegradeType.IN_COMBAT, new Item(4902),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    
    		/**
    		 *  @[Only registered and activated users can see links. ]s
    		 */
    
    		GUTHANS_HELM(new Item(4724), new Item(4904), DegradeType.IN_COMBAT, new Item(4908),
    				new DegradeTime(TimeUnit.SECONDS, 1)),
    		GUTHANS_HELM_100(new Item(4904), new Item(4905), DegradeType.IN_COMBAT, new Item(4908),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		GUTHANS_HELM_75(new Item(4905), new Item(4906), DegradeType.IN_COMBAT, new Item(4908),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		GUTHANS_HELM_50(new Item(4906), new Item(4907), DegradeType.IN_COMBAT, new Item(4908),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		GUTHANS_HELM_25(new Item(4907), null, DegradeType.IN_COMBAT, new Item(4908),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    
    		GUTHANS_SPEAR(new Item(4726), new Item(4910), DegradeType.IN_COMBAT, new Item(4914),
    				new DegradeTime(TimeUnit.SECONDS, 1)),
    		GUTHANS_SPEAR_100(new Item(4910), new Item(4911), DegradeType.IN_COMBAT, new Item(4914),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		GUTHANS_SPEAR_75(new Item(4911), new Item(4912), DegradeType.IN_COMBAT, new Item(4914),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		GUTHANS_SPEAR_50(new Item(4912), new Item(4913), DegradeType.IN_COMBAT, new Item(4914),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		GUTHANS_SPEAR_25(new Item(4913), null, DegradeType.IN_COMBAT, new Item(4914),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    
    		GUTHANS_PLATEBODY(new Item(4728), new Item(4916), DegradeType.IN_COMBAT, new Item(4920),
    				new DegradeTime(TimeUnit.SECONDS, 1)),
    		GUTHANS_PLATEBODY_100(new Item(4916), new Item(4917), DegradeType.IN_COMBAT, new Item(4920),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		GUTHANS_PLATEBODY_75(new Item(4917), new Item(4918), DegradeType.IN_COMBAT, new Item(4920),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		GUTHANS_PLATEBODY_50(new Item(4918), new Item(4919), DegradeType.IN_COMBAT, new Item(4920),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		GUTHANS_PLATEBODY_25(new Item(4919), null, DegradeType.IN_COMBAT, new Item(4920),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    
    		GUTHANS_PLATELEGS(new Item(4730), new Item(4922), DegradeType.IN_COMBAT, new Item(4926),
    				new DegradeTime(TimeUnit.SECONDS, 1)),
    		GUTHANS_PLATELEGS_100(new Item(4922), new Item(4923), DegradeType.IN_COMBAT, new Item(4926),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		GUTHANS_PLATELEGS_75(new Item(4923), new Item(4924), DegradeType.IN_COMBAT, new Item(4926),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		GUTHANS_PLATELEGS_50(new Item(4924), new Item(4925), DegradeType.IN_COMBAT, new Item(4926),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		GUTHANS_PLATELEGS_25(new Item(4925), null, DegradeType.IN_COMBAT, new Item(4926),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    
    		/**
    		 *  @[Only registered and activated users can see links. ]
    		 */
    
    		KARILS_COIF(new Item(4732), new Item(4928), DegradeType.IN_COMBAT, new Item(4932),
    				new DegradeTime(TimeUnit.SECONDS, 1)),
    		KARILS_COIF_100(new Item(4928), new Item(4929), DegradeType.IN_COMBAT, new Item(4932),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		KARILS_COIF_75(new Item(4929), new Item(4930), DegradeType.IN_COMBAT, new Item(4932),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		KARILS_COIF_50(new Item(4930), new Item(4931), DegradeType.IN_COMBAT, new Item(4932),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		KARILS_COIF_25(new Item(4931), null, DegradeType.IN_COMBAT, new Item(4932),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    
    		KARILS_CROSSBOW(new Item(4734), new Item(4934), DegradeType.IN_COMBAT, new Item(4938),
    				new DegradeTime(TimeUnit.SECONDS, 1)),
    		KARILS_CROSSBOW_100(new Item(4934), new Item(4935), DegradeType.IN_COMBAT, new Item(4938),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		KARILS_CROSSBOW_75(new Item(4935), new Item(4936), DegradeType.IN_COMBAT, new Item(4938),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		KARILS_CROSSBOW_50(new Item(4936), new Item(4937), DegradeType.IN_COMBAT, new Item(4938),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		KARILS_CROSSBOW_25(new Item(4937), null, DegradeType.IN_COMBAT, new Item(4938),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    
    		KARILS_TOP(new Item(4736), new Item(4940), DegradeType.IN_COMBAT, new Item(4944),
    				new DegradeTime(TimeUnit.SECONDS, 1)),
    		KARILS_TOP_100(new Item(4940), new Item(4941), DegradeType.IN_COMBAT, new Item(4944),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		KARILS_TOP_75(new Item(4941), new Item(4942), DegradeType.IN_COMBAT, new Item(4944),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		KARILS_TOP_50(new Item(4942), new Item(4943), DegradeType.IN_COMBAT, new Item(4944),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		KARILS_TOP_25(new Item(4943), null, DegradeType.IN_COMBAT, new Item(4944),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    
    		KARILS_SKIRT(new Item(4738), new Item(4946), DegradeType.IN_COMBAT, new Item(4950),
    				new DegradeTime(TimeUnit.SECONDS, 1)),
    		KARILS_SKIRT_100(new Item(4946), new Item(4947), DegradeType.IN_COMBAT, new Item(4950),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		KARILS_SKIRT_75(new Item(4947), new Item(4948), DegradeType.IN_COMBAT, new Item(4950),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		KARILS_SKIRT_50(new Item(4948), new Item(4949), DegradeType.IN_COMBAT, new Item(4950),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		KARILS_SKIRT_25(new Item(4949), null, DegradeType.IN_COMBAT, new Item(4950),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    
    		/**
    		 *  @[Only registered and activated users can see links. ]
    		 */
    
    		TORAGS_HELM(new Item(4745), new Item(4952), DegradeType.IN_COMBAT, new Item(4956),
    				new DegradeTime(TimeUnit.SECONDS, 1)),
    		TORAGS_HELM_100(new Item(4952), new Item(4953), DegradeType.IN_COMBAT, new Item(4956),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		TORAGS_HELM_75(new Item(4953), new Item(4954), DegradeType.IN_COMBAT, new Item(4956),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		TORAGS_HELM_50(new Item(4954), new Item(4955), DegradeType.IN_COMBAT, new Item(4956),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		TORAGS_HELM_25(new Item(4955), null, DegradeType.IN_COMBAT, new Item(4956),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    
    		TORAGS_HAMMERS(new Item(4747), new Item(4958), DegradeType.IN_COMBAT, new Item(4962),
    				new DegradeTime(TimeUnit.SECONDS, 1)),
    		TORAGS_HAMMERS_100(new Item(4958), new Item(4959), DegradeType.IN_COMBAT, new Item(4962),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		TORAGS_HAMMERS_75(new Item(4959), new Item(4960), DegradeType.IN_COMBAT, new Item(4962),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		TORAGS_HAMMERS_50(new Item(4960), new Item(4961), DegradeType.IN_COMBAT, new Item(4962),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		TORAGS_HAMMERS_25(new Item(4961), null, DegradeType.IN_COMBAT, new Item(4962),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    
    		TORAGS_PLATEBODY(new Item(4749), new Item(4964), DegradeType.IN_COMBAT, new Item(4968),
    				new DegradeTime(TimeUnit.SECONDS, 1)),
    		TORAGS_PLATEBODY_100(new Item(4964), new Item(4965), DegradeType.IN_COMBAT, new Item(4968),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		TORAGS_PLATEBODY_75(new Item(4965), new Item(4966), DegradeType.IN_COMBAT, new Item(4968),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		TORAGS_PLATEBODY_50(new Item(4966), new Item(4967), DegradeType.IN_COMBAT, new Item(4968),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		TORAGS_PLATEBODY_25(new Item(4967), null, DegradeType.IN_COMBAT, new Item(4968),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    
    		TORAGS_PLATELEGS(new Item(4751), new Item(4970), DegradeType.IN_COMBAT, new Item(4974),
    				new DegradeTime(TimeUnit.SECONDS, 1)),
    		TORAGS_PLATELEGS_100(new Item(4970), new Item(4971), DegradeType.IN_COMBAT, new Item(4974),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		TORAGS_PLATELEGS_75(new Item(4971), new Item(4972), DegradeType.IN_COMBAT, new Item(4974),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		TORAGS_PLATELEGS_50(new Item(4972), new Item(4973), DegradeType.IN_COMBAT, new Item(4974),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		TORAGS_PLATELEGS_25(new Item(4973), null, DegradeType.IN_COMBAT, new Item(4974),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    
    		/**
    		 *  @[Only registered and activated users can see links. ]cs
    		 */
    
    		VERACS_HELM(new Item(4753), new Item(4976), DegradeType.IN_COMBAT, new Item(4980),
    				new DegradeTime(TimeUnit.SECONDS, 1)),
    		VERACS_HELM_100(new Item(4976), new Item(4977), DegradeType.IN_COMBAT, new Item(4980),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		VERACS_HELM_75(new Item(4977), new Item(4978), DegradeType.IN_COMBAT, new Item(4980),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		VERACS_HELM_50(new Item(4978), new Item(4979), DegradeType.IN_COMBAT, new Item(4980),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		VERACS_HELM_25(new Item(4979), null, DegradeType.IN_COMBAT, new Item(4980),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    
    		VERACS_FLAIL(new Item(4755), new Item(4982), DegradeType.IN_COMBAT, new Item(4986),
    				new DegradeTime(TimeUnit.SECONDS, 1)),
    		VERACS_FLAIL_100(new Item(4982), new Item(4983), DegradeType.IN_COMBAT, new Item(4986),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		VERACS_FLAIL_75(new Item(4983), new Item(4984), DegradeType.IN_COMBAT, new Item(4986),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		VERACS_FLAIL_50(new Item(4984), new Item(4985), DegradeType.IN_COMBAT, new Item(4986),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		VERACS_FLAIL_25(new Item(4985), null, DegradeType.IN_COMBAT, new Item(4986),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    
    		VERACS_BRASSARD(new Item(4757), new Item(4988), DegradeType.IN_COMBAT, new Item(4992),
    				new DegradeTime(TimeUnit.SECONDS, 1)),
    		VERACS_BRASSARD_100(new Item(4988), new Item(4989), DegradeType.IN_COMBAT, new Item(4992),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		VERACS_BRASSARD_75(new Item(4989), new Item(4990), DegradeType.IN_COMBAT, new Item(4992),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		VERACS_BRASSARD_50(new Item(4990), new Item(4991), DegradeType.IN_COMBAT, new Item(4992),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		VERACS_BRASSARD_25(new Item(4991), null, DegradeType.IN_COMBAT, new Item(4992),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    
    		VERACS_SKIRT(new Item(4759), new Item(4994), DegradeType.IN_COMBAT, new Item(4998),
    				new DegradeTime(TimeUnit.SECONDS, 1)),
    		VERACS_SKIRT_100(new Item(4994), new Item(4995), DegradeType.IN_COMBAT, new Item(4998),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		VERACS_SKIRT_75(new Item(4995), new Item(4996), DegradeType.IN_COMBAT, new Item(4998),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		VERACS_SKIRT_50(new Item(4996), new Item(4997), DegradeType.IN_COMBAT, new Item(4998),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    		VERACS_SKIRT_25(new Item(4997), null, DegradeType.IN_COMBAT, new Item(4998),
    				new DegradeTime(TimeUnit.MINUTES, 225)),
    
    		/**
    		 *  @[Only registered and activated users can see links. ]Bow
    		 */
    		NEW_CRYSTAL_BOW(new Item(4212), new Item(4214), DegradeType.AT_OUTGOING_HIT, 1),
    		FULL_CRYSTAL_BOW(new Item(4214), new Item(4215), DegradeType.AT_OUTGOING_HIT, 250),
    		CRYSTAL_BOW_9(new Item(4215), new Item(4216), DegradeType.AT_OUTGOING_HIT, 250),
    		CRYSTAL_BOW_8(new Item(4216), new Item(4217), DegradeType.AT_OUTGOING_HIT, 250),
    		CRYSTAL_BOW_7(new Item(4217), new Item(4218), DegradeType.AT_OUTGOING_HIT, 250),
    		CRYSTAL_BOW_6(new Item(4218), new Item(4219), DegradeType.AT_OUTGOING_HIT, 250),
    		CRYSTAL_BOW_5(new Item(4219), new Item(4220), DegradeType.AT_OUTGOING_HIT, 250),
    		CRYSTAL_BOW_4(new Item(4220), new Item(4221), DegradeType.AT_OUTGOING_HIT, 250),
    		CRYSTAL_BOW_3(new Item(4221), new Item(4222), DegradeType.AT_OUTGOING_HIT, 250),
    		CRYSTAL_BOW_2(new Item(4222), new Item(4223), DegradeType.AT_OUTGOING_HIT, 250),
    		CRYSTAL_BOW_1(new Item(4223), new Item(4207), DegradeType.AT_OUTGOING_HIT, 250),
    
    		/**
    		 *  @[Only registered and activated users can see links. ]hield
    		 */
    		NEW_CRYSTAL_SHIELD(new Item(4224), new Item(4225), DegradeType.AT_INCOMMING_HIT, 1),
    		FULL_CRYSTAL_SHIELD(new Item(4225), new Item(4226), DegradeType.AT_INCOMMING_HIT, 250),
    		CRYSTAL_SHIELD_9(new Item(4226), new Item(4227), DegradeType.AT_INCOMMING_HIT, 250),
    		CRYSTAL_SHIELD_8(new Item(4227), new Item(4228), DegradeType.AT_INCOMMING_HIT, 250),
    		CRYSTAL_SHIELD_7(new Item(4228), new Item(4229), DegradeType.AT_INCOMMING_HIT, 250),
    		CRYSTAL_SHIELD_6(new Item(4229), new Item(4230), DegradeType.AT_INCOMMING_HIT, 250),
    		CRYSTAL_SHIELD_5(new Item(4230), new Item(4231), DegradeType.AT_INCOMMING_HIT, 250),
    		CRYSTAL_SHIELD_4(new Item(4231), new Item(4232), DegradeType.AT_INCOMMING_HIT, 250),
    		CRYSTAL_SHIELD_3(new Item(4232), new Item(4233), DegradeType.AT_INCOMMING_HIT, 250),
    		CRYSTAL_SHIELD_2(new Item(4233), new Item(4234), DegradeType.AT_INCOMMING_HIT, 250),
    		CRYSTAL_SHIELD_1(new Item(4234), new Item(4207), DegradeType.AT_INCOMMING_HIT, 250),
    
    		/**
    		 *  @[Only registered and activated users can see links. ]
    		 */
    
    		CHAOTIC_RAPIER(new Item(18349), new Item(18350), DegradeType.AT_OUTGOING_HIT, 30000),
    
    		CHAOTIC_LONGSWORD(new Item(18351), new Item(18352), DegradeType.AT_OUTGOING_HIT, 30000),
    
    		CHAOTIC_MAUL(new Item(18353), new Item(18354), DegradeType.AT_OUTGOING_HIT, 30000),
    
    		CHAOTIC_STAFF(new Item(18355), new Item(18356), DegradeType.AT_OUTGOING_HIT, 30000),
    
    		CHAOTIC_CROSSBOW(new Item(18357), new Item(18358), DegradeType.AT_OUTGOING_HIT, 30000),
    
    		CHAOTIC_KITESHIELD(new Item(18359), new Item(18360), DegradeType.AT_INCOMMING_HIT, 30000),
    
    		EAGLE_EYE_SHIELD(new Item(18361), new Item(18362), DegradeType.AT_INCOMMING_HIT, 30000),
    
    		FARSEER_SHIELD(new Item(18363), new Item(18364), DegradeType.AT_INCOMMING_HIT, 30000),
    		
    		
    		/**
    		 * Ringofrecoil
    		 */
    		
    		RING_OF_RECOIL(new Item(2550), null, DegradeType.HITS, 400)
    
    		;
    
    		private Item currentItem, degradedItem, brokenItem;
    		private DegradeType type;
    		private DegradeTime time;
    		private int hits;
    
    		private ItemStore(Item currentItem, Item degradedItem, DegradeType type, DegradeTime time) {// non corrupt
    			this(currentItem, degradedItem, type, null, time, -1);
    		}
    
    		private ItemStore(Item currentItem, Item degradedItem, DegradeTime time) {// corrupt
    			this(currentItem, degradedItem, DegradeType.WEAR, null, time, -1);
    		}
    
    		private ItemStore(Item currentItem, Item degradedItem, DegradeType type, Item brokenItem, DegradeTime time) {// barrows
    			this(currentItem, degradedItem, type, brokenItem, time, -1);
    		}
    
    		private ItemStore(Item currentItem, Item degradedItem, DegradeType type, int hits) {// crystal
    			this(currentItem, degradedItem, type, null, null, hits);
    		}
    
    		private ItemStore(Item currentItem, Item degradedItem, DegradeType type, Item brokenItem, DegradeTime time,
    				int hits) {
    			this.currentItem = currentItem;
    			this.degradedItem = degradedItem;
    			this.type = type;
    			this.brokenItem = brokenItem;
    			this.time = time;
    			this.hits = hits;
    		}
    
    		public Item getCurrentItem() {
    			return currentItem;
    		}
    
    		public Item getDegradedItem() {
    			return degradedItem;
    		}
    
    		public Item getBrokenItem() {
    			return brokenItem;
    		}
    
    		public DegradeType getType() {
    			return type;
    		}
    
    		public DegradeTime getTime() {
    			return time;
    		}
    
    		public int getHits() {
    			return hits;
    		}
    	}
    }






    Spoiler for DegradeTime:
    Code:
    package com.rs.game.item.itemdegrading;
    
    import java.util.concurrent.TimeUnit;
    
    public class DegradeTime {
    
    	private long time;
    	private TimeUnit timeUnit;
    
    	DegradeTime(TimeUnit timeUnit, long time) {
    		this.timeUnit = timeUnit;
    		this.time = time;
    	}
    
    	public TimeUnit getUnit() {
    		return timeUnit;
    	}
    
    	public long getTotalTime() {
    		return this.getUnit().toSeconds(time);
    	}
    
    	public int getTicks() {
    		return (int) (this.getUnit().toSeconds(time) / 0.6);
    	}
    }



    Spoiler for RingOfRecoil:
    Code:
        public void handleRingOfRecoil(Player player, Hit hit) {
            if (hit.getLook() != HitLook.MELEE_DAMAGE && hit.getLook() != HitLook.RANGE_DAMAGE
                    && hit.getLook() != HitLook.MAGIC_DAMAGE) {
                return;
            }
            int damage = (int) (hit.getDamage() * 0.1);
            if (target instanceof Player) {
                Player p2 = (Player) target;
                if (p2.getEquipment().getRingId() != 2550 || hit.getDamage() < 10)
                    return;
                Hit finalHit = new Hit(p2, damage > 60 ? 60 : damage, HitLook.REGULAR_DAMAGE);
                player.applyHit(finalHit);
                player.getCharges().processHit(finalHit);
            }
        }


    Spoiler for OnHit:
    Code:
    p2.getCharges().processIncommingHit();
    player.getCharges().processOutgoingHit();



    NOTE: IM WELL AWARE OF THE REPAIRING IS INCORRECT
    Spoiler for ArmourRepair:

    Code:
    package com.rs.game.item.itemdegrading;
    
    import java.util.HashMap;
    import java.util.Map.Entry;
    
    import com.rs.game.item.Item;
    import com.rs.game.player.Player;
    import com.rs.game.player.Skills;
    import com.rs.utils.Utils;
    
    /**
     * @author -Andreas 2 feb. 2020 07:25:41
     *  @[Only registered and activated users can see links. ] 1. Avalon
     * 
     */
    
    public class ArmourRepair {
    
    	private static RepairData[] data = RepairData.values();
    
    	public enum RepairData {
    
    		/*
    		 * broken pieces id, repairtype, repairedId
    		 */
    
    		AHRIMS_HOOD(new int[] { 4856, 4857, 4858, 4859, 4860 }, RepairType.HELMET, 4708),
    
    		AHRIMS_STAFF(new int[] { 4862, 4863, 4864, 4865, 4866 }, RepairType.WEAPON, 4710),
    
    		AHRIMS_TOP(new int[] { 4868, 4869, 4870, 4871, 4872 }, RepairType.BODY, 4712),
    
    		AHRIMS_BOTTOMS(new int[] { 4874, 4875, 4876, 4877, 4878 }, RepairType.LEGS, 4714),
    
    		DHAROKS_HELM(new int[] { 4880, 4881, 4882, 4883, 4884 }, RepairType.HELMET, 4716),
    
    		DHAROKS_AXE(new int[] { 4886, 4887, 4888, 4889, 4890 }, RepairType.WEAPON, 4718),
    
    		DHAROKS_PLATEBODY(new int[] { 4892, 4893, 4894, 4895, 4896 }, RepairType.BODY, 4720),
    
    		DHAROKS_PLATELEGS(new int[] { 4898, 4899, 4900, 4901, 4902 }, RepairType.LEGS, 4722),
    
    		GUTHANS_HELM(new int[] { 4904, 4905, 4906, 4907, 4908 }, RepairType.HELMET, 4724),
    
    		GUTHANS_SPEAR(new int[] { 4910, 4911, 4912, 4913, 4914 }, RepairType.WEAPON, 4726),
    
    		GUTHANS_BODY(new int[] { 4916, 4917, 4918, 4919, 4920 }, RepairType.BODY, 4728),
    
    		GUTHANS_LEGS(new int[] { 4922, 4923, 4924, 4925, 4926 }, RepairType.LEGS, 4730),
    
    		KARILS_COIF(new int[] { 4928, 4929, 4930, 4931, 4932 }, RepairType.HELMET, 4732),
    
    		KARILS_CROSSBOW(new int[] { 4934, 4935, 4936, 4937, 4938 }, RepairType.WEAPON, 4734),
    
    		KARILS_TOP(new int[] { 4940, 4941, 4942, 4943, 4944 }, RepairType.BODY, 4736),
    
    		KARILS_SKIRT(new int[] { 4946, 4947, 4948, 4949, 4950 }, RepairType.LEGS, 4738),
    
    		TORAGS_HELM(new int[] { 4952, 4953, 4954, 4955, 4956 }, RepairType.HELMET, 4745),
    
    		TORAGS_HAMMER(new int[] { 4958, 4959, 4960, 4961, 4962 }, RepairType.WEAPON, 4747),
    
    		TORAGS_PLATEBODY(new int[] { 4964, 4965, 4966, 4967, 4968 }, RepairType.BODY, 4749),
    
    		TORAGS_PLATELEGS(new int[] { 4970, 4971, 4972, 4973, 4974 }, RepairType.LEGS, 4751),
    
    		VERACS_HELM(new int[] { 4976, 4977, 4978, 4979, 4980 }, RepairType.HELMET, 4753),
    
    		VERACS_FLAIL(new int[] { 4982, 4983, 4984, 4985, 4086 }, RepairType.WEAPON, 4755),
    
    		VERACS_BRASSARD(new int[] { 4088, 4089, 4090, 4091, 4092 }, RepairType.BODY, 4757),
    
    		VERACS_SKIRT(new int[] { 4094, 4095, 4096, 4097, 4098 }, RepairType.LEGS, 4759),
    
    		;
    
    		private int[] itemIds;
    		private int repairedId;
    		private RepairType type;
    
    		private RepairData(int[] itemIds, RepairType type, int repairedId) {
    			this.itemIds = itemIds;
    			this.type = type;
    			this.repairedId = repairedId;
    		}
    
    		public int[] getItemIds() {
    			return itemIds;
    		}
    
    		public RepairType getType() {
    			return type;
    		}
    
    		public int getRepairedId() {
    			return repairedId;
    		}
    	}
    
    	private enum RepairType {
    
    		HELMET(new int[] { 12000, 24000, 36000, 48000, 60000 }),
    
    		WEAPON(new int[] { 20000, 40000, 60000, 80000, 100000 }),
    
    		BODY(new int[] { 18000, 36000, 54000, 72000, 90000 }),
    
    		LEGS(new int[] { 16000, 32000, 48000, 64000, 80000 });
    
    		private int[] prices;
    
    		private RepairType(int[] prices) {
    			this.prices = prices;
    		}
    
    		private int[] getPrices() {
    			return prices;
    		}
    	}
    
    	public static double getPriceReduction(int smithingLevel) {
    		return (1.0 - ((double) (smithingLevel / 2) / 100));
    	}
    
    	public static int getTotalPrice(Player player) {
    		int totalPrice = 0;
    		int smithingLevel = player.getSkills().getLevel(Skills.SMITHING);
    		for (Item inventory : player.getInventory().getItems().toArray()) {
    			if (inventory == null)
    				continue;
    			for (RepairData data : data) {
    				if (data == null)
    					continue;
    				int index = 0;
    				for (int id : data.getItemIds()) {
    					if (inventory.getId() == id) {
    						totalPrice += (data.getType().getPrices()[index] * getPriceReduction(smithingLevel));
    					}
    					index++;
    				}
    
    			}
    		}
    		return totalPrice;
    	}
    
    	public static int getPrice(Player player, Item item) {
    		int totalPrice = 0;
    		int smithingLevel = player.getSkills().getLevel(Skills.SMITHING);
    		for (RepairData data : data) {
    			if (data == null)
    				continue;
    			int index = 0;
    			for (int id : data.getItemIds()) {
    				if (item.getId() == id) {
    					totalPrice += (data.getType().getPrices()[index] * getPriceReduction(smithingLevel));
    				}
    				index++;
    			}
    		}
    		return totalPrice;
    	}
    
    	public static void repairAllItems(Player player) {
    		HashMap<Item, Integer> itemRepairs = new HashMap<>();
    		int totalPrice = getTotalPrice(player);
    		for (Item inventory : player.getInventory().getItems().toArray()) {
    			if (inventory == null)
    				continue;
    			for (RepairData data : data) {
    				if (data == null)
    					continue;
    				for (int id : data.getItemIds()) {
    					if (inventory.getId() == id) {
    						itemRepairs.put(inventory, data.getRepairedId());
    					}
    				}
    			}
    		}
    		if (itemRepairs.isEmpty()) {
    			player.sm("You don't have any items to repair.");
    			return;
    		}
    		if (player.canBuy(totalPrice)) {
    			for (Entry<Item, Integer> repairItems : itemRepairs.entrySet()) {
    				player.getInventory().deleteItem(repairItems.getKey());
    				player.getInventory().addItem(new Item(repairItems.getValue()));
    			}
    			player.sm("All your items has been repaired.");
    		} else {
    			player.sm("You don't have enough coins to repair all items.");
    			player.sm("You need at least " + Utils.getFormattedNumber(totalPrice, ',') + " coins.");
    		}
    	}
    
    	public static void repairItem(Player player, Item item, boolean stand) {
    		int price = getPrice(player, item);
    		for (RepairData data : data) {
    			if (data == null)
    				continue;
    			for (int id : data.getItemIds()) {
    				if (item.getId() == id) {
    					if (player.canBuy(price)) {
    						player.getInventory().deleteItem(item);
    						player.getInventory().addItem(data.getRepairedId(), 1);
    						player.sm(stand ? "You repair your " + item.getName() + " on the armour stand." : "Bob has repaired your " + item.getName() + ".");
    					} else {
    						player.sm("You don't have enough coins to repair all items.");
    						player.sm("You need at least " + Utils.getFormattedNumber(price, ',') + " coins.");
    					}
    				}
    			}
    		}
    	}
    }
    AvalonPK Developer
    Reply With Quote  
     

  2. Thankful user:


  3. #2  
    Respected Member


    Luke132's Avatar
    Join Date
    Dec 2007
    Age
    32
    Posts
    12,530
    Thanks given
    166
    Thanks received
    5,385
    Rep Power
    5000
    good work bro

    Reply With Quote  
     

  4. #3  
    Registered Member
    Join Date
    Sep 2020
    Posts
    12
    Thanks given
    3
    Thanks received
    3
    Rep Power
    29
    Hey man, nice work.

    Just wanted to point a few things out to spread some knowledge.

    Hashmaps

    If the data you want to represent does not naturally represent mappings, hashmap would be a poor choice of data structure. For example if you had say a list of numbers or strings. Any kind of map would be a poor way to implement as well as poor performance.

    If your map has immutable keys and a decent hashcode implementation then hashmap would be worthy.

    If you want your map keys to be iterated over in a specific order, you can use a TreeMap, if you want them to be visited based on the order they were inserted, then you guessed it.. LinkedHashMap.

    In your case if you want to perform lookups using exact object being used (in your case integer), use IdentityHashMap.

    Hashmaps can be more expensive than you think, you can argue here that this degrade manager is per player and represent a mapping between and item id and its degrade counter.

    I'm not here to point out design flaws in your code, just spreading some knowledge that may better you as a programmer in Java.

    My solution which I have implemented may be both easier and more efficient.

    In my model which represents an Item in game,

    Code:
    private int degrade;
    When you construct an item using its id (amount is 0, degrade is 0). If you construct with a degrade, the degrade value is set. Consider the following

    Code:
    	public Item(final int id, final int amount, final int degrade) {
    		this(id, amount);
    		this.degrade = degrade;
    	}
    You have the general setters and getters too.

    With this, when you equip an item that is corrupted and degrades whilst worn, upon equipping such an item, you replace the item with the corrupted (deg) item id (through an enumerated set of data with their ids, degrade timer etc). Now if you were to remove the item and place it in your inventory/bank, the data for degrade is attached to that instance of the item. So you won't lose out on the data on the item as long as when you copy it over you use the constructor with the degrade such as the following

    Code:
    	@Override
    	public void place(Item item, int slot) {
    		if (item != null) {
    			Item replace = player.getItemDegradeManager().onEquip(item);
    			if (replace != null && replace.getId() != item.getId()) {
    				player.sendMessage("Your " + item.getName() + " has degraded.");
    				item = new Item(replace.getId(), replace.getAmount(), replace.getDegradeLimit());
    				update();
    			}
    		}
    		super.place(item, slot);
    	}
    This here is my method for placing an item into a player's equipment container. As you can see no data is lost and the same functionality will be applied when banking. Say for example corrupted vesta's platebody (deg), had 100 ticks left till it is turned to dust. When you equip it from inventory, it will resume the timer from 100 ticks. If you were to bank it and later take it out of your bank, when in your inventory that item will have the data that it has 100 ticks remaining.

    Of course as you can imagine, when you save a player whether it be a SQL database, MongoDB, a file or whatever, their inventory, equipment, bank etc are all saved and when saving the item, the item will have the data for the degrade so both you and player will know how long it has left on it. The same variable can be used for items that degrade on impact such as the barrows equipment or the non corrupted vesta's equipment apart from the fact a little different logic is used in barrows but the variable used is still

    Code:
    private int degrade;
    Here is an example of how barrows item is degraded upon combat for the first time they use it

    Code:
    	if (!barrowsItem.hasDegraded(item.getId())) {
    			int oneHundredId = barrowsItem.getIdFromDegradeStage(item.getId(), 
    					BarrowsDegradeStage.ONE_HUNDRED);
    			Item newItem = new Item(oneHundredId, 1, FIFTEEN_HOURS);
    			if (item.getId() != newItem.getId()) {
    				player.getEquipment().place(newItem, equipmentSlot.getSlot());
    				player.getEquipment().update();
    				sendBarrowsDegradeMessage(equipmentSlot, name);
    			}
    		}
    Hope this was all helpful!
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Lonelyisle update
    By SandyBridge in forum Downloads
    Replies: 6
    Last Post: 12-10-2007, 05:32 PM
  2. Marius MegaPack v1.1 (Updated)
    By Chimeric in forum Tools
    Replies: 19
    Last Post: 08-01-2007, 02:34 AM
  3. SOTM III Update
    By Bullet in forum General
    Replies: 2
    Last Post: 03-28-2007, 06:20 PM
  4. Replies: 0
    Last Post: 12-26-2006, 06:36 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •