//----------------------------------------------------------------------------- // Purpose: Turns a npc towards its ideal yaw. // Input : yawSpeed - Yaw speed in degrees per 1/10th of a second. // flInterval - Time interval to turn, -1 uses time since last think. // Output : Returns the number of degrees turned. //----------------------------------------------------------------------------- void CAI_Motor::UpdateYaw( int yawSpeed ) { // Don't do this if our yaw is locked if ( IsYawLocked() ) return; GetOuter()->SetUpdatedYaw(); float ideal, current, newYaw; if ( yawSpeed == -1 ) yawSpeed = GetYawSpeed(); // NOTE: GetIdealYaw() will never exactly be reached because UTIL_AngleMod // also truncates the angle to 16 bits of resolution. So lets truncate it here. current = UTIL_AngleMod( GetLocalAngles().y ); ideal = UTIL_AngleMod( GetIdealYaw() ); // FIXME: this needs a proper interval float dt = MIN( 0.2, gpGlobals->curtime - GetLastThink() ); newYaw = AI_ClampYaw( (float)yawSpeed * 10.0, current, ideal, dt ); if (newYaw != current) { QAngle angles = GetLocalAngles(); angles.y = newYaw; SetLocalAngles( angles ); } }
void CAI_BlendedMotor::UpdateYaw( int speed ) { // Don't do this is we're locked if ( IsYawLocked() ) return; GetOuter()->UpdateTurnGesture( ); BaseClass::UpdateYaw( speed ); }
void CAI_BlendedMotor::RecalculateYawSpeed() { // Don't do this is we're locked if ( IsYawLocked() ) { SetYawSpeed( 0.0f ); return; } if (GetOuter()->HasMemory( bits_MEMORY_TURNING )) return; SetYawSpeed( CalcYawSpeed() ); }
float CAI_BlendedMotor::OverrideMaxYawSpeed( Activity activity ) { // Don't do this is we're locked if ( IsYawLocked() ) return 0.0f; switch( activity ) { case ACT_TURN_LEFT: case ACT_TURN_RIGHT: return 45; break; default: if (GetOuter()->IsMoving()) { return 15; } return 45; // too fast? break; } return -1; }