Exemplo n.º 1
0
        public virtual bool SelectTarget(NPCInstance npc)
        {
            RoleActor target = null;

            npc.mScanLastTime = 0;
            if (npc.mAttackTarget != 0)
            {
                target = npc.GetTarget(npc.mAttackTarget);
                if (null != target)
                {
                    if (target.IsDie)
                    {
                        npc.KickOneFromEnmityList(npc.mAttackTarget);
                        npc.mAttackTarget = 0;
                        target            = null;
                    }
                }
                else
                {
                    npc.mAttackTarget = 0;
                }
            }
            //从警戒范围找目标
            if (null == target)
            {
                target = npc.FindHatredTarget();
            }
            if (null == target)
            {
                return(false);
            }

            npc.UpdateEnmityList(target.Id, 1);

            return(true);
        }