[FOUND SOLUTION] Pet chances not supporting percentages lower than 1?
Asked by
4 years ago Edited 3 years ago
This has been a problem for many people including me. The local Chance doesn't make the pets under 1% hatchable. The 1 in math.random(1,TotalWeight) would need to be 0 but it won't work.
01 | function ChoosePet(Egg) |
02 | local Data = Eggs [ Egg ] |
03 | local Pets = Data [ "Pets" ] |
05 | for i,v in pairs (Pets) do |
06 | TotalWeight = TotalWeight + v.Rarity |
08 | local Chance = math.random( 1 ,TotalWeight) |
10 | for i,v in pairs (Pets) do |
11 | Counter = Counter+v.Rarity |
12 | if Counter > = Chance then |
This script is from the better pet system. However there's another pet system that has working pet chances, it basically has a math.random(1,TotalWeight) too however it also has this:
1 | if Chance < = Counter then |
Both of these pet systems obviously work differently. The "i" are the suffixes and I believe that this is what makes the pets under 1% hatchable. I still don't know how to make this possible in the other pet system. Any help?