Thread: Dragon Armour Trimming

Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1 Dragon Armour Trimming 
    Banned

    Join Date
    Jun 2012
    Posts
    652
    Thanks given
    233
    Thanks received
    128
    Rep Power
    0
    Well after going through the snippets section and seeing several poor attempts at dragon armour trimming I have decided to just release mine. I didn't notice it until now but godsword making could be added to it(the hilts being added to blade).

    Code:
    package server.model.players.content;
     
    import server.model.players.Client;
    import server.model.items.ItemAssistant;
    import server.util.Misc;
    
    public class Trimming {
    	public static enum TrimmingData {
    		DRAGON_FULL_HELM(19346, 11335, 19336),
    		DRAGON_FULL_HELM2(19354, 11335, 19341),
    		DRAGON_PLATEBODY(19350, 14479, 19337),
    		DRAGON_PLATEBODY2(19358, 14479, 19342),
    		DRAGON_PLATELEGS(19348, 4087, 19338),
    		DRAGON_PLATELEGS2(19356, 4087, 19343),
    		DRAGON_PLATESKIRT(19348, 4585, 19339),
    		DRAGON_PLATESKIRT2(19356, 4585, 19344),
    		DRAGON_SQ_SHIELD(19352, 1187, 19340),
    		DRAGON_SQ_SHIELD2 (19360, 1187, 19345),
    		AMULET_OF_FURY(19333, 6585, 19335);
    		
    		private int set, armour, upgraded;
    		
    		private TrimmingData(final int set, final int armour, final int upgraded) {
    			this.set = set;
    			this.armour = armour;
    			this.upgraded = upgraded;
    		}
    		
    		private int getSet() {
    			return set;
    		}
    		
    		private int getArmour() {
    			return armour;
    		}
    		
    		private int getUpgrade() {
    			return upgraded;
    		}
    		
    		private String getName() {
    			return Misc.optimizeText(toString().toLowerCase().replaceAll("_", " "));
    		}
    	}
    	
    	public static void trimArmour(final Client player, int itemUsed, int useWith) {
    		for(final TrimmingData t: TrimmingData.values()) {
    			if(itemUsed == t.getSet() && useWith == t.getArmour() || itemUsed == t.getArmour() && useWith == t.getSet()) {
    				player.getItems().deleteItem(itemUsed, 1);
    				player.getItems().deleteItem(useWith, 1);
    				player.getItems().addItem(t.getUpgrade(), 1);
    				player.sM("You add trim to your "+t.getName()+".");
    			}
    		}	
    	}
    	
    	public static void dismantleArmour(final Client player, int trimmed) {
    		for(final TrimmingData t: TrimmingData.values()) {
    			if(trimmed == t.getUpgrade()) {
    				player.getItems().deleteItem(t.getUpgrade(), 1);
    				player.getItems().addItem(t.getArmour(), 1);
    				player.getItems().addItem(t.getSet(), 1);
    				player.sM("You remove the trim from your "+t.getName()+".");
    			}
    		}
    	}
    	
    	public static boolean canDismantle(int trim) {
    		for(final TrimmingData t: TrimmingData.values())
    			if(trim == t.getUpgrade())
    				return true;
    			return false;
    	}
    }
    in itemclick2:
    Code:
    if(Trimming.canDismantle(itemId)) {
    			Trimming.dismantleArmour(c, itemId);
    		}
    in useItem in itemonitem method:
    Code:
    Trimming.trimArmour(c, itemUsed, useWith);
    Don't forget to add imports.

    Enjoy.
    Reply With Quote  
     

  2. #2  
    Banned

    Join Date
    Apr 2012
    Age
    27
    Posts
    2,936
    Thanks given
    1,126
    Thanks received
    1,081
    Rep Power
    0
    Reply With Quote  
     

  3. #3  
    Banned

    Join Date
    Jun 2012
    Posts
    652
    Thanks given
    233
    Thanks received
    128
    Rep Power
    0
    Damn you. Totally didnt even notice yours. They are almost the same lol. I'll remove if you want.
    Reply With Quote  
     

  4. #4  
    Father Of Lies


    Join Date
    May 2012
    Age
    26
    Posts
    1,216
    Thanks given
    267
    Thanks received
    289
    Rep Power
    242
    You do know that arrays are loaded faster than enums right? Just decare the arrays as private static final shorts and parse them as ints when you add/delete items
    Reply With Quote  
     

  5. #5  
    Banned

    Join Date
    Apr 2012
    Age
    27
    Posts
    2,936
    Thanks given
    1,126
    Thanks received
    1,081
    Rep Power
    0
    Quote Originally Posted by jakeyy View Post
    You do know that arrays are loaded faster than enums right? Just decare the arrays as private static final shorts and parse them as ints when you add/delete items
    You don't even need to parse them as ints.
    Reply With Quote  
     

  6. Thankful user:


  7. #6  
    Father Of Lies


    Join Date
    May 2012
    Age
    26
    Posts
    1,216
    Thanks given
    267
    Thanks received
    289
    Rep Power
    242
    Quote Originally Posted by Scott Perretta View Post
    You don't even need to parse them as ints.
    woops my mistake

    addItem((int) short, amount );
    Reply With Quote  
     

  8. #7  
    Registered Member

    Join Date
    Apr 2012
    Posts
    762
    Thanks given
    0
    Thanks received
    276
    Rep Power
    213
    Quote Originally Posted by jakeyy View Post
    woops my mistake

    addItem((int) short, amount );
    You don't need to cast either. You only need to cast when going from a higher byte value to a lower byte value. For example;

    private int argument;

    public void test(short argument);

    You would need to do public void test((short) argument). However, if the argument taken was an integer and the actual argument was a short, no casting is needed.
    Reply With Quote  
     

  9. Thankful user:


  10. #8  
    Father Of Lies


    Join Date
    May 2012
    Age
    26
    Posts
    1,216
    Thanks given
    267
    Thanks received
    289
    Rep Power
    242
    ^ Never actually cast shorts before, I just know you had to do it for bytes and doubles so i just assumed
    Reply With Quote  
     

  11. #9  
    Banned
    Join Date
    Aug 2012
    Posts
    808
    Thanks given
    56
    Thanks received
    98
    Rep Power
    0
    Looks good, thanks
    Reply With Quote  
     

  12. #10  
    Donator

    Thock321's Avatar
    Join Date
    Jul 2011
    Posts
    1,804
    Thanks given
    706
    Thanks received
    363
    Rep Power
    416
    Quote Originally Posted by jakeyy View Post
    You do know that arrays are loaded faster than enums right? Just decare the arrays as private static final shorts and parse them as ints when you add/delete items
    It doesn't really matter. The difference is miniscule. Enums are also better because someone else reading your code (or yourself) will know what everything is.
    Reply With Quote  
     

Page 1 of 2 12 LastLast

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. Corrupt Dragon Armour + Weps
    By Josh in forum Models
    Replies: 10
    Last Post: 11-01-2009, 07:34 PM
  2. Ruined Dragon Armour Shard?
    By Re4master8 in forum Models
    Replies: 6
    Last Post: 07-18-2009, 05:43 AM
  3. ruind dragon armour - request
    By dansean in forum Requests
    Replies: 0
    Last Post: 12-01-2008, 12:25 AM
  4. ruind dragon armour - request
    By dansean in forum Models
    Replies: 3
    Last Post: 11-29-2008, 11:58 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
  •