public bool Pet_SendUseSkillMessage(int petIndex, short idSkill, int idTargetObj, float fTargetX, float fTargetZ) { SDATA_PET pPetData = Pet_GetPet(petIndex); int nPetCount = CDataPool.Instance.Pet_GetCount(); if (pPetData != null) { CObject_PlayerNPC pPet = null; if (pPetData.idServer != uint.MaxValue) { pPet = CObjectManager.Instance.FindServerObject((int)pPetData.idServer) as CObject_PlayerNPC; } if (pPet != null) { CGCharUseSkill msg = NetManager.GetNetManager().CreatePacket((int)PACKET_DEFINE.PACKET_CG_CHARUSESKILL) as CGCharUseSkill; msg.ObjectID = (int)pPetData.idServer; msg.SkillDataID = idSkill * 100; msg.TargetID = idTargetObj; WORLD_POS pos = new WORLD_POS(); pos.m_fX = fTargetX; pos.m_fZ = fTargetZ; msg.PosTarget = pos; // msg.PosTarget.m_fZ = fTargetZ; msg.Dir = -1; msg.GuidTarget = -1; LogManager.LogWarning("Pet_SendUseSkillMessage"); NetManager.GetNetManager().SendPacket(msg); } } return(true); }
internal string GetHeadIcon() { CObject_Character pCharObj = _GetTargetAsCharacter(); if (pCharObj.GetCharacterType() == CHARACTER_TYPE.CT_MONSTER) { CObject_PlayerNPC npc = pCharObj as CObject_PlayerNPC; if (npc != null) { return(npc.GetPortrait()); } else { return(""); } } //得到玩家和自己的头像 string pImageName = ""; //打开生物定义表 _DBC_CHAR_FACE pFaceImage = CDataBaseSystem.Instance.GetDataBase <_DBC_CHAR_FACE>( (int)DataBaseStruct.DBC_CHAR_FACE).Search_Index_EQU(pCharObj.GetCharacterData().Get_PortraitID()); if (pFaceImage != null) { pImageName = pFaceImage.pImageSetName; } return(pImageName); }
public void CleanUp( ) { m_nIsPresent = -1; m_GUID.Reset(); m_idServer = MacroDefine.UINT_MAX; m_nDataID = MacroDefine.INVALID_ID; m_nAIType = -1; m_szName = ""; m_nLevel = -1; m_nExp = -1; m_nHP = -1; m_nHPMax = -1; m_nAge = -1; m_nEraCount = -1; m_nHappiness = -1; m_SpouseGUID.Reset(); m_nModelID = MacroDefine.INVALID_ID; m_nMountID = MacroDefine.INVALID_ID; m_nAttPhysics = -1; m_nAttMagic = -1; m_nDefPhysics = -1; m_nDefMagic = -1; m_nHit = -1; m_nMiss = -1; m_nCritical = -1; m_nAttrStrApt = -1; m_nAttrConApt = -1; m_nAttrDexApt = -1; m_nAttrSprApt = -1; m_nAttrIntApt = -1; m_nAttrStr = -1; m_nAttrCon = -1; m_nAttrDex = -1; m_nAttrSpr = -1; m_nAttrInt = -1; m_nBasic = -1; m_nPot = -1; m_nDefCritical = -1; m_nAttrStrBring = -1; m_nAttrConBring = -1; m_nAttrDexBring = -1; m_nAttrIntBring = -1; CObjectManager.Instance.DestroyObject(m_FakeObj); m_FakeObj = null; for (int i = 0; i < (int)m_aSkill.Count; i++) { if (m_aSkill[i] != null) { m_aSkill[i].CleanUp(); } } for (int i = 0; i < (int)PET_EQUIP.PEQUIP_NUMBER; i++) { m_Equipts[i] = null; } }
public override NET_RESULT_DEFINE.PACKET_EXE Execute(PacketBase packet, ref Peer pPlayer) { //当前流程是主流程 if (GameProcedure.GetActiveProcedure() == GameProcedure.s_ProcMain) { GCNewPet pPacket = (GCNewPet)packet; CObjectManager pObjectManager = CObjectManager.Instance; //检查位置是否合法 fVector2 pos = new fVector2(pPacket.getWorldPos().m_fX, pPacket.getWorldPos().m_fZ); if (!WorldManager.Instance.ActiveScene.IsValidPosition(ref pos)) { LogManager.LogError("Valid Position @GCNewPetHandler.Execute"); return(NET_RESULT_DEFINE.PACKET_EXE.PACKET_EXE_ERROR); } //创建宠物 CObject_PlayerNPC pNPC = (CObject_PlayerNPC)pObjectManager.FindServerObject((int)pPacket.getObjID()); float fFaceDir = pPacket.getDir(); if (pNPC == null) { pNPC = pObjectManager.NewPlayerNPC((int)pPacket.getObjID()); SObjectInit initPlayerNPC = new SObjectInit(); initPlayerNPC.m_fvPos = new Vector3(pos.x, 0, pos.y); initPlayerNPC.m_fvRot = new Vector3(0.0f, fFaceDir, 0.0f); pNPC.Initial(initPlayerNPC); } else { pNPC.SetMapPosition(pos.x, pos.y); pNPC.SetFaceDir(fFaceDir); pNPC.Enable((uint)ObjectStatusFlags.OSF_VISIABLE); pNPC.Disalbe((uint)ObjectStatusFlags.OSF_OUT_VISUAL_FIELD); } pNPC.SetNpcType(ENUM_NPC_TYPE.NPC_TYPE_PET); pNPC.GetCharacterData().Set_MoveSpeed(pPacket.getMoveSpeed()); SCommand_Object cmdTemp = new SCommand_Object(); cmdTemp.m_wID = (int)OBJECTCOMMANDDEF.OC_IDLE; cmdTemp.SetValue <float>(0, pos.x); cmdTemp.SetValue <float>(1, pos.y); cmdTemp.SetValue <bool>(2, false); pNPC.PushCommand(cmdTemp); //放入Ask队列 pObjectManager.LoadQueue.TryAddLoadTask(pNPC.ID); //同步渲染层 string szTemp = "GCNewPet(" + pos.x.ToString() + "," + pos.y.ToString() + ")"; pNPC.PushDebugString(szTemp); pNPC.SetMsgTime(GameProcedure.s_pTimeSystem.GetTimeNow()); } return(NET_RESULT_DEFINE.PACKET_EXE.PACKET_EXE_CONTINUE);; }
void UpdateNpcState(int npcID) { CObject_PlayerNPC pObj = (CObject_PlayerNPC)CObjectManager.Instance.FindCharacterByTableID(npcID); if (pObj != null) { pObj.UpdateMissionState(); } }
public CObject_PlayerNPC NewFakePlayerNPC() { CObject_PlayerNPC newFakePlayerNPC = new CObject_PlayerNPC(); newFakePlayerNPC.ServerID = -1; newFakePlayerNPC.SetFakeObjectFlag(true); newFakePlayerNPC.Initial(null); newFakePlayerNPC.SetPosition(new Vector3(0, 0, 0)); return(newFakePlayerNPC); }
//创建怪物NPC public CObject_PlayerNPC NewPlayerNPC(int idServer) { if (mServerObjects.ContainsKey(idServer)) { return((CObject_PlayerNPC)mServerObjects[idServer]); } CObject_PlayerNPC npc = new CObject_PlayerNPC(); add(npc, idServer); mPlayerNPC.AddChild(npc); return(npc); }
public int GetDialogNpcID() { int dialogNpc = CUIDataPool.Instance.GetCurDialogNpcId(); CObject_PlayerNPC npc = (CObject_PlayerNPC)CObjectManager.Instance.FindServerObject(dialogNpc); if (npc != null) { return(npc.ID); } else { return(-1); } }
public string GetDialogNpcName() { int dialogNpc = CUIDataPool.Instance.GetCurDialogNpcId(); CObject_PlayerNPC npc = (CObject_PlayerNPC)CObjectManager.Instance.FindServerObject(dialogNpc); if (npc != null) { return(npc.GetCharacterData().Get_Name()); } else { return(Character.Instance.GetName()); } }
/// <summary> /// 检查是否有额外的特效需要显示 /// </summary> private void UpdateExtraEffect() { if (m_bShow == false || serverId == -1) { HideEffect(); } else { CObject_PlayerNPC npc = CObjectManager.Instance.FindServerObject(serverId) as CObject_PlayerNPC; if (npc != null) { if (npc.GetExtraEffectName() == "") { HideEffect(); } else { ShowEffect(npc.GetExtraEffectName(), npc.GetEffectHeight()); } } } }
public PET_FRIEND() { m_Avatar = null; }
public virtual void SetMainTarget(int id, DESTROY_MAIN_TARGET_TYPE delType) { CObject pFindObj = null; if (id != MacroDefine.INVALID_ID) { pFindObj = (CObject)FindServerObject(id); } //不考虑无法选择的物体 //如果没选中物体或者选种的物体是不CanbeSelect的,告诉服务器取消当前选种对象。 if (pFindObj == null || (pFindObj != null && !(pFindObj.CanbeSelect()))) { if (mMainTarget != null && mMainTarget.GetRenderInterface() != null) { //关闭选择环 mMainTarget.GetRenderInterface().Attach_ProjTexture(GFX.GfxObject.PROJTEX_TYPE.SELECT_RING, false, 1.0f, 1.7f, null); mMainTarget = null; if ((delType != DESTROY_MAIN_TARGET_TYPE.DEL_OBJECT) || (pFindObj != null && !(pFindObj.CanbeSelect()))) { // 如果是鼠标右键销毁, target 窗口. // 2006-4-12 如果当前选择的不是队友返回。 // 设置当前没有选中队友 // SetCurSelTeam(-1); AutoReleaseSkill.Instance.SetTargetObject(-1); CEventSystem.Instance.PushEvent(GAME_EVENT_ID.GE_MAINTARGET_CHANGED, -1); } else { //if(!IsSelTeam()) // { // 2006-4-12 如果当前选择的不是队友返回。 // CEventSystem.Instance.PushEvent(GAME_EVENT_ID.GE_MAINTARGET_CHANGED,-1); // } } } else { // 设置当前没有选中队友 // SetCurSelTeam(-1); AutoReleaseSkill.Instance.SetTargetObject(-1); CEventSystem.Instance.PushEvent(GAME_EVENT_ID.GE_MAINTARGET_CHANGED, -1); } return; } if (pFindObj != null && (pFindObj != mMainTarget)) { //关闭选择环 if (mMainTarget != null && mMainTarget.GetRenderInterface() != null) { mMainTarget.GetRenderInterface().Attach_ProjTexture(GFX.GfxObject.PROJTEX_TYPE.SELECT_RING, false, 1.0f, 1.7f, null); } //设置选择对象 mMainTarget = pFindObj; //告诉server选中的对象 //发往服务器 CGLockTarget msg = new CGLockTarget(); msg.TargetID = id; NetManager.GetNetManager().SendPacket(msg); //打开新的选择环 if (mMainTarget != null && mMainTarget.GetRenderInterface() != null) { CObject_PlayerNPC pFindNPC = (CObject_PlayerNPC)pFindObj; float Select_Ring_Range = pFindNPC.GetProjtexRange(); //ENUM_RELATION eCampTypeMetoIt = ENUM_RELATION.RELATION_INVALID; //if(g_theKernel.IsKindOf(m_pMainTarget->GetClass(), GETCLASS(CObject_Character))) //{ // eCampTypeMetoIt = CalcRelationType( // CObjectManager::GetMe()->GetMySelf()->GetCharacterData()->Get_CampData()->m_nCampID, // pFindNPC->GetCampData()->m_nCampID, // CGameProcedure::s_pCampDataMgr ); // // 如果选中的是玩家则通过PK模式判断关系 [8/19/2011 edit by ZL] // if (eCampTypeMetoIt != RELATION_ENEMY) // { // INT tempRelation = CObjectManager::GetMe()->GetMySelf()->GetRelationOther((CObject_Character*)pFindObj); // if ( tempRelation != -1 ) // eCampTypeMetoIt = (ENUM_RELATION)tempRelation; // } //} mMainTarget.GetRenderInterface().Attach_ProjTexture(GFX.GfxObject.PROJTEX_TYPE.SELECT_RING, true, Select_Ring_Range, 1.7f, null); } //产生一个选择对象更改的事件 UIWindowMng.Instance.ShowWindow("TargetWindow"); CEventSystem.Instance.PushEvent(GAME_EVENT_ID.GE_MAINTARGET_CHANGED, id); AutoReleaseSkill.Instance.SetTargetObject(id); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // 设置选中队友2006-4-1 // //TeamMemberInfo* pInfo = CUIDataPool::GetMe()->GetTeamOrGroup()->GetMemberByServerId(m_pMainTarget->GetServerID()); //if(pInfo) //{ // GUID_t GUID = pInfo->m_GUID; // // 设置当前选中队友 // SetCurSelTeam(TRUE); // SetCurSelTeam(GUID); //} } }
public override NET_RESULT_DEFINE.PACKET_EXE Execute(PacketBase pPacket, ref Peer pPlayer) { //当前流程是主流程 if (GameProcedure.GetActiveProcedure() == (GameProcedure)GameProcedure.s_ProcMain) { GCNewMonster_Death newMonsterPacket = (GCNewMonster_Death)pPacket; CObjectManager pObjectManager = GameProcedure.s_pObjectManager; // //检查位置是否合法 // if(!CWorldManager::GetMe().GetActiveScene().IsValidPosition(fVector2(newMonsterPacket.getWorldPos().m_fX, newMonsterPacket.getWorldPos().m_fZ))) // { // TDThrow("ERROR POSITION @ GCNewMonsterHandler"); // } //创建玩家 CObject_PlayerNPC pNPC = (CObject_PlayerNPC)pObjectManager.FindServerObject((int)newMonsterPacket.ObjectID); if (pNPC == null) { pNPC = pObjectManager.NewPlayerNPC((int)newMonsterPacket.ObjectID); pNPC.Initial(null); } else { // pNPC.Enable( OSF_VISIABLE ); // pNPC.Disalbe( OSF_OUT_VISUAL_FIELD ); } //设置怪物位置和面向 pNPC.SetMapPosition(newMonsterPacket.Position.m_fX, newMonsterPacket.Position.m_fZ); pNPC.SetFaceDir(newMonsterPacket.Dir); if (newMonsterPacket.IsNpc != 0) { pNPC.SetNpcType(ENUM_NPC_TYPE.NPC_TYPE_NPC); } else { pNPC.SetNpcType(ENUM_NPC_TYPE.NPC_TYPE_MONSTER); } SCommand_Object cmdTemp = new SCommand_Object(); cmdTemp.m_wID = (int)OBJECTCOMMANDDEF.OC_DEATH; cmdTemp.SetValue <bool>(0, false); pNPC.PushCommand(cmdTemp); //清除界面选中NPC if (CObjectManager.Instance.GetMainTarget() != null && pNPC != null && (CObjectManager.Instance.GetMainTarget().ID == pNPC.ID)) { GameProcedure.s_pGameInterface.Object_SelectAsMainTarget(MacroDefine.INVALID_ID); } pNPC.GetCharacterData().Set_MoveSpeed(newMonsterPacket.MoveSpeed); //放入Ask队列 pObjectManager.LoadQueue.TryAddLoadTask(pNPC.ID); //此版不做服务器繁忙客户端延后发消息的处理 // CGCharAskBaseAttrib msgAskBaseAttrib = new CGCharAskBaseAttrib(); // msgAskBaseAttrib.setTargetID( (uint)newMonsterPacket.ObjectID); // GameProcedure.s_NetManager.SendPacket(msgAskBaseAttrib ); // char szTemp[MAX_PATH]; // _snprintf(szTemp, MAX_PATH, "GCNewMonster(%.1f,%.1f)", // newMonsterPacket.getWorldPos().m_fX, newMonsterPacket.getWorldPos().m_fZ); // pNPC.PushDebugString(szTemp); pNPC.SetMsgTime(GameProcedure.s_pTimeSystem.GetTimeNow()); } return(NET_RESULT_DEFINE.PACKET_EXE.PACKET_EXE_CONTINUE); }
public override NET_RESULT_DEFINE.PACKET_EXE Execute(PacketBase pPacket, ref Peer pPlayer) { //if(GameProcedure.GetActiveProcedure() == GameProcedure.s_ProcMain) // LogManager.Log("RECV GCNewMonster"); //当前流程是主流程 if (GameProcedure.GetActiveProcedure() == (GameProcedure)GameProcedure.s_ProcMain) { GCNewMonster newMonsterPacket = (GCNewMonster)pPacket; CObjectManager pObjectManager = GameProcedure.s_pObjectManager; // //检查位置是否合法 // if(!CWorldManager::GetMe().GetActiveScene().IsValidPosition(fVector2(newMonsterPacket.getWorldPos().m_fX, newMonsterPacket.getWorldPos().m_fZ))) // { // TDThrow("ERROR POSITION @ GCNewMonsterHandler"); // } //创建玩家 CObject_PlayerNPC pNPC = (CObject_PlayerNPC )pObjectManager.FindServerObject((int)newMonsterPacket.ObjectID); if (pNPC == null) { pNPC = pObjectManager.NewPlayerNPC((int)newMonsterPacket.ObjectID); pNPC.Initial(null); } else { // pNPC.Enable( OSF_VISIABLE ); // pNPC.Disalbe( OSF_OUT_VISUAL_FIELD ); } //设置怪物位置和面向 pNPC.SetMapPosition(newMonsterPacket.Position.m_fX, newMonsterPacket.Position.m_fZ); pNPC.SetFaceDir(newMonsterPacket.Dir); if (newMonsterPacket.IsNpc != 0) { pNPC.SetNpcType(ENUM_NPC_TYPE.NPC_TYPE_NPC); } else { pNPC.SetNpcType(ENUM_NPC_TYPE.NPC_TYPE_MONSTER); } pNPC.GetCharacterData().Set_MoveSpeed(newMonsterPacket.MoveSpeed); // SGWEB.SCommand_Object cmdTemp; // cmdTemp.m_wID = (SGWEB.AICommandDef)ObjectCommandDef.OC_IDLE; // cmdTemp.m_afParam[0] = newMonsterPacket.Position.m_fX; // cmdTemp.m_afParam[1] = newMonsterPacket.Position.m_fZ; // cmdTemp.m_abParam[2] = false; // pNPC.PushCommand(cmdTemp ); //放入Ask队列 pObjectManager.LoadQueue.TryAddLoadTask(pNPC.ID); //此版不做服务器繁忙客户端延后发消息的处理 // CGCharAskBaseAttrib msgAskBaseAttrib = new CGCharAskBaseAttrib(); // msgAskBaseAttrib.setTargetID( (uint)newMonsterPacket.ObjectID); // GameProcedure.s_NetManager.SendPacket(msgAskBaseAttrib ); // char szTemp[MAX_PATH]; // _snprintf(szTemp, MAX_PATH, "GCNewMonster(%.1f,%.1f)", // newMonsterPacket.getWorldPos().m_fX, newMonsterPacket.getWorldPos().m_fZ); // pNPC.PushDebugString(szTemp); pNPC.SetMsgTime(GameProcedure.s_pTimeSystem.GetTimeNow()); } return(NET_RESULT_DEFINE.PACKET_EXE.PACKET_EXE_CONTINUE); }
public override NET_RESULT_DEFINE.PACKET_EXE Execute(PacketBase pPacket, ref Peer pPlayer) { //当前流程是主流程 if (GameProcedure.GetActiveProcedure() == (GameProcedure)GameProcedure.s_ProcMain) { CObjectManager pObjectManager = CObjectManager.Instance; GCNewMonster_Move newMonsterMovPacket = (GCNewMonster_Move)pPacket; // //检查位置是否合法 // if(!CWorldManager::GetMe().GetActiveScene().IsValidPosition(fVector2(pPacket.getWorldPos().m_fX, pPacket.getWorldPos().m_fZ))) // { // TDThrow("ERROR POSITION @ GCNewMonster_MoveHandler"); // } // if(!CWorldManager::GetMe().GetActiveScene().IsValidPosition(fVector2(pPacket.getTargetPos().m_fX, pPacket.getTargetPos().m_fZ))) // { // TDThrow("ERROR POSITION @ GCNewMonster_MoveHandler target"); // } //创建玩家 CObject_PlayerNPC pNPC = (CObject_PlayerNPC)pObjectManager.FindServerObject((int)newMonsterMovPacket.getObjID()); if (pNPC == null) { pNPC = pObjectManager.NewPlayerNPC((int)newMonsterMovPacket.getObjID()); pNPC.Initial(null); } else { //pNPC.Enable( OSF_VISIABLE ); // pNPC.Disalbe( OSF_OUT_VISUAL_FIELD ); } //设置x z坐标 pNPC.SetMapPosition(newMonsterMovPacket.getWorldPos().m_fX, newMonsterMovPacket.getWorldPos().m_fZ); if (newMonsterMovPacket.getIsNPC()) { pNPC.SetNpcType(ENUM_NPC_TYPE.NPC_TYPE_NPC); } else { pNPC.SetNpcType(ENUM_NPC_TYPE.NPC_TYPE_MONSTER); } pNPC.GetCharacterData().Set_MoveSpeed(newMonsterMovPacket.getMoveSpeed()); // move to command { WORLD_POS[] posTarget = new WORLD_POS[1]; posTarget[0].m_fX = newMonsterMovPacket.getTargetPos().m_fX; posTarget[0].m_fZ = newMonsterMovPacket.getTargetPos().m_fZ; SCommand_Object cmdTemp = new SCommand_Object(); cmdTemp.m_wID = (int)OBJECTCOMMANDDEF.OC_MOVE; cmdTemp.SetValue <uint>(0, 0); cmdTemp.SetValue(1, newMonsterMovPacket.getHandleID()); cmdTemp.SetValue(2, 1); cmdTemp.SetValue <WORLD_POS[]>(3, posTarget); pNPC.PushCommand(cmdTemp); } //放入Ask队列 pObjectManager.LoadQueue.TryAddLoadTask(pNPC.ID); //tempcode // { // //此版不做服务器繁忙客户端延后发消息的处理 // CGCharAskBaseAttrib msgAskBaseAttrib = new CGCharAskBaseAttrib(); // msgAskBaseAttrib.setTargetID( (uint)(int)newMonsterMovPacket.getObjID()); // GameProcedure.s_NetManager.SendPacket(msgAskBaseAttrib ); // // } pNPC.SetMsgTime(GameProcedure.s_pTimeSystem.GetTimeNow()); } return(NET_RESULT_DEFINE.PACKET_EXE.PACKET_EXE_CONTINUE);; }