コード例 #1
0
ファイル: PeriodItemEx.cpp プロジェクト: 331515194/zTeamS6.3
//006bc390
//CGUseItemRecv
//CGUseItemRecv
bool CPeriodItemEx::SetPeriodItemInfo(LPOBJ lpObj,WORD wItemCode,DWORD dwSerial,DWORD dwDuration)	//~OK
{
	if( !lpObj )
		return false;

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

	int iInventoryPosition = 0;
	DWORD dwExpireDate = 0;
	CItem* lpItem = NULL;
	ITEMDATA ItemData;
	LPBUFF_EFFECT_DATE lpBuffData = NULL;
	LPITEMEFFECT lpItemEffect = NULL;

	if( !dwSerial )
	{
		lpBuffData		= g_BuffEffectSlot.GetEffectDataFromItemCode(wItemCode);
		lpItemEffect	= g_ItemAddOption.GetItemEffectData(wItemCode);

		if( !lpBuffData || !lpItemEffect )
			return false;

		if( gObjAddBuffEffect(lpObj,lpBuffData->btIndex,dwDuration) == TRUE )
		{
			ItemData.Clear();
			ItemData.btType = 1;
			ItemData.wItemCode = wItemCode;
			ItemData.btTmp = lpBuffData->btViewPortIndex;
			ItemData.btEffectType1 = lpItemEffect->wEffectType1;
			ItemData.btEffectType2 = lpItemEffect->wEffectType2;
			ItemData.iDuration = dwDuration;
			ItemData.iUnk3 = 0;
			ItemData.lCurentDate = this->GetCurrentDate();
			ItemData.lExpireDate = this->GetExpireDate(dwDuration);
		}
		else
		{
			return FALSE;
		}
	}
	else
	{
		iInventoryPosition = this->GetItemFromInventory(lpObj,wItemCode,dwSerial);

		if( iInventoryPosition == -1 )
		{
			return false;
		}

		lpItem = &lpObj->pInventory[iInventoryPosition];
		lpItem->SetPeriodItem();

		GCInventoryItemOneSend(lpObj->m_Index, iInventoryPosition);

		dwExpireDate = this->GetExpireDate(dwDuration);
		AddPeriodItemData(lpObj,wItemCode,dwSerial,dwDuration,dwExpireDate);
		ItemData.Clear();
		ItemData.wItemCode		= wItemCode;
		ItemData.btType			= 2;
		ItemData.dwSerial		= lpItem->GetNumber();
		ItemData.iDuration		= dwDuration;
		ItemData.iUnk3			= 0;
		ItemData.lCurentDate	= this->GetCurrentDate();
		ItemData.lExpireDate	= dwExpireDate;
	}
	RequestPeriodItemInsert(lpObj,&ItemData,dwDuration);
	return true;
}
コード例 #2
0
// -----------------------------------------------------------------------------------------------------------------------------------------------------
void CPersonalShop::SetPersonalShopItemPrice(PMSG_REQ_PSHOP_SETITEMPRICE * lpMsg, int aIndex)
{
	LPOBJ lpObj = &gObj[aIndex];
	// ------
	if( gDoPShopOpen == FALSE )
	{
		CLog.LogAddC(TColor.Red(), PShopModule, "(Error): [%s][%s] is Trying to Open Personal Shop.", lpObj->AccountID, lpObj->Name);
		// ------
		SendPShopSetItemPriceResult(aIndex, 0, lpMsg->btItemPos);
		return;
	}
	// ------
	if( !gObjIsConnected(aIndex) )
	{
		CLog.LogAddC(TColor.Red(), PShopModule, "(Error): [%s][%s] is Offline Player.", lpObj->AccountID, lpObj->Name);
		return;
	}
	// ------
	if( lpObj->Type != OBJ_USER )
	{
		CLog.LogAddC(TColor.Red(), PShopModule, "(Error): [%s] isn't an Object User.", lpObj->m_Index);
		return;
	}
	// ------
	if( lpObj->Level <= 5 )
	{
		CLog.LogAddC(TColor.Red(), PShopModule, "(Error): [%s][%s] is Level: (%d)", lpObj->AccountID, lpObj->Name, lpObj->Level);
		// ------
		SendPShopSetItemPriceResult(aIndex, 5, lpMsg->btItemPos);
		return;
	}
	// ------
	if( INVENTORY_RANGE(lpMsg->btItemPos) == FALSE )
	{
		CLog.LogAddC(TColor.Red(), PShopModule, "(Error): [%s][%s] Item Position Out of Range: (%d)",lpObj->AccountID, lpObj->Name, lpMsg->btItemPos);
		// ------
		SendPShopSetItemPriceResult(aIndex, 2, lpMsg->btItemPos);
		return;
	}
	// ------
	if( lpObj->Inventory1[lpMsg->btItemPos].IsItem() == FALSE )
	{
		CLog.LogAddC(TColor.Red(), PShopModule, "(Error): [%s][%s] Item Doesn't Exist: (%d)",lpObj->AccountID, lpObj->Name, lpMsg->btItemPos);
		// ------
		SendPShopSetItemPriceResult(aIndex, 3, lpMsg->btItemPos);
		return;
	}
	// ------
	CItem * sitem = &lpObj->Inventory1[lpMsg->btItemPos];
	// ------
	int iItemPrice = MAKE_NUMBERDW(MAKE_NUMBERW(lpMsg->sItemPrice4, lpMsg->sItemPrice3), MAKE_NUMBERW(lpMsg->sItemPrice2, lpMsg->sItemPrice1));
	// ------
	if( gObjInventorySearchSerialNumber(lpObj, sitem->GetNumber()) == FALSE )
	{
		GCReFillSend(aIndex, lpObj->Life, 0xFD, TRUE, lpObj->iShield);
		// ------
		CLog.LogAddC(TColor.Red(), PShopModule, "(Error): [%s][%s] CopyItem :: [%s](%d)",lpObj->AccountID, lpObj->Name, __FILE__, __LINE__);
		return;
	}
	// ------
	if( iItemPrice <= 0 )
	{
		CLog.LogAddC(TColor.Red(), PShopModule, "(Error): [%s][%s] Item Price <= (0): (%d)",lpObj->AccountID, lpObj->Name, sitem->m_iPShopValue);
		// ------
		SendPShopSetItemPriceResult(aIndex, 4, lpMsg->btItemPos);
		return;
	}
	// ------
	if( (lpObj->Penalty&4) == 4 || (lpObj->Penalty&8) == 8 )
	{
		CLog.LogAddC(TColor.Red(), PShopModule, "(Error): [%s][%s] Item Price Change(%d), Item Block",lpObj->AccountID, lpObj->Name, sitem->m_iPShopValue);
		// ------
		SendPShopSetItemPriceResult(aIndex, 6, lpMsg->btItemPos);
		return;
	}
	// ------
	sitem->m_iPShopValue = iItemPrice;
	// ------
	ItemAttribute[sitem->m_Type].Name[31] = 0;
	// ------
	CLog.LogAddC(TColor.Green(), PShopModule, "[%s][%s]: Changing Item Price:(%d) - Type:(%d) [%s] - Level:(%d) - Serial:(%d) - Dur:(%d)",lpObj->AccountID,
		lpObj->Name, sitem->m_iPShopValue, sitem->m_Type, ItemAttribute[sitem->m_Type].Name, sitem->m_Level, sitem->m_Number, sitem->m_Durability);
	// ------
	SendPShopSetItemPriceResult(aIndex, 1, lpMsg->btItemPos);
}