- Joined
- Jul 24, 2010
- Messages
- 31
- Reaction score
- 21
PHP:
//script by Derick.
importPackage(Packages.server);
importPackage(Packages.client);
var item=Array(
[50, 100, [[200, 4000001], [100, 4000009]]],
[75, 125, [[250, 4000023], [125, 4000030]]],
[100, 150, [[250, 4000058], [200, 4000059]]],
[100, 200, [[175, 4000232], [175, 4000233]]],
[150, 200, [[250, 4000042], [300, 4000014]]],
[200, 250, [[300, 4000022], [300, 4000025]]],
[250, 300, [[300, 4000268], [300, 4000269], [300, 4000270]]]);
// syntax: [(increase on dex/str/int/luk), (increase in Wep Attack), [[item 1 amount, item 1 ID], [item 2 amount, item 2 ID], (this is optional) [item3 amount, item 3 id]]
var itemid=Math.floor(Math.random()*item.length);
var st =-1;
var equip;
var equip2;
var se;
function removeItems(){
for (var i = 0; i<item[itemid][2].length; i++){
cm.gainItem(item[itemid][2][i][1], -item[itemid][2][i][0]);
}
}
function haveItem(){
var b=true;
for (var i = 0; i<item[itemid][2].length; i++){
if (!cm.haveItem(item[itemid][2][i][1],item[itemid][2][i][0])){
b=false;
break;
}
}
return b;
}
function getItems(){
var derp ="";
for (var i =0;i<item[itemid][2].length;i++){
derp+=item[itemid][2][i][0]+" #i"+item[itemid][2][i][1]+"# #t"+item[itemid][2][i][1]+"#\r\n";
}
return derp;
}
function start(){
cm.sendYesNo("Hey I can upgrade one of your items by "+item[itemid][0]+" on all stats and "+item[itemid][1]+" on yourWep Attack. However, you'll need the following items: \r\n"+getItems());
}
function action(m,t,s){
if (m<1)
cm.dispose();
else{
st++;
if (st==0){
if (haveItem()){
cm.sendSimple("Pick an item to update.\r\n"+cm.EquipList(cm.getClient()));
}else {
cm.sendOk("You don't have these items: "+getItems());
cm.dispose();
}
} else if (st==1){
se=s;
var gain = item[itemid][0];
var gain2 = item[itemid][1];
equip=MapleItemInformationProvider.getInstance().getEquipById(cm.getPlayer().getInventory(MapleInventoryType.getByType(1)).getItem(s).getItemId());
equip2 = cm.getPlayer().getInventory(MapleInventoryType.getByType(1)).getItem(s);
equip.setDex(equip2.getDex()+gain);
equip.setStr(equip2.getDex()+gain);
equip.setInt(equip2.getInt()+gain);
equip.setLuk(equip2.getLuk()+gain);
equip.setWatk(equip2.getWatk()+gain2);
cm.sendYesNo("Are you sure you want to upgrade your #r#t"+equip.getItemId()+"#?");
} else if (st==2){
MapleInventoryManipulator.removeFromSlot(cm.getClient(), MapleInventoryType.getByType(1), se, 1, true);
MapleInventoryManipulator.addFromDrop(cm.getClient(), equip);
removeItems();
cm.dispose();
}
}
}
Basically this NPC randomly fetches an array, which contains a few items and upgrade stat values. You can use 1 of the 6 options to gain more stats on items already in your equips.
If you just look at the script it's pretty self explanatory..
also, sorry that I had to release a crappy NPC.. meh.
also the only function in NPCConversationManager that you need is EquipList(MapleClient), but that's becoming pretty common nowadays.
Last edited by a moderator: