int shouldBank(CConfigData *config) { CMemReader& reader = CMemReader::getMemReader(); CTibiaCharacter self; reader.readSelfCharacter(& self); int belowCaps = self.cap < config->capsLimit; int goldId = CTibiaItem::getValueForConst("GP"); int platId = CTibiaItem::getValueForConst("PlatinumCoin"); int crystalId = CTibiaItem::getValueForConst("CrystalCoin"); int goldCount = countAllItemsOfType(goldId, true); int platCount = countAllItemsOfType(platId, true); int crystalCount = countAllItemsOfType(crystalId, true); int totalCash = goldCount + platCount * 100 + crystalCount * 10000; int canChange = goldCount >= 100 || platCount >= 100; if (belowCaps) if (!config->changeGold && totalCash > config->cashOnHand || config->changeGold && canChange) return 1; if (!config->changeGold) { if (totalCash >= config->minimumGoldToBank || totalCash < config->cashOnHand && config->drawUpTo) return 1; else return 0; } return 0; }
int changeGold() { CMemReader& reader = CMemReader::getMemReader(); CTibiaCharacter self; reader.readSelfCharacter(& self); float origcaps = self.cap; int retval = 0; int goldId = CTibiaItem::getValueForConst("GP"); int goldCount = countAllItemsOfType(goldId, true); char buf[128]; Sleep(RandomTimeBankerSay(strlen("hi"))); CPackSender::say("hi"); Sleep(500);//Give time for NPC window to open if (goldCount >= 100) { Sleep(RandomTimeBankerSay(strlen("change gold"))); CPackSender::sayNPC("change gold"); sprintf(buf, "%d", goldCount / 100); Sleep(RandomTimeBankerSay(strlen(buf))); CPackSender::sayNPC(buf); Sleep(RandomTimeBankerSay(strlen("yes"))); CPackSender::sayNPC("yes"); } if (CModuleUtil::waitForCapsChange(origcaps)) retval = 1; int platId = CTibiaItem::getValueForConst("PlatinumCoin"); int platCount = countAllItemsOfType(platId, true); if (platCount >= 100) { Sleep(RandomTimeBankerSay(strlen("change platinum"))); CPackSender::sayNPC("change platinum"); Sleep(RandomTimeBankerSay(strlen("crystal"))); CPackSender::sayNPC("crystal"); sprintf(buf, "%d", platCount / 100); Sleep(RandomTimeBankerSay(strlen(buf))); CPackSender::sayNPC(buf); Sleep(RandomTimeBankerSay(strlen("yes"))); CPackSender::sayNPC("yes"); } if (CModuleUtil::waitForCapsChange(origcaps)) retval = 1; return retval; }
int buyItems(CConfigData *config, int traderNum) { CMemReaderProxy reader; CPackSenderProxy sender; CTibiaItemProxy itemProxy; int itemCount, goldCount; int done = -1; if (itemProxy.getItemId(config->buyItem[traderNum].tradeItem[0].itemName)==0) return 1; int objectId; //char buf[64]; Sleep (RandomTimeSellerSay(strlen("hi"))); sender.say("hi"); Sleep (800);//Give time for NPC window to open Sleep (RandomTimeSellerSay(strlen("trade"))); sender.sayNPC("trade"); Sleep (RandomTimeSeller()); for (int j = 0; j < 32; j++) { objectId = itemProxy.getItemId(config->buyItem[traderNum].tradeItem[j].itemName); //sprintf(buf, "Item Name: %s", config->buyItem[traderNum].tradeItem[j].itemName); //AfxMessageBox(buf); if (objectId) itemCount = countAllItemsOfType(objectId,true); else break; goldCount = countAllItemsOfType(itemProxy.getValueForConst("GP"),true); goldCount += countAllItemsOfType(itemProxy.getValueForConst("PlatinumCoin"),true) * 100; goldCount += countAllItemsOfType(itemProxy.getValueForConst("CrystalCoin"),true) * 10000; itemCount = config->buyItem[traderNum].tradeItem[j].quantityBuySell - itemCount; itemCount = goldCount / config->buyItem[traderNum].tradeItem[j].salePrice >= itemCount?itemCount:goldCount / config->buyItem[traderNum].tradeItem[j].salePrice; //sprintf(buf, "Item: %d\nGold: %d\nCount: %d",objectId, goldCount, itemCount); //AfxMessageBox(buf); if (itemCount > 0) { CTibiaCharacter *self = reader.readSelfCharacter(); sender.npcBuy(objectId, itemCount, 0, 0); Sleep (RandomTimeSeller()); if (CModuleUtil::waitForCapsChange(self->cap)) { if (done!=0) done = 1; } else done =0; delete self; } } return done==1?1:0; }
bool shouldGo(CConfigData *config) { //char buf[64]; CTibiaItemProxy itemProxy; CMemReaderProxy reader; CTibiaCharacter *self = reader.readSelfCharacter(); int count = 0; bool should = false; for (int i = 0; i < MAX_SELLERS; i++) { if (config->sellOnCap && self->cap < config->sellWhen && individualShouldGo(config, i)) {delete self; return true;} if (config->sellOnSpace && !spaceAvailable() && individualShouldGo(config, i)) {delete self; return true;} for (int j = 0; j < 32; j++) { int objectId = itemProxy.getItemId(config->sellItem[i].tradeItem[j].itemName); if (objectId) { //sprintf(buf, "%s\nItem count: %d\nTrigger Quantity: %d", config->sellItem[i].tradeItem[j].itemName, countAllItemsOfType(objectId), config->sellItem[i].tradeItem[j].quantityBuySell); //AfxMessageBox(buf); count = countAllItemsOfType(objectId); if (count && count >= config->sellItem[i].tradeItem[j].quantityBuySell) should = true; } } for (j = 0; j < 32; j++) { int objectId = itemProxy.getItemId(config->buyItem[i].tradeItem[j].itemName); if (objectId) { //sprintf(buf, "%s\nItem count: %d\nTrigger Quantity: %d", config->sellItem[i].tradeItem[j].itemName, countAllItemsOfType(objectId), config->sellItem[i].tradeItem[j].quantityBuySell); //AfxMessageBox(buf); count = countAllItemsOfType(itemProxy.getValueForConst("GP"),true); count += countAllItemsOfType(itemProxy.getValueForConst("PlatinumCoin"),true) * 100; count += countAllItemsOfType(itemProxy.getValueForConst("CrystalCoin"),true) * 10000; if (countAllItemsOfType(objectId,true) < config->buyItem[i].tradeItem[j].triggerQuantity && count >= config->buyItem[i].tradeItem[j].salePrice) should = true; } } } // should?AfxMessageBox("Should go"):AfxMessageBox("Should not go"); delete self; return should; }
int individualShouldGo(CConfigData *config, int traderNum) { //char buf[64]; CTibiaItemProxy itemProxy; CMemReaderProxy reader; int ret = NOGO; for (int j = 0; j < 32; j++) { int objectId = itemProxy.getItemId(config->sellItem[traderNum].tradeItem[j].itemName); if (!objectId) break; //sprintf(buf, "Seller: %d\nObjectID: %d", traderNum+1, objectId); //AfxMessageBox(buf); if (objectId && countAllItemsOfType(objectId) > 0) ret = SELLONLY; } int count = -1; for (j = 0; j < 32; j++) { int objectId = itemProxy.getItemId(config->buyItem[traderNum].tradeItem[j].itemName); if (!objectId) break; //sprintf(buf, "Seller: %d\nObjectID: %d", traderNum+1, objectId); //AfxMessageBox(buf); if (count==-1){ count = countAllItemsOfType(itemProxy.getValueForConst("GP"),true); count += countAllItemsOfType(itemProxy.getValueForConst("PlatinumCoin"),true) * 100; count += countAllItemsOfType(itemProxy.getValueForConst("CrystalCoin"),true) * 10000; } if (objectId && countAllItemsOfType(objectId,true) < config->buyItem[traderNum].tradeItem[j].quantityBuySell && count >= config->buyItem[traderNum].tradeItem[j].salePrice) { if (ret == SELLONLY) ret = DOBOTH; else ret = BUYONLY; } } // if (ret == NOGO) AfxMessageBox("No business for this seller."); // if (ret == BUYONLY) AfxMessageBox("No SELL business for this seller."); // if (ret == SELLONLY) AfxMessageBox("No BUY business for this seller."); // if (ret == DOBOTH) AfxMessageBox("We have business for this seller."); return ret; }
int canBank(CConfigData *config) { CMemReader& reader = CMemReader::getMemReader(); CTibiaCharacter self; reader.readSelfCharacter(& self); int goldId = CTibiaItem::getValueForConst("GP"); int platId = CTibiaItem::getValueForConst("PlatinumCoin"); int crystalId = CTibiaItem::getValueForConst("CrystalCoin"); int goldCount = countAllItemsOfType(goldId, true); int platCount = countAllItemsOfType(platId, true); int crystalCount = countAllItemsOfType(crystalId, true); int totalCash = goldCount + platCount * 100 + crystalCount * 10000; int canChange = goldCount >= 100 || platCount >= 100; if (!config->changeGold && (totalCash > config->cashOnHand || totalCash < config->cashOnHand && config->drawUpTo) || config->changeGold && canChange) return 1; return 0; }
int depositGold() { CMemReader& reader = CMemReader::getMemReader(); CTibiaCharacter self; reader.readSelfCharacter(& self); float origcaps = self.cap; int moneycount = countAllItemsOfType(CTibiaItem::getValueForConst("GP"), true); moneycount += countAllItemsOfType(CTibiaItem::getValueForConst("PlatinumCoin"), true) * 100; moneycount += countAllItemsOfType(CTibiaItem::getValueForConst("CrystalCoin"), true) * 10000; Sleep(RandomTimeBankerSay(strlen("hi"))); CPackSender::say("hi"); Sleep(500);//Give time for NPC window to open Sleep(RandomTimeBankerSay(strlen("deposit all"))); CPackSender::sayNPC("deposit all"); Sleep(RandomTimeBankerSay(strlen("yes"))); CPackSender::sayNPC("yes"); if (CModuleUtil::waitForCapsChange(origcaps) || moneycount == 0)//return success if caps changed or if we might have had no money to begin with return 1; return 0; }
bool canGo(CConfigData *config) { CTibiaItemProxy itemProxy; CMemReaderProxy reader; int count = 0; for (int i = 0; i < MAX_SELLERS; i++) { //see if there's anything to for (int j = 0; j < 32; j++) { int objectId = itemProxy.getItemId(config->sellItem[i].tradeItem[j].itemName); if (objectId) { //sprintf(buf, "%s\nItem count: %d\nTrigger Quantity: %d", config->sellItem[i].tradeItem[j].itemName, countAllItemsOfType(objectId), config->sellItem[i].tradeItem[j].quantityBuySell); //AfxMessageBox(buf); count = countAllItemsOfType(objectId); if (count) { return true; } } } for (j = 0; j < 32; j++) { int objectId = itemProxy.getItemId(config->buyItem[i].tradeItem[j].itemName); if (objectId) { //sprintf(buf, "%s\nItem count: %d\nTrigger Quantity: %d", config->sellItem[i].tradeItem[j].itemName, countAllItemsOfType(objectId), config->sellItem[i].tradeItem[j].quantityBuySell); //AfxMessageBox(buf); count = countAllItemsOfType(itemProxy.getValueForConst("GP"),true); count += countAllItemsOfType(itemProxy.getValueForConst("PlatinumCoin"),true) * 100; count += countAllItemsOfType(itemProxy.getValueForConst("CrystalCoin"),true) * 10000; if (countAllItemsOfType(objectId,true) < config->buyItem[i].tradeItem[j].quantityBuySell && count >= config->buyItem[i].tradeItem[j].salePrice) return true; } } } // should?AfxMessageBox("Should go"):AfxMessageBox("Should not go"); return false; }
int sellItems(CConfigData *config, int traderNum) { CMemReaderProxy reader; CPackSenderProxy sender; CTibiaItemProxy itemProxy; CMemConstData memConstData = reader.getMemConstData(); CTibiaContainer *cont; int itemCount; int done = 0; if (itemProxy.getItemId(config->sellItem[traderNum].tradeItem[0].itemName)==0) return 1; Sleep (RandomTimeSellerSay(strlen("hi"))); sender.say("hi"); Sleep (800);//Give time for NPC window to open Sleep (RandomTimeSellerSay(strlen("trade"))); sender.sayNPC("trade"); Sleep (RandomTimeSeller()); for (int j = 0; j < 32; j++) { int objectId = itemProxy.getItemId(config->sellItem[traderNum].tradeItem[j].itemName); for (int contNr = 0; contNr < memConstData.m_memMaxContainers; contNr++) { cont = reader.readContainer(contNr); if (cont->flagOnOff) { int count = cont->itemsInside; for (int slotNr = count - 1; slotNr >= 0; slotNr--) { CTibiaItem *item = (CTibiaItem *)cont->items.GetAt(slotNr); if (item->objectId == objectId) { itemCount = countAllItemsOfType(objectId); CTibiaCharacter *self = reader.readSelfCharacter(); sender.npcSell(objectId, itemCount); Sleep(RandomTimeSeller()); if (CModuleUtil::waitForCapsChange(self->cap)) { done = 1; delete self; break; } delete self; done = 0; } } } delete cont; } } return done; }