void CAI_Motor::SetIdealYawAndUpdate( float idealYaw, float yawSpeed) { SetIdealYaw( idealYaw ); if (yawSpeed == AI_CALC_YAW_SPEED) RecalculateYawSpeed(); else if (yawSpeed != AI_KEEP_YAW_SPEED) SetYawSpeed( yawSpeed ); UpdateYaw(-1); }
void CAI_Motor::SetIdealYawToTarget( const Vector &target, float noise, float offset ) { float base = CalcIdealYaw( target ); base += offset; if ( noise > 0 ) { noise *= 0.5; base += random->RandomFloat( -noise, noise ); if ( base < 0 ) base += 360; else if ( base >= 360 ) base -= 360; } SetIdealYaw( base ); }
void CAI_Motor::SetIdealYawToTarget( const Vector &target ) { SetIdealYaw( CalcIdealYaw( target ) ); }
void CTalkMonster :: StartTask( const Task_t& task ) { switch ( task.iTask ) { case TASK_TLK_SPEAK: // ask question or make statement FIdleSpeak(); TaskComplete(); break; case TASK_TLK_RESPOND: // respond to question IdleRespond(); TaskComplete(); break; case TASK_TLK_HELLO: // greet player FIdleHello(); TaskComplete(); break; case TASK_TLK_STARE: // let the player know I know he's staring at me. FIdleStare(); TaskComplete(); break; case TASK_FACE_PLAYER: case TASK_TLK_LOOK_AT_CLIENT: case TASK_TLK_CLIENT_STARE: // track head to the client for a while. m_flWaitFinished = gpGlobals->time + task.flData; break; case TASK_TLK_EYECONTACT: break; case TASK_TLK_IDEALYAW: if (m_hTalkTarget != NULL) { SetYawSpeed( 60 ); float yaw = VecToYaw(m_hTalkTarget->GetAbsOrigin() - GetAbsOrigin()) - GetAbsAngles().y; if (yaw > 180) yaw -= 360; if (yaw < -180) yaw += 360; if (yaw < 0) { SetIdealYaw( min( yaw + 45, 0.0f ) + GetAbsAngles().y ); } else { SetIdealYaw( max( yaw - 45, 0.0f ) + GetAbsAngles().y ); } } TaskComplete(); break; case TASK_TLK_HEADRESET: // reset head position after looking at something m_hTalkTarget = NULL; TaskComplete(); break; case TASK_TLK_STOPSHOOTING: // tell player to stop shooting PlaySentence( m_szGrp[TLK_NOSHOOT], RANDOM_FLOAT(2.8, 3.2), VOL_NORM, ATTN_NORM ); TaskComplete(); break; case TASK_CANT_FOLLOW: StopFollowing( false ); PlaySentence( m_szGrp[TLK_STOP], RANDOM_FLOAT(2, 2.5), VOL_NORM, ATTN_NORM ); TaskComplete(); break; case TASK_WALK_PATH_FOR_UNITS: m_movementActivity = ACT_WALK; break; case TASK_MOVE_AWAY_PATH: { Vector dir = GetAbsAngles(); dir.y = GetIdealYaw() + 180; Vector move; UTIL_MakeVectorsPrivate( dir, &move, nullptr, nullptr ); dir = GetAbsOrigin() + move * task.flData; if ( MoveToLocation( ACT_WALK, 2, dir ) ) { TaskComplete(); } else if ( FindCover( GetAbsOrigin(), GetViewOffset(), 0, CoverRadius() ) ) { // then try for plain ole cover m_flMoveWaitFinished = gpGlobals->time + 2; TaskComplete(); } else { // nowhere to go? TaskFail(); } } break; case TASK_PLAY_SCRIPT: m_hTalkTarget = NULL; CBaseMonster::StartTask( task ); break; default: CBaseMonster::StartTask( task ); } }