Example #1
0
        private void CreateCriteria()
        {
            Criteria += unit =>
            {
                if (unit == null)
                {
                    Logger.DBLog.DebugFormat("[Funky] Recieved null CacheUnit value in skill criteria evaluation");
                    return(true);
                }

                return(true);
            };
            //Distance
            if (MaximumDistance > -1)
            {
                Criteria += (unit) => unit.TargetInfo.RadiusDistance <= MaximumDistance;
            }
            if (MinimumDistance > -1)
            {
                Criteria += (unit) => unit.TargetInfo.RadiusDistance >= MinimumDistance;
            }

            //Health
            if (HealthPercent > 0d)
            {
                Criteria += (unit) => unit.CurrentHealthPct.HasValue && unit.CurrentHealthPct.Value <= HealthPercent;
            }


            //TRUE CONDITIONS
            if (TrueConditionFlags.Equals(TargetProperties.None))
            {
                Criteria += (unit) => true;
            }
            else
            {
                if (ObjectCache.CheckFlag(TrueConditionFlags, TargetProperties.Boss))
                {
                    Criteria += (unit) => unit.IsBoss;
                }
                if (ObjectCache.CheckFlag(TrueConditionFlags, TargetProperties.Burrowing))
                {
                    Criteria += (unit) => unit.IsBurrowableUnit;
                }
                if (ObjectCache.CheckFlag(TrueConditionFlags, TargetProperties.FullHealth))
                {
                    Criteria += (unit) => unit.CurrentHealthPct.HasValue &&
                                unit.CurrentHealthPct.Value == 1d;
                }

                if (ObjectCache.CheckFlag(TrueConditionFlags, TargetProperties.Weak))
                {
                    Criteria += (unit) => unit.UnitMaxHitPointAverageWeight < 0;
                }
                if (ObjectCache.CheckFlag(TrueConditionFlags, TargetProperties.MissileDampening))
                {
                    Criteria += (unit) => unit.MonsterMissileDampening;
                }
                if (ObjectCache.CheckFlag(TrueConditionFlags, TargetProperties.RareElite))
                {
                    Criteria += (unit) => unit.IsEliteRareUnique;
                }
                if (ObjectCache.CheckFlag(TrueConditionFlags, TargetProperties.MissileReflecting))
                {
                    Criteria += (unit) => unit.IsMissileReflecting && unit.AnimState == AnimationState.Transform;
                }
                if (ObjectCache.CheckFlag(TrueConditionFlags, TargetProperties.Shielding))
                {
                    Criteria += (unit) => unit.MonsterShielding;
                }
                if (ObjectCache.CheckFlag(TrueConditionFlags, TargetProperties.Stealthable))
                {
                    Criteria += (unit) => unit.IsStealthableUnit;
                }
                if (ObjectCache.CheckFlag(TrueConditionFlags, TargetProperties.SucideBomber))
                {
                    Criteria += (unit) => unit.IsSucideBomber;
                }
                if (ObjectCache.CheckFlag(TrueConditionFlags, TargetProperties.TreasureGoblin))
                {
                    Criteria += (unit) => unit.IsTreasureGoblin;
                }
                if (ObjectCache.CheckFlag(TrueConditionFlags, TargetProperties.Unique))
                {
                    Criteria += (unit) => unit.MonsterUnique;
                }
                if (ObjectCache.CheckFlag(TrueConditionFlags, TargetProperties.Ranged))
                {
                    Criteria += (unit) => unit.IsRanged;
                }
                if (ObjectCache.CheckFlag(TrueConditionFlags, TargetProperties.TargetableAndAttackable))
                {
                    Criteria += (unit) => unit.IsTargetableAndAttackable;
                }
                if (ObjectCache.CheckFlag(TrueConditionFlags, TargetProperties.Fast))
                {
                    Criteria += (unit) => unit.IsFast;
                }
                if (ObjectCache.CheckFlag(TrueConditionFlags, TargetProperties.DOTDPS))
                {
                    Criteria += (unit) => unit.HasDOTdps.HasValue && unit.HasDOTdps.Value;
                }
                if (ObjectCache.CheckFlag(TrueConditionFlags, TargetProperties.CloseDistance))
                {
                    Criteria += (unit) => unit.TargetInfo.RadiusDistance < 10f;
                }
                if (ObjectCache.CheckFlag(TrueConditionFlags, TargetProperties.ReflectsDamage))
                {
                    Criteria += (unit) => unit.MonsterReflectDamage;
                }
                if (ObjectCache.CheckFlag(TrueConditionFlags, TargetProperties.Electrified))
                {
                    Criteria += (unit) => unit.MonsterElectrified;
                }
                if (ObjectCache.CheckFlag(TrueConditionFlags, TargetProperties.Normal))
                {
                    Criteria += (unit) => unit.MonsterNormal;
                }
                if (ObjectCache.CheckFlag(TrueConditionFlags, TargetProperties.LowHealth))
                {
                    Criteria += (unit) => unit.CurrentHealthPct.HasValue && unit.CurrentHealthPct.Value < 0.25d;
                }


                if (ObjectCache.CheckFlag(TrueConditionFlags, TargetProperties.Flying))
                {
                    Criteria +=
                        (unit) =>
                        unit.UnitPropertyFlags.HasValue &&
                        ObjectCache.CheckFlag(unit.UnitPropertyFlags.Value, UnitFlags.Flying);
                }

                if (ObjectCache.CheckFlag(TrueConditionFlags, TargetProperties.Summoner))
                {
                    Criteria +=
                        (unit) =>
                        unit.UnitPropertyFlags.HasValue &&
                        ObjectCache.CheckFlag(unit.UnitPropertyFlags.Value, UnitFlags.Summoner);
                }

                if (ObjectCache.CheckFlag(TrueConditionFlags, TargetProperties.AvoidanceSummoner))
                {
                    Criteria +=
                        (unit) =>
                        unit.UnitPropertyFlags.HasValue &&
                        ObjectCache.CheckFlag(unit.UnitPropertyFlags.Value, UnitFlags.AvoidanceSummoner);
                }

                if (ObjectCache.CheckFlag(TrueConditionFlags, TargetProperties.Debuffing))
                {
                    Criteria +=
                        (unit) =>
                        unit.UnitPropertyFlags.HasValue &&
                        ObjectCache.CheckFlag(unit.UnitPropertyFlags.Value, UnitFlags.Debuffing);
                }
            }

            //FALSE CONDITIONS
            if (FalseConditionFlags.Equals(TargetProperties.None))
            {
                Criteria += (unit) => true;
            }
            else
            {
                if (ObjectCache.CheckFlag(FalseConditionFlags, TargetProperties.Boss))
                {
                    Criteria += (unit) => !unit.IsBoss;
                }
                if (ObjectCache.CheckFlag(FalseConditionFlags, TargetProperties.Burrowing))
                {
                    Criteria += (unit) => !unit.IsBurrowableUnit;
                }

                if (ObjectCache.CheckFlag(FalseConditionFlags, TargetProperties.FullHealth))
                {
                    Criteria += (unit) => unit.CurrentHealthPct.HasValue &&
                                unit.CurrentHealthPct.Value < 1d;
                }

                if (ObjectCache.CheckFlag(FalseConditionFlags, TargetProperties.Weak))
                {
                    Criteria += (unit) => unit.UnitMaxHitPointAverageWeight > 0;
                }
                if (ObjectCache.CheckFlag(FalseConditionFlags, TargetProperties.MissileDampening))
                {
                    Criteria += (unit) => !unit.MonsterMissileDampening;
                }
                if (ObjectCache.CheckFlag(FalseConditionFlags, TargetProperties.RareElite))
                {
                    Criteria += (unit) => !unit.IsEliteRareUnique;
                }
                if (ObjectCache.CheckFlag(FalseConditionFlags, TargetProperties.MissileReflecting))
                {
                    Criteria += (unit) => !unit.IsMissileReflecting || unit.AnimState != AnimationState.Transform;
                }
                if (ObjectCache.CheckFlag(FalseConditionFlags, TargetProperties.Shielding))
                {
                    Criteria += (unit) => !unit.MonsterShielding;
                }
                if (ObjectCache.CheckFlag(FalseConditionFlags, TargetProperties.Stealthable))
                {
                    Criteria += (unit) => !unit.IsStealthableUnit;
                }
                if (ObjectCache.CheckFlag(FalseConditionFlags, TargetProperties.SucideBomber))
                {
                    Criteria += (unit) => !unit.IsSucideBomber;
                }
                if (ObjectCache.CheckFlag(FalseConditionFlags, TargetProperties.TreasureGoblin))
                {
                    Criteria += (unit) => !unit.IsTreasureGoblin;
                }
                if (ObjectCache.CheckFlag(FalseConditionFlags, TargetProperties.Unique))
                {
                    Criteria += (unit) => !unit.MonsterUnique;
                }
                if (ObjectCache.CheckFlag(FalseConditionFlags, TargetProperties.Ranged))
                {
                    Criteria += (unit) => !unit.IsRanged;
                }
                if (ObjectCache.CheckFlag(FalseConditionFlags, TargetProperties.TargetableAndAttackable))
                {
                    Criteria += (unit) => !unit.IsTargetableAndAttackable;
                }
                if (ObjectCache.CheckFlag(FalseConditionFlags, TargetProperties.Fast))
                {
                    Criteria += (unit) => !unit.IsFast;
                }
                if (ObjectCache.CheckFlag(FalseConditionFlags, TargetProperties.DOTDPS))
                {
                    Criteria += (unit) => !unit.HasDOTdps.HasValue || !unit.HasDOTdps.Value;
                }
                if (ObjectCache.CheckFlag(FalseConditionFlags, TargetProperties.CloseDistance))
                {
                    Criteria += (unit) => unit.TargetInfo.RadiusDistance > 10f;
                }
                if (ObjectCache.CheckFlag(FalseConditionFlags, TargetProperties.ReflectsDamage))
                {
                    Criteria += (unit) => !unit.MonsterReflectDamage;
                }
                if (ObjectCache.CheckFlag(FalseConditionFlags, TargetProperties.Electrified))
                {
                    Criteria += (unit) => !unit.MonsterElectrified;
                }
                if (ObjectCache.CheckFlag(FalseConditionFlags, TargetProperties.Normal))
                {
                    Criteria += (unit) => !unit.MonsterNormal;
                }
                if (ObjectCache.CheckFlag(FalseConditionFlags, TargetProperties.LowHealth))
                {
                    Criteria += (unit) => !unit.CurrentHealthPct.HasValue || unit.CurrentHealthPct.Value >= 0.25d;
                }


                if (ObjectCache.CheckFlag(FalseConditionFlags, TargetProperties.Flying))
                {
                    Criteria +=
                        (unit) =>
                        unit.UnitPropertyFlags.HasValue &&
                        !ObjectCache.CheckFlag(unit.UnitPropertyFlags.Value, UnitFlags.Flying);
                }

                if (ObjectCache.CheckFlag(FalseConditionFlags, TargetProperties.Summoner))
                {
                    Criteria +=
                        (unit) =>
                        unit.UnitPropertyFlags.HasValue &&
                        !ObjectCache.CheckFlag(unit.UnitPropertyFlags.Value, UnitFlags.Summoner);
                }

                if (ObjectCache.CheckFlag(FalseConditionFlags, TargetProperties.AvoidanceSummoner))
                {
                    Criteria +=
                        (unit) =>
                        unit.UnitPropertyFlags.HasValue &&
                        !ObjectCache.CheckFlag(unit.UnitPropertyFlags.Value, UnitFlags.AvoidanceSummoner);
                }

                if (ObjectCache.CheckFlag(FalseConditionFlags, TargetProperties.Debuffing))
                {
                    Criteria +=
                        (unit) =>
                        unit.UnitPropertyFlags.HasValue &&
                        !ObjectCache.CheckFlag(unit.UnitPropertyFlags.Value, UnitFlags.Debuffing);
                }
            }
        }
Example #2
0
        private void CreateCriteria()
        {
            //Distance
            if (Distance > -1)
            {
                Criteria += () => Bot.Targeting.Cache.CurrentTarget.RadiusDistance <= Distance;
            }
            //Health
            if (HealthPercent > 0d)
            {
                Criteria += () => Bot.Targeting.Cache.CurrentUnitTarget.CurrentHealthPct.Value <= HealthPercent;
            }


            //TRUE CONDITIONS
            if (TrueConditionFlags.Equals(TargetProperties.None))
            {
                Criteria += () => true;
            }
            else
            {
                if (AbilityLogicConditions.CheckTargetPropertyFlag(TrueConditionFlags, TargetProperties.Boss))
                {
                    Criteria += () => Bot.Targeting.Cache.CurrentTarget.IsBoss;
                }
                if (AbilityLogicConditions.CheckTargetPropertyFlag(TrueConditionFlags, TargetProperties.Burrowing))
                {
                    Criteria += () => Bot.Targeting.Cache.CurrentTarget.IsBurrowableUnit;
                }
                if (AbilityLogicConditions.CheckTargetPropertyFlag(TrueConditionFlags, TargetProperties.FullHealth))
                {
                    Criteria += () => Bot.Targeting.Cache.CurrentUnitTarget.CurrentHealthPct.Value == 1d;
                }
                if (AbilityLogicConditions.CheckTargetPropertyFlag(TrueConditionFlags, TargetProperties.IsSpecial))
                {
                    Criteria += () => Bot.Targeting.Cache.CurrentTarget.ObjectIsSpecial;
                }
                if (AbilityLogicConditions.CheckTargetPropertyFlag(TrueConditionFlags, TargetProperties.Weak))
                {
                    Criteria += () => Bot.Targeting.Cache.CurrentUnitTarget.UnitMaxHitPointAverageWeight < 0;
                }
                if (AbilityLogicConditions.CheckTargetPropertyFlag(TrueConditionFlags, TargetProperties.MissileDampening))
                {
                    Criteria += () => Bot.Targeting.Cache.CurrentUnitTarget.MonsterMissileDampening;
                }
                if (AbilityLogicConditions.CheckTargetPropertyFlag(TrueConditionFlags, TargetProperties.RareElite))
                {
                    Criteria += () => Bot.Targeting.Cache.CurrentUnitTarget.IsEliteRareUnique;
                }
                if (AbilityLogicConditions.CheckTargetPropertyFlag(TrueConditionFlags, TargetProperties.MissileReflecting))
                {
                    Criteria += () => Bot.Targeting.Cache.CurrentTarget.IsMissileReflecting && Bot.Targeting.Cache.CurrentTarget.AnimState == AnimationState.Transform;
                }
                if (AbilityLogicConditions.CheckTargetPropertyFlag(TrueConditionFlags, TargetProperties.Shielding))
                {
                    Criteria += () => Bot.Targeting.Cache.CurrentUnitTarget.MonsterShielding;
                }
                if (AbilityLogicConditions.CheckTargetPropertyFlag(TrueConditionFlags, TargetProperties.Stealthable))
                {
                    Criteria += () => Bot.Targeting.Cache.CurrentTarget.IsStealthableUnit;
                }
                if (AbilityLogicConditions.CheckTargetPropertyFlag(TrueConditionFlags, TargetProperties.SucideBomber))
                {
                    Criteria += () => Bot.Targeting.Cache.CurrentTarget.IsSucideBomber;
                }
                if (AbilityLogicConditions.CheckTargetPropertyFlag(TrueConditionFlags, TargetProperties.TreasureGoblin))
                {
                    Criteria += () => Bot.Targeting.Cache.CurrentTarget.IsTreasureGoblin;
                }
                if (AbilityLogicConditions.CheckTargetPropertyFlag(TrueConditionFlags, TargetProperties.Unique))
                {
                    Criteria += () => Bot.Targeting.Cache.CurrentUnitTarget.MonsterUnique;
                }
                if (AbilityLogicConditions.CheckTargetPropertyFlag(TrueConditionFlags, TargetProperties.Ranged))
                {
                    Criteria += () => Bot.Targeting.Cache.CurrentUnitTarget.IsRanged;
                }
                if (AbilityLogicConditions.CheckTargetPropertyFlag(TrueConditionFlags, TargetProperties.TargetableAndAttackable))
                {
                    Criteria += () => Bot.Targeting.Cache.CurrentUnitTarget.IsTargetableAndAttackable;
                }
                if (AbilityLogicConditions.CheckTargetPropertyFlag(TrueConditionFlags, TargetProperties.Fast))
                {
                    Criteria += () => Bot.Targeting.Cache.CurrentUnitTarget.IsFast;
                }
                if (AbilityLogicConditions.CheckTargetPropertyFlag(TrueConditionFlags, TargetProperties.DOTDPS))
                {
                    Criteria += () => Bot.Targeting.Cache.CurrentUnitTarget.HasDOTdps.HasValue && Bot.Targeting.Cache.CurrentUnitTarget.HasDOTdps.Value;
                }
                if (AbilityLogicConditions.CheckTargetPropertyFlag(TrueConditionFlags, TargetProperties.CloseDistance))
                {
                    Criteria += () => Bot.Targeting.Cache.CurrentTarget.RadiusDistance < 10f;
                }
                if (AbilityLogicConditions.CheckTargetPropertyFlag(TrueConditionFlags, TargetProperties.ReflectsDamage))
                {
                    Criteria += () => Bot.Targeting.Cache.CurrentUnitTarget.MonsterReflectDamage;
                }
                if (AbilityLogicConditions.CheckTargetPropertyFlag(TrueConditionFlags, TargetProperties.Electrified))
                {
                    Criteria += () => Bot.Targeting.Cache.CurrentUnitTarget.MonsterElectrified;
                }
                if (AbilityLogicConditions.CheckTargetPropertyFlag(TrueConditionFlags, TargetProperties.Normal))
                {
                    Criteria += () => Bot.Targeting.Cache.CurrentUnitTarget.MonsterNormal;
                }
            }

            //FALSE CONDITIONS
            if (FalseConditionFlags.Equals(TargetProperties.None))
            {
                Criteria += () => true;
            }
            else
            {
                if (AbilityLogicConditions.CheckTargetPropertyFlag(FalseConditionFlags, TargetProperties.Boss))
                {
                    Criteria += () => !Bot.Targeting.Cache.CurrentTarget.IsBoss;
                }
                if (AbilityLogicConditions.CheckTargetPropertyFlag(FalseConditionFlags, TargetProperties.Burrowing))
                {
                    Criteria += () => !Bot.Targeting.Cache.CurrentTarget.IsBurrowableUnit;
                }
                if (AbilityLogicConditions.CheckTargetPropertyFlag(FalseConditionFlags, TargetProperties.FullHealth))
                {
                    Criteria += () => Bot.Targeting.Cache.CurrentUnitTarget.CurrentHealthPct.Value != 1d;
                }
                if (AbilityLogicConditions.CheckTargetPropertyFlag(FalseConditionFlags, TargetProperties.IsSpecial))
                {
                    Criteria += () => !Bot.Targeting.Cache.CurrentTarget.ObjectIsSpecial;
                }
                if (AbilityLogicConditions.CheckTargetPropertyFlag(FalseConditionFlags, TargetProperties.Weak))
                {
                    Criteria += () => Bot.Targeting.Cache.CurrentUnitTarget.UnitMaxHitPointAverageWeight > 0;
                }
                if (AbilityLogicConditions.CheckTargetPropertyFlag(FalseConditionFlags, TargetProperties.MissileDampening))
                {
                    Criteria += () => !Bot.Targeting.Cache.CurrentUnitTarget.MonsterMissileDampening;
                }
                if (AbilityLogicConditions.CheckTargetPropertyFlag(FalseConditionFlags, TargetProperties.RareElite))
                {
                    Criteria += () => !Bot.Targeting.Cache.CurrentUnitTarget.IsEliteRareUnique;
                }
                if (AbilityLogicConditions.CheckTargetPropertyFlag(FalseConditionFlags, TargetProperties.MissileReflecting))
                {
                    Criteria += () => !Bot.Targeting.Cache.CurrentTarget.IsMissileReflecting || Bot.Targeting.Cache.CurrentTarget.AnimState != AnimationState.Transform;
                }
                if (AbilityLogicConditions.CheckTargetPropertyFlag(FalseConditionFlags, TargetProperties.Shielding))
                {
                    Criteria += () => !Bot.Targeting.Cache.CurrentUnitTarget.MonsterShielding;
                }
                if (AbilityLogicConditions.CheckTargetPropertyFlag(FalseConditionFlags, TargetProperties.Stealthable))
                {
                    Criteria += () => !Bot.Targeting.Cache.CurrentTarget.IsStealthableUnit;
                }
                if (AbilityLogicConditions.CheckTargetPropertyFlag(FalseConditionFlags, TargetProperties.SucideBomber))
                {
                    Criteria += () => !Bot.Targeting.Cache.CurrentTarget.IsSucideBomber;
                }
                if (AbilityLogicConditions.CheckTargetPropertyFlag(FalseConditionFlags, TargetProperties.TreasureGoblin))
                {
                    Criteria += () => !Bot.Targeting.Cache.CurrentTarget.IsTreasureGoblin;
                }
                if (AbilityLogicConditions.CheckTargetPropertyFlag(FalseConditionFlags, TargetProperties.Unique))
                {
                    Criteria += () => !Bot.Targeting.Cache.CurrentUnitTarget.MonsterUnique;
                }
                if (AbilityLogicConditions.CheckTargetPropertyFlag(FalseConditionFlags, TargetProperties.Ranged))
                {
                    Criteria += () => !Bot.Targeting.Cache.CurrentUnitTarget.IsRanged;
                }
                if (AbilityLogicConditions.CheckTargetPropertyFlag(FalseConditionFlags, TargetProperties.TargetableAndAttackable))
                {
                    Criteria += () => !Bot.Targeting.Cache.CurrentUnitTarget.IsTargetableAndAttackable;
                }
                if (AbilityLogicConditions.CheckTargetPropertyFlag(FalseConditionFlags, TargetProperties.Fast))
                {
                    Criteria += () => !Bot.Targeting.Cache.CurrentUnitTarget.IsFast;
                }
                if (AbilityLogicConditions.CheckTargetPropertyFlag(FalseConditionFlags, TargetProperties.DOTDPS))
                {
                    Criteria += () => !Bot.Targeting.Cache.CurrentUnitTarget.HasDOTdps.HasValue || !Bot.Targeting.Cache.CurrentUnitTarget.HasDOTdps.Value;
                }
                if (AbilityLogicConditions.CheckTargetPropertyFlag(FalseConditionFlags, TargetProperties.CloseDistance))
                {
                    Criteria += () => Bot.Targeting.Cache.CurrentTarget.RadiusDistance > 10f;
                }
                if (AbilityLogicConditions.CheckTargetPropertyFlag(FalseConditionFlags, TargetProperties.ReflectsDamage))
                {
                    Criteria += () => !Bot.Targeting.Cache.CurrentUnitTarget.MonsterReflectDamage;
                }
                if (AbilityLogicConditions.CheckTargetPropertyFlag(FalseConditionFlags, TargetProperties.Electrified))
                {
                    Criteria += () => !Bot.Targeting.Cache.CurrentUnitTarget.MonsterElectrified;
                }
                if (AbilityLogicConditions.CheckTargetPropertyFlag(FalseConditionFlags, TargetProperties.Normal))
                {
                    Criteria += () => !Bot.Targeting.Cache.CurrentUnitTarget.MonsterNormal;
                }
            }
        }