/// <summary>Sends updates to the client for spell-modifier</summary> public static void SendModifierUpdate(Character chr, SpellEffect effect, bool isPercent) { SpellModifierType miscValue = (SpellModifierType)effect.MiscValue; List <AddModifierEffectHandler> modifierEffectHandlerList = isPercent ? chr.PlayerAuras.SpellModifiersPct : chr.PlayerAuras.SpellModifiersFlat; foreach (uint affectMaskBit in effect.AffectMaskBitSet) { int amount = 0; uint num1 = affectMaskBit >> 5; uint num2 = affectMaskBit - (num1 << 5); for (int index = 0; index < modifierEffectHandlerList.Count; ++index) { AddModifierEffectHandler modifierEffectHandler = modifierEffectHandlerList[index]; if ((SpellModifierType)modifierEffectHandler.SpellEffect.MiscValue == miscValue && modifierEffectHandler.SpellEffect.Spell.SpellClassSet == effect.Spell.SpellClassSet && (modifierEffectHandler.SpellEffect.AffectMask[num1] & 1 << (int)num2) != 0L) { amount += modifierEffectHandler.SpellEffect.ValueMin; } } SpellHandler.SendSpellModifier(chr, (byte)affectMaskBit, miscValue, amount, isPercent); } }
/// <summary> /// Returns the modified value (modified by certain talents) of the given type for the given spell (as float) /// </summary> public override float GetModifiedFloat(SpellModifierType type, Spell spell, float value) { var flatMod = GetModifierFlat(type, spell); var percentMod = GetModifierPercent(type, spell); return((value + flatMod) * (1 + (percentMod / 100f))); }
/// <summary> /// Returns the modified value (modified by certain talents) of the given type for the given spell (as float) /// </summary> public override float GetModifiedFloat(SpellModifierType type, Spell spell, float value) { int modifierFlat = GetModifierFlat(type, spell); int modifierPercent = GetModifierPercent(type, spell); return((float)((value + (double)modifierFlat) * (1.0 + modifierPercent / 100.0))); }
public SpellModifier(int id, ModifierCondition condition, SpellModifierType modifierType) { Id = id; modifierCondition = condition; ModifierType = modifierType; NeedRemoval = false; }
/// <summary> /// Returns the given value minus bonuses through certain talents, of the given type for the given spell (as int) /// </summary> public override int GetModifiedIntNegative(SpellModifierType type, Spell spell, int value) { var flatMod = GetModifierFlat(type, spell); var percentMod = GetModifierPercent(type, spell); return((((value - flatMod) * (100 - percentMod)) + 50) / 100); // rounded }
/// <summary> /// Returns the modified value (modified by certain talent bonusses) of the given type for the given spell (as int) /// </summary> public override int GetModifiedInt(SpellModifierType type, Spell spell, int value) { int modifierFlat = this.GetModifierFlat(type, spell); int modifierPercent = this.GetModifierPercent(type, spell); return(((value + modifierFlat) * (100 + modifierPercent) + 50) / 100); }
/// <summary> /// Returns the given value minus bonuses through certain talents, of the given type for the given spell (as int) /// </summary> public override int GetModifiedIntNegative(SpellModifierType type, Spell spell, int value) { int modifierFlat = GetModifierFlat(type, spell); int modifierPercent = GetModifierPercent(type, spell); return(((value - modifierFlat) * (100 - modifierPercent) + 50) / 100); }
/// <summary> /// Returns the modified value (modified by certain talents) of the given type for the given spell (as float) /// </summary> public virtual float GetModifiedFloat(SpellModifierType type, Spell spell, float value) { if (this.Owner.Master is Character) { return(((Character)this.Owner.Master).PlayerAuras.GetModifiedFloat(type, spell, value)); } return(value); }
/// <summary> /// Returns the given value minus bonuses through certain talents, of the given type for the given spell (as int) /// </summary> public virtual int GetModifiedIntNegative(SpellModifierType type, Spell spell, int value) { if (this.Owner.Master is Character) { return(((Character)this.Owner.Master).PlayerAuras.GetModifiedIntNegative(type, spell, value)); } return(value); }
/// <summary> /// Sends spell modifier update /// </summary> public static void SendSpellModifier(Character chr, byte groupBitNumber, SpellModifierType type, int amount, bool isPercent) { var opcode = isPercent ? RealmServerOpCode.SMSG_SET_PCT_SPELL_MODIFIER : RealmServerOpCode.SMSG_SET_FLAT_SPELL_MODIFIER; using (var packet = new RealmPacketOut(opcode, 6)) { packet.Write(groupBitNumber); packet.Write((byte)type); packet.Write(amount); chr.Send(packet, addEnd: false); } }
/// <summary> /// Returns the flat modifier (through certain talents) of the given type for the given spell /// </summary> public int GetModifierFlat(SpellModifierType type, Spell spell) { var amount = 0; for (var i = 0; i < SpellModifiersFlat.Count; i++) { var modifier = SpellModifiersFlat[i]; if ((SpellModifierType)modifier.SpellEffect.MiscValue == type && modifier.SpellEffect.MatchesSpell(spell)) { amount += modifier.SpellEffect.ValueMin; } } return(amount); }
/// <summary> /// Returns the flat modifier (through certain talents) of the given type for the given spell /// </summary> public int GetModifierFlat(SpellModifierType type, Spell spell) { int num = 0; for (int index = 0; index < SpellModifiersFlat.Count; ++index) { AddModifierEffectHandler modifierEffectHandler = SpellModifiersFlat[index]; if ((SpellModifierType)modifierEffectHandler.SpellEffect.MiscValue == type && modifierEffectHandler.SpellEffect.MatchesSpell(spell)) { num += modifierEffectHandler.SpellEffect.ValueMin; } } return(num); }
internal float ApplySpellModifier(Spell spell, SpellModifierType modifierType, float baseValue) { float valueMultiplier = 1.0f; float valueModifier = 0.0f; if (spellModifiers.TryGetValue((modifierType, SpellModifierApplicationType.Flat), out List <SpellModifier> flatModifiers)) { foreach (SpellModifier modifier in flatModifiers) { if (!IsAffectedBySpellModifier(spell, modifier)) { continue; } valueModifier += modifier.Value; spell.AddAppliedModifierAura(modifier.Aura); } } float flatValue = baseValue + valueModifier; if (Mathf.Approximately(flatValue, 0.0f)) { return(0.0f); } if (spellModifiers.TryGetValue((modifierType, SpellModifierApplicationType.Percent), out List <SpellModifier> percentModifiers)) { foreach (SpellModifier modifier in percentModifiers) { if (!IsAffectedBySpellModifier(spell, modifier)) { continue; } valueMultiplier *= 1.0f + 1.0f.ApplyPercentage(modifier.Value); spell.AddAppliedModifierAura(modifier.Aura); if (Mathf.Approximately(valueMultiplier, 0.0f)) { return(0.0f); } } } return(flatValue * valueMultiplier); }
public SpellInfoModifierFromBuff(int id, ModifierCondition condition, SpellModifierType modifierType, float newValue, string newSpellName) : base(id, condition, modifierType) { value = newValue; SpellName = newSpellName; }
/// <summary> /// Sends spell modifier update /// </summary> public static void SendSpellModifier(Character chr, byte groupBitNumber, SpellModifierType type, int amount, bool isPercent) { var opcode = isPercent ? RealmServerOpCode.SMSG_SET_PCT_SPELL_MODIFIER : RealmServerOpCode.SMSG_SET_FLAT_SPELL_MODIFIER; using (var packet = new RealmPacketOut(opcode, 6)) { packet.Write(groupBitNumber); packet.Write((byte) type); packet.Write(amount); chr.Send(packet); } }
internal void HandleUnappliedModifers(Unit unit, SpellModifierType modifierType, SpellModifierApplicationType applicationType, ref float value) { switch (applicationType) { case SpellModifierApplicationType.Flat: for (int i = unappliedModifiers.Count - 1; i >= 0; i--) { if (unappliedModifiers[i].Kind != (modifierType, applicationType)) { continue; } if (!unit.Spells.IsAffectedBySpellModifier(this, unappliedModifiers[i])) { continue; } value += unappliedModifiers[i].Value; appliedModifiers.Add(unappliedModifiers[i]); unappliedModifiers.RemoveAt(i); } break; case SpellModifierApplicationType.Percent: for (int i = unappliedModifiers.Count - 1; i >= 0; i--) { if (unappliedModifiers[i].Kind != (modifierType, applicationType)) { continue; } if (!unit.Spells.IsAffectedBySpellModifier(this, unappliedModifiers[i])) { continue; } value *= 1.0f + 1.0f.ApplyPercentage(unappliedModifiers[i].Value); appliedModifiers.Add(unappliedModifiers[i]); unappliedModifiers.RemoveAt(i); } break; case SpellModifierApplicationType.SpellValue: for (int i = unappliedModifiers.Count - 1; i >= 0; i--) { if (unappliedModifiers[i].Kind != (modifierType, applicationType)) { continue; } if (!unit.Spells.IsAffectedBySpellModifier(this, unappliedModifiers[i])) { continue; } if (unappliedModifiers[i].AuraModifier.SpellValueModifier != null) { ApplySpellValueModifier(unappliedModifiers[i].AuraModifier.SpellValueModifier); } appliedModifiers.Add(unappliedModifiers[i]); unappliedModifiers.RemoveAt(i); } break; default: throw new ArgumentOutOfRangeException(nameof(applicationType), applicationType, null); } }
/// <summary> /// Returns the given value minus bonuses through certain talents, of the given type for the given spell (as int) /// </summary> public override int GetModifiedIntNegative(SpellModifierType type, Spell spell, int value) { var flatMod = GetModifierFlat(type, spell); var percentMod = GetModifierPercent(type, spell); return (((value - flatMod) * (100 - percentMod)) + 50) / 100; // rounded }
public SpellInfoModifier(int id, ModifierCondition condition, SpellModifierType modifierType, float newValue) : base(id, condition, modifierType) { value = newValue; }
/// <summary> /// Returns the flat modifier (through certain talents) of the given type for the given spell /// </summary> public int GetModifierFlat(SpellModifierType type, Spell spell) { var amount = 0; for (var i = 0; i < SpellModifiersFlat.Count; i++) { var modifier = SpellModifiersFlat[i]; if ((SpellModifierType)modifier.SpellEffect.MiscValue == type && modifier.SpellEffect.MatchesSpell(spell)) { amount += modifier.SpellEffect.ValueMin; } } return amount; }
/// <summary> /// Returns the modified value (modified by certain talents) of the given type for the given spell (as float) /// </summary> public override float GetModifiedFloat(SpellModifierType type, Spell spell, float value) { var flatMod = GetModifierFlat(type, spell); var percentMod = GetModifierPercent(type, spell); return (value + flatMod) * (1 + (percentMod / 100f)); }