Lootdrop Probability

General support forum. If you require assistance and your problem doesnt fall in any of the other categories, this is the forum for you!

Moderator: Team Members

Forum rules
READ THE FORUM STICKY THREADS BEFORE ASKING FOR HELP!
Most information can be found there, and if not, the posts will help you determine the information required to get assistance from the development team.
Incomplete Help Requests will be locked or deleted.
Post Reply
User avatar
Gangrenous
Posts: 812
Joined: Sun Apr 24, 2016 6:54 am
Characters: Dinsmoor

Lootdrop Probability

Post by Gangrenous » Sat Apr 06, 2019 3:07 am

A few years ago I changed it on my server so that I could have a float for loot drop, and minimum items. I found this handy to have min and max loot amounts. Plus I wanted ultra rare drops. It looks like the official source has also changed to float, or am I wrong? I am just checking to see the differences on implementation, to see how far off my solution was since I am not as seasoned as some.

On the chance to drop, this is now in.

Code: Select all

chancedrop = static_cast <float> (rand()) / (static_cast <float> (RAND_MAX / 100));
This was my old code, somewhat close.

Code: Select all

chance = (float)rand()/((float)(RAND_MAX))*100;
I thought they did the same thing, which confused me. Having float on the left in parens did the casting to float. Is one safer?

What does the static cast actually do? I also brought in a random seed. One thing I found was that the loottable never resorts. So things at the top of the loot will always have a higher chance does that make sense? Unless you sort the loot table drops at every roll, those at the top have a higher chance. If you have a list of 20 items to be dropped unless you resort, those at the bottom may never drop. I hope that makes sense? I seem to remember bringing in chrono and using the time as a random seed.
Resident Dirty Hippy

User avatar
Gangrenous
Posts: 812
Joined: Sun Apr 24, 2016 6:54 am
Characters: Dinsmoor

Re: Lootdrop Probability

Post by Gangrenous » Sat Apr 06, 2019 3:19 am

Okay, that is funny. I see someone had the same idea and randomized the loot tables. I thought it was intentional that they were not shuffled but someone changed it now which is great.
Resident Dirty Hippy

User avatar
Ememjr
Team Member
Posts: 975
Joined: Wed Mar 15, 2017 9:41 am
EQ2Emu Server: Perseverance

Re: Lootdrop Probability

Post by Ememjr » Sat Apr 06, 2019 4:42 am

well on this one i have to disagree lol to me all the shuffle is mix up the outcome but does not actually fix the poor loot code

i think we went around about this a few years ago as well
i had an awesome way of doing it and thought i had committed it, but its gone


oh well

here is what i remember about it the orginal way
if there were 100 items in the table with a 5% chance to get the item
it would loop through the 100 items until you won something then stop
and repeat if there were multiple items
so you would end up winning mostly items from the top of the list, ( the reason you added shuffle

the way i beleived is that if you get to the table of 100 items then you are guaranteed 1 of those items at the propability that is listed and more like a ratio and not percent so on the 100 even if you put 100% on each one and there are a 100 items, it is still a 1% chance to get 1 of the 100
i changed mine so it was not rolling on each of the 100 and stopping but rolling once like a randdom(100) and you get that item( it was a little more complicated than that though

User avatar
Ememjr
Team Member
Posts: 975
Joined: Wed Mar 15, 2017 9:41 am
EQ2Emu Server: Perseverance

Re: Lootdrop Probability

Post by Ememjr » Sat Apr 06, 2019 4:54 am

if your curious i do believe that this post contains the way i changed loot drops
viewtopic.php?f=88&t=4324&p=32434&hilit=loot#p32434

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests