//----------------------------------------------------------------------------- // Purpose: Charge up, prepare to fire and give player time to dodge //----------------------------------------------------------------------------- void CNPC_RocketTurret::LockingThink( void ) { //Allow descended classes a chance to do something before the think function if ( PreThink() ) return; //Turn to face UpdateFacing(); SetNextThink( gpGlobals->curtime + ROCKET_TURRET_THINK_RATE ); if ( m_flTimeLocking == 0.0f ) { // Play lockon sound EmitSound ( ROCKET_TURRET_SOUND_LOCKING ); EmitSound ( ROCKET_TURRET_SOUND_LOCKING, gpGlobals->curtime + ROCKET_TURRET_QUARTER_LOCKON_TIME ); EmitSound ( ROCKET_TURRET_SOUND_LOCKED, gpGlobals->curtime + ROCKET_TURRET_HALF_LOCKON_TIME ); ResetSequence(LookupSequence("load")); // Change lockon sprite UpdateSkin( ROCKET_SKIN_LOCKING ); } m_flTimeLocking += ROCKET_TURRET_THINK_RATE; if ( m_flTimeLocking > ROCKET_TURRET_LOCKON_TIME ) { // Set Locked sprite to 'rocket out' color UpdateSkin( ROCKET_SKIN_LOCKED ); FireRocket(); SetThink ( &CNPC_RocketTurret::FiringThink ); m_flTimeLocking = 0.0f; } }
//----------------------------------------------------------------------------- // Purpose: Charge up, deal damage along our facing direction. //----------------------------------------------------------------------------- void CNPC_RocketTurret::FiringThink( void ) { //Allow descended classes a chance to do something before the think function if ( PreThink() ) return; SetNextThink( gpGlobals->curtime + ROCKET_TURRET_THINK_RATE ); CRocket_Turret_Projectile* pRocket = dynamic_cast<CRocket_Turret_Projectile*>(m_hCurRocket.Get()); if ( pRocket ) { // If this rocket has been out too long, detonate it and launch a new one if ( (gpGlobals->curtime - m_flTimeLastFired) > ROCKET_PROJECTILE_DEFAULT_LIFE ) { pRocket->ShotDown(); m_flTimeLastFired = gpGlobals->curtime; SetThink( &CNPC_RocketTurret::FollowThink ); } } else { // Set Locked sprite UpdateSkin( ROCKET_SKIN_IDLE ); // Rocket dead, or never created. Revert to follow think m_flTimeLastFired = gpGlobals->curtime; SetThink( &CNPC_RocketTurret::FollowThink ); } }
//----------------------------------------------------------------------------- // Purpose: Rocket destructed, resume search behavior //----------------------------------------------------------------------------- void CNPC_RocketTurret::RocketDied( void ) { // Set Locked sprite UpdateSkin( ROCKET_SKIN_IDLE ); // Rocket dead, return to follow think m_flTimeLastFired = gpGlobals->curtime; SetThink( &CNPC_RocketTurret::FollowThink ); }
void DrawSkin() { ClearLCD(); printf("\r\DrawSkin\r\n"); LCDPrint(8,2,"Skin Treatment"); LCDLineH(0,10,30); // head line LCDPrint(3,12,"use Skin Treatment handle"); UpdateSkin(); }
//----------------------------------------------------------------------------- // Purpose: the entity //----------------------------------------------------------------------------- void CNPC_RocketTurret::Spawn( void ) { Precache(); BaseClass::Spawn(); SetViewOffset( vec3_origin ); AddEFlags( EFL_NO_DISSOLVE ); SetModel( ROCKET_TURRET_MODEL_NAME ); SetSolid( SOLID_VPHYSICS ); m_iMuzzleAttachment = LookupAttachment ( "barrel" ); m_iLightAttachment = LookupAttachment ( "eye" ); m_iPosePitch = LookupPoseParameter( "aim_pitch" ); m_iPoseYaw = LookupPoseParameter( "aim_yaw" ); m_vecCurrentAngles = m_vecGoalAngles = GetAbsAngles(); CreateVPhysics(); //Set our autostart state m_bEnabled = ( ( m_spawnflags & SF_ROCKET_TURRET_START_INACTIVE ) == false ); // Set Locked sprite if ( m_bEnabled ) { m_iLaserState = 1; SetSequence(LookupSequence("idle")); } else { m_iLaserState = 0; SetSequence(LookupSequence("inactive")); } SetCycle(1.0f); UpdateSkin( ROCKET_SKIN_IDLE ); SetPoseParameter( "aim_pitch", 0 ); SetPoseParameter( "aim_yaw", -180 ); if ( m_bEnabled ) { SetThink( &CNPC_RocketTurret::FollowThink ); } SetNextThink( gpGlobals->curtime + ROCKET_TURRET_THINK_RATE ); }
//----------------------------------------------------------------------------- // Purpose: Retire the turret until enabled again //----------------------------------------------------------------------------- void CNPC_RocketTurret::Disable( void ) { if ( !m_bEnabled ) return; UpdateSkin( ROCKET_SKIN_IDLE ); m_bEnabled = false; ResetSequence(LookupSequence("close")); SetThink( &CNPC_RocketTurret::ClosingThink ); SetNextThink( gpGlobals->curtime + 0.05 ); SetEnemy( NULL ); }
//----------------------------------------------------------------------------- // Purpose: Show this rocket turret has overloaded with effects and noise for a period of time //----------------------------------------------------------------------------- void CNPC_RocketTurret::DyingThink( void ) { // Make the beam graphics freak out a bit m_iLaserState = 2; UpdateSkin( ROCKET_SKIN_IDLE ); // If we've freaked out for long enough, be dead if ( m_flTimeSpentDying > ROCKET_TURRET_DEATH_EFFECT_TIME ) { Vector vForward; AngleVectors( m_vecCurrentAngles, &vForward, NULL, NULL ); g_pEffects->EnergySplash( EyePosition(), vForward, true ); m_OnDeath.FireOutput( this, this ); SetThink( &CNPC_RocketTurret::DeathThink ); SetNextThink( gpGlobals->curtime + 1.0f ); m_flTimeSpentDying = 0.0f; } SetNextThink( gpGlobals->curtime + ROCKET_TURRET_THINK_RATE ); m_flTimeSpentDying += ROCKET_TURRET_THINK_RATE; }