Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[Add-On]Upgrade Equip NPC

Initiate Mage
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:
Custom Title Activated
Member
Joined
Nov 27, 2009
Messages
1,905
Reaction score
948
Re: Upgrade Equip NPC

y do peeple put Array([asdf]) instead of just [asdf]
 
Initiate Mage
Joined
Apr 1, 2011
Messages
88
Reaction score
0
Re: Upgrade Equip NPC

Thanks i will try this when i get back from school :)
 
JavaScript Is Best Script
Joined
Dec 13, 2010
Messages
631
Reaction score
131
Re: Upgrade Equip NPC

y do peeple put Array([asdf]) instead of just [asdf]

Cause that's how you declare arrays in javascript
 
bleh....
Member
Joined
Oct 15, 2008
Messages
2,898
Reaction score
1,129
Re: Upgrade Equip NPC

Cause that's how you declare arrays in javascript

That's only one way to declare an array. eric is right.

PHP:
var imAnArray = new Array("blah","blah");
var imAnArray = ["blah","blah"];
var imAnArray = new Array(123, 123);
var imAnArray = [123,123];

Both versions work, which is what he was referring to.
 
Last edited:
Legendary Battlemage
Member
Joined
Dec 13, 2010
Messages
649
Reaction score
140
Re: Upgrade Equip NPC

yes yes, what eric said. But nice job anywayz derick. Kinda funny how i was JUST about to do this o_o. But i think you did a pretty good job.
 
Junior Spellweaver
Joined
Jul 1, 2007
Messages
159
Reaction score
16
Re: Upgrade Equip NPC

nice man thank you probably i will add that into my server. :)

and here is the method if you ain't got it..

public String EquipList(MapleClient c) {
StringBuilder str = new StringBuilder();
MapleInventory equip = c.getPlayer().getInventory(MapleInventoryType.EQUIP);
List<String> stra = new LinkedList<String>();
for (IItem item : equip.list()) {
stra.add("#L"+item.getPosition()+"##v"+item.getItemId()+"##l");
}
for (String strb : stra) {
str.append(strb);
}
return str.toString();
}
 
Last edited:
Legendary Battlemage
Member
Joined
Dec 13, 2010
Messages
649
Reaction score
140
Re: Upgrade Equip NPC

@pincher

Its a method, not a function.
 
offonline
Member
Joined
Aug 5, 2009
Messages
1,403
Reaction score
164
Re: Upgrade Equip NPC

@pincher

Its a method, not a function.

That doesn't really matter since most programmers will understand what you mean, but yeah technically you are right as functions are a block of code that are perform a specific task and return a value.
 
Initiate Mage
Joined
Apr 21, 2011
Messages
18
Reaction score
0
How will I make this so that it can be used only 1 time for every item?
 
Back
Top