コード例 #1
0
ファイル: CCharNPCAct_Vendor.cpp プロジェクト: nefthon/Source
bool CChar::NPC_StablePetRetrieve( CChar * pCharPlayer )
{
	ADDTOCALLSTACK("CChar::NPC_StablePetRetrieve");
	// Get pets for this person from my inventory.
	// May want to put up a menu ???

	if ( !m_pNPC || m_pNPC->m_Brain != NPCBRAIN_STABLE )
		return false;

	int iCount = 0;
	CItem *pItemNext = NULL;
	for ( CItem *pItem = GetBank()->GetContentHead(); pItem != NULL; pItem = pItemNext )
	{
		pItemNext = pItem->GetNext();
		if ( pItem->IsType(IT_FIGURINE) && pItem->m_uidLink == pCharPlayer->GetUID() )
		{
			if ( !pCharPlayer->Use_Figurine(pItem) )
			{
				tchar *pszTemp = Str_GetTemp();
				sprintf(pszTemp, g_Cfg.GetDefaultMsg(DEFMSG_NPC_STABLEMASTER_CLAIM_FOLLOWER), pItem->GetName());
				Speak(pszTemp);
				return true;
			}

			pItem->Delete();
			iCount++;
		}
	}

	Speak(g_Cfg.GetDefaultMsg((iCount > 0) ? DEFMSG_NPC_STABLEMASTER_CLAIM : DEFMSG_NPC_STABLEMASTER_CLAIM_NOPETS));
	return true;
}
コード例 #2
0
ファイル: CInventory.cpp プロジェクト: xardasVB/Deathspeakers
void CInventory::AddItem(CItem _item)
{
	bool active = true;
	for (int i = 0; i < sizeOfInventory; i++)
	{
		if (strcmp(GetInventory()[i].GetName(), _item.GetName()) == 0)
		{
			GetInventory()[i].IncreaseCount();
			active = false;
		}
	}
	
	if(active)
	{
		AddElement(inventory, sizeOfInventory, sizeOfInventory - 1, _item);
	}
}
コード例 #3
0
ファイル: CInventory.cpp プロジェクト: xardasVB/Deathspeakers
void CInventory::RemoveItem(CItem _item)
{
	int position;
	for (int i = 0; i < sizeOfInventory; i++)
	{
		if (strcmp(GetInventory()[i].GetName(), _item.GetName()) == 0)
		{
			position = i;
			if (GetInventory()[i].GetCount() == 1)
			{
				RemoveElement(inventory, sizeOfInventory, position);
			}
			else
			{
				GetInventory()[i].DecreaseCount();
			}
		}
	}	
}
コード例 #4
0
ファイル: CClientUse.cpp プロジェクト: Sphereserver/Source
void CClient::Cmd_EditItem( CObjBase *pObj, int iSelect )
{
	ADDTOCALLSTACK("CClient::Cmd_EditItem");
	// ARGS:
	//   iSelect == -1 = setup.
	//   m_Targ_Text = what are we doing to it ?
	//
	if ( !pObj )
		return;

	CContainer *pContainer = dynamic_cast<CContainer *>(pObj);
	if ( !pContainer )
	{
		addGumpDialogProps(pObj->GetUID());
		return;
	}

	if ( iSelect == 0 )		// cancelled
		return;

	if ( iSelect > 0 )		// we selected an item
	{
		if ( static_cast<size_t>(iSelect) >= COUNTOF(m_tmMenu.m_Item) )
			return;

		if ( m_Targ_Text.IsEmpty() )
			addGumpDialogProps(m_tmMenu.m_Item[static_cast<size_t>(iSelect)]);
		else
			OnTarg_Obj_Set(CGrayUID(m_tmMenu.m_Item[static_cast<size_t>(iSelect)]).ObjFind());
		return;
	}
	
	CMenuItem item[minimum(COUNTOF(m_tmMenu.m_Item), MAX_MENU_ITEMS)];	// Most as we want to display at one time.
	item[0].m_sText.Format("Contents of %s", pObj->GetName());

	size_t count = 0;
	for ( CItem *pItem = pContainer->GetContentHead(); pItem != NULL; pItem = pItem->GetNext() )
	{
		count++;
		m_tmMenu.m_Item[count] = pItem->GetUID();
		item[count].m_sText = pItem->GetName();
		ITEMID_TYPE idi = pItem->GetDispID();
		item[count].m_id = static_cast<WORD>(idi);
		item[count].m_color = 0;

		if ( !pItem->IsType(IT_EQ_MEMORY_OBJ) )
		{
			HUE_TYPE wHue = pItem->GetHue();
			if ( wHue != 0 )
			{
				wHue = (wHue == 1 ? 0x7FF : wHue - 1);
				item[count].m_color = wHue;
			}
		}

		if ( count >= (COUNTOF(item) - 1) )
			break;
	}
	
	ASSERT(count < COUNTOF(item));
	addItemMenu(CLIMODE_MENU_EDIT, item, count, pObj);
}
コード例 #5
0
ファイル: CSector.cpp プロジェクト: MortalROs/Source
void CSector::OnTick(int iPulseCount)
{
	ADDTOCALLSTACK_INTENSIVE("CSector::OnTick");
	// CWorld gives OnTick() to all CSectors.

	EXC_TRY("Tick");
	EXC_SET("light change");

	//	do not tick sectors on maps not supported by server
	if ( !g_MapList.m_maps[m_map] ) return;

	// Check for light change before putting the sector to sleep, since in other case the
	// world light levels will be shitty
	bool fEnvironChange = false;
	bool fLightChange = false;
	bool fSleeping = false;

	if ( ! ( iPulseCount & 0x7f ))	// 30 seconds or so.
	{
		// check for local light level change ?
		BYTE blightprv = m_Env.m_Light;
		m_Env.m_Light = GetLightCalc( false );
		if ( m_Env.m_Light != blightprv )
		{
			fEnvironChange = true;
			fLightChange = true;
		}
	}

	EXC_SET("sector sleeping?");
	size_t clients = m_Chars_Active.HasClients();

	if ( clients <= 0 ) // having no clients inside
	{
		// Put the sector to sleep if no clients been here in a while.
		fSleeping = IsSectorSleeping();
		if ( fSleeping )
		{
			if ( !g_Cfg.m_iSectorSleepMask )
				return;
			if (( iPulseCount & g_Cfg.m_iSectorSleepMask ) != ( GetIndex() & g_Cfg.m_iSectorSleepMask ))
				return;
		}
	}

	EXC_SET("sound effects");
	// random weather noises and effects.
	SOUND_TYPE sound = 0;
	bool fWeatherChange = false;
	int iRegionPeriodic = 0;

	if ( ! ( iPulseCount & 0x7f ))	// 30 seconds or so.
	{
		// Only do this every x minutes or so (TICK_PER_SEC)
		// check for local weather change ?
		WEATHER_TYPE weatherprv = m_Env.m_Weather;
		if ( ! Calc_GetRandVal( 30 ))	// change less often
		{
			m_Env.m_Weather = GetWeatherCalc();
			if ( weatherprv != m_Env.m_Weather )
			{
				fWeatherChange = true;
				fEnvironChange = true;
			}
		}

		// Random area noises. Only do if clients about.
		if ( clients > 0 )
		{
			iRegionPeriodic = 2;

			static const SOUND_TYPE sm_SfxRain[] = { 0x10, 0x11 };
			static const SOUND_TYPE sm_SfxWind[] = { 0x14, 0x15, 0x16 };
			static const SOUND_TYPE sm_SfxThunder[] = { 0x28, 0x29 , 0x206 };

			// Lightning ?	// wind, rain,
			switch ( GetWeather() )
			{
				case WEATHER_CLOUDY:
					break;

				case WEATHER_SNOW:
					if ( ! Calc_GetRandVal(5) )
						sound = sm_SfxWind[ Calc_GetRandVal( COUNTOF( sm_SfxWind )) ];
					break;

				case WEATHER_RAIN:
					{
						int iVal = Calc_GetRandVal(30);
						if ( iVal < 5 )
						{
							// Mess up the light levels for a sec..
							LightFlash();
							sound = sm_SfxThunder[ Calc_GetRandVal( COUNTOF( sm_SfxThunder )) ];
						}
						else if ( iVal < 10 )
							sound = sm_SfxRain[ Calc_GetRandVal( COUNTOF( sm_SfxRain )) ];
						else if ( iVal < 15 )
							sound = sm_SfxWind[ Calc_GetRandVal( COUNTOF( sm_SfxWind )) ];
					}
					break;

				default:
					break;
			}
		}
	}

	// regen all creatures and do AI

	ProfileTask charactersTask(PROFILE_CHARS);

	//pChar = STATIC_CAST <CChar*>( m_Chars_Active.GetHead());
	CChar * pCharNext = NULL;
	CChar * pChar = dynamic_cast <CChar*>( m_Chars_Active.GetHead());
	for ( ; pChar != NULL; pChar = pCharNext )
	{
		EXC_TRYSUB("TickChar");

		pCharNext = pChar->GetNext();
		if (( fEnvironChange ) && ( IsTrigUsed(TRIGGER_ENVIRONCHANGE) ))
			pChar->OnTrigger(CTRIG_EnvironChange, pChar);

		if ( pChar->IsClient())
		{
			CClient * pClient = pChar->GetClient();
			ASSERT( pClient );
			if ( sound )
				pClient->addSound(sound, pChar);

			if ( fLightChange && ! pChar->IsStatFlag( STATF_DEAD | STATF_NightSight ))
				pClient->addLight();

			if ( fWeatherChange )
				pClient->addWeather(GetWeather());

			if ( iRegionPeriodic && pChar->m_pArea )
			{
				if (( iRegionPeriodic == 2 )&&( IsTrigUsed(TRIGGER_REGPERIODIC) ))
				{
					pChar->m_pArea->OnRegionTrigger( pChar, RTRIG_REGPERIODIC );
					iRegionPeriodic--;
				}
				if ( IsTrigUsed(TRIGGER_CLIPERIODIC) )
					pChar->m_pArea->OnRegionTrigger( pChar, RTRIG_CLIPERIODIC );
			}
		}
		// Can only die on your own tick.
		if ( !pChar->OnTick() )
			pChar->Delete();

		EXC_CATCHSUB("Sector");

		EXC_DEBUGSUB_START;
		CPointMap pt = GetBasePoint();
		g_Log.EventDebug("char 0%lx '%s'\n", static_cast<DWORD>(pChar->GetUID()), pChar->GetName());
		g_Log.EventDebug("sector #%d [%d,%d,%d,%d]\n", GetIndex(),  pt.m_x, pt.m_y, pt.m_z, pt.m_map);
		EXC_DEBUGSUB_END;
	}

	// decay items on ground = time out spells / gates etc.. etc..
	// No need to check these so often !

	ProfileTask itemsTask(PROFILE_ITEMS);

	CItem * pItemNext = NULL;
	CItem * pItem = dynamic_cast <CItem*>( m_Items_Timer.GetHead());
	for ( ; pItem != NULL; pItem = pItemNext )
	{
		EXC_TRYSUB("TickItem");
		pItemNext = pItem->GetNext();

		EXC_SETSUB("TimerExpired");
		if ( pItem->IsTimerExpired() )
		{
			EXC_SETSUB("ItemTick");
			if ( !pItem->OnTick() )
			{
				EXC_SETSUB("ItemDelete");
				pItem->Delete();
			}
			else
			{
				EXC_SETSUB("TimerExpired2");
				if ( pItem->IsTimerExpired() )	// forgot to clear the timer.? strange.
				{
					EXC_SETSUB("SetTimeout");
					pItem->SetTimeout(-1);
				}
			}
		}

		EXC_SETSUB("UpdateFlags");
		pItem->OnTickStatusUpdate();

#ifdef _WIN32
		EXC_CATCHSUB("Sector");

		EXC_DEBUGSUB_START;
		CPointMap pt = GetBasePoint();
		g_Log.EventError("item 0%lx '%s' [timer=%lld, type=%lld]\n", static_cast<DWORD>(pItem->GetUID()), pItem->GetName(), pItem->GetTimerAdjusted(), static_cast<int>(pItem->GetType()));
		g_Log.EventError("sector #%d [%d,%d,%d,%d]\n", GetIndex(),  pt.m_x, pt.m_y, pt.m_z, pt.m_map);
		
		EXC_DEBUGSUB_END;
#else
		}
#ifndef _DEBUG
		catch ( const CGrayError& e )
コード例 #6
0
BOOL CJewelOfHarmonySystem::StrengthenItemByJewelOfHarmony(LPOBJ lpObj, int source, int target)
{
	if ( this->m_bSystemStrengthenItem == FALSE )
	{
		GCServerMsgStringSend(lMsg.Get(MSGGET(13, 52)), lpObj->m_Index, 1);
		return FALSE;
	}

	if ( source < 0 || source > MAIN_INVENTORY_SIZE-1 )
		return FALSE;

	if ( target < 0 || target > MAIN_INVENTORY_SIZE-1 )
		return FALSE;

	if ( lpObj->pInventory[source].IsItem() == FALSE )
		return FALSE;

	if ( lpObj->pInventory[target].IsItem() == FALSE )
		return FALSE;

	CItem * pSource = &lpObj->pInventory[source];
	CItem * pTarget = &lpObj->pInventory[target];

	if ( this->IsStrengthenByJewelOfHarmony(pTarget) == TRUE )
	{
		CLog.LogAdd("[JewelOfHarmony][Strengten Item] Already Strengtened [%s][%s]",
			lpObj->AccountID, lpObj->Name);

		return FALSE;
	}

	if (pTarget->IsSetItem() == TRUE )
	{
		GCServerMsgStringSend(lMsg.Get(MSGGET(13, 44)), lpObj->m_Index, 1);
		CLog.LogAdd("[JewelOfHarmony][Strengten Item] SetItem not enable to Strengtened [%s][%s]",
			lpObj->AccountID, lpObj->Name);

		return FALSE;
	}

	int iItemType = this->_GetItemType(pTarget);

	if ( iItemType == JEWELOFHARMONY_ITEM_TYPE_NULL )
	{
		CLog.LogAdd("[JewelOfHarmony][Strengten Item] Strenghten Fail [%s][%s] Name[%s] Type[%d] Serial[%d] Invalid ItemType[%d]",
			lpObj->AccountID, lpObj->Name, pTarget->GetName(), pTarget->m_Type,
			pTarget->m_Number, iItemType);
		
		return FALSE;
	}

	int iItemOption = this->_GetSelectRandomOption(pTarget, iItemType);

	if ( iItemOption == AT_JEWELOFHARMONY_NOT_STRENGTHEN_ITEM )
	{
		CLog.LogAdd("[JewelOfHarmony][Strengten Item] Strenghten Fail - NOT OPTION [%s][%s] Name[%s] Type[%d] Serial[%d] ItemType[%d]",
			lpObj->AccountID, lpObj->Name, pTarget->GetName(), pTarget->m_Type,
			pTarget->m_Number, iItemType);
		
		return FALSE;
	}

	int iItemOptionLevel = this->m_itemOption[iItemType][iItemOption].iRequireLevel;
	int iSuccessRate = rand() % 100;

	if ( iSuccessRate >= this->m_iRateStrengthenSuccess )
	{
		CLog.LogAdd("[JewelOfHarmony][Strengten Item] Strenghten Fail [%s][%s] Name[%s] Type[%d] Serial[%d]  Rate (%d/%d)",
			lpObj->AccountID, lpObj->Name, pTarget->GetName(), pTarget->m_Type,
			pTarget->m_Number, iSuccessRate, this->m_iRateStrengthenSuccess);
		GCServerMsgStringSend(lMsg.Get(MSGGET(13, 45)), lpObj->m_Index, 1);
		return TRUE;
	}


	this->_MakeOption(pTarget, iItemOption, iItemOptionLevel);

	CLog.LogAdd("[JewelOfHarmony][Strengten Item] Strenghten Success [%s][%s] Name[%s] Type[%d] Serial[%d] Rate (%d/%d) Option %d OptionLevel %d",
		lpObj->AccountID, lpObj->Name, pTarget->GetName(), pTarget->m_Type,
		pTarget->m_Number, iSuccessRate, this->m_iRateStrengthenSuccess,
		iItemOption, iItemOptionLevel);

	GCServerMsgStringSend(lMsg.Get(MSGGET(13, 46)), lpObj->m_Index, 1);

	gObjMakePreviewCharSet(lpObj->m_Index);

	float levelitemdur = (float)ItemGetDurability(lpObj->pInventory[target].m_Type,
		lpObj->pInventory[target].m_Level, lpObj->pInventory[target].IsExtItem(),
		lpObj->pInventory[target].IsSetItem());

	lpObj->pInventory[target].m_Durability = levelitemdur * lpObj->pInventory[target].m_Durability / lpObj->pInventory[target].m_BaseDurability;

	lpObj->pInventory[target].Convert(lpObj->pInventory[target].m_Type,
		lpObj->pInventory[target].m_Option1, lpObj->pInventory[target].m_Option2,
		lpObj->pInventory[target].m_Option3, lpObj->pInventory[target].m_NewOption,
		lpObj->pInventory[target].m_SetOption, lpObj->pInventory[target].m_ItemOptionEx,lpObj->pInventory[target].m_ItemSocket);


	return TRUE;
}
コード例 #7
0
BOOL CJewelOfHarmonySystem::RestoreStrengthenItem(LPOBJ lpObj)
{
	if ( this->m_bSystemRestoreStrengthen != TRUE )
	{
		GCServerMsgStringSend(lMsg.Get(MSGGET(13,54)), lpObj->m_Index, 1);
		return TRUE;
	}

	lpObj->ChaosLock = TRUE;

	PMSG_CHAOSMIXRESULT pMsg;

	C1HeadSet((LPBYTE)&pMsg, 0x86, sizeof(pMsg));
	pMsg.Result = 0;
	int iStrengtenItemCount = 0;
	int iInvalidItemCount = 0;
	CItem * pItem = NULL;

	for ( int n=0;n<CHAOS_BOX_SIZE;n++)
	{
		if ( lpObj->pChaosBox[n].IsItem() == TRUE )
		{
			if ( this->IsStrengthenByJewelOfHarmony(&lpObj->pChaosBox[n]) == TRUE )
			{
				iStrengtenItemCount++;
				pItem = &lpObj->pChaosBox[n];
			}
		}
	}

	if ( iStrengtenItemCount != 1 )
	{
		gSendProto.DataSend(lpObj->m_Index, (LPBYTE)&pMsg, pMsg.h.size);
		lpObj->ChaosLock = FALSE;

		return FALSE;
	}
	
	int iItemOption = this->GetItemStrengthenOption(pItem);
	int iItemOptionLevel = this->_GetItemOptionLevel(pItem);
	int JEWEL_OF_HARMONY_RETORE_NEEDZEN = this->_GetZenForRestoreItem(pItem);

	if ( JEWEL_OF_HARMONY_RETORE_NEEDZEN < 0 ) 
	{
		gSendProto.DataSend(lpObj->m_Index, (LPBYTE)&pMsg, pMsg.h.size);
		lpObj->ChaosLock = FALSE;

		return FALSE;
	}

	int iChaosTaxMoney = JEWEL_OF_HARMONY_RETORE_NEEDZEN * g_CastleSiegeSync.GetTaxRateChaos(lpObj->m_Index) / 100;

	if ( iChaosTaxMoney < 0 )
		iChaosTaxMoney = 0;

	JEWEL_OF_HARMONY_RETORE_NEEDZEN += iChaosTaxMoney;

	if ( JEWEL_OF_HARMONY_RETORE_NEEDZEN < 0 )
		JEWEL_OF_HARMONY_RETORE_NEEDZEN = 0;

	if ( lpObj->Money < JEWEL_OF_HARMONY_RETORE_NEEDZEN )
	{
		pMsg.Result = 2;
		gSendProto.DataSend(lpObj->m_Index, (LPBYTE)&pMsg, pMsg.h.size);
		lpObj->ChaosLock = FALSE;

		return FALSE;
	}

	lpObj->Money -= JEWEL_OF_HARMONY_RETORE_NEEDZEN;
	g_CastleSiegeSync.AddTributeMoney(iChaosTaxMoney);
	GCMoneySend(lpObj->m_Index, lpObj->Money);
	LogChaosItem(lpObj, "JewelOfHarmony][Restore Item");
	CLog.LogAdd("[JewelOfHarmony][Restore Item] - Restore Start");

	CLog.LogAdd("[JewelOfHarmony][Restore Item] Restore Strengtened Item [%s][%s] Name[%s] ItemType[%d] Serial[%d] OptionType[%d] OptionLevel [%d] Money %d-%d",
		lpObj->AccountID, lpObj->Name, pItem->GetName(), pItem->m_Type,
		pItem->m_Number, iItemOption, iItemOptionLevel, 
		lpObj->Money, JEWEL_OF_HARMONY_RETORE_NEEDZEN);

	pItem->m_JewelOfHarmonyOption = 0;
	GCUserChaosBoxSend(lpObj, 0);
	this->ShowStrengthenOption(pItem);
	lpObj->ChaosLock = FALSE;

	return TRUE;
}
コード例 #8
0
BOOL CJewelOfHarmonySystem::SmeltItemBySmeltingStone(LPOBJ lpObj, int source, int target)
{
	if ( this->m_bSystemSmeltingItem == FALSE )
	{
		GCServerMsgStringSend(lMsg.Get(MSGGET(13,51)), lpObj->m_Index, 1);
		return FALSE;
	}

	if ( source < 0 || source > MAIN_INVENTORY_SIZE-1 )
		return FALSE;

	if ( target < 0 || target > MAIN_INVENTORY_SIZE-1 )
		return FALSE;

	if ( lpObj->pInventory[source].IsItem() == FALSE )
		return FALSE;

	if ( lpObj->pInventory[target].IsItem() == FALSE )
		return FALSE;

	CItem * pSource = &lpObj->pInventory[source];
	CItem * pTarget = &lpObj->pInventory[target];

	if ( !this->IsStrengthenByJewelOfHarmony(pTarget)  )
	{
		CLog.LogAdd("[JewelOfHarmony][Smelt Item] Not Strengten Item [%s][%s]",
			lpObj->AccountID, lpObj->Name);

		return FALSE;
	}

	int iItemOptionLevel = this->_GetItemOptionLevel(pTarget);

	if ( iItemOptionLevel >= pTarget->m_Level )
	{
		if ( iItemOptionLevel == 13 )
		{
			GCServerMsgStringSend(lMsg.Get(MSGGET(13,41)), lpObj->m_Index, 1);
		}
		else
		{
			GCServerMsgStringSend(lMsg.Get(MSGGET(13,40)), lpObj->m_Index, 1);
		}

		CLog.LogAdd("[JewelOfHarmony][Smelt Item] Already Have Max OptionLevel [%s][%s] OptionLevel [%d] ItemLevel [%d]",
			lpObj->AccountID, lpObj->Name, iItemOptionLevel, pTarget->m_Level);

		return FALSE;
	}

	if ( this->_GetItemType(pTarget) == JEWELOFHARMONY_ITEM_TYPE_WEAPON )
	{
		if ( this->GetItemStrengthenOption(pTarget) == AT_JEWELOFHARMONY_WEAPON_IMPROVE_MINATTACKDAMAGE )
		{
			int iNextLevel = this->_GetItemOptionLevel(pTarget)+1;
			BYTE iValue = this->m_itemOption[JEWELOFHARMONY_ITEM_TYPE_WEAPON][AT_JEWELOFHARMONY_WEAPON_IMPROVE_MINATTACKDAMAGE].iItemEffectValue[iNextLevel];

			if ( (pTarget->m_DamageMin+iValue) > (pTarget->m_DamageMax-1) )
			{
				GCServerMsgStringSend(lMsg.Get(MSGGET(13,41)), lpObj->m_Index, 1);
				return FALSE;
			}
		}
	}

	int iSuccessRate = rand() % 100;
	int iRateSmeltingSuccess = 0;
	BOOL bIsNormalSmeltingStone = this->_IsJewelOfHarmonySmeltingItemNor(pSource->m_Type);

	if ( bIsNormalSmeltingStone == TRUE )
		iRateSmeltingSuccess = this->m_iRateSmeltingSuccessNor;
	else
		iRateSmeltingSuccess = this->m_iRateSmeltingSuccessExt;

	if ( iSuccessRate >= iRateSmeltingSuccess )
	{
		int iItemOptionNewLevel = _GetItemOptionRequireLevel(pTarget);
		pTarget->m_JewelOfHarmonyOption = pTarget->m_JewelOfHarmonyOption & 0xF0;
		pTarget->m_JewelOfHarmonyOption |= iItemOptionNewLevel & 0x0F;
		this->ShowStrengthenOption(pTarget);

		CLog.LogAdd("[JewelOfHarmony][Smelt Item] Smelt Item Fail by Normal[%d] [%s][%s] Name[%s] Type [%d] Serial [%d] Rate(%d/%d) Level(%d->%d)",
			bIsNormalSmeltingStone, lpObj->AccountID, lpObj->Name, pTarget->GetName(), pTarget->m_Type,
			pTarget->m_Number, iSuccessRate, iRateSmeltingSuccess, iItemOptionLevel, iItemOptionNewLevel);
		GCServerMsgStringSend(lMsg.Get(MSGGET(13, 47)), lpObj->m_Index, 1);
	}
	else
	{
		int iItemOptionNewLevel = iItemOptionLevel+1;
		pTarget->m_JewelOfHarmonyOption = pTarget->m_JewelOfHarmonyOption & 0xF0;
		pTarget->m_JewelOfHarmonyOption |= iItemOptionNewLevel & 0x0F;
		this->ShowStrengthenOption(pTarget);

		CLog.LogAdd("[JewelOfHarmony][Smelt Item] Smelt Item Success by Normal[%d] [%s][%s] Name[%s] Type [%d] Serial [%d] Rate(%d/%d) Level(%d->%d)",
			bIsNormalSmeltingStone, lpObj->AccountID, lpObj->Name, pTarget->GetName(), pTarget->m_Type,
			pTarget->m_Number, iSuccessRate, iRateSmeltingSuccess, iItemOptionLevel, iItemOptionNewLevel & 0x0F);
		GCServerMsgStringSend(lMsg.Get(MSGGET(13, 48)), lpObj->m_Index, 1);
	}

	return TRUE;
}
コード例 #9
0
ファイル: CCharUse.cpp プロジェクト: DarkLotus/Source
void CChar::Use_CarveCorpse( CItemCorpse * pCorpse )
{
	ADDTOCALLSTACK("CChar::Use_CarveCorpse");
	CREID_TYPE CorpseID = pCorpse->m_itCorpse.m_BaseID;
	CCharBase *pCorpseDef = CCharBase::FindCharBase(CorpseID);
	if ( !pCorpseDef || pCorpse->m_itCorpse.m_carved )
	{
		SysMessageDefault(DEFMSG_CARVE_CORPSE_NOTHING);
		return;
	}

	CChar *pChar = pCorpse->m_uidLink.CharFind();
	CPointMap pnt = pCorpse->GetTopLevelObj()->GetTopPoint();

	UpdateAnimate(ANIM_BOW);
	if ( pCorpse->m_TagDefs.GetKeyNum("BLOOD", true) )
	{
		CItem *pBlood = CItem::CreateBase(ITEMID_BLOOD4);
		ASSERT(pBlood);
		pBlood->SetHue(pCorpseDef->m_wBloodHue);
		pBlood->MoveToDecay(pnt, 5 * TICK_PER_SEC);
	}

	size_t iItems = 0;
	for ( size_t i = 0; i < pCorpseDef->m_BaseResources.GetCount(); i++ )
	{
		long long iQty = pCorpseDef->m_BaseResources[i].GetResQty();
		RESOURCE_ID rid = pCorpseDef->m_BaseResources[i].GetResourceID();
		if ( rid.GetResType() != RES_ITEMDEF )
			continue;

		ITEMID_TYPE id = static_cast<ITEMID_TYPE>(rid.GetResIndex());
		if ( id == ITEMID_NOTHING )
			break;

		iItems++;
		CItem *pPart = CItem::CreateTemplate(id, NULL, this);
		ASSERT(pPart);
		switch ( pPart->GetType() )
		{
			case IT_FOOD:
			case IT_FOOD_RAW:
			case IT_MEAT_RAW:
				SysMessageDefault(DEFMSG_CARVE_CORPSE_MEAT);
				//pPart->m_itFood.m_MeatType = CorpseID;
				break;
			case IT_HIDE:
				SysMessageDefault(DEFMSG_CARVE_CORPSE_HIDES);
				//pPart->m_itSkin.m_creid = CorpseID;
				if ( (g_Cfg.m_iRacialFlags & RACIALF_HUMAN_WORKHORSE) && IsHuman() )	// humans always find 10% bonus when gathering hides, ores and logs (Workhorse racial trait)
					iQty = iQty * 110 / 100;
				break;
			case IT_FEATHER:
				SysMessageDefault(DEFMSG_CARVE_CORPSE_FEATHERS);
				//pPart->m_itSkin.m_creid = CorpseID;
				break;
			case IT_WOOL:
				SysMessageDefault(DEFMSG_CARVE_CORPSE_WOOL);
				//pPart->m_itSkin.m_creid = CorpseID;
				break;
			/*case IT_DRAGON_SCALE:			// TO-DO (typedef IT_DRAGON_SCALE doesn't exist yet)
				SysMessageDefault(DEFMSG_CARVE_CORPSE_SCALES);
				//pPart->m_itSkin.m_creid = CorpseID;
				break;*/
			default:
				break;
		}

		if ( iQty > 1 )
			pPart->SetAmount(static_cast<unsigned int>(iQty));

		if ( pChar && pChar->m_pPlayer )
		{
			TCHAR *pszMsg = Str_GetTemp();
			sprintf(pszMsg, g_Cfg.GetDefaultMsg(DEFMSG_CORPSE_NAME), pPart->GetName(), pChar->GetName());
			pPart->SetName(pszMsg);
			pPart->m_uidLink = pChar->GetUID();
			pPart->MoveToDecay(pnt, pPart->GetDecayTime());
			continue;
		}
		pCorpse->ContentAdd(pPart);
	}

	if ( iItems < 1 )
		SysMessageDefault(DEFMSG_CARVE_CORPSE_NOTHING);

	CheckCorpseCrime(pCorpse, false, false);
	pCorpse->m_itCorpse.m_carved = 1;			// mark as been carved
	pCorpse->m_itCorpse.m_uidKiller = GetUID();	// by you

	if ( pChar && pChar->m_pPlayer )
		pCorpse->SetTimeout(0);		// reset corpse timer to make it turn bones
}
コード例 #10
0
bool ItemUpgradeJewels::ProcUpgrade(LPOBJ lpUser, int JewelPos, int TargetPos, ItemUpgradeJewelsInfo* lpJewel)
{
	if( JewelPos < 0 || JewelPos > MAIN_INVENTORY_SIZE-1 )
	{
		return false;
	}

	if( TargetPos < 0 || TargetPos > MAIN_INVENTORY_SIZE-1 )
	{
		return false;
	}

	if(		!lpUser->pInventory[JewelPos].IsItem()
		||	!lpUser->pInventory[TargetPos].IsItem() )
	{
		return false;
	}
	
	int JewelCode = lpUser->pInventory[JewelPos].m_Type;
	int TargetCode = lpUser->pInventory[TargetPos].m_Type;

	if(		JewelCode == ITEMGET(14, 13) 
		&&	TargetCode == ITEMGET(0, 41) )
	{
		if( gObjItemLevelUpPickAxe(lpUser, JewelPos, TargetPos) == TRUE )
		{
			return true;
		}
		else
		{
			return false;
		}
	}

	if(		JewelCode == ITEMGET(14, 13) 
		&&	TargetCode == ITEMGET(13, 37) )
	{
		CItem* ItemFenrir = &lpUser->pInventory[TargetPos];

		if( ItemFenrir->m_Durability >= 255 )
		{
			return false;
		}

		if( rand()% 10000 < g_iFenrirRepairRate )
		{
			int iAddDur = rand()%150 + 50;

			if( (ItemFenrir->m_Durability + iAddDur) > 255 )
			{
				ItemFenrir->m_Durability = 255.0f;
			}
			else
			{
				ItemFenrir->m_Durability += iAddDur;
			}

			MsgOutput(lpUser->m_Index,lMsg.Get(3342),int(ItemFenrir->m_Durability));
			LogAddTD("[FENRIR REPAIR][SUCCESS] [%s][%s] - %d/255 (+%d)",lpUser->AccountID,
				lpUser->Name,ItemFenrir->m_Durability,iAddDur);
		}
		else
		{
			MsgOutput(lpUser->m_Index,lMsg.Get(3343));
			LogAddTD("[FENRIR REPAIR][FAILED] [%s][%s] - %d/255 (+%d)",lpUser->AccountID,lpUser->Name,
				ItemFenrir->m_Durability);
		}

		return true;
	}

	CItem* ItemTarget = &lpUser->pInventory[TargetPos];

	if( ItemTarget->m_bLuckySet == TRUE )
	{
		return false;
	}
	
	if( lpJewel->TargetLevelMax != (BYTE)-1
		&& ItemTarget->m_Level >= lpJewel->TargetLevelMax )
	{
		return false;
	}

	if( lpJewel->TargetLevelMin != (BYTE)-1
		&& ItemTarget->m_Level < lpJewel->TargetLevelMin )
	{
		return false;
	}
	
	if( ItemTarget->m_Type >= ITEMGET(12,36) && 
		ItemTarget->m_Type <= ITEMGET(12,40) )
	{

	}
#if (CUSTOM_WINGS == 1)
	else if( ItemTarget->m_Type >= ITEMGET(12,440) && ItemTarget->m_Type <= ITEMGET(12,445) )
	{

	}
#endif
	else if( ItemTarget->m_Type >= ITEMGET(12,41) &&
			 ItemTarget->m_Type <= ITEMGET(12,43) )
	{

	}
	else if( ItemTarget->m_Type == ITEMGET(12,49) ||
			 ItemTarget->m_Type == ITEMGET(12,50) )
	{

	}
	else if( ItemTarget->m_Type >= ITEMGET(12,200) && ItemTarget->m_Type <= ITEMGET(12,214) )
	{

	}
	else if( ItemTarget->m_Type >= ITEMGET(12,262) &&
			 ItemTarget->m_Type <= ITEMGET(12,265) )
	{

	}
	else if(!(ItemTarget->m_Type < ITEMGET(12,7)
		|| ItemTarget->m_Type == ITEMGET(13,30) )
		|| ItemTarget->m_Type == ITEMGET(4,7)
		|| ItemTarget->m_Type == ITEMGET(4,15))
	{
		return false;
	}

	if( ItemTarget->m_NewOption && lpJewel->TargetRankExcellent != 1 )
	{
		return false;
	}

	if( gSetItemOption.IsSetItem(ItemTarget->m_Type) && ItemTarget->m_SetOption > 0 
		&& lpJewel->TargetRankAncient != 1 )
	{
		return false;
	}

	if( g_SocketItem.IsSocketItem(ItemTarget->m_Type) && lpJewel->TargetRankSocket != 1 )
	{
		return false;
	}

	DWORD Rate = lpJewel->DefaultRate;

	for( int i = 0; i < lpJewel->m_RateChangeRules.size(); i++ )
	{
		bool Bonus = false;

		if(		lpJewel->m_RateChangeRules[i].Type == ItemUpgradeJewelsRateType::Luck
			&&	ItemTarget->m_Option2 )
		{
			Bonus = true;
		}
		else if(	lpJewel->m_RateChangeRules[i].Type == ItemUpgradeJewelsRateType::Excellent
				&&	ItemTarget->m_NewOption )
		{
			Bonus = true;
		}
		else if(	lpJewel->m_RateChangeRules[i].Type == ItemUpgradeJewelsRateType::Ancient
				&&	gSetItemOption.IsSetItem(ItemTarget->m_Type) && ItemTarget->m_SetOption > 0 )
		{
			Bonus = true;
		}
		else if(	lpJewel->m_RateChangeRules[i].Type == ItemUpgradeJewelsRateType::Socket
				&&	g_SocketItem.IsSocketItem(ItemTarget->m_Type) )
		{
			Bonus = true;
		}
		else if(	lpJewel->m_RateChangeRules[i].Type == ItemUpgradeJewelsRateType::Level
				&&	lpJewel->m_RateChangeRules[i].Level != (BYTE)-1 && lpJewel->m_RateChangeRules[i].Level == ItemTarget->m_Level )
		{
			Bonus = true;
		}
		else if(	lpJewel->m_RateChangeRules[i].Type == ItemUpgradeJewelsRateType::Option
				&&	lpJewel->m_RateChangeRules[i].Option != (BYTE)-1 && lpJewel->m_RateChangeRules[i].Option == ItemTarget->m_Option3 )
		{
			Bonus = true;
		}

		if( Bonus )
		{
			Rate -= lpJewel->m_RateChangeRules[i].RateDecrease;
			Rate += lpJewel->m_RateChangeRules[i].RateIncrease;
		}
	}

	if( JewelCode == ITEMGET(14, 13) )
	{
		if( rand() % 10000 < Rate )
		{
			ItemTarget->m_Level++;
		
			if( ItemTarget->m_Level > lpJewel->TargetLevelMax )
			{
				ItemTarget->m_Level = lpJewel->TargetLevelMax;
			}
		}		
	}
	else if( JewelCode == ITEMGET(14, 14) )
	{
		if( rand() % 10000 < Rate )
		{
			ItemTarget->m_Level++;
		
			if( ItemTarget->m_Level > lpJewel->TargetLevelMax )
			{
				ItemTarget->m_Level = lpJewel->TargetLevelMax;
			}
		}
		else
		{
			if( ItemTarget->m_Level >= 7 )
			{
				ItemTarget->m_Level = 0;
			}
			else
			{
				ItemTarget->m_Level--;

				if( ItemTarget->m_Level < 0 )
				{
					ItemTarget->m_Level = 0;
				}
			}
		}
	}
	else if( JewelCode == ITEMGET(14, 16) )
	{
		if( ItemTarget->m_Option3 == 0 )
		{
			if(ItemTarget->m_Type >= ITEMGET(12,3) && ItemTarget->m_Type <= ITEMGET(12,6) ||
				ItemTarget->m_Type == ITEMGET(12,49) ||
				ItemTarget->m_Type == ITEMGET(12,42) )
			{
				ItemTarget->m_NewOption &= 0xDF;

				if(rand()%2)
				{
					ItemTarget->m_NewOption |= 0x20;
				}
			}
			
			if( ItemTarget->m_Type >= ITEMGET(12,36) &&
				ItemTarget->m_Type <= ITEMGET(12,40) ||
				ItemTarget->m_Type == ITEMGET(12,43) ||
				ItemTarget->m_Type == ITEMGET(12,50)
	#if (CUSTOM_WINGS == 1)
				|| 
				ItemTarget->m_Type >= ITEMGET(12,440) &&
				ItemTarget->m_Type <= ITEMGET(12,445)
	#endif
				)
			{
				ItemTarget->m_NewOption &= 0xDF;

				if(rand()%3)
				{
					ItemTarget->m_NewOption |= 0x20;
				}
				else if(rand()%3)
				{
					ItemTarget->m_NewOption |= 0x10;
				}
			}

			if( ItemTarget->m_Type >= ITEMGET(12,262) &&
				ItemTarget->m_Type <= ITEMGET(12,265) )
			{
				ItemTarget->m_NewOption &= 0xDF;

				if( rand()%2 )
				{
					ItemTarget->m_NewOption |= 0x10;
				}
			}
		}

		if( ItemTarget->m_Option3 >= 7 )
		{
			return false;
		}

		if( rand() % 10000 < Rate )
		{
			ItemTarget->m_Option3++;
		}
		else
		{
			ItemTarget->m_Option3 = 0;
		}
	}
	else if( JewelCode == ITEMGET(14, 42) )
	{
		if( g_kJewelOfHarmonySystem.m_bSystemSmeltingItem == false )
		{
			return false;
		}

		if( g_kJewelOfHarmonySystem.IsStrengthenByJewelOfHarmony(ItemTarget) )
		{
			LogAddTD("[JewelOfHarmony][Strengten Item] Already Strengtened [%s][%s]",
				lpUser->AccountID, lpUser->Name);
			return false;
		}
		
		int iItemType = g_kJewelOfHarmonySystem._GetItemType(ItemTarget);

		if( iItemType == JEWELOFHARMONY_ITEM_TYPE_NULL )
		{
			LogAddTD("[JewelOfHarmony][Strengten Item] Strenghten Fail [%s][%s] Name[%s] Type[%d] Serial[%d] Invalid ItemType[%d]",
				lpUser->AccountID, lpUser->Name, ItemTarget->GetName(), ItemTarget->m_Type,
				ItemTarget->m_Number, iItemType);
			return false;
		}

		int iItemOption = g_kJewelOfHarmonySystem._GetSelectRandomOption(ItemTarget, iItemType);

		if( iItemOption == AT_JEWELOFHARMONY_NOT_STRENGTHEN_ITEM )
		{
			LogAddTD("[JewelOfHarmony][Strengten Item] Strenghten Fail - NOT OPTION [%s][%s] Name[%s] Type[%d] Serial[%d] ItemType[%d]",
				lpUser->AccountID, lpUser->Name, ItemTarget->GetName(), ItemTarget->m_Type,
				ItemTarget->m_Number, iItemType);
			return false;
		}
		
		int iItemOptionLevel = g_kJewelOfHarmonySystem.m_itemOption[iItemType][iItemOption].iRequireLevel;

		if( rand() % 10000 < Rate )
		{
			g_kJewelOfHarmonySystem._MakeOption(ItemTarget, iItemOption, iItemOptionLevel);
			LogAddTD("[JewelOfHarmony][Strengten Item] Strenghten Success [%s][%s] Name[%s] Type[%d] Serial[%d] Rate (%d/%d) Option %d OptionLevel %d",
				lpUser->AccountID, lpUser->Name, ItemTarget->GetName(), ItemTarget->m_Type,
				ItemTarget->m_Number, Rate, Rate,
				iItemOption, iItemOptionLevel);

			GCServerMsgStringSend(lMsg.Get(MSGGET(13, 46)), lpUser->m_Index, 1);
		}
		else
		{
			LogAddTD("[JewelOfHarmony][Strengten Item] Strenghten Fail [%s][%s] Name[%s] Type[%d] Serial[%d]  Rate (%d/%d)",
				lpUser->AccountID, lpUser->Name, ItemTarget->GetName(), ItemTarget->m_Type,
				ItemTarget->m_Number, Rate, Rate);
			GCServerMsgStringSend(lMsg.Get(MSGGET(13, 45)), lpUser->m_Index, 1);
		}
	}

	gObjMakePreviewCharSet(lpUser->m_Index);

	float levelitemdur = (float)ItemGetDurability(lpUser->pInventory[TargetPos].m_Type,
		lpUser->pInventory[TargetPos].m_Level,
		lpUser->pInventory[TargetPos].IsExtItem(),
		lpUser->pInventory[TargetPos].IsSetItem());

	lpUser->pInventory[TargetPos].m_Durability = levelitemdur * lpUser->pInventory[TargetPos].m_Durability / lpUser->pInventory[TargetPos].m_BaseDurability;

	lpUser->pInventory[TargetPos].Convert(
			lpUser->pInventory[TargetPos].m_Type,
			lpUser->pInventory[TargetPos].m_Option1,
			lpUser->pInventory[TargetPos].m_Option2,
			lpUser->pInventory[TargetPos].m_Option3,
			lpUser->pInventory[TargetPos].m_NewOption,
			lpUser->pInventory[TargetPos].m_SetOption,
			lpUser->pInventory[TargetPos].m_ItemOptionEx,0,-1,
			CURRENT_DB_VERSION);

	LogAddTD(lMsg.Get(557),lpUser->AccountID,lpUser->Name,lpUser->pInventory[JewelPos].m_Number,
			lpUser->pInventory[TargetPos].GetName(),lpUser->pInventory[TargetPos].m_Number,
			lpUser->pInventory[TargetPos].m_Level);
	return true;
}