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

📄 skillmanager.cpp

📁 奇迹世界 部分源代码奇迹世界 部分源代码奇迹世界 部分源代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	if( !ValidState() ) return;

	// 货酚霸 胶懦浇吩 沥焊甫 悸泼茄促.
	SCSkillSlot rNewSlot;
	rNewSlot.SetCode( NewSkillCode );

	// 浇吩狼 后 磊府甫 茫绰促.
	POSTYPE EmptyPos = 0;
	SCSlotContainer *pContainer = GetSkillSlotContainer();
	if( !pContainer->GetEmptyPos( EmptyPos ) )	return;

	// 胶懦浇吩阑 眠啊茄促.
	pContainer->InsertSlot( EmptyPos, rNewSlot );

	// NewSkillSlot俊 蔼阑 悸泼茄促.
	NewSkillSlot.m_SkillPos = rNewSlot.GetPos();
	rNewSlot.CopyOut( NewSkillSlot.m_Stream );

	// 菩矫宏 胶懦捞扼搁 府胶飘俊 眠啊窍绊 扁瓷阑 利侩茄促.
	AddAttrForPassiveSkill( NewSkillCode );

	// 家券眉 胶懦捞扼搁  货肺款 胶懦阑 眠啊茄促.
	SummonManager::Instance()->AddSummonedSkill( m_pPlayer->GetSummonerKey(), NewSkillCode );
}

//-------------------------------------------------------------------------------------------------
// 胶鸥老 嚼垫
//-------------------------------------------------------------------------------------------------

RC::eSKILL_RESULT SkillManager::CanLevelUpStyle( SLOTCODE CurStyleCode, SLOTCODE NewStyleCode )
{
	if( !ValidState() ) return RC::RC_SKILL_FAILED;

	// dwCurStyleCode俊 秦寸窍绰 胶鸥老阑 嚼垫窍绊 乐绰瘤 眉农
	SCSkillSlotContainer *pContainer = GetSkillSlotContainer();
	SCSkillSlot *pCurSkillSlot = pContainer->GetSkillSlotByCode( CurStyleCode );
	if( !pCurSkillSlot )		return RC::RC_SKILL_DOES_NOT_HAVE;

	BASE_STYLEINFO *pBaseCurStylenfo = SkillInfoParser::Instance()->GetStyleInfo( CurStyleCode );
	if( !pBaseCurStylenfo )		return RC::RC_SKILL_BASEINFO_NOTEXIST;

	// 胶鸥老饭骇捞 父肪(LV10)牢 版快, 坷滚啊瓷 饭骇 眉农 鞘夸!!!
	if( pBaseCurStylenfo->m_wStyleLV >= MAX_SKILL_LEVEL )		return RC::RC_SKILL_MAX_LEVEL_LIMIT;

	// 货肺款 胶懦狼 夸备炼扒阑 父练窍绰瘤 眉农
	return CanLearnStyle( NewStyleCode );
}

class QuickStyleLevelUp
{
	BOOL		m_bComplete;
	SLOTCODE	m_CurStyleCode;
	SLOTCODE	m_NewStyleCode;
public:
	QuickStyleLevelUp( SLOTCODE CurStyleCode, SLOTCODE NewStyleCode ) : m_CurStyleCode(CurStyleCode), 
		m_NewStyleCode(NewStyleCode), m_bComplete(0) {}

		VOID operator () ( SCSlot* pSlot )
		{
			SCQuickStyleSlot *pStyleSlot = (SCQuickStyleSlot*)pSlot;

			if( m_bComplete )									return;
			if( pStyleSlot->GetOrgCode() != m_CurStyleCode )	return;

			pStyleSlot->SetOrgCode( m_NewStyleCode );
			m_bComplete = TRUE;
		}
};

VOID SkillManager::LevelUpStyle( SLOTCODE CurStyleCode, SLOTCODE NewStyleCode, SKILLSLOT & OUT NewSkillSlot )
{
	if( !ValidState() ) return;

	// 泅犁 胶懦浇吩
	SCSkillSlot *pCurSkillSlot = m_pSkillSlotContainer->GetSkillSlotByCode( CurStyleCode );
	if( !pCurSkillSlot )	return;

	// 货酚霸 胶懦浇吩 沥焊甫 悸泼茄促.
	SCSkillSlot rNewSlot;
	rNewSlot.SetCode( NewStyleCode );
	rNewSlot.SetPos( pCurSkillSlot->GetPos() );

	// 泅犁 胶懦浇吩阑 昏力茄促.
	m_pSkillSlotContainer->DeleteSlot( pCurSkillSlot->GetPos(), NULL );

	// 货酚霸 胶懦浇吩阑 眠啊茄促.
	m_pSkillSlotContainer->InsertSlot( rNewSlot.GetPos(), rNewSlot );

	// NewSkillSlot俊 蔼阑 悸泼茄促.
	NewSkillSlot.m_SkillPos = rNewSlot.GetPos();
	rNewSlot.CopyOut( NewSkillSlot.m_Stream );

	// QuickSlot俊 胶懦捞 殿废登绢 乐促搁 饭骇诀 矫难霖促.
	QuickStyleLevelUp Opr( CurStyleCode, NewStyleCode );
	m_pStyleSlotContainer->ForEachSlot( Opr );

	// 饭骇诀茄 胶鸥老捞 郴啊 急琶窍绊 乐带 胶鸥老捞扼搁
	// 货酚霸 滚橇甫 利侩窍绊, 急琶 胶鸥老 内靛甫 货吧肺 官层霖促.
	if( m_pPlayer->GetSelectedStyle() == CurStyleCode )
	{
		SetSelectStyle( NewStyleCode );
	}
}

RC::eSKILL_RESULT SkillManager::CanLearnStyle( SLOTCODE NewStyleCode )
{
	if( !ValidState() ) return RC::RC_SKILL_FAILED;

	// dwNewStyleCode俊 秦寸窍绰 胶鸥老捞 胶鸥老胶农赋飘俊 粮犁窍绰瘤 眉农
	BASE_STYLEINFO *pBaseNewStylenfo = SkillInfoParser::Instance()->GetStyleInfo( NewStyleCode );
	if( !pBaseNewStylenfo )	return RC::RC_SKILL_BASEINFO_NOTEXIST;

	// 秦寸 努贰胶狼 胶鸥老阑 捞固 嚼垫窍绊 乐栏哥, 扁粮狼 饭骇捞 货肺款 饭骇焊促 鞍芭唱 臭阑 版快
	SCSkillSlotContainer *pContainer = GetSkillSlotContainer();
	SCSkillSlot *pCurSkillSlot = pContainer->GetSkillSlotByClass( pBaseNewStylenfo->m_SkillClassCode );
	if( pCurSkillSlot )		
	{
		BASE_STYLEINFO *pBaseCurStylenfo = SkillInfoParser::Instance()->GetStyleInfo( pCurSkillSlot->GetCode() );

		if( pBaseCurStylenfo->m_wStyleLV >= pBaseNewStylenfo->m_wStyleLV )	return RC::RC_SKILL_ALREADY_EXIST_SKILL;
	}

	// 巢篮 胶懦器牢飘啊 夸备胶懦器牢飘焊促 利篮 版快
	if( m_pPlayer->GetCharInfo()->m_dwRemainSkill < pBaseNewStylenfo->m_byRequireSkillPoint )	
		return RC::RC_SKILL_REMAIN_SKILLPOINT_LACK;

	// 货肺款 胶鸥老狼 夸备饭骇阑 父练窍绰瘤 眉农
	if( m_pPlayer->GetLevel() < pBaseNewStylenfo->m_wRequireLV )	return RC::RC_SKILL_REQUIRE_LEVEL_LIMIT;

	// 某腐磐 努贰胶 炼扒捞 嘎绰瘤 眉农
	if( m_pPlayer->GetCharType() != pBaseNewStylenfo->m_byClassDefine )
		return RC::RC_SKILL_CHAR_CLASS_LIMIT;

	return RC::RC_SKILL_SUCCESS;
}

VOID SkillManager::LearnStyle( SLOTCODE NewStyleCode, SKILLSLOT & OUT NewSkillSlot )
{
	if( !ValidState() ) return;

	// 货酚霸 胶懦浇吩 沥焊甫 悸泼茄促.
	SCSkillSlot rNewSlot;
	rNewSlot.SetCode( NewStyleCode );

	// 浇吩狼 后 磊府甫 茫绰促.
	POSTYPE EmptyPos = 0;
	SCSlotContainer *pContainer = GetSkillSlotContainer();
	if( !pContainer->GetEmptyPos( EmptyPos ) )	return;

	// 胶懦浇吩阑 眠啊茄促.
	pContainer->InsertSlot( EmptyPos, rNewSlot );

	// NewSkillSlot俊 蔼阑 悸泼茄促.
	NewSkillSlot.m_SkillPos = rNewSlot.GetPos();
	rNewSlot.CopyOut( NewSkillSlot.m_Stream );

	// 狞 胶鸥老 浇吩狼 沥焊甸捞 葛滴 官诧促.
	m_pPlayer->GetStyleManager()->UpdateStyleSlot();
}

RC::eSKILL_RESULT SkillManager::CanSelectStyle( SLOTCODE NewStyleCode )
{
	if( !ValidState() ) return RC::RC_SKILL_FAILED;

	// 秦寸窍绰 胶鸥老阑 嚼垫窍绊 乐绰瘤 眉农茄促.
	SCSkillSlotContainer *pContainer = GetSkillSlotContainer();
	SCSkillSlot *pSkillSlot = pContainer->GetSkillSlotByCode( NewStyleCode );
	if( !pSkillSlot )		return RC::RC_SKILL_DOES_NOT_HAVE;

	// 秦寸窍绰 胶鸥老捞 胶鸥老胶农赋飘俊 粮犁窍绰瘤 眉农
	BASE_STYLEINFO *pBaseStylenfo = SkillInfoParser::Instance()->GetStyleInfo( NewStyleCode );
	if( !pBaseStylenfo )	return RC::RC_SKILL_BASEINFO_NOTEXIST;

	// 某腐磐 努贰胶 眉农
	if( m_pPlayer->GetCharType() != pBaseStylenfo->m_byClassDefine )
	{
		SUNLOG( eFULL_LOG,  "[SkillManager::CanSelectStyle] The Type Of Character is Invalid! " );
		return RC::RC_SKILL_CHAR_CLASS_LIMIT;
	}

	// 公扁 力茄
	if( pBaseStylenfo->m_iWeaponDefine != -1 )
	{
		DWORD dwCurWeaponKind = m_pPlayer->GetWeaponKind();

		if( dwCurWeaponKind != pBaseStylenfo->m_iWeaponDefine )
		{
			SUNLOG( eFULL_LOG,  "[SkillManager::CanSelectStyle] The Weapon Type is Invalid! " );
			return RC::RC_SKILL_WEAPON_LIMIT;
		}
	}

	// 夸备饭骇阑 眉农茄促.
	if( m_pPlayer->GetLevel() < pBaseStylenfo->m_wRequireLV )
	{
		SUNLOG( eFULL_LOG,  "[SkillManager::CanSelectStyle] The Level of Player doesn't reach RequireLevel! " );
		return RC::RC_SKILL_REQUIRE_LEVEL_LIMIT;
	}

	return RC::RC_SKILL_SUCCESS;
}

VOID SkillManager::SetSelectStyle( SLOTCODE NewStyleCode )
{
	if( !ValidState() ) return;

	MSG_CG_STYLE_SELECT_STYLE_BRD BrdMsg;
	BrdMsg.m_CurStyleCode = m_pPlayer->GetSelectedStyle();

	// 捞傈 滚橇甫 秦力茄促.
	ReleaseStyleBuff( m_pPlayer->GetSelectedStyle() );

	// 胶鸥老阑 瘤沥茄促.
	m_pPlayer->SetSelectedStyle( NewStyleCode );

	// 货肺 瘤沥茄 胶鸥老狼 滚橇甫 利侩茄促.
	ApplyStyleBuff( NewStyleCode ); 

	// 林函俊 菩哦阑 朝赴促.
	BrdMsg.m_NewStyleCode = NewStyleCode;
	BrdMsg.m_dwObjectKey = m_pPlayer->GetObjectKey();
	m_pPlayer->SendPacketAround( &BrdMsg, sizeof(BrdMsg) );
}

VOID SkillManager::ApplyStyleBuff( SLOTCODE StyleCode )
{
	BASE_STYLEINFO *pBaseStylenfo = SkillInfoParser::Instance()->GetStyleInfo( StyleCode );
	if( !pBaseStylenfo )	return;

	SkillAttrCalculator SkillCalc( m_pPlayer->GetAttr() );

	// 傍拜 己傍 刘啊
	if( pBaseStylenfo->m_iAttackRate )
		SkillCalc.AddAttr( eATTR_PHYSICAL_ATTACK_SUCCESS_RATIO, VALUE_TYPE_VALUE, pBaseStylenfo->m_iAttackRate );

	// 喉废 己傍 刘啊
	if( pBaseStylenfo->m_iAvoidRate )
		SkillCalc.AddAttr( eATTR_PHYSICAL_ATTACK_BLOCK_RATIO, VALUE_TYPE_VALUE, pBaseStylenfo->m_iAvoidRate );

	// 傍加 刘啊
	if( pBaseStylenfo->m_iAttackSpeed )
		SkillCalc.AddAttr( eATTR_ATTACK_SPEED, VALUE_TYPE_VALUE, pBaseStylenfo->m_iAttackSpeed );

	// 规绢仿 刘啊
	if( pBaseStylenfo->m_iBonusDefence )
		SkillCalc.AddAttr( eATTR_OPTION_ALL_DEFENSE_POWER, VALUE_TYPE_VALUE, pBaseStylenfo->m_iBonusDefence );

	// 农府萍拿 犬伏 刘啊
	if( pBaseStylenfo->m_wCriticalBonus )
		SkillCalc.AddAttr( eATTR_ADD_ALL_CRITICAL_RATIO, VALUE_TYPE_VALUE, pBaseStylenfo->m_wCriticalBonus );
}

VOID SkillManager::ReleaseStyleBuff( SLOTCODE StyleCode )
{
	BASE_STYLEINFO *pBaseStylenfo = SkillInfoParser::Instance()->GetStyleInfo( StyleCode );
	if( !pBaseStylenfo )	return;

	SkillAttrCalculator SkillCalc( m_pPlayer->GetAttr() );

	// 傍拜 己傍 皑家
	if( pBaseStylenfo->m_iAttackRate )
		SkillCalc.DelAttr( eATTR_PHYSICAL_ATTACK_SUCCESS_RATIO, VALUE_TYPE_VALUE, pBaseStylenfo->m_iAttackRate );

	// 喉废 己傍 皑家
	if( pBaseStylenfo->m_iAvoidRate )
		SkillCalc.DelAttr( eATTR_PHYSICAL_ATTACK_BLOCK_RATIO, VALUE_TYPE_VALUE, pBaseStylenfo->m_iAvoidRate );

	// 傍加 皑家
	if( pBaseStylenfo->m_iAttackSpeed )
		SkillCalc.DelAttr( eATTR_ATTACK_SPEED, VALUE_TYPE_VALUE, pBaseStylenfo->m_iAttackSpeed );

	// 规绢仿 皑家
	if( pBaseStylenfo->m_iBonusDefence )
		SkillCalc.DelAttr( eATTR_OPTION_ALL_DEFENSE_POWER, VALUE_TYPE_VALUE, pBaseStylenfo->m_iBonusDefence );

	// 农府萍拿 犬伏 皑家
	if( pBaseStylenfo->m_wCriticalBonus )
		SkillCalc.DelAttr( eATTR_ADD_ALL_CRITICAL_RATIO, VALUE_TYPE_VALUE, pBaseStylenfo->m_wCriticalBonus );
}

VOID SkillManager::AddWeapon( CODETYPE dwNewWeaponCode )
{
	BASE_ITEMINFO *pItemInfo = ItemInfoParser::Instance()->GetItemInfo( dwNewWeaponCode );
	if( !pItemInfo )	
	{
		SUNLOG( eCRITICAL_LOG,  "[SkillManager::AddWeapon] Invalid NewWeaponCode[%d] ", dwNewWeaponCode );
		return;
	}

	// 菩矫宏 胶懦甸狼 扁瓷捞 混酒抄促.
	UpdatePassiveSkills();

	// 捞傈 胶鸥老狼 公扁鸥涝苞 火涝窍妨绰 公扁狼 鸥涝捞 鞍栏搁 捞傈 胶鸥老阑 汗盔秦 霖促.
	BASE_STYLEINFO *pPreBaseStylenfo = SkillInfoParser::Instance()->GetStyleInfo( m_PreStyleCode );
	if( pPreBaseStylenfo && pPreBaseStylenfo->m_iWeaponDefine == pItemInfo->m_wType )
	{
		SetSelectStyle( m_PreStyleCode );
	}
	// 捞傈 胶鸥老捞 货肺款 公扁甫 荤侩且 荐 绝促搁 扁夯 胶鸥老肺 背眉茄促.
	else
	{
		SetSelectStyle( m_pPlayer->GetDefaultStyle( dwNewWeaponCode ) );
	}

	// 狞 胶鸥老 浇吩狼 沥焊甸捞 葛滴 官诧促.
	m_pPlayer->GetStyleManager()->UpdateStyleSlot();
}

VOID SkillManager::DelWeapon()
{
	// 菩矫宏 胶懦甸狼 扁瓷捞 秦力等促.
	UpdatePassiveSkills();

	// 捞傈 胶鸥老 沥焊甫 扁撅茄促.
	BASE_STYLEINFO *pBaseStylenfo = SkillInfoParser::Instance()->GetStyleInfo( m_pPlayer->GetSelectedStyle() );
	if( pBaseStylenfo )
	{
		m_PreStyleCode = m_pPlayer->GetSelectedStyle();
	}

	// 林冈龙 胶鸥老肺 背眉茄促.
	SetSelectStyle( m_pPlayer->GetDefaultStyle( 0 ) );

	// 狞 胶鸥老 浇吩狼 沥焊甸捞 葛滴 官诧促.
	m_pPlayer->GetStyleManager()->UpdateStyleSlot();
}

VOID SkillManager::UpdatePassiveSkills()
{
	Skill *pSkill = NULL;
	m_pPassiveSkillHashTable->SetFirst();
	while( pSkill = m_pPassiveSkillHashTable->GetNext() )
	{
		if( m_pPlayer->CanApplyPassiveSkill( pSkill->GetSkillCode() ) )
		{
			ApplyPassiveSkill( pSkill );
		}
		else
		{
			ReleasePassiveSkill( pSkill );
		}
	}
}














⌨️ 快捷键说明

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