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); }
public void ReplaceEffect(int index, MagicItemEffect newEffect) { if (index < 0 || index >= Effects.Count) { EpicLoot.LogError("Tried to replace effect on magic item outside of the range of the effects list!"); return; } SetEffectAsAugmented(index); Effects[index] = newEffect; }
private static string GetEffectText(MagicItemEffect effect) { var value = effect.EffectValue; var intValue = (int)effect.EffectValue; var percentValue = Mathf.Round(effect.EffectValue * 200.0f) / 2; switch (effect.EffectType) { case MagicEffectType.ModifyDamage: return($"Increase damage by {value}%"); default: throw new ArgumentOutOfRangeException(); } }
private static string GetEffectText(MagicItemEffect effect, ItemRarity rarity, bool showRange) { var effectDef = MagicItemEffectDefinitions.Get(effect.EffectType); var result = string.Format(effectDef.DisplayText, effect.EffectValue); var values = effectDef.GetValuesForRarity(rarity); if (showRange && values != null) { if (!Mathf.Approximately(values.MinValue, values.MaxValue)) { result += $" [{values.MinValue}-{values.MaxValue}]"; } } return(result); }
public static string GetEffectText(MagicItemEffect effect, ItemRarity rarity, bool showRange, string legendaryID, MagicItemEffectDefinition.ValueDef valuesOverride) { var effectDef = MagicItemEffectDefinitions.Get(effect.EffectType); var result = GetEffectText(effectDef, effect.EffectValue); var values = valuesOverride ?? (string.IsNullOrEmpty(legendaryID) ? effectDef.GetValuesForRarity(rarity) : UniqueLegendaryHelper.GetLegendaryEffectValues(legendaryID, effect.EffectType)); if (showRange && values != null) { if (!Mathf.Approximately(values.MinValue, values.MaxValue)) { result += $" [{values.MinValue}-{values.MaxValue}]"; } } return(result); }
public void ReplaceEffect(int index, MagicItemEffect newEffect) { if (index < 0 || index >= Effects.Count) { EpicLoot.LogError("Tried to replace effect on magic item outside of the range of the effects list!"); return; } if (HasBeenAugmented() && AugmentedEffectIndex != index) { EpicLoot.LogError($"Tried to replace an effect on index {index} but the player has already augmented this item at index {AugmentedEffectIndex}"); return; } AugmentedEffectIndex = index; Effects[index] = newEffect; }
public static List <MagicItemEffect> GetAllActiveSetMagicEffects(this Player player, string effectType = null) { var activeSetEffects = new List <MagicItemEffect>(); var equippedSets = player.GetEquippedSets(); foreach (var setInfo in equippedSets) { var count = player.GetEquippedSetPieces(setInfo.ID).Count; foreach (var setBonusInfo in setInfo.SetBonuses) { if (count >= setBonusInfo.Count && (effectType == null || setBonusInfo.Effect.Type == effectType)) { var effect = new MagicItemEffect(setBonusInfo.Effect.Type, setBonusInfo.Effect.Values?.MinValue ?? 0); activeSetEffects.Add(effect); } } } return(activeSetEffects); }
private static MagicItemEffectDefinition GetReplacementEffectDef(MagicItemEffect effect) { switch (effect.EffectType) { case "AddFireResistance": return(MagicItemEffectDefinitions.Get(MagicEffectType.AddFireResistancePercentage)); case "AddFrostResistance": return(MagicItemEffectDefinitions.Get(MagicEffectType.AddFrostResistancePercentage)); case "AddLightningResistance": return(MagicItemEffectDefinitions.Get(MagicEffectType.AddLightningResistancePercentage)); case "AddPoisonResistance": return(MagicItemEffectDefinitions.Get(MagicEffectType.AddPoisonResistancePercentage)); case "AddSpiritResistance": return(MagicItemEffectDefinitions.Get(MagicEffectType.AddElementalResistancePercentage)); } return(null); }
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 GetEffectText(MagicItemEffect effect, MagicItemEffectDefinition.ValueDef valuesOverride) { return(GetEffectText(effect, ItemRarity.Legendary, false, null, valuesOverride)); }
public static string GetEffectText(MagicItemEffect effect, ItemRarity rarity, bool showRange, string legendaryID = null) { return(GetEffectText(effect, rarity, showRange, legendaryID, null)); }