873 lines
22 KiB
C++
873 lines
22 KiB
C++
#include "stdafx.h"
|
|
#include <assert.h>
|
|
#include "SSummonSlotMgr.h"
|
|
#include "SGameMessage.h"
|
|
#include "SCreatureDB.h"
|
|
#include "SStringDB.h"
|
|
#include "SInventoryMgr.h"
|
|
#include "SExpDB.h"
|
|
#include "SkillBaseFile.h"
|
|
|
|
#include "SDebug_Util.h"
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// creatureinfo
|
|
|
|
const int c_nOverLevel1 = 50;
|
|
const int c_nOverLevel2 = 100;
|
|
|
|
SCreatureInfo::SCreatureInfo()
|
|
{
|
|
m_nLevel = 0;
|
|
m_nExp = 0;
|
|
m_nHP = 0;
|
|
m_nMP = 0;
|
|
m_nMaxHP = 0;
|
|
m_nMaxMP = 0;
|
|
m_nJp = 0;
|
|
m_nSp = 0;
|
|
m_nCreatureID = 0;
|
|
m_strName.clear();
|
|
|
|
m_nCurExp = 0;
|
|
m_n64_MaxExp = 0;
|
|
m_n64_PreviosExp = 0;
|
|
|
|
ZeroMemory( m_nCreatureLevel, sizeof( m_nCreatureLevel ) );
|
|
}
|
|
void SCreatureInfo::SetCreatureInfo( struct SMSG_ADD_SUMMON_INFO* pAddSummonInfoMsg )
|
|
{
|
|
m_nLevel = pAddSummonInfoMsg->level;
|
|
m_nSp = pAddSummonInfoMsg->sp;
|
|
m_strName = pAddSummonInfoMsg->name;
|
|
m_nCreatureID = pAddSummonInfoMsg->code;
|
|
m_card_handle = pAddSummonInfoMsg->card_handle;
|
|
}
|
|
void SCreatureInfo::SetUpdateInfo( SMSG_SUMMON_EVOLUTION* pMsg )
|
|
{
|
|
m_nCreatureID = pMsg->code;
|
|
m_strName = pMsg->name;
|
|
}
|
|
|
|
void SCreatureInfo::SetEvolutionLevel( const int* pEvolLevel )
|
|
{
|
|
if( pEvolLevel )
|
|
{
|
|
for( int nCnt = 0; nCnt < MAX_CREATURE_EVOLUTION; ++nCnt )
|
|
{
|
|
//크리처 카드 일 경우
|
|
//0은 크리처 UID
|
|
//1에 기본 레벨
|
|
//2에 성장 레벨
|
|
//3에 진화 레벨
|
|
m_nCreatureLevel[nCnt] = pEvolLevel[nCnt+1];
|
|
}
|
|
}
|
|
else
|
|
assert( false && "SetUpdateInfo pEvolLevel == NULL 이면 안돼!!!" );
|
|
}
|
|
|
|
void SCreatureInfo::SetExp( __int64 nExp )
|
|
{
|
|
m_nExp = nExp;
|
|
RefreshExpInfo();
|
|
}
|
|
void SCreatureInfo::SetLevel( int nLevel )
|
|
{
|
|
m_nLevel = nLevel;
|
|
RefreshExpInfo();
|
|
}
|
|
void SCreatureInfo::RefreshExpInfo()
|
|
{
|
|
_SUMMON_INFO_FILE * pSummon = GetCreatureDB().GetCreatureData( m_nCreatureID );
|
|
if( !pSummon ) return;
|
|
|
|
// 레벨에 따른 exp 재 계산
|
|
m_n64_PreviosExp = GetSummonExpDB().GetNeedExp( m_nLevel - 1, pSummon->nForm );
|
|
m_n64_MaxExp = GetSummonExpDB().GetNeedExp( m_nLevel, pSummon->nForm ) - m_n64_PreviosExp;
|
|
|
|
if( m_nExp > 0 )
|
|
m_nCurExp = m_nExp - m_n64_PreviosExp;
|
|
else
|
|
m_nCurExp = 0; //셋팅 전임
|
|
}
|
|
|
|
//OverBreed //오버 브리드 계산
|
|
const int SCreatureInfo::GetOverBreed() const
|
|
{
|
|
//40, 50, 100 : 진화 레벨 상수
|
|
int nOverBreed = 0;
|
|
if( m_nCreatureLevel[0] > c_nOverLevel1 )
|
|
nOverBreed = m_nCreatureLevel[0] - c_nOverLevel1;
|
|
if( m_nCreatureLevel[1] > c_nOverLevel2 )
|
|
nOverBreed += m_nCreatureLevel[1] - c_nOverLevel2;
|
|
|
|
return nOverBreed;
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// creaturestat
|
|
void SCreatureStat::SetCreatureStat( const CreatureStat& stat, const CreatureAttribute& attribute )
|
|
{
|
|
::memcpy( &m_Stat, &stat, sizeof(m_Stat) );
|
|
::memcpy( &m_Attribute, &attribute, sizeof(m_Attribute) );
|
|
}
|
|
void SCreatureStat::SetCreatureStatByItem( const CreatureStat& stat, const CreatureAttribute& attribute )
|
|
{
|
|
// 빼준다
|
|
m_Stat.strength -= stat.strength ;
|
|
m_Stat.vital -= stat.vital ;
|
|
m_Stat.dexterity -= stat.dexterity ;
|
|
m_Stat.agility -= stat.agility ;
|
|
m_Stat.intelligence -= stat.intelligence;
|
|
m_Stat.mentality -= stat.mentality ;
|
|
m_Stat.luck -= stat.luck ;
|
|
|
|
m_Attribute.nCritical -= attribute.nCritical ;
|
|
m_Attribute.nCriticalPower -= attribute.nCriticalPower;
|
|
m_Attribute.nAttackPointRight -= attribute.nAttackPointRight ;
|
|
m_Attribute.nAttackPointLeft -= attribute.nAttackPointLeft ;
|
|
m_Attribute.nDefence -= attribute.nDefence ;
|
|
m_Attribute.nBlockDefence -= attribute.nBlockDefence ;
|
|
m_Attribute.nMagicPoint -= attribute.nMagicPoint ;
|
|
m_Attribute.nMagicDefence -= attribute.nMagicDefence ;
|
|
m_Attribute.nAccuracyRight -= attribute.nAccuracyRight;
|
|
m_Attribute.nAccuracyLeft -= attribute.nAccuracyLeft ;
|
|
m_Attribute.nMagicAccuracy -= attribute.nMagicAccuracy;
|
|
m_Attribute.nAvoid -= attribute.nAvoid ;
|
|
m_Attribute.nMagicAvoid -= attribute.nMagicAvoid ;
|
|
m_Attribute.nBlockChance -= attribute.nBlockChance ;
|
|
m_Attribute.nMoveSpeed -= attribute.nMoveSpeed ;
|
|
m_Attribute.nAttackSpeed -= attribute.nAttackSpeed ;
|
|
m_Attribute.nAttackRange -= attribute.nAttackRange ;
|
|
m_Attribute.nCastingSpeed -= attribute.nCastingSpeed ;
|
|
m_Attribute.nCoolTimeSpeed -= attribute.nCoolTimeSpeed;
|
|
m_Attribute.nItemChance -= attribute.nItemChance ;
|
|
m_Attribute.nHPRegenPercentage -= attribute.nHPRegenPercentage; // HP 리젠%
|
|
m_Attribute.nHPRegenPoint -= attribute.nHPRegenPoint; // HP 리젠P
|
|
m_Attribute.nMPRegenPercentage -= attribute.nMPRegenPercentage; // MP 리젠%
|
|
m_Attribute.nMPRegenPoint -= attribute.nMPRegenPoint; // MP 리젠P
|
|
/// 2011.03.30 왜 빼는 건가? - prodongi
|
|
m_Attribute.nPerfectBlock -= attribute.nPerfectBlock; // 퍼펙트블럭%
|
|
m_Attribute.nMagicalDefIgnore -= attribute.nMagicalDefIgnore; // 마법방어력무시P
|
|
m_Attribute.nMagicalDefIgnoreRatio -= attribute.nMagicalDefIgnoreRatio; // 마법방어력무시%
|
|
m_Attribute.nPhysicalDefIgnore -= attribute.nPhysicalDefIgnore; // 물리방어력무시P
|
|
m_Attribute.nPhysicalDefIgnoreRatio -= attribute.nPhysicalDefIgnoreRatio; // 물리방어력무시%
|
|
m_Attribute.nMagicalPenetration -= attribute.nMagicalPenetration; // 마법관통력P
|
|
m_Attribute.nMagicalPenetrationRatio -= attribute.nMagicalPenetrationRatio; // 마법관통력%
|
|
m_Attribute.nPhysicalPenetration -= attribute.nPhysicalPenetration; // 물리관통력P
|
|
m_Attribute.nPhysicalPenetrationRatio -= attribute.nPhysicalPenetrationRatio; // 물리관통력%
|
|
}
|
|
//////////////////////////////////////////////////////////////////////////
|
|
//SSummonSlot
|
|
SCreatureSlot::SCreatureSlot()
|
|
{
|
|
Init();
|
|
}
|
|
|
|
SCreatureSlot::~SCreatureSlot()
|
|
{
|
|
SAFE_DELETE( m_pSummonInfo );
|
|
}
|
|
|
|
void SCreatureSlot::Init()
|
|
{
|
|
m_pSummonInfo = new SMSG_ADD_SUMMON_INFO;
|
|
m_bIsExist = FALSE;
|
|
|
|
::memset( m_hItem, 0, sizeof(m_hItem) );
|
|
}
|
|
|
|
AR_HANDLE SCreatureSlot::GetCardHandle()
|
|
{
|
|
if( !IsUseSlot() )
|
|
return 0;
|
|
|
|
return m_pSummonInfo->card_handle;
|
|
}
|
|
AR_HANDLE SCreatureSlot::GetCreatureHandle()
|
|
{
|
|
if( !IsUseSlot() )
|
|
return 0;
|
|
|
|
return m_pSummonInfo->summon_handle;
|
|
}
|
|
|
|
const int SCreatureSlot::GetCreatureCode() const
|
|
{
|
|
if( !IsUseSlot() )
|
|
return 0;
|
|
|
|
return m_pSummonInfo->code;
|
|
}
|
|
|
|
const BOOL SCreatureSlot::IsUseSlot() const // 2011.03.02 servantes
|
|
{
|
|
return m_bIsExist;
|
|
}
|
|
|
|
void SCreatureSlot::SetCreature( SMSG_ADD_SUMMON_INFO* pMsg )
|
|
{
|
|
assert( !IsUseSlot() && "크리쳐 슬롯이 이미 사용 중인데!!!" );
|
|
|
|
m_bIsExist = TRUE;
|
|
|
|
m_pSummonInfo->card_handle = pMsg->card_handle;
|
|
m_pSummonInfo->summon_handle = pMsg->summon_handle; //크리쳐 핸들
|
|
|
|
m_pSummonInfo->code = pMsg->code; //크리쳐 코드
|
|
|
|
strncpy( m_pSummonInfo->name, GetStringDB().GetString( GetCreatureDB().GetTextID(m_pSummonInfo->code) ), sizeof(m_pSummonInfo->name) );
|
|
|
|
// 이하 정보 필요
|
|
m_pSummonInfo->level = pMsg->level;
|
|
m_pSummonInfo->sp = pMsg->sp;
|
|
}
|
|
|
|
// creature
|
|
void SCreatureSlot::SetCreatureInfo( struct SMSG_ADD_SUMMON_INFO* pAddSummonInfoMsg )
|
|
{
|
|
m_CreatureInfo.SetCreatureInfo( pAddSummonInfoMsg );
|
|
}
|
|
void SCreatureSlot::SetUpdateInfo( SMSG_SUMMON_EVOLUTION* pMsg )
|
|
{
|
|
m_pSummonInfo->card_handle = pMsg->card_handle;
|
|
m_pSummonInfo->code = pMsg->code;
|
|
|
|
strncpy( m_pSummonInfo->name, GetStringDB().GetString( GetCreatureDB().GetTextID(m_pSummonInfo->code) ), sizeof(m_pSummonInfo->name) );
|
|
|
|
m_CreatureInfo.SetUpdateInfo( pMsg );
|
|
}
|
|
|
|
void SCreatureSlot::SetSlotState()
|
|
{
|
|
//초기화
|
|
Init();
|
|
}
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// 인터페이스에서 사용
|
|
const int SCreatureSlot::GetCreatureItemCount() const
|
|
{
|
|
int nCount = 0;
|
|
for( int i = 0; i < MAX_CREATURE_SLOT; i++ )
|
|
{
|
|
if( m_hItem[i] != NULL )
|
|
nCount++;
|
|
}
|
|
|
|
return nCount;
|
|
}
|
|
void SCreatureSlot::SetCreatureItem( AR_HANDLE hItem, int nPos )
|
|
{
|
|
if( nPos == -1 ) // 탈착
|
|
{
|
|
for( int i = 0; i < MAX_CREATURE_SLOT; i++ )
|
|
{
|
|
if( m_hItem[i] == hItem )
|
|
{
|
|
m_hItem[i] = NULL;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else if( nPos == -2 ) // 창고
|
|
{
|
|
|
|
}
|
|
else if( GetCreatureItemCount() < MAX_CREATURE_SLOT )
|
|
{
|
|
if( nPos >= 0 && nPos < MAX_CREATURE_SLOT )
|
|
m_hItem[nPos] = hItem;
|
|
}
|
|
}
|
|
const AR_HANDLE SCreatureSlot::GetCreatureItem( int nIndex ) const
|
|
{
|
|
if( nIndex < 0 ) return NULL;
|
|
if( nIndex >= MAX_CREATURE_SLOT ) return NULL;
|
|
|
|
return m_hItem[nIndex];
|
|
}
|
|
/// 2011.05.27 - prodongi
|
|
int SCreatureSlot::getMaxMP() const
|
|
{
|
|
return m_CreatureInfo.GetMaxMP();
|
|
}
|
|
/// 2011.05.27 - prodongi
|
|
int SCreatureSlot::getMP() const
|
|
{
|
|
return m_CreatureInfo.GetMP();
|
|
}
|
|
void SCreatureSlot::SetCreatureStat( const CreatureStat& stat, const CreatureAttribute& attribute, int nType )
|
|
{
|
|
switch(nType)
|
|
{
|
|
case TS_SC_STAT_INFO::TOTAL:
|
|
m_CreatureStat.SetCreatureStat( stat, attribute );
|
|
break;
|
|
case TS_SC_STAT_INFO::BY_ITEM:
|
|
{
|
|
m_CreatureStatByItem.SetCreatureStat( stat, attribute );
|
|
m_CreatureStat.SetCreatureStatByItem( stat, attribute );
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
const SCreatureStat* SCreatureSlot::GetCreatureStat( int nType ) const
|
|
{
|
|
switch(nType)
|
|
{
|
|
case TYPE_SELF: return &m_CreatureStat;
|
|
case TYPE_ITEM: return &m_CreatureStatByItem;
|
|
}
|
|
return NULL;
|
|
}
|
|
const SCreatureInfo* SCreatureSlot::GetCreatureInfo() const
|
|
{
|
|
return &m_CreatureInfo;
|
|
}
|
|
//////////////////////////////////////////////////////////////////////////
|
|
//SSummonSlotMgr
|
|
SCreatureSlotMgr::SCreatureSlotMgr()
|
|
: SGameUIMgr() // 2011.03.29 - servantes
|
|
{
|
|
Clear();
|
|
}
|
|
|
|
SCreatureSlotMgr::~SCreatureSlotMgr()
|
|
{
|
|
Clear();
|
|
}
|
|
|
|
void SCreatureSlotMgr::Clear()
|
|
{
|
|
m_hSelCreatureCard = 0;
|
|
m_hSelCreature = 0;
|
|
m_hSelSummonCreature = 0;
|
|
m_hActiveCreatureQuickSlot = 0;
|
|
|
|
m_hCurDispSummonCreature = 0;
|
|
|
|
::memset( m_hCreatureCard, 0, sizeof(m_hCreatureCard) );
|
|
::memset( m_hSummonedCreature, 0, sizeof(m_hSummonedCreature) );
|
|
|
|
SAFE_DELETE_VECTOR( m_vecCreatureList );
|
|
}
|
|
|
|
void SCreatureSlotMgr::ResetInfo()
|
|
{
|
|
Clear();
|
|
}
|
|
|
|
void SCreatureSlotMgr::AddCreature( SMSG_ADD_SUMMON_INFO* pMsg )
|
|
{
|
|
if( GetEquipedCreatureCard(pMsg->summon_handle) )
|
|
{
|
|
std::vector< SCreatureSlot * >::iterator it = m_vecCreatureList.begin();
|
|
while( it != m_vecCreatureList.end() )
|
|
{
|
|
SCreatureSlot* pCreature = (*it);
|
|
if( pCreature->GetCreatureHandle() == pMsg->summon_handle )
|
|
{
|
|
(*it)->SetCreature( pMsg );
|
|
(*it)->SetCreatureInfo( pMsg );
|
|
}
|
|
it++;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
SCreatureSlot * pCreature = new SCreatureSlot;
|
|
pCreature->SetCreature( pMsg );
|
|
pCreature->SetCreatureInfo( pMsg );
|
|
|
|
m_vecCreatureList.push_back( pCreature );
|
|
}
|
|
}
|
|
|
|
void SCreatureSlotMgr::SetEquipCreature( struct SMSG_EQUIP_SUMMON * pMsg )
|
|
{
|
|
for( int i(0); MAX_CREATURE_SLOT>i; i++ )
|
|
m_hCreatureCard[i] = pMsg->card_handle[i];
|
|
}
|
|
|
|
void SCreatureSlotMgr::DelCreature ( AR_HANDLE card_handle )
|
|
{
|
|
for( unsigned int i(0); m_vecCreatureList.size()>i; i++ )
|
|
{
|
|
if( m_vecCreatureList[i]->GetCardHandle() == card_handle )
|
|
{
|
|
delete m_vecCreatureList[i];
|
|
m_vecCreatureList.erase( m_vecCreatureList.begin()+i );
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
void SCreatureSlotMgr::SetSelectCreatureCard( AR_HANDLE hCard )
|
|
{
|
|
m_hSelCreatureCard = hCard;
|
|
m_hSelCreature = GetEquipedCreature(hCard);
|
|
m_hSelSummonCreature = m_hSelCreature;
|
|
}
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// 인터페이스에서 사용
|
|
// get
|
|
const int SCreatureSlotMgr::GetSummonedCreatureCount() const
|
|
{
|
|
int nCount = 0;
|
|
for( int i = 0; i < MAX_SUMMON_SLOT; i++ )
|
|
{
|
|
if( m_hSummonedCreature[i] ) nCount++;
|
|
}
|
|
return nCount;
|
|
}
|
|
const AR_HANDLE SCreatureSlotMgr::GetEquipedCreatureCard( int nIndex ) const
|
|
{
|
|
if( nIndex >= MAX_CREATURE_SLOT ) return NULL;
|
|
if( nIndex < 0 ) return NULL;
|
|
|
|
return m_hCreatureCard[nIndex];
|
|
}
|
|
const AR_HANDLE SCreatureSlotMgr::GetEquipedCreatureCard( AR_HANDLE hCreature ) const
|
|
{
|
|
for( unsigned int i(0); m_vecCreatureList.size()>i; i++ )
|
|
{
|
|
if( m_vecCreatureList[i]->GetCreatureHandle() == hCreature )
|
|
{
|
|
return m_vecCreatureList[i]->GetCardHandle();
|
|
}
|
|
}
|
|
return NULL;
|
|
}
|
|
const AR_HANDLE SCreatureSlotMgr::GetEquipedCreature( int nIndex ) const
|
|
{
|
|
if( nIndex >= MAX_CREATURE_SLOT ) return NULL;
|
|
if( nIndex < 0 ) return NULL;
|
|
|
|
for( unsigned int i(0); m_vecCreatureList.size()>i; i++ )
|
|
{
|
|
if( m_vecCreatureList[i]->GetCardHandle() == m_hCreatureCard[nIndex] )
|
|
{
|
|
return m_vecCreatureList[i]->GetCreatureHandle();
|
|
}
|
|
}
|
|
return NULL;
|
|
}
|
|
const AR_HANDLE SCreatureSlotMgr::GetEquipedCreature( AR_HANDLE hCard ) const
|
|
{
|
|
if( hCard == NULL ) return NULL;
|
|
|
|
for( unsigned int i(0); m_vecCreatureList.size()>i; i++ )
|
|
{
|
|
if( m_vecCreatureList[i]->GetCardHandle() == hCard )
|
|
{
|
|
return m_vecCreatureList[i]->GetCreatureHandle();
|
|
}
|
|
}
|
|
return NULL;
|
|
}
|
|
const int SCreatureSlotMgr::GetEquipedCardIndexByCreature( AR_HANDLE hCreature ) const
|
|
{
|
|
if( hCreature == NULL ) return -1;
|
|
|
|
AR_HANDLE hCard = GetEquipedCreatureCard(hCreature);
|
|
if( hCard == NULL ) return -1;
|
|
|
|
for( int i = 0; i < MAX_CREATURE_SLOT; i++ )
|
|
{
|
|
if( m_hCreatureCard[i] == hCard )
|
|
return i;
|
|
}
|
|
|
|
return -1;
|
|
}
|
|
|
|
const AR_HANDLE SCreatureSlotMgr::GetCreatureHandleByCardHandle( AR_HANDLE hCardHandle ) const
|
|
{
|
|
if( hCardHandle == NULL )
|
|
return -1;
|
|
|
|
for( unsigned int i(0); m_vecCreatureList.size()>i; i++ )
|
|
{
|
|
if( m_vecCreatureList[i]->GetCardHandle() == hCardHandle )
|
|
{
|
|
return m_vecCreatureList[i]->GetCreatureHandle();
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
const int SCreatureSlotMgr::GetEquipedCardIndex( AR_HANDLE hCard ) const
|
|
{
|
|
if( hCard == NULL ) return -1;
|
|
|
|
for( int i = 0; i < MAX_CREATURE_SLOT; i++ )
|
|
{
|
|
if( m_hCreatureCard[i] == hCard )
|
|
return i;
|
|
}
|
|
|
|
return -1;
|
|
}
|
|
const int SCreatureSlotMgr::GetEquipedCreatureCount() const
|
|
{
|
|
int nCount = 0;
|
|
for( int i = 0; i < MAX_CREATURE_SLOT; i++ )
|
|
{
|
|
if( m_hCreatureCard[i] )
|
|
nCount++;
|
|
}
|
|
|
|
return nCount;
|
|
}
|
|
const AR_HANDLE SCreatureSlotMgr::GetCreatureItem( AR_HANDLE hCreature, int nIndex ) const
|
|
{
|
|
for( unsigned int i(0); m_vecCreatureList.size()>i; i++ )
|
|
{
|
|
if( m_vecCreatureList[i]->GetCreatureHandle() == hCreature )
|
|
return m_vecCreatureList[i]->GetCreatureItem(nIndex);
|
|
}
|
|
return NULL;
|
|
}
|
|
const int SCreatureSlotMgr::GetCreatureItemCount( AR_HANDLE hCreature ) const
|
|
{
|
|
for( unsigned int i(0); m_vecCreatureList.size()>i; i++ )
|
|
{
|
|
if( m_vecCreatureList[i]->GetCreatureHandle() == hCreature )
|
|
return m_vecCreatureList[i]->GetCreatureItemCount();
|
|
}
|
|
return NULL;
|
|
}
|
|
const SCreatureStat* SCreatureSlotMgr::GetCreatureStat( AR_HANDLE hCreature, int nType ) const
|
|
{
|
|
for( unsigned int i = 0; m_vecCreatureList.size()>i; i++ )
|
|
{
|
|
if( m_vecCreatureList[i]->GetCreatureHandle() == hCreature )
|
|
return m_vecCreatureList[i]->GetCreatureStat( nType );
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
const SCreatureInfo* SCreatureSlotMgr::GetCreatureInfo( AR_HANDLE hCreature ) const
|
|
{
|
|
for( unsigned int i = 0; m_vecCreatureList.size()>i; i++ )
|
|
{
|
|
if( m_vecCreatureList[i]->GetCreatureHandle() == hCreature )
|
|
return m_vecCreatureList[i]->GetCreatureInfo();
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
|
|
const SCreatureInfo* SCreatureSlotMgr::GetCreatureInfoByCardHandle( AR_HANDLE hCardHandle )
|
|
{
|
|
for( unsigned int i = 0; m_vecCreatureList.size()>i; i++ )
|
|
{
|
|
if( m_vecCreatureList[i]->GetCardHandle() == hCardHandle )
|
|
return m_vecCreatureList[i]->GetCreatureInfo();
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
// 2011.05.23 - servantes
|
|
const bool SCreatureSlotMgr::IsExistSummonedCreatureByCard( AR_HANDLE hCreatureCard ) const
|
|
{
|
|
if( hCreatureCard == NULL )
|
|
return false;
|
|
|
|
const AR_HANDLE hCreature = GetCreatureHandleByCardHandle(hCreatureCard);
|
|
if( hCreature == -1 )
|
|
return false;
|
|
|
|
for( int i = 0; i < MAX_SUMMON_SLOT; i++ )
|
|
{
|
|
if( m_hSummonedCreature[i] == hCreature )
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
// 조건
|
|
const bool SCreatureSlotMgr::IsExistSummonedCreature( AR_HANDLE hCreature ) const
|
|
{
|
|
if( hCreature == NULL ) return false;
|
|
|
|
for( int i = 0; i < MAX_SUMMON_SLOT; i++ )
|
|
{
|
|
if( m_hSummonedCreature[i] == hCreature )
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
const int SCreatureSlotMgr::GetSummonedCreatureCnt() const
|
|
{
|
|
int nCnt(0);
|
|
for( int i = 0; i < MAX_SUMMON_SLOT; i++ )
|
|
{
|
|
if( m_hSummonedCreature[i] )
|
|
nCnt++;
|
|
}
|
|
return nCnt;
|
|
}
|
|
const SCreatureSlot* SCreatureSlotMgr::GetCreatureSlot( AR_HANDLE hCreature ) const
|
|
{
|
|
std::vector< SCreatureSlot* >::const_iterator it = m_vecCreatureList.begin(), end = m_vecCreatureList.end();
|
|
for( ; it != end; ++it )
|
|
{
|
|
if( (*it) && (*it)->GetCreatureHandle() == hCreature )
|
|
{
|
|
return *it;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
const bool SCreatureSlotMgr::IsExistCreatureCard( AR_HANDLE hCard ) const
|
|
{
|
|
if( hCard == NULL ) return false;
|
|
|
|
for( int i = 0; i < MAX_CREATURE_SLOT; i++ )
|
|
{
|
|
if( m_hCreatureCard[i] == hCard )
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
const bool SCreatureSlotMgr::IsExistCreature( AR_HANDLE hCreature ) const
|
|
{
|
|
for( unsigned int i(0); m_vecCreatureList.size()>i; i++ )
|
|
{
|
|
if( m_vecCreatureList[i]->GetCreatureHandle() == hCreature )
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
const bool SCreatureSlotMgr::IsEquipedCreature( AR_HANDLE hCreature ) const
|
|
{
|
|
for( unsigned int i(0); m_vecCreatureList.size()>i; i++ )
|
|
{
|
|
if( m_vecCreatureList[i]->GetCreatureHandle() == hCreature )
|
|
return IsExistCreatureCard( m_vecCreatureList[i]->GetCardHandle() );
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
/// 2011.06.07 - prodongi
|
|
bool SCreatureSlotMgr::isInCreatureCard(unsigned int index) const
|
|
{
|
|
if (MAX_CREATURE_SLOT <= index)
|
|
return false;
|
|
return m_hCreatureCard[index] ? true : false;
|
|
}
|
|
|
|
// 2010.07.07 - prodongi
|
|
const bool SCreatureSlotMgr::IsEquipedCreatureCheckZeroCount( AR_HANDLE hCreature ) const
|
|
{
|
|
for( unsigned int i(0); m_vecCreatureList.size()>i; i++ )
|
|
{
|
|
if( m_vecCreatureList[i]->GetCreatureHandle() == hCreature )
|
|
{
|
|
if (GetEquipedCreatureCount() == 0)
|
|
return true;
|
|
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
|
|
void SCreatureSlotMgr::SetSelectSummonCreature( AR_HANDLE hCreature )
|
|
{
|
|
m_hSelSummonCreature = NULL;
|
|
if( !IsExistSummonedCreature(hCreature) ) return;
|
|
|
|
m_hSelSummonCreature = hCreature;
|
|
}
|
|
|
|
void SCreatureSlotMgr::AddSummonCreature( AR_HANDLE hCreature )
|
|
{
|
|
// 이미 소환되었는지 검사
|
|
if( IsExistSummonedCreature(hCreature) ) return;
|
|
|
|
AR_HANDLE hOldCreature = NULL;
|
|
hOldCreature = m_hSummonedCreature[0];
|
|
m_hSummonedCreature[0] = hCreature;
|
|
m_hSummonedCreature[1] = hOldCreature;
|
|
|
|
// 활성화 크리처로 지정
|
|
m_hSelSummonCreature = hCreature;
|
|
}
|
|
void SCreatureSlotMgr::DelSummonCreature( AR_HANDLE hCreature )
|
|
{
|
|
if( !IsExistSummonedCreature(hCreature) ) return;
|
|
|
|
if( m_hSummonedCreature[0] == hCreature )
|
|
{
|
|
m_hSummonedCreature[0] = m_hSummonedCreature[1];
|
|
m_hSummonedCreature[1] = NULL;
|
|
}
|
|
else if( m_hSummonedCreature[1] == hCreature )
|
|
m_hSummonedCreature[1] = NULL;
|
|
}
|
|
void SCreatureSlotMgr::SetCreatureItem( AR_HANDLE hCreature, AR_HANDLE hItem, int nPos )
|
|
{
|
|
for( unsigned int i(0); m_vecCreatureList.size()>i; i++ )
|
|
{
|
|
if( m_vecCreatureList[i]->GetCreatureHandle() == hCreature )
|
|
{
|
|
m_vecCreatureList[i]->SetCreatureItem( hItem, nPos );
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
void SCreatureSlotMgr::SetCreatureInfo( struct SMSG_ADD_SUMMON_INFO* pAddSummonInfoMsg )
|
|
{
|
|
for( unsigned int i = 0; m_vecCreatureList.size()>i; i++ )
|
|
{
|
|
if( m_vecCreatureList[i]->GetCreatureHandle() == pAddSummonInfoMsg->summon_handle )
|
|
{
|
|
m_vecCreatureList[i]->SetCreatureInfo( pAddSummonInfoMsg );
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
void SCreatureSlotMgr::SetUpdateInfo( SMSG_SUMMON_EVOLUTION* pMsg )
|
|
{
|
|
for( unsigned int i = 0; m_vecCreatureList.size()>i; i++ )
|
|
{
|
|
if( m_vecCreatureList[i]->GetCreatureHandle() == pMsg->summon_handle )
|
|
{
|
|
m_vecCreatureList[i]->SetUpdateInfo( pMsg );
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
void SCreatureSlotMgr::SetCreatureStat( AR_HANDLE hCreature, const CreatureStat& stat, const CreatureAttribute& attribute, int nType )
|
|
{
|
|
for( unsigned int i = 0; m_vecCreatureList.size()>i; i++ )
|
|
{
|
|
if( m_vecCreatureList[i]->GetCreatureHandle() == hCreature )
|
|
{
|
|
m_vecCreatureList[i]->SetCreatureStat( stat, attribute, nType );
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
void SCreatureSlotMgr::SetCreatureHP( AR_HANDLE hCreature, int nHP )
|
|
{
|
|
for( unsigned int i = 0; m_vecCreatureList.size()>i; i++ )
|
|
{
|
|
if( m_vecCreatureList[i]->GetCreatureHandle() == hCreature )
|
|
{
|
|
m_vecCreatureList[i]->SetCreatureHP(nHP);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
void SCreatureSlotMgr::SetCreatureMP( AR_HANDLE hCreature, int nMP )
|
|
{
|
|
for( unsigned int i = 0; m_vecCreatureList.size()>i; i++ )
|
|
{
|
|
if( m_vecCreatureList[i]->GetCreatureHandle() == hCreature )
|
|
{
|
|
m_vecCreatureList[i]->SetCreatureMP(nMP);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
void SCreatureSlotMgr::SetCreatureMaxHP( AR_HANDLE hCreature, int nMaxHP )
|
|
{
|
|
for( unsigned int i = 0; m_vecCreatureList.size()>i; i++ )
|
|
{
|
|
if( m_vecCreatureList[i]->GetCreatureHandle() == hCreature )
|
|
{
|
|
m_vecCreatureList[i]->SetCreatureMaxHP( nMaxHP );
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
void SCreatureSlotMgr::SetCreatureMaxMP( AR_HANDLE hCreature, int nMaxMP )
|
|
{
|
|
for( unsigned int i = 0; m_vecCreatureList.size()>i; i++ )
|
|
{
|
|
if( m_vecCreatureList[i]->GetCreatureHandle() == hCreature )
|
|
{
|
|
m_vecCreatureList[i]->SetCreatureMaxMP( nMaxMP );
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
void SCreatureSlotMgr::SetCreatureLevel( AR_HANDLE hCreature, int nLevel )
|
|
{
|
|
for( unsigned int i = 0; m_vecCreatureList.size()>i; i++ )
|
|
{
|
|
if( m_vecCreatureList[i]->GetCreatureHandle() == hCreature )
|
|
{
|
|
m_vecCreatureList[i]->SetCreatureLevel(nLevel);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
void SCreatureSlotMgr::SetCreatureEvolutionLevel( AR_HANDLE hCardHandle, const int* pEvolLevel )
|
|
{
|
|
for( unsigned int i = 0; m_vecCreatureList.size()>i; i++ )
|
|
{
|
|
if( m_vecCreatureList[i]->GetCardHandle() == hCardHandle )
|
|
{
|
|
m_vecCreatureList[i]->SetEvolutionLevel(pEvolLevel);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
void SCreatureSlotMgr::SetCreatureExp( AR_HANDLE hCreature, __int64 nExp )
|
|
{
|
|
for( unsigned int i = 0; m_vecCreatureList.size()>i; i++ )
|
|
{
|
|
if( m_vecCreatureList[i]->GetCreatureHandle() == hCreature )
|
|
{
|
|
m_vecCreatureList[i]->SetCreatureExp( nExp );
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
/// 2011.04.29 int->__int64 - prodongi
|
|
void SCreatureSlotMgr::SetCreatureJP( AR_HANDLE hCreature, __int64 nJP )
|
|
{
|
|
for( unsigned int i = 0; m_vecCreatureList.size()>i; i++ )
|
|
{
|
|
if( m_vecCreatureList[i]->GetCreatureHandle() == hCreature )
|
|
{
|
|
m_vecCreatureList[i]->SetCreatureJP( nJP );
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
void SCreatureSlotMgr::SetCreatureSP( AR_HANDLE hCreature, int nSP )
|
|
{
|
|
for( unsigned int i = 0; m_vecCreatureList.size()>i; i++ )
|
|
{
|
|
if( m_vecCreatureList[i]->GetCreatureHandle() == hCreature )
|
|
{
|
|
m_vecCreatureList[i]->SetCreatureSP( nSP );
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
void SCreatureSlotMgr::SetCreatureName( AR_HANDLE hCreature, const char* szName )
|
|
{
|
|
for( unsigned int i = 0; m_vecCreatureList.size()>i; i++ )
|
|
{
|
|
if( m_vecCreatureList[i]->GetCreatureHandle() == hCreature )
|
|
{
|
|
m_vecCreatureList[i]->SetCreatureName(szName);
|
|
return;
|
|
}
|
|
}
|
|
}
|