vmangos / core

Progressive Vanilla Core aimed at all versions from 1.2 to 1.12
GNU General Public License v2.0
691 stars 491 forks source link

Fix rolling a random item suffix #2826

Closed Gamemechanicwow closed 2 weeks ago

Gamemechanicwow commented 2 weeks ago

🍰 Pullrequest

This PR fixes an issue where the total chance for an entry in item_enchantment_template is above 100.

The original GetItemEnchantMod() has two issues. If the totalchance is below 100 - sometimes a second roll will happen. If the totalchance is above 100 - there is a risk that some suffixes will never be rolled.

This PR fixes it by summing the totalchance and using that sum for the roll.

Also added a log output for entries that are silently skipped during loading.

Proof

Issues

How2Test

Before: .debug loottable enchant 4566 1000000 46 items dropped after 1000000 attempts for item Sturdy Quarterstaff.

After: .debug loottable enchant 4566 1000000 70 items dropped after 1000000 attempts for item Sturdy Quarterstaff.

Todo / Checklist