//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CTFGrenadeMirvProjectile::Explode( trace_t *pTrace, int bitsDamageType ) { // Pass through. BaseClass::Explode( pTrace, bitsDamageType ); // Server specific. #ifdef GAME_DLL // Create the bomblets. for ( int iBomb = 0; iBomb < TF_WEAPON_GRENADE_MIRV_BOMB_COUNT; ++iBomb ) { Vector vecSrc = pTrace->endpos + Vector( 0, 0, 1.0f ); Vector vecVelocity( random->RandomFloat( -75.0f, 75.0f ) * 3.0f, random->RandomFloat( -75.0f, 75.0f ) * 3.0f, random->RandomFloat( 30.0f, 70.0f ) * 5.0f ); Vector vecZero( 0,0,0 ); CTFPlayer *pPlayer = ToTFPlayer( GetThrower() ); float flTime = 2.0f + random->RandomFloat( 0.0f, 1.0f ); CTFGrenadeMirvBomb *pBomb = CTFGrenadeMirvBomb::Create( vecSrc, GetAbsAngles(), vecVelocity, vecZero, pPlayer, flTime ); pBomb->SetDamage( GetDamage() * 0.5f ); pBomb->SetDamageRadius( GetDamageRadius() ); } #endif }
//----------------------------------------------------------------------------- //----------------------------------------------------------------------------- void CEnvMeteorShared::ConvertFromWorldToSkybox( void ) { // Scale the speed. float flSkyboxScale = g_pMapData->Get3DSkyboxScale(); m_flSpeed /= flSkyboxScale; float flDeltaTime = m_flWorldExitTime - m_flStartTime; Vector vecVelocity( m_vecDirection.x * m_flSpeed, m_vecDirection.y * m_flSpeed, m_vecDirection.z * m_flSpeed ); VectorMA( m_vecStartPosition, flDeltaTime, vecVelocity, m_vecPos ); // Reset the start time. m_flPosTime = m_flWorldExitTime; // Set the location to skybox. m_nLocation = METEOR_LOCATION_SKYBOX; }
//----------------------------------------------------------------------------- // Purpose: Fire targets and spawn sprites. // Input : bulletCount - // barrelEnd - // forward - // pAttacker - //----------------------------------------------------------------------------- void CFuncTank::Fire( int bulletCount, const Vector &barrelEnd, const Vector &forward, CBaseEntity *pAttacker ) { if ( m_iszSpriteSmoke != NULL_STRING ) { CSprite *pSprite = CSprite::SpriteCreate( STRING(m_iszSpriteSmoke), barrelEnd, TRUE ); pSprite->AnimateAndDie( random->RandomFloat( 15.0, 20.0 ) ); pSprite->SetTransparency( kRenderTransAlpha, m_clrRender->r, m_clrRender->g, m_clrRender->b, 255, kRenderFxNone ); Vector vecVelocity( 0, 0, random->RandomFloat(40, 80) ); pSprite->SetAbsVelocity( vecVelocity ); pSprite->SetScale( m_spriteScale ); } if ( m_iszSpriteFlash != NULL_STRING ) { CSprite *pSprite = CSprite::SpriteCreate( STRING(m_iszSpriteFlash), barrelEnd, TRUE ); pSprite->AnimateAndDie( 60 ); pSprite->SetTransparency( kRenderTransAdd, 255, 255, 255, 255, kRenderFxNoDissipation ); pSprite->SetScale( m_spriteScale ); } m_OnFire.FireOutput(this, this); }
// this is the think that flips the weapon into the world when it is spawned void CASW_Laser_Mine::SpawnFlipThink() { // we are still flagged as spawn flipping in the air if ( m_bIsSpawnFlipping == false ) { // we get here if we spawned, but haven't started spawn flipping yet, please try again! SetContextThink( &CASW_Laser_Mine::SpawnFlipThink, gpGlobals->curtime, s_pLaserMineSpawnFlipThink ); return; } // when we should hit the ground float flEndTime = m_flSpawnFlipEndTime; // the total time it takes for us to flip float flFlipTime = flEndTime - m_flSpawnFlipStartTime; float flFlipProgress = ( gpGlobals->curtime - m_flSpawnFlipStartTime ) / flFlipTime; flFlipProgress = clamp( flFlipProgress, 0.0f, 2.5f ); if ( !m_bIsSpawnLanded ) { // high gravity, it looks more satisfying float flGravity = 2200; float flInitialZVelocity = (m_vecSpawnFlipEndPos.z - m_vecSpawnFlipStartPos.z)/flFlipTime + (flGravity/2) * flFlipTime; float flZVelocity = flInitialZVelocity - flGravity * (gpGlobals->curtime - m_flSpawnFlipStartTime); float flXDiff = (m_vecSpawnFlipEndPos.x - m_vecSpawnFlipStartPos.x) / flFlipTime; float flYDiff = (m_vecSpawnFlipEndPos.y - m_vecSpawnFlipStartPos.y) / flFlipTime; Vector vecVelocity( flXDiff, flYDiff, flZVelocity ); SetAbsVelocity( vecVelocity ); // angular velocity QAngle angCurAngVel = GetLocalAngularVelocity(); float flXAngDiff = 360 / flFlipTime; // keep the Y angular velocity that was given to it at the start (it's random) SetLocalAngularVelocity( QAngle( flXAngDiff, angCurAngVel.y, 0 ) ); } if ( flFlipProgress >= 1.0f ) { if ( !m_bIsSpawnLanded ) { Vector vecVelStop( 0,0,0 ); SetAbsVelocity( vecVelStop ); SetAbsOrigin( m_vecSpawnFlipEndPos ); QAngle angVel( 0, 0, 0 ); SetLocalAngularVelocity( angVel ); /* // get the current angles of the item so we can use them to determine the final angles QAngle angPrevAngles = GetAbsAngles(); float flYAngles = angPrevAngles.y; QAngle angFlat( 0, flYAngles, 0 ); */ SetAbsAngles( m_angSpawnFlipEndAngle ); EmitSound("ASW_Laser_Mine.Lay"); m_bIsSpawnLanded = true; } if ( flFlipProgress >= 2.5f ) { SetContextThink( NULL, 0, s_pLaserMineSpawnFlipThink ); EmitSound("ASW_Mine.Lay"); m_bMineActive = true; return; } } SetContextThink( &CASW_Laser_Mine::SpawnFlipThink, gpGlobals->curtime, s_pLaserMineSpawnFlipThink ); }
//----------------------------------------------------------------------------- //----------------------------------------------------------------------------- void CEnvMeteorShared::GetPositionAtTime( float flTime, Vector &vecPosition ) { float flDeltaTime = flTime - m_flPosTime; Vector vecVelocity( m_vecDirection.x * m_flSpeed, m_vecDirection.y * m_flSpeed, m_vecDirection.z * m_flSpeed ); VectorMA( m_vecPos, flDeltaTime, vecVelocity, vecPosition ); }