public StatusEffects() { _onExpire = new ModifierEffect(); _onRemove = new ModifierEffect(); _onTick = new ModifierEffect(); _onApply = new ModifierEffect(); }
/// <summary> /// Calculate the damage for a status tick. /// </summary> /// <param name="castable">Castable responsible for the status</param> /// <param name="effect">ModifierEffect structure for the status</param> /// <param name="target">Target for the damage (e.g. the player or creature with the status)</param> /// <param name="source">Original source of the status</param> /// <param name="statusName">The name of the status</param> /// <returns></returns> public static DamageOutput CalculateDamage(Xml.Castable castable, Xml.ModifierEffect effect, Creature target, Creature source, string statusName) { // Defaults double dmg = 0; var type = effect.Damage?.Type ?? Xml.DamageType.Magical; if (effect?.Damage == null) { return new DamageOutput() { Amount = dmg, Type = type, Flags = Xml.DamageFlags.None, Element = castable.Element } } ; var statusAdd = castable?.Effects?.Statuses?.Add?.Where(e => e.Value == statusName)?.ToList(); var intensity = statusAdd != null ? statusAdd[0].Intensity : 1; if (effect.Damage.IsSimple) { dmg = _evalSimple(effect.Damage.Simple); } else { dmg = _evalFormula(effect.Damage.Formula, castable, target, source); } return(new DamageOutput() { Amount = (dmg * intensity * target.Stats.DamageModifier), Type = type, Flags = effect.Damage.Flags, Element = castable.Element }); }
private void ProcessFullEffects(Xml.ModifierEffect effect, bool RemoveStatBonuses = false, bool displaySfx = true) { // Stat modifiers and condition changes are only processed during start/remove ProcessConditions(effect); ProcessStatModifiers(XmlStatus.Effects?.OnApply?.StatModifiers, RemoveStatBonuses); if (displaySfx) { ProcessSfx(effect); } }
private void ProcessConditions(Xml.ModifierEffect effect) { if (effect.Conditions?.Set != null) { Target.Condition.Conditions |= effect.Conditions.Set; } if (effect.Conditions?.Unset != null) { Target.Condition.Conditions &= ~effect.Conditions.Unset; } }
private void ProcessSfx(Xml.ModifierEffect effect) { if (effect.Sound?.Id != 0) { User?.PlaySound(effect.Sound.Id); } if (effect.Animations != null) { if (effect.Animations?.Target?.Id != 0) { var animation = effect.Animations.Target; if (Target is Monster || !Target.Condition.Comatose || (Target.Condition.Comatose && animation.Id == (Game.Config.Handlers?.Death?.Coma?.Effect ?? 24))) { Target.Effect(effect.Animations.Target.Id, effect.Animations.Target.Speed); } } if (effect.Animations?.SpellEffect?.Id != 0) { Source?.Effect(effect.Animations.SpellEffect.Id, effect.Animations.SpellEffect.Speed); } } // Message handling if (effect.Messages != null) { if (User != null) { if (effect.Messages?.Target != null) { User.SendSystemMessage(string.Format(effect.Messages.Target, User.Name)); } if (effect.Messages?.Group != null) { User.Group?.SendMessage(string.Format(effect.Messages.Group, User.Name)); } } if (effect.Messages?.Source != null) { (Source as User)?.SendSystemMessage(string.Format(effect.Messages.Source, User?.Name ?? string.Empty)); } if (effect.Messages?.Say != null) { Target.Say(string.Format(effect.Messages.Say, User?.Name ?? string.Empty)); } if (effect.Messages?.Shout != null) { Target.Shout(string.Format(effect.Messages.Shout, User?.Name ?? string.Empty)); } } }
/// <summary> /// Deserializes xml markup from file into an ModifierEffect object /// </summary> /// <param name="fileName">string xml file to load and deserialize</param> /// <param name="obj">Output ModifierEffect object</param> /// <param name="exception">output Exception value if deserialize failed</param> /// <returns>true if this Serializer can deserialize the object; otherwise, false</returns> public static bool LoadFromFile(string fileName, out ModifierEffect obj, out Exception exception) { exception = null; obj = default(ModifierEffect); try { obj = LoadFromFile(fileName); return(true); } catch (Exception ex) { exception = ex; return(false); } }
/// <summary> /// Deserializes ModifierEffect object /// </summary> /// <param name="input">string workflow markup to deserialize</param> /// <param name="obj">Output ModifierEffect object</param> /// <param name="exception">output Exception value if deserialize failed</param> /// <returns>true if this Serializer can deserialize the object; otherwise, false</returns> public static bool Deserialize(string input, out ModifierEffect obj, out Exception exception) { exception = null; obj = default(ModifierEffect); try { obj = Deserialize(input); return(true); } catch (Exception ex) { exception = ex; return(false); } }
/// <summary> /// Calculate the healing for a status tick. /// </summary> /// <param name="castable">Castable responsible for the status</param> /// <param name="effect">ModifierEffect structure for the status</param> /// <param name="target">Target for the healing (e.g. the player or creature with the status)</param> /// <param name="source">Original source of the status</param> /// <param name="statusName">The name of the status</param> /// <returns></returns> public static double CalculateHeal(Xml.Castable castable, Xml.ModifierEffect effect, Creature target, Creature source, string statusName) { // Defaults double heal = 0; if (effect?.Heal == null) { return(heal); } var statusAdd = castable?.Effects?.Statuses?.Add?.Where(e => e.Value == statusName)?.ToList(); var intensity = statusAdd != null ? statusAdd[0].Intensity : 1; if (effect.Heal.IsSimple) { heal = _evalSimple(effect.Heal.Simple); } else { heal = _evalFormula(effect.Heal.Formula, castable, target, source); } return(heal * intensity * target.Stats.HealModifier); }
public static bool LoadFromFile(string fileName, out ModifierEffect obj) { Exception exception = null; return(LoadFromFile(fileName, out obj, out exception)); }
public static bool Deserialize(string input, out ModifierEffect obj) { Exception exception = null; return(Deserialize(input, out obj, out exception)); }
private void ProcessEffects(Xml.ModifierEffect effect) { ProcessSfx(effect); }
private (double Heal, DamageOutput Damage) CalculateNumericEffects(Xml.Castable castable, Xml.ModifierEffect effect, Creature source) { double heal = 0; DamageOutput dmg = new DamageOutput(); if (!effect.Heal.IsEmpty) { heal = NumberCruncher.CalculateHeal(castable, effect, Target, source, Name); } if (!effect.Damage.IsEmpty) { dmg = NumberCruncher.CalculateDamage(castable, effect, Target, source, Name); } return(heal, dmg); }