Thread: Boss achievements and tracker help

Results 1 to 4 of 4
  1. #1 Boss achievements and tracker help 
    Registered Member
    Join Date
    Jan 2017
    Posts
    23
    Thanks given
    0
    Thanks received
    0
    Rep Power
    11
    I tried following a boss achievement and tracker code made by hc747 and zach.
    Code:
    package com.rs.game.player.content;
    
    
    import java.io.Serializable;
    import java.util.HashMap;
    
    
    import com.rs.cache.loaders.NPCDefinitions;
    import com.rs.game.World;
    import com.rs.game.player.Player;
    
    
    public class NpcCounts implements Serializable {
    
    
        private static final long serialVersionUID = -6650338643379886360L;
        
        private Player player;
        private HashMap<Integer,Integer> NPC_COUNTS;
        
        /**
         * In the player class, place:
         * private NpcCounts npcCounts;
         * public NpcCounts getNpcCounts() {
         * return npcCounts();
         * }
         * 
         * Then in your initialisation methods
         * if (npcCounts == null)
         * npcCounts = new NpcCounts();
         * 
         * and
         * 
         * npcCounts.setPlayer(this);
         * 
         * In the npc class, within the sendDeath method, place:
         * 
         * final NpcCounts npcCounts = player.getNpcCounts();
         * if (npcCounts != null)
         * npcCounts.incrementCounts(npcId);
         * 
         * In your commands class:
         * if (cmd[0].equalsIgnoreCase("bosskills") {
         * final NpcCounts counts = player.getNpcCounts();
         * if (counts == null)
         * return true;
         * counts.showProgress();
         * return true;
         * }
         */
        
        public void setPlayer(final Player player) {
            this.player = player;
        }
        
        private static final int[] VALID_NPCS = {
            /**
             * Add the npc ids you want to be tracked in here
             */
        };
        
        private static final int[] ANNOUNCED_COUNTS = {
            /**
             * Add the counts that you want to be announced here
             */
            50,150,250,500,750,1000,1500,2000
        };
        
        public NpcCounts() {
            NPC_COUNTS = new HashMap<Integer,Integer>();
            for (final int i : VALID_NPCS)
                NPC_COUNTS.put(i, 0);
        }
        
        private void announceAchievement(String name, int count) {
            if (player == null)
                return;
            World.sendWorldMessage("<col=ff0000>"+player.getDisplayName()+" has just reached "+count+" "+name+" kills!");
        }
        
        private static boolean isValidNpc(final int npcId) {
            for (final int i : VALID_NPCS)
                if (npcId == i)
                    return true;
            return false;
        }
        
        public void incrementCount(final int npcId) {
            if (player == null || !isValidNpc(npcId))
                return;
            final NPCDefinitions defs = NPCDefinitions.getNPCDefinitions(npcId);
            if (defs == null)
                return;
            Integer previous = NPC_COUNTS.remove(npcId);
            if (previous == null)
                previous = 0;
            previous+=1;
            player.getPackets().sendGameMessage("<col=00ff00>You have now killed "+previous+" "+defs.getName()+"!");
            NPC_COUNTS.put(npcId, previous);
            for (final int i : ANNOUNCED_COUNTS) {
                if (previous == i) {
                    announceAchievement(defs.getName(),previous);
                    break;
                }
            }
        }
        
         public void showProgress() {		if (player == null)
    			return;
    		player.getInterfaceManager().sendInterface(1245);
    		player.getPackets().sendIComponentText(1245, 330, "Your Total Boss Kills:");
    		int count = 13;
    		if (NPC_COUNTS.isEmpty()) {
    			player.getPackets().sendIComponentText(1245, count, "You have no tracked kills.");
    			return;
    		}
    		for (final int i : NPC_COUNTS.keySet()) {
    			final NPCDefinitions defs = NPCDefinitions.getNPCDefinitions(i);
    			if (defs == null)
    				continue;
    			player.getPackets().sendIComponentText(1245, count++, "You have killed "+defs.getName()+" "+NPC_COUNTS.get(i)+" times.");
    		}
    	}
        
    }
    When I followed the guide inside of the code I didnt know where I were supposed to place this
    Code:
    * Then in your initialisation methods
         * if (npcCounts == null)
         * npcCounts = new NpcCounts();
         * 
         * and
         * 
         * npcCounts.setPlayer(this);
    So I was wondering if anyone knew? Thank you!
    Reply With Quote  
     

  2. #2  
    Contributor
    Kris's Avatar
    Join Date
    Jun 2016
    Age
    23
    Posts
    3,536
    Thanks given
    703
    Thanks received
    2,322
    Discord
    View profile
    Rep Power
    5000
    Both go in Player class, in the init() method. Make sure to put them in the same order as you displayed, otherwise you're facing a nullpointer.
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Jan 2017
    Posts
    23
    Thanks given
    0
    Thanks received
    0
    Rep Power
    11
    Quote Originally Posted by Kris View Post
    Both go in Player class, in the init() method. Make sure to put them in the same order as you displayed, otherwise you're facing a nullpointer.
    I can seem to find the init() method in player.java, could you be more specific? Or am I doing it wrong?
    Reply With Quote  
     

  4. #4  
    Contributor
    Kris's Avatar
    Join Date
    Jun 2016
    Age
    23
    Posts
    3,536
    Thanks given
    703
    Thanks received
    2,322
    Discord
    View profile
    Rep Power
    5000
    Quote Originally Posted by kronans1234 View Post
    I can seem to find the init() method in player.java, could you be more specific? Or am I doing it wrong?
    Just find any other method similar to that then, your easiest bet is to find for another bunch of setPlayer(this); methods being called, just slam it in there.
    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. Replies: 57
    Last Post: 03-22-2015, 02:54 AM
  2. HELP: 718 - 718 Boss Anims and Black Screens?
    By Super Noodles in forum Help
    Replies: 1
    Last Post: 12-08-2013, 01:31 PM
  3. Replies: 1
    Last Post: 07-30-2013, 09:43 PM
  4. Replies: 5
    Last Post: 10-24-2008, 05:37 PM
  5. magic cape gfx and animation help
    By T-Sex in forum RS2 Server
    Replies: 6
    Last Post: 05-04-2008, 04:29 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
  •