Öncelikle biraz sistemden bahsedeyim. Biliyorsunuz rubinum yıl dönümü parası gibi birçok itemi başka itemler karşılığında satıyor. Örnek resimdeki gibi...
common/service.h:
common/tables.h:
game/packet.h:
game/shop.cpp:
game/shop.h:
db/ClientManagerBoot.cpp:
GameType.h:
PythonApplicationModule.cpp:
PythonNetworkStreamPhaseGame.cpp:
PythonShop.cpp:
Packet.h:
root/uishop.py:
root/uitooltip.py:
locale/locale_game.txt:
common/service.h:
C++:
#define ENABLE_BUY_WITH_ITEM
common/tables.h:
C++:
// Ara:
typedef struct SShopItemTable
// İçine ekle:
#ifdef ENABLE_BUY_WITH_ITEM
DWORD witemVnum;
#endif
game/packet.h:
Kod:
// Ara:
SHOP_SUBHEADER_GC_NOT_ENOUGH_MONEY
// Altına ekle:
#ifdef ENABLE_BUY_WITH_ITEM
SHOP_SUBHEADER_GC_NOT_ENOUGH_ITEM,
#endif
// Ara:
struct packet_shop_item
// İçine ekle:
#ifdef ENABLE_BUY_WITH_ITEM
DWORD witemVnum;
#endif
game/shop.cpp:
Kod:
// void CShop::SetShopItems(TShopItemTable * pTable, BYTE bItemCount) Fonksiyonun içinde ara:
item.price = pTable->price; // yada
item.count = pTable->count; // hangisi varsa
// Altına ekle:
#ifdef ENABLE_BUY_WITH_ITEM
item.witemVnum = pTable->witemVnum;
#endif
// int CShop::Buy( fonksiyonunun içinde ara:
DWORD dwPrice = r_item.price;
// Altına ekle:
#ifdef ENABLE_BUY_WITH_ITEM
DWORD dwWItemVnum = r_item.witemVnum;
#endif
// Arat:
if (ch->GetGold() < (int) dwPrice)
{
sys_log(1, "Shop::Buy : Not enough money : %s has %d, price %d", ch->GetName(), ch->GetGold(), dwPrice);
return SHOP_SUBHEADER_GC_NOT_ENOUGH_MONEY;
}
// Değiştir:
#ifdef ENABLE_BUY_WITH_ITEM
if (dwWItemVnum > 0)
if (ch->CountSpecifyItem(dwWItemVnum) < (int)dwPrice)
return SHOP_SUBHEADER_GC_NOT_ENOUGH_ITEM;
else if (ch->GetGold() < (int) dwPrice)
#else
if (ch->GetGold() < (int) dwPrice)
#endif
// Arat:
ch->PointChange(POINT_GOLD, -dwPrice, false);
// Değiştir:
#ifdef ENABLE_BUY_WITH_ITEM
if (dwWItemVnum > 0)
ch->RemoveSpecifyItem(dwWItemVnum, dwPrice);
else
ch->PointChange(POINT_GOLD, -dwPrice, false);
#else
ch->PointChange(POINT_GOLD, -dwPrice, false);
#endif
// Arat:
pack2.items[i].price = item.price;
// Altına ekle:
#ifdef ENABLE_BUY_WITH_ITEM
pack2.items[i].witemVnum = item.witemVnum;
#endif
// Arat:
else if (!m_pkPC && !IsPCShop())
// İçine ekle:
#ifdef ENABLE_BUY_WITH_ITEM
pack2.item.witemVnum = m_itemVector[pos].witemVnum;
#endif
game/shop.h:
Kod:
// Arat:
shop_item()
// Üstüne ekle:
#ifdef ENABLE_BUY_WITH_ITEM
DWORD witemVnum;
#endif
// Arat:
pkItem = NULL;
// Üstüne ekle:
#ifdef ENABLE_BUY_WITH_ITEM
witemVnum = 0;
#endif
db/ClientManagerBoot.cpp:
Kod:
// Arat:
"shop_item.count "
// Altına ekle:
#ifdef ENABLE_BUY_WITH_ITEM
",shop_item.witemVnum "
#endif
// Arat:
str_to_number(pItem->count, data[col++]);
// Altına ekle:
#ifdef ENABLE_BUY_WITH_ITEM
str_to_number(pItem->witemVnum, data[col++]);
#endif
Client Source
Locale_inc.h:
Kod:
#define ENABLE_BUY_WITH_ITEM
GameType.h:
Kod:
// Arat:
typedef struct packet_shop_item
// İçine ekle:
#ifdef ENABLE_BUY_WITH_ITEM
DWORD witemVnum;
#endif
PythonApplicationModule.cpp:
Kod:
#ifdef ENABLE_BUY_WITH_ITEM
PyModule_AddIntConstant(poModule, "ENABLE_BUY_WITH_ITEM", 1);
#else
PyModule_AddIntConstant(poModule, "ENABLE_BUY_WITH_ITEM", 0);
#endif
PythonNetworkStreamPhaseGame.cpp:
Kod:
// Arat:
case SHOP_SUBHEADER_GC_NOT_ENOUGH_MONEY:
PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "OnShopError", Py_BuildValue("(s)", "NOT_ENOUGH_MONEY"));
break;
// Altına ekle:
#ifdef ENABLE_BUY_WITH_ITEM
case SHOP_SUBHEADER_GC_NOT_ENOUGH_ITEM:
PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "OnShopError", Py_BuildValue("(s)", "NOT_ENOUGH_ITEM"));
break;
#endif
PythonShop.cpp:
Kod:
// Arat:
PyObject * shopGetItemMetinSocket(PyObject * poSelf, PyObject * poArgs)
// Altına ekle:
#ifdef ENABLE_BUY_WITH_ITEM
PyObject * shopGetBuyWithItem(PyObject * poSelf, PyObject * poArgs)
{
int nPos;
if (!PyTuple_GetInteger(poArgs, 0, &nPos))
return Py_BuildException();
const TShopItemData * c_pItemData;
if (CPythonShop::Instance().GetItemData(nPos, &c_pItemData))
return Py_BuildValue("i", c_pItemData->witemVnum);
return Py_BuildValue("i", 0);
}
#endif
// Arat:
{ "GetItemMetinSocket", shopGetItemMetinSocket, METH_VARARGS },
// Altına ekle:
#ifdef ENABLE_BUY_WITH_ITEM
{ "GetBuyWithItem", shopGetBuyWithItem, METH_VARARGS },
#endif
Packet.h:
Kod:
// Arat:
typedef struct SShopItemTable
// İçine ekle:
#ifdef ENABLE_BUY_WITH_ITEM
DWORD witemVnum;
#endif
// Arat:
SHOP_SUBHEADER_GC_NOT_ENOUGH_MONEY,
// Altına ekle:
#ifdef ENABLE_BUY_WITH_ITEM
SHOP_SUBHEADER_GC_NOT_ENOUGH_ITEM,
#endif
Pack
root/localeinfo.py:
Kod:
# Arat:
SHOP_ERROR_DICT = {
# Altına veya üstüne ekle:
if app.ENABLE_BUY_WITH_ITEM:
SHOP_ERROR_DICT.update({
"NOT_ENOUGH_ITEM" : SHOP_NOT_ENOUGH_ITEM,
}
)
# Arat:
def NumberToMoneyString(n):
# Altına ekle:
if app.ENABLE_BUY_WITH_ITEM:
def NumberToWithItemString(n,c) :
if n <= 0 :
return "0 %s" % (c)
return "%s adet | %s" % ('.'.join([ i-3<0 and str(n)[:i] or str(n)[i-3:i] for i in range(len(str(n))%3, len(str(n))+1, 3) if i ]), c)
root/uishop.py:
Kod:
# def AskBuyItem(self, slotPos): fonksiyonu içinde ara:
itemBuyQuestionDialog.SetText(localeInfo.DO_YOU_BUY_ITEM(itemName, itemCount, localeInfo.NumberToMoneyString(itemPrice)))
# Değiştir:
if app.ENABLE_BUY_WITH_ITEM:
buyItemVnum = shop.GetBuyWithItem(slotPos)
if buyItemVnum != 0:
item.SelectItem(buyItemVnum)
istenenItemAd = item.GetItemName()
itemBuyQuestionDialog.SetText(localeInfo.DO_YOU_BUY_ITEM(itemName, itemCount, localeInfo.NumberToWithItemString(itemPrice, istenenItemAd)))
else:
itemBuyQuestionDialog.SetText(localeInfo.DO_YOU_BUY_ITEM(itemName, itemCount, localeInfo.NumberToMoneyString(itemPrice)))
else:
itemBuyQuestionDialog.SetText(localeInfo.DO_YOU_BUY_ITEM(itemName, itemCount, localeInfo.NumberToMoneyString(itemPrice)))
root/uitooltip.py:
Kod:
# def SetShopItem veya shopEx kullananlar için SetShopExItem fonksiyonu içinde ara:
else:
self.AppendPrice(price)
# Değiştir:
elif app.ENABLE_BUY_WITH_ITEM:
buyItemVnum = shop.GetBuyWithItem(slotIndex)
if buyItemVnum != 0:
item.SelectItem(buyItemVnum)
istenenItemAd = item.GetItemName()
istenenItemVnum = item.GetVnum()
self.AppendPrice_WithItem(price, istenenItemVnum, istenenItemAd)
else:
self.AppendPrice(price)
else:
self.AppendPrice(price)
# Müsait bir yere ekle:
if app.ENABLE_BUY_WITH_ITEM:
def AppendTextLine_WithItem(self, text, image, color = FONT_COLOR):
ayraC = text.split("|")
resimdenOnce, resimdenSonra = (ayraC[0], ayraC[1])
textLine = ui.TextLine()
textLine.SetParent(self)
textLine.SetFontName(self.defFontName)
textLine.SetPackedFontColor(color)
textLine.SetText(resimdenOnce)
textLine.SetOutline()
textLine.SetFeather(FALSE)
itemIcon = ui.ImageBox()
itemIcon.SetParent(self)
itemIcon.LoadImage(image)
textLine2 = ui.TextLine()
textLine2.SetParent(self)
textLine2.SetFontName(self.defFontName)
textLine2.SetPackedFontColor(color)
textLine2.SetText(resimdenSonra)
textLine2.SetOutline()
textLine2.SetFeather(FALSE)
textLine.Show()
itemIcon.Show()
textLine2.Show()
baslangicX_a = self.GetWidth() / 2 - 75
baslangicX_b = textLine.GetTextSize()[0]
baslangicX_c = itemIcon.GetWidth()
textLine.SetPosition(baslangicX_a, self.toolTipHeight+6)
itemIcon.SetPosition(baslangicX_a + baslangicX_b, self.toolTipHeight)
textLine2.SetPosition(baslangicX_a + baslangicX_b + baslangicX_c, self.toolTipHeight+6)
self.childrenList.append(textLine)
self.childrenList.append(itemIcon)
self.childrenList.append(textLine2)
self.toolTipHeight += itemIcon.GetHeight()
self.ResizeToolTip()
return textLine
return itemIcon
return textLine2
if app.ENABLE_BUY_WITH_ITEM:
def AppendPrice_WithItem(self, price, itemVnum, itemName):
self.AppendSpace(5)
self.AppendTextLine("[Nesne ile satın alınabilir]" , self.SHOP_ITEM_COLOR)
item.SelectItem(itemVnum)
eklenecekIcon = item.GetIconImageFileName()
self.AppendTextLine_WithItem((localeInfo.NumberToWithItemString(price, itemName)), eklenecekIcon, self.GetPriceColor(price))
locale/locale_game.txt:
C++:
SHOP_NOT_ENOUGH_ITEM Yeterli Nesne'ye sahip değilsin.