Exemple #1
0
//=========================================================
// HandleAnimEvent - catches the monster-specific messages
// that occur when tagged animation frames are played.
//
// Returns number of events handled, 0 if none.
//=========================================================
void CBarney :: HandleAnimEvent( MonsterEvent_t *pEvent )
{
	switch( pEvent->event )
	{
	case BARNEY_AE_SHOOT:
		BarneyFirePistol();
		break;

	case BARNEY_AE_DRAW:
		// barney's bodygroup switches here so he can pull gun from holster
		pev->body = m_iBaseBody + BARNEY_BODY_GUNDRAWN;
		m_fGunDrawn = TRUE;
		break;

	case BARNEY_AE_HOLSTER:
		// change bodygroup to replace gun in holster
		pev->body = m_iBaseBody + BARNEY_BODY_GUNHOLSTERED;
		m_fGunDrawn = FALSE;
		break;

	default:
		CTalkMonster::HandleAnimEvent( pEvent );
	}
}
//=========================================================
// HandleAnimEvent - catches the monster-specific messages
// that occur when tagged animation frames are played.
//
// Returns number of events handled, 0 if none.
//=========================================================
void CNPC_HL1Barney::HandleAnimEvent( animevent_t *pEvent )
{
	switch( pEvent->event )
	{
	case BARNEY_AE_SHOOT:
		BarneyFirePistol();
		break;

	case BARNEY_AE_DRAW:
		// barney's bodygroup switches here so he can pull gun from holster
		SetBodygroup( 1, BARNEY_BODY_GUNDRAWN);
		m_fGunDrawn = true;
		break;

	case BARNEY_AE_HOLSTER:
		// change bodygroup to replace gun in holster
		SetBodygroup( 1, BARNEY_BODY_GUNHOLSTERED);
		m_fGunDrawn = false;
		break;

	default:
		BaseClass::HandleAnimEvent( pEvent );
	}
}
//=========================================================
// HandleAnimEvent - catches the monster-specific messages
// that occur when tagged animation frames are played.
//
// Returns number of events handled, 0 if none.
//=========================================================
void CFriend :: HandleAnimEvent( MonsterEvent_t *pEvent )
{
	Vector	vecGunPos;
	Vector	vecGunAngles;

	GetAttachment( 0, vecGunPos, vecGunAngles );

	switch( pEvent->event )
	{
	case HGRUNT_AE_BURST1:
		BarneyFirePistol();
		break;
//sys	
	case HGRUNT_AE_BURST2:
	case HGRUNT_AE_BURST3:
		BarneyFirePistol();
		break;
/*
	case HGRUNT_AE_KICK:
	{
		CBaseEntity *pHurt = Kick();

		if ( pHurt )
		{
			// SOUND HERE!
			UTIL_MakeVectors( pev->angles );
			pHurt->pev->punchangle.x = 15;
			pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_forward * 100 + gpGlobals->v_up * 50;
			pHurt->TakeDamage( pev, pev, gSkillData.hgruntDmgKick, DMG_CLUB );
		}
	}
	break;
*/
		case HGRUNT_AE_DROP_GUN:
			{
				//SP: si tiene el flag de "no tirar arma" cerrar con break y no ejecutar
				//mas codigo
				if (pev->spawnflags & SF_MONSTER_NO_WPN_DROP) break; //LRC

				Vector	vecGunPos;
				Vector	vecGunAngles;

				GetAttachment( 0, vecGunPos, vecGunAngles );

				SetBodygroup( GUN_GROUP, GUN_NONE );

				CBaseEntity *pItem;

				// now spawn a gun.
				//if (FBitSet( pev->weapons, HGRUNT_SHOTGUN ))
				if (pev->frags)
				{
					pItem = DropItem( "weapon_shotgun", vecGunPos, vecGunAngles );
					pItem->pev->spawnflags |= SF_NORESPAWN; // No respawn
				}
				else
				{
					pItem = DropItem( "weapon_m16", vecGunPos, vecGunAngles );
					pItem->pev->spawnflags |= SF_NORESPAWN; // No respawn
				}
				
			//if -> crash, remove the following	
			//	pItem->pev->avelocity = Vector ( RANDOM_FLOAT( -222, 222 ), RANDOM_FLOAT( -222, 222 ),RANDOM_FLOAT( -222, 222 ) );
			}
		break;

	case HGRUNT_AE_RELOAD:
		EMIT_SOUND( ENT(pev), CHAN_WEAPON, "hgrunt/gr_reload1.wav", 1, ATTN_NORM );
		m_cAmmoLoaded = m_cClipSize;
		ClearConditions(bits_COND_NO_AMMO_LOADED);
				
//		DropItem( "item_clip_rifle", vecGunPos, vecGunAngles );//test
		break;

	case FBARNEY_AE_DRAW:
		if (pev->frags)//shotgun
		SetBodygroup( GUN_GROUP, GUN_SHOTGUN );
		else
		SetBodygroup( GUN_GROUP, GUN_MP5 );

		m_fGunDrawn = TRUE;
		break;
	
	case HGRUNT_AE_GREN_DROP:
		{
			UTIL_MakeVectors( pev->angles );		
		
			CGrenade::ShootTimed( pev, pev->origin + gpGlobals->v_forward * 17 - gpGlobals->v_right * 27 + gpGlobals->v_up * 6, g_vecZero, 3 );
		}
		break;
	
	case HGRUNT_AE_GREN_TOSS:
		{
			UTIL_MakeVectors( pev->angles );
			// CGrenade::ShootTimed( pev, pev->origin + gpGlobals->v_forward * 34 + Vector (0, 0, 32), m_vecTossVelocity, 3.5 );
			
			CGrenade::ShootTimed( pev, GetGunPosition(), m_vecTossVelocity, 3.5 );

			m_fThrowGrenade = FALSE;
			m_flNextGrenadeCheck = gpGlobals->time + 6;// wait six seconds before even looking again to see if a grenade can be thrown.
		}
		break;

	default:
		CTalkMonster::HandleAnimEvent( pEvent );
	}
}