Nice Job.
|
Requirements: Event Handler http://www.rune-server.org/runescape...t-handler.html
Difficulty: Low
Create a new class DegradingSystem
Add the enum inside it:
This will store the items which degrade when the player is in combat. I have added two so you can copy the format for adding more later.Code:private enum DegradeData { DH_HELM(4716, 4880,Player.playerHat), DH_HELM2(4880, 4881,Player.playerHat); private int initItem, finalItem,slot; /** * @return the initItem */ public int getInitItem() { return initItem; } /** * @return the finalItem */ public int getFinalItem() { return finalItem; } /** * @return the slot */ public int getSlot() { return slot; } DegradeData(int initItem, int finalItem, int slot) { this.initItem = initItem; this.finalItem = finalItem; this.slot=slot; } }
Next we will make a method which uses the data to do the degrading. Add this method directly under the enum.
This line:Code:public static boolean setupDegrade(final Client c){ for (final DegradeData dd: DegradeData.values()){ if(c.playerEquipment[dd.getSlot()]==dd.getInitItem()){ CycleEventHandler.getSingleton().addEvent(c, new CycleEvent(){ @Override public void execute( CycleEventContainer container) { if(c.playerEquipment[dd.getSlot()]!=dd.getInitItem()){ container.stop(); return; } c.playerEquipment[dd.getSlot()]=dd.getFinalItem(); c.getActionSender().sendMessage("Your armour has degraded."); c.getItems().updateSlot(dd.getSlot()); container.stop(); } @Override public void stop() { // TODO Auto-generated method stub } }, 5);//thats 5 game ticks until the next degrade is called } } return false; }simply grabs the data in the enum DegradeData.Code:for (final DegradeData dd: DegradeData.values()){
Close DegradeSystem class and open CombatAssistant. Inside attackNpc method find the following lines similar to these:
and directly above that add this:Code:if (c.attackTimer <= 0) { boolean usingBow = false; boolean usingArrows = false; boolean usingOtherRangeWeapons = false;
Now you have a basic degrading system implemented. Make sure you import the necessary packages.Code:if(DegradingSystem.setupDegrade(c)){ //hook }
Bugs: The item can be stalled from degrading by simply the player removing the item every second or switching with another item that does not degrade to preserve the full stats of the degradable item.
Nice Job.
Hmmm, may put good use to this, thanks for contributing.
A hashmap would be a much better alternative to this to prevent looping every time a player is hit, nonetheless a good release.
nice
Thanks for contributing, a simple start.
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |