public void RerollValue() { List <AffixBonusProperty> bonuses = Base.affixBonuses; for (int i = 0; i < bonuses.Count; i++) { AffixBonusProperty mod = bonuses[i]; if (mod.readAsFloat) { float roll = UnityEngine.Random.Range((int)Math.Round(mod.minValue * 10f, 0), (int)Math.Round(mod.maxValue * 10f, 0) + 1); affixValues[i] = (float)Math.Round(roll, 1); } else { affixValues[i] = UnityEngine.Random.Range((int)mod.minValue, (int)mod.maxValue + 1); } } List <TriggeredEffectBonusProperty> effects = Base.triggeredEffects; for (int i = 0; i < effects.Count; i++) { TriggeredEffectBonusProperty addedEffect = effects[i]; int roll = UnityEngine.Random.Range((int)(addedEffect.effectMinValue * 10f), (int)(addedEffect.effectMaxValue * 10f + 1)); addedEffectValues[i] = (float)Math.Round(roll / 10d, 1); } }
private void ApplyEquipmentBonuses(List <Affix> affixes) { foreach (Affix affix in affixes) { for (int i = 0; i < affix.Base.affixBonuses.Count; i++) { AffixBonusProperty b = affix.Base.affixBonuses[i]; //ignore local mods if (b.bonusType >= (BonusType)0x700) { continue; } else { if (affix.GetAffixValue(i) != 0 || b.modifyType == ModifyType.FIXED_TO) { AddStatBonus(b.bonusType, b.restriction, b.modifyType, affix.GetAffixValue(i)); } } } for (int i = 0; i < affix.Base.triggeredEffects.Count; i++) { TriggeredEffectBonusProperty triggeredEffect = affix.Base.triggeredEffects[i]; TriggeredEffect t = new TriggeredEffect(triggeredEffect, affix.GetEffectValue(i), affix.Base.idName); AddTriggeredEffect(triggeredEffect, t); } } }
public void RemoveTriggeredEffect(TriggeredEffectBonusProperty triggeredEffect) { TriggeredEffect t; t = TriggeredEffects[triggeredEffect.triggerType].Find(x => x.BaseEffect == triggeredEffect); TriggeredEffects[triggeredEffect.triggerType].Remove(t); }
public string GetLocalizationText_TriggeredEffect(TriggeredEffectBonusProperty triggeredEffect, float value, float?maxValue = null) { commonLocalizationData.TryGetValue("triggerType." + triggeredEffect.triggerType.ToString(), out string s); string valueString, effectString, bonusString; if (maxValue != null) { valueString = "(" + value.ToString("F0") + "-" + ((float)maxValue).ToString("F0") + ")"; bonusString = GetLocalizationText_BonusType(triggeredEffect.statBonusType, triggeredEffect.statModifyType, value, (float)maxValue, GroupType.NO_GROUP).TrimEnd('\n'); } else { valueString = value.ToString("F0"); bonusString = GetLocalizationText_BonusType(triggeredEffect.statBonusType, triggeredEffect.statModifyType, value, GroupType.NO_GROUP).TrimEnd('\n'); } switch (triggeredEffect.triggerType) { case TriggerType.WHEN_HITTING: effectString = bonusString; break; default: effectString = GetLocalizationText("effectType.bonusProp." + triggeredEffect.effectType); effectString = effectString.Replace("{TARGET}", GetLocalizationText(triggeredEffect.effectTargetType)); effectString = effectString.Replace("{VALUE}", valueString); if (triggeredEffect.effectType != EffectType.BUFF && triggeredEffect.effectType != EffectType.DEBUFF) { effectString = effectString.Replace("{ELEMENT}", GetLocalizationText_Element(triggeredEffect.effectElement)); } else { effectString = effectString.Replace("{BONUS}", bonusString); } if (triggeredEffect.effectDuration > 0) { effectString += " for " + triggeredEffect.effectDuration.ToString("#.#") + "s"; } break; } string restrictionString = ""; if (triggeredEffect.restriction != GroupType.NO_GROUP) { restrictionString = GetLocalizationText_GroupTypeRestriction(triggeredEffect.restriction); } if (triggeredEffect.triggerChance < 1) { s = triggeredEffect.triggerChance.ToString("P0") + " Chance to " + s; } s = string.Format(s, restrictionString, effectString) + '\n'; return(s); }
public TemporaryTriggerEffectBuff(Actor target, Actor source, TriggeredEffectBonusProperty bonus, float value, float duration, string buffName, EffectType effectType) : base(target, source) { this.effectType = effectType; this.duration = duration; EffectName = buffName; this.bonus = bonus; EffectPower = value; }
public virtual void ApplyTriggerEffects(TriggerType triggerType, Actor target) { Dictionary <ElementType, MinMaxRange> retaliationToEnemy = new Dictionary <ElementType, MinMaxRange>(); Dictionary <ElementType, MinMaxRange> retaliationToSelf = new Dictionary <ElementType, MinMaxRange>(); foreach (TriggeredEffect actorEffect in SourceActor.Data.TriggeredEffects[triggerType].ToArray()) { TriggeredEffectBonusProperty baseEffect = actorEffect.BaseEffect; if (baseEffect.effectType == EffectType.RETALIATION_DAMAGE) { if (baseEffect.effectTargetType == AbilityTargetType.ENEMY) { if (!retaliationToEnemy.ContainsKey(baseEffect.effectElement)) { retaliationToEnemy.Add(baseEffect.effectElement, new MinMaxRange()); } retaliationToEnemy[baseEffect.effectElement].AddToBoth((int)actorEffect.Value); } else if (baseEffect.effectTargetType == AbilityTargetType.SELF) { if (!retaliationToSelf.ContainsKey(baseEffect.effectElement)) { retaliationToSelf.Add(baseEffect.effectElement, new MinMaxRange()); } retaliationToSelf[baseEffect.effectElement].AddToBoth((int)actorEffect.Value); } continue; } actorEffect.OnTrigger(target, SourceActor); } if (retaliationToEnemy.Count > 0) { SourceActor.StartCoroutine(InstantEffects.ApplyRetaliationDamageEffect(target, SourceActor, retaliationToEnemy)); } if (retaliationToSelf.Count > 0) { SourceActor.StartCoroutine(InstantEffects.ApplyRetaliationDamageEffect(SourceActor, SourceActor, retaliationToSelf)); } }
private void RemoveEquipmentBonuses(List <Affix> affixes) { foreach (Affix affix in affixes) { for (int i = 0; i < affix.Base.affixBonuses.Count; i++) { AffixBonusProperty b = affix.Base.affixBonuses[i]; //ignore local mods if (b.bonusType < (BonusType)0x700) { if (affix.GetAffixValue(i) != 0 || b.modifyType == ModifyType.FIXED_TO) { RemoveStatBonus(b.bonusType, b.restriction, b.modifyType, affix.GetAffixValue(i)); } } } for (int i = 0; i < affix.Base.triggeredEffects.Count; i++) { TriggeredEffectBonusProperty triggeredEffect = affix.Base.triggeredEffects[i]; RemoveTriggeredEffect(triggeredEffect); } } }
public void AddTriggeredEffect(TriggeredEffectBonusProperty triggeredEffect, TriggeredEffect effectInstance) { TriggeredEffects[triggeredEffect.triggerType].Add(effectInstance); }
public static string BuildAffixString(AffixBase Base, float indent, Affix instancedAffix = null, IList <float> affixValues = null, IList <float> effectValues = null, bool showRange = false, bool showTier = false) { List <int> bonusesToSkip = new List <int>(); string s = ""; if (showTier) { indent += 2f; if (Base.tier > 0) { s += " T" + Base.tier; } } if (indent != 0) { s += "<indent=" + indent + "em>"; } for (int i = 0; i < Base.affixBonuses.Count; i++) { if (bonusesToSkip.Contains(i)) { continue; } AffixBonusProperty bonusProp = Base.affixBonuses[i]; if (bonusProp.bonusType.ToString().Contains("DAMAGE_MIN") && bonusProp.modifyType == ModifyType.FLAT_ADDITION) { BonusType maxType = (BonusType)Enum.Parse(typeof(BonusType), bonusProp.bonusType.ToString().Replace("_MIN", "_MAX")); int matchedIndex = Base.affixBonuses.FindIndex(x => x.bonusType == maxType); if (matchedIndex > 0 && Base.affixBonuses[matchedIndex].modifyType == ModifyType.FLAT_ADDITION) { bonusesToSkip.Add(matchedIndex); if (bonusProp.restriction != GroupType.NO_GROUP) { s += LocalizationManager.Instance.GetLocalizationText_GroupTypeRestriction(bonusProp.restriction) + ", "; } s += LocalizationManager.Instance.GetLocalizationText("bonusType." + bonusProp.bonusType.ToString().Replace("_MIN", "")) + " "; if (affixValues != null) { s += "<nobr>+" + affixValues[i] + "~" + affixValues[matchedIndex] + "</nobr>"; if (showRange && (bonusProp.minValue != bonusProp.maxValue || Base.affixBonuses[matchedIndex].minValue != Base.affixBonuses[matchedIndex].maxValue)) { s += "<nobr><color=" + Helpers.AFFIX_RANGE_COLOR + "> (" + bonusProp.minValue + "-" + bonusProp.maxValue + ") (" + Base.affixBonuses[matchedIndex].minValue + "-" + Base.affixBonuses[matchedIndex].maxValue + ")</color></nobr>"; } } else { s += "<nobr>+(" + bonusProp.minValue + "-" + bonusProp.maxValue + ")~(" + Base.affixBonuses[matchedIndex].minValue + "-" + Base.affixBonuses[matchedIndex].maxValue + ")</nobr>"; } s += '\n'; continue; } } if (affixValues != null) { s += LocalizationManager.Instance.GetLocalizationText_BonusType(bonusProp.bonusType, bonusProp.modifyType, affixValues[i], bonusProp.restriction); if (showRange && bonusProp.minValue != bonusProp.maxValue) { s = s.TrimEnd('\n') + "<nobr><color=" + Helpers.AFFIX_RANGE_COLOR + "> (" + bonusProp.minValue + "-" + bonusProp.maxValue + ")</color></nobr>\n"; } } else { s += LocalizationManager.Instance.GetLocalizationText_BonusType(bonusProp.bonusType, bonusProp.modifyType, bonusProp.minValue, bonusProp.maxValue, bonusProp.restriction); } } for (int i = 0; i < Base.triggeredEffects.Count; i++) { TriggeredEffectBonusProperty triggeredEffect = Base.triggeredEffects[i]; if (effectValues != null) { s += LocalizationManager.Instance.GetLocalizationText_TriggeredEffect(triggeredEffect, effectValues[i]); } else { s += LocalizationManager.Instance.GetLocalizationText_TriggeredEffect(triggeredEffect, triggeredEffect.effectMinValue, triggeredEffect.effectMaxValue); } if (showRange && triggeredEffect.effectMinValue != triggeredEffect.effectMaxValue) { s = s.TrimEnd('\n') + "<nobr><color=" + Helpers.AFFIX_RANGE_COLOR + "> (" + triggeredEffect.effectMinValue + "-" + triggeredEffect.effectMaxValue + ")</color></nobr>\n"; } } if (instancedAffix != null) { if (instancedAffix.IsLocked) { s = "<sprite=15> <color=#00802b>" + s.TrimEnd('\n') + "</color>\n"; } else { s = "○ " + s; } } if (indent != 0) { s = s.TrimEnd('\n') + "</indent>\n"; } return(s); }
public TriggeredEffect(TriggeredEffectBonusProperty baseEffect, float value, string sourceName) { this.sourceName = sourceName; BaseEffect = baseEffect; Value = value; }