예제 #1
0
        public static Image CreateAndGetMagicItemBackgroundImage(GameObject elementGo, GameObject equipped, bool addSetItem)
        {
            var magicItemTransform = elementGo.transform.Find("magicItem");

            if (magicItemTransform == null)
            {
                var magicItemObject = Object.Instantiate(equipped, equipped.transform.parent);
                magicItemObject.transform.SetSiblingIndex(equipped.transform.GetSiblingIndex() + 1);
                magicItemObject.name = "magicItem";
                magicItemObject.SetActive(true);
                magicItemTransform = magicItemObject.transform;
                var magicItemInit = magicItemTransform.GetComponent <Image>();
                magicItemInit.color         = Color.white;
                magicItemInit.raycastTarget = false;
            }

            // Also add set item marker
            if (addSetItem)
            {
                var setItemTransform = elementGo.transform.Find("setItem");
                if (setItemTransform == null)
                {
                    var setItemObject = Object.Instantiate(equipped, equipped.transform.parent);
                    setItemObject.transform.SetAsLastSibling();
                    setItemObject.name = "setItem";
                    setItemObject.SetActive(true);
                    setItemTransform = setItemObject.transform;
                    var setItemInit = setItemTransform.GetComponent <Image>();
                    setItemInit.raycastTarget = false;
                    setItemInit.sprite        = EpicLoot.Assets.GenericSetItemSprite;
                    setItemInit.color         = ColorUtility.TryParseHtmlString(EpicLoot.GetSetItemColor(), out var color) ? color : Color.white;
                }
            }

            // Also change equipped image
            var equippedImage = equipped.GetComponent <Image>();

            if (equippedImage != null)
            {
                equippedImage.sprite        = EpicLoot.Assets.EquippedSprite;
                equippedImage.color         = Color.white;
                equippedImage.raycastTarget = false;
                var rectTransform = equipped.RectTransform();
                rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, equippedImage.sprite.texture.width);
                rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, equippedImage.sprite.texture.height);
            }

            return(magicItemTransform.GetComponent <Image>());
        }
예제 #2
0
        public static string GetSetTooltip(this ItemDrop.ItemData item)
        {
            var text    = new StringBuilder();
            var setID   = item.GetSetID(out var isMundane);
            var setSize = item.GetSetSize();

            var setPieces          = ItemDataExtensions.GetSetPieces(setID);
            var currentSetEquipped = Player.m_localPlayer.GetEquippedSetPieces(setID);

            var setDisplayName = GetSetDisplayName(item, isMundane);

            text.Append($"\n\n<color={EpicLoot.GetSetItemColor()}> $mod_epicloot_set: {setDisplayName} ({currentSetEquipped.Count}/{setSize}):</color>");

            foreach (var setItemName in setPieces)
            {
                var isEquipped  = IsSetItemEquipped(currentSetEquipped, setItemName, isMundane);
                var color       = isEquipped ? "white" : "grey";
                var displayName = GetSetItemDisplayName(setItemName, isMundane);
                text.Append($"\n  <color={color}>{displayName}</color>");
            }

            if (isMundane)
            {
                var setEffectColor = currentSetEquipped.Count == setSize?EpicLoot.GetSetItemColor() : "grey";

                text.Append($"\n<color={setEffectColor}>({setSize}) ‣ {item.GetSetStatusEffectTooltip().Replace("\n", " ")}</color>");
            }
            else
            {
                var setInfo = item.GetLegendarySetInfo();
                foreach (var setBonusInfo in setInfo.SetBonuses.OrderBy(x => x.Count))
                {
                    var hasEquipped = currentSetEquipped.Count >= setBonusInfo.Count;
                    var effectDef   = MagicItemEffectDefinitions.Get(setBonusInfo.Effect.Type);
                    if (effectDef == null)
                    {
                        EpicLoot.LogError($"Set Tooltip: Could not find effect ({setBonusInfo.Effect.Type}) for set ({setInfo.ID}) bonus ({setBonusInfo.Count})!");
                        continue;
                    }

                    var display = MagicItem.GetEffectText(effectDef, setBonusInfo.Effect.Values?.MinValue ?? 0);
                    text.Append($"\n<color={(hasEquipped ? EpicLoot.GetSetItemColor() : "grey")}>({setBonusInfo.Count}) ‣ {display}</color>");
                }
            }

            return(text.ToString());
        }
        private static void AddSetTooltip(ItemDrop.ItemData item, StringBuilder text)
        {
            var setPieces          = ObjectDB.instance.GetSetPieces(item.m_shared.m_setName);
            var currentSetEquipped = Player.m_localPlayer.GetEquippedSetPieces(item.m_shared.m_setName);
            var setEffectColor     = currentSetEquipped.Count == item.m_shared.m_setSize ? EpicLoot.GetSetItemColor() : "grey";

            TextInfo textInfo       = new CultureInfo("en-US", false).TextInfo;
            var      setDisplayName = textInfo.ToTitleCase(item.m_shared.m_setName);

            text.Append($"\n\n<color={EpicLoot.GetSetItemColor()}>ᛟ Set: {setDisplayName} ({currentSetEquipped.Count}/{item.m_shared.m_setSize}):</color>");

            foreach (var setItem in setPieces)
            {
                var isEquipped = currentSetEquipped.Find(x => x.m_shared.m_name == setItem.m_shared.m_name) != null;
                var color      = isEquipped ? "white" : "grey";
                text.Append($"\n  <color={color}>{setItem.m_shared.m_name}</color>");
            }

            text.Append($"\n<color={setEffectColor}>({item.m_shared.m_setSize}) ‣ {item.GetSetStatusEffectTooltip().Replace("\n", " ")}</color>");
        }
예제 #4
0
        private static bool Prefix(ref string __result, ItemDrop.ItemData item, int qualityLevel, bool crafting)
        {
            if (!item.IsMagic())
            {
                return(true);
            }

            var localPlayer = Player.m_localPlayer;
            var text        = new StringBuilder(256);

            var magicItem    = item.GetMagicItem();
            var magicColor   = magicItem.GetColorString();
            var itemTypeName = magicItem.GetItemTypeName(item.Extended());

            text.Append($"<color={magicColor}>{magicItem.GetRarityDisplay()} {itemTypeName}</color>\n");
            if (item.IsLegendarySetItem())
            {
                text.Append($"<color={EpicLoot.GetSetItemColor()}>$mod_epicloot_legendarysetlabel</color>\n");
            }
            text.Append(item.GetDescription());

            text.Append("\n");
            if (item.m_shared.m_dlc.Length > 0)
            {
                text.Append("\n<color=aqua>$item_dlc</color>");
            }

            ItemDrop.ItemData.AddHandedTip(item, text);
            if (item.m_crafterID != 0L)
            {
                text.AppendFormat("\n$item_crafter: <color=orange>{0}</color>", item.m_crafterName);
            }

            if (!item.m_shared.m_teleportable)
            {
                text.Append("\n<color=orange>$item_noteleport</color>");
            }

            if (item.m_shared.m_value > 0)
            {
                text.AppendFormat("\n$item_value: <color=orange>{0} ({1})</color>", item.GetValue(), item.m_shared.m_value);
            }

            var weightColor = magicItem.HasEffect(MagicEffectType.ReduceWeight) || magicItem.HasEffect(MagicEffectType.Weightless) ? magicColor : "orange";

            text.Append($"\n$item_weight: <color={weightColor}>{item.GetWeight():0.0}</color>");

            if (item.m_shared.m_maxQuality > 1)
            {
                text.AppendFormat("\n$item_quality: <color=orange>{0}</color>", qualityLevel);
            }

            var indestructible = magicItem.HasEffect(MagicEffectType.Indestructible);

            if (!indestructible && item.m_shared.m_useDurability)
            {
                var maxDurabilityColor1 = magicItem.HasEffect(MagicEffectType.ModifyDurability) ? magicColor : "orange";
                var maxDurabilityColor2 = magicItem.HasEffect(MagicEffectType.ModifyDurability) ? magicColor : "yellow";

                var maxDurability = item.GetMaxDurability(qualityLevel);
                var durability    = item.m_durability;
                var currentDurabilityPercentage = item.GetDurabilityPercentage() * 100f;
                var durabilityPercentageString  = currentDurabilityPercentage.ToString("0");
                var durabilityValueString       = durability.ToString("0");
                var durabilityMaxString         = maxDurability.ToString("0");
                text.Append($"\n$item_durability: <color={maxDurabilityColor1}>{durabilityPercentageString}%</color> <color={maxDurabilityColor2}>({durabilityValueString}/{durabilityMaxString})</color>");

                if (item.m_shared.m_canBeReparied)
                {
                    var recipe = ObjectDB.instance.GetRecipe(item);
                    if (recipe != null)
                    {
                        var minStationLevel = recipe.m_minStationLevel;
                        text.AppendFormat("\n$item_repairlevel: <color=orange>{0}</color>", minStationLevel.ToString());
                    }
                }
            }
            else if (indestructible)
            {
                text.Append($"\n$item_durability: <color={magicColor}>$mod_epicloot_me_indestructible_display</color>");
            }

            var magicBlockPower    = magicItem.HasEffect(MagicEffectType.ModifyBlockPower);
            var magicBlockColor1   = magicBlockPower ? magicColor : "orange";
            var magicBlockColor2   = magicBlockPower ? magicColor : "yellow";
            var magicParry         = magicItem.HasEffect(MagicEffectType.ModifyParry);
            var totalParryBonusMod = magicItem.GetTotalEffectValue(MagicEffectType.ModifyParry, 0.01f);
            var magicParryColor    = magicParry ? magicColor : "orange";

            switch (item.m_shared.m_itemType)
            {
            case ItemDrop.ItemData.ItemType.Consumable:
                if (item.m_shared.m_food > 0.0)
                {
                    text.AppendFormat("\n$item_food_health: <color=orange>{0}</color>", item.m_shared.m_food);
                    text.AppendFormat("\n$item_food_stamina: <color=orange>{0}</color>", item.m_shared.m_foodStamina);
                    text.AppendFormat("\n$item_food_duration: <color=orange>{0}s</color>", item.m_shared.m_foodBurnTime);
                    text.AppendFormat("\n$item_food_regen: <color=orange>{0} hp/tick</color>", item.m_shared.m_foodRegen);
                }

                var consumeStatusEffectTooltip = item.GetStatusEffectTooltip();
                if (consumeStatusEffectTooltip.Length > 0)
                {
                    text.Append("\n\n");
                    text.Append(consumeStatusEffectTooltip);
                }

                break;

            case ItemDrop.ItemData.ItemType.OneHandedWeapon:
            case ItemDrop.ItemData.ItemType.Bow:
            case ItemDrop.ItemData.ItemType.TwoHandedWeapon:
            case ItemDrop.ItemData.ItemType.Torch:
                text.Append(GetDamageTooltipString(magicItem, item.GetDamage(qualityLevel), item.m_shared.m_skillType, magicColor));
                var baseBlockPower1            = item.GetBaseBlockPower(qualityLevel);
                var blockPowerTooltipValue     = item.GetBlockPowerTooltip(qualityLevel);
                var blockPowerPercentageString = blockPowerTooltipValue.ToString("0");
                text.Append($"\n$item_blockpower: <color={magicBlockColor1}>{baseBlockPower1}</color> <color={magicBlockColor2}>({blockPowerPercentageString})</color>");
                if (item.m_shared.m_timedBlockBonus > 1.0)
                {
                    text.Append($"\n$item_deflection: <color={magicParryColor}>{item.GetDeflectionForce(qualityLevel)}</color>");

                    var timedBlockBonus = item.m_shared.m_timedBlockBonus;
                    if (magicParry)
                    {
                        timedBlockBonus *= 1.0f + totalParryBonusMod;
                    }

                    text.Append($"\n$item_parrybonus: <color={magicParryColor}>{timedBlockBonus:0.#}x</color>");
                }

                text.AppendFormat("\n$item_knockback: <color=orange>{0}</color>", item.m_shared.m_attackForce);

                var magicBackstab         = magicItem.HasEffect(MagicEffectType.ModifyBackstab);
                var totalBackstabBonusMod = magicItem.GetTotalEffectValue(MagicEffectType.ModifyBackstab, 0.01f);
                var magicBackstabColor    = magicBackstab ? magicColor : "orange";
                var backstabValue         = item.m_shared.m_backstabBonus * (1.0f + totalBackstabBonusMod);
                text.Append($"\n$item_backstab: <color={magicBackstabColor}>{backstabValue:0.#}x</color>");

                var projectileTooltip = item.GetProjectileTooltip(qualityLevel);
                if (projectileTooltip.Length > 0)
                {
                    text.Append("\n\n");
                    text.Append(projectileTooltip);
                }

                var statusEffectTooltip2 = item.GetStatusEffectTooltip();
                if (statusEffectTooltip2.Length > 0)
                {
                    text.Append("\n\n");
                    text.Append(statusEffectTooltip2);
                }

                break;

            case ItemDrop.ItemData.ItemType.Shield:
                var baseBlockPower2 = item.GetBaseBlockPower(qualityLevel);
                blockPowerTooltipValue = item.GetBlockPowerTooltip(qualityLevel);
                var str5 = blockPowerTooltipValue.ToString("0");
                text.Append($"\n$item_blockpower: <color={magicBlockColor1}>{baseBlockPower2}</color> <color={magicBlockColor2}>({str5})</color>");
                if (item.m_shared.m_timedBlockBonus > 1.0)
                {
                    text.Append($"\n$item_deflection: <color={magicParryColor}>{item.GetDeflectionForce(qualityLevel)}</color>");

                    var timedBlockBonus = item.m_shared.m_timedBlockBonus;
                    if (magicParry)
                    {
                        timedBlockBonus *= 1.0f + totalParryBonusMod;
                    }

                    text.Append($"\n$item_parrybonus: <color={magicParryColor}>{timedBlockBonus:0.#}x</color>");
                }

                break;

            case ItemDrop.ItemData.ItemType.Helmet:
            case ItemDrop.ItemData.ItemType.Chest:
            case ItemDrop.ItemData.ItemType.Legs:
            case ItemDrop.ItemData.ItemType.Shoulder:
                var magicArmorColor = magicItem.HasEffect(MagicEffectType.ModifyArmor) ? magicColor : "orange";
                text.Append($"\n$item_armor: <color={magicArmorColor}>{item.GetArmor(qualityLevel):0.#}</color>");
                var modifiersTooltipString = SE_Stats.GetDamageModifiersTooltipString(item.m_shared.m_damageModifiers);
                if (modifiersTooltipString.Length > 0)
                {
                    text.Append(modifiersTooltipString);
                }

                var statusEffectTooltip3 = item.GetStatusEffectTooltip();
                if (statusEffectTooltip3.Length > 0)
                {
                    text.Append("\n");
                    text.Append(statusEffectTooltip3);
                }

                break;

            case ItemDrop.ItemData.ItemType.Ammo:
                text.Append(item.GetDamage(qualityLevel).GetTooltipString(item.m_shared.m_skillType));
                text.AppendFormat("\n$item_knockback: <color=orange>{0}</color>", item.m_shared.m_attackForce);
                break;
            }

            var magicMovement = magicItem.HasEffect(MagicEffectType.ModifyMovementSpeed);

            if ((magicMovement || item.m_shared.m_movementModifier != 0) && localPlayer != null)
            {
                var itemMovementModDisplay = GetMovementModifier(item, magicItem, out _, out var removePenalty);

                var movementModifier      = localPlayer.GetEquipmentMovementModifier();
                var totalMovementModifier = movementModifier * 100f;
                var color = (removePenalty || magicMovement) ? magicColor : "orange";
                text.Append($"\n$item_movement_modifier: <color={color}>{itemMovementModDisplay}</color> ($item_total:<color=yellow>{totalMovementModifier:+0;-0}%</color>)");
            }

            // Add magic item effects here
            text.Append(magicItem.GetTooltip());

            // Set stuff
            if (item.IsSetItem())
            {
                text.Append(item.GetSetTooltip());
            }

            __result = text.ToString();
            return(false);
        }
예제 #5
0
        public static Image CreateAndGetMagicItemBackgroundImage(GameObject elementGo, GameObject equipped, bool isInventoryGrid)
        {
            var magicItemTransform = (RectTransform)elementGo.transform.Find("magicItem");

            if (magicItemTransform == null)
            {
                var magicItemObject = Object.Instantiate(equipped, equipped.transform.parent);
                magicItemObject.transform.SetSiblingIndex(EpicLoot.HasAuga ? equipped.transform.GetSiblingIndex() : equipped.transform.GetSiblingIndex() + 1);
                magicItemObject.name = "magicItem";
                magicItemObject.SetActive(true);
                magicItemTransform           = (RectTransform)magicItemObject.transform;
                magicItemTransform.anchorMin = magicItemTransform.anchorMax = new Vector2(0.5f, 0.5f);
                magicItemTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 64);
                magicItemTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 64);
                magicItemTransform.pivot            = new Vector2(0.5f, 0.5f);
                magicItemTransform.anchoredPosition = Vector2.zero;
                var magicItemInit = magicItemTransform.GetComponent <Image>();
                magicItemInit.color         = Color.white;
                magicItemInit.raycastTarget = false;
            }

            // Also add set item marker
            if (isInventoryGrid)
            {
                var setItemTransform = (RectTransform)elementGo.transform.Find("setItem");
                if (setItemTransform == null)
                {
                    var setItemObject = Object.Instantiate(equipped, equipped.transform.parent);
                    setItemObject.transform.SetAsLastSibling();
                    setItemObject.name = "setItem";
                    setItemObject.SetActive(true);
                    setItemTransform           = (RectTransform)setItemObject.transform;
                    setItemTransform.anchorMin = setItemTransform.anchorMax = new Vector2(0.5f, 0.5f);
                    setItemTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 64);
                    setItemTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 64);
                    setItemTransform.pivot            = new Vector2(0.5f, 0.5f);
                    setItemTransform.anchoredPosition = Vector2.zero;
                    var setItemInit = setItemTransform.GetComponent <Image>();
                    setItemInit.raycastTarget = false;
                    setItemInit.sprite        = EpicLoot.GetSetItemSprite();
                    setItemInit.color         = ColorUtility.TryParseHtmlString(EpicLoot.GetSetItemColor(), out var color) ? color : Color.white;
                }
            }

            // Also change equipped image
            var equippedImage = equipped.GetComponent <Image>();

            if (equippedImage != null && (!isInventoryGrid || !EpicLoot.HasAuga))
            {
                equippedImage.sprite        = EpicLoot.GetEquippedSprite();
                equippedImage.color         = Color.white;
                equippedImage.raycastTarget = false;
                var rectTransform = equipped.RectTransform();
                rectTransform.anchorMin        = new Vector2(0.5f, 0.5f);
                rectTransform.anchorMax        = new Vector2(0.5f, 0.5f);
                rectTransform.pivot            = new Vector2(0.5f, 0.5f);
                rectTransform.anchoredPosition = Vector2.zero;
                rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, equippedImage.sprite.texture.width);
                rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, equippedImage.sprite.texture.height);
            }

            return(magicItemTransform.GetComponent <Image>());
        }