void CControllerZapBall::ExplodeTouch( CBaseEntity *pOther ) { if( pOther->pev->takedamage ) { TraceResult tr = UTIL_GetGlobalTrace(); CBaseEntity* pOwner; if( m_hOwner != nullptr ) { pOwner = m_hOwner; } else { pOwner = this; } g_MultiDamage.Clear(); pOther->TraceAttack( CTakeDamageInfo( pOwner, gSkillData.GetControllerDmgBall(), DMG_ENERGYBEAM ), pev->velocity.Normalize(), &tr ); g_MultiDamage.ApplyMultiDamage( pOwner, pOwner ); UTIL_EmitAmbientSound( this, tr.vecEndPos, "weapons/electro4.wav", 0.3, ATTN_NORM, 0, RANDOM_LONG( 90, 99 ) ); } UTIL_Remove( this ); }
void CTentacle :: HitTouch( CBaseEntity *pOther ) { TraceResult tr = UTIL_GetGlobalTrace( ); if (pOther->pev->modelindex == pev->modelindex) return; if (m_flHitTime > gpGlobals->time) return; // only look at the ones where the player hit me if (tr.pHit == NULL || tr.pHit->v.modelindex != pev->modelindex) return; if (tr.iHitgroup >= 3) { pOther->TakeDamage( pev, pev, m_iHitDmg, DMG_CRUSH ); // ALERT( at_console, "wack %3d : ", m_iHitDmg ); } else if (tr.iHitgroup != 0) { pOther->TakeDamage( pev, pev, 20, DMG_CRUSH ); // ALERT( at_console, "tap %3d : ", 20 ); } else { return; // Huh? } m_flHitTime = gpGlobals->time + 0.5; // ALERT( at_console, "%s : ", STRING( tr.pHit->v.classname ) ); // ALERT( at_console, "%.0f : %s : %d\n", pev->angles.y, STRING( pOther->pev->classname ), tr.iHitgroup ); }
void CControllerZapBall::ExplodeTouch( CBaseEntity *pOther ) { if (pOther->pev->takedamage) { TraceResult tr = UTIL_GetGlobalTrace( ); entvars_t *pevOwner; if (m_hOwner != NULL) { pevOwner = m_hOwner->pev; } else { pevOwner = pev; } ClearMultiDamage( ); pOther->TraceAttack(pevOwner, gSkillData.controllerDmgBall, pev->velocity.Normalize(), &tr, DMG_ENERGYBEAM ); ApplyMultiDamage( pevOwner, pevOwner ); UTIL_EmitAmbientSound( ENT(pev), tr.vecEndPos, "weapons/electro4.wav", 0.3, ATTN_NORM, 0, RANDOM_LONG( 90, 99 ) ); } UTIL_Remove( this ); }
void CGrenade::BounceTouch( CBaseEntity *pOther ) { // don't hit the guy that launched this grenade if ( pOther->edict() == pev->owner ) return; // only do damage if we're moving fairly fast if (m_flNextAttack < gpGlobals->time && pev->velocity.Length() > 100) { entvars_t *pevOwner = VARS( pev->owner ); if (pevOwner) { TraceResult tr = UTIL_GetGlobalTrace( ); ClearMultiDamage( ); pOther->TraceAttack(pevOwner, 1, gpGlobals->v_forward, &tr, DMG_CLUB ); ApplyMultiDamage( pev, pevOwner); } m_flNextAttack = gpGlobals->time + 1.0; // debounce } Vector vecTestVelocity; // pev->avelocity = Vector (300, 300, 300); // this is my heuristic for modulating the grenade velocity because grenades dropped purely vertical // or thrown very far tend to slow down too quickly for me to always catch just by testing velocity. // trimming the Z velocity a bit seems to help quite a bit. vecTestVelocity = pev->velocity; vecTestVelocity.z *= 0.45; if ( !m_fRegisteredSound && vecTestVelocity.Length() <= 60 ) { //ALERT( at_console, "Grenade Registered!: %f\n", vecTestVelocity.Length() ); // grenade is moving really slow. It's probably very close to where it will ultimately stop moving. // go ahead and emit the danger sound. // register a radius louder than the explosion, so we make sure everyone gets out of the way CSoundEnt::InsertSound ( bits_SOUND_DANGER, pev->origin, pev->dmg / 0.4, 0.3 ); m_fRegisteredSound = TRUE; } if (pev->flags & FL_ONGROUND) { // add a bit of static friction pev->velocity = pev->velocity * 0.8; pev->sequence = RANDOM_LONG( 1, 1 ); } else { // play bounce sound BounceSound(); } pev->framerate = pev->velocity.Length() / 200.0; if (pev->framerate > 1.0) pev->framerate = 1; else if (pev->framerate < 0.5) pev->framerate = 0; }
void CApache::FlyTouch( CBaseEntity *pOther ) { // bounce if we hit something solid if ( pOther->pev->solid == SOLID_BSP) { TraceResult tr = UTIL_GetGlobalTrace( ); // UNDONE, do a real bounce pev->velocity = pev->velocity + tr.vecPlaneNormal * (pev->velocity.Length() + 200); } }