void AAirMoveType::ReservePad(CAirBaseHandler::LandingPad* lp) { oldGoalPos = goalPos; orgWantedHeight = wantedHeight; assert(reservedPad == NULL); AddDeathDependence(lp, DEPENDENCE_LANDINGPAD); SetGoal(lp->GetUnit()->pos); reservedPad = lp; padStatus = 0; Takeoff(); }
//----------------------------------------------------------------------------- // Purpose: Catches the monster-specific messages that occur when tagged // animation frames are played. // Input : pEvent - //----------------------------------------------------------------------------- void CNPC_Crow::HandleAnimEvent( animevent_t *pEvent ) { if ( pEvent->event == AE_CROW_TAKEOFF ) { if ( GetNavigator()->GetPath()->GetCurWaypoint() ) { Takeoff( GetNavigator()->GetCurWaypointPos() ); } return; } if( pEvent->event == AE_CROW_HOP ) { SetGroundEntity( NULL ); // // Take him off ground so engine doesn't instantly reset FL_ONGROUND. // UTIL_SetOrigin( this, GetLocalOrigin() + Vector( 0 , 0 , 1 )); // // How fast does the crow need to travel to reach the hop goal given gravity? // float flHopDistance = ( m_vSavePosition - GetLocalOrigin() ).Length(); float gravity = sv_gravity.GetFloat(); if ( gravity <= 1 ) { gravity = 1; } float height = 0.25 * flHopDistance; float speed = sqrt( 2 * gravity * height ); float time = speed / gravity; // // Scale the sideways velocity to get there at the right time // Vector vecJumpDir = m_vSavePosition - GetLocalOrigin(); vecJumpDir = vecJumpDir / time; // // Speed to offset gravity at the desired height. // vecJumpDir.z = speed; // // Don't jump too far/fast. // float distance = vecJumpDir.Length(); if ( distance > 650 ) { vecJumpDir = vecJumpDir * ( 650.0 / distance ); } m_nMorale -= random->RandomInt( 1, 6 ); if ( m_nMorale <= 0 ) { m_nMorale = 0; } // Play a hop flap sound. EmitSound( "NPC_Crow.Hop" ); SetAbsVelocity( vecJumpDir ); return; } if( pEvent->event == AE_CROW_FLY ) { // // Start flying. // SetActivity( ACT_FLY ); m_bSoar = false; m_flSoarTime = gpGlobals->curtime + random->RandomFloat( 3, 5 ); return; } CAI_BaseNPC::HandleAnimEvent( pEvent ); }
void AAirMoveType::ReservePad(CAirBaseHandler::LandingPad* lp) { oldGoalPos = goalPos; AMoveType::ReservePad(lp); Takeoff(); }