예제 #1
0
파일: APet.cpp 프로젝트: rdrago/LCSource
int CAPet::GetDefenseLevel()
{
	static int armors[APET_WEARPOINT] = { APET_WEAR_HEAD, APET_WEAR_BODY, APET_WEAR_WEAPON, APET_WEAR_ACCE };

	int defenselevel = 0;
	bool bWear = false;

	int i;

	for (i = 0; i < APET_WEARPOINT; i++)
	{
		if (m_wearing[armors[i]])
		{
			CItem* pItem = m_wearing[armors[i]];
			int nThisItemLevel = pItem->GetItemLevel();
			if (defenselevel < nThisItemLevel)
				defenselevel = nThisItemLevel;
			bWear = true;
		}
	}

	if (!bWear)
	{
		defenselevel = m_level * 2;
	}

	return defenselevel;
}
bool local_exchangeWeapon(CPC* ch, CItem* item, bool bprolong, RequestClient::doItemUse* packet)
{
	int extra1 = packet->extra_1;
	int extra2 = packet->extra_2;

	CItem* vitem = ch->m_inventory.FindByVirtualIndex(extra1);
	if (!vitem)
		return false;

	if (!vitem->IsWeaponType())
		return false;

	if (vitem->m_itemProto->getItemSubTypeIdx() == extra2)
		return false;

	if (extra2 < 0 || extra2 >= 16)
		return false;

	int itemlevel = vitem->GetItemLevel();

	// 레벨, 한손검, 석궁, 스태프, 대검, 도끼, 숏스테프, 활, 단검, -1, -1, -1, 이도류, 완드, 사이드, 폴암 : 할일 : 소서러
	const static int matchTable[12][16] =
	{
		{1,48,530,600,12,558,356,50,528,-1,-1,-1,459,599,-1,-1},
		{5,53,666,628,51,601,357,56,529,-1,-1,-1,610,619,-1,-1},
		{9,55,637,629,52,602,358,57,532,-1,-1,-1,611,620,-1,-1},
		{13,107,638,630,105,603,359,106,533,-1,-1,-1,612,621,-1,-1},
		{17,180,639,631,306,604,360,185,534,-1,-1,-1,613,622,-1,-1},
		{21,322,640,632,307,605,361,341,535,-1,-1,-1,614,623,-1,-1},
		{25,323,641,633,308,606,362,342,536,-1,-1,-1,615,624,-1,-1},
		{29,324,642,634,309,607,363,343,537,-1,-1,-1,616,625,983,995},
		{33,325,643,635,310,608,364,344,538,-1,-1,-1,617,626,984,-996},
		{37,326,644,636,311,609,365,345,539,-1,-1,-1,618,627,985,997},
		{41,681,721,719,715,645,720,718,722,-1,-1,-1,716,717,986,998},
		{45,800,823,816,793,794,815,808,822,-1,-1,-1,801,809,987,999}
	};

	CItemProto* proto = NULL;
	int i;
	for (i = 0; i < 12; i++)
	{
		if (matchTable[i][0] == itemlevel)
		{
			proto = gserver->m_itemProtoList.FindIndex(matchTable[i][extra2 + 1]);
			break;
		}
	}

	if (proto == NULL)
		return false;

	CItem* newitem = gserver->m_itemProtoList.CreateItem(proto->getItemIndex(), -1, vitem->getPlus(), vitem->getFlag(), 1);
	if (!newitem)
		return false;

	GAMELOG << init("CASHITEM_CHANGE_WEAPON_WITHOUT OPTION", ch)
			<< "OLD" << delim
			<< itemlog(vitem) << delim;

	GAMELOG << "NEW" << delim
			<< itemlog(newitem) << delim;

	ch->m_inventory.decreaseItemCount(vitem, 1);

	if (ch->m_inventory.addItem(newitem) == false)
	{
		ch->m_pArea->DropItem(newitem, ch);
		newitem->m_preferenceIndex = ch->m_index;

		CNetMsg::SP rmsg(new CNetMsg);
		ItemDropMsg(rmsg, ch, newitem);
		ch->m_pArea->SendToCell(rmsg, GET_YLAYER(newitem), newitem->m_cellX, newitem->m_cellZ);
		GAMELOG << "DROP"
				<< end;
	}

	return true;
}