Beispiel #1
0
void cVipSystem::BuyItem(LPOBJ lpObj, int IDNumber)
{
	if(IDNumber >= 0 && IDNumber <= (this->ItemsCount-1))
	{
		BOOL IfBuy = FALSE;	
		PMSG_BUYRESULT pResult;
		PHeadSetB((LPBYTE)&pResult, 0x32, sizeof(pResult));

		if(this->Shop[IDNumber].Cost < lpObj->VipMoney)
		{
			pResult.Result = gObjShopBuyInventoryInsertItem(lpObj->m_Index,this->m_item[IDNumber]);
				
			if ( pResult.Result != 0xFF )
			{
				lpObj->AccountExtraInfoModified = 1;

				ItemByteConvert((LPBYTE)&pResult.ItemInfo, this->m_item[IDNumber]);
				DataSend(lpObj->m_Index, (LPBYTE)&pResult, pResult.h.size);
				lpObj->VipMoney -= this->Shop[IDNumber].Cost;
				IfBuy = TRUE;
			}else
			{				
				GCServerMsgStringSend(lMsg.Get(MSGGET(14, 58)),lpObj->m_Index, 0x01);
			}
		}
		//Log
		if(IfBuy == TRUE)
		{
			LogAddTD("[VIPShop] BuyItem [%s][%s] Item {%d %d} Cost: %d",lpObj->AccountID,lpObj->Name,this->Shop[IDNumber].Type,this->Shop[IDNumber].Index,this->Shop[IDNumber].Cost);
		} else 
		{
			LogAddTD("[VIPShop] Attempt to BuyItem [%s][%s] Item {%d %d} Cost: %d",lpObj->AccountID,lpObj->Name,this->Shop[IDNumber].Type,this->Shop[IDNumber].Index,this->Shop[IDNumber].Cost);
		}
	}
}
Beispiel #2
0
void GetTitanReward(SDHP_GETREWARD_INFOSAVE * lpMsg)
{	
	char szId[11]={0};
	int aIndex = 0;

	szId[MAX_ACCOUNT_LEN]=0;
	memcpy(szId, lpMsg->AccountID, sizeof(lpMsg->AccountID));
	aIndex = lpMsg->aIndex;

	if ( !gObjIsAccontConnect(aIndex, szId))
	{
		LogAddC(2, lMsg.Get(MSGGET(1, 175)), szId, aIndex);
		return;
	}
	
	LPOBJ lpObj = &gObj[aIndex];

	if (( lpObj->m_Index == aIndex) && (!strcmp(lpMsg->Name,lpObj->Name)))
	{
		char exVipMoney[512]={0};
		char exZen[512]={0};
		wsprintf(exVipMoney,"VipMoney increased in %d",lpMsg->rew.VipMoney);
		wsprintf(exZen,"Zen increased in %d",lpMsg->rew.Zen);

		if(lpMsg->ID_Num >= 0)
		{
			if(lpMsg->rew.num != (WORD) -1)
			{
				if(lpMsg->rew.Days == 0)
				{
					PMSG_BUYSHOPRESULT pResult;	
					PHeadSetB((LPBYTE)&pResult, 0x32, sizeof(pResult));
					CItem item;
					item.m_Level = lpMsg->rew.Level;
					item.m_SkillOption = lpMsg->rew.Skill;
					item.m_LuckOption = lpMsg->rew.Luck;
					item.m_Z28Option = lpMsg->rew.Opt;
					item.m_Durability = lpMsg->rew.Dur;
					item.m_ItemOptionEx = lpMsg->rew.Exc;
					item.m_JewelOfHarmonyOption = 0;
					if(lpMsg->rew.JOH > 0)
					{
						int btOptionLevel = item.m_Level;
						if(btOptionLevel > ReadConfig.JOHLevelMax)
							btOptionLevel = ReadConfig.JOHLevelMax;
						item.m_JewelOfHarmonyOption |= lpMsg->rew.JOH << 4;
						item.m_JewelOfHarmonyOption |= btOptionLevel & 0x0F;
					}
						
					item.Convert(lpMsg->rew.num, lpMsg->rew.Skill, lpMsg->rew.Luck, lpMsg->rew.Opt, lpMsg->rew.Exc, 0, 0, CURRENT_DB_VERSION);
					item.m_Durability = item.m_BaseDurability;
					item.m_ItemSlot1 = lpMsg->rew.Sock1;
					item.m_ItemSlot2 = lpMsg->rew.Sock2;
					item.m_ItemSlot3 = lpMsg->rew.Sock3;
					item.m_ItemSlot4 = lpMsg->rew.Sock4;
					item.m_ItemSlot5 = lpMsg->rew.Sock5;

					item.Value();
					pResult.Result = gObjShopBuyInventoryInsertItem(lpObj->m_Index,item);
						
					if ( pResult.Result != 0xFF )
					{
						DelTitanReward(aIndex,lpMsg->ID_Num);

						if(lpMsg->rew.IsForeverFFFE == 1)
							lpObj->pInventory[pResult.Result].m_Number = 0xFFFFFFFE;

						ItemByteConvert((LPBYTE)&pResult.ItemInfo, item);
						DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);

						if(lpMsg->rew.VipMoney > 0)
						{						
							lpObj->AccountExtraInfoModified = 1;
							lpObj->VipMoney += lpMsg->rew.VipMoney;
							GCServerMsgStringSend(exVipMoney, lpObj->m_Index, 0x01);
						}
						if(lpMsg->rew.Zen > 0)
						{
							if((__int64)(lpMsg->rew.Zen + gObj[aIndex].Money) > (__int64)MAX_ZEN)
								gObj[aIndex].Money = MAX_ZEN;
							else
								gObj[aIndex].Money += lpMsg->rew.Zen;

							::GCMoneySend(aIndex, gObj[aIndex].Money);
							GCServerMsgStringSend(exZen, lpObj->m_Index, 0x01);
						}
							
						GCServerMsgStringSend("Get Reward Success!", aIndex, 0x01);
						
						char sbuf[512]={0};
						wsprintf(sbuf,"[BotReward](%s)(%s) Buy Item:%d(%d %d) ID_DB:%d [LVL:%d O:%d L:%d S:%d E:%d]",
							gObj[aIndex].AccountID,gObj[aIndex].Name,
							lpMsg->rew.num, lpMsg->rew.num/512, lpMsg->rew.num-((int)(lpMsg->rew.num/512)*512), lpMsg->ID_Num,
							lpMsg->rew.Level,lpMsg->rew.Opt,lpMsg->rew.Luck,lpMsg->rew.Skill,lpMsg->rew.Exc);
						LogAddTD(sbuf);

						BOTREWARD_LOG.Output(sbuf);
					}
				}else
				{
					time_t t = time(NULL);
					localtime(&t);
					DWORD iTime = (DWORD)t + lpMsg->rew.Days * 86400;
					BYTE iItemPos = gObjInventoryInsertItem(&gObj[aIndex], ITEM_GET_TYPE(lpMsg->rew.num), ITEM_GET_INDEX(lpMsg->rew.num), lpMsg->rew.Level, iTime, 0xff,0,0,0,0,0);
					
					if ( iItemPos != (BYTE)-1 )
					{
						DelTitanReward(aIndex,lpMsg->ID_Num);
						gObj[aIndex].pInventory[iItemPos].m_JewelOfHarmonyOption = 0;
						if(lpMsg->rew.JOH > 0)
						{
							int btOptionLevel = gObj[aIndex].pInventory[iItemPos].m_Level;
							if(btOptionLevel > ReadConfig.JOHLevelMax)
								btOptionLevel = ReadConfig.JOHLevelMax;
							gObj[aIndex].pInventory[iItemPos].m_JewelOfHarmonyOption |= lpMsg->rew.JOH << 4;
							gObj[aIndex].pInventory[iItemPos].m_JewelOfHarmonyOption |= btOptionLevel & 0x0F;
						}
						gObj[aIndex].pInventory[iItemPos].Convert(lpMsg->rew.num, lpMsg->rew.Skill, lpMsg->rew.Luck, lpMsg->rew.Opt, lpMsg->rew.Exc, 0, 0, CURRENT_DB_VERSION);
						BYTE btItemType=0;
						btItemType |= (lpMsg->rew.num & 0x1E00 ) >> 5;
						gObj[aIndex].pInventory[iItemPos].m_ItemOptionEx = btItemType+2;
						gObj[aIndex].pInventory[iItemPos].m_ItemSlot1 = lpMsg->rew.Sock1;
						gObj[aIndex].pInventory[iItemPos].m_ItemSlot2 = lpMsg->rew.Sock2;
						gObj[aIndex].pInventory[iItemPos].m_ItemSlot3 = lpMsg->rew.Sock3;
						gObj[aIndex].pInventory[iItemPos].m_ItemSlot4 = lpMsg->rew.Sock4;
						gObj[aIndex].pInventory[iItemPos].m_ItemSlot5 = lpMsg->rew.Sock5;
						::GCInventoryItemOneSend(aIndex, iItemPos);
						MuItemShop.ItemSendTime(aIndex,iItemPos);					

						if(lpMsg->rew.VipMoney > 0)
						{						
							lpObj->AccountExtraInfoModified = 1;
							lpObj->VipMoney += lpMsg->rew.VipMoney;
							GCServerMsgStringSend(exVipMoney, lpObj->m_Index, 0x01);
						}
						if(lpMsg->rew.Zen > 0)
						{
							if((__int64)(lpMsg->rew.Zen + gObj[aIndex].Money) > (__int64)MAX_ZEN)
								gObj[aIndex].Money = MAX_ZEN;
							else
								gObj[aIndex].Money += lpMsg->rew.Zen;

							::GCMoneySend(aIndex, gObj[aIndex].Money);
							GCServerMsgStringSend(exZen, lpObj->m_Index, 0x01);
						}

						char sbuf[512]={0};
						GCServerMsgStringSend("Get Reward Success!", lpObj->m_Index, 0x01);
						wsprintf(sbuf,"[BotReward](%s)(%s) Buy Item:%d(%d %d) ID_DB:%d [LVL:%d O:%d L:%d S:%d E:%d]",
							gObj[aIndex].AccountID,gObj[aIndex].Name,
							lpMsg->rew.num, lpMsg->rew.num/512, lpMsg->rew.num-((int)(lpMsg->rew.num/512)*512), lpMsg->ID_Num,
							lpMsg->rew.Level,lpMsg->rew.Opt,lpMsg->rew.Luck,lpMsg->rew.Skill,lpMsg->rew.Exc);
						LogAddTD(sbuf);
						BOTREWARD_LOG.Output(sbuf);
					}
				}
			}else
			{
				if(lpMsg->rew.VipMoney > 0)
Beispiel #3
0
bool CShop::BuyShopItemAndDelete(int Pos, int aIndex,CShop *Shop)
{
	LPOBJ lpObj = &gObj[aIndex];
	if ( Shop->m_item[Pos].IsItem() == TRUE )
	{
		PMSG_BUYRESULT pResult;

		PHeadSetB((LPBYTE)&pResult, 0x32, sizeof(pResult));
		pResult.Result = -1;

		int iStoreTaxMoney = Shop->m_item[Pos].m_BuyMoney + (int)((__int64)Shop->m_item[Pos].m_BuyMoney * (__int64)g_CastleSiegeSync.GetTaxRateStore(lpObj->m_Index) / (__int64)100);

		if ( iStoreTaxMoney < 0 )
			iStoreTaxMoney  = 0;

		int iStoreTaxMoney2 = (int)((__int64)Shop->m_item[Pos].m_BuyMoney * (__int64)g_CastleSiegeSync.GetTaxRateStore(lpObj->m_Index) / (__int64)100);

		if ( iStoreTaxMoney2 < 0 )
			iStoreTaxMoney2  = 0;

		if ( lpObj->Money < iStoreTaxMoney )
			pResult.Result = -1;
		else
		{
			BOOL bNoItem = TRUE;

			if ( (Shop->m_item[Pos].m_Type >= ITEMGET(14,0) && Shop->m_item[Pos].m_Type <= ITEMGET(14,8)) ||
				(Shop->m_item[Pos].m_Type >= ITEMGET(14,35) && Shop->m_item[Pos].m_Type <= ITEMGET(14,40)))
			{
				int dur = (int)Shop->m_item[Pos].m_Durability;

				if ( dur == 0 )
					dur = 1;

				if ( ::gObjSearchItem(lpObj, Shop->m_item[Pos].m_Type,dur, Shop->m_item[Pos].m_Level) == TRUE )
				{
					bNoItem = FALSE;
					lpObj->Money -= iStoreTaxMoney;
					::g_CastleSiegeSync.AddTributeMoney(iStoreTaxMoney2);

					if ( lpObj->Money < 0 )
						lpObj->Money = 0;


					::GCMoneySend(lpObj->m_Index, lpObj->Money);
				}
			}

			if ( bNoItem != FALSE )
			{
				pResult.Result = gObjShopBuyInventoryInsertItem(lpObj->m_Index, Shop->m_item[Pos]);

				if ( pResult.Result != 0xFF )
				{
					ItemByteConvert((LPBYTE)&pResult.ItemInfo, Shop->m_item[Pos]);
					int lc64 = Shop->m_item[Pos].m_BuyMoney;
					lpObj->Money -= iStoreTaxMoney;
					::g_CastleSiegeSync.AddTributeMoney(iStoreTaxMoney2);

					if ( lpObj->Money < 0 )
						lpObj->Money = 0;

					GCMoneySend(lpObj->m_Index, lpObj->Money);
					int iTaxRate = g_CastleSiegeSync.GetTaxRateStore(lpObj->m_Index);

					for (int i = 0; i < Type.size(); i++)
					{
						int type = ITEMGET(Type[i],Index[i]); 
						if ( type == Shop->m_item[Pos].m_Type && Dur[i] == Shop->m_item[Pos].m_Durability && Level[i] == Shop->m_item[Pos].m_Level && 
							Opt1[i] == Shop->m_item[Pos].m_Option1 && Opt2[i] == Shop->m_item[Pos].m_Option2 && Opt3[i] == Shop->m_item[Pos].m_Option3 )
						{
							Type[i] = -1;
							Index[i] = -1;
							Dur[i] = -1;
							Level[i] = -1;
							Opt1[i] = -1;
							Opt2[i] = -1;
							Opt3[i] = -1;
							break;
						}
					}

					Shop->m_item[Pos].Clear();

					Shop->SendItemDataLen -= 8;
					Shop->ItemCount -- ;
					Shop->RefreshShopItems();
					DataSend(lpObj->m_Index, (LPBYTE)&pResult, pResult.h.size);


					LogAdd("[%s][%s] (%d) Shop buy [%d][%d][%d][%s] LEV:%d, DUR:%d, OP:[%d][%d][%d]",
						lpObj->AccountID, lpObj->Name, 14, lc64, iTaxRate, lc64+iStoreTaxMoney2, Shop->m_item[Pos].GetName(),
						Shop->m_item[Pos].m_Level, Shop->m_item[Pos].m_Durability,
						Shop->m_item[Pos].m_Option1, Shop->m_item[Pos].m_Option2,
						Shop->m_item[Pos].m_Option3);


					if ( Shop->ItemCount < 1 )
					{
						PMSG_TALKRESULT pResult;
						lpObj->TargetShopNumber = -1;
						lpObj->m_IfState.use = 0;
						lpObj->m_IfState.type = 0;
						lpObj->m_ShopTime = 0;
						pResult.h.c = 0xC3;
						pResult.h.headcode = 0x30;
						pResult.h.size = sizeof(pResult);
						pResult.result = -1;
						DataSend(lpObj->m_Index, (LPBYTE)&pResult, pResult.h.size);

						/*if ( Random(0,1) != 0 )
							ChatTargetSend(&gObj[DealerNumber], lMsg.Get(MSGGET(4, 119)), aIndex);//#info - ChatTargetSend - может что то интересненькое
						else
							ChatTargetSend(&gObj[DealerNumber], lMsg.Get(MSGGET(4, 120)), aIndex);*/

						return true;
					}
					else
					{
						lpObj->TargetShopNumber = 14;
						lpObj->m_IfState.use = 1;
						lpObj->m_IfState.type = 3;
						lpObj->m_ShopTime = 0;

						

						PMSG_SHOPITEMCOUNT pShopItemCount;
						BYTE SendByte[1024];
						int lOfs = 0;

						lOfs += sizeof(pShopItemCount );

						int size = lOfs + Shop->SendItemDataLen;
						PHeadSetW((LPBYTE)&pShopItemCount, 0x31, size);
						pShopItemCount.Type = 0;
						pShopItemCount.count = Shop->ItemCount;
						memcpy(SendByte, &pShopItemCount, sizeof(pShopItemCount));
						memcpy(&SendByte[lOfs], Shop->SendItemData, Shop->SendItemDataLen);

						DataSend(lpObj->m_Index, SendByte, size);
						GCAnsCsMapSvrTaxInfo(lpObj->m_Index,2,  ::g_CastleSiegeSync.GetTaxRateStore(lpObj->m_Index));

						return true;
					}

				}
			}
		}
	}

	return false;
}