Exemple #1
0
void noShip::Driven()
{
    MapPoint enemy_territory_discovered(0xffff, 0xffff);
    gwg->RecalcMovingVisibilities(pos, player, GetVisualRange(), GetCurMoveDir(), &enemy_territory_discovered);

    // Feindliches Territorium entdeckt?
    if(enemy_territory_discovered.x != 0xffff)
    {
        // Send message if necessary
        if(players->getElement(player)->ShipDiscoveredHostileTerritory
                (enemy_territory_discovered) && player == GAMECLIENT.GetPlayerID())
            GAMECLIENT.SendPostMessage(new PostMsgWithLocation(_("A ship disovered an enemy territory"), PMC_MILITARY, enemy_territory_discovered));

    }

    switch(state)
    {
        case STATE_GOTOHARBOR: HandleState_GoToHarbor(); break;
        case STATE_EXPEDITION_DRIVING: HandleState_ExpeditionDriving(); break;
        case STATE_EXPLORATIONEXPEDITION_DRIVING: HandleState_ExplorationExpeditionDriving(); break;
        case STATE_TRANSPORT_DRIVING: HandleState_TransportDriving(); break;
        case STATE_SEAATTACK_DRIVINGTODESTINATION: HandleState_SeaAttackDriving(); break;
        case STATE_SEAATTACK_RETURN: HandleState_SeaAttackReturn(); break;
        default:
            break;
    }
}
Exemple #2
0
/// Sagt Bescheid, dass ein Schiffsangreifer nicht mehr mit nach Hause fahren will
void noShip::SeaAttackerWishesNoReturn()
{
    RTTR_Assert(remaining_sea_attackers);
    RTTR_Assert(state == STATE_SEAATTACK_WAITING);

    --remaining_sea_attackers;
    // Alle Soldaten an Bord
    if(remaining_sea_attackers == 0)
    {
        // Andere Events ggf. erstmal abmelden
        GetEvMgr().RemoveEvent(current_ev);
        if(!figures.empty())
        {
            // Go back home. Note: home_harbor can be 0 if it was destroyed, allow this and let the state handlers handle that case later
            goal_harborId = home_harbor;
            state = STATE_SEAATTACK_RETURN_DRIVING;
            StartDrivingToHarborPlace();
            HandleState_SeaAttackReturn();
        }
        else
        {
            // Wenn keine Soldaten mehr da sind können wir auch erstmal idlen
            StartIdling();
            gwg->GetPlayer(player).GetJobForShip(this);
        }
    }

}
Exemple #3
0
void noShip::Driven()
{
    MapPoint enemy_territory_discovered(MapPoint::Invalid());
    gwg->RecalcMovingVisibilities(pos, player, GetVisualRange(), GetCurMoveDir(), &enemy_territory_discovered);

    // Feindliches Territorium entdeckt?
    if(enemy_territory_discovered.isValid())
    {
        // Send message if necessary
        if(gwg->GetPlayer(player).ShipDiscoveredHostileTerritory(enemy_territory_discovered))
            SendPostMessage(player, new PostMsg(GetEvMgr().GetCurrentGF(), _("A ship disovered an enemy territory"), PostCategory::Military, enemy_territory_discovered));
    }

    switch(state)
    {
        case STATE_GOTOHARBOR: HandleState_GoToHarbor(); break;
        case STATE_EXPEDITION_DRIVING: HandleState_ExpeditionDriving(); break;
        case STATE_EXPLORATIONEXPEDITION_DRIVING: HandleState_ExplorationExpeditionDriving(); break;
        case STATE_TRANSPORT_DRIVING: HandleState_TransportDriving(); break;
        case STATE_SEAATTACK_DRIVINGTODESTINATION: HandleState_SeaAttackDriving(); break;
        case STATE_SEAATTACK_RETURN_DRIVING: HandleState_SeaAttackReturn(); break;
        default:
            RTTR_Assert(false);
            break;
    }
}
Exemple #4
0
void noShip::FindUnloadGoal(State newState)
{
    state = newState;
    // Das Schiff muss einen Notlandeplatz ansteuern
    // Neuen Hafen suchen
    if(gwg->GetPlayer(player).FindHarborForUnloading(this, pos, &goal_harborId, &route_, NULL))
    {
        curRouteIdx = 0;
        home_harbor = goal_harborId; // To allow unloading here
        if(state == STATE_EXPEDITION_DRIVING)
            HandleState_ExpeditionDriving();
        else if(state == STATE_TRANSPORT_DRIVING)
            HandleState_TransportDriving();
        else if(state == STATE_SEAATTACK_RETURN_DRIVING)
            HandleState_SeaAttackReturn();
        else
        {
            RTTR_Assert(false);
            LOG.write("Bug detected: Invalid state for FindUnloadGoal");
            FindUnloadGoal(STATE_TRANSPORT_DRIVING);
        }
    }
    else
    {
        // Ansonsten als verloren markieren, damit uns später Bescheid gesagt wird
        // wenn es einen neuen Hafen gibt
        home_harbor = goal_harborId = 0;
        lost = true;
    }
}
Exemple #5
0
void noShip::AbortSeaAttack()
{
    RTTR_Assert(state != STATE_SEAATTACK_WAITING); // figures are not aboard if this fails!
    RTTR_Assert(remaining_sea_attackers == 0); // Some soldiers are still not aboard

    if ((state == STATE_SEAATTACK_LOADING || state == STATE_SEAATTACK_DRIVINGTODESTINATION) &&
        goal_harborId != home_harbor && home_harbor != 0)
    {
        // We did not start the attack yet and we can (possibly) go back to our home harbor
        // -> tell the soldiers we go back (like after an attack)
        goal_harborId = home_harbor;
        for (std::list<noFigure*>::iterator it = figures.begin(); it != figures.end(); ++it)
        {
            RTTR_Assert(dynamic_cast<nofAttacker*>(*it));
            static_cast<nofAttacker*>(*it)->StartReturnViaShip(*this);
        }
        if(state == STATE_SEAATTACK_LOADING)
        {
            // We are still loading (loading event must be active)
            // -> Use it to unload
            RTTR_Assert(current_ev);
            state = STATE_SEAATTACK_UNLOADING;
        }else
        {
            // Else start driving back
            state = STATE_SEAATTACK_RETURN_DRIVING;
            HandleState_SeaAttackReturn();
        }
    }else
    {
        // attack failed and we cannot go back to our home harbor 
        // -> Tell figures that they won't go to their planned destination
        for (std::list<noFigure*>::iterator it = figures.begin(); it != figures.end(); ++it)
        {
            RTTR_Assert(dynamic_cast<nofAttacker*>(*it));
            static_cast<nofAttacker*>(*it)->CancelSeaAttack();
        }

        if (state == STATE_SEAATTACK_LOADING)
        {
            // Abort loading
            RTTR_Assert(current_ev);
            GetEvMgr().RemoveEvent(current_ev);
        }

        // Das Schiff muss einen Notlandeplatz ansteuern
        FindUnloadGoal(STATE_SEAATTACK_RETURN_DRIVING);
    }
}