Example #1
0
 //------------------------------------------------------------------------------
 void        TurnToAction::Execute (void)
 {
     IshipIGC*   pShip = static_cast<IshipIGC*> (static_cast<ImodelIGC*> (*m_pObject));
     ImodelIGC*  pTarget = static_cast<ImodelIGC*> (*m_pTarget);
     if (pShip && pTarget)
     {
         Vector      delta = pTarget->GetPosition () - pShip->GetPosition ();
         turnToFace (delta, GetWindow ()->GetDeltaTime (), pShip, &g_setInputControls);
         g_setInputControls.jsValues[c_axisYaw] *= 0.5f;
         g_setInputControls.jsValues[c_axisPitch] *= 0.5f;
         g_setInputControls.jsValues[c_axisRoll] *= 0.5f;
     }
     else
     {
         g_setInputControls.jsValues[c_axisYaw] = NA;
         g_setInputControls.jsValues[c_axisPitch] = NA;
         g_setInputControls.jsValues[c_axisRoll] = NA;
     }
 }
Example #2
0
//------------------------------------------------------------------------------
Goal*       Mission4::CreateGoal03 (void)
{
    GoalList*       pGoalList = new GoalList;
    ImissionIGC*    pMission = trekClient.GetCore ();
    BuoyID          buoyID = pMission->GenerateNewBuoyID ();
    IshipIGC*       pShip = trekClient.GetShip ();

    // tm_4_07
    // The last means of communication is to receive an order from
    // your commander. I'm giving you a command to go to a
    // waypoint.
    pGoalList->AddGoal (CreatePlaySoundGoal (tm_4_07Sound));

    // wait half second
    pGoalList->AddGoal (new Goal (new ElapsedTimeCondition (0.5f)));

    // tm_4_08
    // This red text denotes an objective from the commander.
    {
        Goal*   pGoal = CreatePlaySoundGoal (tm_4_08Sound);
        IwarpIGC*   pAleph = pMission->GetWarp (1030);
        Vector      delta = pAleph->GetPosition () - pShip->GetPosition ();
        Vector      position = pShip->GetPosition () + (delta * 0.25f) + (pAleph->GetOrientation ().GetUp () * (delta.Length () * 0.1f));
        pGoal->AddStartAction (new CreateWaypointAction (buoyID, position, 1030));
        pGoal->AddStartAction (new SetCommandAction (pShip, c_cmdQueued, OT_buoy, buoyID, c_cidGoto));
        //pGoal->AddStartAction (new SetHUDOverlayAction (CommandTrainingOverlay));
        pGoalList->AddGoal (pGoal);
    }

    // wait half second
    pGoalList->AddGoal (new Goal (new ElapsedTimeCondition (0.5f)));

    // tm_4_08r
    // Press the INSERT key to accept this objective.
    {
        Goal*   pGoal = new Goal (new GetCommandCondition (trekClient.GetShip (), c_cidGoto));
        pGoal->AddStartAction (new MessageAction ("Press the INSERT key to accept the command."));
        pGoal->AddStartAction (new PlaySoundAction (tm_4_08rSound));
        pGoal->AddConstraintCondition (CreateTooLongCondition (30.0f, tm_4_08rSound));
        pGoalList->AddGoal (pGoal);
    }

    // wait a few seconds
    pGoalList->AddGoal (new Goal (new ElapsedTimeCondition (1.5f)));

    // tm_4_09
    // Good. Notice that autopilot is activated when you accept an
    // objective to fly you to your goal.
    {
        Goal*   pGoal = CreatePlaySoundGoal (tm_4_09Sound);
        //pGoal->AddStartAction (new SetHUDOverlayAction (NoTrainingOverlay));
        pGoalList->AddGoal (pGoal);
    }

    // (Wait for ship to get near waypoint)
    {
        Goal*   pGoal = new Goal (new ObjectWithinRadiusCondition (static_cast<ImodelIGC*> (pShip), OT_buoy, buoyID, 100.0f));
        pGoal->AddConstraintCondition (new ConditionalAction (new TrueCondition, new SetAutopilotAction (trekClient.GetShip (), true)));
        pGoalList->AddGoal (pGoal);
    }

    return new Goal (pGoalList);
}