Jump to content

Recommended Posts

Posted

I understand how to make the mob drops 0-2 dropping only 1 out of 2 and sometimes nothing, but how would I increase that number to say 10? 1-10 and only 1 out of 10 items? This is what I have now.

 

    protected void dropFewItems(boolean par1, int par2)

    {

        int random = this.rand.nextInt(4) + this.rand.nextInt(1 + par2);

       

for (int k = 0; k < random; ++k)

        {

 

        if(k == 2){

       

            this.dropItem(PhantasyRealmsItems.blade, 1);

            }

       

        else

       

        if (k == 1){

       

        this.dropItem(PhantasyRealmsItems.brand, 1);

        }

Posted

Well, just change how you calculate the number. Random.nextInt(n) gives you a number between 0 (inclusive) and n (exclusive).

So Random.nextInt(3) gives you 0, 1 or 2. Then just use math to get to the range you want.

 

yes but when I try to add on to this

      for (int k = 0; k < random; ++k)

        {

       

        if(k == 2){

         

              this.dropItem(PhantasyRealmsItems.blade, 1);

            }

       

        else

         

        if (k == 1){

         

          this.dropItem(PhantasyRealmsItems.brand, 1);

        }

 

        else

         

        if (k == 3){

         

          this.dropItem(PhantasyRealmsItems.brand, 1);

        }

 

and so on it just makes killing the mob  drop both items after the first else.. I dont know Im at a loss for what to do after setting Random.nextInt(n) to a higher number.

Posted

First select the drop type, it's a number from 0-9 (10 possible types):

int dropType = rand.nextInt(10);

 

Then select how many of that Item to drop (1-10):

int dropAmount = 1 + rand.nextInt(10);

 

Then switch on the drop type and drop the selected amount of it. This is not hard.

 

No sorry, I read your comment wrong, there are 10 possible Items a mob can drop, each time a mob is killed 1 out of those 10 items is dropped.

Posted

Then just remove the drop amount part. Just select the drop type and drop it...

Thanks, I know it may seem basic to you guys but I learn by trial and error and by actually testing with things not just reading about them, and I appreciate you helping me out. Thank you

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.