Esempio n. 1
0
AI_Helicopter::~AI_Helicopter()
{
	FREE_HSTRING(m_hstrDeathMessage);
	FREE_HSTRING(m_hstrDeath0_3rdMessage);
	FREE_HSTRING(m_hstrDeath1_3rdMessage);
	FREE_HSTRING(m_hstrDeath2_3rdMessage);

	if ( m_pHelicopterState )
	{
		FACTORY_DELETE(m_pHelicopterState);
        m_pHelicopterState = LTNULL;
        m_pVehicleState = LTNULL;
        m_pState = LTNULL;
	}

	if ( -1 != m_iObjectGunner && m_apObjects[m_iObjectGunner] )
	{
		HOBJECT hGunner = m_apObjects[m_iObjectGunner]->m_hObject;
		if ( hGunner )
		{
			CCharacter* pGunner = (CCharacter*)g_pLTServer->HandleToObject(hGunner);
			if ( pGunner )
			{
				Unlink(hGunner);
				pGunner->RemoveObject();
			}
		}
	}
}
Esempio n. 2
0
void CAISharkStrategyFollowPath::Destructor()
{
	FACTORY_DELETE(m_pPath);
	m_AIMovement.Destructor();

	super::Destructor();
}
void CAISenseRecorder::Update()
{
	// TODO: Optimize this so we don't do it every frame.

    LTFLOAT fTime = g_pLTServer->GetTime();

	for ( int iSense = 0 ; iSense < CAISense::kNumSenses ; iSense++ )
	{
		CAISenseRecord** ppRecord = m_alstpSenseRecords[iSense].GetItem(TLIT_FIRST);
		while ( ppRecord && *ppRecord )
		{
			if ( !(*ppRecord)->UpdateLifetime(fTime) )
			{
				Unlink((*ppRecord)->GetObject());
				FACTORY_DELETE((*ppRecord));
				m_alstpSenseRecords[iSense].Remove((*ppRecord));
				ppRecord = m_alstpSenseRecords[iSense].GetItem(TLIT_CURRENT);
			}
			else
			{
				ppRecord = m_alstpSenseRecords[iSense].GetItem(TLIT_NEXT);
			}
		}
	}
}
Esempio n. 4
0
void CAIHelicopterStrategyFollowPath::Destructor()
{
	FACTORY_DELETE(m_pPath);
	m_AIMovement.Destructor();

	CAIHelicopterStrategy::Destructor();
}
Esempio n. 5
0
CAIAnimal::~CAIAnimal()
{
	if ( m_pAnimalState )
	{
		FACTORY_DELETE(m_pAnimalState);
        m_pAnimalState = LTNULL;
        m_pState = LTNULL;
	}
}
void CAISenseRecorder::Destructor()
{
	for ( int iSense = 0 ; iSense < CAISense::kNumSenses ; iSense++ )
	{
		CAISenseRecord** ppRecord = m_alstpSenseRecords[iSense].GetItem(TLIT_FIRST);
		while ( ppRecord && *ppRecord )
		{
			Unlink((*ppRecord)->GetObject());
			FACTORY_DELETE((*ppRecord));
			ppRecord = m_alstpSenseRecords[iSense].GetItem(TLIT_NEXT);
		}
	}
}
Esempio n. 7
0
	void FSM::LeaveCurrentBehaviour(FSMBehaviour* pNextBehaviour)
	{
		if(m_pCurBehaviour)
		{
			m_pCurBehaviour->Leave(pNextBehaviour);
		}

		if(m_pPrevBehaviour)
		{
			FACTORY_DELETE(m_pPrevBehaviour);
		}
		m_pPrevBehaviour = m_pCurBehaviour;
		m_pCurBehaviour = NULL;
	}
