- Joined
- Jan 23, 2013
- Messages
- 695
- Reaction score
- 101
Probably not a really useful release for most of you, because most of you either, already have it or better, or can't figure it out and won't be able to work this out either.
NPCConversationManager.java
MapleMonsterInformationProvider.java
Please note: I did it this way (seperated it all) for testing only, and never went ahead and fixed it. Array size is still printed!
MapleItemInformationProvider.java
you must create an xml file called items.xml, and populate the data yourself (copy the values from etc, eqp, and consume..don't duck up!)
Also, in most tetra based sources you will have to fix equip loading for them to show up. Hint, it's in getItemData.
If you want screenshots I will supply them, shouldn't be necessary however.
Edit:
Decided I'd add the NPC script in as well, for those who're confused. I'll add screenshots later.
Oh, that also includes the original checkdrop method included with tetrasea.
Here's the screenshots I promised a while ago.
Note they don't show that a quest is required, because they're ilbis..I can assure you that does work.
NPCConversationManager.java
Code:
public void getItemByName(String itemname) { MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
List <Integer> itemId = ii.getItemIdFromName(itemname);
System.out.println(" Array Size is " + itemId.size());
String text = "Please Select Your Item: \r\n";
for (int i = 0; i < itemId.size(); i++) {
text += "#L" + itemId.get(i) + "##i" + itemId.get(i) + "# - " + ii.getName(itemId.get(i)) + "\r\n";
}
sendSimple(text);
}
public void getMobs(int itemid) {
MapleMonsterInformationProvider mi = MapleMonsterInformationProvider.getInstance();
final List<Integer> mobs = MapleMonsterInformationProvider.getInstance().getMobByItem(itemid);
String text = "The following mobs drop your item: \r\n";
for (int i = 0; i < mobs.size(); i++) {
int quest = 0;
if (mi.getDropQuest(mobs.get(i)) > 0) {
quest = mi.getDropQuest(mobs.get(i));
}
int chance = mi.getDropChance(mobs.get(i)) * getClient().getChannelServer().getDropRate();
text += "#o" + mobs.get(i) +"# - " + (Integer.valueOf(chance >= 999999 ? 1000000 : chance).doubleValue() / 10000.0) + "%. " + (quest > 0 && MapleQuest.getInstance(quest).getName().length() > 0 ? ("Requires quest " + MapleQuest.getInstance(quest).getName() + " to be started.") : "") + "\r\n";
}
sendNext(text);
}
MapleMonsterInformationProvider.java
Code:
public int getDropQuest(int monsterId) { PreparedStatement ps = null;
ResultSet rs = null;
int quest = 0;
try {
ps = DatabaseConnection.getConnection().prepareStatement("SELECT questid FROM drop_data where dropperid = ?");
ps.setInt(1, monsterId);
rs = ps.executeQuery();
while (rs.next()) {
quest = rs.getInt("questid");
}
} catch (SQLException e) {
}
return quest;
}
public int getDropChance(int monsterId) {
PreparedStatement ps = null;
ResultSet rs = null;
int chance = 0;
try {
ps = DatabaseConnection.getConnection().prepareStatement("SELECT chance FROM drop_data where dropperid = ?");
ps.setInt(1, monsterId);
rs = ps.executeQuery();
while (rs.next()) {
chance = rs.getInt("chance");
}
} catch (SQLException e) {
}
return chance;
}
public List<Integer> getMobByItem(final int itemId) {
final List<Integer> mobs = new LinkedList<Integer>() {};
PreparedStatement ps = null;
ResultSet rs = null;
try {
ps = DatabaseConnection.getConnection().prepareStatement("SELECT * FROM drop_data WHERE itemid = ?");
ps.setInt(1, itemId);
rs = ps.executeQuery();
int mobid;
while (rs.next()) {
mobid = rs.getInt("dropperid");
if (!mobs.contains(mobid))
mobs.add(mobid);
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
if (ps != null) {
ps.close();
}
if (rs != null) {
rs.close();
}
} catch (SQLException ignore) {
return null;
}
}
return mobs;
}
Please note: I did it this way (seperated it all) for testing only, and never went ahead and fixed it. Array size is still printed!
MapleItemInformationProvider.java
Code:
public List<Integer> getItemIdFromName(String name) { List <Integer> itemReturn = new LinkedList <Integer> ();
MapleDataProvider dataProvider = MapleDataProviderFactory.getDataProvider(new File ("wz/String.wz"));
MapleData data = dataProvider.getData(("items.img"));
List<Pair<Integer, String>> itemPairList = new LinkedList<Pair<Integer, String>>();
for (MapleData itemIdData : data.getChildren()) {
int itemIdFromData = Integer.parseInt(itemIdData.getName());
String itemNameFromData = MapleDataTool.getString(itemIdData.getChildByPath("name"), "NO-NAME");
itemPairList.add(new Pair<Integer, String> (itemIdFromData, itemNameFromData));
}
for (Pair<Integer, String> itemPair : itemPairList) {
if (itemPair.getRight().toLowerCase().contains(name.toLowerCase()) && itemPair.getLeft() > 0) {
if (getItemData(itemPair.getLeft()) != null)
itemReturn.add(itemPair.getLeft());
}
}
return itemReturn;
}
you must create an xml file called items.xml, and populate the data yourself (copy the values from etc, eqp, and consume..don't duck up!)
Also, in most tetra based sources you will have to fix equip loading for them to show up. Hint, it's in getItemData.
If you want screenshots I will supply them, shouldn't be necessary however.
Edit:
Decided I'd add the NPC script in as well, for those who're confused. I'll add screenshots later.
Code:
var status = -1;var item = false;
var map = false;
function start() {
cm.sendSimple("Please choose which method you would like. \r\n#L0#Search by item name#l\r\n#L1#Search mobs on map#l");
}
function action(mode, type, selection) {
status++;
if (mode != 1) {
cm.dispose();
return;
}
if (!item && !map)
if (selection == 0)
item = true;
else if (selection == 1)
map = true;
if (item)
items(selection);
else if (map)
maps(selection);
function items(selection) {
if (status == 0) {
cm.sendGetText("Please type the name of the item you wish to search for:");
} else if (status == 1) {
cm.getItemByName(cm.getText());
} else if (status == 2) {
cm.getMobs(selection);
cm.dispose();
}
}
function maps(selection){
if (status == 0) {
if (cm.getMap().getAllMonstersThreadsafe().size() <= 0) {
cm.sendOk("There are no monsters in this map.");
cm.dispose();
return;
}
var selStr = "Select which monster you wish to check.\r\n\r\n#b";
var iz = cm.getMap().getAllUniqueMonsters().iterator();
while (iz.hasNext()) {
var zz = iz.next();
selStr += "#L" + zz + "##o" + zz + "##l\r\n";
}
cm.sendSimple(selStr);
} else if (status == 1) {
cm.sendNext(cm.checkDrop(selection));
cm.dispose();
}
}
}
Oh, that also includes the original checkdrop method included with tetrasea.
Here's the screenshots I promised a while ago.
Note they don't show that a quest is required, because they're ilbis..I can assure you that does work.
Attachments
You must be registered for see attachments list
Last edited: