⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 equipmentslotcontainer.cpp

📁 奇迹世界 部分源代码奇迹世界 部分源代码奇迹世界 部分源代码
💻 CPP
字号:
// EquipmentSlotContainer.cpp: implementation of the CEquipmentSlotContainer class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "EquipmentSlotContainer.h"
#include "Player.h"
#include "Field.h"
#include <Protocol_CG.h>
#include <PacketStruct_CG.h>
#include <ItemInfoParser.h>
#include "ItemAttrCalculator.h"
#include "SkillManager.h"
#include <SCItemSlot.h>
#include <ItemFormula.h>
#include "QuickManager.h"
#include "QuickSlotContainer.h"
#include <SCQuickSlot.h>
#include "ItemManager.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CEquipmentSlotContainer::CEquipmentSlotContainer()
{
	Init( MAX_EQUIPMENT_SLOT_NUM, SI_EQUIPMENT );
}										  

CEquipmentSlotContainer::~CEquipmentSlotContainer()
{
}
	
BOOL CEquipmentSlotContainer::InsertSlot( POSTYPE AtPos, SCSlot & IN rSlot )
{
	SASSERT( m_pPlayer != NULL, "[CEquipmentSlotContainer::InsertSlot] m_pPlayer == NULL" );

	if( !CanEquip( AtPos, rSlot ) ) return FALSE;

	BOOL rt = SCSlotContainer::InsertSlot( AtPos, rSlot );
	if( !rt ) return FALSE;

	m_pPlayer->GetQuickManager()->GetQuickSlotContainer()->UpdateQuickSlot( rSlot.GetSlotIdx(), rSlot.GetPos(), rSlot.GetCode(), 
		SI_EQUIPMENT, AtPos, rSlot.GetCode() );

	// Equip AttrChange
	ItemAttrCalculator itemCalc( m_pPlayer->GetAttr(), *this );
	itemCalc.Equip( rSlot, TRUE );

	// 公扁啊 函版登菌阑 版快 胶鸥老 悸泼苞 菩矫宏 利侩捞 崔扼柳促.
	if( AtPos == eEQUIPCONTAINER_WEAPON )
	{
		m_pPlayer->GetSkillManager()->AddWeapon( rSlot.GetCode() );
	}

	// 磊脚阑 力寇茄 葛电 荤恩俊霸 朝赴促.
	MSG_CG_CHARINFO_APPREARANCE_BRD msg;
	msg.m_byCategory	= CG_CHARINFO;
	msg.m_byProtocol	= CG_CHARINFO_APPREARANCE_BRD;
	msg.m_dwObjectKey	= m_pPlayer->GetObjectKey();
	msg.m_EquipPos		= AtPos;
	msg.m_ItemCode		= rSlot.GetCode();

	m_pPlayer->SendPacketAround( &msg, sizeof(msg), FALSE );

	m_pPlayer->GetItemManager()->AddSerialCode( GetSlotIdx(), rSlot.GetSerial() );

	return rt;
}

VOID CEquipmentSlotContainer::DeleteSlot( POSTYPE AtPos, SCSlot * pSlotOut )
{
	SASSERT( m_pPlayer != NULL, "[CEquipmentSlotContainer::DeleteSlot] m_pPlayer == NULL" );

	m_pPlayer->GetItemManager()->RemoveSerialCode( GetSlot(AtPos).GetSerial() );

	SCSlotContainer::DeleteSlot( AtPos, pSlotOut );
	SASSERT( pSlotOut != NULL, "[CEquipmentSlotContainer::DeleteSlot] pSlotOut == NULL" );

	// UnEquip AttrChange
	ItemAttrCalculator itemCalc( m_pPlayer->GetAttr(), *this );
	itemCalc.UnEquip( pSlotOut, TRUE );

	// 公扁啊 函版登菌阑 版快 胶鸥老 悸泼苞 菩矫宏 利侩捞 崔扼柳促.
	if( AtPos == eEQUIPCONTAINER_WEAPON )
	{
		m_pPlayer->GetSkillManager()->DelWeapon();
	}

	MSG_CG_CHARINFO_APPREARANCE_BRD msg;
	msg.m_byCategory	= CG_CHARINFO;
	msg.m_byProtocol	= CG_CHARINFO_APPREARANCE_BRD;
	msg.m_dwObjectKey	= m_pPlayer->GetObjectKey();
	msg.m_EquipPos		= AtPos;
	msg.m_ItemCode		= 0;
//	msg.m_ItemCode		= pSlotOut->GetCode();

	m_pPlayer->SendPacketAround( &msg, sizeof(msg), FALSE );

}

