1. common/service.h:
  2. #define ENABLE_BUY_WITH_ITEM
  3. common/tables.h:
  4. // Ara:
  5. typedef struct SShopItemTable
  6. // İçine ekle:
  7. #ifdef ENABLE_BUY_WITH_ITEM
  8. DWORD witemVnum;
  9. #endif
  10. game/packet.h:
  11. // Ara:
  12. SHOP_SUBHEADER_GC_NOT_ENOUGH_MONEY
  13. // Altına ekle:
  14. #ifdef ENABLE_BUY_WITH_ITEM
  15. SHOP_SUBHEADER_GC_NOT_ENOUGH_ITEM,
  16. #endif
  17. // Ara:
  18. struct packet_shop_item
  19. // İçine ekle:
  20. #ifdef ENABLE_BUY_WITH_ITEM
  21. DWORD witemVnum;
  22. #endif
  23. game/shop.cpp:
  24. // void CShop::SetShopItems(TShopItemTable * pTable, BYTE bItemCount) Fonksiyonun içinde ara:
  25. item.price = pTable->price; // yada
  26. item.count = pTable->count; // hangisi varsa
  27. // Altına ekle:
  28. #ifdef ENABLE_BUY_WITH_ITEM
  29. item.witemVnum = pTable->witemVnum;
  30. #endif
  31. // int CShop::Buy( fonksiyonunun içinde ara:
  32. DWORD dwPrice = r_item.price;
  33. // Altına ekle:
  34. #ifdef ENABLE_BUY_WITH_ITEM
  35. DWORD dwWItemVnum = r_item.witemVnum;
  36. #endif
  37. // Arat:
  38. if (ch->GetGold() < (int) dwPrice)
  39. {
  40. sys_log(1, "Shop::Buy : Not enough money : %s has %d, price %d", ch->GetName(), ch->GetGold(), dwPrice);
  41. return SHOP_SUBHEADER_GC_NOT_ENOUGH_MONEY;
  42. }
  43. // Değiştir:
  44. #ifdef ENABLE_BUY_WITH_ITEM
  45. if (dwWItemVnum > 0)
  46. if (ch->CountSpecifyItem(dwWItemVnum) < (int)dwPrice)
  47. return SHOP_SUBHEADER_GC_NOT_ENOUGH_ITEM;
  48. else if (ch->GetGold() < (int) dwPrice)
  49. #else
  50. if (ch->GetGold() < (int) dwPrice)
  51. #endif
  52. // Arat:
  53. ch->PointChange(POINT_GOLD, -dwPrice, false);
  54. // Değiştir:
  55. #ifdef ENABLE_BUY_WITH_ITEM
  56. if (dwWItemVnum > 0)
  57. ch->RemoveSpecifyItem(dwWItemVnum, dwPrice);
  58. else
  59. ch->PointChange(POINT_GOLD, -dwPrice, false);
  60. #else
  61. ch->PointChange(POINT_GOLD, -dwPrice, false);
  62. #endif
  63. // Arat:
  64. pack2.items[i].price = item.price;
  65. // Altına ekle:
  66. #ifdef ENABLE_BUY_WITH_ITEM
  67. pack2.items[i].witemVnum = item.witemVnum;
  68. #endif
  69. // Arat:
  70. else if (!m_pkPC && !IsPCShop())
  71. // İçine ekle:
  72. #ifdef ENABLE_BUY_WITH_ITEM
  73. pack2.item.witemVnum = m_itemVector[pos].witemVnum;
  74. #endif
  75. game/shop.h:
  76. // Arat:
  77. shop_item()
  78. // Üstüne ekle:
  79. #ifdef ENABLE_BUY_WITH_ITEM
  80. DWORD witemVnum;
  81. #endif
  82. // Arat:
  83. pkItem = NULL;
  84. // Üstüne ekle:
  85. #ifdef ENABLE_BUY_WITH_ITEM
  86. witemVnum = 0;
  87. #endif
  88. db/ClientManagerBoot.cpp:
  89. // Arat:
  90. "shop_item.count "
  91. // Altına ekle:
  92. #ifdef ENABLE_BUY_WITH_ITEM
  93. ",shop_item.witemVnum "
  94. #endif
  95. // Arat:
  96. str_to_number(pItem->count, data[col++]);
  97. // Altına ekle:
  98. #ifdef ENABLE_BUY_WITH_ITEM
  99. str_to_number(pItem->witemVnum, data[col++]);
  100. #endif
  101. Client Source:​
  102. Locale_inc.h:
  103. #define ENABLE_BUY_WITH_ITEM
  104. GameType.h:
  105. // Arat:
  106. typedef struct packet_shop_item
  107. // İçine ekle:
  108. #ifdef ENABLE_BUY_WITH_ITEM
  109. DWORD witemVnum;
  110. #endif
  111. PythonApplicationModule.cpp:
  112. #ifdef ENABLE_BUY_WITH_ITEM
  113. PyModule_AddIntConstant(poModule, "ENABLE_BUY_WITH_ITEM", 1);
  114. #else
  115. PyModule_AddIntConstant(poModule, "ENABLE_BUY_WITH_ITEM", 0);
  116. #endif
  117. PythonNetworkStreamPhaseGame.cpp:
  118. // Arat:
  119. case SHOP_SUBHEADER_GC_NOT_ENOUGH_MONEY:
  120. PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "OnShopError", Py_BuildValue("(s)", "NOT_ENOUGH_MONEY"));
  121. break;
  122. // Altına ekle:
  123. #ifdef ENABLE_BUY_WITH_ITEM
  124. case SHOP_SUBHEADER_GC_NOT_ENOUGH_ITEM:
  125. PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "OnShopError", Py_BuildValue("(s)", "NOT_ENOUGH_ITEM"));
  126. break;
  127. #endif
  128. PythonShop.cpp:
  129. // Arat:
  130. PyObject * shopGetItemMetinSocket(PyObject * poSelf, PyObject * poArgs)
  131. // Altına ekle:
  132. #ifdef ENABLE_BUY_WITH_ITEM
  133. PyObject * shopGetBuyWithItem(PyObject * poSelf, PyObject * poArgs)
  134. {
  135. int nPos;
  136. if (!PyTuple_GetInteger(poArgs, 0, &nPos))
  137. return Py_BuildException();
  138. const TShopItemData * c_pItemData;
  139. if (CPythonShop::Instance().GetItemData(nPos, &c_pItemData))
  140. return Py_BuildValue("i", c_pItemData->witemVnum);
  141. return Py_BuildValue("i", 0);
  142. }
  143. #endif
  144. // Arat:
  145. { "GetItemMetinSocket", shopGetItemMetinSocket, METH_VARARGS },
  146. // Altına ekle:
  147. #ifdef ENABLE_BUY_WITH_ITEM
  148. { "GetBuyWithItem", shopGetBuyWithItem, METH_VARARGS },
  149. #endif
  150. Packet.h:
  151. // Arat:
  152. typedef struct SShopItemTable
  153. // İçine ekle:
  154. #ifdef ENABLE_BUY_WITH_ITEM
  155. DWORD witemVnum;
  156. #endif
  157. // Arat:
  158. SHOP_SUBHEADER_GC_NOT_ENOUGH_MONEY,
  159. // Altına ekle:
  160. #ifdef ENABLE_BUY_WITH_ITEM
  161. SHOP_SUBHEADER_GC_NOT_ENOUGH_ITEM,
  162. #endif
  163. Python:​
  164. root/localeinfo.py:
  165. # Arat:
  166. SHOP_ERROR_DICT = {
  167. # Altına veya üstüne ekle:
  168. if app.ENABLE_BUY_WITH_ITEM:
  169. SHOP_ERROR_DICT.update({
  170. "NOT_ENOUGH_ITEM" : SHOP_NOT_ENOUGH_ITEM,
  171. }
  172. )
  173. # Arat:
  174. def NumberToMoneyString(n):
  175. # Altına ekle:
  176. if app.ENABLE_BUY_WITH_ITEM:
  177. def NumberToWithItemString(n,c) :
  178. if n <= 0 :
  179. return "0 %s" % (c)
  180. 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)
  181. root/uishop.py:
  182. # def AskBuyItem(self, slotPos): fonksiyonu içinde ara:
  183. itemBuyQuestionDialog.SetText(localeInfo.DO_YOU_BUY_ITEM(itemName, itemCount, localeInfo.NumberToMoneyString(itemPrice)))
  184. # Değiştir:
  185. if app.ENABLE_BUY_WITH_ITEM:
  186. buyItemVnum = shop.GetBuyWithItem(slotPos)
  187. if buyItemVnum != 0:
  188. item.SelectItem(buyItemVnum)
  189. istenenItemAd = item.GetItemName()
  190. itemBuyQuestionDialog.SetText(localeInfo.DO_YOU_BUY_ITEM(itemName, itemCount, localeInfo.NumberToWithItemString(itemPrice, istenenItemAd)))
  191. else:
  192. itemBuyQuestionDialog.SetText(localeInfo.DO_YOU_BUY_ITEM(itemName, itemCount, localeInfo.NumberToMoneyString(itemPrice)))
  193. else:
  194. itemBuyQuestionDialog.SetText(localeInfo.DO_YOU_BUY_ITEM(itemName, itemCount, localeInfo.NumberToMoneyString(itemPrice)))
  195. root/uitooltip.py:
  196. # def SetShopItem veya shopEx kullananlar için SetShopExItem fonksiyonu içinde ara:
  197. else:
  198. self.AppendPrice(price)
  199. # Değiştir:
  200. elif app.ENABLE_BUY_WITH_ITEM:
  201. buyItemVnum = shop.GetBuyWithItem(slotIndex)
  202. if buyItemVnum != 0:
  203. item.SelectItem(buyItemVnum)
  204. istenenItemAd = item.GetItemName()
  205. istenenItemVnum = item.GetVnum()
  206. self.AppendPrice_WithItem(price, istenenItemVnum, istenenItemAd)
  207. else:
  208. self.AppendPrice(price)
  209. else:
  210. self.AppendPrice(price)
  211. # Müsait bir yere ekle:
  212. if app.ENABLE_BUY_WITH_ITEM:
  213. def AppendTextLine_WithItem(self, text, image, color = FONT_COLOR):
  214. ayraC = text.split("|")
  215. resimdenOnce, resimdenSonra = (ayraC[0], ayraC[1])
  216. textLine = ui.TextLine()
  217. textLine.SetParent(self)
  218. textLine.SetFontName(self.defFontName)
  219. textLine.SetPackedFontColor(color)
  220. textLine.SetText(resimdenOnce)
  221. textLine.SetOutline()
  222. textLine.SetFeather(FALSE)
  223. itemIcon = ui.ImageBox()
  224. itemIcon.SetParent(self)
  225. itemIcon.LoadImage(image)
  226. textLine2 = ui.TextLine()
  227. textLine2.SetParent(self)
  228. textLine2.SetFontName(self.defFontName)
  229. textLine2.SetPackedFontColor(color)
  230. textLine2.SetText(resimdenSonra)
  231. textLine2.SetOutline()
  232. textLine2.SetFeather(FALSE)
  233. textLine.Show()
  234. itemIcon.Show()
  235. textLine2.Show()
  236. baslangicX_a = self.GetWidth() / 2 - 75
  237. baslangicX_b = textLine.GetTextSize()[0]
  238. baslangicX_c = itemIcon.GetWidth()
  239. textLine.SetPosition(baslangicX_a, self.toolTipHeight+6)
  240. itemIcon.SetPosition(baslangicX_a + baslangicX_b, self.toolTipHeight)
  241. textLine2.SetPosition(baslangicX_a + baslangicX_b + baslangicX_c, self.toolTipHeight+6)
  242. self.childrenList.append(textLine)
  243. self.childrenList.append(itemIcon)
  244. self.childrenList.append(textLine2)
  245. self.toolTipHeight += itemIcon.GetHeight()
  246. self.ResizeToolTip()
  247. return textLine
  248. return itemIcon
  249. return textLine2
  250. if app.ENABLE_BUY_WITH_ITEM:
  251. def AppendPrice_WithItem(self, price, itemVnum, itemName):
  252. self.AppendSpace(5)
  253. self.AppendTextLine("[Nesne ile satın alınabilir]" , self.SHOP_ITEM_COLOR)
  254. item.SelectItem(itemVnum)
  255. eklenecekIcon = item.GetIconImageFileName()
  256. self.AppendTextLine_WithItem((localeInfo.NumberToWithItemString(price, itemName)), eklenecekIcon, self.GetPriceColor(price))
  257. locale/locale_game.txt:
  258. SHOP_NOT_ENOUGH_ITEM Yeterli Nesne'ye sahip değilsin.