Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core/Loot: Items and references are not calculated correctly inside the same group #23908

Open
Killyana opened this issue Nov 12, 2019 · 5 comments
Open

Comments

@Killyana
Copy link
Member

@Killyana Killyana commented Nov 12, 2019

Description: If we put an item and a reference inside the same loot group the calculation will not be the sum of both entries.
Example:
Start by executing:

UPDATE `reference_loot_template` SET GroupId=1, `MinCount`=2, `MaxCount`=2 WHERE `entry` = 12009 AND `Item` = 36908;

-- gameobject_loot_template
Entry, Item, Reference, Chance, QuestRequired, LootMode, GroupId, MinCount, MaxCount
24228, 1, 12009, 5, 0, 1, 1, 1, 1
24228, 36908, 0, 95, 0, 1, 1, 1, 1
-- reference_loot_template
Entry, Item, Reference, Chance, QuestRequired, LootMode, GroupId, MinCount, MaxCount
12009, 36908, 0, 100, 0, 1, 1, 2, 2

What must happen in this case is the gob=190176 must always contain 95% 1 Lotus or 5% 2 lotus.

What happen instead, the gob could contain 0 Lotus.

To have better representation of the issue we will change the drop rate to 50% 50%

UPDATE `gameobject_loot_template` SET `Chance` = 50 WHERE `Entry` = 24228 AND `Item` IN (36908,1);

Result:
Entry, Item, Reference, Chance, QuestRequired, LootMode, GroupId, MinCount, MaxCount
24228, 1, 12009, 50, 0, 1, 1, 1, 1
24228, 36908, 0, 50, 0, 1, 1, 1, 1

And the result in game in this case:
1/3 1 lotus
1/3 2 lotus
1/3 0 lotus

So the issue is when you put and item and a reference inside a group the drop rate will not be the sum of the 2 but every rate is calculated separately, this could result having no item from this group (having 2 items from the same group is not possible)

Steps to reproduce the problem:

  1. Execute the 2 sql above
  2. connect a char with 450 herbalism
  3. .gob add temp 190176 and look at the number of lotus inside
  4. do that many times and notice 1/3 of gob doesn't contain any lotus

Branch(es): both

TC rev. hash/commit: rev. c79571a

@Killyana

This comment has been minimized.

Copy link
Member Author

@Killyana Killyana commented Nov 12, 2019

If I set the reference to 50% and the item to 0 (it means 100 - (all drop rate of other items+refs from the group) the drop will be correct.

UPDATE `gameobject_loot_template` SET `Chance` = 50 WHERE `Entry` = 24228 AND `Item` IN (1);
UPDATE `gameobject_loot_template` SET `Chance` = 0 WHERE `Entry` = 24228 AND `Item` IN (36908);
@Shauren

This comment has been minimized.

Copy link
Member

@Shauren Shauren commented Nov 12, 2019

This is working as intended, setting GroupId on a reference entry already has a special meaning - if the referenced loot has multiple groups in it, only process the one specified on parent
For example, if your reference_loot_template 12009 had one more item in it with GroupId=2, it would never drop

@Killyana

This comment has been minimized.

Copy link
Member Author

@Killyana Killyana commented Nov 12, 2019

Yes, but why the Chance must be 0 for the item 36908 to have the correct result, 50 also must give the same result as 0 in this case

Imagine if we have a 3rd entry with a specific drop rate in the same group, we will not be able to do it.

@Shauren

This comment has been minimized.

Copy link
Member

@Shauren Shauren commented Nov 12, 2019

Loot groups are split into 2 containers, explicitly chanced (case 50) and equal chanced (case 0). When drops are determined, first all explicitly chanced items are rolled for "the one", if nothing is found, it falls back to taking from equal chanced container

@meji46

This comment has been minimized.

Copy link

@meji46 meji46 commented Nov 12, 2019

This is working as intended, setting GroupId on a reference entry already has a special meaning - if the referenced loot has multiple groups in it, only process the one specified on parent
For example, if your reference_loot_template 12009 had one more item in it with GroupId=2, it would never drop

Is there any situation in which this behavior is useful? (Apart from reducing number of reference entries)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.