collinsmith / riiablo

Diablo II remade using Java and LibGDX
http://riiablo.com
Apache License 2.0
884 stars 101 forks source link

improve set item detection #21

Open collinsmith opened 5 years ago

collinsmith commented 5 years ago

Set item detection is a bit hacky. It would be beneficial to create some kind of enumeration of the sets, possibly using Sets.txt. I think each set needs a bitsum of held items which can get set when the player is loaded and updated when items are picked up/dropped. It would also be nice to iterate through the Sets.txt and generate the set item lists.

collinsmith commented 5 years ago

SetItems excel will now generate a mapping from set name to items belonging to set. This will work fine in the meantime, but ideally this responsibility should belong with the eventual Set excel, but I'll need to guarantee that they are loaded in the correct order, as one will be tightly coupled with the excel reference in Riiablo.files. As for updates (adding/removing items during runtime) -- I'm not sure yet how I want to implement that.

I would like the API calls to work something like this in item details creation -- this pseudocode assumes that the d2s has already loaded the items:

if (quality == SET) {
  add().height(font.getLineHeight()).space(SPACING).row();
  Sets.Entry set = Riiablo.files.SetItems.get(qualityId).getSet();
  add(new Label(Riiablo.string.lookup(set.index), font, Riiablo.colors.gold)).space(SPACING).row();
  for (SetItems.Entry item : set.getItems()) {
    Color color = (gameScreen.player.setFlags.get(set.index) & item.flag) == 0
        ? Riiablo.colors.red
        : Riiablo.colors.green;
    add(new Label(Riiablo.string.lookup(item.index), font, color)).space(SPACING).row();
  }
}

item.flag will be the flag assigned when the SetItem.Entry is created (1 << size) at time of adding. When the items are loaded, if it's a set item, bitwise or the set's items with the new item. The issue I am going to run into though is removal of the items (multiple copies of the same set item, so I can't just unset the flag if the user still has one, unless I iterate through the items to check).

collinsmith commented 5 years ago

I decided for the first iteration to create a function in Sets which indexes a SetItems reference and assigned forward and backwards references between sets and their items. As far as set bonuses and keep track of sets, there isn't any kind of support for this right now, at least as far as Item ownership is concerned. I think I'm going to make set ownership tied to Player references.

I am considering how viewing other players items or viewing items referenced in chat (like in D3) might work and what bonuses to show (I'd like to show the owner's bonuses maybe), and also what player stats are based from (e.g., stat / level properties, the viewer's level or owner's level)

collinsmith commented 5 years ago

bdfbb5c922d09c24dff7d3fe9d22454b6d925974 added support for updating set and set item counters at run time. Once I configure the item details and attributes updating I'll close this issue.