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