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

📄 player_parameter.cpp

📁 奇迹世界 部分源代码奇迹世界 部分源代码奇迹世界 部分源代码
💻 CPP
📖 第 1 页 / 共 3 页
字号:

	// 角力肺 stat阑 利侩窍磊
	m_Attr[attrType][eATTR_KIND_BASE] += 1;

	m_Attr.UpdateEx();

	DWORD resultValue = m_Attr[attrType][eATTR_KIND_BASE];

	if( attrType == eATTR_VIT ) //刮酶
	{
		UpdateHPMPRecover( TRUE, FALSE );
	}
	else if( attrType == eATTR_SPR )  //瘤仿
	{
		UpdateHPMPRecover( FALSE, TRUE );
	}

	// 胶泡荤侩 肺弊 巢扁扁

	return resultValue;
}


// GM 疙飞绢 贸府
VOID Player::LevelUp( DWORD dwPlusLevel )
{
	DWORD bonusStat, bonusSkill;

	if( MAX_LEVEL < GetLevel() + dwPlusLevel )
	{
		return;
	}

	for( DWORD i = 0; i < dwPlusLevel; ++i )
	{
		SetLevel( GetLevel() + 1 );

		// Stat bonus
		bonusStat = GetStatPointPerLevel();
		SCPlayer::GetCharInfo()->m_dwRemainStat += bonusStat;

		// Skill Bonus!
		bonusSkill = GetSkillPoint( GetLevel() );
		SCPlayer::GetCharInfo()->m_dwRemainSkill += bonusSkill;

		// 促澜 版氰摹 汲沥
		SetExp( GetAccumExp( GetLevel() ) );
		SetNextExp();
	}

	// HP, MP 雀汗
	SetHP( GetMaxHP() );
	if( GetCharType() != eCHAR_BERSERKER && GetCharType() != eCHAR_SHADOW )
		SetMP( GetMaxMP() );

	// Agent肺 舅覆
	MSG_AG_STATUS_LEVEL_UP_CMD cmsg;
	cmsg.m_Level				= GetLevel();
	cmsg.m_wRemainStat			= (WORD)SCPlayer::GetCharInfo()->m_dwRemainStat;	// 巢篮 胶湃器牢飘
	cmsg.m_wRemainSkill			= (WORD)SCPlayer::GetCharInfo()->m_dwRemainSkill;	// 巢篮 胶懦器牢飘
	cmsg.m_dwCurHP				= GetHP();
	cmsg.m_dwCurMP				= GetMP();
	SendPacket( &cmsg, sizeof(cmsg) );

	// 林函 敲饭捞绢俊 官肺 舅覆
	MSG_CG_STATUS_LEVEL_UP_BRD	sendMsg;
	sendMsg.m_dwObjectKey		= GetObjectKey();
	sendMsg.m_Level				= GetLevel();
	sendMsg.m_wRemainStat		= (WORD)SCPlayer::GetCharInfo()->m_dwRemainStat;	// 巢篮 胶湃器牢飘
	sendMsg.m_wRemainSkill		= (WORD)SCPlayer::GetCharInfo()->m_dwRemainSkill;	// 巢篮 胶懦器牢飘
	sendMsg.m_dwCurHP			= GetHP();
	sendMsg.m_dwCurMP			= GetMP();
	SendPacketAround( &sendMsg, sizeof(sendMsg), FALSE );

	// 颇萍盔 饭骇诀 贸府甫 茄促.
	Party *pParty = PartyManager::Instance()->FindParty( GetPartyState().GetPartyKey() );
	if( pParty )
	{
		pParty->MemberLevelUp( GetObjectKey() );
	}
}


VOID Player::StatPointUp( DWORD dwBonusStat )
{
	SCPlayer::GetCharInfo()->m_dwRemainStat += dwBonusStat;

	MSG_CG_GM_STAT_UP_ACK sendMsg;
	sendMsg.m_byCategory			= CG_GM;
	sendMsg.m_byProtocol			= CG_GM_STAT_UP_ACK;
	sendMsg.m_dwRemainStat			= (WORD)SCPlayer::GetCharInfo()->m_dwRemainStat;	// 巢篮 胶湃器牢飘

	SendPacket( &sendMsg, sizeof(sendMsg) );
}

VOID Player::SkillPointUp( DWORD dwBonusSkill )
{
	SCPlayer::GetCharInfo()->m_dwRemainSkill += dwBonusSkill;

	MSG_CG_GM_SKILLPOINT_UP_ACK sendMsg;
	sendMsg.m_byCategory			= CG_GM;
	sendMsg.m_byProtocol			= CG_GM_SKILLPOINT_UP_ACK;
	sendMsg.m_dwRemainSkill			= (WORD)SCPlayer::GetCharInfo()->m_dwRemainSkill;	// 巢篮 胶懦器牢飘

	SendPacket( &sendMsg, sizeof(sendMsg) );
}

VOID Player::AddPlayerTitle( ePLAYER_TITLE title ) 
{ 
	m_PlayerTitle |= title; 

	// 磊脚
	MSG_CG_STATUS_TITLE_CHANGED_CMD cmsg;
	cmsg.m_PlayerTitle	= GetPlayerTitle();
	SendPacket( &cmsg, sizeof(cmsg) );

	// 林困
	MSG_CG_STATUS_TITLE_CHANGED_BRD bmsg;
	bmsg.m_dwPlayerKey	= GetObjectKey();
	bmsg.m_PlayerTitle	= GetPlayerTitle();
	SendPacketAround( &bmsg, sizeof(bmsg), FALSE );
}

VOID Player::RemovePlayerTitle( ePLAYER_TITLE title ) 
{ 
	m_PlayerTitle &= ~title;

	// 磊脚
	MSG_CG_STATUS_TITLE_CHANGED_CMD cmsg;
	cmsg.m_PlayerTitle	= GetPlayerTitle();
	SendPacket( &cmsg, sizeof(cmsg) );

	// 林困
	MSG_CG_STATUS_TITLE_CHANGED_BRD bmsg;
	bmsg.m_dwPlayerKey	= GetObjectKey();
	bmsg.m_PlayerTitle	= GetPlayerTitle();
	SendPacketAround( &bmsg, sizeof(bmsg), FALSE );
}
//-------------------------------------------------------------------------------------------------
// Private 糕滚窃荐
//-------------------------------------------------------------------------------------------------

VOID Player::SetNextExp()
{
	// m_Level阑 焊绊... 促澜 版氰摹甫 汲沥茄促.		
	m_dwNextExp = GetAccumExp( GetLevel() + 1 );
}

VOID Player::FixLevel()
{
	DWORD curMinExp = GetAccumExp( GetLevel() );
	DWORD nextExp	= GetAccumExp( GetLevel() + 1 );

	if (GetExp() >= curMinExp && GetExp() < nextExp)
	{
		// 沥惑利牢 饭骇
		return;
	}

	// 泅犁 版氰摹啊 促澜 饭骇狼 版氰摹焊促 臭篮 版快
	while (GetExp() >= GetNextExp())
	{
		SetLevel( GetLevel() + 1 );

		if( MAX_LEVEL < GetLevel() )
		{
			SUNLOG( eCRITICAL_LOG, "[Player::FixLevel] [Player_Parameter] LEVEL Error(%d) CharName(%20s) !!", GetLevel(), GetCharName());
			return;
		}
		OnLevelUp();
	}
}

// 版氰摹 棵扼埃吧 舅妨霖促.
VOID Player::OnAddExp( DWORD dwTargetObjKey )
{
	// level up苞 阿辆 惑怕蔼 函拳甫 舅妨霖促.
	// 傍拜 菩哦阑 焊郴拎具茄促!!
	MSG_CG_STATUS_EXP_CMD sendMsg;
	sendMsg.m_byCategory = CG_STATUS;
	sendMsg.m_byProtocol = CG_STATUS_EXP_CMD;
	sendMsg.m_dwTargetObjKey = dwTargetObjKey;
	sendMsg.m_dwExp = GetExp();

	SendPacket( &sendMsg, sizeof(sendMsg) );
}

VOID Player::OnLevelUp()
{
	// Stat bonus
	DWORD bonusStat = GetStatPointPerLevel();
	SCPlayer::GetCharInfo()->m_dwRemainStat = SCPlayer::GetCharInfo()->m_dwRemainStat + bonusStat;

	// Skill Bonus!
	DWORD bonusSkill = GetSkillPoint( GetLevel() );
	SCPlayer::GetCharInfo()->m_dwRemainSkill = SCPlayer::GetCharInfo()->m_dwRemainSkill + bonusSkill;

	// 促澜 版氰摹 汲沥
	SetNextExp();

	// HP, MP 雀汗
	SetHP( GetMaxHP() );
	if( GetCharType() != eCHAR_BERSERKER && GetCharType() != eCHAR_SHADOW )
		SetMP( GetMaxMP() );

	// Agent肺 舅覆
	MSG_AG_STATUS_LEVEL_UP_CMD cmsg;
	cmsg.m_Level				= GetLevel();
	cmsg.m_wRemainStat			= (WORD)SCPlayer::GetCharInfo()->m_dwRemainStat;	// 巢篮 胶湃器牢飘
	cmsg.m_wRemainSkill			= (WORD)SCPlayer::GetCharInfo()->m_dwRemainSkill;	// 巢篮 胶懦器牢飘
	cmsg.m_dwCurHP				= GetHP();
	cmsg.m_dwCurMP				= GetMP();
	SendPacket( &cmsg, sizeof(cmsg) );

	// level up苞 阿辆 惑怕蔼 函拳甫 舅妨霖促.
	// 傍拜 菩哦阑 焊郴拎具茄促!!
	MSG_CG_STATUS_LEVEL_UP_BRD sendMsg;
	sendMsg.m_dwObjectKey		= GetObjectKey();
	sendMsg.m_Level				= GetLevel();
	sendMsg.m_wRemainStat		= (WORD)SCPlayer::GetCharInfo()->m_dwRemainStat;	// 巢篮 胶湃器牢飘
	sendMsg.m_wRemainSkill		= (WORD)SCPlayer::GetCharInfo()->m_dwRemainSkill;	// 巢篮 胶懦器牢飘
	sendMsg.m_dwCurHP			= GetHP();
	sendMsg.m_dwCurMP			= GetMP();

	//!!!!!烙矫!!!!!!!!!!!!!!!!!!!
	//!!!!!烙矫!!!!!!!!!!!!!!!!!!!
	SendPacketAround( &sendMsg, sizeof(sendMsg), FALSE );

	// 颇萍盔 饭骇诀 贸府甫 茄促.
	Party *pParty = PartyManager::Instance()->FindParty( GetPartyState().GetPartyKey() );
	if( pParty )
	{
		pParty->MemberLevelUp( GetObjectKey() );
	}
}

DWORD Player::IncreaseMP( DWORD dwIncreament )
{
	dwIncreament = Character::IncreaseMP( dwIncreament );

	// 胶乔复 单固瘤 胶懦狼 版快 MP 炼扒俊 蝶扼 利侩蜡公啊 官诧促.
	m_pSkillManager->UpdatePassiveSkills();

	return dwIncreament;
}

DWORD Player::DecreaseMP( DWORD dwDecrement )
{
	dwDecrement = Character::DecreaseMP( dwDecrement );

	// 胶乔复 单固瘤 胶懦狼 版快 MP 炼扒俊 蝶扼 利侩蜡公啊 官诧促.
	m_pSkillManager->UpdatePassiveSkills();

	return dwDecrement;
}

VOID Player::SaveStartLocation()
{
	if( !GetField() ) return ;

	Map * pMap = GetField()->GetMap();
	if( pMap->GetZoneType() == eZONETYPE_VILLAGE )
	{
		WzVector cpos;
		GetPos(&cpos);
		SCPlayer::GetCharInfo()->m_dwRegion		= GetField()->GetMap()->GetMapCode();

		SCPlayer::GetCharInfo()->m_sLocationX	= (SHORT)cpos.x;
		SCPlayer::GetCharInfo()->m_sLocationY	= (SHORT)cpos.y;
		SCPlayer::GetCharInfo()->m_sLocationZ	= (SHORT)cpos.z;
	}
	else
	{
		SCPlayer::GetCharInfo()->m_sLocationX	= 0;
		SCPlayer::GetCharInfo()->m_sLocationY	= 0;
		SCPlayer::GetCharInfo()->m_sLocationZ	= 0;
	}
}

WzVector Player::GetStartVector( Field * pField )
{
	
	WzVector wzVec;
	if( SCPlayer::GetCharInfo()->m_dwRegion == pField->GetMap()->GetMapCode() &&
		SCPlayer::GetCharInfo()->m_sLocationX != 0 &&
		SCPlayer::GetCharInfo()->m_sLocationY != 0 &&
		SCPlayer::GetCharInfo()->m_sLocationZ != 0 )
	{
		wzVec.x = SCPlayer::GetCharInfo()->m_sLocationX;
		wzVec.y = SCPlayer::GetCharInfo()->m_sLocationY;
		wzVec.z = SCPlayer::GetCharInfo()->m_sLocationZ;

		if( -1 == pField->GetWorldBase()->x_pPathFinder->GetTileToStand( wzVec ) )
		{
			wzVec = pField->GetRandomStartingVector();
		}
	}
	else
	{
		wzVec = pField->GetRandomStartingVector();
	}
	return wzVec;
}
BOOL Player::CanPlusMoney( MONEY plus_money )
{
	if( GetMoney() + plus_money > UINT_MAX )	//< 4294967295 : 42撅阑 逞瘤 臼扁
		return FALSE;
	return TRUE;
}
BOOL Player::CanMinusMoney( MONEY minus_money )
{
	if( GetMoney() < minus_money )
		return FALSE;
	return TRUE;
}
BOOL Player::PlusMoney( MONEY plus_money )
{
	if( !CanPlusMoney(plus_money) )	//< 4294967295 : 42撅阑 逞瘤 臼扁
		return FALSE;

	SetMoney( GetMoney() + plus_money );
	g_pGameServer->PlusUserMoney( plus_money );	// 烹拌 陛咀 刘啊(己泅芒)

	return TRUE;
}

BOOL Player::MinusMoney( MONEY minus_money )
{
	if( !CanMinusMoney(minus_money) )
		return FALSE;

	SetMoney( GetMoney() - minus_money );
	g_pGameServer->MinusUserMoney( minus_money );	// 烹拌 陛咀 皑家(己泅芒)
	g_pGameServer->MinusTotalMinus( minus_money );

	return TRUE;
}

⌨️ 快捷键说明

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