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

📄 charinfo.cpp

📁 国内著名网络游戏dragon的服务端完整源码 内附完整数据库结构
💻 CPP
📖 第 1 页 / 共 3 页
字号:
	//  规绢备啊 规菩捞搁
	return (pShield->GetItemKind() == IK_SHIELD || pShield->GetItemKind() == IK_IRON_SHIELD)	? true:false;
}

bool CCharInfo::IsArrow() const
{
	ItemAttr arrow = equip[WT_SHIELD];
	if (arrow.item_no == 0)  return false;
	
	CItem* pArrow = ItemUnit(arrow);
	if (pArrow == NULL)  return false;
	//  拳混捞 乐促搁
	return (pArrow->GetItemKind() == IK_TWO_ARROW || pArrow->GetItemKind() == IK_DUAL_ARROW) ? true:false;//030102 lsw Arrow
}

bool CCharInfo::IsLimit(int nPoint) const
{	//< CSD-030806
	int nCount = GetCombatPoint() + nPoint;
	
	for (int i = LIGHTNING_BOOM; i <= WIND_EXTREME; ++i)
	{
		nCount += GetCombatLevel(i);
	}
	
	const int nLevel = GetLevel();
	return (nCount > NPC_Lev_Ref[nLevel].nCspMax) ? true:false;
}	//> CSD-030806

bool CCharInfo::IsEnableCombat(BYTE nCombat) const 
{
	return (Magic_Ref[nCombat].exhaust_MP <= Cp) ? true:false;
}

///////////////////////////////////////////////////////////////////////////////
// Protected Method
///////////////////////////////////////////////////////////////////////////////

int CCharInfo::GetExtStr() const
{
	return Str+ Strw + RareEM.GetStaticRareStrength(StaticRare);
}

int CCharInfo::GetExtCon() const
{
	return Con + Conw + RareEM.GetStaticRareConstitution(StaticRare);  
}

int CCharInfo::GetExtDex() const
{
	return Dex + Dexw + RareEM.GetStaticRareDexterity(StaticRare);  
}

int CCharInfo::GetExtWis() const
{
	return Wis + Wisw + RareEM.GetStaticRareWisdom(StaticRare);  
}

int CCharInfo::GetExtInt() const
{
	return Int + Intw + RareEM.GetStaticRareIntelligence(StaticRare);  
}

int CCharInfo::GetExtMove() const
{
	return MoveP + MovePw + RareEM.GetStaticRareMovement(StaticRare);  
}

int CCharInfo::GetExtChar() const
{
	return Char + Charw + RareEM.GetStaticRareCharisma(StaticRare);  
}

int CCharInfo::GetExtEndu() const
{
	return Endu + Enduw + RareEM.GetStaticRareEndurance(StaticRare);  
}

int CCharInfo::GetExtMor() const
{
	return Moral + Moralw + RareEM.GetStaticRareMoral(StaticRare);  
}

int CCharInfo::GetExtLuck() const
{
	return Luck + Luckw + RareEM.GetStaticRareLucky(StaticRare);  
}

int CCharInfo::GetExtWs() const
{
	return wsps + wspsw + RareEM.GetStaticRareWizard(StaticRare);
}

int CCharInfo::GetExtPs() const
{
	return wsps + wspsw + RareEM.GetStaticRarePriest(StaticRare);
}

int CCharInfo::GetRemainStr() const
{
	CAbilityLimit* pLimit = g_mgrLimit.GetCell(Class, m_nClsStep);
	
	const int nDiff = Str - pLimit->GetStr();
	return (nDiff < 0) ? 0:nDiff;
}

int CCharInfo::GetRemainCon() const
{
	CAbilityLimit* pLimit = g_mgrLimit.GetCell(Class, m_nClsStep);
	
	const int nDiff = Con - pLimit->GetCon();
	return (nDiff < 0) ? 0:nDiff;
}

int CCharInfo::GetRemainDex() const
{
	CAbilityLimit* pLimit = g_mgrLimit.GetCell(Class, m_nClsStep);
	
	const int nDiff = Dex - pLimit->GetDex();
	return (nDiff < 0) ? 0:nDiff;
}

int CCharInfo::GetRemainWis() const
{
	CAbilityLimit* pLimit = g_mgrLimit.GetCell(Class, m_nClsStep);
	
	const int nDiff = Wis - pLimit->GetWis();
	return (nDiff < 0) ? 0:nDiff;
}

int CCharInfo::GetRemainInt() const
{
	CAbilityLimit* pLimit = g_mgrLimit.GetCell(Class, m_nClsStep);
	
	const int nDiff = Int - pLimit->GetInt();
	return (nDiff < 0) ? 0:nDiff;
}

