[Add-On]Upgrade Equip NPC

Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Ultimate Member derick is offline
    MemberRank
    Jul 2010 Join Date
    173Posts

    [Add-On]Upgrade Equip NPC


    RaGEZONE Recommends

    RaGEZONE Recommends

    PHP Code:
    //script by Derick.
    importPackage(Packages.server);
    importPackage(Packages.client);
    var 
    item=Array(
    [
    50100, [[2004000001], [1004000009]]],
    [
    75125, [[2504000023], [1254000030]]],
    [
    100150, [[2504000058], [2004000059]]],
    [
    100200, [[1754000232], [1754000233]]],
    [
    150200, [[2504000042], [3004000014]]],
    [
    200250, [[3004000022], [3004000025]]],
    [
    250300, [[3004000268], [3004000269], [3004000270]]]);
    // 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 
    0;  i<item[itemid][2].lengthi++){
            
    cm.gainItem(item[itemid][2][i][1], -item[itemid][2][i][0]);
        }
    }
    function 
    haveItem(){
        var 
    b=true;
        for (var 
    0;  i<item[itemid][2].lengthi++){
            if (!
    cm.haveItem(item[itemid][2][i][1],item[itemid][2][i][0])){
                
    b=false;
                break;
            }
        }
        return 
    b;
    }
    function 
    getItems(){
        var 
    derp ="";
        for (var 
    =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), se1true);
                
    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 shitty NPC.. meh.
    also the only function in NPCConversationManager that you need is EquipList(MapleClient), but that's becoming pretty common nowadays.
    Last edited by Shawn; 08-04-11 at 08:01 PM.


  2. #2
    Infraction Banned rice is offline
    GammaRank
    Nov 2009 Join Date
    2,957Posts

    Re: Upgrade Equip NPC

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

  3. #3
    Account Inactive Xuraz is offline
    InactiveRank
    Apr 2011 Join Date
    SwedenLocation
    177Posts

    Re: Upgrade Equip NPC

    Thanks i will try this when i get back from school :)

  4. #4
    JavaScript Is Best Script Jash is offline
    True MemberRank
    Dec 2010 Join Date
    SingaporeLocation
    697Posts

    Re: Upgrade Equip NPC

    Quote Originally Posted by eric View Post
    y do peeple put Array([asdf]) instead of just [asdf]
    Cause that's how you declare arrays in javascript

  5. #5
    Infraction Banned rice is offline
    GammaRank
    Nov 2009 Join Date
    2,957Posts

    Re: Upgrade Equip NPC

    Quote Originally Posted by Jash View Post
    Cause that's how you declare arrays in javascript
    yea but it's longer and ugly to do that way

  6. #6
    bleh.... Shawn is offline
    The OmegaRank
    Oct 2008 Join Date
    Mississauga, CaLocation
    6,123Posts

    Re: Upgrade Equip NPC

    Quote Originally Posted by Jash View Post
    Cause that's how you declare arrays in javascript
    That's only one way to declare an array. eric is right.

    PHP Code:
    var imAnArray = new Array("blah","blah");
    var 
    imAnArray = ["blah","blah"];
    var 
    imAnArray = new Array(123123);
    var 
    imAnArray = [123,123]; 
    Both versions work, which is what he was referring to.
    Last edited by Shawn; 07-04-11 at 04:04 AM.

    Quote Originally Posted by Russell Peters
    I have a theory. I believe that the size of your penis is in indirect correlation with how much sex you will have in your life. The smaller your dick, the more you will fuck. You dont believe me, look at the two largest populations in the world

    RIP Akaruz, The Godfather

    Spoiler:

    mental is hot
    Spoiler:

    This is a true story
    Spoiler:

    This message is endorsed by Shawn and not added by MentaL.



  7. #7
    Alpha Member Soulfist is offline
    Alpha MaleRank
    Dec 2010 Join Date
    a hovelLocation
    1,835Posts

    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.

  8. #8
    Account Upgraded | Title Enabled! MuTrex is offline
    True MemberRank
    Jul 2007 Join Date
    190Posts

    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 by MuTrex; 07-04-11 at 06:19 PM.

  9. #9
    Alpha Member Soulfist is offline
    Alpha MaleRank
    Dec 2010 Join Date
    a hovelLocation
    1,835Posts

    Re: Upgrade Equip NPC

    @pincher

    Its a method, not a function.

  10. #10
    Account Upgraded | Title Enabled! MuTrex is offline
    True MemberRank
    Jul 2007 Join Date
    190Posts

    Re: Upgrade Equip NPC

    Quote Originally Posted by Soulfist View Post
    @pincher

    Its a method, not a function.
    true.. sowwiee.. let me edit. :)

  11. #11
    offonline King Grub is offline
    GammaRank
    Aug 2009 Join Date
    Spring fieldLocation
    3,311Posts

    Re: Upgrade Equip NPC

    Quote Originally Posted by Soulfist View Post
    @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.

  12. #12
    Ultimate Member derick is offline
    MemberRank
    Jul 2010 Join Date
    173Posts

    Re: [Add-On]Upgrade Equip NPC

    functions don't always return a value. Well at least functions in js.

  13. #13
    Account Inactive chlwotjd678 is offline
    InactiveRank
    Apr 2011 Join Date
    49Posts

    Re: [Add-On]Upgrade Equip NPC

    How will I make this so that it can be used only 1 time for every item?

  14. #14
    Account Inactive BrenMS is offline
    InactiveRank
    Mar 2011 Join Date
    54Posts

    Re: [Add-On]Upgrade Equip NPC

    Thanks

  15. #15
    Account Inactive zImagine is offline
    InactiveRank
    Apr 2011 Join Date
    81Posts

    Re: [Add-On]Upgrade Equip NPC

    Thanks :]




Page 1 of 2 12 LastLast

Advertisement