Jump to content
  • 0

Question

Posted (edited)

Hello, I would like to understand how the item box system works

Ex:

// Old Card Album Obtainable Items Database
//
// Structure of Database:
// GroupID,ItemID,Rate

IG_CardAlbum,4001,10	// Poring Card
IG_CardAlbum,4002,10	// Fabre Card
IG_CardAlbum,4003,6		// Pupa Card
// Old Blue Box Obtainable Items Database
//
// Structure of Database:
// GroupID,ItemID,Rate

IG_BlueBox,501,12	// Red Potion
IG_BlueBox,502,12	// Orange Potion
IG_BlueBox,503,12	// Yellow Potion
IG_BlueBox,504,12	// White Potion

I would like to know which method is being used to calculate the rate or what it is based on.

thank you, by Hyro~

Edited by Hyroshima

6 answers to this question

Recommended Posts

  • 0
Posted
3 hours ago, AnnieRuru said:

Ty...

But I wanted to understand how it was done to have this rate in% of the examples?

https://github.com/rathena/rathena/blob/master/doc/item_group.txt#L51

Rate: Probability to get the item. Not a percentage value!

Examples:
	IG_MyItemGroup,Knife,5
	IG_MyItemGroup,Dagger,1

	- Knife has chance 5/6 (83.3%) to be obtained
	- Dagger has chance 1/6 (16.7%) to be obtained

 

I created a system in sql:

5ac209956efe9_I1a1KzA1.jpg.f585823ca78631862f2ea5293f16dc5f.jpg

  • id (auto-increment)
  • item_id
  • item_qtd (amount)
  • rate (%)
  • cat (would be like the groupid, box ID.)

 

But the system is basically basic rand (1,100)

	set .@rate,rand(1,100);

	query_sql "SELECT `item_id`,`item_qtd`,`rate` FROM `custom_box` WHERE `rate`>='"+.@rate+"' AND `cat`='"+getarg(0)+"' ORDER BY RAND() LIMIT 1",.@id,.@qtd,.@rt;
	if(!.@id) query_sql "SELECT `item_id`,`item_qtd`,`rate` FROM `custom_box` WHERE `rate`='100' AND `cat`='"+getarg(0)+"' ORDER BY RAND() LIMIT 1",.@id,.@qtd,.@rt;

	if(!.@id){ dispbottom "[ Custom Box ]: Houve um erro, por favor informe a um GM!"; end; }
	getitem .@id,.@qtd;
	end;

 

the rand () method does not work well, so I would like to understand how the rate of the items added in a custom box works.

Thank you in advance for your attention!

By: Hyro~

  • 0
Posted
Rate: Probability to get the item. Not a percentage value!

Examples:
	IG_MyItemGroup,Knife,5
	IG_MyItemGroup,Dagger,1
	IG_MyItemGroup,Jellopy,14

	- Knife has chance 5/20 (25%) to be obtained
	- Dagger has chance 1/20 (5%) to be obtained
	- Jellopy has chance 14/20 (70%) to be obtained

You add all of the numbers, and each item has a rate of number/sum.

sum = 5 + 1 + 14 = 20

Knife = 5 / 20 = 25%

Dagger = 1 / 20 = 5%

Jellopy = 14 / 20 = 70%

  • Love 1
  • 0
Posted (edited)
4 hours ago, Nitrous said:

You add all of the numbers, and each item has a rate of number/sum.

sum = 5 + 1 + 14 = 20

Knife = 5 / 20 = 25%

Dagger = 1 / 20 = 5%

Jellopy = 14 / 20 = 70%

Many thanks for responding ^^..

Then, as you explained, did not have repeated numbers, I figured that's repeated values are indebted by of quantity the sum of rates in which it is repeated correctly?

my example below, how I understood ...

Quote

1 selects all items in the category.
2 sum all values in `rate`
3 after obtaining the values above, each value in `rate` will be defined based on the total value of the sum of of rates,
 and then check each item to see what the value in% is worth of that item in relation to the total value of the sum of rates!


box1
{
    607,5
    608,1
    609,3
    610,5
    611,10
}


Exp1:

    picks up all items in (box1), total: 5

Exp2:

    sum all rates in (box1), total: 24

Exp3:

    then define the value that each item will have a chance:

box1 (defined rate)
{
    607 = 20,83%
    608 = 4,16%
    609 = 12,5%
    610 = 20,83%
    611 = 41,66%

    total percent: 99,98
    total percent rounded (above of ,5): 100 
}

 

Edited by Hyroshima

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...