diff --git a/core/src/com/riiablo/item/item4/Item.java b/core/src/com/riiablo/item/item4/Item.java index 3311f58d..6b5908fb 100644 --- a/core/src/com/riiablo/item/item4/Item.java +++ b/core/src/com/riiablo/item/item4/Item.java @@ -12,6 +12,8 @@ import com.riiablo.codec.excel.ItemEntry; import com.riiablo.codec.excel.ItemTypes; import com.riiablo.codec.excel.MagicAffix; import com.riiablo.codec.excel.Misc; +import com.riiablo.codec.excel.SetItems; +import com.riiablo.codec.excel.UniqueItems; import com.riiablo.codec.excel.Weapons; import com.riiablo.item.Attributes; import com.riiablo.item.BodyLoc; @@ -27,9 +29,9 @@ public class Item { private static final String TAG = "Item"; private static final boolean DEBUG = true; - private static final boolean DEBUG_VERBOSE = DEBUG && true; + private static final boolean DEBUG_VERBOSE = DEBUG && !true; - private static final boolean SIMPLE_FLAGS = false; + private static final boolean SIMPLE_FLAGS = !true; private static final boolean ONLY_KNOWN_FLAGS = SIMPLE_FLAGS && true; public static final float ETHEREAL_ALPHA = 2 / 3f; @@ -147,8 +149,8 @@ public class Item { public int runewordData; public String inscription; - Attributes attrs; - PropertyList stats[]; + public Attributes attrs; + public PropertyList stats[]; String name; // cache? Table header; // needed? @@ -268,6 +270,162 @@ public class Item { } } + public String getInvFileName() { + if (isIdentified()) { + switch (quality) { + case SET: + SetItems.Entry setItem = (SetItems.Entry) qualityData; + if (!setItem.invfile.isEmpty()) return setItem.invfile; + break; + case UNIQUE: + UniqueItems.Entry uniqueItem = (UniqueItems.Entry) qualityData; + if (!uniqueItem.invfile.isEmpty()) return uniqueItem.invfile; + break; + default: + // do nothing + } + } + + return pictureId >= 0 ? typeEntry.InvGfx[pictureId] : base.invfile; + } + + public String getInvColor() { + if (base.InvTrans == 0 || !isIdentified()) return null; + switch (quality) { + case MAGIC: { + MagicAffix affix; + int prefix = qualityId & Item.MAGIC_AFFIX_MASK; + if ((affix = Riiablo.files.MagicPrefix.get(prefix)) != null && affix.transform) + return affix.transformcolor; + int suffix = qualityId >>> Item.MAGIC_AFFIX_SIZE; + if ((affix = Riiablo.files.MagicSuffix.get(suffix)) != null && affix.transform) + return affix.transformcolor; + return null; + } + + case RARE: + case CRAFTED: { + MagicAffix affix; + RareQualityData rareQualityData = (RareQualityData) qualityData; + for (int i = 0; i < RareQualityData.NUM_AFFIXES; i++) { + int prefix = rareQualityData.prefixes[i]; + if ((affix = Riiablo.files.MagicPrefix.get(prefix)) != null && affix.transform) + return affix.transformcolor; + int suffix = rareQualityData.suffixes[i]; + if ((affix = Riiablo.files.MagicSuffix.get(suffix)) != null && affix.transform) + return affix.transformcolor; + } + return null; + } + + case SET: + return ((SetItems.Entry) qualityData).invtransform; + + case UNIQUE: + return ((UniqueItems.Entry) qualityData).invtransform; + + default: + return null; + } + } + + public String getCharColor() { + if (base.Transform == 0 || !isIdentified()) return null; + switch (quality) { + case MAGIC: { + MagicAffix affix; + int prefix = qualityId & Item.MAGIC_AFFIX_MASK; + if ((affix = Riiablo.files.MagicPrefix.get(prefix)) != null && affix.transform) + return affix.transformcolor; + int suffix = qualityId >>> Item.MAGIC_AFFIX_SIZE; + if ((affix = Riiablo.files.MagicSuffix.get(suffix)) != null && affix.transform) + return affix.transformcolor; + return null; + } + + case RARE: + case CRAFTED: { + MagicAffix affix; + RareQualityData rareQualityData = (RareQualityData) qualityData; + for (int i = 0; i < RareQualityData.NUM_AFFIXES; i++) { + int prefix = rareQualityData.prefixes[i]; + if ((affix = Riiablo.files.MagicPrefix.get(prefix)) != null && affix.transform) + return affix.transformcolor; + int suffix = rareQualityData.suffixes[i]; + if ((affix = Riiablo.files.MagicSuffix.get(suffix)) != null && affix.transform) + return affix.transformcolor; + } + return null; + } + + case SET: + return ((SetItems.Entry) qualityData).chrtransform; + + case UNIQUE: + return ((UniqueItems.Entry) qualityData).chrtransform; + + default: + return null; + } + } + + public int getDropFxFrame() { + if (isIdentified()) { + switch (quality) { + case SET: + SetItems.Entry setItem = (SetItems.Entry) qualityData; + if (setItem.dropsfxframe > 0) return setItem.dropsfxframe; + break; + case UNIQUE: + UniqueItems.Entry uniqueItem = (UniqueItems.Entry) qualityData; + if (uniqueItem.dropsfxframe > 0) return uniqueItem.dropsfxframe; + break; + default: + // do nothing + } + } + + return base.dropsfxframe; + } + + public String getDropSound() { + if (isIdentified()) { + switch (quality) { + case SET: + SetItems.Entry setItem = (SetItems.Entry) qualityData; + if (!setItem.dropsound.isEmpty()) return setItem.dropsound; + break; + case UNIQUE: + UniqueItems.Entry uniqueItem = (UniqueItems.Entry) qualityData; + if (!uniqueItem.dropsound.isEmpty()) return uniqueItem.dropsound; + break; + default: + // do nothing + } + } + + return base.dropsound; + } + + public String getUseSound() { + if (isIdentified()) { + switch (quality) { + case SET: + SetItems.Entry setItem = (SetItems.Entry) qualityData; + if (!setItem.usesound.isEmpty()) return setItem.usesound; + break; + case UNIQUE: + UniqueItems.Entry uniqueItem = (UniqueItems.Entry) qualityData; + if (!uniqueItem.usesound.isEmpty()) return uniqueItem.usesound; + break; + default: + // do nothing + } + } + + return base.usesound; + } + private String getFlagsString() { StringBuilder builder = new StringBuilder(); if (ONLY_KNOWN_FLAGS && (flags & ITEMFLAG__RELOAD ) == ITEMFLAG__RELOAD ) builder.append("ITEMFLAG__RELOAD" ).append('|'); diff --git a/core/src/com/riiablo/item/item4/ItemUtils.java b/core/src/com/riiablo/item/item4/ItemUtils.java index 771d32f0..f195fcce 100644 --- a/core/src/com/riiablo/item/item4/ItemUtils.java +++ b/core/src/com/riiablo/item/item4/ItemUtils.java @@ -5,9 +5,6 @@ import com.badlogic.gdx.utils.GdxRuntimeException; import com.riiablo.Riiablo; import com.riiablo.codec.excel.Gems; import com.riiablo.codec.excel.ItemEntry; -import com.riiablo.codec.excel.MagicAffix; -import com.riiablo.codec.excel.SetItems; -import com.riiablo.codec.excel.UniqueItems; import com.riiablo.item.PropertyList; public class ItemUtils { @@ -30,103 +27,4 @@ public class ItemUtils { props[Item.GEMPROPS_SHIELD] = PropertyList.obtain().add(gem.shieldModCode, gem.shieldModParam, gem.shieldModMin, gem.shieldModMax); return props; } - - static String getInvFileName(Item item) { - if (item.isIdentified()) { - switch (item.quality) { - case SET: - SetItems.Entry setItem = (SetItems.Entry) item.qualityData; - if (!setItem.invfile.isEmpty()) return setItem.invfile; - break; - case UNIQUE: - UniqueItems.Entry uniqueItem = (UniqueItems.Entry) item.qualityData; - if (!uniqueItem.invfile.isEmpty()) return uniqueItem.invfile; - break; - default: - // do nothing - } - } - - return item.pictureId >= 0 ? item.typeEntry.InvGfx[item.pictureId] : item.base.invfile; - } - - static String getInvColor(Item item) { - if (item.base.InvTrans == 0 || !item.isIdentified()) return null; - switch (item.quality) { - case MAGIC: { - MagicAffix affix; - int prefix = item.qualityId & Item.MAGIC_AFFIX_MASK; - if ((affix = Riiablo.files.MagicPrefix.get(prefix)) != null && affix.transform) - return affix.transformcolor; - int suffix = item.qualityId >>> Item.MAGIC_AFFIX_SIZE; - if ((affix = Riiablo.files.MagicSuffix.get(suffix)) != null && affix.transform) - return affix.transformcolor; - return null; - } - - case RARE: - case CRAFTED: { - MagicAffix affix; - RareQualityData rareQualityData = (RareQualityData) item.qualityData; - for (int i = 0; i < RareQualityData.NUM_AFFIXES; i++) { - int prefix = rareQualityData.prefixes[i]; - if ((affix = Riiablo.files.MagicPrefix.get(prefix)) != null && affix.transform) - return affix.transformcolor; - int suffix = rareQualityData.suffixes[i]; - if ((affix = Riiablo.files.MagicSuffix.get(suffix)) != null && affix.transform) - return affix.transformcolor; - } - return null; - } - - case SET: - return ((SetItems.Entry) item.qualityData).invtransform; - - case UNIQUE: - return ((UniqueItems.Entry) item.qualityData).invtransform; - - default: - return null; - } - } - - static String getCharColor(Item item) { - if (item.base.Transform == 0 || !item.isIdentified()) return null; - switch (item.quality) { - case MAGIC: { - MagicAffix affix; - int prefix = item.qualityId & Item.MAGIC_AFFIX_MASK; - if ((affix = Riiablo.files.MagicPrefix.get(prefix)) != null && affix.transform) - return affix.transformcolor; - int suffix = item.qualityId >>> Item.MAGIC_AFFIX_SIZE; - if ((affix = Riiablo.files.MagicSuffix.get(suffix)) != null && affix.transform) - return affix.transformcolor; - return null; - } - - case RARE: - case CRAFTED: { - MagicAffix affix; - RareQualityData rareQualityData = (RareQualityData) item.qualityData; - for (int i = 0; i < RareQualityData.NUM_AFFIXES; i++) { - int prefix = rareQualityData.prefixes[i]; - if ((affix = Riiablo.files.MagicPrefix.get(prefix)) != null && affix.transform) - return affix.transformcolor; - int suffix = rareQualityData.suffixes[i]; - if ((affix = Riiablo.files.MagicSuffix.get(suffix)) != null && affix.transform) - return affix.transformcolor; - } - return null; - } - - case SET: - return ((SetItems.Entry) item.qualityData).chrtransform; - - case UNIQUE: - return ((UniqueItems.Entry) item.qualityData).chrtransform; - - default: - return null; - } - } } diff --git a/core/src/com/riiablo/item/item4/ItemWrapper.java b/core/src/com/riiablo/item/item4/ItemWrapper.java index f474fbdc..7609ce5b 100644 --- a/core/src/com/riiablo/item/item4/ItemWrapper.java +++ b/core/src/com/riiablo/item/item4/ItemWrapper.java @@ -44,16 +44,16 @@ public class ItemWrapper extends Actor implements Disposable { public void load() { if (invFileDescriptor != null) return; - invFileDescriptor = new AssetDescriptor<>("data\\global\\items\\" + ItemUtils.getInvFileName(item) + '.' + DC6.EXT, DC6.class); + invFileDescriptor = new AssetDescriptor<>("data\\global\\items\\" + item.getInvFileName() + '.' + DC6.EXT, DC6.class); Riiablo.assets.load(invFileDescriptor); checkLoaded(); invColormap = Riiablo.colormaps.get(item.base.InvTrans); - String invColor = ItemUtils.getInvColor(item); + String invColor = item.getInvColor(); invColorIndex = invColor != null ? Riiablo.files.colors.index(invColor) + 1 : 0; charColormap = Riiablo.colormaps.get(item.base.Transform); - String charColor = ItemUtils.getCharColor(item); + String charColor = item.getCharColor(); charColorIndex = charColor != null ? Riiablo.files.colors.index(charColor) + 1 : 0; // TODO: load images of socketed items