Ejemplo n.º 1
0
        internal static Msg_RC_NpcEnter BuildNpcEnterMessage(NpcInfo npc)
        {
            Msg_RC_NpcEnter bder = new Msg_RC_NpcEnter();

            bder.npc_id = npc.GetId();
            Vector3 pos = npc.GetMovementStateInfo().GetPosition3D();

            bder.cur_pos_x      = (float)pos.X;
            bder.cur_pos_z      = (float)pos.Z;
            bder.face_direction = (float)npc.GetMovementStateInfo().GetFaceDir();
            return(bder);
        }
Ejemplo n.º 2
0
 public void CreateNpcView(int objId)
 {
     if (!m_NpcViews.ContainsKey(objId))
     {
         NpcInfo obj = WorldSystem.Instance.NpcManager.GetNpcInfo(objId);
         if (null != obj)
         {
             NpcView view = new NpcView();
             view.Create(obj);
             m_NpcViews.Add(objId, view);
         }
     }
 }
Ejemplo n.º 3
0
        internal static Msg_RC_NpcTarget BuildNpcTargetMessage(NpcInfo npc)
        {
            Msg_RC_NpcTarget npcFaceTargetBuilder = null;
            NpcAiStateInfo   data = npc.GetAiStateInfo();

            if (null != data && data.Target > 0)
            {
                npcFaceTargetBuilder           = new Msg_RC_NpcTarget();
                npcFaceTargetBuilder.npc_id    = npc.GetId();
                npcFaceTargetBuilder.target_id = data.Target;
            }
            return(npcFaceTargetBuilder);
        }
Ejemplo n.º 4
0
        private void OnNpcMove(NpcInfo npc)
        {
            Scene scene = npc.SceneContext.CustomData as Scene;

            if (null != scene && !npc.GetMovementStateInfo().IsSkillMoving)
            {
                Msg_RC_NpcMove npcMoveBuilder = DataSyncUtility.BuildNpcMoveMessage(npc);
                if (null != npcMoveBuilder)
                {
                    scene.NotifyAreaUser(npc, npcMoveBuilder);
                }
            }
        }
Ejemplo n.º 5
0
 private static bool WayPointArrived(NpcInfo npc, AiData_ForMoveCommand data)
 {
     if (TimeUtility.GetServerMilliseconds() >= data.EstimateFinishTime)
     {
         var     move_info = npc.GetMovementStateInfo();
         Vector3 to        = data.WayPoints[data.Index];
         Vector3 now       = move_info.GetPosition3D();
         float   distance  = Geometry.Distance(now, to);
         DLog._("ai_move", "[{0}]: closest distance({1}) ", npc.GetId(), distance);
         return(true);
     }
     return(false);
 }
Ejemplo n.º 6
0
        private void OnNpcTargetChange(NpcInfo npc)
        {
            Scene scene = npc.SceneContext.CustomData as Scene;

            if (null != scene)
            {
                Msg_RC_NpcTarget npcTargetBuilder = DataSyncUtility.BuildNpcTargetMessage(npc);
                if (null != npcTargetBuilder)
                {
                    scene.NotifyAreaUser(npc, npcTargetBuilder);
                }
            }
        }
Ejemplo n.º 7
0
        protected override void OnStateLogicInit(NpcInfo npc, AiCommandDispatcher aiCmdDispatcher, long deltaTime)
        {
            NpcAiStateInfo        info = npc.GetAiStateInfo();
            AiData_PvpNpc_General data = GetAiData(npc);

            if (null != data)
            {
                info.Time = 0;
                npc.GetMovementStateInfo().IsMoving = false;
                info.HomePos = npc.GetMovementStateInfo().GetPosition3D();
                info.Target  = 0;
            }
        }
