// 一键换装:保存装备 INT QuickChange::Lua_SaveSuit( LuaPlus::LuaState* state ) { LuaStack args(state); if( !args[ 2 ].IsInteger() ) return 0; if( !args[ 3 ].IsInteger() ) return 0; int isSend = args[ 2 ].GetInteger(); // 是否发送 int suitId = args[ 3 ].GetInteger(); // 套装id // 填充需要保存的装备guid if( isSend == 0 ) { int idx = args[ 4 ].GetInteger(); // 一套中的装备点 // server guid int world = args[ 5 ].GetInteger(); int server = args[ 6 ].GetInteger(); int serial = args[ 7 ].GetInteger(); int index = args[ 8 ].GetInteger(); // 一套中的套装索引 // 读取装备guid CCharacterData* pData = ((CObject_Character*)CObjectManager::GetMe()->GetMySelf())->GetCharacterData(); if( index == 0 ) { _SUIT_SETTING aSuit; pData->Set_EquipSuit(suitId, aSuit); } _SUIT_SETTING aSuit = pData->Get_EquipSuit(suitId); if( world == -1 ) { return 0; } // 设置装备guid _ITEM_GUID item_guid; item_guid.m_World = (BYTE)world; item_guid.m_Server = (BYTE)server; item_guid.m_Serial = (INT)serial; aSuit.m_EquipData[idx] = item_guid; pData->Set_EquipSuit(suitId, aSuit); } // 发送保存装备消息 else if( isSend == 1 ) { char* name = (char*)args[ 4 ].GetString(); // 套装名字 CCharacterData* pData = ((CObject_Character*)CObjectManager::GetMe()->GetMySelf())->GetCharacterData(); _SUIT_SETTING aSuit = pData->Get_EquipSuit(suitId); sprintf( aSuit.m_SuitName, name, sizeof(CHAR)*MAX_SUIT_NAME_SIZE ); pData->Set_EquipSuit(suitId, aSuit); CGameInterface::GetMe()->PacketItem_SaveSuit(suitId); } return 0; }
//一键换装:得到装备套装的名字 INT QuickChange::Lua_GetSuitName( LuaPlus::LuaState* state ) { LuaStack args(state); if( !(args[2].IsInteger()) )return 0; INT suitId = args[2].GetInteger(); // 读取装备guid CCharacterData* pData = ((CObject_Character*)CObjectManager::GetMe()->GetMySelf())->GetCharacterData(); _SUIT_SETTING aSuit = pData->Get_EquipSuit(suitId); state->PushString( aSuit.m_SuitName ); return 1; }
INT SuperTooltips::GetItemDesc(LuaPlus::LuaState* state) { // 不利用保存的指针。要重新得到指针。 m_pActionItem = (CActionItem*)CActionSystem::GetMe()->GetAction(m_nActionId); if(!m_pActionItem) { state->PushString(""); return 1; } STRING type( m_pActionItem->GetType_String() ); if( type == "changesuit" ) { CCharacterData* pData = ((CObject_Character*)CObjectManager::GetMe()->GetMySelf())->GetCharacterData(); INT id = pData->Get_EquipSuitId(); _SUIT_SETTING aSuit = pData->Get_EquipSuit( id ); STRING name(aSuit.m_SuitName); if( !name.empty() ) { CHAR szTemp[100]; _snprintf(szTemp, 10, "%s套装", name.c_str()); state->PushString(szTemp); } else { CHAR szTemp[100]; _snprintf(szTemp, 10, "这是自定义的第%d套套装", id); state->PushString(szTemp); } return 1; } //得到详细说明. state->PushString(m_pActionItem->GetDesc()); return 1; }