Thread: Skill guides better handling (Need help)

Page 1 of 2 12 LastLast
Results 1 to 10 of 13
  1. #1 Skill guides better handling (Need help) 
    Banned
    Join Date
    Sep 2017
    Posts
    340
    Thanks given
    24
    Thanks received
    30
    Rep Power
    0
    Hello i'm trying to get this crap code less crap and more capable what i need it for.

    Currently each skill guide can handle 8 items per skill and thats not enough and the repeat code is just horrible can someone point me out how to hadle this more properly? And easier to add new items into skill guide thanks in advance!

    Code:
    public static void farmingInterface(final Player Player) {
    		SkillGuides.skillsInterface(Player, "Farming",
    				5291, 1, "Guam seed",
    				5292, 15, "Marrentill seed",
    				5293, 20, "Tarromin seed",
    				5295, 30, "Ranarr seed",
    				5298, 40, "Avanote seed",
    				5300, 60, "Snapdragon seed",
    				5302, 72, "Lantadyme seed",
    				5304, 90, "Torsol seed");
    	}
    Code:
    private static int item[] = new int[31];
    	
    	public static void skillsInterface(final Player Player, final String skill,
    			final int item1ItemId, final int item1lvl, final String item1lvldef,
    			final int item2ItemId, final int item2lvl, final String item2lvldef,
    			final int item3ItemId, final int item3lvl, final String item3lvldef,
    			final int item4ItemId, final int item4lvl, final String item4lvldef,
    			final int item5ItemId, final int item5lvl, final String item5lvldef,
    			final int item6ItemId, final int item6lvl, final String item6lvldef,
    			final int item7ItemId, final int item7lvl, final String item7lvldef,
    			final int item8ItemId, final int item8lvl, final String item8lvldef) {
    	
    
    		Player.send(new SendString("@[email protected]"+skill, 8716));
    		for(int i = 0;i<31;i++) {
    			SkillGuides.item[i] = 0;
    		}
    		SkillGuides.item[0] = item1ItemId;
    		SkillGuides.item[1] = item2ItemId;
    		SkillGuides.item[2] = item3ItemId;
    		SkillGuides.item[3] = item4ItemId;
    		SkillGuides.item[4] = item5ItemId;
    		SkillGuides.item[5] = item6ItemId;
    		SkillGuides.item[6] = item7ItemId;
    		SkillGuides.item[7] = item8ItemId;
    		if(item1lvl > 0) {
    			Player.send(new SendString(""+item1lvl,8720));
    		}
    		Player.send(new SendString(""+item1lvldef,8760));
    		if(item2lvl > 0) {
    			Player.send(new SendString(""+item2lvl,8721));
    		}
    		Player.send(new SendString(""+item2lvldef, 8761));
    		if(item3lvl > 0) {
    			Player.send(new SendString(""+item3lvl,8722));
    		}
    		Player.send(new SendString(""+item3lvldef,8762));
    		if(item4lvl > 0) {
    			Player.send(new SendString(""+item4lvl,8723));
    		}
    		Player.send(new SendString(""+item4lvldef, 8763));
    		if(item5lvl > 0) {
    			Player.send(new SendString(""+item5lvl,8724));
    		}
    		Player.send(new SendString(""+item5lvldef, 8764));
    		if(item6lvl > 0) {
    			Player.send(new SendString(""+item6lvl,8725));
    		}
    		Player.send(new SendString(""+item6lvldef,8765));
    		if(item7lvl > 0) {
    			Player.send(new SendString(""+item7lvl,8726));
    		}
    		Player.send(new SendString(""+item7lvldef, 8766));
    		if(item8lvl > 0) {
    			Player.send(new SendString(""+item8lvl,8727));
    		}
    		Player.send(new SendString(""+item8lvldef, 8767));
    		Player.send(new SendString("",8849));
    		Player.send(new SendString("Attack",8846));
    		Player.send(new SendString("Strength",8823));
    		Player.send(new SendString("Defence",8824));
    		Player.send(new SendString("Hitpoints",8827));
    		Player.send(new SendString("Ranged",8837));
    		Player.send(new SendString("Magic",8840));
    		Player.send(new SendString("Prayer",8843));
    		Player.send(new SendString("RuneCraf",8859));
    		Player.send(new SendString("Agility",8862));
    		Player.send(new SendString("Herblore",8865));
    		Player.send(new SendString("Thieving",15303));
    		Player.send(new SendString("Crafting",15306));
    		Player.send(new SendString("Slayer",15309));
    
    		SkillGuides.sendSkillInterface(Player, SkillGuides.item);
    		Player.send(new SendInterface(8714));
    	}
    
    	public static void agilityInterface(final Player Player) {
    		SkillGuides.skillsInterface(Player, "Agility",
    				2150, 1, "Gnome stronghold agility course",
    				2996, 1, "Low-level agility arena",
    				2996, 20, "Medium-level agility arena",
    				2996, 40, "High-level agility arena",
    				1365, 35, "Barberian outpost agility course",
    				4024, 48, "Ape attol agility course",
    				964, 52, "Wilderness agility course",
    				4170, 60, "Werewolf agility course");
    	}
    
    	public static void atkInterface(final Player Player) {
    		SkillGuides.skillsInterface(Player, "Attack",
    				/*1291, 1, "Bronze",
    				1293, 1, "Iron",
    				1295, 5, "Steel",
    				1297, 10, "Black",
    				1299, 20, "Mithril",
    				1301, 30, "Adamant",
    				1303, 40, "Rune",
    				1305, 60, "Dragon");*/
    				1205, 1, "Bronze",
    				1203, 1, "Iron",
    				1207, 5, "Steel",
    				1217, 10, "Black",
    				1209, 20, "Mithril",
    				1211, 30, "Adamant",
    				//1391, 30, "Battlestaves (with 30 Magic)",
    				1213, 40, "Rune",
    				1305, 60, "Dragon");
    	}
    
    	public static void cookingInterface(final Player Player) {
    		SkillGuides.skillsInterface(Player, "Cooking",
    				315, 1, "Shrimps",
    				333, 20, "Trouts",
    				361, 30, "Tunas",
    				379, 40, "Lobsters",
    				373, 50, "Swordfishes",
    				385, 76, "Sharks",
    				397, 79, "Sea Turtles",
    				391, 81, "Manta rays");
    	}
    
    	public static void craftingInterface(final Player Player) {
    		SkillGuides.skillsInterface(Player, "Crafting",
    				1059, 1, "Leather",
    				1777, 10, "Flax into bow string",
    				1097, 20, "Hard leather",
    				1065, 57, "Green dragonhide leather",
    				2487, 66, "Blue dragonhide leather",
    				2489, 73, "Red dragonhide leather",
    				2491, 79, "Black dragonhide leather",
    				6585, 90, "Onyx amulet");
    	}
    
    	public static void defInterface(final Player Player) {
    		SkillGuides.skillsInterface(Player, "Defence",
    				1139, 1, "Bronze",
    				1137, 1, "Iron",
    				1141, 5, "Steel",
    				1151, 10, "Black",
    				1143, 20, "Mithril",
    				1145, 30, "Adamant",
    				1147, 40, "Rune",
    				1149, 60, "Dragon");
    	}
    
    	public static void farmingInterface(final Player Player) {
    		SkillGuides.skillsInterface(Player, "Farming",
    				5291, 1, "Guam seed",
    				5292, 15, "Marrentill seed",
    				5293, 20, "Tarromin seed",
    				5295, 30, "Ranarr seed",
    				5298, 40, "Avanote seed",
    				5300, 60, "Snapdragon seed",
    				5302, 72, "Lantadyme seed",
    				5304, 90, "Torsol seed");
    	}
    
    	public static void firemakingInterface(final Player Player) {
    		SkillGuides.skillsInterface(Player, "Firemaking",
    				1511, 1, "Tree logs",
    				1521, 15, "Oak logs",
    				1519, 30, "Willow logs",
    				6333, 35, "Teak logs",
    				1517, 45, "Maple logs",
    				4544, 49, "Bullseye lantern",
    				6332, 50, "Mahogany logs",
    				1515, 60, "Yew logs");
    	}
    
    	public static void fishingInterface(final Player Player) {
    		SkillGuides.skillsInterface(Player, "Fishing",
    				317, 1, "Shrimps",
    				335, 20, "Trouts",
    				359, 35, "Tunas",
    				377, 40, "Lobsters",
    				371, 50, "Swordfishes",
    				383, 76, "Sharks",
    				395, 79, "Sea Turtles",
    				389, 81, "Manta rays");
    	}
    
    	public static void fletchingInterface(final Player Player) {
    		SkillGuides.skillsInterface(Player, "Fletching",
    				50, 5, "Normal bows",
    				54, 20, "Oak bows",
    				60, 35, "Willow bows",
    				64, 50, "Maple bows",
    				68, 65, "Yew bows",
    				892, 75, "Rune arrow",
    				72, 80, "Magic shortbow",
    				70, 85, "Magic longbow");
    
    	}
    
    	public static void herbloreInterface(final Player Player) {
    		SkillGuides.skillsInterface(Player, "Agility",
    				221, 3, "Attack Potion",
    				235, 5, "Anti-poison Potion",
    				225, 12, "Strength Potion",
    				223, 22, "Restore Potion",
    				1975, 22, "Energy Potion",
    				239, 30, "Defence Potion",
    				1526, 38, "Prayer Potion",
    				221, 45, "Super Attack Potion");
    	}
    
    	public static void hpInterface(final Player Player) {
    		SkillGuides.skillsInterface(Player, "Hitpoints",
    				0, 0, "",
    				0, 0, "",
    				0, 0, "",
    				0, 0, "",
    				0, 0, "",
    				0, 0, "",
    				0, 0, "",
    				0, 0, "");
    	}
    
    	public static void mageInterface(final Player Player) {
    		SkillGuides.skillsInterface(Player, "Magic",
    				579, 1, "Wizard",
    				4089, 40, "Mystic",
    				7400, 40, "Enchant",
    				3385, 40, "Splitbark",
    				6918, 50, "Infinity",
    				2412, 60, "God capes and staffs",
    				6914, 70, "Mage's book and Master Wand",
    				4708, 70, "Ahrims");
    	}
    
    	public static void miningInterface(final Player Player) {
    		SkillGuides.skillsInterface(Player, "Mining",
    				436, 1, "Tin & Cooper",
    				440, 15, "Iron",
    				442, 30, "Silver",
    				453, 30, "Coal",
    				444, 40, "Gold",
    				447, 55, "Mithril",
    				449, 70, "Adamant",
    				451, 85, "Rune");
    	}
    
    	public static void prayInterface(final Player Player) {
    		SkillGuides.skillsInterface(Player, "Prayer",
    				526, 1, "Bones",
    				532, 1, "Big bones",
    				534, 1, "Baby dragon bones",
    				536, 1, "Dragon bones",
    				6729, 1, "Dagannoth bones",
    				4812, 1, "Zogre bones",
    				4830, 1, "Fayrg bones",
    				4832, 1, "Raurg bones");
    	}
    
    	public static void rangeInterface(final Player Player) {
    		SkillGuides.skillsInterface(Player, "Ranged",
    				1129, 1, "Plain Leather",
    				1131, 1, "Hard leather",
    				1133, 20, "Studded leather",
    				1135, 40, "Green d'hide leather",
    				2499, 50, "Blue d'hide leather",
    				2501, 60, "Red d'hide leather",
    				2503, 70, "Black d'hide leather",
    				4736, 70, "Karils");
    	}
    
    	public static void rcInterface(final Player Player) {
    		SkillGuides.skillsInterface(Player, "Runecrafting",
    				6422, 1, "Air runes",
    				6436, 2, "Mind runes",
    				6438, 20, "Body runes",
    				6430, 35, "Chaos runes",
    				561, 44, "Nature runes",
    				6434, 54, "Law runes",
    				6432, 65, "Death runes",
    				565, 77, "Blood runes");
    	}
    
    	public static void slayerInterface(final Player Player) {
    		SkillGuides.skillsInterface(Player, "Slayer",
    				4133, 1, "Crawling hand",
    				4134, 10, "Cave crawler",
    				4140, 45, "Infernal Mage",
    				4144, 60, "Aberrant Spectre",
    				4145, 65, "Dust devil",
    				4147, 75, "Gargoyle",
    				4148, 80, "Nechryael",
    				4149, 85, "Abyssal demon");
    	}
    
    	public static void smithingInterface(final Player Player) {
    		SkillGuides.skillsInterface(Player, "Smithing",
    				2349, 1, "Bronze",
    				2351, 15, "Iron",
    				2355, 20, "Silver",
    				2353, 30, "Steel",
    				2357, 40, "Gold",
    				2359, 50, "Mithril",
    				2361, 70, "Adamant",
    				2363, 85, "Rune");
    	}
    
    	public static void strInterface(final Player Player) {
    		SkillGuides.skillsInterface(Player, "Strength",
    				3196, 5, "Black halberd",
    				3198, 10, "Mithril halberd",
    				3200, 15, "Adamant halberd",
    				3202, 20, "Rune halberd",
    				3204, 30, "Dragon halberd",
    				4153, 50, "Granite maul",
    				6528, 60, "Tzhaar-Ket-Om",
    				4718, 70, "Dharok's greataxe");
    	}
    
    	public static void thievingInterface(final Player Player) {
    		SkillGuides.skillsInterface(Player, "Thieving",
    				3241, 1, "Man",
    				3243, 10, "Farmer",
    				3245, 25, "Warrior",
    				3249, 40, "Guard",
    				3251, 53, "Knights of ardogne",
    				3255, 70, "Paladin",
    				3257, 75, "Gnome",
    				3259, 80, "Hero");
    	}
    
    	public static void woodcuttingInterface(final Player Player) {
    		SkillGuides.skillsInterface(Player, "Woodcutting",
    				1511, 1, "Normal tree",
    				1521, 15, "Oak tree",
    				1519, 30, "Willow tree",
    				6333, 35, "Teak tree",
    				1517, 45, "Maple tree",
    				6332, 50, "Mahogany tree",
    				1515, 60, "Yews tree",
    				6739, 61, "Dragon axe");
    	}
    
    }
    Reply With Quote  
     

  2. #2  
    Community Veteran


    arch337's Avatar
    Join Date
    Sep 2008
    Posts
    2,833
    Thanks given
    187
    Thanks received
    306
    Discord
    View profile
    Rep Power
    770
    So what do you need it for?


    "A fail act is something you do regular, but a dumb act is something you can learn from"
    Spoiler for Problem?:
    Reply With Quote  
     

  3. #3  
    Banned
    Join Date
    Sep 2017
    Posts
    340
    Thanks given
    24
    Thanks received
    30
    Rep Power
    0
    Quote Originally Posted by arch337 View Post
    So what do you need it for?
    Currently each skill guide can store only 8 items.
    The crap code is repeating on each frame as you can see i want it to get less repeat code and easier to add more items because if i want to add 9th item inside lets say farming i can't because i will need to add - final int item9ItemId, final int item9lvl, final String item9lvldef) and other stuff to make it work but inside other skill guides you will need to add somethink too otherwise it will send a blank item by itself even if you give -1 values inside.

    Added you on discord if its fine so i can explain it more clearly here
    Reply With Quote  
     

  4. #4  
    what the dog doin

    mikan's Avatar
    Join Date
    Aug 2017
    Posts
    917
    Thanks given
    698
    Thanks received
    731
    Discord
    View profile
    Rep Power
    4898
    Quote Originally Posted by replicant View Post
    Currently each skill guide can store only 8 items.
    The crap code is repeating on each frame as you can see i want it to get less repeat code and easier to add more items because if i want to add 9th item inside lets say farming i can't because i will need to add - final int item9ItemId, final int item9lvl, final String item9lvldef) and other stuff to make it work but inside other skill guides you will need to add somethink too otherwise it will send a blank item by itself even if you give -1 values inside.

    Added you on discord if its fine so i can explain it more clearly here

    [Only registered and activated users can see links. ]

    (...)
    Reply With Quote  
     

  5. #5  
    Registered Member

    Join Date
    Sep 2016
    Posts
    161
    Thanks given
    76
    Thanks received
    70
    Discord
    View profile
    Rep Power
    404
    Biggest problem is that the interface might not support more than 8. You need to figure out if theres more slots available or else add more. You could make an enum for each skill guide and get them to implement an interface. I think this might be a bit out of your depth here though.

    Simple but still not great is variable array length params which mikan posted.
    Need to use some for loops as well.
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  6. #6  
    Banned

    Join Date
    Jun 2019
    Posts
    203
    Thanks given
    99
    Thanks received
    44
    Rep Power
    0
    Quote Originally Posted by knd6060 View Post
    Biggest problem is that the interface might not support more than 8. You need to figure out if theres more slots available or else add more. You could make an enum for each skill guide and get them to implement an interface. I think this might be a bit out of your depth here though.

    Simple but still not great is variable array length params which mikan posted.
    Need to use some for loops as well.
    All of this data can be added into an enum tho, and simply loop the enum. Easiest solution.
    Reply With Quote  
     

  7. #7  
    Registered Member

    Join Date
    Sep 2016
    Posts
    161
    Thanks given
    76
    Thanks received
    70
    Discord
    View profile
    Rep Power
    404
    Quote Originally Posted by Zerikoth View Post
    All of this data can be added into an enum tho, and simply loop the enum. Easiest solution.
    Would be a big ass enum. You would also have to add Skill to the emum amd filter it by skill everytime you use it. I'm unsure on what would be better but 25 skills, hmm. Tbh sounds painful either way. One enum actually sounds easier now I think about it.
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  8. #8  
    Be the change you wanna see!

    Nozemi's Avatar
    Join Date
    Jul 2010
    Posts
    378
    Thanks given
    166
    Thanks received
    182
    Discord
    View profile
    Rep Power
    852
    Quote Originally Posted by knd6060 View Post
    Would be a big ass enum. You would also have to add Skill to the emum amd filter it by skill everytime you use it. I'm unsure on what would be better but 25 skills, hmm. Tbh sounds painful either way. One enum actually sounds easier now I think about it.
    If it's about the items. It's a bad idea to hardcode all of this stuff to be honest. If for whatever reason you change some requirements and forget to update the skillguide, you have a useless skillguide.

    Figuring out how to handle both requirements and guides at the same time is where to go probably. Use the same way to retrieve the requirements for both the guide and the actual restrictive code.
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  9. Thankful user:


  10. #9  
    Registered Member

    Join Date
    Sep 2016
    Posts
    161
    Thanks given
    76
    Thanks received
    70
    Discord
    View profile
    Rep Power
    404
    Quote Originally Posted by Nozemi View Post
    If it's about the items. It's a bad idea to hardcode all of this stuff to be honest. If for whatever reason you change some requirements and forget to update the skillguide, you have a useless skillguide.

    Figuring out how to handle both requirements and guides at the same time is where to go probably. Use the same way to retrieve the requirements for both the guide and the actual restrictive code.
    That would definitely be ideal, whether the guy has the time or skill to do that though lol. Would require rewriting core parts of every skill. Well worth it though for a long term server that is planning on doing lot of work on skills.
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  11. #10  
    Be the change you wanna see!

    Nozemi's Avatar
    Join Date
    Jul 2010
    Posts
    378
    Thanks given
    166
    Thanks received
    182
    Discord
    View profile
    Rep Power
    852
    Quote Originally Posted by knd6060 View Post
    That would definitely be ideal, whether the guy has the time or skill to do that though lol. Would require rewriting core parts of every skill. Well worth it though for a long term server that is planning on doing lot of work on skills.
    He asked how he could improve it and avoid duplicate code. So whether he has the experience or not isn't really relevant. He can learn how to do this perfectly fine.
    [Only registered and activated users can see links. ]
    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. [Delta] Need help with skills
    By Shoes in forum Help
    Replies: 0
    Last Post: 06-13-2010, 04:08 PM
  2. need help with thieving skill
    By Brody in forum Help
    Replies: 2
    Last Post: 02-14-2010, 09:50 PM
  3. Need Help with skill Interface
    By pkergod in forum Help
    Replies: 11
    Last Post: 10-26-2009, 07:03 AM
  4. Need help with the 500+ Skill Interface
    By Nightleaf in forum Help
    Replies: 21
    Last Post: 02-04-2009, 08:00 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
  •