Thread: [PI]Armour Degrading Base[PI]

Results 1 to 9 of 9
  1. #1 [PI]Armour Degrading Base[PI] 
    Registered Member
    Join Date
    Apr 2012
    Posts
    83
    Thanks given
    79
    Thanks received
    52
    Rep Power
    30



    Requirements: Event Handler http://www.rune-server.org/runescape...t-handler.html
    Difficulty: Low

    Create a new class DegradingSystem

    Add the enum inside it:
    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;
    	}
    
    
        }
    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.
    Next we will make a method which uses the data to do the degrading. Add this method directly under the enum.
    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;
        }
    This line:
    Code:
    for (final DegradeData dd: DegradeData.values()){
    simply grabs the data in the enum DegradeData.

    Close DegradeSystem class and open CombatAssistant. Inside attackNpc method find the following lines similar to these:
    Code:
    if (c.attackTimer <= 0) {
    				boolean usingBow = false;
    				boolean usingArrows = false;
    				boolean usingOtherRangeWeapons = false;
    and directly above that add this:
    Code:
    if(DegradingSystem.setupDegrade(c)){
    			    //hook
    			}
    Now you have a basic degrading system implemented. Make sure you import the necessary packages.

    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.
    Reply With Quote  
     

  2. #2  
    The One And Only

    01053's Avatar
    Join Date
    Apr 2011
    Age
    28
    Posts
    2,887
    Thanks given
    417
    Thanks received
    885
    Rep Power
    856
    Nice Job.


    Reply With Quote  
     

  3. #3  
    Registered Member cannabiss's Avatar
    Join Date
    Nov 2013
    Posts
    379
    Thanks given
    9
    Thanks received
    21
    Rep Power
    19
    Hmmm, may put good use to this, thanks for contributing.
    Reply With Quote  
     

  4. #4  
    need java lessons
    Eclipse's Avatar
    Join Date
    Aug 2012
    Posts
    4,436
    Thanks given
    686
    Thanks received
    898
    Rep Power
    490
    or just calculate the amount of times the player is hit while wearing that armour.

    Quote Originally Posted by jerryrocks317 View Post
    i am 14 and have my own laptop im on almost 24/7 currently creating rsps lol so please get off my thread lol
    Reply With Quote  
     

  5. #5  
    Registered Member
    Join Date
    Jan 2014
    Posts
    308
    Thanks given
    115
    Thanks received
    57
    Rep Power
    0
    A hashmap would be a much better alternative to this to prevent looping every time a player is hit, nonetheless a good release.
    Spoiler for Charlie Sheen ft Lil B:

    Every derep I ever got was from a butthurt bitch I shut down.
    Reply With Quote  
     

  6. Thankful user:


  7. #6  
    Registered Member
    Join Date
    Apr 2012
    Posts
    83
    Thanks given
    79
    Thanks received
    52
    Rep Power
    30
    Quote Originally Posted by ProjectPvP View Post
    A hashmap would be a much better alternative to this to prevent looping every time a player is hit, nonetheless a good release.
    I will check it out thanks
    Reply With Quote  
     

  8. #7  
    Banned

    Join Date
    Jun 2013
    Posts
    938
    Thanks given
    462
    Thanks received
    171
    Rep Power
    0
    nice
    Reply With Quote  
     

  9. #8  
    Registered Member Grown's Avatar
    Join Date
    Oct 2012
    Posts
    838
    Thanks given
    650
    Thanks received
    86
    Rep Power
    54
    Thanks for contributing, a simple start.
    "Programs aren’t just built in one go, like a bridge. They are talked about,
    sketched out, prototyped, played with, refactored, tuned, tested, tweaked,
    deleted, rewritten....
    A program is not built; it is grown.
    Because a program is always growing and always changing, it must be written
    with change in mind."
    Reply With Quote  
     

  10. #9  
    Registered Member
    Join Date
    Dec 2010
    Posts
    354
    Thanks given
    17
    Thanks received
    61
    Rep Power
    47
    Quote Originally Posted by Calendar View Post
    or just calculate the amount of times the player is hit while wearing that armour.

    ^ This would be a lot better because you wouldn't be needing to use tasks and this doesn't make sense because you can keep switching off your armour and on.
    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. [Pi] PvP Armour - Degrading to (deg)
    By Skarlett in forum Help
    Replies: 4
    Last Post: 06-15-2013, 06:58 AM
  2. nex armors degrade base [pi] with fixing
    By hi im paul in forum Tutorials
    Replies: 22
    Last Post: 06-17-2012, 02:30 AM
  3. Cleaner Armour Exchange Base [PI]
    By relex lawl in forum Snippets
    Replies: 4
    Last Post: 04-21-2012, 05:08 PM
  4. [PI] Trivia Bot Base [PI]
    By T3rminator in forum Help
    Replies: 4
    Last Post: 04-01-2012, 09:17 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •