Jump to content
  • 0

Box chance and announcement


ADMSarah

Question


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.03
  • Content Count:  144
  • Reputation:   10
  • Joined:  08/19/23
  • Last Seen:  

Can someone help me to modify this function?

Quote

function    script    AROCG    {
    .@amt = rand(1,100);
    getitem 50007,.@amt;
    announce "["+strcharinfo(0)+"] got [ "+.@amt+"x "+getitemname(50007)+"] from AsurielRO Coins Bag.",0;
    end;
}

I want the following:

  • 1 to 10 = 99%
  • 11 to 20 = 80%
  • 21 to 30 = 75%
  • 31 to 50 = 50%
  • 51 to 100 = 1%

The announcement also includes what are the percentage of each category.

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  75
  • Reputation:   11
  • Joined:  12/16/11
  • Last Seen:  

5 hours ago, Questune said:

Can someone help me to modify this function?

I want the following:

  • 1 to 10 = 99%
  • 11 to 20 = 80%
  • 21 to 30 = 75%
  • 31 to 50 = 50%
  • 51 to 100 = 1%

The announcement also includes what are the percentage of each category.

Hello, I think there is a mistake in % thinking... all % must be 100, you can't calculate 99% 1 to 10 or 50% 11 to 20, must be something like:

49% -> 1 to 10 coins
25% -> 11 to 20 coins
15% -> 21 to 30 coins
5% -> 31 to 50 coins
1% -> 51 to 100 coins

 

function	script	AROCG	{
    set .@luckyRate, rand(100);
    set .@amount, rand(51, 100); // 1% chance
    set .@chance$, "1%";
    if (.@luckyRate >= 0 && .@luckyRate < 49) {// 49% chance
        set .@amount, rand(1, 10);
        set .@chance$, "50%";
    } else if (.@luckyRate >= 49 && .@luckyRate < 74) { // 25% chance
        set .@amount, rand(11, 20);
        set .@chance$, "25%";
    } else if (.@luckyRate >= 49 && .@luckyRate < 74) { // 15% chance
        set .@amount, rand(21, 30);
        set .@chance$, "15%";
    } else if (.@luckyRate >= 49 && .@luckyRate < 74) { // 5% chance
        set .@amount, rand(31, 50);
        set .@chance$, "5%";
    }
    getitem 50007, .@amount;
    announce "[" + strcharinfo(0) + "]: got [" + .@amount + "x " + getitemname(50007) + "] at " + .@chance$ + "% chance, from AsurielRO Coins Bag.", 0;
    end;
}

Test before going production, I could not test, but I'm pretty sure this works 100%.

  • Love 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.03
  • Content Count:  144
  • Reputation:   10
  • Joined:  08/19/23
  • Last Seen:  

Thank you! works perfectly!

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  75
  • Reputation:   11
  • Joined:  12/16/11
  • Last Seen:  

Sorry I did a mistake copying paste, this is the proper version corresponding to the % configured.

function	script	AROCG	{
    set .@luckyRate, rand(100);
    set .@amount, rand(51, 100); // 1% chance
    set .@chance$, "1%";
    if (.@luckyRate >= 0 && .@luckyRate < 49) {// 49% chance
        set .@amount, rand(1, 10);
        set .@chance$, "50%";
    } else if (.@luckyRate >= 49 && .@luckyRate < 74) { // 25% chance
        set .@amount, rand(11, 20);
        set .@chance$, "25%";
    } else if (.@luckyRate >= 74 && .@luckyRate < 89) { // 15% chance
        set .@amount, rand(21, 30);
        set .@chance$, "15%";
    } else if (.@luckyRate >= 89 && .@luckyRate < 94) { // 5% chance
        set .@amount, rand(31, 50);
        set .@chance$, "5%";
    }
    getitem 50007, .@amount;
    announce "[" + strcharinfo(0) + "]: got [" + .@amount + "x " + getitemname(50007) + "] at " + .@chance$ + "% chance, from AsurielRO Coins Bag.", 0;
    end;
}

 

  • Love 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.03
  • Content Count:  144
  • Reputation:   10
  • Joined:  08/19/23
  • Last Seen:  

12 minutes ago, rokimoki said:

Sorry I did a mistake copying paste, this is the proper version corresponding to the % configured.

function	script	AROCG	{
    set .@luckyRate, rand(100);
    set .@amount, rand(51, 100); // 1% chance
    set .@chance$, "1%";
    if (.@luckyRate >= 0 && .@luckyRate < 49) {// 49% chance
        set .@amount, rand(1, 10);
        set .@chance$, "50%";
    } else if (.@luckyRate >= 49 && .@luckyRate < 74) { // 25% chance
        set .@amount, rand(11, 20);
        set .@chance$, "25%";
    } else if (.@luckyRate >= 74 && .@luckyRate < 89) { // 15% chance
        set .@amount, rand(21, 30);
        set .@chance$, "15%";
    } else if (.@luckyRate >= 89 && .@luckyRate < 94) { // 5% chance
        set .@amount, rand(31, 50);
        set .@chance$, "5%";
    }
    getitem 50007, .@amount;
    announce "[" + strcharinfo(0) + "]: got [" + .@amount + "x " + getitemname(50007) + "] at " + .@chance$ + "% chance, from AsurielRO Coins Bag.", 0;
    end;
}

 

Thanks Mate!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  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.

×
×
  • Create New...