Example #1
0
        internal AmpFromMeEffectApplierWorker(
            IAbilityModifier modifier,
            bool updateWithLevel,
            Func <IAbilityModifier, double> valueGetter)
            : base(updateWithLevel)
        {
            this.Modifier                = modifier;
            this.ValueGetter             = valueGetter;
            this.ApplyEffectActionGetter = () =>
            {
                return(unit =>
                {
                    this.Value = this.ValueGetter.Invoke(this.Modifier);
                    unit.DamageManipulation.AmpFromMe.AddModifierValue(modifier, this.Value, true);
                });
            };
            this.RemoveEffectActionGetter =
                () => unit => { unit.DamageManipulation.AmpFromMe.RemoveModifierValue(modifier, this.Value); };

            this.UpdateEffectActionGetter = () =>
            {
                return(unit =>
                {
                    this.Value = this.ValueGetter.Invoke(this.Modifier);
                    unit.DamageManipulation.AmpFromMe.UpdateModifierValue(modifier, this.Value);
                });
            };
        }
Example #2
0
        internal MagicOnlyEffectApplierWorker(
            IAbilityModifier modifier,
            bool updateWithLevel,
            Func <IAbilityModifier, float> valueGetter)
            : base(updateWithLevel)
        {
            this.Modifier                = modifier;
            this.ValueGetter             = valueGetter;
            this.ApplyEffectActionGetter = () =>
            {
                return(unit =>
                {
                    this.Value = this.ValueGetter.Invoke(this.Modifier);
                    unit.DamageManipulation.MagicalDamageAbsorb.AddModifierValue(modifier, this.Value, true);
                });
            };
            this.RemoveEffectActionGetter =
                () => unit => { unit.DamageManipulation.MagicalDamageAbsorb.RemoveModifierValue(modifier, this.Value); };

            this.UpdateEffectActionGetter = () =>
            {
                return(unit =>
                {
                    this.Value = this.ValueGetter.Invoke(this.Modifier);
                    unit.DamageManipulation.MagicalDamageAbsorb.UpdateModifierValue(modifier, this.Value);
                });
            };
        }
Example #3
0
        public void UpdateSpecialModifierValue(IAbilityModifier modifier, Func <IAbilityUnit, float, double> newGetValue)
        {
            var valueHolder = this.specialModifierValues[modifier.ModifierHandle];

            valueHolder.GetSpecialValue = newGetValue;
            this.ValueChanged.Notify();
        }
Example #4
0
 internal ReduceOtherEffectApplierWorker(
     IAbilityModifier modifier,
     bool updateWithLevel,
     Func <IAbilityModifier, double> valueGetter)
     : base(updateWithLevel)
 {
     this.Modifier                = modifier;
     this.ValueGetter             = valueGetter;
     this.ApplyEffectActionGetter = () =>
     {
         return(unit =>
         {
             this.Value = this.ValueGetter.Invoke(this.Modifier);
             unit.DamageManipulation.ReduceOther += this.Value;
             unit.DamageManipulation.ReduceOtherMinusEvents.Add(
                 this.Modifier.ModifierHandle,
                 new Tuple <float, double>(this.Modifier.SourceModifier.DieTime, this.Value));
         });
     };
     this.RemoveEffectActionGetter = () => unit =>
     {
         unit.DamageManipulation.ReduceOtherMinusEvents.Remove(this.Modifier.ModifierHandle);
         unit.DamageManipulation.ReduceOther -= this.Value;
     };
 }
Example #5
0
 internal DamageBlockEffectApplierWorker(
     IAbilityModifier modifier,
     bool updateWithLevel,
     Func <IAbilityModifier, float> modifierValueGetter)
     : base(updateWithLevel)
 {
     this.Modifier                = modifier;
     this.ModifierValueGetter     = modifierValueGetter;
     this.ApplyEffectActionGetter = () =>
     {
         return(unit =>
         {
             this.Value = this.ModifierValueGetter.Invoke(this.Modifier);
             unit.DamageManipulation.AddDamageBlock(this.Modifier.ModifierHandle, this.Value);
         });
     };
     this.RemoveEffectActionGetter =
         () => unit => { unit.DamageManipulation.RemoveDamageBlock(this.Modifier.ModifierHandle); };
     this.UpdateEffectActionGetter = () =>
     {
         return(unit =>
         {
             this.Value = this.ModifierValueGetter.Invoke(this.Modifier);
             unit.DamageManipulation.UpdateDamageBlock(this.Modifier.ModifierHandle, this.Value);
         });
     };
 }
Example #6
0
 internal DamageShieldEffectApplierWorker(
     IAbilityModifier modifier,
     bool updateWithLevel,
     bool magical,
     bool physical,
     bool pure)
     : base(updateWithLevel)
 {
     this.Modifier = modifier;
     this.ApplyEffectActionGetter =
         () =>
     {
         return
             (unit =>
         {
             unit.DamageManipulation.AddDamageShield(
                 this.Modifier.ModifierHandle,
                 magical,
                 physical,
                 pure);
         });
     };
     this.RemoveEffectActionGetter =
         () =>
         unit =>
     {
         unit.DamageManipulation.RemoveDamageShield(
             this.Modifier.ModifierHandle,
             magical,
             physical,
             pure);
     };
 }
Example #7
0
 public void AddModifierValue(IAbilityModifier modifier, double value, bool willExpire = false)
 {
     this.modifierValues.Add(
         modifier.ModifierHandle,
         new ValueHolder <double>(value, willExpire, () => modifier.SourceModifier.DieTime));
     this.value += value;
     this.ValueChanged.Notify();
 }
Example #8
0
        public void UpdateModifierValue(IAbilityModifier modifier, double newValue)
        {
            var valueHolder = this.modifierValues[modifier.ModifierHandle];

            this.value       -= valueHolder.Value;
            valueHolder.Value = newValue;
            this.value       += newValue;
            this.ValueChanged.Notify();
        }
Example #9
0
 public void AddSpecialModifierValue(
     IAbilityModifier modifier,
     Func <IAbilityUnit, float, double> getValue,
     bool willExpire = false)
 {
     this.specialModifierValues.Add(
         modifier.ModifierHandle,
         new ValueHolder <double>(getValue, willExpire, () => modifier.SourceModifier.DieTime));
     this.specialModifierValuesAny = true;
     this.ValueChanged.Notify();
 }
Example #10
0
        public void Compose(IAbilityModifier modifier)
        {
            foreach (var keyValuePair in this.Assignments)
            {
                keyValuePair.Value.Invoke(modifier);
            }

            foreach (var keyValuePair in modifier.Parts)
            {
                keyValuePair.Value.Initialize();
            }
        }
Example #11
0
 internal ManaShieldEffectApplierWorker(
     IAbilityModifier modifier,
     bool updateWithLevel,
     Func <IAbilityModifier, double> valueGetter)
     : base(updateWithLevel)
 {
     this.Modifier                = modifier;
     this.ValueGetter             = valueGetter;
     this.ApplyEffectActionGetter = () =>
     {
         return(unit =>
         {
             this.Value = this.ValueGetter.Invoke(this.Modifier);
             unit.DamageManipulation.ManaShield.AddSpecialModifierValue(
                 modifier,
                 (unit1, damageValue) =>
             {
                 if (modifier.AffectedUnit.Mana.Current >= damageValue * .6 / this.Value)
                 {
                     return 0.6;
                 }
                 else
                 {
                     return modifier.AffectedUnit.Mana.Current * this.Value / damageValue;
                 }
             });
         });
     };
     this.RemoveEffectActionGetter =
         () => unit => { unit.DamageManipulation.ManaShield.RemoveSpecialModifierValue(modifier); };
     this.UpdateEffectActionGetter = () =>
     {
         return(unit =>
         {
             this.Value = this.ValueGetter.Invoke(this.Modifier);
             unit.DamageManipulation.ManaShield.UpdateSpecialModifierValue(
                 modifier,
                 (unit1, damageValue) =>
             {
                 if (modifier.AffectedUnit.Mana.Current >= damageValue * .6 / this.Value)
                 {
                     return 0.6;
                 }
                 else
                 {
                     return modifier.AffectedUnit.Mana.Current * this.Value / damageValue;
                 }
             });
         });
     };
 }
Example #12
0
        public IceBlastModifierEffectApplier(IAbilityModifier modifier)
            : base(modifier)
        {
            var value  = 0d;
            var worker = new EffectApplierWorker(
                true,
                () =>
            {
                return(unit =>
                {
                    value = modifier.SourceSkill.SourceAbility.GetAbilityData("kill_pct") / 100;
                    unit.DamageManipulation.Aa = new ValueHolder <float>(
                        (abilityUnit, f) =>
                    {
                        var percent = modifier.AffectedUnit.Health.Maximum * value;
                        if (modifier.AffectedUnit.Health.Current - f <= percent)
                        {
                            return (float)percent;
                        }

                        return 0;
                    },
                        true,
                        () => modifier.SourceModifier.DieTime);
                });
            },
                () => unit => unit.DamageManipulation.Aa = null,
                () =>
            {
                return(unit =>
                {
                    value = modifier.SourceSkill.SourceAbility.GetAbilityData("kill_pct") / 100;
                    unit.DamageManipulation.Aa = new ValueHolder <float>(
                        (abilityUnit, f) =>
                    {
                        var percent = modifier.AffectedUnit.Health.Maximum * value;
                        if (modifier.AffectedUnit.Health.Current - f <= percent)
                        {
                            return (float)percent;
                        }

                        return 0;
                    },
                        true,
                        () => modifier.SourceModifier.DieTime);
                });
            });

            this.Workers.Add(worker);
        }
Example #13
0
        public virtual bool TryGenerateModifier(IAbilityModifier modifier)
        {
            var isEnemy = modifier.AffectedUnit.Team != this.Skill.Owner.Team;

            foreach (var modifierGeneratorWorker in this.Workers)
            {
                if ((!isEnemy && modifierGeneratorWorker.AffectsAllies ||
                     isEnemy && modifierGeneratorWorker.AffectsEnemies || modifierGeneratorWorker.AffectsEveryone ||
                     !modifier.AffectedUnit.UnitHandle.Equals(this.Skill.Owner.UnitHandle) &&
                     modifierGeneratorWorker.AffectsSelf || modifierGeneratorWorker.AffectsSelf) &&
                    modifierGeneratorWorker.ModifierName.Equals(modifier.Name))
                {
                    modifier.SourceSkill = this.Skill;
                    modifierGeneratorWorker.GenerateModifier(modifier);
                    return(true);
                }
            }

            return(false);
        }
Example #14
0
        internal DamageNegationEffectApplierWorker(
            IAbilityModifier modifier,
            bool updateWithLevel,
            Func <IAbilityModifier, double> valueGetter)
            : base(updateWithLevel)
        {
            this.Modifier                = modifier;
            this.ValueGetter             = valueGetter;
            this.ApplyEffectActionGetter = () =>
            {
                return(unit =>
                {
                    this.Value = this.ValueGetter.Invoke(this.Modifier);
                    unit.DamageManipulation.DamageNegation.AddModifierValue(modifier, this.Value, true);

                    // unit.DamageManipulation.DamageNegationMinusEvents.Add(
                    // this.Modifier.ModifierHandle,
                    // new Tuple<float, float>(this.Modifier.SourceModifier.DieTime, this.Value));
                });
            };
            this.RemoveEffectActionGetter = () => unit =>
            {
                // unit.DamageManipulation.DamageNegationMinusEvents.Remove(this.Modifier.ModifierHandle);
                unit.DamageManipulation.DamageNegation.RemoveModifierValue(modifier, this.Value);
            };
            this.UpdateEffectActionGetter = () =>
            {
                return(unit =>
                {
                    this.Value = this.ValueGetter.Invoke(this.Modifier);
                    unit.DamageManipulation.DamageNegation.UpdateModifierValue(modifier, this.Value);

                    // unit.DamageManipulation.DamageNegationMinusEvents.Add(
                    // this.Modifier.ModifierHandle,
                    // new Tuple<float, float>(this.Modifier.SourceModifier.DieTime, this.Value));
                });
            };
        }
Example #15
0
        public FleshGolemModifierEffectApplier(IAbilityModifier modifier)
            : base(modifier)
        {
            var worker = new EffectApplierWorker(
                false,
                () =>
            {
                return(unit =>
                {
                    Console.WriteLine("applying undying");
                    unit.DamageManipulation.DamageAmplification.AddSpecialModifierValue(
                        modifier,
                        (abilityUnit, f) =>
                    {
                        var baseAmp = .05 * modifier.SourceSkill.Level.Current;
                        var distance =
                            modifier.SourceSkill.Owner.Position.Current.Distance2D(
                                modifier.AffectedUnit.Position.Current);
                        if (distance <= 200)
                        {
                            return baseAmp + 0.15;
                        }
                        else if (distance > 750)
                        {
                            return 0.1;
                        }
                        else
                        {
                            return baseAmp + (750 - distance) * 0.03 / 110;
                        }
                    });
                });
            },
                () => unit => { unit.DamageManipulation.DamageAmplification.RemoveSpecialModifierValue(modifier); },
                null);

            this.Workers.Add(worker);
        }
Example #16
0
 public ModifierEffectApplier(IAbilityModifier modifier)
 {
     this.Modifier = modifier;
 }
Example #17
0
 public void RemoveSpecialModifierValue(IAbilityModifier modifier)
 {
     this.specialModifierValues.Remove(modifier.ModifierHandle);
     this.specialModifierValuesAny = this.specialModifierValues.Any();
     this.ValueChanged.Notify();
 }
Example #18
0
 public bool ModifierRemoved(IAbilityModifier modifier)
 {
     throw new NotImplementedException();
 }
Example #19
0
 public bool ModifierAdded(IAbilityModifier modifier)
 {
     return(this.ModifierAddedChecks.AnyFunctionPasses(modifier));
 }
Example #20
0
        public BloodrageModifierEffectApplier(IAbilityModifier modifier)
            : base(modifier)
        {
            this.ampApplier = new EffectApplierWorker(
                true,
                () =>
            {
                return(unit =>
                {
                    this.realValue =
                        Math.Floor(
                            this.Modifier.SourceSkill.SourceAbility.GetAbilityData("damage_increase_pct"))
                        / 100;
                    this.value = this.realValue;
                    unit.DamageManipulation.DamageAmplification.AddSpecialModifierValue(
                        modifier,
                        (abilityUnit, damageValue) =>
                    {
                        if (
                            modifier.AffectedUnit.Position.Current.Distance2D(
                                abilityUnit.Position.Current) < 2200)
                        {
                            return this.value;
                        }
                        else
                        {
                            return this.value / 2;
                        }
                    },
                        true);
                    unit.DamageManipulation.AmpFromMe.AddSpecialModifierValue(
                        modifier,
                        (abilityUnit, damageValue) =>
                    {
                        if (
                            modifier.AffectedUnit.Position.Current.Distance2D(
                                abilityUnit.Position.Current) < 2200)
                        {
                            return this.value;
                        }
                        else
                        {
                            return this.value / 2;
                        }
                    },
                        true);
                });
            },
                () =>
            {
                return(unit =>
                {
                    unit.DamageManipulation.DamageAmplification.RemoveSpecialModifierValue(modifier);
                    unit.DamageManipulation.AmpFromMe.RemoveSpecialModifierValue(modifier);
                });
            },
                () =>
            {
                return(unit =>
                {
                    this.realValue =
                        Math.Floor(
                            this.Modifier.SourceSkill.SourceAbility.GetAbilityData("damage_increase_pct"))
                        / 100;
                    this.value = this.realValue;
                    unit.DamageManipulation.DamageAmplification.UpdateSpecialModifierValue(
                        modifier,
                        (abilityUnit, damageValue) =>
                    {
                        if (
                            modifier.AffectedUnit.Position.Current.Distance2D(
                                abilityUnit.Position.Current) < 2200)
                        {
                            return this.value;
                        }
                        else
                        {
                            return this.value / 2;
                        }
                    });
                    unit.DamageManipulation.AmpFromMe.UpdateSpecialModifierValue(
                        modifier,
                        (abilityUnit, damageValue) =>
                    {
                        if (
                            modifier.AffectedUnit.Position.Current.Distance2D(
                                abilityUnit.Position.Current) < 2200)
                        {
                            return this.value;
                        }
                        else
                        {
                            return this.value / 2;
                        }
                    });
                });
            });

            this.Workers.Add(this.ampApplier);
        }
Example #21
0
 public void RemoveModifierValue(IAbilityModifier modifier, double value)
 {
     this.modifierValues.Remove(modifier.ModifierHandle);
     this.value -= value;
     this.ValueChanged.Notify();
 }