Thread: Need Help With explaining ... [PI]

Results 1 to 9 of 9
  1. #1 Need Help With explaining ... [PI] 
    Donator

    Join Date
    Apr 2013
    Posts
    99
    Thanks given
    3
    Thanks received
    2
    Rep Power
    15
    Hello there

    i'm really confused and don't know what this line means ... ==> NPCDrops.dropRarity.get(npcs[i].npcType) != null == > This line can be found at npchandler (class)

    i know that it's a boolean but what i need is what the line returns what is the value referred to ... and what is get method ??

    Here is my npc drops if it helps
    Code:
    package server.model.npcs;
    
    import java.io.File;
    import java.util.HashMap;
    import java.util.StringTokenizer;
    import java.util.Scanner;
    
    /**
     * @author Sanity
     */
    
    public class NPCDrops {
    	
    	public NPCDrops() {
    		loadDrops();
    	}
    	
    
    	
    	public static HashMap<Integer, int[][]> normalDrops = new HashMap<Integer, int[][]>();
    	public static HashMap<Integer, int[][]> rareDrops = new HashMap<Integer, int[][]>();
    	public static HashMap<Integer, int[]> constantDrops = new HashMap<Integer, int[]>();
    	public static HashMap<Integer, Integer> dropRarity = new HashMap<Integer,Integer>();
    	
    	public void loadDrops() {
    		try {
    			int[][][] npcDrops = new int [62585][][];
    			int[][][] rareDrops2 = new int [62585][][];
    			int[] itemRarity = new int [62585];
    			File f = new File("./Data/cfg/NPCDrops.TSM");
    			Scanner s = new Scanner(f);
    			while (s.hasNextLine()) {
    				String line = s.nextLine();
    				if (line.startsWith("#"))
    					continue;
    				StringTokenizer normalTok = new StringTokenizer(line, "\t");
    				line = s.nextLine();
    				if (line.startsWith("#"))
    					continue;
    				StringTokenizer rareTok = new StringTokenizer(line, "\t");
    				String[] information = normalTok.nextToken().split(":");
    				int npcId = Integer.parseInt(information[0]);
    				itemRarity[npcId] = Integer.parseInt(information[1])-1;
    				npcDrops[npcId] = new int[normalTok.countTokens()][2];
    				rareDrops2[npcId] = new int[rareTok.countTokens()][2];
    				int count = 0;
    				while (normalTok.hasMoreTokens()) {
    					String[] temp = normalTok.nextToken().split(":");
    					npcDrops[npcId][count][0] = Integer.parseInt(temp[0]);
    					npcDrops[npcId][count][1] = Integer.parseInt(temp[1]);
    					count++;
    				}
    				count = 0;
    				while (rareTok.hasMoreTokens()) {
    					String[] temp = rareTok.nextToken().split(":");
    					rareDrops2[npcId][count][0] = Integer.parseInt(temp[0]);
    					//System.out.println("Raredrop: " + count + " " + rareDrops2[npcId][count][0]);
    					rareDrops2[npcId][count][1] = Integer.parseInt(temp[1]);
    					//System.out.println("Raredrop: " + count + " " + rareDrops2[npcId][count][1]);
    					count++;
    				}
    				normalDrops.put(npcId, npcDrops[npcId]);
    				rareDrops.put(npcId, rareDrops2[npcId]);
    				dropRarity.put(npcId, itemRarity[npcId]);
    			}
    			loadConstants();
    		} catch (Exception e) {
    			e.printStackTrace();
    		}	
    	}
    	
    	public void loadConstants() {
    		try {
    			File f = new File("./Data/cfg/NpcConstants.TSM");
    			Scanner s = new Scanner(f);
    			while (s.hasNextLine()) {
    				String line = s.nextLine();
    				if (line.startsWith("#"))
    					continue;
    				StringTokenizer constantTok = new StringTokenizer(line, "\t");
    				int npcId = Integer.parseInt(constantTok.nextToken());
    				int count = 0;
    				int[] temp = new int[constantTok.countTokens()];
    				while (constantTok.hasMoreTokens()) {
    					temp[count] = Integer.parseInt(constantTok.nextToken());
    					count++;
    				}
    				constantDrops.put(npcId,temp);
    			}
    		} catch (Exception e) {
    			e.printStackTrace();
    		}
    	
    	}
    	
    	
    }
    Thank you for the response

    Well i get what you mean .. The problem is that when some npc's (Not All) Are killed this NPCDrops.dropRarity.get(npcs[i].npcType) returns null


    Like Example For killing Nex this --> NPCDrops.dropRarity.get(npcs[i].npcType) returns Null But the npc drops Items ... But What i need is it to check for the rarity ..

    So my point of the question is why it gives Null For some npcs ? And When it checks for drop rarity where does it go to check ? (I think it goes to NpcDrops.tsm -- But what Does it check in there ?)

    This is the drops for nex from NpcDrops.TSM :

    Code:
    #Nex
    5248:35	995:1000000	560:10	9185:1	9185:1	555:150	565:150	805:20	830:20	1079:1	1303:1	1373:1	4131:1	1213:1	1147:1	1113:1	13362:1	1359:1	892:150	1185:1	1249:1	1616:2	50:20	560:199	555:150	565:150	805:20	830:20	1079:1	1303:1	1373:1	4131:1	1213:1	1147:1	1113:1	560:250	1359:1	892:150	1185:1	1249:1	1616:2
    1149:1	1187:1	2366:1	4585:1	2366:1	892:999	2366:1	2366:1	15241:1	1149:1	1187:1	2366:1	4585:1	2366:1	11335:1	2366:1	2366:1	562:100		2713:1		2710:1		2707:1

    Thanks for the Help
    Reply With Quote  
     

  2. #2  
    Ex Rune-Scaper

    Join Date
    Jun 2008
    Posts
    3,534
    Thanks given
    457
    Thanks received
    1,257
    Rep Power
    990
    The piece of code you have in red is checking to see if there is a valid npc. The simple operator != means not equal to. The keyword null represents nothing in java. That's called a null check because you don't want someting that's not there to suddenly drop something its not suppose to. From what I see there are no getters and setters in your NPCDrops class.

    You can tell what something returns in java by looking at the keywords in methods.

    boolean returns true and false

    Here I'm either returning a yes (true) or no (false). The age has either decreased or it has not.
    Code:
    boolean decreased;
    
    boolean hasDecreased() {
    return decreased;
    }
    void is used when your method doesn't return anything.

    Here I'm setting the age to a different number from what ever I put in the methods parameters. I'm not returning any number, I'm just changing the value of age.
    Code:
    void setAge(int age) {
    this.age = age;
    }
    int returns an integer (value)

    Here I'm returning some age.
    Code:
    int age;
    
    int getAge() {
    return age;
    }
    Hope this helps.
    Attached image
    Reply With Quote  
     

  3. Thankful user:


  4. #3  
    Donator

    Join Date
    Apr 2013
    Posts
    99
    Thanks given
    3
    Thanks received
    2
    Rep Power
    15
    Thank you for the response

    Well i get what you mean .. The problem is that when some npc's (Not All) Are killed this NPCDrops.dropRarity.get(npcs[i].npcType) returns null


    Like Example For killing Nex this --> NPCDrops.dropRarity.get(npcs[i].npcType) returns Null But the npc drops Items ... But What i need is it to check for the rarity ..

    So my point of the question is why it gives Null For some npcs ? And When it checks for drop rarity where does it go to check ? (I think it goes to NpcDrops.tsm -- But what Does it check in there ?)

    This is the drops for nex from NpcDrops.TSM :

    Code:
    #Nex
    5248:35	995:1000000	560:10	9185:1	9185:1	555:150	565:150	805:20	830:20	1079:1	1303:1	1373:1	4131:1	1213:1	1147:1	1113:1	13362:1	1359:1	892:150	1185:1	1249:1	1616:2	50:20	560:199	555:150	565:150	805:20	830:20	1079:1	1303:1	1373:1	4131:1	1213:1	1147:1	1113:1	560:250	1359:1	892:150	1185:1	1249:1	1616:2
    1149:1	1187:1	2366:1	4585:1	2366:1	892:999	2366:1	2366:1	15241:1	1149:1	1187:1	2366:1	4585:1	2366:1	11335:1	2366:1	2366:1	562:100		2713:1		2710:1		2707:1
    Reply With Quote  
     

  5. #4  
    Donator

    Join Date
    Apr 2013
    Posts
    99
    Thanks given
    3
    Thanks received
    2
    Rep Power
    15
    Bump

    Some one should know this for sure ??!!!

    Why it returns for nex null ??? Why the method returns null for nex ???!!!!!
    Reply With Quote  
     

  6. #5  
    Donator

    Join Date
    Apr 2013
    Posts
    99
    Thanks given
    3
    Thanks received
    2
    Rep Power
    15
    Any one ?
    Reply With Quote  
     

  7. #6  
    Donator

    Join Date
    Apr 2013
    Posts
    99
    Thanks given
    3
    Thanks received
    2
    Rep Power
    15
    Bump ?
    Reply With Quote  
     

  8. #7  
    Server Developer
    Argyros's Avatar
    Join Date
    Apr 2011
    Posts
    498
    Thanks given
    25
    Thanks received
    31
    Rep Power
    23
    Use Eclipse and find the method in there it should be very easy if you do it that way.
    Reply With Quote  
     

  9. #8  
    Donator

    Join Date
    Apr 2013
    Posts
    99
    Thanks given
    3
    Thanks received
    2
    Rep Power
    15
    I meant what does the method do ?? like goes inside of the NPCDROPS FILE reads the line ... etc

    Can't you guys help me with this ??? Pleasing you ?


    Really
    Reply With Quote  
     

  10. #9  
    Donator

    Join Date
    Apr 2013
    Posts
    99
    Thanks given
    3
    Thanks received
    2
    Rep Power
    15
    What Do you mean ?
    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. need help with webclient [pi]
    By superbombet in forum Help
    Replies: 2
    Last Post: 12-26-2010, 04:43 PM
  2. need help with webclient PI
    By superbombet in forum Help
    Replies: 1
    Last Post: 10-20-2010, 06:51 PM
  3. [PI] Need help with vengbook! [PI]
    By My t4rg fail in forum Help
    Replies: 2
    Last Post: 10-14-2010, 03:23 PM
  4. [PI] Need help with Highscores![/PI] REP++!
    By Alexander in forum Help
    Replies: 4
    Last Post: 07-13-2010, 04:53 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
  •