Jump to content
  • 0

Box that has a chance to give % item


Yudax

Question


  • Group:  Members
  • Topic Count:  57
  • Topics Per Day:  0.01
  • Content Count:  248
  • Reputation:   7
  • Joined:  11/27/12
  • Last Seen:  

I have an item:

25620,3D_Glasses_Box,Box of Minion,2,0,,0,,,,,0xFFFFFFFF,7,2,,,,,,{ },{},{}

Is there a possible way that when a player double click's this item, it gives a random item with these sets and its percentage?;

20103 - 60%

20104 - 10%

20105 - 10%

20106- 10%

20106 - 5%

20107 - 5%

 

so like its;

getitem 20103,1; getitem 20104,1;....

 

Link to comment
Share on other sites

9 answers to this question

Recommended Posts

  • 2

  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  143
  • Reputation:   30
  • Joined:  12/23/11
  • Last Seen:  

{if(rand(100)>60) getitem 20103,1; if(rand(100)>10) getitem 20104,1; ... }
Link to comment
Share on other sites

  • 1

  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  

function	script	box____	{
	setarray .@reward,  20103, 60,
						20104, 10,
						20105, 10,
						20106, 10,
						20106, 5,
						20107, 5;
	set .@size, getarraysize( .@reward );
	for( set .@i, 1; .@i < .@size; .@i += 2 ) {
		.@percent[.@i] = .@total + .@reward[.@i];
		.@total += .@reward[.@i];
	}
	.@r = rand( .@total +1 );
	for( set .@i, 1; .@i < .@size; .@i += 2 )
		if( .@percent[.@i] > .@r )
			break;
	getitem .@reward[ .@i-1 ], 1;
	end;
}

EDIT : Fix a mistake.

25620,3D_Glasses_Box,Box of Minion,2,0,,0,,,,,0xFFFFFFFF,7,2,,,,,,{ callfunc "box____"; },{},{}
  • Upvote 3
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  62
  • Topics Per Day:  0.02
  • Content Count:  296
  • Reputation:   4
  • Joined:  02/19/17
  • Last Seen:  

How to put percentage to this script?

{getitem callfunc("F_Rand",7078,7079,7080,7081,7082,7083,7084,7085,7086,7087),1;}{}{}

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.01
  • Content Count:  40
  • Reputation:   0
  • Joined:  02/26/21
  • Last Seen:  

Sir Capuche, please guide where to add bc_all for certain item opened?

Link to comment
Share on other sites

  • -1

  • Group:  Members
  • Topic Count:  57
  • Topics Per Day:  0.01
  • Content Count:  248
  • Reputation:   7
  • Joined:  11/27/12
  • Last Seen:  

setarray .@reward, 20103, 60,

            20104, 10,

            20105, 10,

            20106, 10,

            20106, 5,

            20107, 5;

            20107, 805;

            20107, 60;

in red must be ,

the rest is right.

 

thank you sir!

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  57
  • Topics Per Day:  0.01
  • Content Count:  248
  • Reputation:   7
  • Joined:  11/27/12
  • Last Seen:  

Thank you sir, If I like to add another Item, do I have to edit one of these?

.@size = getarraysize( .@reward );
	for( set .@i, 1; .@i < .@size; .@i += 2 )
		.@percent[.@i] += .@reward[.@i];
	.@r = rand( .@percent[ .@size -1 ] +1 );
	for( set .@i, 1; .@i < .@size; .@i += 2 )
		if( .@percent[.@i] > .@r )
			break;
	getitem .@reward[ .@i-1 ], 1;
	return;
function	script	box____	{
	setarray .@reward,  20103, 60,
						20104, 10,
						20105, 10,
						20106, 10,
						20106, 5,
						20107, 5;
	.@size = getarraysize( .@reward );
	for( set .@i, 1; .@i < .@size; .@i += 2 )
		.@percent[.@i] += .@reward[.@i];
	.@r = rand( .@percent[ .@size -1 ] +1 );
	for( set .@i, 1; .@i < .@size; .@i += 2 )
		if( .@percent[.@i] > .@r )
			break;
	getitem .@reward[ .@i-1 ], 1;
	return;
}
25620,3D_Glasses_Box,Box of Minion,2,0,,0,,,,,0xFFFFFFFF,7,2,,,,,,{ callfunc "box____"; },{},{}

 

I made it work like the old one, but I was wondering whether this has the same effect just like you did?

63,20103,70
63,20296,10
63,20703,10
63,20705,10
63,20706,10
63,20707,10
63,20294,10
63,20113,10
63,20114,10
63,20115,10
63,20116,10
63,20702,10
Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  

I made it work like the old one, but I was wondering whether this has the same effect just like you did?

The effect is the same : you get an item randomly.

 

 

Thank you sir, If I like to add another Item, do I have to edit one of these?

No, just add in this

	setarray .@reward,  20103, 60,
			20104, 10,
			20105, 10,
			20106, 10,
			20106, 5,
			20107, 5;

<item ID>, <rate>

The total can be above 100

 

 

 

 

Btw I made a mistake in the previous function. I edited the previous post, please take the new function.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  57
  • Topics Per Day:  0.01
  • Content Count:  248
  • Reputation:   7
  • Joined:  11/27/12
  • Last Seen:  

I made it work like the old one, but I was wondering whether this has the same effect just like you did?

The effect is the same : you get an item randomly.

 

 

>Thank you sir, If I like to add another Item, do I have to edit one of these?

No, just add in this

	setarray .@reward,  20103, 60,
			20104, 10,
			20105, 10,
			20106, 10,
			20106, 5,
			20107, 5;

<item ID>, <rate>

The total can be above 100

 

 

 

 

Btw I made a mistake in the previous function. I edited the previous post, please take the new function.

 

 

Okay thanks, I can make it like this right? You said Its okay that the total can be above 100.

setarray .@reward,  20103, 60,
			20104, 10,
			20105, 10,
			20106, 10,
			20106, 5,
			20107, 5;
			20107, 80;
			20107, 60;
Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  

setarray .@reward, 20103, 60,

            20104, 10,

            20105, 10,

            20106, 10,

            20106, 5,

            20107, 5;

            20107, 805;

            20107, 60;

in red must be ,

the rest is right.

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...