//宠物休息 INT Pet::Go_Relax(LuaPlus::LuaState* state) { LuaStack args(state); if ( !args[2].IsInteger() ) { KLThrow("LUA:Pet Go_Relax parameter error"); } INT nPetNum = args[2].GetInteger(); SDATA_PET* My_Pet= CDataPool::GetMe()->Pet_GetPet(nPetNum); if( (!My_Pet) || ( !My_Pet->m_pModelData ) ) { KLThrow("LUA:Pet Go_Relax parameter error"); return 0; } //向服务器发送 CGManipulatePet Msg; Msg.SetGUID(My_Pet->m_GUID); Msg.SetManipulateType(MANIPULATE_DELETEPET); CNetManager::GetMe()->SendPacket(&Msg); return 0; }
//宠物参战 INT Pet::Go_Fight(LuaPlus::LuaState* state) { LuaStack args(state); if ( !args[2].IsInteger() ) { KLThrow("LUA:Pet Go_Fight parameter error"); } INT nPetNum = args[2].GetInteger(); SDATA_PET* My_Pet= CDataPool::GetMe()->Pet_GetPet(nPetNum); if( (!My_Pet) || ( !My_Pet->m_pModelData ) ) { KLThrow("LUA:Pet Go_Fight parameter error"); return 0; } // 如果自己正在摆摊,不能出战 if(TRUE == CObjectManager::GetMe()->GetMySelf()->GetCharacterData()->Get_IsInStall()) { STRING strTemp = ""; strTemp = NOCOLORMSGFUNC("GMAI_Base_Info_You_Stalling"); CEventSystem::GetMe()->PushEvent(GE_NEW_DEBUGMESSAGE, strTemp.c_str()); //CEventSystem::GetMe()->PushEvent(GE_NEW_DEBUGMESSAGE,"你正在摆摊……"); return 0; } //向服务器发送 CGManipulatePet Msg; Msg.SetGUID(My_Pet->m_GUID); Msg.SetManipulateType( MANIPULATE_CREATEPET ); CNetManager::GetMe()->SendPacket(&Msg); return 0; }
/* ------------------------------------------------ // 发送领取繁殖坐骑消息 参数1 nNpcSeverID ------------------------------------------------ */ INT Mount::RequestGainMatingMount(LuaPlus::LuaState* state) { LuaStack args(state); if (!(args[2].IsInteger())) { KLThrow("Mount::RequestGainMatingMount[2] param parameter error"); } INT nNpcSeverID = args[2].GetInteger(); // npc有效 tObject* pObj = CObjectManager::GetMe()->FindServerObject(nNpcSeverID); if (pObj) { /// 发送领取繁殖坐骑消息 CGManipulatePet Msg; Msg.SetCharObjID(nNpcSeverID); Msg.SetManipulateType( MANIPULATE_HORSE_MATING_RETRIEVE ); CNetManager::GetMe()->SendPacket(&Msg); } return 0; }
/* ------------------------------------------------ // 放生 参数1 GUID m_uHighSection 参数2 GUID m_uLowSection ------------------------------------------------ */ INT Mount::FreeMount(LuaPlus::LuaState* state) { LuaStack args(state); if (!(args[2].IsString())) { KLThrow("Mount::FreeMount[2] param parameter error"); } STRING szHighSection = args[2].GetString(); if (!(args[3].IsString())) { KLThrow("Mount::FreeMount[3] param parameter error"); } STRING szLowSection = args[3].GetString(); PET_GUID_t GUID; GUID.m_uHighSection = atol(szHighSection.c_str()); GUID.m_uLowSection = atol(szLowSection.c_str()); const SDATA_PET* pPet = CDataPool::GetMe()->Pet_GetPet(GUID); if (pPet && FALSE == pPet->m_GUID.IsNull()) { //向服务器发送 CGManipulatePet Msg; Msg.SetGUID(pPet->m_GUID); Msg.SetManipulateType( MANIPULATE_FREEHORSE ); CNetManager::GetMe()->SendPacket(&Msg); } return 0; }
/* ------------------------------------------------ // 上马 ------------------------------------------------ */ INT Mount::Mounting(LuaPlus::LuaState* state) { LuaStack args(state); if (!(args[2].IsInteger())) { KLThrow("Mount::Mounting[2] param parameter error"); } INT nMountIndex = args[2].GetInteger(); // 摆摊中 if( TRUE == CObjectManager::GetMe()->GetMySelf()->GetCharacterData()->Get_IsInStall() ) { return 0; } const SDATA_PET* pPet = CDataPool::GetMe()->Pet_GetPet(nMountIndex); if (pPet && FALSE == pPet->m_GUID.IsNull()) { //向服务器发送 CGManipulatePet Msg; Msg.SetGUID(pPet->m_GUID); Msg.SetManipulateType( MANIPULATE_CREATEHORSE ); CNetManager::GetMe()->SendPacket(&Msg); } return 0; }
/* ------------------------------------------------ // 发送打开繁殖界面消息 参数1 MountIndex ------------------------------------------------ */ INT Mount::RequestTogleMatingPage(LuaPlus::LuaState* state) { LuaStack args(state); if (!(args[2].IsInteger())) { KLThrow("Mount::RequestTogleMatingPage[2] param parameter error"); } INT nNpcSeverID = args[2].GetInteger(); tObject* pObj = CObjectManager::GetMe()->FindServerObject(nNpcSeverID); if (pObj) { // 发送打开界面消息 CGManipulatePet Msg; Msg.SetCharObjID(nNpcSeverID); Msg.SetManipulateType( MANIPULATE_HORSE_OPEN_MATING_UI ); CNetManager::GetMe()->SendPacket(&Msg); } else { CEventSystem::GetMe()->PushEvent(GE_NEW_DEBUGMESSAGE, "目标距离太远"); } return 0; }
/* ------------------------------------------------ // 鉴定骑宠成长率 参数1 MountIndex ------------------------------------------------ */ INT Mount::RequestIdentifyMount(LuaPlus::LuaState* state) { LuaStack args(state); if (!(args[2].IsInteger())) { KLThrow("Mount::RequestIdentifyMount[2] param parameter error"); } INT nMountIndex = args[2].GetInteger(); SDATA_PET* pPet = CDataPool::GetMe()->Pet_GetPet(nMountIndex); if (pPet && FALSE == pPet->m_GUID.IsNull()) { if (pPet->m_nUpRate < 0) { // 发送鉴定消息 CGManipulatePet Msg; Msg.SetGUID( pPet->m_GUID ); Msg.SetManipulateType( MANIPULATE_HORSE_CHECKUP ); CNetManager::GetMe()->SendPacket(&Msg); } } return 0; }
/* ------------------------------------------------ // 申请改变坐骑的名字 参数1 MountIndex 参数2 MountName ------------------------------------------------ */ INT Mount::ChangeMountName(LuaPlus::LuaState* state) { LuaStack args(state); if (!(args[2].IsInteger())) { KLThrow("Mount::ChangeMountName[2] param parameter error"); } INT nMountIndex = args[2].GetInteger(); if (!(args[3].IsString())) { KLThrow("Mount::ChangeMountName[3] param parameter error"); } STRING szNickName = args[3].GetString(); INT nNum = strlen(szNickName.c_str()); // if (nNum <= 0) { CEventSystem::GetMe()->PushEvent(GE_NEW_DEBUGMESSAGE, "名字不能为空"); return 0; } // 名字最大长度 if (nNum >= MAX_NICK_NAME-1) { CEventSystem::GetMe()->PushEvent(GE_NEW_DEBUGMESSAGE, "名字字数过长"); return 0; } SDATA_PET* pPet = CDataPool::GetMe()->Pet_GetPet(nMountIndex); if (pPet && FALSE == pPet->m_GUID.IsNull()) { // 和当前名不一样 if (0 != strcmp(szNickName.c_str(), pPet->m_szNickname.c_str())) { // 发送改名消息 CGManipulatePet Msg; Msg.SetGUID( pPet->m_GUID ); Msg.SetNickName(szNickName.c_str()); Msg.SetManipulateType( MANIPULATE_HORSE_NICKNAME ); CNetManager::GetMe()->SendPacket(&Msg); } } return 0; }
/* ------------------------------------------------ // 下马 ------------------------------------------------ */ INT Mount::Dismount(LuaPlus::LuaState* state) { if (NULL != CObjectManager::GetMe()->GetMySelf()->GetCharacterData()) { INT nMount = CObjectManager::GetMe()->GetMySelf()->GetCharacterData()->Get_MountID(); if (nMount > 0) { //向服务器发送 CGManipulatePet Msg; Msg.SetGUID( CObjectManager::GetMe()->GetMySelf()->GetCharacterData()->Get_CurrentPetGUID() ); Msg.SetManipulateType( MANIPULATE_DELETEHORSE ); CNetManager::GetMe()->SendPacket(&Msg); } } return 0; }
//宠物放生 INT Pet::Go_Free(LuaPlus::LuaState* state) { LuaStack args(state); if ( !args[2].IsInteger() ) { KLThrow("LUA:Pet Go_Free parameter error"); } INT nPetNum = args[2].GetInteger(); SDATA_PET* My_Pet= CDataPool::GetMe()->Pet_GetPet(nPetNum); if( (!My_Pet) || ( !My_Pet->m_pModelData ) ) { KLThrow("LUA:Pet Go_Free parameter error"); return 0; } if( CGameProcedure::s_pUISystem->IsWindowShow("ProgressBar") ) { STRING strMsg = COLORMSGFUNC("GMGameInterface_Script_Pet_CantFree"); //ADDTALKMSG(strMsg); ADDNEWDEBUGMSG(strMsg); return 0; } // 如果自己正在摆摊,不能放生 if(TRUE == CObjectManager::GetMe()->GetMySelf()->GetCharacterData()->Get_IsInStall()) { STRING strTemp = ""; strTemp = NOCOLORMSGFUNC("GMAI_Base_Info_You_Stalling"); CEventSystem::GetMe()->PushEvent(GE_NEW_DEBUGMESSAGE, strTemp.c_str()); //CEventSystem::GetMe()->PushEvent(GE_NEW_DEBUGMESSAGE,"你正在摆摊……"); return 0; } //向服务器发送 CGManipulatePet Msg; Msg.SetGUID(My_Pet->m_GUID); Msg.SetManipulateType( MANIPULATE_FREEPET ); CNetManager::GetMe()->SendPacket(&Msg); return 0; }
/* ------------------------------------------------ // 发送交配锁定或解锁消息 参数1 MountIndex 参数2 nLocked 解锁或加锁 ------------------------------------------------ */ INT Mount::RequestMyMountMatingLocked(LuaPlus::LuaState* state) { LuaStack args(state); if (!(args[2].IsInteger())) { KLThrow("Mount::RequestMyMountMatingLocked[2] param parameter error"); } INT nMountIndex = args[2].GetInteger(); if (!(args[3].IsInteger())) { KLThrow("Mount::RequestMyMountMatingLocked[3] param parameter error"); } INT nLocked = args[3].GetInteger(); // 发送解锁消息 if (0 == nLocked) { CGManipulatePet Msg; Msg.SetManipulateType( MANIPULATE_HORSE_MATING_UNLOCK ); CNetManager::GetMe()->SendPacket(&Msg); } // 锁定 else { SDATA_PET* pPet = CDataPool::GetMe()->Pet_GetPet(nMountIndex); if (pPet && FALSE == pPet->m_GUID.IsNull()) { CGManipulatePet Msg; Msg.SetGUID( pPet->m_GUID ); Msg.SetManipulateType( MANIPULATE_HORSE_MATING_LOCK ); CNetManager::GetMe()->SendPacket(&Msg); } } return 0; }
/* ------------------------------------------------ // 请求目标骑宠属性 ------------------------------------------------ */ INT Mount::TargetMountAttrRequest(LuaPlus::LuaState* state) { tObject* pObj = CObjectManager::GetMe()->GetMainTarget(); if (pObj && g_theKernel.IsKindOf(pObj->GetClass(), GETCLASS(CObject_PlayerOther))) { CObject_PlayerOther* pOtherPlayer = (CObject_PlayerOther*)pObj; if (0 < pOtherPlayer->GetCharacterData()->Get_MountID()) { // 发送 请求目标骑宠属性消息 CGManipulatePet Msg; Msg.SetObjID(pOtherPlayer->GetServerID()); Msg.SetCharObjID(CObjectManager::GetMe()->GetMySelf()->GetServerID()); Msg.SetManipulateType(MANIPULATE_ASKOTHERPETINFO); CNetManager::GetMe()->SendPacket(&Msg); } } return 0; }
/* ------------------------------------------------ // 使用物品 参数1 ActionItemID 参数2 MountIndex ------------------------------------------------ */ INT Mount::UseMountItem(LuaPlus::LuaState* state) { LuaStack args(state); if (!(args[2].IsInteger())) { KLThrow("Mount::UseMountItem[2] param parameter error"); } INT nActionItemID = args[2].GetInteger(); if (!(args[3].IsInteger())) { KLThrow("Mount::UseMountItem[3] param parameter error"); } INT nMountIndex = args[3].GetInteger(); // 骑宠有效 SDATA_PET* pPet = CDataPool::GetMe()->Pet_GetPet(nMountIndex); if (NULL == pPet) return 0; // 物品有效 if (-1 == nActionItemID) return 0; tActionItem* pAction = CActionSystem::GetMe()->GetAction(nActionItemID); if (NULL == pAction) return 0; if (AOT_ITEM != pAction->GetType()) return 0; CActionItem_Item* pActionItem = (CActionItem_Item*)pAction; // 是坐骑物品 tObject_Item *pObj = pActionItem->GetItemImpl(); if(pObj && pObj->GetItemClass() == ICLASS_COMITEM) { CObject_Item_Medicine* pMedicine_Item = (CObject_Item_Medicine*)pObj; if (pMedicine_Item->GetItemTableType() == COMMON_HORSE_ITEM) { // 发送物品使用消息 CGManipulatePet Msg; Msg.SetGUID( pPet->m_GUID ); Msg.SetItemID( pMedicine_Item->GetIdTable() ); Msg.SetTypeData( pMedicine_Item->GetNumber() ); Msg.SetManipulateType( MANIPULATE_HORSE_ITEM ); Msg.SetBagIndex(pMedicine_Item->GetPosIndex()); CNetManager::GetMe()->SendPacket(&Msg); } } return 0; }
/* ------------------------------------------------ // 发送确认或取消交配消息 参数1 MountIndex 参数2 nOK 确认或取消 参数3 nNpcSeverID ------------------------------------------------ */ INT Mount::RequestMating(LuaPlus::LuaState* state) { LuaStack args(state); if (!(args[2].IsInteger())) { KLThrow("Mount::RequestMyMountMatingLocked[2] param parameter error"); } INT nMountIndex = args[2].GetInteger(); if (!(args[3].IsInteger())) { KLThrow("Mount::RequestMating[3] param parameter error"); } INT nOK = args[3].GetInteger(); if (!(args[4].IsInteger())) { KLThrow("Mount::RequestMating[4] param parameter error"); } INT nNpcSeverID = args[4].GetInteger(); if (TRUE == nOK) { // 发送确认消息 SDATA_PET* pPet = CDataPool::GetMe()->Pet_GetPet(nMountIndex); if (pPet && FALSE == pPet->m_GUID.IsNull()) { CGManipulatePet Msg; Msg.SetGUID( pPet->m_GUID ); Msg.SetCharObjID(nNpcSeverID); Msg.SetManipulateType( MANIPULATE_HORSE_MATING_CONFIRM ); CNetManager::GetMe()->SendPacket(&Msg); } } else { // 发送取消消息 CGManipulatePet Msg; Msg.SetManipulateType( MANIPULATE_HORSE_MATING_CANCEL ); CNetManager::GetMe()->SendPacket(&Msg); } return 0; }