//========================================================= // HandleAnimEvent - catches the monster-specific messages // that occur when tagged animation frames are played. //========================================================= void CIchthyosaur :: HandleAnimEvent( MonsterEvent_t *pEvent ) { int bDidAttack = FALSE; switch( pEvent->event ) { case ICHTHYOSAUR_AE_SHAKE_RIGHT: case ICHTHYOSAUR_AE_SHAKE_LEFT: { if (m_hEnemy != NULL && FVisible( m_hEnemy )) { CBaseEntity *pHurt = m_hEnemy; if (m_flEnemyTouched < gpGlobals->time - 0.2 && (m_hEnemy->BodyTarget( pev->origin ) - pev->origin).Length() > (32+16+32)) break; Vector vecShootDir = ShootAtEnemy( pev->origin ); UTIL_MakeAimVectors ( pev->angles ); if (DotProduct( vecShootDir, gpGlobals->v_forward ) > 0.707) { m_bOnAttack = TRUE; pHurt->pev->punchangle.z = -18; pHurt->pev->punchangle.x = 5; pHurt->pev->velocity = pHurt->pev->velocity - gpGlobals->v_right * 300; if (pHurt->IsPlayer()) { pHurt->pev->angles.x += RANDOM_FLOAT( -35, 35 ); pHurt->pev->angles.y += RANDOM_FLOAT( -90, 90 ); pHurt->pev->angles.z = 0; pHurt->pev->fixangle = TRUE; } pHurt->TakeDamage( pev, pev, gSkillData.ichthyosaurDmgShake, DMG_SLASH ); } } BiteSound(); bDidAttack = TRUE; } break; default: CFlyingMonster::HandleAnimEvent( pEvent ); break; } if (bDidAttack) { Vector vecSrc = pev->origin + gpGlobals->v_forward * 32; UTIL_Bubbles( vecSrc - Vector( 8, 8, 8 ), vecSrc + Vector( 8, 8, 8 ), 16 ); } }
//----------------------------------------------------------------------------- // Purpose: LeapTouch - this is the headcrab's touch function when it is in the air. // Input : *pOther - //----------------------------------------------------------------------------- void CNPC_Headcrab::LeapTouch( CBaseEntity *pOther ) { if ( pOther->Classify() == Classify() ) { return; } // Don't hit if back on ground if ( !(GetFlags() & FL_ONGROUND) ) { BiteSound(); TouchDamage( pOther ); } SetTouch( NULL ); }
void CASW_Parasite::LeapTouch( CBaseEntity *pOther ) { m_bMidJump = false; if ( IRelationType( pOther ) == D_HT ) { if (m_bDefanged) { if ( pOther->m_takedamage != DAMAGE_NO ) { BiteSound(); TouchDamage( pOther ); //ClearSchedule( "About to gib self" ); // gib us CTakeDamageInfo info(NULL, NULL, Vector(0,0,0), GetAbsOrigin(), GetHealth() * 2, DMG_ACID); TakeDamage(info); SetSchedule( SCHED_DIE ); return; } else { //ImpactSound(); } } // Don't hit if back on ground //if ( !( GetFlags() & FL_ONGROUND ) && m_bDefanged) // if we're defanged, don't infest, just do some combat damage //{ //} //else //{ //ImpactSound(); //} } else if( !(GetFlags() & FL_ONGROUND) ) { // Still in the air... if( gpGlobals->curtime < m_flIgnoreWorldCollisionTime ) { // Headcrabs try to ignore the world, static props, and friends for a // fraction of a second after they jump. This is because they often brush // doorframes or props as they leap, and touching those objects turns off // this touch function, which can cause them to hit the player and not bite. // A timer probably isn't the best way to fix this, but it's one of our // safer options at this point (sjb). return; } if( !pOther->IsSolid() ) { // Touching a trigger or something. return; } } // make sure we're solid RemoveSolidFlags( FSOLID_NOT_SOLID ); // Shut off the touch function. SetTouch( &CASW_Parasite::NormalTouch ); SetThink ( &CASW_Parasite::CallNPCThink ); SetCollisionGroup( ASW_COLLISION_GROUP_PARASITE ); // if we hit a marine, infest him and go away NormalTouch( pOther ); }