Thread: Probably an easy fix but need help.... [Rep++]

Results 1 to 7 of 7
  1. #1 Probably an easy fix but need help.... [Rep++] 
    Registered Member
    Coke zero's Avatar
    Join Date
    Jun 2012
    Posts
    624
    Thanks given
    178
    Thanks received
    75
    Rep Power
    197
    Hey guys....


    I'm using the matrix default slayer system to improve and add more features too but I'm having a little trouble.
    The requirements to attack a monster don't work....
    Here is my Slayer.java

    Code:
    package com.rs.game.player.actions;
    
    import java.io.Serializable;
    import java.util.HashMap;
    import java.util.Map;
    
    import com.rs.game.npc.NPC;
    import com.rs.game.player.Player;
    import com.rs.game.player.Skills;
    import com.rs.utils.Utils;
    
    public class Slayer {
    
    	public enum Master {
    
    		SPRIA(8462, "Travel north of Taverly to get here; Burthorpe.", 3, 1,
    				new int[] { 15, 50 }, "Birds", "Chicken", "Rats", "Bears",
    				"Bats", "Cow", "Cow calf", "Crawling hands", "Cave slime",
    				"Banshees", "Dwarves", "Ghosts", "Goblins", "Spiders",
    				"Monkeys", "Scorpions"),
    
    		MAZCHNA(8464, "Canifis is quite a walk, east of Varrock; Canifis.", 20,
    				1, new int[] { 40, 70 }, "Bats", "Bears", "Crawling hands",
    				"Cave bugs", "Cave slime", "Banshees", "Ghosts", "Moss giant",
    				"Spiders", "Cave crawlers", "Cockatrice", "Zombies",
    				"Hill giants", "Hobgoblins", "Icefiends", "Pyrefiends",
    				"Skeletons", "Wolves", "Kalphites", "Dogs"),
    
    		VANNAKA(
    				1597,
    				"Use the trapdoor in Edgeville to get here; Edgeville Dungeon.",
    				40, 1, new int[] { 60, 120 }, "Bats", "Crawling hands",
    				"Cave bugs", "Cave slime", "Banshees", "Rock slug", "Spiders",
    				"Cave crawlers", "Cockatrice", "Zombies", "Hill giants",
    				"Hobgoblins", "Dagannoth", "Icefiends", "Pyrefiends",
    				"Gargoyles", "Skeletons", "Wolves", "Kalphites",
    				"Aberrant spectres", "Basilisks", "Wild dog", "Bloodvelds",
    				"Dust devils", "Green dragons", "Ice giants", "Ice warriors",
    				"Jellies", "Infernal mages", "Lesser demons", "Moss giant",
    				"Fire giant", "Turoth"),
    
    		CHAELDAR(
    				1598,
    				"You must have completed Lost City quest to get here; Zanaris.",
    				70, 1, new int[] { 60, 170 }, "Banshees", "Spiders",
    				"Cave crawlers", "Cockatrice", "Rock slug", "Hill giants",
    				"Hobgoblins", "Pyrefiends", "Kalphites", "Aberrant spectres",
    				"Basilisks", "Bloodvelds", "Dust devils", "Nechryael",
    				"Wild dog", "Blue dragons", "Ice giants", "Gargoyles",
    				"Jellies", "Infernal mages", "Lesser demons", "Fire giant",
    				"Turoth", "Kurasks", "Dagannoth", "Cave horrors",
    				"Bronze dragons", "Waterfiends"),
    
    		SUMONA(
    				7780,
    				"Southeast of the north carpet stop in Pollnivneach; Pollnivneach.",
    				85, 35, new int[] { 120, 192 }, "Aberrant spectres",
    				"Abbyssal demons", "Aquanties", "Banshees", "Basiliks",
    				"Black demons", "Bloodvelds", "Blue dragons", "Cave crawlers",
    				"Cave horror", "Dragannoths", "Desert strykewyrms",
    				"Dust devils", "Elves", "Fire giant", "Gargoyles",
    				"Greater demons", "Hellhounds", "Iron Dragons",
    				"Jungle strykewyrms", "Kalphites", "Kurasks",
    				"Mutated jadinko", "Nechryaels", "Red Dragons",
    				"Scabarite minions", "Spiritual mages", "Spiritual warriors",
    				"Terror dogs", "Trolls", "Turoth", "Warped tortoises"),
    
    		LAPALOK(
    				8467,
    				"I hear there is a Gnome who can direct you here; Shilo Village",
    				100, 50, new int[] { 130, 200 }, "Aberrant spectres",
    				"Gargoyles", "Abyssal demons", "Black demons", "Black Dragons",
    				"Bloodvelds", "Dogs", 1594, "Dark beasts", "Goraks",
    				"Dagannoth", "Kalphites", "Iron dragons", "Steel dragons",
    				"Mithril dragons", "Nechryael", "Spiritual mages", "Suqahs",
    				"Greater demons", "Fire giant", "Hellhounds"),
    
    		KURADAL(9084, "", 110, 75, new int[] { 190, 270 }, "Aberrant spectres",
    				"Abbyssal demons", "Aquanties", "Black demons",
    				"Black Dragons", "Bloodvelds", "Blue Dragons", "Dagannoth",
    				"Dark beasts", "Desert strykewyrms", "Dust devils",
    				"Fire giant", "Gargoyles", "Greater demons", "Hellhound",
    				"Ice strykewyrms", "Iron dragons", "Jungle strykewyrms",
    				"Kalphites", "Living rock creatures", "Mithril dragons",
    				"Mutated jadinko", "Nechryael", "Skeletal wyverns",
    				"Spiritual mages", "Steel dragons", "Suqahs", "Terror dogs",
    				"Tez-Tek", "Warped tortoises", "Vyrewatch", "Waterfiends");
    
    		private int combatLevel;
    		private int master;
    		private int levelRequired;
    		private int[] range;
    		private Object[] tasks;
    		private String dialouge;
    
    		private Master(int master, String dialouge, int combatLevel,
    				int levelRequired, int[] range, Object... tasks) {
    			this.combatLevel = combatLevel;
    			this.levelRequired = levelRequired;
    			this.range = range;
    			this.tasks = tasks;
    			this.dialouge = dialouge;
    			this.master = master;
    		}
    
    		public String getDialouge() {
    			return dialouge;
    		}
    
    		public int getMaster() {
    			return master;
    		}
    
    		public int getCombatLevel() {
    			return combatLevel;
    		}
    
    		public int getLevelRequired() {
    			return levelRequired;
    		}
    
    		public int[] getRange() {
    			return range;
    		}
    
    		public Object[] getTasks() {
    			return tasks;
    		}
    
    		public static Master forId(int npcId) {
    			for (Master master : Master.values()) {
    				if (master.getMaster() == npcId)
    					return master;
    			}
    			return null;
    		}
    	}
    
    	public static class SlayerTask implements Serializable {
    
    		/**
    		 * 
    		 */
    		private static final long serialVersionUID = 3925639922342382315L;
    		private Master master;
    		private int index;
    		private int amount;
    
    		public SlayerTask(Master master, int index, int amount) {
    			this.master = master;
    			this.index = index;
    			this.amount = amount;
    		}
    
    		public void setMaster(Master master) {
    			this.master = master;
    		}
    
    		public void setIndex(int index) {
    			this.index = index;
    		}
    
    		public void setAmount(int amount) {
    			this.amount = amount;
    		}
    
    		public Master getMaster() {
    			return master;
    		}
    
    		public int getIndex() {
    			return index;
    		}
    
    		public int getAmount() {
    			return amount;
    		}
    
    		public String getName() {
    			return master.getTasks()[index].toString();
    		}
    	}
    
    	public static enum SlayerMonsters {
    
    		CRAWLING_HAND(1648, 5),
    
    		CAVE_BUG(1832, 7),
    
    		CAVE_CRAWLER(7787, 10),
    
    		BANSHEE(1612, 15),
    
    		CAVE_SLIM(1831, 17),
    
    		ROCK_SLUG(1631, 20),
    
    		DESERT_LIZARD(2804, 22),
    
    		COCKATRICE(1620, 25),
    
    		PYREFIED(1633, 30),
    
    		MORGE(114, 32),
    
    		HARPIE_BUG_SWARM(3163, 33),
    
    		WALL_BEAST(7823, 35),
    
    		KILLERWATT(3201, 37),
    
    		MOLANISK(5751, 39),
    
    		BASILISK(1616, 40),
    
    		TERROR_DOG(5417, 40),
    
    		FEVER_SPIDER(2850, 42),
    
    		INFERNAL_MAGE(1643, 45),
    
    		BRINE_RAT(3707, 47),
    
    		BLOODVELD(1618, 50),
    
    		PHOENIX(8549, 51),
    
    		JELLY(1637, 52),
    
    		TUROTH(1622, 55),
    
    		WARPED_TERRORBIRD(6285, 56),
    
    		WARPED_TORTOISE(6296, 56),
    
    		ZYGOMITE(3346, 57),
    
    		CAVE_HORROR(4353, 58),
    
    		WILD_JADE_FINE(3409, 59),
    
    		ABERRANT_SPECTRE(1604, 60),
    
    		SPIRITUAL_RANGE(6220, 63),
    
    		DUST_DEVIL(1624, 65),
    
    		SPIRITUAL_WARRIOR(6219, 68),
    
    		KURASK(1608, 70),
    
    		SKELETAL_WYVERN(3068, 72),
    
    		GARGOYLE(1610, 75),
    
    		AQUANITE(9172, 78),
    
    		NECHRYAEL(1613, 80),
    
    		SPIRITUAL_MAGE(6221, 83),
    
    		ABYSSAL_DEMON(1615, 85),
    
    		DARK_BEAST(2783, 90);
    
    		private static Map<Integer, SlayerMonsters> monsters = new HashMap<Integer, SlayerMonsters>();
    
    		public static SlayerMonsters forId(int id) {
    			return monsters.get(id);
    		}
    
    		static {
    			for (SlayerMonsters monster : SlayerMonsters.values())
    				monsters.put(monster.id, monster);
    		}
    
    		private int id;
    		private int req;
    
    		private SlayerMonsters(int id, int req) {
    			this.id = id;
    			this.req = req;
    		}
    
    		public int getId() {
    			return id;
    		}
    
    		public int getRequirement() {
    			return req;
    		}
    	}
    
    	public static boolean checkRequirement(Player player, SlayerMonsters slayer) {
    		if (player.getSkills().getLevel(Skills.SLAYER) < slayer
    				.getRequirement()) {
    			player.getPackets().sendGameMessage("This monster requires " + slayer.getRequirement()+ " to slay.");
    			return false;
    		}
    		return true;
    	}
    	
    	
    	public static void SlayerMonsterChecking(Player player, SlayerMonsters slayer) {
    		if (player.getSkills().getLevel(Skills.SLAYER) < slayer
    				.getRequirement()) {
    			player.getPackets().sendGameMessage("This monster requires " + slayer.getRequirement()+ " to slay.");
    		}
    	}
    
    	public static void submitRandomTask(Player player) {
    		SlayerTask task = null;
    		Master master = player.getSlayerMaster();
    		if (master == null) {
    			player.setSlayerMaster(Master.SPRIA);
    			master = player.getSlayerMaster();
    		}
    		int index = Utils.getRandom(master.getTasks().length);
    		int amount = Utils.random(master.getRange()[0], master.getRange()[1]);
    		task = new SlayerTask(master, index, amount);
    		if (player.getSlayerTask() == null)
    			player.setSlayerTask(task);
    	}
    
    	public static void killedTask(Player player, NPC npc) {
    		SlayerTask task = player.getSlayerTask();
    		task.setAmount(task.getAmount() - 1);
    		player.getSkills().addXp(Skills.SLAYER,
    				npc.getCombatDefinitions().getHitpoints() / 10);
    		if (task.getAmount() == 0) {
    			task = null;
    			player.setSlayerTask(task);
    		}
    	}
    }
    I can attack any slayer monster that needs requirements at level 1 slayer.
    Do i have to call any methods somewhere?

    Any help would be great thanks!, and to the person who can fix this, rep++
    I'm fluent in Java-Script as well as Klingon... lol jks
    sig removed
    Reply With Quote  
     

  2. #2  
    Donator
    Sake's Avatar
    Join Date
    Jan 2013
    Posts
    398
    Thanks given
    71
    Thanks received
    23
    Rep Power
    2
    Add the monsters in this format:

    { "Abyssal demon", 85, 25, 130, 235.0 },
    First number is slayer level required, last one is xp I believe.
    Reply With Quote  
     

  3. #3  
    Registered Member
    Coke zero's Avatar
    Join Date
    Jun 2012
    Posts
    624
    Thanks given
    178
    Thanks received
    75
    Rep Power
    197
    Quote Originally Posted by revize View Post
    Add the monsters in this format:


    First number is slayer level required, last one is xp I believe.

    I don't know what you're trying to say

    I'm talking about the SlayerMonsters enum..
    The first int is the npc id and the last int is the level required but I can still attack the npc without the level required...

    Thanks for replying though
    I'm fluent in Java-Script as well as Klingon... lol jks
    sig removed
    Reply With Quote  
     

  4. #4  
    Set the World on Fire
    Unsafe's Avatar
    Join Date
    Jan 2009
    Posts
    608
    Thanks given
    59
    Thanks received
    123
    Rep Power
    8
    This is handled in playercombat.java


    Stand up for what you believe in, Even if it means Standing Alone


    Reply With Quote  
     

  5. #5  
    Registered Member
    Coke zero's Avatar
    Join Date
    Jun 2012
    Posts
    624
    Thanks given
    178
    Thanks received
    75
    Rep Power
    197
    Quote Originally Posted by Unsafe View Post
    This is handled in playercombat.java
    Thanks but it's a big class man, where and what would I declare?
    I'm fluent in Java-Script as well as Klingon... lol jks
    sig removed
    Reply With Quote  
     

  6. #6  
    Registered Member
    Coke zero's Avatar
    Join Date
    Jun 2012
    Posts
    624
    Thanks given
    178
    Thanks received
    75
    Rep Power
    197
    Wait how do I declare the checkrequirement so I don't need to type up all the cases and levels...
    I'm fluent in Java-Script as well as Klingon... lol jks
    sig removed
    Reply With Quote  
     

  7. #7  
    Banned
    Join Date
    Jun 2012
    Posts
    438
    Thanks given
    13
    Thanks received
    27
    Rep Power
    0
    getCombatLevel() int in the slayer class, just make an if level is under that level return and send a message
    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. Easy find but need help!
    By JoshuaFTW in forum Help
    Replies: 1
    Last Post: 11-07-2012, 04:07 AM
  2. probably an easy fix
    By startcode in forum Help
    Replies: 3
    Last Post: 03-10-2012, 12:07 AM
  3. 4 errors easy fix but need help
    By realitylife2 in forum Help
    Replies: 7
    Last Post: 10-24-2011, 02:45 PM
  4. Replies: 2
    Last Post: 11-21-2010, 06:37 AM
  5. Prob an easy fix but...
    By shoopdawhoop in forum Help
    Replies: 8
    Last Post: 03-10-2010, 04:22 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
  •