Ejemplo n.º 8
0
        internal NpcInfo SummonNpc(int id, int owner_id, int owner_skillid, int npc_type_id, string modelPrefab, int skillid, int ailogicid, bool followsummonerdead,
                                   float x, float y, float z, string aiparamstr)
        {
            CharacterInfo charObj = SceneContext.GetCharacterInfoById(owner_id);

            if (charObj == null)
            {
                return(null);
            }
            NpcInfo   npc            = null;
            SkillInfo ownerSkillInfo = charObj.GetSkillStateInfo().GetSkillInfoById(owner_skillid);

            if (null != ownerSkillInfo)
            {
                if (null != ownerSkillInfo.m_EnableSummonNpcs && ownerSkillInfo.m_EnableSummonNpcs.Contains(npc_type_id))
                {
                    //ownerSkillInfo.m_EnableSummonNpcs.Remove(npc_type_id);

                    Data_Unit data = new Data_Unit();
                    data.m_Id       = -1;
                    data.m_LinkId   = npc_type_id;
                    data.m_CampId   = charObj.GetCampId();
                    data.m_IsEnable = true;
                    data.m_Pos      = new Vector3(x, y, z);
                    data.m_RotAngle = 0;
                    data.m_AiLogic  = ailogicid;
                    if (!string.IsNullOrEmpty(aiparamstr))
                    {
                        string[] strarry = aiparamstr.Split(new char[] { ',' }, 8);
                        int      i       = 0;
                        foreach (string str in strarry)
                        {
                            data.m_AiParam[i++] = str;
                        }
                    }
                    npc = NpcManager.AddNpc(data);
                    if (!string.IsNullOrEmpty(modelPrefab))
                    {
                        npc.SetModel(modelPrefab);
                    }
                    npc.FollowSummonerDead = followsummonerdead;
                    SkillInfo skillinfo = new SkillInfo(skillid);
                    npc.GetSkillStateInfo().AddSkill(skillinfo);
                    npc.GetMovementStateInfo().SetPosition(data.m_Pos);
                    npc.SummonOwnerId = charObj.GetId();
                    charObj.GetSkillStateInfo().AddSummonObject(npc);
                    AbstractNpcStateLogic.OnNpcSkill(npc, skillid);
                }
            }
            return(npc);
        }
Ejemplo n.º 9
0
        private void OnImpactDamage(CharacterInfo entity, int attackerId, int damage, bool isKiller, bool isCritical, bool isOrdinary)
        {
            if (null != entity)
            {
                Msg_RC_ImpactDamage bd = new Msg_RC_ImpactDamage();
                bd.role_id     = entity.GetId();
                bd.attacker_id = attackerId;
                bd.is_killer   = isKiller;
                bd.is_critical = isCritical;
                bd.is_ordinary = isOrdinary;
                bd.hp          = damage;

                Scene scene = entity.SceneContext.CustomData as Scene;
                if (null != scene)
                {
                    if (entity.IsHaveStoryFlag(StoryListenFlagEnum.Damage))
                    {
                        scene.StorySystem.SendMessage("objdamage", entity.GetId(), attackerId, damage, 0, isCritical ? 1 : 0);
                        NpcInfo npc = entity as NpcInfo;
                        if (null != npc)
                        {
                            scene.StorySystem.SendMessage("npcdamage:" + npc.GetUnitId(), entity.GetId(), attackerId, damage, 0, isCritical ? 1 : 0);
                        }
                    }

                    int estimateDamage = damage;
                    if (isCritical)
                    {
                        estimateDamage /= 2;
                    }
                    if (entity.Hp + estimateDamage <= 0)
                    {
                        scene.TryFireFinalBlow(entity);
                    }
                }

                for (LinkedListNode <UserInfo> linkNode = entity.UserManager.Users.FirstValue; null != linkNode; linkNode = linkNode.Next)
                {
                    UserInfo info = linkNode.Value;
                    if (null != info && null != info.CustomData)
                    {
                        User u = info.CustomData as User;
                        if (null != u)
                        {
                            u.SendMessage(bd);
                        }
                    }
                }
                entity.SetAttackerInfo(attackerId, 0, isKiller, isOrdinary, isCritical, damage, 0);
            }
        }
Ejemplo n.º 10
0
        private void IdleHandler(NpcInfo npc, AiCommandDispatcher aiCmdDispatcher, long deltaTime)
        {
            if (npc.IsDead())
            {
                return;
            }
            NpcAiStateInfo info = npc.GetAiStateInfo();

            info.Time += deltaTime;
            if (info.Time > 100)
            {
                info.Time = 0;
                if (GetAiData(npc).HasPatrolData)
                {
                    npc.GetMovementStateInfo().IsMoving = false;
                    ChangeToState(npc, (int)AiStateId.PatrolCommand);
                }
                else
                {
                    CharacterInfo target = null;
                    if (info.IsExternalTarget)
                    {
                        target = AiLogicUtility.GetSeeingLivingCharacterInfoHelper(npc, info.Target);
                        if (null == target)
                        {
                            target = AiLogicUtility.GetNearstTargetHelper(npc, CharacterRelation.RELATION_ENEMY);
                            if (null != target)
                            {
                                info.Target = target.GetId();
                            }
                        }
                    }
                    else
                    {
                        target = AiLogicUtility.GetNearstTargetHelper(npc, CharacterRelation.RELATION_ENEMY);
                        if (null != target)
                        {
                            info.Target = target.GetId();
                        }
                    }
                    if (null != target)
                    {
                        NotifyNpcTargetChange(npc);
                        npc.GetMovementStateInfo().IsMoving = false;
                        NotifyNpcMove(npc);
                        info.Time = 0;
                        ChangeToState(npc, (int)AiStateId.Pursuit);
                    }
                }
            }
        }
Ejemplo n.º 11
0
        internal static void SyncNpcAiStateToUser(NpcInfo npc, User user)
        {
            Msg_RC_NpcMove   npcMoveBuilder       = BuildNpcMoveMessage(npc);
            Msg_RC_NpcTarget npcFaceTargetBuilder = BuildNpcTargetMessage(npc);

            if (null != npcMoveBuilder)
            {
                user.SendMessage(npcMoveBuilder);
            }
            if (null != npcFaceTargetBuilder)
            {
                user.SendMessage(npcFaceTargetBuilder);
            }
        }
Ejemplo n.º 12
0
 private void NpcSkill(NpcInfo npc, int skillId, CharacterInfo target)
 {
     if (null != npc)
     {
         CharacterView view = EntityManager.Instance.GetCharacterViewById(npc.GetId());
         if (null != view)
         {
             SkillParam param = new SkillParam();
             param.SkillId  = skillId;
             param.TargetId = target.GetId();
             GfxSystem.SendMessage(view.Actor, "MonsterStartSkill", param);
         }
     }
 }
Ejemplo n.º 13
0
        private float GetRunSpeed(NpcInfo info)
        {
            Data_ActionConfig ac = info.GetCurActionConfig();

            if (null != ac)
            {
                return(ac.m_FastStdSpeed);
            }
            else
            {
                LogSystem.Error("AiLogic_Demo_Melee can't find CurActionConfig");
            }
            return(0.0f);
        }
Ejemplo n.º 14
0
        private void OnSetNpcIdleAnim(NpcInfo npc, List <int> anims)
        {
            NpcView view = EntityManager.Instance.GetNpcViewById(npc.GetId());

            if (null != view)
            {
                List <Animation_Type> idleAnims = new List <Animation_Type>();
                foreach (int animId in anims)
                {
                    idleAnims.Add((Animation_Type)animId);
                }
                view.SetIdleAnim(idleAnims);
            }
        }
