460 lines
11 KiB
C++
460 lines
11 KiB
C++
|
|
#include "stdafx.h"
|
|
#include "SAvatarProperty.h"
|
|
#include "SGameMessage.h"
|
|
#include "GameRule.h"
|
|
#include "SExpDB.h"
|
|
#include "SNpcResourceDB.h"
|
|
|
|
#include "SDebug_Util.h"
|
|
// 2010.08.02 - prodongi
|
|
#include "SMonsterDB.h"
|
|
|
|
SAvatarProperty::SAvatarProperty( ENC_INT nContentID )
|
|
{
|
|
static ENC_INT _autotrap( XFastRandom() );
|
|
|
|
m_nContentID.init( _autotrap ); // init to autotrap
|
|
m_nContentID.set( nContentID );
|
|
|
|
m_nInnContentID.init( _autotrap ); // init to autotrap
|
|
m_nInnContentID.set( nContentID );
|
|
|
|
m_strName = "Unknown Name";
|
|
|
|
m_ObjType = 0;
|
|
//////////////////////////////////////////////////////////////////////////
|
|
//Content Data
|
|
m_nRace = 0; //종족
|
|
m_nSex = 0; //성별
|
|
|
|
m_nGold = 0; //GOLD
|
|
|
|
m_nHP = 0; //HP~
|
|
m_nMP = 0; //MP~
|
|
m_nMaxHP = -1; //HP MAX
|
|
m_nMaxMP = -1; //MP MAX
|
|
|
|
m_nJobPoint = 0; //JOB POINT
|
|
m_nJobLevel = 0; //JOB LEVEL
|
|
m_nJob = 0; //JOB
|
|
|
|
m_nLevel = 0; //LEVEL
|
|
m_nEXP = 0; //EXP
|
|
m_nJP = 0; //JP
|
|
|
|
m_n64_PreviosExp = 0;
|
|
m_n64_MaxExp = 0;
|
|
m_nCurExp = 0;
|
|
|
|
m_nOldExp = 0;
|
|
m_nOldJP = 0;
|
|
|
|
ZeroMemory( &m_stat , sizeof(m_stat) ); //스탯
|
|
ZeroMemory( &m_attribute, sizeof(m_attribute) ); //속성
|
|
|
|
m_nCharisma = 0; //매력
|
|
m_nMoral = 0; //도덕
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
m_faceId = 0;
|
|
m_faceTextureId = 0;
|
|
m_hairId = 0;
|
|
|
|
m_bLocal = false;
|
|
|
|
SetStatus(0); //상태:앉기,서기, PKMODE
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
//AvatarEx 내부 사용 용
|
|
m_InnObjType = 0;
|
|
|
|
m_nInnRace = 0;
|
|
m_nInnSex = 0;
|
|
|
|
m_InnfaceId = 0;
|
|
m_InFaceTexureId = 0;
|
|
m_InnhairId = 0;
|
|
}
|
|
|
|
SAvatarProperty::~SAvatarProperty()
|
|
{
|
|
|
|
}
|
|
|
|
AR_UNIT SAvatarProperty::GetAttackRange()
|
|
{
|
|
return ( ((float)(GameRule::DEFAULT_UNIT_SIZE) ) * m_attribute.nAttackRange) / (float)(GameRule::ATTACK_RANGE_UNIT ) ;
|
|
}
|
|
|
|
float SAvatarProperty::GetDBAttackRange()
|
|
{
|
|
return (float)m_attribute.nAttackRange / (float)(GameRule::ATTACK_RANGE_UNIT);
|
|
}
|
|
|
|
bool SAvatarProperty::IsLive()
|
|
{
|
|
return (m_nHP > 0) ? true : false;
|
|
}
|
|
|
|
void SAvatarProperty::ProcMsgAtStatic( struct SGameMessage * pMsg )
|
|
{
|
|
//주로 데이타가 설정 되겠다.
|
|
switch( pMsg->nType )
|
|
{
|
|
|
|
case MSG_ENTER :
|
|
{
|
|
SMSG_ENTER* pEnterMsg = static_cast<SMSG_ENTER*>(pMsg);
|
|
m_ObjType = pEnterMsg->ObjType;
|
|
|
|
switch( m_ObjType )
|
|
{
|
|
case TS_ENTER::GAME_PLAYER :
|
|
{
|
|
SMSG_ENTER::PlayerInfo * pPlayerInfo = (SMSG_ENTER::PlayerInfo *)(pEnterMsg+1);
|
|
|
|
m_nRace = pPlayerInfo->race;
|
|
m_nSex = pPlayerInfo->sex;
|
|
m_strName = pPlayerInfo->szName;
|
|
SetStatus( pPlayerInfo->status );
|
|
m_faceId = pPlayerInfo->faceId;
|
|
m_faceTextureId = pPlayerInfo->faceTextureId;
|
|
m_hairId = pPlayerInfo->hairId;
|
|
m_is_first_enter = pPlayerInfo->is_first_enter;
|
|
m_nJob = pPlayerInfo->job_id;
|
|
|
|
SetLevel( pPlayerInfo->level );
|
|
|
|
SetHP( pPlayerInfo->hp );
|
|
SetMaxHP( pPlayerInfo->max_hp );
|
|
SetMP( pPlayerInfo->mp );
|
|
SetMaxMP( pPlayerInfo->max_mp );
|
|
|
|
assert( m_nHP >= 0 && "HP 에 (-) 값이 설정 됨" );
|
|
}
|
|
break;
|
|
case TS_ENTER::GAME_SUMMON:
|
|
{
|
|
SMSG_ENTER::CreatureInfo * pCreatureInfo = (SMSG_ENTER::CreatureInfo *)(pEnterMsg+1);
|
|
SetHP(pCreatureInfo->hp);
|
|
SetMaxHP(pCreatureInfo->max_hp);
|
|
SetMP( pCreatureInfo->mp );
|
|
SetMaxMP( pCreatureInfo->max_mp );
|
|
|
|
SetLevel( pCreatureInfo->level );
|
|
}
|
|
break;
|
|
case TS_ENTER::GAME_MOB:
|
|
{
|
|
SMSG_ENTER::MonsterInfo * pMonsterInfo = (SMSG_ENTER::MonsterInfo *)(pEnterMsg+1);
|
|
SetHP( pMonsterInfo->hp );
|
|
SetMaxHP( pMonsterInfo->max_hp );
|
|
SetMP( pMonsterInfo->mp );
|
|
SetMaxMP( pMonsterInfo->max_mp );
|
|
|
|
SetLevel( pMonsterInfo->level );
|
|
SetStatus( pMonsterInfo->status );
|
|
|
|
// 2010.08.02 - prodongi
|
|
SetName(S(GetMonsterDB().GetTextID(pMonsterInfo->monster_id)));
|
|
}
|
|
break;
|
|
case TS_ENTER::GAME_NPC:
|
|
{
|
|
SMSG_ENTER::NPCInfo * pNpcInfo = (SMSG_ENTER::NPCInfo *)(pEnterMsg+1);
|
|
|
|
NpcResourceBase* pNpcInfoDB = GetNpcResourceDB().GetNpcInfo( pNpcInfo->npc_id );
|
|
if( pNpcInfoDB && pNpcInfoDB->sexsual_id > 0)
|
|
{
|
|
m_nRace = pNpcInfoDB->race_id;
|
|
m_nSex = pNpcInfoDB->sexsual_id;
|
|
m_faceId = pNpcInfoDB->face_id;
|
|
m_hairId = pNpcInfoDB->hair_id;
|
|
}
|
|
}
|
|
break;
|
|
case TS_ENTER::GAME_ITEM:
|
|
case TS_ENTER::GAME_FIELD_PROP:
|
|
case TS_ENTER::GAME_SKILL_PROP:
|
|
{
|
|
SetHP( 100 );
|
|
SetMaxHP( 100 );
|
|
SetMP( 100 );
|
|
SetMaxMP( 100 );
|
|
|
|
SetLevel( 1 );
|
|
}
|
|
break;
|
|
case TS_ENTER::GAME_PET: // sonador 10.2.1 팻 시스템 구현
|
|
{
|
|
SMSG_ENTER::PetInfo* pPetInfo = reinterpret_cast< SMSG_ENTER::PetInfo* >( pEnterMsg + 1 );
|
|
SetHP ( pPetInfo->hp );
|
|
SetMaxHP( pPetInfo->max_hp );
|
|
SetMP ( pPetInfo->mp );
|
|
SetMaxMP( pPetInfo->max_mp );
|
|
SetLevel( pPetInfo->level );
|
|
}
|
|
break;
|
|
}
|
|
|
|
SetInnInfo( pEnterMsg );
|
|
}
|
|
break;
|
|
case MSG_LOGIN :
|
|
{
|
|
SMSG_LOGIN* pLoginMsg = static_cast<SMSG_LOGIN*>(pMsg);
|
|
m_nRace = pLoginMsg->race;
|
|
m_nSex = pLoginMsg->sex;
|
|
m_strName = pLoginMsg->szName;
|
|
m_ObjType = TS_ENTER::GAME_PLAYER;
|
|
m_nHP = pLoginMsg->hp;
|
|
m_nMaxHP = pLoginMsg->max_hp;
|
|
m_nMP = pLoginMsg->mp;
|
|
m_nMaxMP = pLoginMsg->max_mp;
|
|
m_faceId = pLoginMsg->faceid;
|
|
m_hairId = pLoginMsg->hairid;
|
|
assert( m_nHP >= 0 && "HP 에 (-) 값이 설정 됨" );
|
|
m_bLocal = true;
|
|
|
|
SetInnInfo( pLoginMsg );
|
|
}
|
|
break;
|
|
/* case MSG_REGEN_HPMP:
|
|
{
|
|
SMSG_REGEN_HPMP* pRegenHpMp = static_cast<SMSG_REGEN_HPMP*>(pMsg);
|
|
SetHP( pRegenHpMp->hp );
|
|
SetMP( pRegenHpMp->mp );
|
|
}
|
|
break;*/
|
|
case MSG_STAT_INFO :
|
|
{
|
|
SMSG_STAT_INFO * pStat = static_cast<SMSG_STAT_INFO*>(pMsg);
|
|
memcpy( &m_stat , &pStat->stat , sizeof( m_stat ) );
|
|
memcpy( &m_attribute, &pStat->attribute, sizeof( m_attribute ) );
|
|
}
|
|
break;
|
|
/* case MSG_HPMP : //HP및 MP는 SGameSystem에서 처리될꺼다
|
|
{
|
|
SMSG_HPMP * pHpMp = static_cast<SMSG_HPMP*>(pMsg);
|
|
// SetHP( pHpMp->hp );
|
|
// SetMP( pHpMp->mp );
|
|
m_nMaxHP = pHpMp->max_hp;
|
|
m_nMaxMP = pHpMp->max_mp;
|
|
assert( m_nHP >= 0 && "HP 에 (-) 값이 설정 됨" );
|
|
}
|
|
break;*/
|
|
case MSG_EXP_UPDATE :
|
|
{
|
|
SMSG_EXP_UPDATE * pExpUpdate = static_cast<SMSG_EXP_UPDATE*>(pMsg);
|
|
|
|
if( m_nEXP == 0 && m_nJP == 0 )
|
|
{ //첫 엔터시만 설정
|
|
m_nEXP = pExpUpdate->exp;
|
|
m_nJP = pExpUpdate->jp;
|
|
}
|
|
|
|
//m_nOldExp = m_nEXP;
|
|
//m_nOldJP = m_nJP;
|
|
|
|
//m_nEXP = pExpUpdate->exp;
|
|
//m_nJP = pExpUpdate->jp;
|
|
|
|
//// 레벨에 따른 exp 재 계산
|
|
//m_n64_PreviosExp = GetExpDB().GetNeedExp( m_nLevel - 1 );
|
|
//m_n64_MaxExp = GetExpDB().GetNeedExp(m_nLevel) - m_n64_PreviosExp;
|
|
|
|
//m_nCurExp = m_nEXP - m_n64_PreviosExp;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
int SAvatarProperty::GetPercentEXP()
|
|
{
|
|
if( m_n64_MaxExp == 0 ) return 0;
|
|
if( m_nCurExp.value() >= m_n64_MaxExp.value() ) return 100;
|
|
|
|
float fPer = static_cast<float>(m_nCurExp)/static_cast<float>(m_n64_MaxExp)*100.f;
|
|
fPer = min( fPer, 100.f );
|
|
|
|
return (int)fPer;
|
|
}
|
|
|
|
void SAvatarProperty::SetHP( int nHP )
|
|
{
|
|
m_nHP = nHP;
|
|
if (m_nHP < 0)
|
|
m_nHP = 0;
|
|
|
|
assert( m_nHP >= 0 && "HP 에 (-) 값이 설정 됨" );
|
|
}
|
|
|
|
void SAvatarProperty::SetMaxHP( int nMaxHP )
|
|
{
|
|
m_nMaxHP = nMaxHP;
|
|
if (m_nMaxHP < 0)
|
|
m_nMaxHP = 0;
|
|
|
|
assert( m_nMaxHP >= 0 && "MAXHP 에 (-) 값이 설정 됨" );
|
|
}
|
|
|
|
void SAvatarProperty::SetMP( int nMP )
|
|
{
|
|
m_nMP = nMP;
|
|
// assert( m_nMP >= 0 && "MP 에 (-) 값이 설정 됨" );
|
|
}
|
|
|
|
void SAvatarProperty::SetMaxMP( int nMaxMP )
|
|
{
|
|
m_nMaxMP = nMaxMP;
|
|
assert( m_nMaxMP >= 0 && "MAXMP 에 (-) 값이 설정 됨" );
|
|
}
|
|
|
|
int SAvatarProperty::SetLevel( int nLevel )
|
|
{
|
|
if( m_nLevel )
|
|
{
|
|
if( m_nLevel == nLevel )
|
|
return false;
|
|
|
|
m_nLevel = nLevel;
|
|
return m_nLevel;
|
|
}
|
|
m_nLevel = nLevel;
|
|
//처음엔 Play 안 함
|
|
return false;
|
|
}
|
|
|
|
int SAvatarProperty::SetJobLevel( int nJobLevel )
|
|
{
|
|
if( m_nJobLevel )
|
|
{
|
|
if( m_nJobLevel == nJobLevel )
|
|
return false;
|
|
|
|
m_nJobLevel = nJobLevel;
|
|
return m_nJobLevel;
|
|
}
|
|
m_nJobLevel = nJobLevel;
|
|
//처음엔 Play 안 함
|
|
return false;
|
|
}
|
|
|
|
/// 2011.07.11 - prodongi
|
|
void SAvatarProperty::SetJobID(int id)
|
|
{
|
|
m_nJob = id;
|
|
}
|
|
|
|
void SAvatarProperty::SetStatus( unsigned status )
|
|
{
|
|
m_status = status;
|
|
|
|
#ifndef NDEBUG
|
|
if( m_bLocal )
|
|
{
|
|
if( m_status & TS_ENTER::PlayerInfo::FLAG_PK_ON )
|
|
{
|
|
_oprint( "Local : PK ON\n" );
|
|
}
|
|
|
|
if( m_status & TS_ENTER::PlayerInfo::FLAG_BLOODY )
|
|
{
|
|
_oprint( "Local : FLAG_BLOODY\n" );
|
|
}
|
|
else if( m_status & TS_ENTER::PlayerInfo::FLAG_DEMONIAC )
|
|
{
|
|
_oprint( "Local : FLAG_DEMONIAC\n" );
|
|
}
|
|
}
|
|
#endif
|
|
}
|
|
|
|
void SAvatarProperty::SetName( const char* pCreatureName )
|
|
{
|
|
m_strName = pCreatureName;
|
|
if( m_strName.empty() )
|
|
m_strName = "Unknown Name";
|
|
}
|
|
void SAvatarProperty::AddExp( __int64 nExp )
|
|
{
|
|
m_nEXP += nExp;
|
|
}
|
|
void SAvatarProperty::AddJP( __int64 nJp )
|
|
{
|
|
m_nJP += nJp;
|
|
}
|
|
|
|
void SAvatarProperty::SetInnContentID( ENC_INT nContentID )
|
|
{
|
|
static ENC_INT _autotrap( XFastRandom() );
|
|
|
|
m_nInnContentID.init( _autotrap ); // init to autotrap
|
|
m_nInnContentID.set( nContentID );
|
|
}
|
|
|
|
void SAvatarProperty::SetInnInfo( struct SGameMessage* pMsg )
|
|
{
|
|
switch( pMsg->nType )
|
|
{
|
|
case MSG_ENTER :
|
|
{
|
|
SMSG_ENTER* pEnterMsg = static_cast<SMSG_ENTER*>(pMsg);
|
|
m_InnObjType = pEnterMsg->ObjType;
|
|
|
|
switch( m_InnObjType )
|
|
{
|
|
case TS_ENTER::GAME_PLAYER:
|
|
{
|
|
SMSG_ENTER::PlayerInfo * pPlayerInfo = (SMSG_ENTER::PlayerInfo *)(pEnterMsg+1);
|
|
|
|
m_nInnRace = pPlayerInfo->race;
|
|
m_nInnSex = pPlayerInfo->sex;
|
|
m_InnfaceId = pPlayerInfo->faceId;
|
|
m_InnhairId = pPlayerInfo->hairId;
|
|
}
|
|
break;
|
|
case TS_ENTER::GAME_NPC:
|
|
{
|
|
SMSG_ENTER::NPCInfo * pNpcInfo = (SMSG_ENTER::NPCInfo *)(pEnterMsg+1);
|
|
|
|
NpcResourceBase* pNpcInfoDB = GetNpcResourceDB().GetNpcInfo( pNpcInfo->npc_id );
|
|
if( pNpcInfoDB && pNpcInfoDB->sexsual_id > 0)
|
|
{
|
|
m_nInnRace = pNpcInfoDB->race_id;
|
|
m_nInnSex = pNpcInfoDB->sexsual_id;
|
|
m_InnfaceId = pNpcInfoDB->face_id;
|
|
m_InnhairId = pNpcInfoDB->hair_id;
|
|
}
|
|
}
|
|
break;
|
|
case TS_ENTER::GAME_SUMMON:
|
|
case TS_ENTER::GAME_MOB:
|
|
case TS_ENTER::GAME_PET:
|
|
case TS_ENTER::GAME_FIELD_PROP:
|
|
case TS_ENTER::GAME_SKILL_PROP:
|
|
case TS_ENTER::GAME_ITEM:
|
|
{
|
|
m_nInnRace = 0;
|
|
m_nInnSex = 0;
|
|
m_InnfaceId = 0;
|
|
m_InnhairId = 0;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
break;
|
|
case MSG_LOGIN :
|
|
{
|
|
SMSG_LOGIN* pLoginMsg = static_cast<SMSG_LOGIN*>(pMsg);
|
|
|
|
m_InnObjType = TS_ENTER::GAME_PLAYER;
|
|
m_nInnRace = pLoginMsg->race;
|
|
m_nInnSex = pLoginMsg->sex;
|
|
m_InnfaceId = pLoginMsg->faceid;
|
|
m_InnhairId = pLoginMsg->hairid;
|
|
}
|
|
break;
|
|
}
|
|
} |