int CCharInfo::GetRemainMove() const
{
	CAbilityLimit* pLimit = g_mgrLimit.GetCell(Class, m_nClsStep);
	
	const int nDiff = MoveP - pLimit->GetMove();
	return (nDiff < 0) ? 0:nDiff;
}

int CCharInfo::GetRemainChar() const
{
	CAbilityLimit* pLimit = g_mgrLimit.GetCell(Class, m_nClsStep);
	
	const int nDiff = Char - pLimit->GetChar();
	return (nDiff < 0) ? 0:nDiff;
}

int CCharInfo::GetRemainEndu() const
{
	CAbilityLimit* pLimit = g_mgrLimit.GetCell(Class, m_nClsStep);
	
	const int nDiff = Endu - pLimit->GetEndu();
	return (nDiff < 0) ? 0:nDiff;
}

int CCharInfo::GetRemainMor() const
{
	CAbilityLimit* pLimit = g_mgrLimit.GetCell(Class, m_nClsStep);
	
	const int nDiff = Moral - pLimit->GetMor();
	return (nDiff < 0) ? 0:nDiff;
}

int CCharInfo::GetRemainLuck() const
{
	CAbilityLimit* pLimit = g_mgrLimit.GetCell(Class, m_nClsStep);
	
	const int nDiff = Luck - pLimit->GetLuck();
	return (nDiff < 0) ? 0:nDiff;
}

int CCharInfo::GetRemainWs() const
{
	CAbilityLimit* pLimit = g_mgrLimit.GetCell(Class, m_nClsStep);
	
	const int nDiff = wsps - pLimit->GetWs();
	return (nDiff < 0) ? 0:nDiff;
}

int CCharInfo::GetRemainPs() const
{
	CAbilityLimit* pLimit = g_mgrLimit.GetCell(Class, m_nClsStep);
	
	const int nDiff = wsps - pLimit->GetPs();
	return (nDiff < 0) ? 0:nDiff;
}

int CCharInfo::CalcNewLife(BYTE nCombat) const
{	// 弥措 Life樊 拌魂
	if (IsNpc())
	{
		return NPC_Gen_Ref[npc_index].nHpMax;
	}
	
	int nNew = GetPureLife(), nPercent = 0, nAdd = 0;
	
	switch (nCombat)
	{
	case TYBERN_GIFT:
		{
			nPercent = __max(RareEM.GetStaticRareBrood(StaticRare), GetCombatValue(nCombat));
			nAdd = RareEM.GetStaticRareLife(StaticRare) + RareEM.GetStaticRareHighBlood(StaticRare);//020730 lsw
			
			break;
		}
    default:
		{
			nPercent = RareEM.GetStaticRareBrood(StaticRare);
			nAdd = RareEM.GetStaticRareLife(StaticRare)+RareEM.GetStaticRareHighBlood(StaticRare);//020730 lsw
			break;
		}
	}
	
	nNew += nNew*nPercent/100;
	nNew += nAdd;
	
	for (int i = 0 ; i < 8 ; ++i)	
	{
		const int nItem = equip[i].item_no;
		if (nItem) 
		{
			CItem* pItem = ::ItemUnit(nItem/1000, nItem%1000);
			if (pItem != NULL)
			{
				nNew += pItem->GetPlusLife();
			}
		}
	}
	
	if (nNew <= 0 )  nNew = 1;
	if (nNew >= 150000)  nNew = 150000; // CSD-030306
	return nNew;
}

int CCharInfo::CalcNewMana(BYTE nCombat) const
{	// 弥措 Mana樊 拌魂 
	if (IsNpc() == true)  return 0;
	
	int nNew = GetAbility(WSPS)*5.3;
	
	if (Spell == PRIEST_SPELL)//己流磊
	{
		nNew += nNew * RareEM.GetStaticRareSpirit(StaticRare)/100; //020214 lsw
		nNew += RareEM.GetStaticRareDivine(StaticRare);
	}
	else
	{
		nNew += nNew * RareEM.GetStaticRareMind(StaticRare)/100;	 //020214 lsw
		nNew += RareEM.GetStaticRareMana(StaticRare);
	}
	// 厘馒茄 厘厚狼 Mana 加己蔼阑 歹窃
	for (int i = 0 ; i < 8 ; ++i)	
	{
		const int nItem = equip[i].item_no;
		if (nItem) 
		{
			CItem* pItem = ::ItemUnit(nItem/1000, nItem%1000);
			if (pItem != NULL)
			{
				nNew += (Spell) ? pItem->GetPlusDivine():pItem->GetPlusMana();
			}
		}
	}
	
	if (nNew <= 0)  nNew = 1;
	if (nNew >= 150000)	nNew = 150000; // CSD-030306
	return nNew;
}

int CCharInfo::CalcNewHungry(BYTE nCombat) const
{	// 弥措 Hungry樊 拌魂
	const int nCon = GetAbility(CON)*20;
	int nNew = (nCon + GetLevel()*100 + 3000)/100; // CSD-030806
	// 厘馒茄 厘厚狼 Hungry 加己蔼阑 歹窃
	for (int i = 0 ; i < 8 ; ++i)	
	{
		const int nItem = equip[i].item_no;
		
		if (nItem) 
		{
			CItem* pItem = ::ItemUnit(nItem/1000, nItem%1000);
			
			if (pItem != NULL)
			{
				nNew += pItem->GetPlusHungry();
			}
		}
	}
	
	nNew += nNew*RareEM.GetStaticRareYouth(StaticRare)/100; //020214 lsw
	nNew += RareEM.GetStaticRareHealth(StaticRare);
	return nNew;
}

int CCharInfo::CalcNewCombat() const
{	//< CSD-040223
	const int nLevel = GetLevel();
	return NPC_Lev_Ref[nLevel].nBaseCP + GetExtChar();
}	//> CSD-040223

int CCharInfo::CalcNewAc() const
{
	int nAc = 1;
	
	for (int i = 0 ; i < 8 ; i ++)	// 厘馒茄 厘厚狼 规绢仿 啊摹甫 歹茄促. 
	{
		const int nItem = equip[i].item_no;
		
		if (nItem) 
		{
			CItem* pItem = ::ItemUnit(nItem/1000, nItem%1000);
			
			if (pItem != NULL)  
			{
				nAc += pItem->GetAR_or_DH();
			}
		}
	}
	
	return nAc;
}

int CCharInfo::CalcWeaponHit() const
{
	int nWeapon	=	iPhysicalTotalDamage;
	
	if (iPhysicalRandomDamage!= 0)
	{
		const int nRandom	=	rand()%abs(iPhysicalRandomDamage);
		nWeapon = (iPhysicalRandomDamage > 0) ? nWeapon + nRandom:nWeapon - nRandom;
	}
	
	return nWeapon;
}

int CCharInfo::CalcCriticalHit(BYTE nActive, BYTE nPassive) const
{	//< CSD-031007 : 拱府利 傍拜俊辑 农府萍拿 洒飘 焊沥
	const int nItem = RareEM.GetStaticRareCritical(StaticRare);
	int nRate = __max(50 - (nItem*50/100 + 20) + rand()%10, 5);
	
	if (RareEM.GetDynamicRareValue(FITEM_CRITICAL, DynamicRare))
	{
		nRate = 5;
	}
	
	switch (nActive)
	{
    case CRITICAL_HIDING:
		{
			nRate = 0;
			break;
		}
	}
	
	if (++m_nCriticalCount > nRate)
	{ 
		const int nRandom = Hp*100/HpMax;
		m_nCriticalCount = 0; // 农府萍拿 洒飘 檬扁拳
		return (nRandom <= 0) ? 50:50 + rand()%nRandom;
	}
	
	return 0;
}	//> CSD-031007

int CCharInfo::CalcTacticExp(BYTE nKind, DWORD dwExp) const
{   //< CSD-020821
	const int nLevel = Skill[TACTICS_Crapple + nKind];
	//MyLog(LOG_NORMAL, "Tactics Rate : %d", NPC_Lev_Ref[nLevel].nTacRate);
	return dwExp*NPC_Lev_Ref[nLevel].nTacRate/100;
}   //> CSD-020821

void CCharInfo::SendCharInfoBasic(BYTE nKind, DWORD dwData) const
{	//< CSD-TW-030624 : 敲饭捞绢啊 酒聪搁 救焊辰促
	if (IsPlayer())
	{
		t_packet packet;
		packet.h.header.type = CMD_CHAR_INFO_BASIC;
		packet.h.header.size = sizeof(t_char_info_basic) - 1;
		packet.u.char_info_basic.kind = nKind;
		packet.u.char_info_basic.data = dwData;
		::QueuePacket(connections, GetServerID(), &packet, 1);
	}
}	//> CSD-TW-030624

void CCharInfo::SendCharInfoTactic(BYTE nKind) const
{	//< CSD-TW-030624
	if (IsPlayer())
	{
		t_packet packet;
		packet.h.header.type = CMD_CHAR_INFO_TACTIC;
		packet.h.header.size = sizeof(t_char_info_tactic);
		packet.u.char_info_tactic.wKind = nKind;
		packet.u.char_info_tactic.dwExperience = tac_skillEXP[nKind];
		packet.u.char_info_tactic.nStep = GetTacticsStep(nKind);
		::QueuePacket(connections, GetServerID(), &packet, 1);
	}
}	//> CSD-TW-030624

void CCharInfo::AddPhysicalTacExp1(int nKind, int nExp)
{	//< CSD-TW-030624 : 荤成矫 琶平 版氰摹
	if (!IsLimitTac(nKind))  return;
	
	if (Tactics_para == nKind)  
	{
		nExp = nExp*1.2;
	}
	
	cur_tac_skill = nKind;

	IncTacticExp(nKind, nExp);
	LevelUpTactics(nKind);
}	//> CSD-TW-030624

void CCharInfo::AddPhysicalTacExp2(int nKind, int nExp)
{	//< CSD-030806 : 琶平 荐访矫 琶平 版氰摹
	if (!IsLimitTac(nKind))
	{
		return;
	}

	const int nLevel = GetLevel();
	
	if (NPC_Lev_Ref[nLevel].nMaxTactic > Skill[TACTICS_Crapple + nKind])
	{	// 琶平 荐访俊辑 棵副 荐 乐绰 版氰摹 力茄
		if (Tactics_para == nKind)
		{
			nExp = (NPC_Lev_Ref[nLevel].nTrainingExp*nExp/HpMax)/7;
		}
		else
		{
			nExp = (NPC_Lev_Ref[nLevel].nTrainingExp*nExp/HpMax)/12;
		}
		
		cur_tac_skill = nKind;
		IncTacticExp(nKind, nExp);
		LevelUpTactics(nKind);
	}	
}	//> CSD-030806

void CCharInfo::AddPhysicalTacExp3(int nKind, int nExp)
{	//< CSD-030806
	if (!IsLimitTac(nKind))
	{
		return;
	}

	const int nLevel = GetLevel();
	
	if (NPC_Lev_Ref[nLevel].nMaxTactic > Skill[TACTICS_Crapple + nKind])
	{	// 琶平 荐访俊辑 棵副 荐 乐绰 版氰摹 力茄
		cur_tac_skill = nKind;
		IncTacticExp(nKind, nExp);
		LevelUpTactics(nKind);
	}	
}	//> CSD-030806

void CCharInfo::AddMagicTacExp1(int nKind, int nExp)
{	//< CSD-TW-030624 : 荤成矫 琶平 版氰摹
	if (!IsLimitTac(nKind))  return;
	
	cur_tac_skill = nKind;
	IncTacticExp(nKind, nExp);
	LevelUpTactics(nKind);
}	//> CSD-TW-030624

void CCharInfo::AddMagicTacExp2(int nKind, int nExp)
{	//< CSD-030806 : 琶平 荐访矫 琶平 版氰摹
	if (!IsLimitTac(nKind))
	{
		return;
	}

	const int nLevel = GetLevel();
	
	if (NPC_Lev_Ref[nLevel].nMaxTactic > Skill[TACTICS_Crapple + nKind])
	{	// 琶平 荐访俊辑 棵副 荐 乐绰 版氰摹 力茄
		cur_tac_skill = nKind;
		IncTacticExp(nKind, nExp);
		LevelUpTactics(nKind);
	}
}	//> CSD-030806

///////////////////////////////////////////////////////////////////////////////
// Private Method
///////////////////////////////////////////////////////////////////////////////

bool CCharInfo::IsLimitExp(int nLevel)
{	//< CSD-030415
	const int nStep = GetClassStep();  
	// 努贰胶 窜拌俊 蝶弗 力茄
	CDualDataInfo* pDualData = g_pDualManager->GetDualDataInfo(nStep);

	if (pDualData == NULL)
	{
		return false;
	}

	if (nLevel >= pDualData->GetMaxLevel())
	{
		return false;
	}
	
	return true;
}	//> CSD-030415

bool CCharInfo::IsLimitTac(int nKind)
{	//< CSD-030806
	const int nTactic = Skill[TACTICS_Crapple + nKind];
	
	if (!IsLevelUp(nTactic))
	{
		return false;
	}
	
	if (GetLevel() <= 99)
	{ 
		if (nTactic >= 99)
		{
			m_aTacStep[nKind] = NPC_Lev_Ref[nTactic].nStep;
			tac_skillEXP[nKind] = NPC_Lev_Ref[nTactic].nMinExp;
			return false;
		}
	}
	
	return true;
}	//> CSD-030806

⌨️ 快捷键说明

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