本文主要是介绍追逐自己的梦想----------辅助制作第三十七课:物品购买实现,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
本次我们将对上次找到的物品商店进行遍历,然后实现物品购买功能
具体代码如下:
#define nSizeGoodsList 60
typedef struct TGoodsShopList
{TBACK_PACK_OBJ mtGoodlist[nSizeGoodsList];TGoodsShopList* TGoodsShopList::GetData(); //初始化函数void TGoodsShopList::DbgPrintGoodsList();BOOL TGoodsShopList::BuyGoodsByName(char * szpName, DWORD ndNum);}_TGoodsShopList;#pragma pack(1)
#define ndBuyType 1
#define ndSelType 2
typedef struct _tBuyGoodsData{BYTE nd111[2];DWORD ndSendCmdType;DWORD ndBuySelType;DWORD nd1111;DWORD ndGoodsType;DWORD nd2222;DWORD ndNum;BYTE nb[0x80];}_tBuyGoodsData;
#pragma pack()
//背包结构定义
typedef struct TBACK_PACK_OBJ{char* szpGoodName; //+5Cchar* szpGoodMsg; //+F1DWORD ndGoodNum;//+c44DWORD ndID1;// +4cQWORD ndID2; //+54BYTE ndIndexForPack; //+1f4}_TBACK_PACK_OBJ;
TGoodsShopList* TGoodsShopList::GetData() //初始化函数
{DWORD ndObj = NULL;DWORD ndBase = NULL;memset(this, 0, sizeof(TGoodsShopList));__try{ndObj = *(DWORD*)( *(DWORD*)(Base_GoodsShopAddr + 0x2e0 * 4 + 0x4) + 0x4);for (int i = 0; i < 60; i++){ndBase = *(DWORD*)(ndObj + 0x410 + 4 * i);//DbgPrintf_Mine("%X", ndBase);if (ndBase == NULL){mtGoodlist[i].szpGoodName = NULL;continue;}mtGoodlist[i].szpGoodName = (char*)(ndBase + 0x5c);mtGoodlist[i].ndIndexForPack = *(BYTE*)(ndBase + 0x1f4);mtGoodlist[i].ndID1 = *(DWORD*)(ndBase + 0x4c);}}__except (1){DbgPrintf_Mine("TGoodsShopList* TGoodsShopList::GetData() //初始化函数 出现异常");}return this;
}void TGoodsShopList::DbgPrintGoodsList(){for (int i = 0; i < 60; i++){if (mtGoodlist[i].szpGoodName == NULL){//DbgPrintf_Mine("%d", i);continue;}DbgPrintf_Mine("商店物品名字: %s 物品类型 %X 物品下表%d",mtGoodlist[i].szpGoodName,mtGoodlist[i].ndID1,mtGoodlist[i].ndIndexForPack);}}BOOL TGoodsShopList::BuyGoodsByName(char * szpName, DWORD ndNum){__try{for (int i = 0; i < nSizeGoodsList; i++){if (strcmp(szpName, mtGoodlist[i].szpGoodName) == 0){_tBuyGoodsData tBuygoodList = { 0 };tBuygoodList.ndSendCmdType = 0x00800092;tBuygoodList.ndBuySelType = ndBuyType;tBuygoodList.ndGoodsType = mtGoodlist[i].ndID1;tBuygoodList.ndNum = ndNum;__asm{lea ecx, tBuygoodListpush 0x86push ecxMOV ECX, DWORD PTR DS : [Base_CallSendDataEcx]mov eax, Base_CallSendDataCALLCALL eax}return TRUE;}}}__except (1){DbgPrintf_Mine("BOOL TGoodsShopList::BuyGoodsByName(char * szpName, DWORD ndNum) 出现异常");return FALSE;}return FALSE;
}
这篇关于追逐自己的梦想----------辅助制作第三十七课:物品购买实现的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!