NPC Scripting

Results 1 to 14 of 14
  1. #1
    Account Upgraded | Title Enabled! ooSnowCapxx is offline
    MemberRank
    Jul 2011 Join Date
    250Posts

    NPC Scripting

    Do you guys mind helping me fix this npc please or shorten it! Very much appreciated! :3
    It's kind of messy so you can flame all you want but either than that please help me! (:
    PHP Code:
     var text "Hey Quick Pick One Before I Shoot You!";
        var 
    amount 9;
        var 
    status;
         
        function 
    start() {
            
    status = -1;
            
    action(100);
        }
         
        function 
    action(modetypeselection) {
            if (
    mode == 1)
                
    status++;
            else {
                
    cm.sendOk("#e#kOk, see you next time!");
                
    cm.dispose();
                return;
            }
                if (
    cm.getPlayer().getReborns() <= 9) {
                }
                if (
    status == 12) {
                    
    cm.sendNext("Hello #hI am the Boot camp instructor of Servername, pick a boss to spawn NOW!!");
                }
                else if (
    status == 0) {
            
    cm.sendSimple("Hello #h # I am the Boot camp instructor of Servername. I will spawn 5 mobs at a time.\r\nPick one to spawn.\r\n#b#L0#Snail\r\n#L1#Tiguru\r\n#L2#Pixie\r\n#L3#Desert Rabbit (M)\r\n#L4#Desert Rabbith (F)\r\n#L5#Kill All Monsters");
                }
                        else if (
    status == && cm.getPlayer().getMap().getMonsterCount() > && selection <= 7) {
            
    cm.sendOk("Sorry there are already monsters spawned in this map.");
                
    cm.dispose();
                }
    // wtf are you doing o-o
                
    else if (status == 1) {
                        
    //if (cm.getPlayer().getMap().getMonsterCount() == 0) {
                               
                                
    if (selection == 0) {
                                        if (
    cm.getPlayer().getReborns()<= 9) {
                                        
    cm.summonMob(100100850100010);
                                        if (
    cm.getPlayer().getReborns()>= 10) {
                                        
    cm.sendnext("You have over 10 reborns so you may not use this sorry!");
                                        
    cm.dispose();
                                }
                                }
                                }
                                else if (
    selection == 1) {
                                        if (
    cm.getPlayer().getReborns()<= 9) {
                                        
    cm.summonMob(10012485010000010);
                                        if (
    cm.getPlayer().getReborns()>= 10) {
                                        
    cm.sendsimple("You have over 10 reborns so you may not use this sorry!");
                                        
    cm.dispose();
                                }
                                }
                                }
                                else if (
    selection == 2) {
                                        if (
    cm.getPlayer().getReborns()<= 9) {
                                        
    cm.summonMob(512000085010000010);
                                        if (
    cm.getPlayer().getReborns()>= 10) {
                                        
    cm.sendsimple("You have over 10 reborns so you may not use this sorry!");
                                        
    cm.dispose();
                                }
                                }
                                }
                                else if (
    selection == 3) {
                                        if (
    cm.getPlayer().getReborns()<= 9) {
                                        
    cm.summonMob(210010185010000010);
                                        if (
    cm.getPlayer().getReborns()>= 10) {
                                        
    cm.sendOk("You have over 10 reborns so you may not use this sorry!");
                                        
    cm.dispose();
                                }
                                }
                                }
                                else if (
    selection == 4) {
                                        if (
    cm.getPlayer().getReborns()<= 9) {
                                        
    cm.summonMob(210010085010000010);
                                        if (
    cm.getPlayer().getReborns()>= 10) {
                                        
    cm.sendOk("You have over 10 reborns so you may not use this sorry!");
                                        
    cm.dispose();
                                }
                                }
                                }
                               
                       
                                else if (
    selection == 5) {
                                        
    cm.killallMonsters();
                
    cm.dispose();
                                }
               
                        }
                }
        
    //} 


  2. #2
    Nae-un <33 Thane Krios is offline
    MemberRank
    Jun 2012 Join Date
    CaliforniaLocation
    568Posts

    Re: NPC Scripting

    Spoiler:
    PHP Code:
    var status;
    var 
    mobs = [100100,100124,51200002100101,2100100];

    function 
    start() {
        
    status = -1;
        
    action(1,0,0);
    }

    function 
    action(modetypeselection) {
        (
    mode != cm.dispose() : status++);
        if (
    status == 0) {
            
    text "Hello #h # I am the Boot camp instructor of Servername. I will spawn 5 mobs at a time. You must have 10 rebirths to use this feature.\r\n#L"+mobs.length 1+"#Kill All Mobs";
            for (var 
    0mobs.lengthi++)
            
    text += "\r\n#L"+i+"##o"+i+"#";
            
    cm.sendSimple(text);
        } else if (
    status == 1) {
            if (
    cm.getPlayer().getReborns() < 10) {
                
    cm.sendOk("You need at least 10 reborns to use this feature.");
            } else if (
    selection == (mobs.length 1)) {
                
    cm.killAllMonsters();
            } else {
                
    cm.summonMob(mobs[selection], 850100010); // what is your summonMob function? Edit in the values (850,1000,10) because I have no idea what they are
            
    }
            
    cm.dispose();
        }


  3. #3
    Account Upgraded | Title Enabled! ooSnowCapxx is offline
    MemberRank
    Jul 2011 Join Date
    250Posts

    Re: NPC Scripting

    Quote Originally Posted by Thane Krios View Post
    Spoiler:
    PHP Code:
    var status;
    var 
    mobs = [100100,100124,51200002100101,2100100];

    function 
    start() {
        
    status = -1;
        
    action(1,0,0);
    }

    function 
    action(modetypeselection) {
        (
    mode != cm.dispose() : status++);
        if (
    status == 0) {
            
    text "Hello #h # I am the Boot camp instructor of Servername. I will spawn 5 mobs at a time. You must have 10 rebirths to use this feature.\r\n#L"+mobs.length 1+"#Kill All Mobs";
            for (var 
    0mobs.lengthi++)
            
    text += "\r\n#L"+i+"##o"+i+"#";
            
    cm.sendSimple(text);
        } else if (
    status == 1) {
            if (
    cm.getPlayer().getReborns() < 10) {
                
    cm.sendOk("You need at least 10 reborns to use this feature.");
            } else if (
    selection == (mobs.length 1)) {
                
    cm.killAllMonsters();
            } else {
                
    cm.summonMob(mobs[selection], 850100010); // what is your summonMob function? Edit in the values (850,1000,10) because I have no idea what they are
            
    }
            
    cm.dispose();
        }

    I don't get it where are the mobs llo :0

  4. #4
    Account Upgraded | Title Enabled! Nmb1Gamer is offline
    MemberRank
    Apr 2009 Join Date
    Anime HeavenLocation
    383Posts

    Re: NPC Scripting

    Spoiler:
    PHP Code:
    var status;
    var 
    mobs = [100100,100124,51200002100101,2100100]; // Add mobs up here

    function start() {
        
    status = -1;
        
    action(1,0,0);
    }

    function 
    action(modetypeselection) {
        (
    mode != cm.dispose() : status++); // Not sure if this works. If it does, awesome, I might have to start doing that
        
    if (status == 0) {
            
    text "Hello #h # I am the Boot camp instructor of Servername. I will spawn 5 mobs at a time. You must have 10 rebirths to use this feature.\r\n";
            for (var 
    0mobs.lengthi++) {
                
    text += "\r\n#L"+i+"##o"+mobs[i]+"##l"// forgot to make it mobs[i] and add the #l to the end of the selection
            
    }
            
    text += "\r\n#L"+(mobs.length 1)+"#Kill all mobs#l"// The previous location it was at would have worked too, although it's just more visually appealing to me down here.
            
    cm.sendSimple(text);
        } else if (
    status == 1) {
            if (
    cm.getPlayer().getReborns() < 10) {
                
    cm.sendOk("You need at least 10 reborns to use this feature.");
            } else {
                if (
    selection == (mobs.length 1)) {
                    
    cm.killAllMonsters();
                } else {
                    
    cm.summonMob(mobs[selection], 850100010); // what is your summonMob function? Edit in the values (850,1000,10) because I have no idea what they are
                
    }
            }
            
    cm.dispose();
        }



    Modified Thane's original script and fixed a few minor errors. Also added some notes to clarify things

  5. #5
    Nae-un <33 Thane Krios is offline
    MemberRank
    Jun 2012 Join Date
    CaliforniaLocation
    568Posts

    Re: NPC Scripting

    Haha, thanks for patching it up. Though I've never used #l at the end of a selection for loops. And ternaries do indeed work.


    And just to be curious, how many errors did you fix? I could only spot 1 now that I'm awake.
    Last edited by Thane Krios; 01-05-13 at 02:25 PM.

  6. #6
    Account Upgraded | Title Enabled! linkdamasta is offline
    MemberRank
    Oct 2009 Join Date
    280Posts

    Re: NPC Scripting

    The mobs are declared as the IDs in the mob array variable at the top of the script. It's called later in the for loop:

    PHP Code:
    if (status == 0) {
            
    text "Hello #h # I am the Boot camp instructor of Servername. I will spawn 5 mobs at a time. You must have 10 rebirths to use this feature.\r\n";
            for (var 
    0mobs.lengthi++) {
                
    text += "\r\n#L"+i+"##o"+mobs[i]+"##l";
            }
            
    text += "\r\n#L"+(mobs.length 1)+"#Kill all mobs#l";
            
    cm.sendSimple(text);
        } 
    This creates a loop that repeats the code enclosed in the squigglyparens until the loop function is complete: for (var i = 0; i < mobs.length; i++)

    i is declared as the loop integer and is set to 0. mobs.length retrieves the number of items in the mobs array as an integer. If i is less than that number, it does the code inside the squigglyparens and then increases i by 1, then checks the for loop criteria again before looping again or cutting it off if i is no longer smaller than mobs.length. This is practical because we now have a loop variable, and the loop repeats only as many times as there are mobs you want spawnable. Using this, every time we loop, we can add another selection for one of the mobs until they're all available. This is done with:

    PHP Code:
    text += "\r\n#L"+i+"##o"+mobs[i]+"##l"
    This is what is looped. It plugs in the loop variable, i, as the selection value and to retrieve the mob id from the array. If you plug in, say, 1, you get: "\r\n#L1##o"+mobs[1]+"##l", or you have a new line, on which you have selection 1 which spawns the monster 100124 (value one in the array), and gives you the name (That's what the #o does). This then repeats for i = 2, then 3, then 4, until you have a selection for every monster in the array. It's basically like typing it all in manually like you did, except it's in 3 lines, and it can be easily expanded seamlessly just by throwing in as many new monster IDs as you want into the array as you want.

    I hope you learned something from this! It took a while to type. :)

  7. #7
    Account Upgraded | Title Enabled! ooSnowCapxx is offline
    MemberRank
    Jul 2011 Join Date
    250Posts

    Re: NPC Scripting

    Quote Originally Posted by Nmb1Gamer View Post
    Spoiler:
    PHP Code:
    var status;
    var 
    mobs = [100100,100124,51200002100101,2100100]; // Add mobs up here

    function start() {
        
    status = -1;
        
    action(1,0,0);
    }

    function 
    action(modetypeselection) {
        (
    mode != cm.dispose() : status++); // Not sure if this works. If it does, awesome, I might have to start doing that
        
    if (status == 0) {
            
    text "Hello #h # I am the Boot camp instructor of Servername. I will spawn 5 mobs at a time. You must have 10 rebirths to use this feature.\r\n";
            for (var 
    0mobs.lengthi++) {
                
    text += "\r\n#L"+i+"##o"+mobs[i]+"##l"// forgot to make it mobs[i] and add the #l to the end of the selection
            
    }
            
    text += "\r\n#L"+(mobs.length 1)+"#Kill all mobs#l"// The previous location it was at would have worked too, although it's just more visually appealing to me down here.
            
    cm.sendSimple(text);
        } else if (
    status == 1) {
            if (
    cm.getPlayer().getReborns() < 10) {
                
    cm.sendOk("You need at least 10 reborns to use this feature.");
            } else {
                if (
    selection == (mobs.length 1)) {
                    
    cm.killAllMonsters();
                } else {
                    
    cm.summonMob(mobs[selection], 850100010); // what is your summonMob function? Edit in the values (850,1000,10) because I have no idea what they are
                
    }
            }
            
    cm.dispose();
        }



    Modified Thane's original script and fixed a few minor errors. Also added some notes to clarify things
    Ahhhhhhhhhhh The npc is correct except that is a 0-10 rbs helper LOL :3 Not you need 10 rbs to use it :p And the 850,10000, 10 are the hp and exp and 10 spawns
    Last edited by ooSnowCapxx; 02-05-13 at 06:36 AM.

  8. #8
    Nae-un <33 Thane Krios is offline
    MemberRank
    Jun 2012 Join Date
    CaliforniaLocation
    568Posts

    Re: NPC Scripting

    Quote Originally Posted by ooSnowCapxx View Post
    Ahhhhhhhhhhh The npc is correct except that is a 0-10 rbs helper LOL :3 Not you need 10 rbs to use it :p And the 850,10000, 10 are the hp and exp and 10 spawns


    The rebirths conditions didn't look like that in your original script.

  9. #9
    Account Upgraded | Title Enabled! ooSnowCapxx is offline
    MemberRank
    Jul 2011 Join Date
    250Posts

    Re: NPC Scripting

    Quote Originally Posted by Thane Krios View Post
    The rebirths conditions didn't look like that in your original script.
    It's messy but it's soppose to spawn those monsters spawn 10 wiith 1000 exp or something like that :3 and only allowed for 0-10 rbs :3

  10. #10
    Account Upgraded | Title Enabled! Nmb1Gamer is offline
    MemberRank
    Apr 2009 Join Date
    Anime HeavenLocation
    383Posts

    Re: NPC Scripting

    If you want it to work only with people from 0 - 10 rebirths just change
    PHP Code:
            if (cm.getPlayer().getReborns() < 10) { 
    to this
    PHP Code:
            if (cm.getPlayer().getReborns() >= 10) { 
    Quote Originally Posted by Thane Krios View Post
    Haha, thanks for patching it up. Though I've never used #l at the end of a selection for loops. And ternaries do indeed work.


    And just to be curious, how many errors did you fix? I could only spot 1 now that I'm awake.
    It was just that mob[i] and missing the #l that I noticed. #l might not be necessary anymore, it's been awhile since I've NPC scripted so I could be wrong lol.

  11. #11
    Account Upgraded | Title Enabled! ooSnowCapxx is offline
    MemberRank
    Jul 2011 Join Date
    250Posts

    Re: NPC Scripting

    How do I make it so that theres a set amount of exp on that mob? And how do i make it so that it checks if you have 20 rbs or not to enter? :3
    Last edited by ooSnowCapxx; 03-05-13 at 06:56 AM.

  12. #12
    Account Upgraded | Title Enabled! linkdamasta is offline
    MemberRank
    Oct 2009 Join Date
    280Posts

    Re: NPC Scripting

    Quote Originally Posted by ooSnowCapxx View Post
    How do I make it so that theres a set amount of exp on that mob? And how do i make it so that it checks if you have 20 rbs or not to enter? :3
    Mob EXP is a server side WZ setting, at least if I get what you're asking. You need to go to your wz\Mob\(mobid).img\info and change the exp property. At least I think so, it has been quite a while.

  13. #13
    Account Upgraded | Title Enabled! ooSnowCapxx is offline
    MemberRank
    Jul 2011 Join Date
    250Posts

    Re: NPC Scripting

    The 100100, 10000 <- exp, 10 <- amount of mob that spawns

  14. #14
    Account Upgraded | Title Enabled! linkdamasta is offline
    MemberRank
    Oct 2009 Join Date
    280Posts

    Re: NPC Scripting

    Okay, so you want to go to: (Your repack folder)\wz\Mob.wz\0100100.img, open it with notepad++ or some other editor.

    In there, go down to line 15:

    Code:
        <int name="exp" value="3" />
    And change the value to 10000.

    Save, restart the server. Also, keep in mind that this will be affected by your server's multiplier, so if you want it to be 10000 but are at x100 exp, just set it to 100.



Advertisement