[Small Release] Random number for npcs

Page 1 of 2 12 LastLast
Results 1 to 15 of 27
  1. #1
    The almighty chicken kippieeej is offline
    MemberRank
    Apr 2008 Join Date
    1,038Posts

    [Small Release] Random number for npcs

    Code:
        public int getRandom(int start, int end) {
            return (int)Math.floor(Math.random()*end+start);
        }
    Add this in NPCConversationManager.java

    how to use:
    Code:
    int lol = cm.getRandom(1, 100);
    that would pick a random number between the 1 and the 100

    this is a small release, but some of you might really need this

    Quick example:
    PHP Code:
    function start() { 
        switch(
    cm.getRandom(1100)) { 
            case 
    1
                
    cm.gainMeso(100000); 
                
    cm.sendOk("Whoa, you've just beaten a chance of 1:100\r\nHere, take 100k mesos!"); 
                
    cm.dispose(); 
                break; 
            case 
    2
            case 
    3
            case 
    4
            case 
    5
            case 
    6
                
    cm.gainMeso(50000); 
                
    cm.sendOk("Whoa, you've just beaten a chance of 1:20\r\nHere, take 50k mesos!"); 
                
    cm.dispose(); 
                break; 
            default: 
                
    cm.sendOk("You haven't won anything, sorry"); 
                
    cm.dispose(); 
                break; 
        } 

    Last edited by kippieeej; 08-02-09 at 12:07 PM.


  2. #2
    Account Upgraded | Title Enabled! xcelinex33 is offline
    MemberRank
    Apr 2008 Join Date
    spooksLocation
    859Posts

    Re: [Small Release] Random number for npcs

    Lmao awesome release! ♥

  3. #3
    Infraction Banned Maple1134 is offline
    MemberRank
    Jun 2008 Join Date
    564Posts

    Re: [Small Release] Random number for npcs

    Nice release, I'm using it =]

  4. #4
    Account Upgraded | Title Enabled! flashlights is offline
    MemberRank
    Jun 2008 Join Date
    307Posts

    Re: [Small Release] Random number for npcs

    Hehe, you can use this for like a number guessing event.
    Thanks

  5. #5
    Interesting... SharpAceX is offline
    MemberRank
    Oct 2008 Join Date
    2,011Posts

    Re: [Small Release] Random number for npcs

    We could improve gachapons with this no?

  6. #6
    Infraction Banned Maple1134 is offline
    MemberRank
    Jun 2008 Join Date
    564Posts

    Re: [Small Release] Random number for npcs

    What's wrong with this?

    Code:
    importPackage(net.sf.odinms.client);
    importPackage(net.sf.odinms.server.life);
    importPackage(net.sf.odinms.net.channel);
    
    var status = 0; 
    var c;
    var em;
    function start() { 
     status = -1; 
     action(1, 0, 0); 
    } 
    
    function action(mode, type, selection) { 
     if (mode == -1) { 
      cm.dispose(); 
     } else { 
      if (status >= 0 && mode == 0) { 
       cm.dispose(); 
       return; 
      } 
      if (mode == 1) 
       status++; 
      else 
       status--; 
    	if(status == 0){
             cm.sendGetText ("Hi i can think of a number :D");
    	}else if(status == 1){  
         lol = cm.getRandom(1, 5);
               if (cm.getText().equalsIgnoreCase("lol")) {
                cm.sendOk ("Congratz");
                cm.dispose();
                } else {
                cm.sendOk ("You suck");
                }
              }
              }
              }

  7. #7
    Valued Member EC15 is offline
    MemberRank
    Jan 2009 Join Date
    120Posts

    Re: [Small Release] Random number for npcs

    Quote Originally Posted by Maple1134 View Post
    What's wrong with this?

    Code:
    importPackage(net.sf.odinms.client);
    importPackage(net.sf.odinms.server.life);
    importPackage(net.sf.odinms.net.channel);
    
    var status = 0; 
    var c;
    var em;
    function start() { 
     status = -1; 
     action(1, 0, 0); 
    } 
    
    function action(mode, type, selection) { 
     if (mode == -1) { 
      cm.dispose(); 
     } else { 
      if (status >= 0 && mode == 0) { 
       cm.dispose(); 
       return; 
      } 
      if (mode == 1) 
       status++; 
      else 
       status--; 
    	if(status == 0){
             cm.sendGetText ("Hi i can think of a number :D");
    	}else if(status == 1){  
         lol = cm.getRandom(1, 5);
               if (cm.getText().equalsIgnoreCase("lol")) {
                cm.sendOk ("Congratz");
                cm.dispose();
                } else {
                cm.sendOk ("You suck");
                }
              }
              }
              }
    that's wrong :
    Code:
    if (cm.getText().equalsIgnoreCase("lol")) {

  8. #8
    Account Upgraded | Title Enabled! Pooperdude is offline
    MemberRank
    Dec 2008 Join Date
    254Posts

    Re: [Small Release] Random number for npcs

    Well Random number for Npc's I guess could be helpful but idk.

  9. #9
    Infraction Banned XxOsirisxX is offline
    MemberRank
    Jul 2008 Join Date
    2,456Posts

    Re: [Small Release] Random number for npcs

    Quote Originally Posted by EC15 View Post
    that's wrong :
    Code:
    if (cm.getText().equalsIgnoreCase("lol")) {
    He don't even declared lol </3

  10. #10
    Account Upgraded | Title Enabled! Pooperdude is offline
    MemberRank
    Dec 2008 Join Date
    254Posts

    Re: [Small Release] Random number for npcs

    Quote Originally Posted by XxOsirisxX View Post
    He don't even declared lol </3
    He dont even declared isn't correct grammar lol.

  11. #11
    Infraction Banned XxOsirisxX is offline
    MemberRank
    Jul 2008 Join Date
    2,456Posts

    Re: [Small Release] Random number for npcs

    Quote Originally Posted by Pooperdude View Post
    He dont even declared isn't correct grammar lol.
    Since when I do care about grammar?

    stop spamming.

    Also lol = variable.

  12. #12
    Account Upgraded | Title Enabled! Pooperdude is offline
    MemberRank
    Dec 2008 Join Date
    254Posts

    Re: [Small Release] Random number for npcs

    haha but you will have to care about grammar one day -.-.

  13. #13
    Infraction Banned XxOsirisxX is offline
    MemberRank
    Jul 2008 Join Date
    2,456Posts

    Re: [Small Release] Random number for npcs

    Quote Originally Posted by Pooperdude View Post
    haha but you will have to care about grammar one day -.-.
    no, because I'm Spanish <3

    unless I do some English in some job :)

  14. #14
    :) Horizon is offline
    MemberRank
    Jan 2009 Join Date
    Illinois, U.S.Location
    2,381Posts

    Re: [Small Release] Random number for npcs

    Quote Originally Posted by Pooperdude View Post
    haha but you will have to care about grammar one day -.-.
    Just be quiet, mind your own business, and stay on topic.

  15. #15
    Back? gmsinister is offline
    MemberRank
    Apr 2008 Join Date
    New YorkLocation
    1,655Posts

    Re: [Small Release] Random number for npcs

    good job except i hate math random lol.



Page 1 of 2 12 LastLast

Advertisement