Example #1
0
        public override bool Trigger(Character target, float distSqr)
        {
            ActiveSkill jump = (ActiveSkill)ai.GetSkillWithTrait(SkillTraits.Jump);

            if (jump != null && jump.CanUse() && !ai.Owner.GetData().forcedVelocity)
            {
                Vector3 ownerPos  = ai.Owner.GetData().GetBody().transform.position;
                Vector3 targetPos = target.GetData().GetBody().transform.position;

                if (distSqr > (minRangeToJump * minRangeToJump))
                {
                    Vector3 nextTarget = Utils.GeneratePerpendicularPositionAround(ownerPos, targetPos, 2, 6);
                    //Debug.DrawLine(ownerPos, nextTarget, Color.cyan, 1f);

                    //if (ai.StartAction(ai.CastSkill(target, jump, distSqr, true, false, 0f, 0f), 0.5f))
                    if (ai.StartAction(ai.CastSkill(nextTarget, jump, distSqr, true, false, 0f, 0f), 0.5f))
                    {
                        return(true);
                    }
                }
                else if (jumpAtEnemy)
                {
                    if (ai.StartAction(ai.CastSkill(targetPos, jump, distSqr, true, false, 0f, 0f), 0.5f))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Example #2
0
        protected override void AttackTarget(Character target)
        {
            SetMainTarget(target);

            bool isCasting        = Owner.GetData().IsCasting;
            bool isMeleeAttacking = Owner.GetData().IsMeleeAttacking();

            // already doing something
            if (isCasting || Owner.Status.IsStunned())
            {
                return;
            }

            if (Owner.GetData().Target == null || Owner.GetData().Target.Equals(target.GetData().GetBody()))
            {
                Owner.GetData().Target = target.GetData().GetBody();
            }

            float dist               = Utils.DistanceSqr(target.GetData().transform.position, Owner.GetData().transform.position);
            bool  isImmobilized      = Owner.GetData().CanMove();
            int   hpPercentage       = (int)((GetStatus().Hp / (float)GetStatus().MaxHp) * 100);
            int   targetHpPercentage = (int)((target.Status.Hp / (float)target.Status.MaxHp) * 100);
            int   targetHp           = target.Status.Hp;

            //TODO cast this skill here if in range
            ActiveSkill sk = (ActiveSkill)GetSkillWithTrait(SkillTraits.Damage);

            if (IsLowHp(hpPercentage) && !isMeleeAttacking && dist < 5 * 5)
            {
                if (StartAction(RunAway(target, 5f, 20), 5f))
                {
                    return;
                }
            }

            if (dist > 5 * 5 && UnityEngine.Random.Range(0, 100) < 20)
            {
                ActiveSkill jump = (ActiveSkill)GetSkillWithTrait(SkillTraits.Jump);
                if (jump != null && jump.CanUse())
                {
                    if (StartAction(CastSkill(target, jump, dist, true, false, 0f, 0f), 1f))
                    {
                        return;
                    }
                }
            }

            if (sk != null && sk.CanUse())
            {
                StartAction(CastSkill(target, sk, dist, false, true, 0f, 0f), 5f);
            }
            else
            {
                Owner.GetData().MeleeInterract(target.GetData().GetBody(), false);
            }
        }
Example #3
0
        public override bool Trigger(Character target, float distSqr)
        {
            int         topDamage = -1;
            ActiveSkill topSkill  = null;

            // forced skill name to use
            if (skill != null)
            {
                foreach (Skill skk in skills)
                {
                    ActiveSkill sk = (ActiveSkill)skk;

                    if (sk.GetName().Equals(skill, StringComparison.InvariantCultureIgnoreCase))
                    {
                        if (sk.CanUse() && RangeCheck(sk, distSqr))
                        {
                            topSkill = sk;
                        }

                        break;
                    }
                }
            }
            // 1. get the most damage skill and cast if it is available
            else
            {
                foreach (Skill skk in skills)
                {
                    ActiveSkill sk = (ActiveSkill)skk;

                    if (sk.CanUse() && RangeCheck(sk, distSqr) && sk.GetTotalDamageOutput() > topDamage)
                    {
                        topDamage = sk.GetTotalDamageOutput();
                        topSkill  = sk;
                    }
                }
            }

            if (topSkill != null)
            {
                bool rangeCheck = true;
                // range check is already perfomed by this AI
                if (onlyIfWithinRange)
                {
                    rangeCheck = false;
                }

                ai.StartAction(ai.CastSkill(target, topSkill, distSqr, !rangeCheck, true, boostShootRange), topSkill.GetSkillActiveDuration() * 2, false, shootWhileMoving);

                return(true);
            }

            return(false);
        }
Example #4
0
        public override bool Trigger(Character target, float distSqr)
        {
            if (distSqr >= (minRange * minRange))
            {
                ActiveSkill dmg = (ActiveSkill)ai.GetSkillWithTrait(SkillTraits.Damage, SkillTraits.LongRange);
                if (dmg != null && dmg.CanUse() && !ai.Owner.GetData().forcedVelocity)
                {
                    if (ai.StartAction(ai.CastSkill(target, dmg, distSqr, true, false, 0f, 0f), 0.5f))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Example #5
0
        public override bool Trigger(Character target, float distSqr)
        {
            if (minRangeToJump < 0 || distSqr >= (minRangeToJump * minRangeToJump))
            {
                if (maxRangeToJump < 0 || distSqr <= (maxRangeToJump * maxRangeToJump))
                {
                    ActiveSkill jump = (ActiveSkill)ai.GetSkillWithTrait(SkillTraits.Jump);

                    if (jump != null && jump.CanUse() && !ai.Owner.GetData().forcedVelocity)
                    {
                        if (ai.StartAction(ai.CastSkill(target, jump, distSqr, true, false, 0f, 0f), 0.5f))
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
Example #6
0
        public override bool Trigger(Character target, float distSqr)
        {
            if (minRangeToTeleport < 0 || distSqr >= (minRangeToTeleport * minRangeToTeleport))
            {
                if (maxRangeToTeleport < 0 || distSqr <= (maxRangeToTeleport * maxRangeToTeleport))
                {
                    ActiveSkill teleport = (ActiveSkill)ai.GetSkillWithTrait(SkillTraits.Teleport);
                    // if range too high, teleport
                    if (teleport.CanUse() && !ai.Owner.GetData().forcedVelocity&& (!checkTeleportSkillRange || (distSqr >= ((Math.Pow(teleport.GetRange(), 2)) / 4f) && distSqr <= (Math.Pow(teleport.GetRange(), 2)))))
                    {
                        if (ai.StartAction(ai.CastSkill(target, teleport, distSqr, true, false, 0f, 0f), 0.5f))
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
Example #7
0
        public override bool Trigger(Character target, float distSqr)
        {
            Vector3 thisPos   = ai.Owner.GetData().transform.position;
            Vector3 targetPos = target.GetData().GetBody().transform.position;

            Vector3 runDirection = (thisPos - targetPos).normalized;
            Vector3 nextTarget;

            nextTarget = Utils.GeneratePerpendicularPositionAround(thisPos, (thisPos + (runDirection)), 0f, 2f);

            ActiveSkill jump = (ActiveSkill)ai.GetSkillWithTrait(SkillTraits.Jump);

            if (jump.CanUse() && !ai.Owner.GetData().forcedVelocity)
            {
                if (ai.StartAction(ai.CastSkill(nextTarget, jump, distSqr, true, false, 0f, 0f), 0.5f))
                {
                    return(true);
                }
            }

            return(false);
        }
Example #8
0
        public override bool Trigger(Character target, float distSqr)
        {
            Vector3 thisPos   = ai.Owner.GetData().transform.position;
            Vector3 targetPos = target.GetData().GetBody().transform.position;

            Vector3 runDirection = (thisPos - targetPos).normalized;
            Vector3 nextTarget;

            nextTarget = Utils.GeneratePerpendicularPositionAround(thisPos, (thisPos + (runDirection * UnityEngine.Random.Range(minTeleportRange, maxTeleportRange))), 0f, 2f);

            ActiveSkill teleport = (ActiveSkill)ai.GetSkillWithTrait(SkillTraits.Teleport);

            if (teleport.CanUse() && !ai.Owner.GetData().forcedVelocity)
            {
                if (ai.StartAction(ai.CastSkillWithTargetSet(nextTarget, teleport, distSqr, true, false, 0f, 0f), 0.5f))
                {
                    return(true);
                }
            }

            return(false);
        }
Example #9
0
        public override bool Trigger(Character target, float distSqr)
        {
            Vector3 thisPos   = ai.Owner.GetData().transform.position;
            Vector3 targetPos = target.GetData().GetBody().transform.position;

            Vector3 nextTarget;

            int limit = 5;

            while (--limit > 0)
            {
                if (aroundTarget)
                {
                    nextTarget = Utils.GenerateRandomPositionAround(thisPos, targetPos, maxDistanceAroundTarget, minDistanceAroundTarget);
                }
                else
                {
                    nextTarget = Utils.GenerateRandomPositionAround(thisPos, thisPos, maxDistanceAroundTarget, minDistanceAroundTarget);
                }

                if (Utils.CanSee(thisPos, targetPos))
                {
                    ActiveSkill jump = (ActiveSkill)ai.GetSkillWithTrait(SkillTraits.Jump);

                    if (jump.CanUse() && !ai.Owner.GetData().forcedVelocity)
                    {
                        if (ai.StartAction(ai.CastSkill(nextTarget, jump, distSqr, true, false, 0f, 0f), 0.5f))
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }