public static string GetNameForItem(ItemDrop.ItemData item, MagicItem magicItem) { var baseName = TranslateAndCapitalize(item.m_shared.m_name); if (!EpicLoot.UseGeneratedMagicItemNames.Value || magicItem == null) { return(null); } var rarity = magicItem.Rarity; switch (rarity) { case ItemRarity.Magic: var magicFormat = Localization.instance.Localize("$mod_epicloot_basicmagicnameformat"); return(string.Format(magicFormat, baseName)); case ItemRarity.Rare: var prefix = GetPrefix(magicItem); var suffix = GetSuffix(magicItem); var fullNameFormat = Localization.instance.Localize("$mod_epicloot_fullnameformat"); return(string.Format(fullNameFormat, prefix, baseName, suffix)); case ItemRarity.Epic: return(BuildEpicName(item, magicItem)); case ItemRarity.Legendary: return(GetLegendaryName(item, magicItem)); default: throw new ArgumentOutOfRangeException(); } }
public static string GetNamePartForItem(ItemDrop.ItemData item, MagicItem magicItem) { var names = GetAllowedNamesFromList(Config.Epic.Names, item, magicItem); var namePart = GetRandomStringFromList(names); return(string.IsNullOrEmpty(namePart) ? TranslateAndCapitalize(item.m_shared.m_name) : namePart); }
public static string BuildEpicName(ItemDrop.ItemData item, MagicItem magicItem) { var adjective = GetAdjectivePartForItem(item, magicItem); var name = GetNamePartForItem(item, magicItem); return($"{adjective} {name}"); }
public static string GetAdjectivePartForItem(ItemDrop.ItemData item, MagicItem magicItem) { var adjectives = GetAllowedNamesFromList(Config.Epic.Adjectives, item, magicItem); var adjectivePart = GetRandomStringFromList(adjectives); return(string.IsNullOrEmpty(adjectivePart) ? EpicLoot.GetRarityDisplayName(ItemRarity.Epic) : adjectivePart); }
public static string GetNameForItem(ItemDrop.ItemData item, MagicItem magicItem) { var baseName = item.m_shared.m_name; if (!EpicLoot.UseGeneratedMagicItemNames.Value || magicItem == null) { return(null); } var rarity = magicItem.Rarity; switch (rarity) { case ItemRarity.Magic: return($"{EpicLoot.GetRarityDisplayName(ItemRarity.Magic)} {baseName}"); case ItemRarity.Rare: var prefix = GetPrefix(magicItem); var suffix = GetSuffix(magicItem); return($"{prefix}{TranslateAndCapitalize(baseName)}{suffix}"); case ItemRarity.Epic: return(BuildEpicName(item, magicItem)); case ItemRarity.Legendary: return(GetLegendaryName(item, magicItem)); default: throw new ArgumentOutOfRangeException(); } }
private static string GetLegendaryName(ItemDrop.ItemData item, MagicItem magicItem) { var allowedNames = GetAllowedNamesFromListAllRequired(Config.Legendary, item, magicItem); var name = GetRandomStringFromList(allowedNames); return(string.IsNullOrEmpty(name) ? $"{EpicLoot.GetRarityDisplayName(ItemRarity.Legendary)} {TranslateAndCapitalize(item.m_shared.m_name)}" : name); }
public static void OnNewExtendedItemData(ExtendedItemData itemdata) { if (itemdata.m_shared.m_name == "$item_helmet_dverger") { var magicItem = new MagicItem(); magicItem.Rarity = ItemRarity.Rare; magicItem.Effects.Add(new MagicItemEffect(MagicEffectType.DvergerCirclet)); magicItem.TypeNameOverride = "$mod_epicloot_circlet"; itemdata.ReplaceComponent <MagicItemComponent>().MagicItem = magicItem; } else if (itemdata.m_shared.m_name == "$item_beltstrength") { var magicItem = new MagicItem(); magicItem.Rarity = ItemRarity.Rare; magicItem.Effects.Add(new MagicItemEffect(MagicEffectType.Megingjord)); magicItem.TypeNameOverride = "$mod_epicloot_belt"; itemdata.ReplaceComponent <MagicItemComponent>().MagicItem = magicItem; } else if (itemdata.m_shared.m_name == "$item_wishbone") { var magicItem = new MagicItem(); magicItem.Rarity = ItemRarity.Epic; magicItem.Effects.Add(new MagicItemEffect(MagicEffectType.Wishbone)); magicItem.TypeNameOverride = "$mod_epicloot_remains"; itemdata.ReplaceComponent <MagicItemComponent>().MagicItem = magicItem; } }
private static List <GameObject> GetLoot(LootTable lootTable, string characterName) { var results = new List <GameObject>(); foreach (var lootDrop in lootTable.Loot) { var shouldDrop = Random.Range(0.0f, 1.0f) <= lootDrop.PercentDrop; if (shouldDrop) { var itemPrefab = ObjectDB.instance.GetItemPrefab(lootDrop.Item); if (itemPrefab == null) { Debug.LogError($"Tried to spawn loot ({lootDrop.Item}) for character ({characterName}), but the item prefab was not found!"); continue; } var item = Instantiate(itemPrefab); var itemDrop = item.GetComponent <ItemDrop>(); //itemDrop.m_itemData = UniqueItemIdentifiers.UniqueItemIdentifiers.ConvertToUniqueItemData(itemDrop.m_itemData, "EpicLoot.GetLoot"); var magicItem = new MagicItem(); // TODO: Generate magic item magicItem.Rarity = GetItemRarity(lootDrop); magicItem.Effects.Add(new MagicItemEffect() { EffectType = MagicEffectType.ModifyDamage, EffectValue = 0.10f }); //SaveMagicItem((itemDrop.m_itemData as UniqueItemData).m_guid, magicItem); } } return(results); }
public static string BuildEpicName(ItemDrop.ItemData item, MagicItem magicItem) { var adjective = GetAdjectivePartForItem(item, magicItem); var name = GetNamePartForItem(item, magicItem); var format = Localization.instance.Localize("$mod_epicloot_epicnameformat"); return(string.Format(format, adjective, name)); }
public static void AddDebugMagicEffects(MagicItem item) { if (!string.IsNullOrEmpty(ForcedMagicEffect) && !item.HasEffect(ForcedMagicEffect)) { EpicLoot.Log($"AddDebugMagicEffect {ForcedMagicEffect}"); item.Effects.Add(RollEffect(MagicItemEffectDefinitions.Get(ForcedMagicEffect), item.Rarity)); } }
public void SetMagicItem(MagicItem magicItem) { MagicItem = magicItem; Save(); if (ItemData.m_equiped && Player.m_localPlayer.IsItemEquiped(ItemData)) { Multiplayer_Player_Patch.UpdatePlayerZDOForEquipment(Player.m_localPlayer, ItemData, MagicItem != null); } }
public bool CheckRequirements(ExtendedItemData itemData, MagicItem magicItem) { if (Requirements == null) { return(true); } return(Requirements.CheckRequirements(itemData, magicItem, Type)); }
public static void SaveMagicItem(string guid, MagicItem magicItem) { if (_zdo == null) { Debug.LogError($"Tried to save magic item ({guid}) but _zdo was null!"); return; } _zdo.Set(guid, JsonMapper.ToJson(magicItem)); }
public override void Deserialize(string data) { try { MagicItem = JSON.ToObject <MagicItem>(data, _saveParams); } catch (Exception) { EpicLoot.LogError($"[{nameof(MagicItemComponent)}] Could not deserialize MagicItem json data! ({ItemData?.m_shared?.m_name})"); throw; } }
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(); }
public static string GetMovementModifier(ItemDrop.ItemData item, MagicItem magicItem, out bool magicMovement, out bool removePenalty) { magicMovement = magicItem.HasEffect(MagicEffectType.ModifyMovementSpeed); removePenalty = magicItem.HasEffect(MagicEffectType.RemoveSpeedPenalty); var itemMovementModifier = removePenalty ? 0 : item.m_shared.m_movementModifier * 100f; if (magicMovement) { itemMovementModifier += magicItem.GetTotalEffectValue(MagicEffectType.ModifyMovementSpeed); } return((itemMovementModifier == 0) ? "0%" : $"{itemMovementModifier:+0;-0}%"); }
public static void AddMagicEffectsPage(TextsDialog textsDialog, Player player) { var magicEffects = new Dictionary <string, List <KeyValuePair <MagicItemEffect, ItemDrop.ItemData> > >(); var allEquipment = player.GetEquipment(); foreach (var item in allEquipment) { if (item.IsMagic()) { foreach (var effect in item.GetMagicItem().Effects) { if (!magicEffects.TryGetValue(effect.EffectType, out var effectList)) { effectList = new List <KeyValuePair <MagicItemEffect, ItemDrop.ItemData> >(); magicEffects.Add(effect.EffectType, effectList); } effectList.Add(new KeyValuePair <MagicItemEffect, ItemDrop.ItemData>(effect, item)); } } } var t = new StringBuilder(); foreach (var entry in magicEffects) { var effectType = entry.Key; var effectDef = MagicItemEffectDefinitions.Get(effectType); var sum = entry.Value.Sum(x => x.Key.EffectValue); var totalEffectText = MagicItem.GetEffectText(effectDef, sum); var highestRarity = (ItemRarity)entry.Value.Max(x => (int)x.Value.GetRarity()); t.AppendLine($"<size=20><color={EpicLoot.GetRarityColor(highestRarity)}>{totalEffectText}</color></size>"); foreach (var entry2 in entry.Value) { var effect = entry2.Key; var item = entry2.Value; t.AppendLine($" <color=silver>- {MagicItem.GetEffectText(effect, item.GetRarity(), false)} ({item.GetDecoratedName()})</color>"); } t.AppendLine(); } textsDialog.m_texts.Insert(EpicLoot.HasAuga ? 0 : 2, new TextsDialog.TextInfo( Localization.instance.Localize($"{EpicLoot.GetMagicEffectPip(false)} $mod_epicloot_active_magic_effects"), Localization.instance.Localize(t.ToString()))); }
private static string GetLegendaryName(ItemDrop.ItemData item, MagicItem magicItem) { var allowedNames = GetAllowedNamesFromListAllRequired(Config.Legendary, item, magicItem); var name = GetRandomStringFromList(allowedNames); if (!string.IsNullOrEmpty(name)) { return(name); } var format = Localization.instance.Localize("$mod_epicloot_basiclegendarynameformat"); var baseName = TranslateAndCapitalize(item.m_shared.m_name); return(string.Format(format, baseName)); }
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()); }
public static object GetSuffix(MagicItem magicItem) { if (magicItem.Effects.Count < 2) { return(null); } var secondEffect = magicItem.Effects[1]; var effectDef = MagicItemEffectDefinitions.Get(secondEffect.EffectType); if (effectDef == null) { return(null); } var suffixes = effectDef.Suffixes ?? Config.Rare.GenericSuffixes; var randomSuffix = GetRandomStringFromList(suffixes); // Include " of " return(string.IsNullOrEmpty(randomSuffix) ? null : $" of {randomSuffix}"); }
public static object GetPrefix(MagicItem magicItem) { if (magicItem.Effects.Count == 0) { return(null); } var firstEffect = magicItem.Effects[0]; var effectDef = MagicItemEffectDefinitions.Get(firstEffect.EffectType); if (effectDef == null) { return(null); } var prefixes = effectDef.Prefixes ?? Config.Rare.GenericPrefixes; var randomPrefix = GetRandomStringFromList(prefixes); // Include trailing space return(string.IsNullOrEmpty(randomPrefix) ? null : $"{randomPrefix} "); }
private static bool DoCheck(Player player, ZDO zdo, string equipKey, string legendaryDataKey, ref ItemDrop.ItemData itemData) { var zdoLegendaryID = zdo.GetString(legendaryDataKey); if (string.IsNullOrEmpty(zdoLegendaryID)) { var hadItem = itemData != null; if (hadItem) { ForceResetVisEquipment(player, itemData); } itemData = null; return(hadItem); } var currentLegendaryID = itemData?.GetMagicItem()?.LegendaryID; if (currentLegendaryID == zdoLegendaryID) { return(false); } var itemHash = zdo.GetInt(equipKey); var itemPrefab = ObjectDB.instance.GetItemPrefab(itemHash); if (itemPrefab?.GetComponent <ItemDrop>()?.m_itemData is ItemDrop.ItemData targetItemData) { itemData = new ExtendedItemData(targetItemData); itemData.m_durability = float.PositiveInfinity; var magicItemComponent = itemData.Extended().AddComponent <MagicItemComponent>(); var stubMagicItem = new MagicItem { Rarity = ItemRarity.Legendary, LegendaryID = zdoLegendaryID }; magicItemComponent.SetMagicItem(stubMagicItem); ForceResetVisEquipment(player, itemData); } return(false); }
public static void OnNewExtendedItemData(ExtendedItemData itemdata) { if (itemdata.m_shared.m_name == "$item_helmet_dverger") { var magicItem = new MagicItem(); magicItem.Rarity = ItemRarity.Legendary; magicItem.Effects.Add(new MagicItemEffect() { EffectType = MagicEffectType.DvergerCirclet }); magicItem.DisplayNameOverride = "circlet"; itemdata.ReplaceComponent <MagicItemComponent>().MagicItem = magicItem; } else if (itemdata.m_shared.m_name == "$item_beltstrength") { var magicItem = new MagicItem(); magicItem.Rarity = ItemRarity.Legendary; magicItem.Effects.Add(new MagicItemEffect() { EffectType = MagicEffectType.Megingjord }); magicItem.DisplayNameOverride = "belt"; itemdata.ReplaceComponent <MagicItemComponent>().MagicItem = magicItem; } else if (itemdata.m_shared.m_name == "$item_wishbone") { var magicItem = new MagicItem(); magicItem.Rarity = ItemRarity.Legendary; magicItem.Effects.Add(new MagicItemEffect() { EffectType = MagicEffectType.Wishbone }); magicItem.DisplayNameOverride = "remains"; itemdata.ReplaceComponent <MagicItemComponent>().MagicItem = magicItem; } }
public static object GetSuffix(MagicItem magicItem) { if (magicItem.Effects.Count < 2) { return(null); } var secondEffect = magicItem.Effects[1]; var effectDef = MagicItemEffectDefinitions.Get(secondEffect.EffectType); if (effectDef == null) { return(null); } var suffixes = effectDef.Suffixes ?? Config.Rare.GenericSuffixes; var randomSuffix = GetRandomStringFromList(suffixes); // Include " of " var format = Localization.instance.Localize("$mod_epicloot_suffixformat"); return(string.IsNullOrEmpty(randomSuffix) ? null : string.Format(format, randomSuffix)); }
public static object GetPrefix(MagicItem magicItem) { if (magicItem.Effects.Count == 0) { return(null); } var firstEffect = magicItem.Effects[0]; var effectDef = MagicItemEffectDefinitions.Get(firstEffect.EffectType); if (effectDef == null) { return(null); } var prefixes = effectDef.Prefixes ?? Config.Rare.GenericPrefixes; var randomPrefix = GetRandomStringFromList(prefixes); // Include trailing space var format = Localization.instance.Localize("$mod_epicloot_prefixformat"); return(string.IsNullOrEmpty(randomPrefix) ? null : string.Format(format, randomPrefix)); }
public void SetMagicItem(MagicItem magicItem) { MagicItem = magicItem; Save(); }
public static List <MagicItemEffectDefinition> GetAvailableEffects(ExtendedItemData itemData, MagicItem magicItem) { return(AllDefinitions.Values.Where(x => x.CheckRequirements(itemData, magicItem)).ToList()); }
public bool CheckRequirements(ExtendedItemData itemData, MagicItem magicItem) { if (Requirements == null) { return(true); } if (Requirements.NoRoll) { return(false); } if (Requirements.ExclusiveSelf && magicItem.HasEffect(Type)) { return(false); } if (Requirements.ExclusiveEffectTypes?.Count > 0 && magicItem.HasAnyEffect(Requirements.ExclusiveEffectTypes)) { return(false); } if (Requirements.AllowedItemTypes?.Count > 0 && !Requirements.AllowedItemTypes.Contains(itemData.m_shared.m_itemType)) { return(false); } if (Requirements.AllowedRarities?.Count > 0 && !Requirements.AllowedRarities.Contains(magicItem.Rarity)) { return(false); } if (Requirements.AllowedItemNames?.Count > 0 && !Requirements.AllowedItemNames.Contains(itemData.m_shared.m_name)) { return(false); } if (Requirements.ItemHasPhysicalDamage && itemData.m_shared.m_damages.GetTotalPhysicalDamage() <= 0) { return(false); } if (Requirements.ItemHasElementalDamage && itemData.m_shared.m_damages.GetTotalElementalDamage() <= 0) { return(false); } if (Requirements.ItemUsesDurability && !itemData.m_shared.m_useDurability) { return(false); } if (Requirements.ItemHasNegativeMovementSpeedModifier && itemData.m_shared.m_movementModifier >= 0) { return(false); } if (Requirements.ItemHasBlockPower && itemData.m_shared.m_blockPower <= 0) { return(false); } if (Requirements.ItemHasParryPower && itemData.m_shared.m_deflectionForce <= 0) { return(false); } if (Requirements.ItemHasArmor && itemData.m_shared.m_armor <= 0) { return(false); } if (Requirements.ItemHasBackstabBonus && itemData.m_shared.m_backstabBonus <= 0) { return(false); } if (Requirements.ItemUsesStaminaOnAttack && itemData.m_shared.m_attack.m_attackStamina <= 0 && itemData.m_shared.m_secondaryAttack.m_attackStamina <= 0) { return(false); } return(true); }
public override void Deserialize(string data) { MagicItem = JSON.ToObject <MagicItem>(data); }
public static List <MagicItemEffectDefinition> GetAvailableEffects(ExtendedItemData itemData, MagicItem magicItem, int ignoreEffectIndex = -1) { MagicItemEffect effect = null; if (ignoreEffectIndex >= 0 && ignoreEffectIndex < magicItem.Effects.Count) { effect = magicItem.Effects[ignoreEffectIndex]; magicItem.Effects.RemoveAt(ignoreEffectIndex); } var results = AllDefinitions.Values.Where(x => x.CheckRequirements(itemData, magicItem)).ToList(); if (effect != null) { magicItem.Effects.Insert(ignoreEffectIndex, effect); if (AllDefinitions.TryGetValue(effect.EffectType, out var ignoredEffectDef)) { if (!results.Contains(ignoredEffectDef)) { results.Add(ignoredEffectDef); } } } return(results); }