Beispiel #1
0
        public override bool FollowTarget(NPCInstance npc, RoleActor target)
        {
            if (!base.FollowTarget(npc, target))
            {
                return(false);
            }

            Vector3 standPos = target.GetSurroundPosition(npc.GetPosition(), (int)npc.mCastSpellDistance, npc.Id);

            if (!Util.PassableForMod(npc.HostMap.Navigator, standPos))
            {
                if (!Util.PassableForMod(npc.HostMap.Navigator, target.GetPosition()))
                {
                    return(false);
                }
                standPos = target.GetPosition();
            }

            if (!npc.MoveTo(standPos))
            {
                return(false);
            }

            npc.ChangeState(eNPCState.FollowTarget);

            return(true);
        }
Beispiel #2
0
        public override bool FollowTarget(NPCInstance npc, RoleActor target)
        {
            if (!base.FollowTarget(npc, target))
            {
                return(false);
            }

            //超出追击范围
            if (Util.DistanceH(npc.GetPosition(), npc.mSpawnPoint) > npc.InMapData.followRange)
            {
                return(false);
            }

            npc.SelectSpell();

            if (npc.CanCastSpell())
            {
                //到释放技能距离
                npc.ChangeState(eNPCState.WaitCoolDown);
            }
            else
            {
                if (npc.InMapData.followRange > 0)
                {
                    Vector3 standPos = target.GetSurroundPosition(npc.GetPosition(), (int)npc.mCastSpellDistance, npc.Id);
                    if (!Util.PassableForMod(npc.HostMap.Navigator, standPos))
                    {
                        if (!Util.PassableForMod(npc.HostMap.Navigator, target.GetPosition()))
                        {
                            return(false);
                        }

                        standPos = target.GetPosition();
                    }

                    if (!npc.MoveTo(standPos))
                    {
                        return(false);
                    }
                }

                npc.ChangeState(eNPCState.FollowTarget);
            }

            return(true);
        }
Beispiel #3
0
        public override bool StartPatrol(NPCInstance npc)
        {
            if (npc.InMapData.patrolRange <= 0)
            {
                return(false);
            }

            Vector3 randPos = new Vector3();

            //Vector3 randPos = Util.RandInRadius(npc.mSpawnPoint, npc.InMapData.patrolRange);
            //if (Util.PassableForMod(npc.HostMap.Navigator, randPos))
            if (Util.FindRandomPoint(npc.HostMap.Navigator, npc.GetPosition(), npc.mSpawnPoint, npc.InMapData.patrolRange, ref randPos))
            {
                if (npc.MoveTo(randPos))
                {
                    npc.ChangeState(eNPCState.Patrol);
                    return(true);
                }
            }
            return(false);
        }