コード例 #1
0
ファイル: HitMarker.cpp プロジェクト: AntonioModer/xray-16
void CHitMarker::Update_GrenadeView( Fvector& pos_actor )
{
	GRENADEMARKS::iterator	it_b = m_GrenadeMarks.begin();
	GRENADEMARKS::iterator	it_e = m_GrenadeMarks.end();

	for ( ; it_b != it_e; ++it_b )
	{
		if ( (*it_b)->removed_grenade ) continue;

		CGrenade* grn = (*it_b)->p_grenade;
		if( grn->IsExploding() )
		{
			(*it_b)->removed_grenade = true;
			continue;
		}

		Fvector pos_grn, dir;
		grn->Center( pos_grn );
		
		dir.sub( pos_grn, pos_actor );
		//dir.sub( pos_actor, pos_grn );
		dir.normalize();

		(*it_b)->Update( dir.getH() );
	}

}
コード例 #2
0
void CHostageImprov::UpdateGrenadeReactions()
{
	if (m_coughTimer.IsElapsed())
	{
		if (TheBots->IsInsideSmokeCloud(&GetCentroid()))
		{
			m_coughTimer.Start(RANDOM_FLOAT(1, 3));
			Chatter(HOSTAGE_CHATTER_COUGH);
			Frighten(SCARED);
		}
	}

	if (m_grenadeTimer.IsElapsed())
	{
		CBaseEntity *entity = NULL;
		const float watchGrenadeRadius = 500.0f;

		m_grenadeTimer.Start(RANDOM_FLOAT(0.4f, 0.6f));

		while ((entity = UTIL_FindEntityInSphere(entity, GetCentroid(), watchGrenadeRadius)) != NULL)
		{
			CGrenade *grenade = static_cast<CGrenade *>(entity);

			if (!FClassnameIs(grenade->pev, "grenade") || grenade->m_SGSmoke > 1)
				continue;

			if (IsVisible(grenade->Center()))
			{
				Chatter(HOSTAGE_CHATTER_SAW_HE_GRENADE);

				if (grenade->pev->dmg > 50.0f)
				{
					m_idleState.OnInjury();
					Frighten(TERRIFIED);
				}
				else
					Frighten(SCARED);

				m_grenadeTimer.Start(10);
				break;
			}
		}
	}
}