Skip to content

improve loot table UI and item sorting#49

Open
marcoabreu wants to merge 1 commit intomasterfrom
loot-table-improvements
Open

improve loot table UI and item sorting#49
marcoabreu wants to merge 1 commit intomasterfrom
loot-table-improvements

Conversation

@marcoabreu
Copy link
Copy Markdown
Member

  • bigger icons
  • full loot table icon full size when items < 12
  • improved sorting
  • tome icon shows correctly when there's no item class but only tome items can be dropped
  • fixed duplicate entries
  • removed debug message

- bigger icons
- full loot table icon full size when items < 12
- improved sorting
- tome icon shows correctly when there's no item class but only tome items can be dropped
- fixed duplicate entries
- removed debug message
[ItemClass.Misc]: 6
};

function sortItems(itemIds: string[]): string[] {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do sorting ones in findMapInitialCreepsWithDrops(). No need to sort them every time we show them.

Comment on lines +92 to +98
this.allDropsBtn.btn.clearPoints()
this.allDropsBtn.btn.setPoint(
FRAMEPOINT_BOTTOMRIGHT,
Frame.fromOrigin(ORIGIN_FRAME_COMMAND_BUTTON, 11),
FRAMEPOINT_BOTTOMRIGHT,
0, 0
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can remove this. The point is already set in constructor.

}

if (itemIds.length < LootTableUI.MAX_ITEMS) {
this.allDropsBtn.btn.setSize(0.04, 0.04)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think 0.039 is more closer to the actual icon size

Comment on lines 210 to +228
} else {
m += `|cff00ff00[Custom drop pool]|r\n`
m += set.itemDrops.map(d => {
if (d instanceof RandomItemGroupDrop) {
return ` |cff00ff00[${d.itemGroup.itemClass}, Level ${d.itemGroup.itemLevel}]|r\n` +
d.getDropItemIds()
.map(id => ` - ${getItemById(id).name}`)
.join("\n")
} else {
return ` ${getItemById(d.getRawId()).name}`
}
}).join("\n")
m += `|cff00ff00[Custom]|r\n`

const allIds = Array.from(
new Set(
set.itemDrops.flatMap(d =>
d instanceof RandomItemGroupDrop
? d.getDropItemIds()
: [d.getRawId()]
)
)
);

const sortedIds = sortItems(allIds);

m += sortedIds.map(id => {
const item = getItemById(id)!;
return ` ${item.name} |cff00ff00[${item.classification}, Level ${item.level}]|r`;
}).join("\n");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes all "items" within a set clamped into one big chunk. I like the previous one better.

Old
Image

Now
Image

//A set that contains a list of specific items or multiple GroupDrops, or a mix of both

const ids = Array.from(new Set(set.itemDrops.flatMap(d => d.getDropItemIds())));
const sortedIds = sortItems(ids);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do sorting ones in findMapInitialCreepsWithDrops(). No need to sort them every time we show them.

} else if (getItemById(itemOrGroupId) !== undefined) {
return [new SpecificItemDrop(itemOrGroupId)]
} else {
print(`Unknown item drop id "${itemOrGroupId}" for unit "${unit.name}" at (${unit.x}, ${unit.y}).`);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment instead. This might be useful in the future.
But im not even sure if this have to be disable, we could fix faster with this one enabled xD

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can for example have a creep with
Item Set 1 (Total Chance: 100%)

  • 100% - None
    That would still trigger the debug message.
    Debug message could still somewhat be acceptable for casual ladder games, but considering our triggers also get used for tournament games, I'd rather avoid them.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All current maps do not print this msg.

If new map is added. Would it be better to have this msg, temporarily disable the feature/or msg, fix the bug in the feature or a map, then enable it back.

Or its better to hide all the bugs?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's a non-blocking issue, no? I would just print some warning messages when you run the script

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you mean by

I would just print some warning messages when you run the script

But, if you think it's an issue - you can comment it out instead of disabling.

Ideally i would like for print() to be toggleable at runtime and enabled for dev builds.
Like a logging system. Then we could take somebody's replay, enable logging - and there would be prints/writes to disk when watching the replay - may help with debugging when issue happens for end users.

Comment on lines +129 to +136
if (drop instanceof RandomItemGroupDrop) {
if (!isTomeDrop(drop)) return false;
} else {
const item = getItemById(drop.getRawId());
if (!item) return false;
if (item.classification !== ItemClass.Power_Up) return false;
if (item.level !== 1 && item.level !== 2) return false;
}
Copy link
Copy Markdown
Contributor

@Psimage Psimage Oct 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this to isTomeDrop (so it check for group tome drop and single item drop)

if (!isTomeDrop(drop)) return false;
} else {
const item = getItemById(drop.getRawId());
if (!item) return false;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't do those checks for items from drop sets - they are guaranteed to not be null anyway and it keeps it consistent with other code

e = Effect.create("loot-indicator\\loot-indicator-generic.mdx", 0, 0)!;
}

e.scale = 1.5;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check with @Kenshin on changes to indicator appearance. I think it looks better with this scale, but maybe too big? Like 1.3 - 1.4 maybe?

@Psimage
Copy link
Copy Markdown
Contributor

Psimage commented Oct 11, 2025

What does this mean?

fixed duplicate entries

@marco93f
Copy link
Copy Markdown
Contributor

What does this mean?

fixed duplicate entries

Let's say you mistakenly added the same item twice within the same item set, for example Mantle +3, Slippers +3, and another Mantle +3. Then in the list of items (and the loot recap as well) you're going to see Mantle +3 listed only once.
Another example is item set 1 with Permanent level 2 and item set 2 also with Permanent level 2. In this case the Permanent level 2 items are listed only once, meanwhile in the loot recap they are still going to be listed twice since they belong to two different item sets.
There are some examples in the file I shared yesterday that you may want to look at.

@Psimage
Copy link
Copy Markdown
Contributor

Psimage commented Oct 12, 2025

What does this mean?

fixed duplicate entries

Let's say you mistakenly added the same item twice within the same item set, for example Mantle +3, Slippers +3, and another Mantle +3. Then in the list of items (and the loot recap as well) you're going to see Mantle +3 listed only once. Another example is item set 1 with Permanent level 2 and item set 2 also with Permanent level 2. In this case the Permanent level 2 items are listed only once, meanwhile in the loot recap they are still going to be listed twice since they belong to two different item sets. There are some examples in the file I shared yesterday that you may want to look at.

The command bar (and full drop table tooltip) should display exactly the items that were configured by the map maker.
If the set contains 3 identical claws and a ring - then it should display 3 claws and a ring, because chance of getting a claw would be 75% and 25% for a ring.

Also, don't complicate the code for the cases that do not exist in practice or don't cause any issues.

@jzy-chitong56
Copy link
Copy Markdown
Contributor

Sorry, both. I haven't seen any content displayed by this indicator in the past two days of the competition or from the player's first perspective. I would like to confirm if it hasn't been implemented in the official environment map or for some reason. You have been improving the display effect, which is very exciting to both of you, but it seems that making the audience see it is more important?

@Psimage
Copy link
Copy Markdown
Contributor

Psimage commented Oct 12, 2025

Sorry, both. I haven't seen any content displayed by this indicator in the past two days of the competition or from the player's first perspective. I would like to confirm if it hasn't been implemented in the official environment map or for some reason. You have been improving the display effect, which is very exciting to both of you, but it seems that making the audience see it is more important?

For discussion not relevant to the PR, use W3Champions discord server https://discord.gg/uJmQxG2

@marco93f
Copy link
Copy Markdown
Contributor

What does this mean?

fixed duplicate entries

Let's say you mistakenly added the same item twice within the same item set, for example Mantle +3, Slippers +3, and another Mantle +3. Then in the list of items (and the loot recap as well) you're going to see Mantle +3 listed only once. Another example is item set 1 with Permanent level 2 and item set 2 also with Permanent level 2. In this case the Permanent level 2 items are listed only once, meanwhile in the loot recap they are still going to be listed twice since they belong to two different item sets. There are some examples in the file I shared yesterday that you may want to look at.

The command bar (and full drop table tooltip) should display exactly the items that were configured by the map maker. If the set contains 3 identical claws and a ring - then it should display 3 claws and a ring, because chance of getting a claw would be 75% and 25% for a ring.

Also, don't complicate the code for the cases that do not exist in practice or don't cause any issues.

I'm honestly not sure about that. 1v1, 2v2 and 4v4 are mostly safe on the ladder because I look after them personally, but for anything else (FFA, ATR, any other non-ladder map we are asked to upload to Flo for whatever reason) it's totally unregulated and mapmakers are oftentimes able to freestyle as much as they like.
This is an example it comes to mind of a map I had to upload a while ago with an absolutely random 4% drop and duplicate entry for Ring of the Archmagi when the item was not part of any Permanent class still (iirc it was even used for a ToD tournament): https://discord.com/channels/554057770035314728/753283898787496088/875006602028150875

Anyways not really a hill I'm willing to die on. It just seemed cleaner to me to avoid duplicates on the main list.

@Psimage
Copy link
Copy Markdown
Contributor

Psimage commented Oct 13, 2025

I don't see value in displaying unique items right now (same goes for sorting). Maybe if we introduce drop percentages.
Everything else - fix comments and let's deploy it.

@MichaelDeitz
Copy link
Copy Markdown

@marcoabreu Can this be closed? If not, what all needs to be done?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants