Esempio n. 1
0
 public override void Update(long Tick)
 {
     if (!CombatInterface.IsFriend(Ab.Caster, Target))
     {
         Stop();
     }
 }
Esempio n. 2
0
        public override GameData.AbilityResult CanCast(bool IsStart)
        {
            GameData.AbilityResult Result = GameData.AbilityResult.ABILITYRESULT_OK;

            if (Target == null || !Target.IsPlayer()) //nonplayer Chars are illegal too
            {
                Result = GameData.AbilityResult.ABILITYRESULT_ILLEGALTARGET;
            }
            else if (Target.IsDead)
            {
                Result = GameData.AbilityResult.ABILITYRESULT_ILLEGALTARGET_DEAD;
            }
            else if (Ab.Caster.GetDistanceTo(Target) > Ab.Info.Info.MaxRange)
            {
                Result = GameData.AbilityResult.ABILITYRESULT_OUTOFRANGE;
            }
            else if (IsStart && Ab.Caster.GetDistanceTo(Target) < Ab.Info.Info.MinRange)
            {
                Result = GameData.AbilityResult.ABILITYRESULT_TOOCLOSE;
            }
            else if (IsStart && Ab.Info.Info.MinRange <= 5 && !Ab.Caster.IsObjectInFront(Target, 110))
            {
                Result = GameData.AbilityResult.ABILITYRESULT_OUT_OF_ARC;
            }
            else if (!CombatInterface.IsFriend(Ab.Caster.GetUnit(), Target))
            {
                Result = GameData.AbilityResult.ABILITYRESULT_ILLEGALTARGET_NOT_ALLY;
            }

            //Log.Info("SimpleHeal", Result.ToString());
            return(Result);
        }
Esempio n. 3
0
 public override void Start(Ability Ab)
 {
     if (!CombatInterface.IsFriend(Ab.Caster, Target))
     {
         Stop();
     }
 }
Esempio n. 4
0
        public override IAbilityTypeHandler Cast()
        {
            if (!CombatInterface.IsFriend(Ab.Caster, Target))
            {
                return(null);
            }

            //Log.Info("DealDamage", "Cast");

            uint Damage = GetAbilityDamage() / Ab.Info.GetTime(0);

            CallOnCast(this, Damage);
            Ab.Caster.DealHeal(Target, Ab, Damage);
            return(null);
        }
        /// <summary>
        /// Identifies target of an ability before it is casted and checks its validity (pvp flag, visibility...).
        /// </summary>
        /// <param name="abInfo">Ability that is about to be casted</param>
        /// <param name="instigator">Instigator of the ability</param>
        /// <param name="foeVisible">True if current targeted foe is visible</param>
        /// <param name="allyVisible">True if current targeted ally is visible</param>
        /// <returns>True if target is valid for the ability</returns>
        private bool GetTarget(AbilityInfo abInfo, Unit instigator, bool foeVisible, bool allyVisible)
        {
            if (_pendingInfo.Range == 0 || _pendingInfo.CommandInfo == null)
            {
                _pendingInfo.Target = _caster;
                return(true);
            }

            if (_pendingInfo.TargetType == CommandTargetTypes.SiegeCannon)
            {
                _pendingInfo.Target = ((Creature)_caster).SiegeInterface.BuildTargetList(instigator);
                return(true);
            }

            CommandTargetTypes selectType = (CommandTargetTypes)((int)_pendingInfo.TargetType & 7);

            switch (selectType)
            {
            case CommandTargetTypes.Caster:
                _pendingInfo.Target = _caster;
                break;

            case CommandTargetTypes.Ally:
                if (!allyVisible)
                {
                    return(false);
                }
                _pendingInfo.Target = _caster.CbtInterface.GetTarget(TargetTypes.TARGETTYPES_TARGET_ALLY);
                if (_pendingInfo.Target == _caster || !CombatInterface.IsFriend(_caster, _pendingInfo.Target) || (_pendingInfo.Target is Creature && !(_pendingInfo.Target is Pet)))
                {
                    return(false);
                }
                if (_pendingInfo.TargetType.HasFlag(CommandTargetTypes.Groupmates))
                {
                    Group myGroup = ((Player)_caster).PriorityGroup;
                    if (myGroup == null || !myGroup.HasMember(_pendingInfo.Target))
                    {
                        return(false);
                    }
                }
                break;

            case CommandTargetTypes.AllyOrSelf:
                if (!allyVisible)
                {
                    return(false);
                }
                _pendingInfo.Target = _caster.CbtInterface.GetTarget(TargetTypes.TARGETTYPES_TARGET_ALLY) ?? _caster;

                if (!CombatInterface.IsFriend(_caster, _pendingInfo.Target) || (_pendingInfo.Target is Creature && !(_pendingInfo.Target is Pet)))
                {
                    return(false);
                }
                if (_pendingInfo.Target != _caster)
                {
                    if (_pendingInfo.TargetType.HasFlag(CommandTargetTypes.Groupmates))
                    {
                        Group myGroup = ((Player)_caster).PriorityGroup;
                        if (myGroup == null || !myGroup.HasMember(_pendingInfo.Target))
                        {
                            return(false);
                        }
                    }
                }
                break;

            case CommandTargetTypes.AllyOrCareerTarget:
                if (!allyVisible)
                {
                    return(false);
                }
                _pendingInfo.Target = _caster.CbtInterface.GetTarget(TargetTypes.TARGETTYPES_TARGET_ALLY);

                if (!CombatInterface.IsFriend(_caster, _pendingInfo.Target) || _pendingInfo.Target != null && (_pendingInfo.Target is Creature && !(_pendingInfo.Target is Pet)))
                {
                    return(false);
                }
                if (_pendingInfo.Target != null && _pendingInfo.Target != _caster)
                {
                    if (_pendingInfo.TargetType.HasFlag(CommandTargetTypes.Groupmates))
                    {
                        Group myGroup = ((Player)_caster).PriorityGroup;
                        if (myGroup == null || !myGroup.HasMember(_pendingInfo.Target))
                        {
                            return(false);
                        }
                    }
                }
                else
                {
                    Player petCareerPlr = null;
                    if (_caster is Player)
                    {
                        petCareerPlr = _caster as Player;
                    }
                    if (petCareerPlr != null)
                    {
                        _pendingInfo.Target = petCareerPlr.CrrInterface.GetTargetOfInterest();
                    }

                    if (_pendingInfo.Target == null || _pendingInfo.Target == _caster)
                    {
                        _pendingInfo.Target = null;
                        return(false);
                    }
                }

                break;

            case CommandTargetTypes.Enemy:
                if (!foeVisible)
                {
                    return(false);
                }
                _pendingInfo.Target = _caster.CbtInterface.GetTarget(TargetTypes.TARGETTYPES_TARGET_ENEMY);
                if (!CombatInterface.CanAttack(_caster, _pendingInfo.Target))
                {
                    _pendingInfo.Target = null;
                }
                else
                {
                    if (!_caster.CbtInterface.IsPvp)
                    {
                        Player plrCaster = _caster as Player;
                        if (plrCaster != null && _pendingInfo.Target.CbtInterface.IsPvp)
                        {
                            ((CombatInterface_Player)plrCaster.CbtInterface).EnablePvp();
                        }
                    }
                }

                Player plrTarget = _pendingInfo.Target as Player;

                if (plrTarget != null && plrTarget.Palisade != null && (plrTarget.Palisade.IsObjectInFront(_caster, 180) ^ plrTarget.Palisade.IsObjectInFront(plrTarget, 180)))
                {
                    _pendingInfo.Target = plrTarget.Palisade;
                }

                //8410 - Terrible Embrace ; 9057 - Wings of Heaven ; 9178 - Fetch! ; 9186 - Pounce
                if (_pendingInfo.Target != null &&
                    (abInfo.Entry == 8410 || abInfo.Entry == 9057 || abInfo.Entry == 9178 || abInfo.Entry == 9186) &&
                    Math.Abs(_caster.Z - _pendingInfo.Target.Z) > 300)
                {
                    _caster.AbtInterface.SetCooldown(abInfo.Entry, -1);
                    return(false);
                }

                break;

            case CommandTargetTypes.CareerTarget:     // Target of Interest (oath friend/dark protector/pet if player, master if pet)
                var player = _caster as Player;
                if (player != null)
                {
                    _pendingInfo.Target = player.CrrInterface.GetTargetOfInterest();
                }
                else
                {
                    var pet = _caster as Pet;
                    if (pet != null)
                    {
                        _pendingInfo.Target = pet.Owner;
                    }
                    else
                    {
                        Log.Error("NewAbility", "Ability " + _pendingInfo.Entry + " with targettype 5 has no target!");
                        _pendingInfo.Target = null;
                    }
                }
                break;

            default:
                Log.Error("NewAbility", "Ability " + _pendingInfo.Entry + " with TargetType zero in 3 LSBs!");
                _pendingInfo.Target = _caster;
                break;
            }

            if (_pendingInfo.TargetType.HasFlag(CommandTargetTypes.Groupmates) && _pendingInfo.Target != _caster)
            {
                Group myGroup = ((Player)_caster).PriorityGroup;
                if (myGroup == null || !myGroup.HasMember(_pendingInfo.Target))
                {
                    return(false);
                }
            }

            return(_pendingInfo.Target != null);
        }