Esempio n. 8
0
void AI_Helicopter::SetState(CAIHelicopterState::AIHelicopterStateType eState)
{
	// Delete the old state

	if ( m_pHelicopterState )
	{
		FACTORY_DELETE(m_pHelicopterState);
        m_pHelicopterState = LTNULL;
        m_pVehicleState = LTNULL;
        m_pState = LTNULL;
	}

	switch ( eState )
	{
		case CAIHelicopterState::eStateIdle:		m_pHelicopterState = FACTORY_NEW(CAIHelicopterStateIdle);		break;
		case CAIHelicopterState::eStateGoto:		m_pHelicopterState = FACTORY_NEW(CAIHelicopterStateGoto);		break;
		case CAIHelicopterState::eStateAttack:		m_pHelicopterState = FACTORY_NEW(CAIHelicopterStateAttack);		break;
	}

	m_pVehicleState = m_pHelicopterState;
	m_pState = m_pVehicleState;

	if ( !m_pHelicopterState )
	{
		_ASSERT(LTFALSE);
		return;
	}

	// Init the state

	if ( !m_pHelicopterState->Init(this) )
	{
		_ASSERT(LTFALSE);
		FACTORY_DELETE(m_pHelicopterState);
        m_pHelicopterState = LTNULL;
	}
}
Esempio n. 9
0
	void FSM::EnterDefaultBehaviour()
	{
		FSMParam* pParam = FSMMgr.MakeParam(Behaviour_Idle);
		if(!pParam)
		{
			return;
		}
		FSMBehaviour* pBehaviour = FSMMgr.MakeBehaviour(Behaviour_Idle, State_Idle);
		if(!pBehaviour)
		{
			return;
		}
		pBehaviour->SetOwner(m_pOwner);
		if(!pBehaviour->InitialBehaviour(pParam))
		{
			return;
		}
		ChangeBehaviour(pBehaviour,pParam,true);
		FACTORY_DELETE(pParam);
	}
void CAISenseRecorder::HandleBrokenLink(HOBJECT hObject)
{
	for ( int iSense = 0 ; iSense < CAISense::kNumSenses ; iSense++ )
	{
		CAISenseRecord** ppRecord = m_alstpSenseRecords[iSense].GetItem(TLIT_FIRST);
		while ( ppRecord && *ppRecord )
		{
			if ( (*ppRecord)->GetObject() == hObject )
			{
				FACTORY_DELETE((*ppRecord));
				m_alstpSenseRecords[iSense].Remove((*ppRecord));
				ppRecord = m_alstpSenseRecords[iSense].GetItem(TLIT_CURRENT);
			}
			else
			{
				ppRecord = m_alstpSenseRecords[iSense].GetItem(TLIT_NEXT);
			}
		}
	}
}
void Body::SetState(BodyState eBodyState, LTBOOL bLoad /* = LTFALSE */)
{
	m_eBodyStatePrevious = m_eBodyState;
	m_eBodyState = eBodyState;

	if ( m_pState )
	{
		FACTORY_DELETE(m_pState);
        m_pState = LTNULL;
	}

	switch ( m_eBodyState )
	{
		case eBodyStateNormal:
			m_pState = FACTORY_NEW(CBodyStateNormal);
			break;

		case eBodyStateExplode:
			m_pState = FACTORY_NEW(CBodyStateExplode);
			break;

		case eBodyStateCrush:
			m_pState = FACTORY_NEW(CBodyStateCrush);
			break;

		case eBodyStateLaser:
			m_pState = FACTORY_NEW(CBodyStateLaser);
			break;

		case eBodyStateDecay:
			m_pState = FACTORY_NEW(CBodyStateDecay);
			break;

		case eBodyStateStairs:
			m_pState = FACTORY_NEW(CBodyStateStairs);
			break;

		case eBodyStateLedge:
			m_pState = FACTORY_NEW(CBodyStateLedge);
			break;

		case eBodyStateUnderwater:
			m_pState = FACTORY_NEW(CBodyStateUnderwater);
			break;

		case eBodyStateChair:
			m_pState = FACTORY_NEW(CBodyStateChair);
			break;

		case eBodyStatePoison:
			m_pState = FACTORY_NEW(CBodyStatePoison);
			break;

		case eBodyStateAcid:
			m_pState = FACTORY_NEW(CBodyStateAcid);
			break;

		case eBodyStateArrow:
			m_pState = FACTORY_NEW(CBodyStateArrow);
			break;

		case eBodyStateFade:
			m_pState = FACTORY_NEW(CBodyStateFade);
			break;

		case eBodyStateFly:
		case eBodyStateStuck:
		default:
            m_pState = LTNULL;
			break;
	}

	if ( m_pState )
	{
		if ( !bLoad )
		{
			m_pState->Init(this);
		}
		else
		{
			m_pState->InitLoad(this);
		}
	}
}
Esempio n. 12
0
void CAIHelicopterStateAttack::Destructor()
{
	FACTORY_DELETE(m_pStrategyShoot);

	CAIHelicopterState::Destructor();
}
Esempio n. 13
0
void CAIHelicopterStateGoto::Destructor()
{
	FACTORY_DELETE(m_pStrategyFollowPath);

	CAIHelicopterState::Destructor();
}