Thread: 718 slayer

Page 1 of 2 12 LastLast
Results 1 to 10 of 13
  1. #1 718 slayer 
    Just a Finn

    Join Date
    Jul 2015
    Posts
    121
    Thanks given
    17
    Thanks received
    4
    Rep Power
    13
    I hate posting these help threads, but I've tried to fix this for the past 2 days. So when people kill slayer task npcs on my server it doesn't give them xp or reduce the amount left to kill..

    Code:
    package com.rs.game.player.content;
    
    import java.io.Serializable;
    
    import com.rs.game.player.Player;
    import com.rs.game.player.Skills;
    import com.rs.utils.Utils;
    import com.rs.game.npc.*;
    
    
    public class SlayerTask implements Serializable {
    
    	/**
    	 * 
    	 */
    	private static final long serialVersionUID = -3885979679549716755L;
    
    	public enum Master {
    		KURADAL(9085, new Object[][] { 
    				{ "Crawling hand", 1, 50, 100, 100.0 },
    				{ "Abyssal demon", 85, 25, 130, 285.0 },
    				{ "Nechryael", 80, 45, 85, 112.0 },
    				{ "Aberrant spectre", 60, 30, 100, 115.0 },
    				{ "Infernal mage", 45, 25, 60, 150.0 },
    				{ "Dust devil", 45, 25, 60, 150.0 },
    				{ "General Graardor", 75, 5, 15, 350.0 },
    				{ "Kree'arra", 75, 5, 15, 355.0 },
    				{ "K'ril Tsutsaroth", 75, 5, 15, 275.0 },
    				{ "Gargoyle", 75, 5, 15, 255.0 },
    				{ "Dark beast", 75, 5, 15, 285.0 },
    				{ "Corporal Beast", 75, 5, 15, 310.0 },
    				{ "Hellhound", 45, 25, 60, 150.0 },
    				{ "Iron dragon", 45, 25, 60, 150.0 },
    				{ "Steel dragon", 45, 25, 60, 150.0 },
    				{ "Blue dragon", 45, 25, 60, 150.0 },
    				{ "Greater demon", 45, 25, 60, 150.0 },
    				{ "Gargoyle", 75, 150, 200, 200.0 },
    				{ "Jelly", 1, 25, 60, 100.0 },
    				{ "Dark beast", 90, 40, 75, 310.0 },
    				{ "Bloodveld", 50, 30, 100, 145.0 } });
    
    		private int id;
    		private Object[][] data;
    
    		private Master(int id, Object[][] data) {
    			this.id = id;
    			this.data = data;
    		}
    
    		public static Master forId(int id) {
    			for (Master master : Master.values()) {
    				if (master.id == id) {
    					return master;
    				}
    			}
    			return null;
    		}
    
    		public int getId() {
    			return id;
    		}
    
    	}
    
    	private Master master;
    	private int taskId;
    	private int taskAmount;
    	private int amountKilled;
    
    	public SlayerTask(Master master, int taskId, int taskAmount) {
    		this.master = master;
    		this.taskId = taskId;
    		this.taskAmount = taskAmount;
    	}
    
    	public String getName() {
    		return (String) master.data[taskId][0];
    	}
    
    	public static SlayerTask random(Player player, Master master) {
    		SlayerTask task = null;
    		while (true) {
    			int random = Utils.random(master.data.length - 1);
    			int requiredLevel = (Integer) master.data[random][1];
    			if (player.getSkills().getLevel(Skills.SLAYER) < requiredLevel) {
    				continue;
    			}
    			int minimum = (Integer) master.data[random][2];
    			int maximum = (Integer) master.data[random][3];
    			if (task == null) {
    				task = new SlayerTask(master, random, Utils.random(minimum,
    						maximum));
    				player.setTask(task);
    			}
    			break;
    		}
    		return task;
    	}
    
    	public int getTaskId() {
    		return taskId;
    	}
    
    	public int getTaskAmount() {
    		return taskAmount;
    	}
    
    	public void decreaseAmount() {
    		taskAmount--;
    	}
    
    	public int getXPAmount() {
    		Object obj = master.data[taskId][4];
    		if (obj instanceof Double) {
    			return (int) Math.round((Double) obj);
    		}
    		if (obj instanceof Integer) {
    			return (Integer) obj;
    		}
    		return 0;
    	}
    
    	public Master getMaster() {
    		return master;
    	}
    
    	/**
    	 * @return the amountKilled
    	 */
    	public int getAmountKilled() {
    		return amountKilled;
    	}
    
    	/**
    	 * @param amountKilled
    	 *            the amountKilled to set
    	 */
    	public void setAmountKilled(int amountKilled) {
    		this.amountKilled = amountKilled;
    	}
    
    	public void onMonsterDeath(Player player, NPC n) {
    		player.getSkills().addXp(Skills.SLAYER, player.getTask().getXPAmount());
    		player.getTask().decreaseAmount();
    		/*
    		 * int[] checkpoints = new int[] { 2, 3, 4, 5, 10, 15, 25, 50, 75, 100,
    		 * 125, 150 }; for (int i : checkpoints) { if
    		 * (player.getTask().getAmountKilled() == i) {
    		 * player.getPackets().sendGameMessage( "You're doing great, Only " +
    		 * player.getTask().getTaskAmount() + " " +
    		 * player.getTask().getName().toLowerCase() + " left to slay."); } }
    		 */
    		player.getTask()
    				.setAmountKilled(player.getTask().getAmountKilled() + 1);
    		player.getPackets().sendGameMessage(
    				"You need to defeat " + player.getTask().getTaskAmount() + " "
    						+ player.getTask().getName().toLowerCase()
    						+ " to complete your task.");
    		if (player.getTask().getTaskAmount() < 1) {
    			player.setTask(null);
    			if (player.getEquipment().getRingId() == 13281) {
    				player.setSlayerPoints(player.getSlayerPoints() + 40);
    				player.getPackets()
    						.sendGameMessage(
    								"You have finished your slayer task, talk to Kuradal for a new task.");
    				player.getPackets().sendGameMessage(
    						"Kuradal rewarded you 40 slayerPoints! You now have "
    								+ player.getSlayerPoints() + " slayerPoints.");
    			} else {
    				player.setSlayerPoints(player.getSlayerPoints() + 20);
    				player.getPackets()
    						.sendGameMessage(
    								"You have finished your slayer task, talk to Kuradal for a new task.");
    				player.getPackets().sendGameMessage(
    						"Kuradal rewarded you 20 slayerPoints! You now have "
    								+ player.getSlayerPoints() + " slayerPoints.");
    			}
    		}
    	}
    }
    My SlayerTask.java

    Any help would be highly appreciated.
    Reply With Quote  
     

  2. #2  
    Registered Member
    hc747's Avatar
    Join Date
    Dec 2013
    Age
    26
    Posts
    1,474
    Thanks given
    3,312
    Thanks received
    691
    Rep Power
    1098
    Call on monster death in npc.java, prior to dropping loot
    Reply With Quote  
     

  3. Thankful user:


  4. #3  
    Just a Finn

    Join Date
    Jul 2015
    Posts
    121
    Thanks given
    17
    Thanks received
    4
    Rep Power
    13
    Quote Originally Posted by hc747 View Post
    Call on monster death in npc.java, prior to dropping loot
    So I'll make it like
    Code:
    (npc.getName().equalsIgnoreCase(General Graardor))
    killer.getSkills().addXp(Skills.SLAYER, xp i want to add?);
    ?
    Reply With Quote  
     

  5. #4  
    Contributor

    clem585's Avatar
    Join Date
    Sep 2013
    Posts
    3,788
    Thanks given
    706
    Thanks received
    702
    Rep Power
    570
    Quote Originally Posted by Dewwie View Post
    So I'll make it like
    Code:
    (npc.getName().equalsIgnoreCase(General Graardor))
    killer.getSkills().addXp(Skills.SLAYER, xp i want to add?);
    ?
    Code:
    if (npc.getId() == player.getTask().getId())//you have to make the task.getId() thing.
        player.getTask().onMonsterDeath();
    Also will have to make player param with something like this:

    Code:
    Entity source = getMostDamage();//idk method name on matrix
    if (source instanceof Player) {
        Player player = (Player) source;
    Project thread
    Reply With Quote  
     

  6. Thankful user:


  7. #5  
    Registered Member
    Join Date
    Jun 2015
    Posts
    17
    Thanks given
    14
    Thanks received
    8
    Rep Power
    11
    go to NPC.java, find senddrop or a method that where your NPC.java does the drops.

    add
    Code:
    SlayerTask.onMonsterDeath("theplayer","thenpc");
    import SlayerTask.java on NPC.java
    Reply With Quote  
     

  8. Thankful users:


  9. #6  
    Just a Finn

    Join Date
    Jul 2015
    Posts
    121
    Thanks given
    17
    Thanks received
    4
    Rep Power
    13
    Got it to work on my own way, thank you anyways for your help.
    Reply With Quote  
     

  10. #7  
    Registered Member
    hc747's Avatar
    Join Date
    Dec 2013
    Age
    26
    Posts
    1,474
    Thanks given
    3,312
    Thanks received
    691
    Rep Power
    1098
    Quote Originally Posted by newerarsps View Post
    go to NPC.java, find senddrop or a method that where your NPC.java does the drops.

    add
    Code:
    SlayerTask.onMonsterDeath("theplayer","thenpc");
    import SlayerTask.java on NPC.java
    Not static, should be referenced via the player object, ie, if (player.getSlayerTask() != null)
    player.getSlayerTask().onMonsterDeath(player, npc);

    Quote Originally Posted by clem585 View Post
    Code:
    if (npc.getId() == player.getTask().getId())//you have to make the task.getId() thing.
        player.getTask().onMonsterDeath();
    Also will have to make player param with something like this:

    Code:
    Entity source = getMostDamage();//idk method name on matrix
    if (source instanceof Player) {
        Player player = (Player) source;
    Should be name based rather than id, so if this.getName().equalsIgnoreCase(player.getSlayerTa sk().getName())
    doStuff();
    Reply With Quote  
     

  11. #8  
    Just a Finn

    Join Date
    Jul 2015
    Posts
    121
    Thanks given
    17
    Thanks received
    4
    Rep Power
    13
    Quote Originally Posted by hc747 View Post
    Not static, should be referenced via the player object, ie, if (player.getSlayerTask() != null)
    player.getSlayerTask().onMonsterDeath(player, npc);


    Should be name based rather than id, so if this.getName().equalsIgnoreCase(player.getSlayerTa sk().getName())
    doStuff();
    I made it like this
    Code:
    if (killer.getTask() != null) {
    					if (getDefinitions().name.toLowerCase().equalsIgnoreCase(
    							killer.getTask().getName().toLowerCase())) {
    killer.getSkills().AddXP(Skills.SLAYER,
                                                            killer.getTask().getXPAmount());
    And then made it so it decreases the npcs left to kill.
    Reply With Quote  
     

  12. #9  
    Registered Member

    Join Date
    Feb 2013
    Posts
    4,409
    Thanks given
    59
    Thanks received
    478
    Rep Power
    138
    Quote Originally Posted by Dewwie View Post
    I made it like this
    Code:
    if (killer.getTask() != null) {
    					if (getDefinitions().name.toLowerCase().equalsIgnoreCase(
    							killer.getTask().getName().toLowerCase())) {
    killer.getSkills().AddXP(Skills.SLAYER,
                                                            killer.getTask().getXPAmount());
    And then made it so it decreases the npcs left to kill.
    Are you not using the method that's provided in the class?
    Reply With Quote  
     

  13. #10  
    Just a Finn

    Join Date
    Jul 2015
    Posts
    121
    Thanks given
    17
    Thanks received
    4
    Rep Power
    13
    Quote Originally Posted by Mayne View Post
    Are you not using the method that's provided in the class?
    Ahh apparently not... Could this be a reason why it is causing me a nullpointerexception in NPC.java in this line?

    Code:
    if (killer.getTask() != null) {
    I'm not entirely sure what the nullpointerexception means though..
    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. 718 slayer
    By JDM Reject in forum Help
    Replies: 6
    Last Post: 10-25-2012, 12:45 AM
  2. [718] Slayer help
    By The Watcher in forum Help
    Replies: 11
    Last Post: 10-04-2012, 09:48 PM
  3. 718 Slayer
    By ben7ohnsen in forum Help
    Replies: 0
    Last Post: 10-02-2012, 12:13 AM
  4. 718 slayer help
    By Mr Sandman in forum Help
    Replies: 1
    Last Post: 07-31-2012, 05:18 AM
  5. 718 Slayer Assignments
    By Ryan. in forum Help
    Replies: 1
    Last Post: 07-28-2012, 06:13 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
  •