示例#1
0
文件: Quiz.cpp 项目: iceberry/flyffsf
void CQuiz::SetNPC()
{
	CMover* pMover	= (CMover*)CreateObj( D3DDEVICE, OT_MOVER, m_sNPC.dwNPCId );
	if( !pMover )
	{
		Error( "CQuiz::SetNPC() - pMover is NULL - %d, %s", m_sNPC.dwNPCId, m_sNPC.strCharKey.c_str() );
		return;
	}
	lstrcpy( pMover->m_szCharacterKey, m_sNPC.strCharKey.c_str() );
	pMover->InitNPCProperty();
	pMover->InitCharacter( pMover->GetCharacter() );
	pMover->SetPos( m_sNPC.vPos );
	pMover->InitMotion( MTI_STAND );
	pMover->UpdateLocalMatrix();
	pMover->AddItToGlobalId();
	m_sNPC.idNpc = pMover->GetId();
	CWorld* pWorld	= g_WorldMng.GetWorld( WI_WORLD_MADRIGAL );
	if( pWorld )
		pWorld->ADDOBJ( pMover, FALSE, nDefaultLayer );
}
示例#2
0
void CCreateMonster::CreateMonster( CUser* pUser, DWORD dwObjId, D3DXVECTOR3 vPos )
{
	if( (int)( m_mapCreateMonsterInfo.size() ) >= m_nMaxCreateNum )
	{
		pUser->AddDefinedText( TID_GAME_CREATEMON_LIMIT );
		return;
	}
	
	CItemElem* pItemElem = pUser->m_Inventory.GetAtId( dwObjId );
	if( !IsUsableItem( pItemElem ) )
		return;

	CREATE_MONSTER_PROP* pCreateMonsterProp = GetCreateMonsterProp( pItemElem );
	if( !pCreateMonsterProp )
		return;

	DWORD dwMonsterId = pCreateMonsterProp->GetRandomMonsterId();
	if( dwMonsterId == NULL_ID )
		return;

	CWorld* pWorld = pUser->GetWorld();
	MoverProp* pMoverProp = prj.GetMoverProp( dwMonsterId );

	if( pWorld && pMoverProp && pMoverProp->dwID != 0 )
	{
		D3DXVECTOR3 vDist2 = pUser->GetPos() - vPos;
		float fDist = D3DXVec3Length( &vDist2 );			// 두좌표간의 거리
		if( 15.f < fDist )
		{
			pUser->AddDefinedText( TID_GAME_CREATEMON_F_15 );
			return;
		}

		int nAttr = pWorld->GetHeightAttribute( vPos.x, vPos.z );		// 이동할 위치의 속성 읽음.
		if( nAttr == HATTR_NOWALK || nAttr == HATTR_NOMOVE )		// 못 움직이는 곳이면 Pass
		{
			pUser->AddDefinedText( TID_GAME_CREATEMON_F_AREA );
			return;
		}
		if( pUser->IsRegionAttr( RA_SAFETY ))		// 안전지역이면 Pass
		{
			pUser->AddDefinedText( TID_GAME_CREATEMON_F_AREA );
			return;
		}
		if( pWorld->GetID() != WI_WORLD_MADRIGAL )
		{
			pUser->AddDefinedText( TID_GAME_CREATEMON_F_AREA );
			return;
		}

		CObj* pObj	= CreateObj( D3DDEVICE, OT_MOVER, pMoverProp->dwID );
		if( NULL == pObj )	return;	// ASSERT( pObj );
		pObj->SetPos( vPos );
		pObj->InitMotion( MTI_STAND );
		pObj->UpdateLocalMatrix();
		((CMover*)pObj)->m_bActiveAttack = FALSE;
		((CMover*)pObj)->AddItToGlobalId();
		pWorld->ADDOBJ( pObj, FALSE, pUser->GetLayer() );
		
		LogItemInfo aLogItem;
		aLogItem.Action = "i";
		aLogItem.SendName = pUser->GetName();
		char szTemp[128] = {0,};
		sprintf( szTemp, "M_C_%s", pMoverProp->szName ); 
		memset( szTemp+31, 0, sizeof(szTemp)-31 );

		aLogItem.RecvName = szTemp;
		aLogItem.Gold = aLogItem.Gold2 = pUser->GetGold();
		aLogItem.Gold_1 = ((CMover*)pObj)->GetId();
		aLogItem.WorldId = pUser->GetWorld()->GetID();
		g_DPSrvr.OnLogItem( aLogItem, pItemElem, 1 );

		pUser->AddDefinedText( TID_GAME_CREATEMON_S, "\"%s\"", pMoverProp->szName );
		pUser->RemoveItem( (BYTE)( dwObjId ), (short)( 1 ) );
		
		CREATE_MONSTER_INFO createMonsterInfo;
		createMonsterInfo.chState = 'N';
		createMonsterInfo.dwOwnerId = pUser->m_idPlayer;
		createMonsterInfo.dwEndTick = pCreateMonsterProp->dwKeepTime + GetTickCount();
		m_mapCreateMonsterInfo.insert( make_pair( ((CMover*)pObj)->GetId(), createMonsterInfo ) );
	}
}