public static void Prefix(Humanoid __instance, Inventory inventory, ItemDrop.ItemData item, bool fromInventoryGui)
        {
            var shippableItem = item.Extended()?.GetComponent <ShippableItemData>();

            var player = __instance as Player;

            if (player == null || (!shippableItem.IsPackaged && !shippableItem.CheckIsPackagable()))
            {
                return;
            }

            UnityEngine.Debug.Log("Station check...");
            if (ShippableMetalBarsConfig.MinimumStationLevel > 0)
            {
                List <CraftingStation> stations = new List <CraftingStation>();
                CraftingStation.FindStationsInRange("forge", (Vector3)player.transform.position, 5f, stations);
                if (!stations.Exists(s => s.GetLevel() >= ShippableMetalBarsConfig.MinimumStationLevel))
                {
                    return;
                }
            }

            if (shippableItem.IsPackaged)
            {
                shippableItem.Unpackage(player, inventory);
            }
            else if (shippableItem.CheckIsPackagable())
            {
                shippableItem.Package(player, inventory);
            }

            return;
        }
Example #2
0
        public static string GetUniqueId(this ItemDrop.ItemData itemData)
        {
            if (itemData.Extended() is ExtendedItemData extendedItemData)
            {
                var uniqueItemData = extendedItemData.GetComponent <UniqueItemData>();
                return(uniqueItemData != null ? uniqueItemData.Guid : string.Empty);
            }

            return(string.Empty);
        }
Example #3
0
        public static bool IsUnique(this ItemDrop.ItemData itemData)
        {
            if (itemData.Extended() is ExtendedItemData extendedItemData)
            {
                var uniqueItemData = extendedItemData.GetComponent <UniqueItemData>();
                return(uniqueItemData != null);
            }

            return(false);
        }
Example #4
0
 private void GenerateEnchantRecipesForItem(ItemDrop.ItemData item)
 {
     if (!item.IsMagic() && EpicLoot.CanBeMagicItem(item))
     {
         var recipe = new EnchantRecipe {
             FromItem = item.Extended()
         };
         Recipes.Add(recipe);
     }
 }
Example #5
0
 public static bool Prefix(ItemDrop.ItemData __instance, ref ItemDrop.ItemData __result)
 {
     if (__instance.IsExtended())
     {
         ExtendedItemDataFramework.Log($"Cloning extended item {__instance.m_shared.m_name}");
         __result = __instance.Extended().ExtendedClone();
         return(false);
     }
     ExtendedItemDataFramework.Log($"Cloning DEFAULT item {__instance.m_shared.m_name}");
     return(true);
 }
Example #6
0
        public static List <MagicItemEffectDefinition> GetAvailableAugments(AugmentRecipe recipe, ItemDrop.ItemData item, MagicItem magicItem, ItemRarity rarity)
        {
            var valuelessEffect = false;

            if (recipe.EffectIndex >= 0 && recipe.EffectIndex < magicItem.Effects.Count)
            {
                var currentEffectDef = MagicItemEffectDefinitions.Get(magicItem.Effects[recipe.EffectIndex].EffectType);
                valuelessEffect = currentEffectDef.GetValuesForRarity(rarity) == null;
            }

            return(MagicItemEffectDefinitions.GetAvailableEffects(item.Extended(), item.GetMagicItem(), valuelessEffect ? -1 : recipe.EffectIndex));
        }
 private void GenerateEnchantRecipesForItem(ItemDrop.ItemData item)
 {
     if (!item.IsMagic() && EpicLoot.CanBeMagicItem(item))
     {
         if (Player.m_localPlayer.m_knownMaterial.Contains($"Magic Runestone"))
         {
             var recipe = new EnchantRecipe {
                 FromItem = item.Extended()
             };
             Recipes.Add(recipe);
         }
     }
 }
Example #8
0
        public static DisenchantRecipe GenerateDisenchantRecipe(ItemDrop.ItemData item)
        {
            if (item.IsMagic())
            {
                var recipe = new DisenchantRecipe {
                    FromItem = item.Extended()
                };
                recipe.Products = GetDisenchantProducts(item, item.GetRarity());
                return(recipe);
            }

            return(null);
        }
        private static DisenchantRecipe GenerateDisenchantRecipe(ItemDrop.ItemData item)
        {
            if (item.IsMagic())
            {
                var recipe = new DisenchantRecipe {
                    FromItem = item.Extended()
                };
                AddDisenchantProducts(item, recipe, item.GetMagicItem().Rarity);
                return(recipe);
            }

            return(null);
        }
Example #10
0
        private static void ReplaceMagicEffect(ItemDrop.ItemData itemData, MagicItem magicItem, MagicItemEffect effect, int index)
        {
            var replacementEffectDef = GetReplacementEffectDef(effect);

            if (replacementEffectDef == null)
            {
                return;
            }

            var replacementEffect = LootRoller.RollEffect(replacementEffectDef, magicItem.Rarity);

            magicItem.Effects[index] = replacementEffect;
            itemData.Extended().Save();
        }
 private void GenerateEnchantRecipesForItem(ItemDrop.ItemData item)
 {
     if (!item.IsMagic() && EpicLoot.CanBeMagicItem(item))
     {
         //foreach (ItemRarity rarity in Enum.GetValues(typeof(ItemRarity)))
         {
             if (Player.m_localPlayer.m_knownMaterial.Contains($"Magic Runestone"))
             {
                 var recipe = new EnchantRecipe {
                     FromItem = item.Extended()
                 };                                                             // todo, no rarity in recipe
                 Recipes.Add(recipe);
             }
         }
     }
 }
        private static DisenchantRecipe GenerateTrophyRecipe(ItemDrop.ItemData item)
        {
            if (item.m_shared.m_itemType == ItemDrop.ItemData.ItemType.Trophie)
            {
                foreach (var entry in TrophyShards)
                {
                    var rarity = entry.Key;
                    if (entry.Value.Contains(item.m_shared.m_name))
                    {
                        var recipe = new DisenchantRecipe {
                            FromItem = item.Extended()
                        };
                        AddDisenchantProducts(item, recipe, rarity);
                        return(recipe);
                    }
                }
            }

            return(null);
        }
Example #13
0
 public static bool IsMagic(this ItemDrop.ItemData itemData)
 {
     return(itemData.Extended()?.GetComponent <MagicItemComponent>() != null);
 }
Example #14
0
 public static MagicItem GetMagicItem(this ItemDrop.ItemData itemData)
 {
     return(itemData.Extended()?.GetComponent <MagicItemComponent>()?.MagicItem);
 }
Example #15
0
 public static bool IsUnpackageable(this ItemDrop.ItemData item)
 {
     return(item.Extended()?.GetComponent <ShippableItemData>()?.IsPackaged ?? false);
 }
Example #16
0
 public static void Package(this ItemDrop.ItemData item, Player player, Inventory inventory)
 {
     item.Extended()?.GetComponent <ShippableItemData>()?.Package(player, inventory);
 }
        private static bool Prefix(ref string __result, ItemDrop.ItemData item, int qualityLevel, bool crafting)
        {
            if (!item.IsMagic())
            {
                return(true);
            }

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

            var magicItem   = item.GetMagicItem();
            var magicColor  = magicItem.GetColorString();
            var displayName = magicItem.GetDisplayName(item.Extended());

            text.Append($"<color={magicColor}>{magicItem.GetRarityDisplay()} {displayName}</color>\n");
            text.Append(item.m_shared.m_description);

            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";

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

                if (item.m_shared.m_canBeReparied)
                {
                    Recipe recipe = ObjectDB.instance.GetRecipe(item);
                    if (recipe != null)
                    {
                        int 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}>Indestructible</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);
                }

                string 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));
                float  baseBlockPower1            = item.GetBaseBlockPower(qualityLevel);
                float  blockPowerTooltipValue     = item.GetBlockPowerTooltip(qualityLevel);
                string 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>");

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

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

                break;

            case ItemDrop.ItemData.ItemType.Shield:
                float baseBlockPower2 = item.GetBaseBlockPower(qualityLevel);
                blockPowerTooltipValue = item.GetBlockPowerTooltip(qualityLevel);
                string 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>");
                string modifiersTooltipString = SE_Stats.GetDamageModifiersTooltipString(item.m_shared.m_damageModifiers);
                if (modifiersTooltipString.Length > 0)
                {
                    text.Append(modifiersTooltipString);
                }

                string 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 removePenalty = magicItem.HasEffect(MagicEffectType.RemoveSpeedPenalty);

                var itemMovementModifier = removePenalty ? 0 : item.m_shared.m_movementModifier * 100f;
                if (magicMovement)
                {
                    itemMovementModifier += magicItem.GetTotalEffectValue(MagicEffectType.ModifyMovementSpeed);
                }

                var itemMovementModDisplay = (itemMovementModifier == 0) ? "0%" : $"{itemMovementModifier:+0;-0}%";

                float 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 (!string.IsNullOrEmpty(item.m_shared.m_setName))
            {
                AddSetTooltip(item, text);
            }

            __result = text.ToString();
            return(false);
        }