📄 charinfo.cpp
字号:
// CharInfo.cpp: implementation of the CCharInfo class.
//
//////////////////////////////////////////////////////////////////////
#include "..\stdafx.h"
#include "CharInfo.h"
#include "CItem.h"
#include "Ability.h"
#include "LTSSupport.h"
#include "ItemMgr.h"//020110 LSW
#include "RareEffectMgr.h"
#include "LocalizingMgr.h"
#include "DualManager.h"
extern int NPC_MaleName_Count;
extern cLocalWarfield* g_pLocalWarfield;
extern NPCName_by_Gender NPC_Name_Ref[Num_Of_NPC_Name];
int MAX_EXP_LEVEL = 150; // CSD-040204
int MAX_TAC_LEVEL = 199; // CSD-040204
///////////////////////////////////////////////////////////////////////////////
// Public Method
///////////////////////////////////////////////////////////////////////////////
int CStatePoint::Increase(int nPoint, int nPercent = 100)
{ // 刘啊
const int nOldPoint = m_nCurPoint;
m_nCurPoint += nPoint;
const int nMaxPoint = m_nMaxPoint*nPercent/100;
if (m_nCurPoint > nMaxPoint)
{
m_nCurPoint = nMaxPoint;
}
return m_nCurPoint - nOldPoint;
}
int CStatePoint::Decrease(int nPoint, int nPercent = 0)
{ // 皑家
const int nOldPoint = m_nCurPoint;
m_nCurPoint -= nPoint;
const int nMaxPoint = m_nMaxPoint*nPercent/100;
if (m_nCurPoint < nMaxPoint)
{
m_nCurPoint = nMaxPoint;
}
return nOldPoint - m_nCurPoint;
}
///////////////////////////////////////////////////////////////////////////////
// Construction/Destruction
///////////////////////////////////////////////////////////////////////////////
CCharInfo::CCharInfo()
{
m_idServer = 0; // CSD-HK-030829
m_nLevel = 0; // CSD-030806
m_nGuildCode = 0; // CSD-030806
m_nCriticalCount = 0; // CSD-031007
m_nItemEffectCount = 0; // CSD-031007
m_nDualCls = 0;
m_nClsStep = 0;
m_nExpStep = 0;
m_bEventRecv = false; // BBD 040308
for (int i = 0; i < NO_TAC; ++i)
{
m_aTacStep[i] = 0;
}
m_gnAbility.Clear(); // 棵副 荐 乐绰 绢呼矾萍 器牢磐 檬扁拳
m_gnCombat.Clear(); // 棵副 荐 乐绰 傈捧胶懦 器牢磐 檬扁拳
m_pArenaGame = NULL; // CSD-030509
m_pArenaTeam = NULL; // CSD-030509
}
///////////////////////////////////////////////////////////////////////////////
// Public Method
///////////////////////////////////////////////////////////////////////////////
void CCharInfo::InitCombat()
{
SetCombatPoint(0);
for (int i = LIGHTNING_BOOM; i <= WIND_EXTREME; ++i)
{
Skill[i - 100] = 0;
}
}
void CCharInfo::IncAbility(BYTE nType)
{
CAbilityLimit* pLimit = g_mgrLimit.GetCell(Class, m_nClsStep);
switch (nType)
{
case STR: if (pLimit->GetStr() <= Str) return; ++Str; break;
case CON: if (pLimit->GetCon() <= Con) return; ++Con; break;
case DEX: if (pLimit->GetDex() <= Dex) return; ++Dex; break;
case WIS: if (pLimit->GetWis() <= Wis) return; ++Wis; break;
case INT_: if (pLimit->GetInt() <= Int) return; ++Int; break;
case MOVP: if (pLimit->GetMove() <= MoveP) return; ++MoveP; break;
case CHA: if (pLimit->GetChar() <= Char) return; ++Char; break;
case ENDU: if (pLimit->GetEndu() <= Endu) return; ++Endu; break;
case MOR: if (pLimit->GetMor() <= Moral) return; ++Moral; break;
case LUCK: if (pLimit->GetLuck() <= Luck) return; ++Luck; break;
case WSPS:
{
switch (Spell)
{
case WIZARD_SPELL: if (pLimit->GetWs() <= wsps) return; ++wsps; break;
case PRIEST_SPELL: if (pLimit->GetPs() <= wsps) return; ++wsps; break;
}
}
}
m_gnAbility.Decrease();
}
void CCharInfo::DecAbility(BYTE nType)
{
switch (nType)
{
case STR: if (Str > 10) return; --Str; break;
case CON: if (Con > 10) return; --Con; break;
case DEX: if (Dex > 10) return; --Dex; break;
case WIS: if (Wis > 10) return; --Wis; break;
case INT_: if (Int > 10) return; --Int; break;
case MOVP: if (MoveP > 10) return; --MoveP; break;
case CHA: if (Char > 10) return; --Char; break;
case ENDU: if (Endu > 10) return; --Endu; break;
case MOR: if (Moral > 10) return; --Moral; break;
case LUCK: if (Luck > 10) return; --Luck; break;
case WSPS:
{
switch (Spell)
{
case WIZARD_SPELL: if (wsps > 10) return; --wsps; break;
case PRIEST_SPELL: if (wsps > 10) return; --wsps; break;
}
}
}
m_gnAbility.Increase();
}
void CCharInfo::ResetAbility(BYTE nCombat)
{
// 弥措 Life樊 拌魂
const int nMaxHp = CalcNewLife(nCombat);
if (HpMax != nMaxHp)
{
HpMax = nMaxHp;
// Player牢 版快 蔼捞 函版登搁 Client俊 傈价
if (IsPlayer()) SendCharInfoBasic(MAX_HP, HpMax);
}
// 弥措 Mana樊 拌魂
const int nMaxMp = CalcNewMana(nCombat);
if (ManaMax != nMaxMp)
{
ManaMax = nMaxMp;
// Player牢 版快 蔼捞 函版登搁 Client俊 傈价
if (IsPlayer()) SendCharInfoBasic(MAX_MP, ManaMax);
}
// 弥措 Hungry樊 拌魂
const int nMaxSp = CalcNewHungry(nCombat);
if (HungryMax != nMaxSp)
{
HungryMax = nMaxSp;
// Player牢 版快 蔼捞 函版登搁 Client俊 傈价
if (IsPlayer()) SendCharInfoBasic(MAX_SP, HungryMax);
}
// 弥措 傈捧胶懦 荤侩啊瓷樊 拌魂
const int nMaxCp = CalcNewCombat();
if (CpMax != nMaxCp)
{
CpMax = nMaxCp;
// Player牢 版快 蔼捞 函版登搁 Client俊 傈价
if (IsPlayer()) SendCharInfoBasic(MAX_CP, CpMax);
}
// 函拳等 弥措 Life俊 蝶弗 Life 犁汲沥
if (Hp > HpMax)
{
Hp = HpMax;
// Player牢 版快 蔼捞 函版登搁 Client俊 傈价
if (IsPlayer()) SendCharInfoBasic(HP, Hp);
}
// 函拳等 弥措 Mana俊 蝶弗 Mana 犁汲沥
if (Mana > ManaMax)
{
Mana = ManaMax;
// Player牢 版快 蔼捞 函版登搁 Client俊 傈价
if (IsPlayer()) SendCharInfoBasic(MP, Mana);
}
// 函拳等 弥措 Hungry俊 蝶弗 Hungry 犁汲沥
if (Hungry > HungryMax)
{
Hungry = HungryMax;
// Player牢 版快 蔼捞 函版登搁 Client俊 傈价
if (IsPlayer()) SendCharInfoBasic(SP, Hungry);
}
// 函拳等 弥措 傈捧胶懦 荤侩啊瓷樊俊 蝶弗 Cp 犁汲沥
if (Cp > CpMax)
{
Cp = CpMax;
// Player牢 版快 蔼捞 函版登搁 Client俊 傈价
if (IsPlayer()) SendCharInfoBasic(CP, Cp);
}
// AC 拌魂
Ac = CalcNewAc();
}
void CCharInfo::DivideAbility(BYTE nNext)
{ // 掂倔 绢呼府萍 犁盒硅
CAbilityDivide* pDivide = g_mgrDivide.GetCell(Class, nNext);
// 掂倔 绢呼府萍 盒硅
Str += pDivide->GetStr();
Con += pDivide->GetCon();
Dex += pDivide->GetDex();
Wis += pDivide->GetWis();
Int += pDivide->GetInt();
MoveP += pDivide->GetMove();
Char += pDivide->GetChar();
Endu += pDivide->GetEndu();
Moral += pDivide->GetMor();
Luck += pDivide->GetLuck();
switch (Spell)
{
case WIZARD_SPELL: wsps += pDivide->GetWs(); break;
case PRIEST_SPELL: wsps += pDivide->GetPs(); break;
}
// 掂倔 努贰胶 窜拌 惑铰
++m_nClsStep;
// Reserved Point 拌魂
int nPoint = GetRemainStr();
nPoint += GetRemainCon();
nPoint += GetRemainDex();
nPoint += GetRemainWis();
nPoint += GetRemainInt();
nPoint += GetRemainMove();
nPoint += GetRemainChar();
nPoint += GetRemainEndu();
nPoint += GetRemainMor();
nPoint += GetRemainLuck();
switch (Spell)
{
case WIZARD_SPELL: nPoint += GetRemainWs(); break;
case PRIEST_SPELL: nPoint += GetRemainPs(); break;
}
// Reserved Point 眠啊
IncReservedPoint(nPoint);
// 绢呼府萍 犁汲沥
Str -= GetRemainStr();
Con -= GetRemainCon();
Dex -= GetRemainDex();
Wis -= GetRemainWis();
Int -= GetRemainInt();
MoveP -= GetRemainMove();
Char -= GetRemainChar();
Endu -= GetRemainEndu();
Moral -= GetRemainMor();
Luck -= GetRemainLuck();
switch (Spell)
{
case WIZARD_SPELL: wsps -= GetRemainWs(); break;
case PRIEST_SPELL: wsps -= GetRemainPs(); break;
}
}
void CCharInfo::ConvertTacticsLevel(BYTE nKind)
{ //< CSD-030314
for (int i = 1 ; i <= MAX_TAC_LEVEL; ++i)
{
if (m_aTacStep[nKind] == NPC_Lev_Ref[i].nStep && tac_skillEXP[nKind] <= NPC_Lev_Ref[i].nMaxExp)
{
Skill[TACTICS_Crapple + nKind] = i;
return;
}
}
Skill[TACTICS_Crapple + nKind] = MAX_TAC_LEVEL;
} //> CSD-030314
void CCharInfo::Message(BYTE nType, BYTE nKind, WORD nNumber)
{
t_packet packet;
packet.h.header.type = CMD_BATTLE_MESSAMGE;
packet.h.header.size = sizeof(t_battle_message);
packet.u.battle.battle_message.nType = nType;
packet.u.battle.battle_message.nKind = nKind;
packet.u.battle.battle_message.nNumber = nNumber;
::QueuePacket(connections, GetServerID(), &packet, 1);
}
bool CCharInfo::IncExperience(int nExp)
{ //< CSD-030930
const int nLevel = GetLevel();
if (nExp <= 0)
{
return false;
}
Exp += nExp;
if (Exp > NPC_Lev_Ref[nLevel].nMaxExp)
{
Exp = NPC_Lev_Ref[nLevel].nMaxExp + 1;
}
SendCharInfoBasic(EXP, Exp);
return true;
} //> CSD-030930
bool CCharInfo::DecExperience(bool bNK)
{ //< CSD-030930
const int nLevel = GetLevel();
const float fReduce = (bNK) ? NPC_Lev_Ref[nLevel].fNKReduction:
NPC_Lev_Ref[nLevel].fExpReduction;
const int nMinus = (NPC_Lev_Ref[nLevel].nNeedExp/100)*fReduce;
if (Exp < nMinus)
{
Exp = 0;
SendCharInfoBasic(EXP, Exp);
return false;
}
Exp -= nMinus;
SendCharInfoBasic(EXP, Exp);
return true;
} //> CSD-030930
bool CCharInfo::IncTacticExp(BYTE nKind, int nExp)
{ //< CSD-030930
const int nLevel = Skill[TACTICS_Crapple + nKind];
const int nPlus = nExp*NPC_Lev_Ref[nLevel].nTacRate/100;
if (nPlus <=0)
{
return false;
}
tac_skillEXP[nKind] += nPlus;
if (tac_skillEXP[nKind] > NPC_Lev_Ref[nLevel].nMaxExp)
{
tac_skillEXP[nKind] = NPC_Lev_Ref[nLevel].nMaxExp + 1;
}
SendCharInfoTactic(nKind);
return true;
} //> CSD-030930
bool CCharInfo::DecTacticExp(BYTE nKind, bool bNK)
{ //< CSD-030930
int nLevel = Skill[TACTICS_Crapple + nKind];
const float fReduce = (bNK) ? NPC_Lev_Ref[nLevel].fNKReduction:
NPC_Lev_Ref[nLevel].fExpReduction;
const int nMinus = (NPC_Lev_Ref[nLevel].nNeedExp/100)*fReduce;
if (tac_skillEXP[nKind] < nMinus)
{
Skill[TACTICS_Crapple + nKind] = --nLevel;
tac_skillEXP[nKind] = NPC_Lev_Ref[nLevel].nMaxExp + tac_skillEXP[nKind] - nMinus;
SetTacticsStep(nKind, NPC_Lev_Ref[nLevel].nStep);
SendCharInfoTactic(nKind);
//tac_skillEXP[nKind] = 0;
return false;
}
tac_skillEXP[nKind] -= nMinus;
SendCharInfoTactic(nKind);
return true;
} //> CSD-030930
int CCharInfo::GetAbility(BYTE nType) const
{
CAbilityLimit* pLimit = g_mgrLimit.GetCell(Class, m_nClsStep);
switch (nType)
{
case STR: return __min(pLimit->GetStr(), GetExtStr());
case CON: return __min(pLimit->GetCon(), GetExtCon());
case DEX: return __min(pLimit->GetDex(), GetExtDex());
case WIS: return __min(pLimit->GetWis(), GetExtWis());
case INT_: return __min(pLimit->GetInt(), GetExtInt());
case MOVP: return __min(pLimit->GetMove(), GetExtMove());
case CHA: return __min(pLimit->GetChar(), GetExtChar());
case ENDU: return __min(pLimit->GetEndu(), GetExtEndu());
case MOR: return __min(pLimit->GetMor(), GetExtMor());
case LUCK: return __min(pLimit->GetLuck(), GetExtLuck());
case WSPS:
{
switch (Spell)
{
case WIZARD_SPELL: return __min(pLimit->GetWs(), GetExtWs());
case PRIEST_SPELL: return __min(pLimit->GetPs(), GetExtPs());
}
}
}
return 0;
}
int CCharInfo::GetWeaponSkill()
{ // 扁贱槛访档 备窍扁
const int nIndex = GetTacticsKind();
if (nIndex >= TACTICS_Crapple && nIndex <= TACTICS_Orison)
{
cur_tac_skill = nIndex - TACTICS_Crapple;
}
else
{
cur_tac_skill = 0;
}
return Skill[nIndex];
}
int CCharInfo::GetNpcAttack() const
{ //< CSD-031007 : NPC 拱府利 傍拜仿
int nRandom = 0;
if (NPC_Gen_Ref[npc_index].nStrikeRandom != 0)
{
if (++m_nCriticalCount > 5 && NPC_Gen_Ref[npc_index].nCriticalRate < rand()%101)
{
nRandom += NPC_Gen_Ref[npc_index].nStrikeDamage*NPC_Gen_Ref[npc_index].nCriticalDamage/100;
m_nCriticalCount = 0;
}
nRandom += rand()%NPC_Gen_Ref[npc_index].nStrikeRandom;
}
return NPC_Gen_Ref[npc_index].nStrikeDamage + nRandom;
} //> CSD-031007
int CCharInfo::GetNpcDefence() const
{ //< CSD-021019 : NPC 拱府利 规绢仿
return NPC_Gen_Ref[npc_index].nPhysical;
} //> CSD-021019
int CCharInfo::GetNpcMagic() const
{ //< CSD-020822 : NPC 付过 傍拜仿
int nRandom = 0;
if (NPC_Gen_Ref[npc_index].nMagicRandom != 0)
{
nRandom = rand()%NPC_Gen_Ref[npc_index].nMagicRandom;
}
return (NPC_Gen_Ref[npc_index].nMagicDamage) + nRandom;
} //> CSD-020822
int CCharInfo::GetNpcDefence(BYTE nType) const
{ //< CSD-021019 : NPC 付过 规绢仿
int nResist = 0; // 阁胶磐狼 扁夯 付过历亲仿
switch (nType)
{
case RESIST_FIRE:
{ // 阂拌凯 付过俊 措茄 历亲仿
nResist += NPC_Gen_Ref[npc_index].nFire;
break;
}
case RESIST_ICE:
{ // 倔澜拌凯 付过俊 措茄 历亲仿
nResist += NPC_Gen_Ref[npc_index].nIce;
break;
}
case RESIST_ELECT:
{ // 傈拜拌凯 付过俊 措茄 历亲仿
nResist += NPC_Gen_Ref[npc_index].nElect;
break;
}
case RESIST_HOLY:
{ // 脚仿拌凯 付过俊 措茄 历亲仿
nResist += NPC_Gen_Ref[npc_index].nHoly;
break;
}
}
return nResist;
} //> CSD-021019
int CCharInfo::GetNpcStrikePiercing() const
{ //< CSD-021024
return NPC_Gen_Ref[npc_index].nPiercingStrike;
} //> CSD-021024
int CCharInfo::GetNpcMagicPiercing() const
{ //< CSD-021024
return NPC_Gen_Ref[npc_index].nPiercingMagic;
} //> CSD-021024
int CCharInfo::GetNpcStunAvoid() const
{ //< CSD-021024
return NPC_Gen_Ref[npc_index].nStun;
} //> CSD-021024
int CCharInfo::GetNpcSlowAvoid() const
{ //< CSD-021024
return NPC_Gen_Ref[npc_index].nSlow;
} //> CSD-021024
int CCharInfo::GetNpcPoisonAvoid() const
{ //< CSD-021024
return NPC_Gen_Ref[npc_index].nPoison;
} //> CSD-021024
int CCharInfo::GetNpcBlindAvoid() const
{ //< CSD-021024
return NPC_Gen_Ref[npc_index].nBlind;
} //> CSD-021024
int CCharInfo::GetNpcDrainAvoid() const
{ //< CSD-021024
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -