//----------------------------------------------------------------------------- // Purpose: // Input : pEvent - //----------------------------------------------------------------------------- void CNPC_Monk::HandleAnimEvent( animevent_t *pEvent ) { switch ( pEvent->event ) { case AE_MONK_FIRE_GUN: { Vector vecShootOrigin; QAngle vecAngles; GetAttachment( "muzzle", vecShootOrigin, vecAngles ); Vector vecShootDir = GetShootEnemyDir( vecShootOrigin ); CPASAttenuationFilter filter2( this, "NPC_Monk.Fire" ); EmitSound( filter2, entindex(), "NPC_Monk.Fire" ); UTIL_Smoke( vecShootOrigin, random->RandomInt(20, 30), 10 ); FireBullets( 1, vecShootOrigin, vecShootDir, vec3_origin, MAX_TRACE_LENGTH, m_nAmmoType, 0 ); m_fEffects |= EF_MUZZLEFLASH; break; } default: { BaseClass::HandleAnimEvent( pEvent ); } } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CUnitBase::AimGun() { if( GetEnemy() ) { Vector vecShootOrigin = Weapon_ShootPosition(); Vector vecShootDir = GetShootEnemyDir( vecShootOrigin, false ); SetAim(vecShootDir); } else { RelaxAim(); } }
//========================================================= // Shoot //========================================================= void CNPC_HAssassin::Shoot ( void ) { Vector vForward, vRight, vUp; Vector vecShootOrigin; QAngle vAngles; if ( GetEnemy() == NULL) { return; } GetAttachment( "guntip", vecShootOrigin, vAngles ); Vector vecShootDir = GetShootEnemyDir( vecShootOrigin ); if (m_flLastShot + 2 < gpGlobals->curtime) { m_flDiviation = 0.10; } else { m_flDiviation -= 0.01; if (m_flDiviation < 0.02) m_flDiviation = 0.02; } m_flLastShot = gpGlobals->curtime; AngleVectors( GetAbsAngles(), &vForward, &vRight, &vUp ); Vector vecShellVelocity = vRight * random->RandomFloat(40,90) + vUp * random->RandomFloat(75,200) + vForward * random->RandomFloat(-40, 40); EjectShell( GetAbsOrigin() + vUp * 32 + vForward * 12, vecShellVelocity, GetAbsAngles().y, 0 ); FireBullets( 1, vecShootOrigin, vecShootDir, Vector( m_flDiviation, m_flDiviation, m_flDiviation ), 2048, m_iAmmoType ); // shoot +-8 degrees //NDebugOverlay::Line( vecShootOrigin, vecShootOrigin + vecShootDir * 2048, 255, 0, 0, true, 2.0 ); CPASAttenuationFilter filter( this ); EmitSound( filter, entindex(), "HAssassin.Shot" ); DoMuzzleFlash(); VectorAngles( vecShootDir, vAngles ); SetPoseParameter( "shoot", vecShootDir.x ); m_cAmmoLoaded--; }
//========================================================= // BarneyFirePistol - shoots one round from the pistol at // the enemy barney is facing. //========================================================= void CNPC_HL1Barney::BarneyFirePistol ( void ) { Vector vecShootOrigin; vecShootOrigin = GetAbsOrigin() + Vector( 0, 0, 55 ); Vector vecShootDir = GetShootEnemyDir( vecShootOrigin ); QAngle angDir; VectorAngles( vecShootDir, angDir ); // SetBlending( 0, angDir.x ); DoMuzzleFlash(); FireBullets(1, vecShootOrigin, vecShootDir, VECTOR_CONE_2DEGREES, 1024, m_iAmmoType ); int pitchShift = random->RandomInt( 0, 20 ); // Only shift about half the time if ( pitchShift > 10 ) pitchShift = 0; else pitchShift -= 5; CPASAttenuationFilter filter( this ); EmitSound_t params; params.m_pSoundName = "Barney.FirePistol"; params.m_flVolume = 1; params.m_nChannel= CHAN_WEAPON; params.m_SoundLevel = SNDLVL_NORM; params.m_nPitch = 100 + pitchShift; EmitSound( filter, entindex(), params ); CSoundEnt::InsertSound ( SOUND_COMBAT, GetAbsOrigin(), 384, 0.3 ); // UNDONE: Reload? m_cAmmoLoaded--;// take away a bullet! }
//========================================================= // ZapBeam - heavy damage directly forward //========================================================= void CNPC_Vortigaunt::ZapBeam( int side ) { Vector vecSrc, vecAim; trace_t tr; CBaseEntity *pEntity; if ( m_iBeams >= VORTIGAUNT_MAX_BEAMS ) return; Vector forward, right, up; AngleVectors( GetAbsAngles(), &forward, &right, &up ); vecSrc = GetAbsOrigin() + up * 36; vecAim = GetShootEnemyDir( vecSrc ); float deflection = 0.01; vecAim = vecAim + side * right * random->RandomFloat( 0, deflection ) + up * random->RandomFloat( -deflection, deflection ); UTIL_TraceLine ( vecSrc, vecSrc + vecAim * 1024, MASK_SOLID, this, COLLISION_GROUP_NONE, &tr); m_pBeam[m_iBeams] = CBeam::BeamCreate( "sprites/lgtning.vmt", 5.0f ); if ( m_pBeam[m_iBeams] == NULL ) return; m_pBeam[m_iBeams]->PointEntInit( tr.endpos, this ); m_pBeam[m_iBeams]->SetEndAttachment( side < 0 ? 2 : 1 ); m_pBeam[m_iBeams]->SetColor( 180, 255, 96 ); m_pBeam[m_iBeams]->SetBrightness( 255 ); m_pBeam[m_iBeams]->SetNoise( 3.2f ); m_iBeams++; pEntity = tr.m_pEnt; if ( pEntity != NULL && m_takedamage ) { CTakeDamageInfo info( this, this, sk_islave_dmg_zap.GetFloat(), DMG_SHOCK ); CalculateMeleeDamageForce( &info, vecAim, tr.endpos ); pEntity->DispatchTraceAttack( info, vecAim, &tr ); } }
// Основная атака огнеметом // This is the cremator's main attack, or more precisely, its damage function. void CNPC_Cremator::DispatchSpray( CBaseEntity *pEntity ) { Vector vecSrc, vecAim; trace_t tr; //const char *entityname = pEntity->GetClassname(); Vector forward, right, up; AngleVectors( GetAbsAngles(), &forward, &right, &up ); vecSrc = GetAbsOrigin() + up * 36; vecAim = GetShootEnemyDir( vecSrc ); float deflection = 0.01; vecAim = vecAim + 1 * right * random->RandomFloat( 0, deflection ) + up * random->RandomFloat( -deflection, deflection ); UTIL_TraceLine ( vecSrc, vecSrc + vecAim * 512, MASK_SOLID, this, COLLISION_GROUP_NONE, &tr); /* if ( tr.DidHitWorld() ) // spawn flames on solid surfaces. // It's not very important since it is extremely rare for a cremator to // hit brush geometry but might be a nice feature for a close-space combat // it also works fine but again is EXTREMELY hard to get in-game { Vector ofsDir = ( tr.endpos - GetAbsOrigin() ); float offset = VectorNormalize( ofsDir ); if ( offset > 128 ) offset = 128; float scale = 0.1f + ( 0.75f * ( 1.0f - ( offset / 128.0f ) ) ); float growth = 0.1f + ( 0.75f * (offset / 128.0f ) ); if ( tr.surface.flags & CONTENTS_GRATE ) // get smaller flames on grates since they have a smaller burning area { scale = 0.1f + ( 0.15f * ( 1.0f - ( offset / 128.0f ) ) ); } else { scale = 0.1f + ( 0.75f * ( 1.0f - ( offset / 128.0f ) ) ); } FireSystem_StartFire( tr.endpos, scale, growth, 8.0, 10.0f, (SF_FIRE_START_ON|SF_FIRE_START_FULL), (CBaseEntity*) this, FIRE_NATURAL ); } */ pEntity = tr.m_pEnt; if ( pEntity != NULL && m_takedamage ) { CTakeDamageInfo firedamage( this, this, sk_cremator_firedamage.GetFloat(), DMG_BURN ); CTakeDamageInfo radiusdamage( this, this, sk_cremator_radiusdamage.GetFloat(), DMG_PLASMA ); CalculateMeleeDamageForce( &firedamage, vecAim, tr.endpos ); RadiusDamage ( CTakeDamageInfo ( this, this, 2, DMG_PLASMA ), // AOE; this stuff makes cremators absurdly powerfull sometimes btw tr.endpos, 64.0f, CLASS_NONE, NULL ); pEntity->DispatchTraceAttack( ( firedamage ), vecAim, &tr ); Vector flEnemyLKP = pEntity->GetAbsOrigin(); GetMotor()->SetIdealYawToTargetAndUpdate( flEnemyLKP ); ClearMultiDamage(); } m_iAmmo --; }