Ejemplo n.º 15
0
        internal int GetBattleNpcCount()
        {
            int ct = 0;

            for (LinkedListNode <NpcInfo> linkNode = m_NpcMgr.Npcs.FirstValue; null != linkNode; linkNode = linkNode.Next)
            {
                NpcInfo info = linkNode.Value;
                if (null != info && info.DeadTime <= 0 && info.IsCombatNpc())
                {
                    ++ct;
                }
            }
            return(ct);
        }
Ejemplo n.º 16
0
        private static void GetInterestestTarget(CharacterInfo srcObj, CharacterRelation relation, AiTargetType type, float powDist, ISpaceObject obj, ref float minPowDist, ref CharacterInfo interestestTarget)
        {
            if (type == AiTargetType.USER && obj.GetObjType() != SpatialObjType.kUser)
            {
                return;
            }
            if (type == AiTargetType.TOWER && obj.GetObjType() != SpatialObjType.kNPC)
            {
                return;
            }
            if (type == AiTargetType.SOLDIER && obj.GetObjType() != SpatialObjType.kNPC)
            {
                return;
            }
            CharacterInfo target = GetSeeingLivingCharacterInfoHelper(srcObj, (int)obj.GetID());

            if (null != target && !target.IsDead())
            {
                if (target.IsControlMecha)
                {
                    return;
                }
                NpcInfo npcTarget = target.CastNpcInfo();
                if (null != npcTarget && npcTarget.NpcType == (int)NpcTypeEnum.Skill)
                {
                    return;
                }
                if (type == AiTargetType.SOLDIER && npcTarget.IsPvpTower)
                {
                    return;
                }
                if (type == AiTargetType.TOWER && !npcTarget.IsPvpTower)
                {
                    return;
                }

                if (relation == CharacterInfo.GetRelation(srcObj, target))
                {
                    if (powDist < minPowDist)
                    {
                        if (powDist > c_MaxViewRangeSqr || CanSee(srcObj, target))
                        {
                            interestestTarget = target;
                            minPowDist        = powDist;
                        }
                    }
                }
            }
        }
Ejemplo n.º 17
0
 public void Create(NpcInfo npc)
 {
     Init();
     if (null != npc)
     {
         m_Npc = npc;
         m_Npc.OnBeginAttack = ResetShootAnimation;
         MovementStateInfo msi = m_Npc.GetMovementStateInfo();
         Vector3           pos = msi.GetPosition3D();
         float             dir = msi.GetFaceDir();
         CreateActor(m_Npc.GetId(), m_Npc.GetModel(), pos, dir, m_Npc.Scale);
         InitAnimationSets();
         UpdateWeaponModel(m_Npc);
     }
 }
Ejemplo n.º 18
0
        internal void DestroyEntities(int[] unit_ids)
        {
            Msg_RC_DestroyNpc destroyNpcBuilder = new Msg_RC_DestroyNpc();

            for (int i = 0; i < unit_ids.Length; i++)
            {
                NpcInfo npc = NpcManager.GetNpcInfoByUnitId(unit_ids[i]);
                if (npc != null)
                {
                    destroyNpcBuilder.npc_id = npc.GetId();
                    NotifyAllUser(destroyNpcBuilder);
                    NpcManager.RemoveNpc(npc.GetId());
                }
            }
        }
Ejemplo n.º 19
0
        public void CreateNpcWithPos(int unitId, float x, float y, float z, float rotateAngle)
        {
            Data_Unit mapUnit = GetCurScene().StaticData.ExtractData(DataMap_Type.DT_Unit, unitId) as Data_Unit;

            if (null != mapUnit)
            {
                mapUnit.m_Pos      = new Vector3(x, y, z);
                mapUnit.m_RotAngle = rotateAngle;
                NpcInfo npc = m_NpcMgr.AddNpc(mapUnit);
                if (null != npc)
                {
                    EntityManager.Instance.CreateNpcView(npc.GetId());
                }
            }
        }
Ejemplo n.º 20
0
        private void InitPatrolData(NpcInfo npc)
        {
            AiData_ForPatrolCommand data = new AiData_ForPatrolCommand();

            data.IsLoopPatrol = true;
            List <Vector3> path = new List <Vector3>();
            NpcAiStateInfo info = npc.GetAiStateInfo();

            path = Converter.ConvertVector3DList(info.AiParam[1]);
            data.PatrolPath.SetPathPoints(npc.GetAiStateInfo().HomePos, path);
            npc.GetAiStateInfo().AiDatas.AddData <AiData_ForPatrolCommand>(data);
            AiData_Demo_Melee aiData = GetAiData(npc);

            aiData.HasPatrolData = true;
        }
Ejemplo n.º 21
0
        public void NotifyNpcFace(NpcInfo npc, float faceDirection = 0.0f)
        {
            if (null != OnNpcFace)
            {
                OnNpcFace(npc);
            }

            if (GlobalVariables.Instance.IsClient)
            {
                if (null != OnNpcFaceClient)
                {
                    OnNpcFaceClient(npc, faceDirection);
                }
            }
        }
Ejemplo n.º 22
0
        public NpcInfo GetNpcInfoByUnitId(int id)
        {
            NpcInfo npc = null;

            for (LinkedListNode <NpcInfo> linkNode = m_Npcs.FirstValue; null != linkNode; linkNode = linkNode.Next)
            {
                NpcInfo info = linkNode.Value;
                if (info.GetUnitId() == id)
                {
                    npc = info;
                    break;
                }
            }
            return(npc);
        }
Ejemplo n.º 23
0
        private void CombatHandler(NpcInfo npc, AiCommandDispatcher aiCmdDispatcher, long deltaTime)
        {
            if (npc.IsDead())
            {
                return;
            }
            NpcAiStateInfo info = npc.GetAiStateInfo();

            info.Time += deltaTime;
            float rps = npc.GetActualProperty().Rps;

            if (rps > 0.001f && info.Time > 1000 / rps)
            {
                info.Time = 0;
                bool          toIdle = false;
                CharacterInfo target = AiLogicUtility.GetSeeingLivingCharacterInfoHelper(npc, info.Target);
                if (null != target && npc.SpatialSystem.CanShoot(npc.SpaceObject, target.GetMovementStateInfo().GetPosition3D()))
                {
                    ScriptRuntime.Vector3 targetPos = target.GetMovementStateInfo().GetPosition3D();
                    ScriptRuntime.Vector3 srcPos    = npc.GetMovementStateInfo().GetPosition3D();
                    float powDist  = Geometry.DistanceSquare(srcPos, targetPos);
                    float dist     = (float)npc.GetActualProperty().AttackRange;
                    float distView = (float)npc.ViewRange;
                    if (powDist < dist * dist)
                    {
                        npc.GetMovementStateInfo().IsMoving = false;
                    }
                    else if (powDist < distView * distView)
                    {
                        npc.GetMovementStateInfo().IsMoving = false;
                    }
                    else
                    {
                        toIdle = true;
                    }
                }
                else
                {
                    toIdle = true;
                }
                if (toIdle)
                {
                    info.Time = 0;
                    npc.GetMovementStateInfo().IsMoving = false;
                    ChangeToState(npc, (int)AiStateId.Idle);
                }
            }
        }
Ejemplo n.º 24
0
        private void SyncSceneObjectsToUser(User user)
        {
            if (null != user)
            {
                UserInfo userInfo = user.Info;
                Room     room     = GetRoom();
                if (null != userInfo && null != room && null != room.GetActiveScene())
                {
                    for (LinkedListNode <NpcInfo> linkNode = NpcManager.Npcs.FirstValue; null != linkNode; linkNode = linkNode.Next)
                    {
                        NpcInfo npc = linkNode.Value;
                        if (null != npc)
                        {
                            Msg_RC_CreateNpc bder = DataSyncUtility.BuildCreateNpcMessage(npc);
                            if (npc.AppendAttrId > 0)
                            {
                                bder.add_attr_id = npc.AppendAttrId;
                            }
                            user.SendMessage(bder);
                        }
                    }

                    int totalKillCountForBlue = 0;
                    int totalKillCountForRed  = 0;
                    for (LinkedListNode <UserInfo> linkNode = UserManager.Users.FirstValue; null != linkNode; linkNode = linkNode.Next)
                    {
                        UserInfo user_info = linkNode.Value;
                        if (user_info.GetCampId() == (int)CampIdEnum.Blue)
                        {
                            totalKillCountForBlue += user_info.GetCombatStatisticInfo().KillHeroCount;
                        }
                        else
                        {
                            totalKillCountForRed += user_info.GetCombatStatisticInfo().KillHeroCount;
                        }
                    }

                    Msg_RC_PvpCombatInfo combat_bd = new Msg_RC_PvpCombatInfo();
                    combat_bd.kill_hero_count_for_blue = totalKillCountForBlue;
                    combat_bd.kill_hero_count_for_red  = totalKillCountForRed;
                    combat_bd.link_id_for_killer       = -1;
                    combat_bd.link_id_for_killed       = -1;
                    combat_bd.killed_nickname          = "";
                    combat_bd.killer_nickname          = "";
                    user.SendMessage(combat_bd);
                }
            }
        }
Ejemplo n.º 25
0
 private void TickDebugSpaceInfo()
 {
     if (GlobalVariables.Instance.IsDebug)
     {
         bool needDebug = false;
         foreach (User user in m_Room.RoomUsers)
         {
             if (user.IsDebug)
             {
                 needDebug = true;
                 break;
             }
         }
         if (needDebug)
         {
             Msg_RC_DebugSpaceInfo builder = new Msg_RC_DebugSpaceInfo();
             for (LinkedListNode <UserInfo> linkNode = UserManager.Users.FirstValue; null != linkNode; linkNode = linkNode.Next)
             {
                 UserInfo info = linkNode.Value;
                 Msg_RC_DebugSpaceInfo.DebugSpaceInfo infoBuilder = new Msg_RC_DebugSpaceInfo.DebugSpaceInfo();
                 infoBuilder.obj_id    = info.GetId();
                 infoBuilder.is_player = true;
                 infoBuilder.pos_x     = (float)info.GetMovementStateInfo().GetPosition3D().X;
                 infoBuilder.pos_z     = (float)info.GetMovementStateInfo().GetPosition3D().Z;
                 infoBuilder.face_dir  = (float)info.GetMovementStateInfo().GetFaceDir();
                 builder.space_infos.Add(infoBuilder);
             }
             for (LinkedListNode <NpcInfo> linkNode = NpcManager.Npcs.FirstValue; null != linkNode; linkNode = linkNode.Next)
             {
                 NpcInfo info = linkNode.Value;
                 Msg_RC_DebugSpaceInfo.DebugSpaceInfo infoBuilder = new Msg_RC_DebugSpaceInfo.DebugSpaceInfo();
                 infoBuilder.obj_id    = info.GetId();
                 infoBuilder.is_player = false;
                 infoBuilder.pos_x     = (float)info.GetMovementStateInfo().GetPosition3D().X;
                 infoBuilder.pos_z     = (float)info.GetMovementStateInfo().GetPosition3D().Z;
                 infoBuilder.face_dir  = (float)info.GetMovementStateInfo().GetFaceDir();
                 builder.space_infos.Add(infoBuilder);
             }
             foreach (User user in m_Room.RoomUsers)
             {
                 if (user.IsDebug)
                 {
                     user.SendMessage(builder);
                 }
             }
         }
     }
 }
Ejemplo n.º 26
0
        private void IdleHandler(NpcInfo npc, AiCommandDispatcher aiCmdDispatcher, long deltaTime)
        {
            if (npc.IsDead())
            {
                return;
            }
            NpcAiStateInfo info = npc.GetAiStateInfo();

            info.Time += deltaTime;
            if (info.Time > 100)
            {
                info.Time = 0;
                npc.GetMovementStateInfo().IsMoving = false;
                ChangeToState(npc, (int)AiStateId.PatrolCommand);
            }
        }
Ejemplo n.º 27
0
 private void RecycleNpcInfo(NpcInfo npcInfo)
 {
     if (null != npcInfo)
     {
         int id = npcInfo.GetId();
         if (id >= c_StartId && id < c_StartId + c_MaxIdNum)
         {
             m_UnusedIds.Push(id);
         }
         if (m_UnusedNpcs.Count < m_NpcPoolSize)
         {
             npcInfo.Reset();
             m_UnusedNpcs.Enqueue(npcInfo);
         }
     }
 }
Ejemplo n.º 28
0
        private NpcInfo NewNpcInfo(int id)
        {
            NpcInfo npc = null;

            if (m_UnusedNpcs.Count > 0)
            {
                npc = m_UnusedNpcs.Dequeue();
                npc.Reset();
                npc.InitId(id);
            }
            else
            {
                npc = new NpcInfo(id);
            }
            return(npc);
        }
Ejemplo n.º 29
0
        private AiData_PveNpc_Monster_CloseCombat GetAiData(NpcInfo npc)
        {
            AiData_PveNpc_Monster_CloseCombat data = npc.GetAiStateInfo().AiDatas.GetData <AiData_PveNpc_Monster_CloseCombat>();

            if (null == data)
            {
                NpcAiStateInfo info = npc.GetAiStateInfo();
                data = new AiData_PveNpc_Monster_CloseCombat();
                data.FastMoveImpact     = int.Parse(info.AiParam[0]);
                data.PreAttackImpact    = int.Parse(info.AiParam[1]);
                data.PreAttackDistance  = int.Parse(info.AiParam[2]);
                data.StandShootDistance = int.Parse(info.AiParam[3]);
                npc.GetAiStateInfo().AiDatas.AddData(data);
            }
            return(data);
        }
Ejemplo n.º 30
0
        private void PatrolHandler(NpcInfo npc, AiCommandDispatcher aiCmdDispatcher, long deltaTime)
        {
            if (npc.IsDead())
            {
                return;
            }
            NpcAiStateInfo info = npc.GetAiStateInfo();

            info.Time += deltaTime;
            if (info.Time > 100)
            {
                info.Time = 0;
                AiData_PvpNpc_General data = GetAiData(npc);
                if (null != data)
                {
                    CharacterInfo interestestTarget = GetInterestestTargetHelper(npc, CharacterRelation.RELATION_ENEMY);
                    if (null != interestestTarget)
                    {
                        npc.GetMovementStateInfo().IsMoving = false;
                        NotifyNpcMove(npc);
                        info.Time   = 0;
                        info.Target = interestestTarget.GetId();
                        data.FoundPath.Clear();
                        ChangeToState(npc, (int)AiStateId.Pursuit);
                    }
                    else
                    {
                        ScriptRuntime.Vector3 srcPos = npc.GetMovementStateInfo().GetPosition3D();
                        if (!data.PatrolPath.IsReached(srcPos))
                        {
                            PathToTargetWithoutObstacle(npc, data.FoundPath, data.PatrolPath.CurPathPoint, 100);
                        }
                        else
                        {
                            data.PatrolPath.UseNextPathPoint();
                            data.FoundPath.Clear();
                            if (!data.PatrolPath.HavePathPoint)
                            {
                                info.Time = 0;
                                ChangeToState(npc, (int)AiStateId.Idle);
                            }
                        }
                        info.HomePos = npc.GetMovementStateInfo().GetPosition3D();
                    }
                }
            }
        }