317 lines
7.6 KiB
C++
317 lines
7.6 KiB
C++
#include "stdafx.h"
|
|
#include "SGameItem.h"
|
|
#include "KSeqModel.h"
|
|
#include "SkillBaseFile.h"
|
|
#include "SItemDB.h"
|
|
#include "SAvatarProperty.h"
|
|
#include "SGameMessage.h"
|
|
#include "KViewport.h"
|
|
|
|
#include "SDebug_Util.h"
|
|
|
|
SGameItem::SGameItem( ENC_INT nID ) : SGameAvatarEx( nID )
|
|
{
|
|
m_bTryHeight = false;
|
|
m_pItemModel = NULL;
|
|
m_bIsActivated = false;
|
|
K3DMatrixIdentity( m_RotMat );
|
|
}
|
|
|
|
SGameItem::~SGameItem()
|
|
{
|
|
Destroy();
|
|
}
|
|
|
|
bool SGameItem::Initialize( class K3DRenderDeviceDX *pDevice )
|
|
{
|
|
m_pItemModel = new KSeqModel;
|
|
m_pItemEffect = new KSeqModel;
|
|
|
|
KSeqObject * pSeq = NULL;
|
|
|
|
std::string strItem;
|
|
if( m_pProperty->ContentID() != 0 )
|
|
{
|
|
strItem = GetItemDB().GetDropFileName( m_pProperty->ContentID() );
|
|
strItem += ".nx3";
|
|
}
|
|
else if( m_pProperty->ContentID() == 0 )
|
|
{
|
|
strItem = "drop_etc_money.nx3";
|
|
}
|
|
|
|
// _oprint( "SGameItem Load : %s\n", strItem.c_str() );
|
|
|
|
NX3LoadPack loadpack;
|
|
loadpack.Init();
|
|
|
|
m_pItemModel->AddAnimation( "default", strItem.c_str(), KNX3Manager::SEQTYPE_ALL, &loadpack );
|
|
m_pItemEffect->AddAnimation( "default", "drop_itemeffect.nx3", KNX3Manager::SEQTYPE_ALL, &loadpack );
|
|
|
|
m_pItemModel->SetParentTransform( GetTransform() );
|
|
m_pItemEffect->SetParentTransform( GetTransform() );
|
|
|
|
m_bIsInit = true;
|
|
|
|
return true;
|
|
}
|
|
|
|
void SGameItem::Destroy()
|
|
{
|
|
SAFE_DELETE( m_pItemModel );
|
|
SAFE_DELETE( m_pItemEffect );
|
|
}
|
|
|
|
void SGameItem::SetPickUpOrder( SMSG_ENTER* pMsg )
|
|
{
|
|
SMSG_ENTER::ItemInfo * pItemInfo = (SMSG_ENTER::ItemInfo*)(pMsg+1);
|
|
|
|
m_arDropTime = pItemInfo->pick_up_order.drop_time;
|
|
|
|
for( int i(0); 3>i; i++ )
|
|
{
|
|
m_hPlayer[ i ] = pItemInfo->pick_up_order.hPlayer[ i ];
|
|
m_nPartyID[ i ] = pItemInfo->pick_up_order.nPartyID[ i ];
|
|
}
|
|
|
|
//Order 있는 아이템인지 판별한다.
|
|
if( m_hPlayer[0] == 0 && m_nPartyID[0] == 0 )
|
|
m_nOrderStep = _NONE_STEP;
|
|
else
|
|
m_nOrderStep = _01_STEP;
|
|
}
|
|
|
|
bool SGameItem::IsPickable( AR_HANDLE hPlayer, int nPartyID ) // #2.1.2.4.2
|
|
{
|
|
if( m_nOrderStep == _NONE_STEP )
|
|
return true;
|
|
|
|
for( int i = 0; i < m_nOrderStep; ++i )
|
|
if( hPlayer == m_hPlayer[ i ] || nPartyID == m_nPartyID[ i ] )
|
|
return true;
|
|
|
|
return false;
|
|
}
|
|
|
|
bool SGameItem::Activate()
|
|
{
|
|
SGameAvatarEx::Activate();
|
|
|
|
return true;
|
|
}
|
|
|
|
void SGameItem::DropSound()
|
|
{
|
|
if( m_pProperty->ContentID() != 0 )
|
|
{
|
|
const ItemBaseEx_info * iteminfo = GetItemDB().GetItemData( m_pProperty->ContentID() );
|
|
if( iteminfo->nOptType[0] == 1 || iteminfo->nOptType[0] == 2 )
|
|
{
|
|
//나는 포션류~
|
|
StartSound( "item_drop_potion.wav" , *GetPosition() );
|
|
return;
|
|
}
|
|
|
|
if( iteminfo->nClass == ItemBase::CLASS_ETC )
|
|
{
|
|
//기타
|
|
StartSound( "item_drop_etc.wav" , *GetPosition() );
|
|
}
|
|
else if( iteminfo->nGroup <= ItemBase::CLASS_TWOHAND_STAFF )
|
|
{
|
|
//무기류
|
|
StartSound( "item_drop_weapon.wav" , *GetPosition() );
|
|
}
|
|
else if( iteminfo->nClass == ItemBase::CLASS_FIGHTER_ARMOR )
|
|
{
|
|
// 전사용 방어구류
|
|
StartSound( "item_drop_heave_equip.wav" , *GetPosition() );
|
|
}
|
|
else if( iteminfo->nGroup <= ItemBase::CLASS_SUMMONER_ARMOR )
|
|
{
|
|
// 전사용 제외 방어구류
|
|
StartSound( "item_drop_light_equip.wav" , *GetPosition() );
|
|
}
|
|
else if( iteminfo->nGroup <= ItemBase::CLASS_MASK )
|
|
{
|
|
// 악세서리
|
|
StartSound( "item_drop_accessary.wav" , *GetPosition() );
|
|
}
|
|
else if( iteminfo->nClass == ItemBase::CLASS_CUBE )
|
|
{
|
|
// 큐
|
|
StartSound( "item_drop_cube.wav" , *GetPosition() );
|
|
}
|
|
else if( iteminfo->nClass == ItemBase::CLASS_SOULSTONE )
|
|
{
|
|
// 소울스톤
|
|
StartSound( "soulstonedrop.wav" , *GetPosition() );
|
|
}
|
|
else
|
|
{
|
|
//기타
|
|
StartSound( "item_drop_etc.wav" , *GetPosition() );
|
|
}
|
|
}
|
|
else
|
|
{ //돈이다
|
|
StartSound( "item_drop_rupi.wav" , *GetPosition() );
|
|
}
|
|
}
|
|
|
|
bool SGameItem::Deactivate()
|
|
{
|
|
m_bIsActivated = false;
|
|
return true;
|
|
}
|
|
|
|
void SGameItem::PlayAnimation( DWORD time, int nAniType, float fPlayRate )
|
|
{
|
|
if( m_pItemModel )
|
|
{
|
|
m_pItemModel->PlayAnimation( time, "default", nAniType, fPlayRate );
|
|
if( m_pItemEffect )
|
|
m_pItemEffect->PlayAnimation( time, "default", nAniType, fPlayRate );
|
|
}
|
|
}
|
|
|
|
const K3DVertex * SGameItem::GetCube()
|
|
{
|
|
if( m_pItemModel )
|
|
return m_pItemModel->GetBoundCube()->GetVertices();
|
|
|
|
return NULL;
|
|
}
|
|
|
|
bool SGameItem::CheckCollision( const K3DVector &nv, const K3DVector &fv )
|
|
{
|
|
if( !m_bIsActivated ) return false;
|
|
if( !m_xRenderFlag.IsOn( AV_BASIC ) ) return false;
|
|
|
|
if( m_pItemModel )
|
|
{
|
|
return m_pItemModel->GetBoundCube()->CheckCollision( nv, fv );
|
|
|
|
//K3DBoundSphere sphere;
|
|
//sphere.SetRadius( 10.f );
|
|
//sphere.SetPosition( *K3DMatrixGetPosVector( *GetTransform()) );
|
|
//return sphere.CheckCollision( nv, fv );
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
void SGameItem::ClipTest( K3DVector * pFrustum )
|
|
{
|
|
if( m_pItemModel )
|
|
{
|
|
m_pItemModel->ClipTest( pFrustum );
|
|
if( !m_pItemModel->GetIsClip() )
|
|
m_xRenderFlag.On( AV_BASIC );
|
|
else
|
|
m_xRenderFlag.Off( AV_BASIC );
|
|
}
|
|
}
|
|
|
|
bool SGameItem::Render( unsigned long uRenderBitVector, KViewportObject** ppViewportList, int nViewportCount )
|
|
{
|
|
if( !m_bIsActivated ) return false;
|
|
|
|
if( m_bTryHeight ) return false;
|
|
|
|
if( !m_xRenderFlag.IsOn( AV_BASIC ) ) return false;
|
|
|
|
if( m_pItemModel )
|
|
{
|
|
for(int i = 0; i < nViewportCount; ++i)
|
|
{
|
|
if(ppViewportList[i]->GetAttributes() & KViewportObject::VIEWPORT_GAME)
|
|
{
|
|
m_pItemModel->Render( ppViewportList[i] );
|
|
m_pItemEffect->Render( ppViewportList[i] );
|
|
|
|
// m_pItemModel->GetBoundCube()->Render( ppViewportList[i] );
|
|
}
|
|
else if(ppViewportList[i]->GetAttributes() & KViewportObject::VIEWPORT_SHADOW)
|
|
{
|
|
m_pItemModel->Render( ppViewportList[i]/*, KRenderObject::RENDEREFX_SHADOW*/ );
|
|
}
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
bool SGameItem::Process( DWORD time, unsigned long uProcessBitVector )
|
|
{
|
|
if( !m_bIsActivated ) return false;
|
|
|
|
if( m_bTryHeight )
|
|
{
|
|
K3DVector pos = *GetPosition();
|
|
if( GetHeight( pos.x, pos.y, pos.z, m_wCurTile ) )
|
|
{
|
|
SetArObjectPos( pos.x, pos.y, pos.z, GetArObject().layer );
|
|
SetPosition( pos );
|
|
m_bTryHeight = false;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
if( m_pItemModel )
|
|
{
|
|
K3DMatrix mat;
|
|
K3DMatrixRotationZ( m_RotMat, cos(time/1000.f) );
|
|
mat = m_RotMat;
|
|
mat._41 = GetTransform()->_41;
|
|
mat._42 = GetTransform()->_42;
|
|
mat._43 = GetTransform()->_43;
|
|
SetTransform( mat );
|
|
|
|
// m_pItemModel->SetTransform( mat );
|
|
m_pItemModel->Process( time );
|
|
|
|
// m_pItemEffect->SetTransform( mat );
|
|
m_pItemEffect->Process( time );
|
|
}
|
|
|
|
AR_TIME curArTime = GetArTime();
|
|
|
|
//먹자 방지 처리
|
|
if( m_nOrderStep != _NONE_STEP )
|
|
{
|
|
if( curArTime - m_arDropTime <= 3000 )
|
|
{
|
|
//pickup_order.hPlayer[0] 가 0이 아닐 경우, hPlayer[0]인 사용자만 집을 수 있습니다.
|
|
//pickup_order.hPlayer[0] 가 0이고, pickup_order.nPartyID[0] > 0 일 경우, pickup_order.nPartyID[0]인 파티 소속원만 집을 수 있습니다.
|
|
if( m_nOrderStep != _01_STEP )
|
|
m_nOrderStep = _01_STEP;
|
|
}
|
|
else if( curArTime - m_arDropTime > 3000 && curArTime - m_arDropTime <= 4000 )
|
|
{
|
|
//pickup_order.hPlayer[1] 가 0이 아닐 경우, hPlayer[1]인 사용자만 집을 수 있습니다.
|
|
//pickup_order.hPlayer[1] 가 0이고, pickup_order.nPartyID[1] > 0 일 경우, pickup_order.nPartyID[1]인 파티 소속원만 집을 수 있습니다.
|
|
|
|
if( m_nOrderStep != _02_STEP )
|
|
m_nOrderStep = _02_STEP;
|
|
}
|
|
else if( curArTime - m_arDropTime > 4000 && curArTime - m_arDropTime <= 5000 )
|
|
{
|
|
//pickup_order.hPlayer[2] 가 0이 아닐 경우, hPlayer[2]인 사용자만 집을 수 있습니다.
|
|
//pickup_order.hPlayer[2] 가 0이고, pickup_order.nPartyID[2] > 0 일 경우, pickup_order.nPartyID[2]인 파티 소속원만 집을 수 있습니다.
|
|
if( m_nOrderStep != _03_STEP )
|
|
m_nOrderStep = _03_STEP;
|
|
}
|
|
else
|
|
{ //아무나 가능
|
|
if( m_nOrderStep != _NONE_STEP )
|
|
m_nOrderStep = _NONE_STEP;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|