PyObject * playerCanAttachMetin(PyObject* poSelf, PyObject* poArgs)
{
int iMetinItemID;
TItemPos TargetSlotIndex;
switch (PyTuple_Size(poArgs))
{
case 2:
if (!PyTuple_GetInteger(poArgs, 0, &iMetinItemID))
return Py_BuildException();
if (!PyTuple_GetInteger(poArgs, 1, &TargetSlotIndex.cell))
return Py_BuildException();
break;
case 3:
if (!PyTuple_GetInteger(poArgs, 0, &iMetinItemID))
return Py_BuildException();
if (!PyTuple_GetInteger(poArgs, 1, &TargetSlotIndex.window_type))
return Py_BuildException();
if (!PyTuple_GetInteger(poArgs, 2, &TargetSlotIndex.cell))
return Py_BuildException();
break;
default:
return Py_BuildException();
}
if (CPythonPlayer::Instance().IsEquipmentSlot(TargetSlotIndex))
{
return Py_BuildValue("i", ATTACH_METIN_CANT_ATTACH_TO_EQUIPMENT);
}
CItemData * pMetinItemData;
if (!CItemManager::Instance().GetItemDataPointer(iMetinItemID, &pMetinItemData))
return Py_BuildException("can't find item data");
DWORD dwTargetItemIndex = CPythonPlayer::Instance().GetItemIndex(TargetSlotIndex);
CItemData * pTargetItemData;
if (!CItemManager::Instance().GetItemDataPointer(dwTargetItemIndex, &pTargetItemData))
return Py_BuildException("can't find item data");
DWORD dwMetinWearFlags = pMetinItemData->GetWearFlags();
DWORD dwTargetWearFlags = pTargetItemData->GetWearFlags();
if (0 == (dwMetinWearFlags & dwTargetWearFlags))
return Py_BuildValue("i", ATTACH_METIN_NOT_MATCHABLE_ITEM);
if (CItemData::ITEM_TYPE_ROD == pTargetItemData->GetType())
return Py_BuildValue("i", ATTACH_METIN_CANT);
BOOL bNotExistGoldSocket = FALSE;
int iSubType = pMetinItemData->GetSubType();
for (int i = 0; i < ITEM_SOCKET_SLOT_MAX_NUM; ++i)
{
DWORD dwSocketType = CPythonPlayer::Instance().GetItemMetinSocket(TargetSlotIndex, i);
if (CItemData::METIN_NORMAL == iSubType)
{
if (CPythonPlayer::METIN_SOCKET_TYPE_SILVER == dwSocketType ||
CPythonPlayer::METIN_SOCKET_TYPE_GOLD == dwSocketType)
{
return Py_BuildValue("i", ATTACH_METIN_OK);
}
}
else if (CItemData::METIN_GOLD == iSubType)
{
if (CPythonPlayer::METIN_SOCKET_TYPE_GOLD == dwSocketType)
{
return Py_BuildValue("i", ATTACH_METIN_OK);
}
else if (CPythonPlayer::METIN_SOCKET_TYPE_SILVER == dwSocketType)
{
bNotExistGoldSocket = TRUE;
}
}
}
if (bNotExistGoldSocket)
{
return Py_BuildValue("i", ATTACH_METIN_NOT_EXIST_GOLD_SOCKET);
}
return Py_BuildValue("i", ATTACH_METIN_NO_MATCHABLE_SOCKET);
}
Paste Hosted With By Wklejamy.pl