VOID CEquipmentSlotContainer::UpdateSlot( POSTYPE AtPos, eSlotType type, DBSERIAL serial, SLOTCODE code, POSTYPE quickPos, DURATYPE dura, BYTE level, eUPDATE_BIT upbits )
{
	SCSlotContainer::UpdateSlot( AtPos, type, serial, code, quickPos, dura, level, upbits );
	
	ASSERT( !"厘馒芒俊辑 肋给等 备泅捞促.");
}

VOID CEquipmentSlotContainer::UpdateSlot( POSTYPE AtPos, SCSlot & IN rSlot )
{
	SCItemSlotContainer::UpdateSlot( AtPos, rSlot );

	ASSERT( !"厘馒芒俊辑 肋给等 备泅捞促.");
}

BOOL CEquipmentSlotContainer::CanEquip( POSTYPE AtPos, SCSlot & IN rSlotIn )
{
	BASE_ITEMINFO * pInfo = ItemInfoParser::Instance()->GetItemInfo( rSlotIn.GetCode() );
	if( !pInfo ) return FALSE;

	if( eITEM_MATERIAL_TYPE_CAN_EQUIP != pInfo->m_byMaterialType &&		// 1: 厘厚啊瓷捞 酒聪促
		eITEM_MATERIAL_TYPE_CAN_BOTH != pInfo->m_byMaterialType )		// 3: 笛促(厘厚,荤侩)啊瓷 窍瘤 臼促.
		return FALSE;

	// class喊 厘馒 咯何
	switch( m_pPlayer->GetCharType() )
	{
	case eCHAR_BERSERKER: if( 0 == pInfo->m_wEqClass1 ) return FALSE; break;
	case eCHAR_DRAGON	: if( 0 == pInfo->m_wEqClass2 ) return FALSE; break;
	case eCHAR_SHADOW	: if( 0 == pInfo->m_wEqClass3 ) return FALSE; break;
	case eCHAR_VALKYRIE	: if( 0 == pInfo->m_wEqClass4 ) return FALSE; break;
	case eCHAR_MAGICIAN	: if( 0 == pInfo->m_wEqClass5 ) return FALSE; break;
	default:
		{
			SUNLOG( eCRITICAL_LOG,  "[CEquipmentSlotContainer::CanEquip] Wrong Char_Type in CanEquip()" );
			return FALSE;
		}
	}

	if( pInfo->m_wEqPos == eEQUIPCONTAINER_RING1 ||
		pInfo->m_wEqPos == eEQUIPCONTAINER_RING2 )
	{
		if( AtPos != eEQUIPCONTAINER_RING1 &&
			AtPos != eEQUIPCONTAINER_RING2 )
			return FALSE;
	}
	else if( pInfo->m_wEqPos != AtPos )	return FALSE;


	if( !ValidLimitStr((SCItemSlot&)rSlotIn) )		return FALSE;
	if( !ValidLimitDex((SCItemSlot&)rSlotIn) )		return FALSE;
	if( !ValidLimitInt((SCItemSlot&)rSlotIn) )		return FALSE;
	if( !ValidLimitLevel((SCItemSlot&)rSlotIn) )	return FALSE;

	if( !ValidLimitSKill1((SCItemSlot&)rSlotIn) )	return FALSE;
	if( !ValidLimitSKill2((SCItemSlot&)rSlotIn) )	return FALSE;


	return TRUE;
}

BOOL CEquipmentSlotContainer::ValidLimitStr( SCItemSlot & ItemSlot )
{
	BASE_ITEMINFO * pInfo = ItemInfoParser::Instance()->GetItemInfo( ItemSlot.GetCode() );
	if( !pInfo ) return FALSE;

	WORD LimitStr = pInfo->m_wLimitStr;
	if( 0 == LimitStr ) return TRUE;

	if( ItemSlot.GetItemInfo()->IsWeapon() )
	{
		if( ItemSlot.GetSet() == 1 )
		{
			LimitStr = CalcLimitStrForDivineWeapon( LimitStr, m_pPlayer->GetCharType(), (eITEMTYPE)pInfo->m_wType );
		}
		LimitStr = CalcLimitStatWeapon( LimitStr, ItemSlot.GetEnchant(), ItemSlot.GetRank(), ItemSlot.GetItemInfo()->m_LV );
	}
	else if( ItemSlot.GetItemInfo()->IsArmor() )
	{
		// Divine 酒捞袍 塞力茄 荐摹 刘啊 : 拌魂等 蔼捞 LimitStr蔼捞 等促.
		if( ItemSlot.GetSet() == 1 )
		{
			LimitStr = CalcLimitStrForDivineArmor( LimitStr, m_pPlayer->GetCharType(), pInfo->m_LV );
		}
		LimitStr = CalcLimitStatArmor( LimitStr, ItemSlot.GetEnchant(), ItemSlot.GetRank(), ItemSlot.GetItemInfo()->m_LV );
	}
	else
	{
		DEBUG_CODE( if(LimitStr!=0) SUNLOG( eFULL_LOG, "[CEquipmentSlotContainer::ValidLimitStr] 胶农赋飘坷幅!厘厚(%s)啊酒囱单0捞酒聪促", pInfo->m_pszName ); );
	}

	// 胶湃 力茄
	if( m_pPlayer->GetBaseStrength() < LimitStr ) return FALSE;

	return TRUE;
}

BOOL CEquipmentSlotContainer::ValidLimitDex( SCItemSlot & ItemSlot )
{
	BASE_ITEMINFO * pInfo = ItemInfoParser::Instance()->GetItemInfo( ItemSlot.GetCode() );
	if( !pInfo ) return FALSE;

	WORD LimitDex = pInfo->m_wLimitDex;
	if( 0 == LimitDex ) return TRUE;

	if( ItemSlot.GetItemInfo()->IsWeapon() )
	{
		if( ItemSlot.GetSet() == 1 )
		{
			LimitDex = CalcLimitDexForDivineWeapon( LimitDex, m_pPlayer->GetCharType(), (eITEMTYPE)pInfo->m_wType );
		}
		LimitDex = CalcLimitStatWeapon( LimitDex, ItemSlot.GetEnchant(), ItemSlot.GetRank(), ItemSlot.GetItemInfo()->m_LV );
	}
	else if( ItemSlot.GetItemInfo()->IsArmor() )
	{
		// Divine 酒捞袍 塞力茄 荐摹 刘啊 : 拌魂等 蔼捞 LimitStr蔼捞 等促.
		if( ItemSlot.GetSet() == 1 )
		{
			LimitDex = CalcLimitDexForDivineArmor( LimitDex, m_pPlayer->GetCharType(), pInfo->m_LV );
		}
		LimitDex = CalcLimitStatArmor( LimitDex, ItemSlot.GetEnchant(), ItemSlot.GetRank(), ItemSlot.GetItemInfo()->m_LV );
	}
	else
	{
		DEBUG_CODE( if(LimitDex!=0) SUNLOG( eFULL_LOG, "[CEquipmentSlotContainer::ValidLimitDex] 胶农赋飘坷幅!厘厚(%s)啊酒囱单0捞酒聪促", pInfo->m_pszName ); );
	}

	// 胶湃 力茄
	if( m_pPlayer->GetBaseDexterity() < LimitDex ) return FALSE;

	return TRUE;
}
BOOL CEquipmentSlotContainer::ValidLimitInt( SCItemSlot & ItemSlot )
{
	BASE_ITEMINFO * pInfo = ItemInfoParser::Instance()->GetItemInfo( ItemSlot.GetCode() );
	if( !pInfo ) return FALSE;

	WORD LimitInt = pInfo->m_wLimitInt;
	if( 0 == LimitInt ) return TRUE;

	if( ItemSlot.GetItemInfo()->IsWeapon() )
	{
		if( ItemSlot.GetSet() == 1 )
		{
			LimitInt = CalcLimitIntForDivineWeapon( LimitInt, m_pPlayer->GetCharType(), (eITEMTYPE)pInfo->m_wType );
		}
		LimitInt = CalcLimitStatWeapon( LimitInt, ItemSlot.GetEnchant(), ItemSlot.GetRank(), ItemSlot.GetItemInfo()->m_LV );
	}
	else if( ItemSlot.GetItemInfo()->IsArmor() )
	{
		// Divine 酒捞袍 塞力茄 荐摹 刘啊 : 拌魂等 蔼捞 LimitStr蔼捞 等促.
		if( ItemSlot.GetSet() == 1 )
		{
			LimitInt = CalcLimitIntForDivineArmor( LimitInt, m_pPlayer->GetCharType(), pInfo->m_LV );
		}
		LimitInt = CalcLimitStatArmor( LimitInt, ItemSlot.GetEnchant(), ItemSlot.GetRank(), ItemSlot.GetItemInfo()->m_LV );
	}
	else
	{
		DEBUG_CODE( if(LimitInt!=0) SUNLOG( eFULL_LOG, "[CEquipmentSlotContainer::ValidLimitInt] 胶农赋飘坷幅!厘厚(%s)啊酒囱单0捞酒聪促", pInfo->m_pszName ); );
	}

	// 胶湃 力茄
	if( m_pPlayer->GetBaseInteligence() < LimitInt ) return FALSE;

	return TRUE;
}

BOOL CEquipmentSlotContainer::ValidLimitLevel( SCItemSlot & ItemSlot )
{
	BASE_ITEMINFO * pInfo = ItemInfoParser::Instance()->GetItemInfo( ItemSlot.GetCode() );
	if( !pInfo ) return FALSE;

	WORD LimitLV = pInfo->m_LimitEqLevel;
	if( 0 == LimitLV ) return TRUE;

	if( ItemSlot.GetItemInfo()->IsAccessary() )
	{
		LimitLV = CalcLimitLVAccessory( LimitLV, ItemSlot.GetRank() );
	}

	// 饭骇 力茄
	if( m_pPlayer->GetLevel() < LimitLV ) return FALSE;

	return TRUE;
}
	
BOOL CEquipmentSlotContainer::ValidLimitSKill1( SCItemSlot & ItemSlot )
{
	BASE_ITEMINFO * pInfo = ItemInfoParser::Instance()->GetItemInfo( ItemSlot.GetCode() );
	if( !pInfo ) return FALSE;

	WORD LimitSkill = pInfo->m_wLimitSkil1;
	if( 0 == LimitSkill ) return TRUE;


	if( ItemSlot.GetItemInfo()->IsWeapon() )
	{
		LimitSkill = CalcLimitStatWeapon( LimitSkill, ItemSlot.GetEnchant(), ItemSlot.GetRank(), ItemSlot.GetItemInfo()->m_LV );
	}
	else if( ItemSlot.GetItemInfo()->IsArmor() )
	{
		LimitSkill = CalcLimitStatArmor( LimitSkill, ItemSlot.GetEnchant(), ItemSlot.GetRank(), ItemSlot.GetItemInfo()->m_LV );
	}
	else
	{
		DEBUG_CODE( if(LimitSkill!=0) SUNLOG( eFULL_LOG, "[CEquipmentSlotContainer::ValidLimitSkill1] 胶农赋飘坷幅!厘厚(%s)啊酒囱单0捞酒聪促", pInfo->m_pszName ); );
	}

	// 胶湃 力茄
	if( m_pPlayer->GetBaseExperty1() < LimitSkill ) return FALSE;

	return TRUE;
}

BOOL CEquipmentSlotContainer::ValidLimitSKill2( SCItemSlot & ItemSlot )
{
	BASE_ITEMINFO * pInfo = ItemInfoParser::Instance()->GetItemInfo( ItemSlot.GetCode() );
	if( !pInfo ) return FALSE;

	WORD LimitSkill = pInfo->m_wLimitSkil2;
	if( 0 == LimitSkill ) return TRUE;

	if( ItemSlot.GetItemInfo()->IsWeapon() )
	{
		LimitSkill = CalcLimitStatWeapon( LimitSkill, ItemSlot.GetEnchant(), ItemSlot.GetRank(), ItemSlot.GetItemInfo()->m_LV );
	}
	else if( ItemSlot.GetItemInfo()->IsArmor() )
	{
		LimitSkill = CalcLimitStatArmor( LimitSkill, ItemSlot.GetEnchant(), ItemSlot.GetRank(), ItemSlot.GetItemInfo()->m_LV );
	}
	else
	{
		DEBUG_CODE( if(LimitSkill!=0) SUNLOG( eFULL_LOG, "[CEquipmentSlotContainer::ValidLimitSkill1] 胶农赋飘坷幅!厘厚(%s)啊酒囱单0捞酒聪促", pInfo->m_pszName ); );
	}

	// 胶湃 力茄
	if( m_pPlayer->GetBaseExperty2() < LimitSkill ) return FALSE;

	return TRUE;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -