📄 player_parameter.cpp
字号:
VOID Player::GetPlayerVillageInfo( PLAYER_VILLAGE_INFO * OUT pVillageInfo )
{
WzVector vec;
GetPos(&vec);
BASE_PLAYERINFO * pInfo = SCPlayer::GetCharInfo();
pVillageInfo->m_wPlayerKey = GetObjectKey();
strncpy((char*)&(pVillageInfo->m_lpszName), pInfo->m_tszCharName, MAX_CHARNAME_LENGTH);
pVillageInfo->m_fPos[0] = vec.x;
pVillageInfo->m_fPos[1] = vec.y;
pVillageInfo->m_fPos[2] = vec.z;
pVillageInfo->m_wMoveSpeedRatio = GetAttr().GetMoveSpeedRatio();
pVillageInfo->m_byHair = pInfo->m_byHair; // 赣府葛剧
pVillageInfo->m_byHeight = pInfo->m_byHeight;// 虐
pVillageInfo->m_byFace = pInfo->m_byFace; // 倔奔葛剧
// GM 殿鞭 悸泼
GM_INFO *pGMInfo = GMList::Instance()->FindGM( GetUserID() );
if( pGMInfo ) pVillageInfo->m_byGMGrade = pGMInfo->m_byGrade;
else pVillageInfo->m_byGMGrade = 0;
// PC规 蜡历
pVillageInfo->m_byPCBangUser = GetReservedValue() > 0 ? 1 : 0;
// 泅犁 惑怕
pVillageInfo->m_byCondition = GetStatusManager()->GetCondition();
pVillageInfo->m_byClass = pInfo->m_byClassCode;
pVillageInfo->m_BehaveState = GetBehave();
}
VOID Player::GetGuildRenderInfo( GUILD_RENDER_INFO * OUT pRenderInfo )
{
BASE_PLAYERINFO * pInfo = SCPlayer::GetCharInfo();
if( 0 != pInfo->m_GuildGuid )
{
pRenderInfo->m_byExistGuild = 1;
pRenderInfo->m_GuildMarkIdx = 0;
//GameGuild * pGameGuild = g_GameGuildManager.FindGuild( pInfo->m_GuildGuid );
//if( pGameGuild )
memcpy( pRenderInfo->m_tszGuildName, pInfo->m_tszGuildName, sizeof(TCHAR)*MAX_GUILDNAME_LENGTH );
}
else
{
pRenderInfo->m_byExistGuild = 0;
}
}
BOOL Player::SerializeInfoToDBProxy()
{
// 林扁利栏肺 DBProxy肺 焊郴绰 沥焊 : 1. 某腐磐 沥焊(m_CharInfo) 2.酒捞袍 3. 胶懦
// 弥利拳 且 鞘夸啊 乐绰 何盒!
// - 函版等 何盒阑 焊郴绰 规过 绊妨!
// MSG_DG_CHARINFO_UPDATE2DBP_CMD SendMsg;
// SerializePlayerTotalInfo( SendMsg.m_PlayerTotalInfo, SERIALIZE_LOAD );
if( GetState() < PLAYER_LOADING ||
GetState() == PLAYER_DESTROYED ) return TRUE;
MSG_DG_CHARINFO_CHAR_ITEM_CMD msg1;
msg1.m_dwKey = GetUserKey();
msg1.m_CharacterInfo = *GetCharInfo();
SerializeItemTotalInfo( msg1.m_ItemInfo, SERIALIZE_LOAD );
if( FALSE == SendToGameDBPServer( &msg1, msg1.GetSize() ) )
{
SUNLOG( eFULL_LOG, "[Player::SerializeInfoToDBProxy] [ERROR]DBP俊菩哦(SerializeInfoToDBProxy)阑傈崔且荐绝嚼聪促." );
return FALSE;
}
MSG_DG_CHARINFO_SKILL_CMD msg2;
msg2.m_dwKey = GetUserKey();
SerializeSkillTotalInfo( msg2.m_SkillInfo, SERIALIZE_LOAD );
SendToGameDBPServer( &msg2, msg2.GetSize() );
MSG_DG_CHARINFO_QUICK_CMD msg3;
msg3.m_dwKey = GetUserKey();
SerializeQuickTotalInfo( msg3.m_QuickInfo, SERIALIZE_LOAD );
SendToGameDBPServer( &msg3, msg3.GetSize() );
MSG_DG_CHARINFO_STYLE_CMD msg4;
msg4.m_dwKey = GetUserKey();
SerializeStyleTotalInfo( msg4.m_StyleInfo, SERIALIZE_LOAD );
SendToGameDBPServer( &msg4, msg4.GetSize() );
MSG_DG_CHARINFO_QUEST_CMD msg5;
msg5.m_dwKey = GetUserKey();
GetMissionManager()->SerializeStream( msg5.m_pMissionStream, MAX_MISSIONSTREAM_SIZE, SERIALIZE_LOAD );
GetQuestManager()->SerializeStream( msg5.m_pQuestStream, MAX_QUESTSTREAM_SIZE, SERIALIZE_LOAD );
SendToGameDBPServer( &msg5, sizeof(msg5) );
// 芒绊啊 矫累吝捞搁 DB肺 泅犁鳖瘤狼 沥焊甫 历厘窍档废 茄促.
if( GetWarehouseContainer()->IsStarted() )
{
BOOL ret = GetWarehouseContainer()->SaveWarehouseToDBP();
ASSERT(ret);
}
return TRUE;
}
VOID Player::CopyToCharInfo( PLAYERINFO_FOR_PACKET & rCharInfoOut )
{
// Hero(磊扁磊脚)牢 版快俊 荐摹甸篮 Base荐摹甫 焊辰促. 努扼俊辑 胶懦, 酒捞袍, 胶鸥老 殿殿俊 狼茄 荐摹甫 促矫 拌魂茄促.
BASE_PLAYERINFO * pInfo = GetCharInfo();
rCharInfoOut.m_dwExp = pInfo->m_dwExp;
rCharInfoOut.m_MaxHP = GetAttr().GetBaseMaxHP();
rCharInfoOut.m_HP = pInfo->m_dwHP;
rCharInfoOut.m_MaxMP = GetAttr().GetBaseMaxMP();
rCharInfoOut.m_MP = pInfo->m_dwMP;
rCharInfoOut.m_Money = pInfo->m_Money;
rCharInfoOut.m_dwRemainStat = pInfo->m_dwRemainStat;
rCharInfoOut.m_dwRemainSkill = pInfo->m_dwRemainSkill;
rCharInfoOut.m_SelectStyleCode = pInfo->m_wSelectStyleCode;
rCharInfoOut.m_byPKState = pInfo->m_byPKState;
rCharInfoOut.m_byCharState = pInfo->m_byCharState;
rCharInfoOut.m_StateTime = pInfo->m_StateTime;
memcpy( rCharInfoOut.m_tszTitleID, pInfo->m_tszTitleID, MAX_TITLEID_LENGTH*sizeof(TCHAR) );
rCharInfoOut.m_TitleTime = pInfo->m_TitleTime;
rCharInfoOut.m_bInventoryLock = pInfo->m_bInventoryLock;
rCharInfoOut.m_sStrength = GetAttr().GetBaseSTR();
rCharInfoOut.m_sDexterity = GetAttr().GetBaseDEX();
rCharInfoOut.m_sVitality = GetAttr().GetBaseVIT();
rCharInfoOut.m_sInteligence = GetAttr().GetBaseINT();
rCharInfoOut.m_sSpirit = GetAttr().GetBaseSPR();
rCharInfoOut.m_sSkillStat1 = pInfo->m_sSkillStat1;
rCharInfoOut.m_sSkillStat2 = pInfo->m_sSkillStat2;
rCharInfoOut.m_wMoveSpeedRatio = GetAttr().GetMoveSpeedRatio();
rCharInfoOut.m_wAttSpeedRatio = GetAttr().GetAttSpeedRatio();
// GM 殿鞭 悸泼
GM_INFO *pGMInfo = GMList::Instance()->FindGM( GetUserID() );
if( pGMInfo ) rCharInfoOut.m_byGMGrade = pGMInfo->m_byGrade;
else rCharInfoOut.m_byGMGrade = 0;
// 泅犁 惑怕
rCharInfoOut.m_byCondition = GetStatusManager()->GetCondition();
// PC规 蜡历
rCharInfoOut.m_byPCBangUser = GetReservedValue() > 0 ? 1 : 0;
// 虐, 倔奔, 赣府
//rCharInfoOut.m_byHeight = pInfo->m_byHeight;
//rCharInfoOut.m_byFace = pInfo->m_byFace;
//rCharInfoOut.m_byHair = pInfo->m_byHair;
rCharInfoOut.m_PlayLimitedTime = pInfo->m_PlayLimitedTime;
rCharInfoOut.m_byInvisibleOptFlag = pInfo->m_byInvisibleOptFlag;
}
const BASE_ITEMINFO* Player::GetEquipItemInfo(eEQUIPCONTAINER_POS pos) const
{
SASSERT( m_pItemManager != NULL, "[Player::GetEquipItemInfo] m_pItemManager == NULL" );
SCSlotContainer* pContainer = m_pItemManager->GetItemSlotContainer(SI_EQUIPMENT);
SASSERT( pContainer != NULL, "[Player::GetEquipItemInfo] pContainer == NULL" );
if (!pContainer->IsEmpty( pos ))
{
const SCSlot & rSlot = pContainer->GetSlot( pos );
const BASE_ITEMINFO *pInfo = ItemInfoParser::Instance()->GetItemInfo( rSlot.GetCode() );
SASSERT( pInfo != NULL, "[Player::GetEquipItemInfo] pInfo == NULL" );
return pInfo;
}
return NULL;
}
eARMOR_TYPE Player::GetArmorType() const
{
const BASE_ITEMINFO* pInfo = GetEquipItemInfo( eEQUIPCONTAINER_SHIRTS );
if (pInfo != NULL)
{
return (eARMOR_TYPE)pInfo->m_wDefType;
}
return eARMOR_UNARMOR;
}
eMELEE_TYPE Player::GetMeleeType() const
{
const BASE_ITEMINFO* pInfo = GetEquipItemInfo( eEQUIPCONTAINER_WEAPON );
if (pInfo != NULL)
{
return (eMELEE_TYPE)pInfo->m_wAttType;
}
return eMELEE_TYPE_HIT;
}
float Player::GetAttackRange() const
{
float fAttackRange;
POSTYPE wPos = eEQUIPCONTAINER_WEAPON;
if( m_pItemManager->GetItemSlotContainer(SI_EQUIPMENT)->IsEmpty( wPos ) )
{
// 盖林冈
fAttackRange = 2.5f;
}
else
{
const SCSlot & rSlot = m_pItemManager->GetItemSlotContainer(SI_EQUIPMENT)->GetSlot( wPos );
BASE_ITEMINFO *pInfo = ItemInfoParser::Instance()->GetItemInfo( rSlot.GetCode() );
SASSERT( pInfo, "[Player::GetAttackRange] pInfo == NULL " );
fAttackRange = pInfo->m_wAttRange;
}
return fAttackRange;
}
VOID Player::AddExp( DWORD exp, DWORD dwTargetObjKey )
{
// 10殿盒 肺弊 巢扁扁 矫累
DWORD dwOldExp = GetExp();
DWORD dwNewExp = GetExp() + exp;
DWORD dwCurAccumExp = GetAccumExp( GetLevel() ) ;
DWORD dwNextAccumExp = GetAccumExp( GetLevel() +1 );
DWORD dwDifExp = (dwNextAccumExp - dwCurAccumExp) / 10;
BYTE byCurDivide = (BYTE)( ( GetExp() - dwCurAccumExp ) / dwDifExp );
BYTE byNextDivide = (BYTE)( ( GetExp() + exp - dwCurAccumExp ) / dwDifExp );
if( byCurDivide < byNextDivide )
{
WORD wLevel = 0;
if( (GetExp() + exp) >= dwNextAccumExp ) wLevel = GetLevel() + 1;
else wLevel = GetLevel();
GAMELOG->WriteDivideExp( this, g_pGameServer->GetServerGUID(), dwOldExp, dwNewExp,
GetLevel(), wLevel, byNextDivide );
}
// 10殿盒 肺弊 巢扁扁 场
SetExp( dwNewExp );
OnAddExp( dwTargetObjKey );
//泅犁 版氰摹啊 促澜 饭骇狼 版氰摹焊促 臭栏搁.. 饭骇诀捞促.
if( GetExp() >= GetNextExp() )
{
// 饭骇诀 肺弊
GAMELOG->WriteLevelUp( this, g_pGameServer->GetServerGUID(), dwOldExp, dwNewExp, GetLevel(),
GetLevel() + 1 );
SUNLOG( eFULL_LOG, "[Player::AddExp] [饭骇 诀] ID = %s, NAME = %s, Level = %d ",
m_pszUserID, SCPlayer::GetCharInfo()->m_tszCharName, GetLevel()+1 );
// 饭骇诀 肺弊 场..
// TODO: level up! --> 泅犁 版氰摹俊 嘎霸 level苞 nextExp甫 促矫 汲沥茄促.
SetLevel( GetLevel() + 1 );
OnLevelUp();
}
}
DWORD Player::GetWeaponKind()
{
const SCSlot & rSlot = m_pItemManager->GetItemSlotContainer(SI_EQUIPMENT)->GetSlot( eEQUIPCONTAINER_WEAPON );
if( !rSlot.GetCode() )
{
// 盖林冈
return 0;
}
else
{
BASE_ITEMINFO *pItemInfo = ItemInfoParser::Instance()->GetItemInfo( rSlot.GetCode() );
if( !pItemInfo )
{
SUNLOG( eMIDDLE_LOG, "[Player::GetWeaponKind] The pItemInfo of a weapon is NULL! " );
return 0;
}
return pItemInfo->m_wType;
}
}
VOID Player::UpdateHPMPRecover( BOOL bHPUpdate, BOOL bMPUpdate )
{
if( bHPUpdate )
{
int iRecoverHP = CalcHPRecover( GetCharType(), m_Attr.GetVIT(), GetStatusManager()->GetCondition(), GetLevel());
SetAttr( eATTR_RECOVERY_HP, eATTR_KIND_BASE, iRecoverHP );
}
if( bMPUpdate )
{
int iRecoverMP = CalcMPRecover( GetCharType(), m_Attr.GetSPR(), GetStatusManager()->GetCondition() );
SetAttr( eATTR_RECOVERY_MP, eATTR_KIND_BASE, iRecoverMP );
}
}
//-------------------------------------------------------------------------------------------------
// 颇扼固磐 函拳
//-------------------------------------------------------------------------------------------------
// stat
BOOL Player::CanSelectStat(eATTR_TYPE attrType) const
{
if (SCPlayer::GetCharInfo()->m_dwRemainStat == 0)
{
return FALSE;
}
// attrType捞 沥惑牢啊?
switch (attrType)
{
case eATTR_STR:
case eATTR_DEX:
case eATTR_VIT:
case eATTR_INT:
case eATTR_SPR:
case eATTR_EXPERTY1:
case eATTR_EXPERTY2:
break;
default :
return FALSE;
}
// TODO: 捞固 attrType捞 MAX俊 档崔茄 版快绰 阂啊! MAX绰 绢叼俊? --;
return TRUE;
}
DWORD Player::SelectStat(eATTR_TYPE attrType)
{
SASSERT( SCPlayer::GetCharInfo()->m_dwRemainStat > 0, "[Player::SelectStat] m_dwRemainStat <= 0" );
if( attrType != eATTR_STR
&& attrType != eATTR_DEX
&& attrType !=eATTR_VIT
&& attrType !=eATTR_INT
&& attrType !=eATTR_SPR
&& attrType !=eATTR_EXPERTY1
&& attrType !=eATTR_EXPERTY2 )
{
ASSERT( ! "[Player::SelectStat] Invalid attrType" );
}
// Stat 1 point 临牢促
SCPlayer::GetCharInfo()->m_dwRemainStat = SCPlayer::GetCharInfo()->m_dwRemainStat - 1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -