Ejemplo n.º 1
0
/// Weist das Schiff an, in einer bestimmten Richtung die Expedition fortzusetzen
void noShip::ContinueExpedition(const unsigned char dir)
{
    if(state != STATE_EXPEDITION_WAITING)
        return;

    assert(state == STATE_EXPEDITION_WAITING);

    // Nächsten Hafenpunkt in dieser Richtung suchen
    unsigned new_goal = gwg->GetNextFreeHarborPoint(pos, goal_harbor_id, dir, player);

    // Auch ein Ziel gefunden?
    if(!new_goal)
        return;

    MapPoint coastalPos = gwg->GetCoastalPoint(new_goal, seaId_);

    // Versuchen, Weg zu finden
    if(!gwg->FindShipPath(pos, coastalPos, &route_, NULL))
        return;

    // Dann fahren wir da mal hin
    curRouteIdx = 0;
    goal_harbor_id = new_goal;
    state = STATE_EXPEDITION_DRIVING;

    StartDriving(route_[curRouteIdx++]);
}
Ejemplo n.º 2
0
/// Fährt zum Hafen, um dort eine Mission (Expedition) zu erledigen
void noShip::GoToHarbor(nobHarborBuilding* hb, const std::vector<unsigned char>& route)
{
    state = STATE_GOTOHARBOR;

    goal_harbor_id = gwg->GetNode(hb->GetPos()).harbor_id;

    // Route merken
    this->route_ = route;
    curRouteIdx = 1;

    // losfahren
    StartDriving(route[0]);
}
Ejemplo n.º 3
0
/// Fährt weiter zu Hafenbauplatz
noShip::Result noShip::DriveToHarbourPlace()
{
    // Sind wir schon da?
    if(curRouteIdx == route_.size())
        return GOAL_REACHED;
    else
    {
        // Punkt, zu dem uns der Hafen hinführen will (Küstenpunkt)
        MapPoint coastalPos = gwg->GetCoastalPoint(goal_harbor_id, seaId_);

        MapPoint goalRoutePos;

        // Route überprüfen
        if(!gwg->CheckShipRoute(pos, route_, curRouteIdx, &goalRoutePos))
        {
            // Route kann nicht mehr passiert werden --> neue Route suchen
            if(!gwg->FindShipPath(pos, coastalPos, &route_, NULL))
            {
                // Wieder keine gefunden -> raus
                return NO_ROUTE_FOUND;
            }

            // Wir fangen bei der neuen Route wieder von vorne an
            curRouteIdx = 0;
        }

        // Kommen wir auch mit unser bisherigen Route an dem ursprünglich anvisierten Hafenplatz an?
        if(coastalPos != goalRoutePos)
        {
            // Nein, d.h. wenn wir schon nah dran sind, müssen wir die Route neu berechnen
            assert(route_.size() >= curRouteIdx);
            if(route_.size() - curRouteIdx < 10)
            {
                if(!gwg->FindShipPath(pos, coastalPos, &route_, NULL))
                    // Keiner gefunden -> raus
                    return NO_ROUTE_FOUND;

                curRouteIdx = 0;
            }
        }

        StartDriving(route_[curRouteIdx++]);
        return DRIVING;
    }

}
Ejemplo n.º 4
0
/// Fährt zum Hafen, um dort eine Mission (Expedition) zu erledigen
void noShip::GoToHarbor(const nobHarborBuilding& hb, const std::vector<unsigned char>& route)
{
    RTTR_Assert(state == STATE_IDLE); // otherwise we might carry wares etc
    RTTR_Assert(figures.empty());
    RTTR_Assert(wares.empty());
    RTTR_Assert(remaining_sea_attackers == 0);

    state = STATE_GOTOHARBOR;

    goal_harborId = gwg->GetNode(hb.GetPos()).harborId;
    RTTR_Assert(goal_harborId);

    // Route merken
    this->route_ = route;
    curRouteIdx = 1;

    // losfahren
    StartDriving(route[0]);
}
Ejemplo n.º 5
0
static ES_Event DuringDrivingStateSM(ES_Event Event)
{
    // Local variable to get debugger to display the value of CurrentEvent
    volatile ES_Event NewEvent = Event;

    // Process ES_ENTRY & ES_EXIT events
    if (Event.EventType == ES_ENTRY) {
			printf("Entered Driving State SM \r\n");
      // Start driving state machine
      StartDriving(Event);
    }
    else if (Event.EventType == ES_EXIT) {
			printf("Exited Driving State SM \r\n");
      // On exit, give the lower levels a chance to clean up first
      NewEvent = RunDriving(Event);
    }
    else {
      // Do the 'during' function for this state
      // Run driving state machine
      NewEvent = RunDriving(Event);
    }
    return(NewEvent);
}
//------------------------------------------------------------------------
bool CVehicleMovementHelicopter::RequestMovement(CMovementRequest& movementRequest)
{
	FUNCTION_PROFILER( gEnv->pSystem, PROFILE_GAME );
 
	m_movementAction.isAI = true;
  //StartEngine(0);

  if (m_HoverAnim && !(m_HoverAnim->GetAnimTime() < 1.0f - FLT_EPSILON))
  {
    m_HoverAnim->StartAnimation();
  }


	CryAutoCriticalSection lk(m_lock);


	if (movementRequest.HasLookTarget())
		m_aiRequest.SetLookTarget(movementRequest.GetLookTarget());
	else
		m_aiRequest.ClearLookTarget();

  if (movementRequest.HasBodyTarget())
    m_aiRequest.SetBodyTarget(movementRequest.GetBodyTarget());
  else
    m_aiRequest.ClearBodyTarget();

  if (movementRequest.HasDesiredBodyDirectionAtTarget())
    m_aiRequest.SetDesiredBodyDirectionAtTarget(movementRequest.GetDesiredBodyDirectionAtTarget());
  else
    m_aiRequest.ClearDesiredBodyDirectionAtTarget();

	if (movementRequest.HasMoveTarget())
	{
		Vec3 end( movementRequest.GetMoveTarget() );
		if(m_bExtendMoveTarget)
		{
			Vec3 entityPos = m_pEntity->GetWorldPos();
			Vec3 start(entityPos);
			Vec3 pos = ( end - start ) * 100.0f;
			pos +=start;
			m_aiRequest.SetMoveTarget( pos );
		}
		else
		{
			m_aiRequest.SetMoveTarget( end );
		}


    if (!m_isEnginePowered)
    {
      StartDriving(0);
    }
	}
	else
		m_aiRequest.ClearMoveTarget();

	float fDesiredSpeed = 0.0f;

	if (movementRequest.HasDesiredSpeed())
		fDesiredSpeed = movementRequest.GetDesiredSpeed();
	else
		m_aiRequest.ClearDesiredSpeed();

	if (movementRequest.HasForcedNavigation())
	{
		const Vec3 forcedNavigation = movementRequest.GetForcedNavigation();
		const Vec3 entityPos = m_pEntity->GetWorldPos();
		m_aiRequest.SetForcedNavigation(forcedNavigation);
		m_aiRequest.SetMoveTarget(entityPos+forcedNavigation.GetNormalizedSafe()*100.0f);
		
		if (fabsf(fDesiredSpeed) <= FLT_EPSILON)
			fDesiredSpeed = forcedNavigation.GetLength();
	}
	else
		m_aiRequest.ClearForcedNavigation();

	m_aiRequest.SetDesiredSpeed(fDesiredSpeed * m_EnginePerformance);

	m_pVehicle->NeedsUpdate(IVehicle::eVUF_AwakePhysics, false);

	return true;
		
}