Exemplo n.º 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);
		}
	}
}
Exemplo n.º 2
0
// -----------------------------------------------------------------------------------------------------------------------------------------------------
void CPersonalShop::SendPShopBuyItemResult(int aSourceIndex, int aTargetIndex, int iItemPos, BYTE btResult)
{
	PMSG_ANS_BUYITEM_FROM_PSHOP pMsg;
	// ------
	C1SubHeadSet((LPBYTE)&pMsg, 0x3F, 0x06, sizeof(pMsg));
	// ------
	pMsg.NumberH	= SET_NUMBERH(aTargetIndex);
	pMsg.NumberL	= SET_NUMBERL(aTargetIndex);
	pMsg.btItemPos	= iItemPos;
	pMsg.Result		= btResult;
	// ------
	ItemByteConvert(pMsg.cItemInfo, gObj[aSourceIndex].Inventory1[iItemPos]);
	// ------
	gSendProto.DataSend(aSourceIndex, (LPBYTE)&pMsg, pMsg.h.size);
}
Exemplo n.º 3
0
//006bbab0
bool CPeriodItemEx::RemovePeriodItemData(LPOBJ lpObj, BYTE btItemType, WORD wItemCode, unsigned long dwSerial)	//OK
{
	if( !lpObj )
		return false;

	if( lpObj->Type != OBJ_USER || lpObj->Connected < 2 )
		return false;

	if( btItemType == 1 )
	{
		BUFF_EFFECT_DATE* lpBuffData = 0;
		lpBuffData = g_BuffEffectSlot.GetEffectDataFromItemCode(wItemCode);

		if( !lpBuffData )
			return false;

		gObjRemoveBuffEffect(lpObj,lpBuffData->btIndex);
	}
	else if( btItemType == 2 )
	{
		if( dwSerial == 0 )
			return false;

		int iInventoryPosition = 0;
		iInventoryPosition = this->GetItemFromInventory(lpObj,wItemCode,dwSerial);

		if( iInventoryPosition == -1 )
			return false;

		SetDisableItemToExpire(lpObj,iInventoryPosition);
		//auto-deleting
		gObjInventoryDeleteItem(lpObj->m_Index, iInventoryPosition);
		GCInventoryItemDeleteSend(lpObj->m_Index, iInventoryPosition, 1);
		gObjCalCharacter(lpObj->m_Index);
		// ----
		if( iInventoryPosition < 12 )
		{
			if( iInventoryPosition == 10 || iInventoryPosition == 11 )
			{
				gObjUseSkill.SkillChangeUse(lpObj->m_Index);
			}
			// ----
			gObjMakePreviewCharSet(lpObj->m_Index);
			PMSG_USEREQUIPMENTCHANGED pChange;
			PHeadSetB((LPBYTE)&pChange, 0x25, sizeof(pChange));
			pChange.NumberH = SET_NUMBERH(lpObj->m_Index);
			pChange.NumberL = SET_NUMBERL(lpObj->m_Index);
			ItemByteConvert(pChange.ItemInfo, lpObj->pInventory[iInventoryPosition]);
			pChange.ItemInfo[1] = iInventoryPosition <<  4;
			pChange.ItemInfo[1] |= LevelSmallConvert(lpObj->m_Index, iInventoryPosition) & 0x0F;
			DataSend(lpObj->m_Index, (LPBYTE)&pChange, pChange.h.size);
			MsgSendV2(lpObj, (LPBYTE)&pChange, pChange.h.size);
		}
	}
	else
	{
		return false;
	}


	ITEMDATA ItemData;
	ItemData.btType = btItemType;
	ItemData.wItemCode = wItemCode;
	ItemData.dwSerial = dwSerial;

	RequestPeriodItemDelete(lpObj,&ItemData);
	return true;
}
Exemplo n.º 4
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)
Exemplo n.º 5
0
void CCashShop::Load(LPSTR pchFilename)
{
	SMDToken Token;

	SMDFile = fopen(pchFilename, "r");	//ok

	if ( SMDFile == NULL )
	{
		MsgBox("[CashItemList] Cash Item List load failed. [%s]", pchFilename);
		return;
	}

	this->Initialize();

	int iType = 0;
	int iItemCode = 0;
	BYTE btItemType = 0;
	WORD wItemIndex = 0;
	BYTE btItemLevel = 0;
	BYTE btItemSkillOpion = 0;
	BYTE btItemLuckOption = 0;
	BYTE btItemAddOption = 0;
	BYTE btItemExOption = 0;
	BYTE btItemX = 0;
	BYTE btItemY = 0;
	BYTE btItemScale = 0;
	CASHSHOP_ITEM_STATUS ItemStatus;
	BOOL bResult = 0;

	while ( true )
	{
		Token = (SMDToken)GetToken();

		if ( Token == END )
			break;

		iType = TokenNumber;

		while ( true )
		{
			Token = (SMDToken)GetToken();

			if ( Token == END )
				break;
		
			if ( iType == 1 )
			{
				if ( !strcmp("end", TokenString) )
					break;

				ItemStatus.btItemType = TokenNumber;

				Token = (SMDToken)GetToken();
				ItemStatus.wItemIndex = TokenNumber;

				Token = (SMDToken)GetToken();
				ItemStatus.btItemLevel = TokenNumber;


				Token = (SMDToken)GetToken();
				ItemStatus.btSkillOption = TokenNumber;

				Token = (SMDToken)GetToken();
				ItemStatus.btLuckOption = TokenNumber;

				Token = (SMDToken)GetToken();
				ItemStatus.btAddOption = TokenNumber;

				BYTE btExOptionValue = 0;
				BYTE btExOption = 0;

				Token = (SMDToken)GetToken();
				btItemExOption = TokenNumber;

				if ( btItemExOption > 0 )
				{
					btExOptionValue = 1 << (int)(btItemExOption-1);
					btExOption |= btExOptionValue;
					ItemStatus.btExOption = btExOption;
				}
				else
				{
					ItemStatus.btExOption = 0;
				}

				Token = (SMDToken)GetToken();
				btItemX = TokenNumber;

				Token = (SMDToken)GetToken();
				btItemY = TokenNumber;

				Token = (SMDToken)GetToken();
				btItemScale = TokenNumber;

				iItemCode = ITEMGET(ItemStatus.btItemType , ItemStatus.wItemIndex);
				ItemStatus.btDurability = ItemAttribute[iItemCode].Durability;

				ItemByteConvert(ItemStatus.btItemInfo, iItemCode, ItemStatus.btSkillOption,
					ItemStatus.btLuckOption, ItemStatus.btAddOption,
					ItemStatus.btItemLevel, 1, ItemStatus.btExOption, 0, 0, 0, NULL, 0xFF, TEMP_PERIOD_VAR);
				
				LogAddTD("[CashShop][Load Cash Item List] - Add List - (%d/%d) Level:%d, Dur:%d, Skill:%d, Luck:%d, Add:%d, Ex:%d, X:%d, Y:%d, Scale:%d",
					ItemStatus.btItemType, ItemStatus.wItemIndex, ItemStatus.btItemLevel, ItemStatus.btDurability,
					ItemStatus.btSkillOption, ItemStatus.btLuckOption, ItemStatus.btAddOption, ItemStatus.btExOption, 
					btItemX, btItemY, btItemScale);

				this->InsertItemStatus(&ItemStatus);
			}
		}
	}

	LogAddTD("[CashShop][Load Cash Item List] - Complete! - Total:%d", this->MapCashItemStatus.size());
	fclose(SMDFile);
	/*if ( g_bConnectShopServer == TRUE && g_bShopServerConnectState == FALSE)
	{
		g_bShopServerConnectState = this->ConnectShopServer(g_ShopServerIP, g_ShopserverPort);

		if ( g_bShopServerConnectState == FALSE )
		{
			MsgBox("[CashShop] Shop Server Connect Failed!!");
		}
	}*/
}
Exemplo n.º 6
0
BOOL CShop::InsertItem(int type, int index, int level, int dur, int op1, int op2 ,int op3)
{
	int itemp;
	int width;
	int height;
	int x;
	int y;
	int blank;

	blank = -1;
	itemp = type * MAX_SUBTYPE_ITEMS + index;
	
	if ( itemp < 0 )
	{
		MsgBox("Error in creating item at shop %s %d", __FILE__, __LINE__);
		return false;
	}
	
	ItemGetSize(itemp, width, height);

	if ( width < 0 || height < 0 )
	{
		MsgBox("Error in getting item size in shop %s %d", __FILE__, __LINE__);
		return FALSE;
	}

	for ( y=0;y<15;y++)
	{
		for ( x=0;x<8;x++)
		{
			if ( this->ShopInventoryMap[x + y*8] == 0 )
			{
				blank = this->InentoryMapCheck(x, y, width, height);

				if ( blank >= 0 )
				{
					goto skiploop;
				}
			}
		}
	}

	if ( blank < 0 )
	{
		MsgBox("error-L2 : %s %d", __FILE__, __LINE__);
		return FALSE;
	}

skiploop:

	this->m_item[blank].m_Level = level;

	if ( dur == 0 )
	{
		dur = ItemGetDurability(ITEMGET(type, index), level, 0, 0);
	}

	this->m_item[blank].m_Durability = dur;
	this->m_item[blank].Convert(itemp, op1, op2, op3, 0, 0, 0, CURRENT_DB_VERSION);
	this->m_item[blank].Value();
	this->SendItemData[this->SendItemDataLen] = blank;
	this->SendItemDataLen++;
	ItemByteConvert((LPBYTE)&this->SendItemData[this->SendItemDataLen], this->m_item[blank]);
	this->SendItemDataLen += 7;
	this->ItemCount++;

	this->Type.push_back(type);
	this->Index.push_back(index);
	this->Level.push_back(level);
	this->Dur.push_back(dur);
	this->Opt1.push_back(op1);
	this->Opt2.push_back(op2);
	this->Opt3.push_back(op3);


	return TRUE;
}
Exemplo n.º 7
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;
}
Exemplo n.º 8
0
// -----------------------------------------------------------------------------------------------------------------------------------------------------
void CPersonalShop::SendPlShopBuyListResult(int aSourceIndex, int aTargetIndex, BYTE btResult, bool bResend)
{
	if( gDoPShopOpen == FALSE ) return;
	// ------
	PMSG_ANS_BUYLIST_FROM_PSHOP		pMsgILC;
	PMSG_BUYLIST_FROM_PSHOP			pMsgIL;
	// ------
	BYTE sendBuf[1024];
	// ------
	int sOfs		= sizeof(pMsgILC);
	int pMsgILSize	= sizeof(pMsgIL);
	// ------
	if( btResult != 1 )
	{
		LPOBJ lpObj = &gObj[aSourceIndex];
		// ------
		pMsgILC.h.c			= 0xC2;
		pMsgILC.h.headcode	= 0x3F;
		// ------
		if( bResend == false )
		{
			pMsgILC.h.subcode = 0x05;
		}
		else
		{
			pMsgILC.h.subcode = 0x13;
		}
		// ------
		pMsgILC.h.sizeH		= SET_NUMBERH(sOfs);
		pMsgILC.h.sizeL		= SET_NUMBERL(sOfs);
		pMsgILC.btCount		= 0;
		pMsgILC.Result		= btResult;
		pMsgILC.NumberH		= SET_NUMBERH(aTargetIndex);
		pMsgILC.NumberL		= SET_NUMBERL(aTargetIndex);
		// ------
		memset(pMsgILC.btName, 0, sizeof(pMsgILC.btName));
		memset(pMsgILC.szPShopText, 0, sizeof(pMsgILC.szPShopText));
		memcpy(sendBuf, &pMsgILC, sizeof(pMsgILC));
		// ------
		gSendProto.DataSend(aSourceIndex, sendBuf, sOfs);
	}
	else
	{
		LPOBJ lpObjSource = &gObj[aSourceIndex];
		LPOBJ lpObjTarget = &gObj[aTargetIndex];
		// ------
		int iCount = 0;
		// ------
		for ( int n=MAIN_INVENTORY_SIZE;n<INVENTORY_SIZE;n++)
		{
			if( lpObjTarget->Inventory1[n].IsItem() == TRUE )
			{
				pMsgIL.Pos = n;
				// ------
				ItemByteConvert(pMsgIL.ItemInfo, lpObjTarget->Inventory1[n]);
				// ------
				pMsgIL.PShopItemValue = lpObjTarget->Inventory1[n].m_iPShopValue;
				// ------
				memcpy(&sendBuf[sOfs], &pMsgIL, pMsgILSize);
				// ------
				iCount++;
				sOfs += pMsgILSize;
				// ------
				CLog.LogAddC(TColor.Green(), PShopModule, "Item Type: (%d)", lpObjTarget->Inventory1[n].m_Type);
			}
		}
		// ------
		pMsgILC.h.c			= 0xC2;
		pMsgILC.h.headcode	= 0x3F;
		// ------
		if( bResend == false )
		{
			pMsgILC.h.subcode = 0x05;
		}
		else
		{
			pMsgILC.h.subcode = 0x13;
		}
		// ------
		pMsgILC.h.sizeH		= SET_NUMBERH(sOfs);
		pMsgILC.h.sizeL		= SET_NUMBERL(sOfs);
		pMsgILC.btCount		= iCount;
		pMsgILC.Result		= btResult;
		pMsgILC.NumberH		= SET_NUMBERH(aTargetIndex);
		pMsgILC.NumberL		= SET_NUMBERL(aTargetIndex);
		// ------
		memcpy(pMsgILC.btName, lpObjTarget->Name, sizeof(pMsgILC.btName));
		memcpy(pMsgILC.szPShopText, lpObjTarget->m_szPShopText, sizeof(pMsgILC.szPShopText));
		memcpy(sendBuf, &pMsgILC, sizeof(pMsgILC));
		// ------
		gSendProto.DataSend(aSourceIndex, sendBuf, sOfs);
	}
}
Exemplo n.º 9
0
// -----------------------------------------------------------------------------------------------------------------------
void CItemSocket::NewMix4(LPOBJ lpObj,BYTE info)
{
    int ItemCount = 0;
	int ItemSlot = 0;

	lpObj->ChaosLock = 1;

    for(int n=0;n < CHAOS_BOX_SIZE;n++)
	{
	    if( ItemAttribute[lpObj->pChaosBox[n].m_Type].SocketItem > 0 && lpObj->pChaosBox[n].m_ItemSocket[info] < 0xFE)
		{
	        ItemCount++;
			ItemSlot = n;
		}
	}

    PMSG_CHAOSMIXRESULT pMsg;

    C1HeadSet((LPBYTE)&pMsg.h,0x86,sizeof(pMsg));

	if(ItemCount != 1)
	{
	    lpObj->ChaosLock = 0;

        pMsg.Result = CB_INCORRECT_MIX_ITEMS;
        gSendProto.DataSend(lpObj->m_Index,(BYTE *)&pMsg, pMsg.h.size);
		return;
	}

	lpObj->ChaosMoney = 1000000;
	
	int TaxMoney = (lpObj->ChaosMoney*g_CastleSiegeSync.GetTaxRateChaos(lpObj->m_Index))/100;

	lpObj->ChaosMoney += TaxMoney;

	if(lpObj->Money < lpObj->ChaosMoney)
	{
	    lpObj->ChaosLock = 0;

        pMsg.Result = CB_NOT_ENOUGH_ZEN;
        gSendProto.DataSend(lpObj->m_Index,(BYTE *)&pMsg, pMsg.h.size);
		return;
	}

    lpObj->Money -= lpObj->ChaosMoney;
    GCMoneySend(lpObj->m_Index,lpObj->Money);

	g_CastleSiegeSync.AddTributeMoney(TaxMoney);

	CItem item = lpObj->pChaosBox[ItemSlot];

	item.m_ItemSocket[info] = 0xFE;

	pMsg.Result = CB_SUCCESS;

	ItemByteConvert(pMsg.ItemInfo,item);

	gChaosBox.ChaosBoxInit(lpObj);

    gObjChaosBoxInsertItemPos(lpObj->m_Index,item,0,-1);
	gObjChaosItemSet(lpObj->m_Index,0,1);

	gSendProto.DataSend(lpObj->m_Index,(BYTE *)&pMsg, pMsg.h.size);

	lpObj->ChaosLock = 0;
}
Exemplo n.º 10
0
// -----------------------------------------------------------------------------------------------------------------------
void CItemSocket::SeedCalc(LPOBJ lpObj,BYTE info)
{
    int ChaosCount = 0;
	int CreationCount = 0;
	int SeedSphereCount = 0;
	int SeedSphereType = 0;
	int SeedSphereLevel = 0;
	int SeedSphereOption = 0;
	int ItemCount = 0;
	int ItemSlot = 0;

	lpObj->ChaosLock = 1;

    for(int n=0;n < CHAOS_BOX_SIZE;n++)
	{
	    if(lpObj->pChaosBox[n].IsItem() == 0)
		{
		    continue;
		}

        if(lpObj->pChaosBox[n].m_Type == ITEMGET(12,15))
		{
		    ChaosCount++;
		}
		else if(lpObj->pChaosBox[n].m_Type == ITEMGET(14,22))
		{
		    CreationCount++;
		}
		else if(lpObj->pChaosBox[n].m_Type >= ITEMGET(12,100) && lpObj->pChaosBox[n].m_Type <= ITEMGET(12,129))
		{
		    SeedSphereCount++;
			SeedSphereType = gItemSocket.CalculateSeedType(lpObj->pChaosBox[n].m_Type); // From 1 to 6
			SeedSphereLevel = gItemSocket.CalculateSeedLevel(lpObj->pChaosBox[n].m_Type); // From 0 to 4
	        SeedSphereOption = lpObj->pChaosBox[n].m_Level; 
		}
		else if( ItemAttribute[lpObj->pChaosBox[n].m_Type].SocketItem != 0 && lpObj->pChaosBox[n].m_ItemSocket[info] == 0xFE)
		{
	        ItemCount++;
			ItemSlot = n;
		}
	}

    PMSG_CHAOSMIXRESULT pMsg;

    C1HeadSet((LPBYTE)&pMsg.h,0x86,sizeof(pMsg));

	if(ChaosCount != 1 || CreationCount != 1 || SeedSphereCount != 1 || ItemCount != 1)
	{
	    lpObj->ChaosLock = 0;

        pMsg.Result = CB_INCORRECT_MIX_ITEMS;
        gSendProto.DataSend(lpObj->m_Index,(BYTE *)&pMsg, pMsg.h.size);
		return;
	}

	lpObj->ChaosMoney = 1000000;
	
	int TaxMoney = (lpObj->ChaosMoney*g_CastleSiegeSync.GetTaxRateChaos(lpObj->m_Index))/100;

	lpObj->ChaosMoney += TaxMoney;

	if(lpObj->Money < lpObj->ChaosMoney)
	{
	    lpObj->ChaosLock = 0;

        pMsg.Result = CB_NOT_ENOUGH_ZEN;
        gSendProto.DataSend(lpObj->m_Index,(BYTE *)&pMsg, pMsg.h.size);
		return;
	}

	BYTE option = gItemSocket.CalculateSeedOption(SeedSphereType,SeedSphereLevel,SeedSphereOption);

	if(option == 0xFE)
	{
        lpObj->ChaosLock = 0;

        pMsg.Result = CB_ERROR;
        gSendProto.DataSend(lpObj->m_Index,(BYTE *)&pMsg, pMsg.h.size);
		return;
	}

    lpObj->Money -= lpObj->ChaosMoney;
    GCMoneySend(lpObj->m_Index,lpObj->Money);

	g_CastleSiegeSync.AddTributeMoney(TaxMoney);

	CItem item = lpObj->pChaosBox[ItemSlot];

	item.m_ItemSocket[info] = option;

	pMsg.Result = CB_SUCCESS;

	ItemByteConvert(pMsg.ItemInfo,item);

	gChaosBox.ChaosBoxInit(lpObj);

    gObjChaosBoxInsertItemPos(lpObj->m_Index,item,0,-1);
	gObjChaosItemSet(lpObj->m_Index,0,1);

	gSendProto.DataSend(lpObj->m_Index,(BYTE *)&pMsg, pMsg.h.size);

	lpObj->ChaosLock = 0;
}