internal static void Execute(object msg, User user) { Msg_CR_Skill use_skill = msg as Msg_CR_Skill; if (null == use_skill) { return; } EntityInfo userObj = user.Info; if (null == userObj) { LogSys.Log(LOG_TYPE.DEBUG, "UseSkillHandler, charactor {0}({1},{2},{3}) not exist", user.RoleId, user.GetKey(), user.Guid, user.Name); return; } Scene scene = user.OwnRoom.ActiveScene; if (null != scene) { EntityInfo obj = scene.GetEntityById(use_skill.role_id); if (null != obj) { AiStateInfo aiInfo = obj.GetAiStateInfo(); if (use_skill.target_id > 0) { aiInfo.Target = use_skill.target_id; } else if (use_skill.target_dir > 0) { float dir = ProtoHelper.DecodeFloat(use_skill.target_dir); obj.GetMovementStateInfo().SetFaceDir(dir); aiInfo.Target = 0; } if (aiInfo.AiLogic == (int)AiStateLogicId.Entity_Leader) { AiData_Leader data = aiInfo.AiDatas.GetData <AiData_Leader>(); if (null == data) { data = new AiData_Leader(); aiInfo.AiDatas.AddData(data); } data.ManualSkillId = use_skill.skill_id; } else { AiData_General data = aiInfo.AiDatas.GetData <AiData_General>(); if (null == data) { data = new AiData_General(); aiInfo.AiDatas.AddData(data); } data.ManualSkillId = use_skill.skill_id; } aiInfo.ChangeToState((int)AiStateId.SkillCommand); } } }
public bool CastSkill(int objId, int skillId) { bool ret = false; EntityInfo obj = GetEntityById(objId); if (null != obj) { SkillInfo skillInfo = obj.GetSkillStateInfo().GetSkillInfoById(skillId); if (null != skillInfo) { if (obj.Energy >= obj.GetActualProperty().EnergyMax) { if (!skillInfo.IsInCd(TimeUtility.GetLocalMilliseconds())) { int targetId = 0; if (null != SelectedTarget) { targetId = SelectedTarget.TargetId; } if (IsRoomScene) { Network.NetworkSystem.Instance.SyncPlayerSkill(obj, skillId, targetId, obj.GetMovementStateInfo().GetFaceDir()); } else { AiStateInfo aiInfo = obj.GetAiStateInfo(); aiInfo.Target = targetId; if (aiInfo.AiLogic == (int)AiStateLogicId.Entity_Leader) { AiData_Leader data = aiInfo.AiDatas.GetData <AiData_Leader>(); if (null == data) { data = new AiData_Leader(); aiInfo.AiDatas.AddData(data); } data.ManualSkillId = skillId; } else { AiData_General data = aiInfo.AiDatas.GetData <AiData_General>(); if (null == data) { data = new AiData_General(); aiInfo.AiDatas.AddData(data); } data.ManualSkillId = skillId; } aiInfo.ChangeToState((int)AiStateId.SkillCommand); } ret = true; } } } } return(ret); }
static public int ChangeToState(IntPtr l) { try { GameFramework.AiStateInfo self = (GameFramework.AiStateInfo)checkSelf(l); System.Int32 a1; checkType(l, 2, out a1); self.ChangeToState(a1); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
private void AttachAiLogic(EntityInfo npc) { AiStateInfo aiInfo = npc.GetAiStateInfo(); string storyId = aiInfo.AiLogic; string storyFile = aiInfo.AiParam[0]; if (!string.IsNullOrEmpty(storyId) && !string.IsNullOrEmpty(storyFile)) { aiInfo.HomePos = npc.GetMovementStateInfo().GetPosition3D(); aiInfo.ChangeToState((int)PredefinedAiStateId.Idle); aiInfo.AiStoryInstanceInfo = GfxStorySystem.Instance.NewAiStoryInstance(storyId, string.Empty, storyFile); if (null != aiInfo.AiStoryInstanceInfo) { aiInfo.AiStoryInstanceInfo.m_StoryInstance.SetVariable("@objid", npc.GetId()); aiInfo.AiStoryInstanceInfo.m_StoryInstance.Start(); } } }
private void OnAiInitDslLogic(EntityInfo npc) { AiStateInfo aiInfo = npc.GetAiStateInfo(); if (aiInfo.AiParam.Length >= 2) { string storyId = aiInfo.AiLogic; string storyFile = aiInfo.AiParam[0]; if (!string.IsNullOrEmpty(storyId) && !string.IsNullOrEmpty(storyFile)) { aiInfo.HomePos = npc.GetMovementStateInfo().GetPosition3D(); aiInfo.ChangeToState((int)PredefinedAiStateId.Idle); aiInfo.AiStoryInstanceInfo = StorySystem.NewAiStoryInstance(storyId, string.Empty, storyFile); if (null != aiInfo.AiStoryInstanceInfo) { aiInfo.AiStoryInstanceInfo.m_StoryInstance.Context = this; aiInfo.AiStoryInstanceInfo.m_StoryInstance.SetVariable("@objid", npc.GetId()); aiInfo.AiStoryInstanceInfo.m_StoryInstance.Start(); } } } m_EntitiesForAi.Add(npc); }