Sarjuuk / aowow

Database viewer for TrinityCore based on aowow by @LordJZ, based on the JS-Engine of Wowhead
204 stars 217 forks source link

Hide drop chance for certain items. #336

Closed dotdotguy closed 2 years ago

dotdotguy commented 2 years ago

Hi, I'm trying to hide the drop chance of certain items while still displaying them on the drops pages.

I've set the drop chance in *.loot_template tables for the items in my world DB to 0 which works when you're browsing the NPC/Gameobject but if you are browsing the item itself, it still shows the drop chance in the "Dropped by" tab and I'm unable to figure out how to change this tab to show 0% as well.

Any help would be greatly appreciated, thanks!

Sarjuuk commented 2 years ago

probably something like this. Filtering the data before it is passed to the template: (functionally untested)

https://github.com/Sarjuuk/aowow/blob/6db77ed4f28772f688f8b386af1f87fde819fb88/pages/item.php#L558-L564

+               $data = array_filter(array_values($contains->getListviewData()), function ($x) { return $x['percent'] > 0; });
                $this->lvTabs[] = ['item', array(
-                   'data'       => array_values($contains->getListviewData()),
+                   'data'       => $data,
                    'name'       => '$LANG.tab_cancontain',
                    'id'         => 'can-contain',
                    'hiddenCols' => $hCols
                )];
dotdotguy commented 2 years ago

probably something like this. Filtering the data before it is passed to the template: (functionally untested)

https://github.com/Sarjuuk/aowow/blob/6db77ed4f28772f688f8b386af1f87fde819fb88/pages/item.php#L558-L564

+               $data = array_filter(array_values($contains->getListviewData()), function ($x) { return $x['percent'] > 0; });
                $this->lvTabs[] = ['item', array(
-                   'data'       => array_values($contains->getListviewData()),
+                   'data'       => $data,
                    'name'       => '$LANG.tab_cancontain',
                    'id'         => 'can-contain',
                    'hiddenCols' => $hCols
                )];

Ty for the response. Doesn't really seem to be changing the behavior I'm experiencing sadly.

If I set the chance of item '32459' to 0 (was 100) inside of creature_loot_template in my world DB, it shows 0 on the NPC page correctly but on the item page in the 'dropped by' tab, I now see '101%'. This is the behavior I seem to have with or without your change.

I get the following error when I am on the item page

E_USER_WARNING - Loot by Item: Ungrouped Item/Ref 32459 has 0% chance assigned! @ X:\aowow\includes\loot.class.php:94

Sarjuuk commented 2 years ago

yeah, i misread you at first. Thought you wanted to skip loot sources with 0% chance from display.

You can hide the 'Percent' column entirely by removing '$Listview.extraCols.percent' from the following snippet. https://github.com/Sarjuuk/aowow/blob/6db77ed4f28772f688f8b386af1f87fde819fb88/pages/item.php#L476-L481

The error is telling you that this loot template makes no sense, which may also cause the 101% chance you are seeing. Maybe set the chance to something abysmal, but technically possible like 0.01%.

dotdotguy commented 2 years ago

yeah, i misread you at first. Thought you wanted to skip loot sources with 0% chance from display.

You can hide the 'Percent' column entirely by removing '$Listview.extraCols.percent' from the following snippet.

https://github.com/Sarjuuk/aowow/blob/6db77ed4f28772f688f8b386af1f87fde819fb88/pages/item.php#L476-L481

The error is telling you that this loot template makes no sense, which may also cause the 101% chance you are seeing. Maybe set the chance to something abysmal, but technically possible like 0.01%.

My end goal is to have some items display it's normal drop chance while hiding only certain items. So deleting the entire row is sadly not an option.

I'll opt for the 0.01% chance if I'm not able to have the item page show 0% as well. Thank you very much for the help! :)

Sarjuuk commented 2 years ago

i don't think there is an easy way to do that.

I guess, instead of array_filter() you could array_walk() over the rows and set 'Percent' to 0 for items matching your criteria.