Beispiel #1
0
    //------------------------------------------------------------------------------
    Goal*       Mission5::CreateGoal03 (void)
    {
        GoalList*   pGoalList = new GoalList;

		// tm_5_12
		// Attention, Cadet, new contact: an enemy scout. In some 
		// cases, utility craft like miners will run home for 
		// protection, but you can tell them to hide by giving them 
		// orders to go to a base. You left-click the miners, then 
		// left-click the Go To command, and then right-click ÿ the 
		// base.
        {
            Goal*               pGoal = CreatePlaySoundGoal (tm_5_12Sound);
            IwarpIGC*           pAlephMars = trekClient.GetCore ()->GetWarp (1052);
            Orientation         alephMarsOrientation = pAlephMars->GetOrientation ();

            // create the enemy scout
            Vector              pos = pAlephMars->GetPosition () + (alephMarsOrientation.GetForward () * random (800.0f, 1200.0f)) + (alephMarsOrientation.GetRight () * random(-100.0f, 200.0f));
            CreateDroneAction*  pCreateDroneAction = new CreateDroneAction ("Enemy Scout", m_enemyScoutID, 310, 1, c_ptWingman);
            pCreateDroneAction->SetCreatedLocation (GetStartSectorID () + 1, pos);
            pGoal->AddStartAction (pCreateDroneAction);

            // tell the enemy scout of these guys to do nothing
            pGoal->AddStartAction (new SetCommandAction (m_enemyScoutID, c_cmdAccepted, NULL, c_cidDoNothing));
            pGoal->AddStartAction (new SetCommandAction (m_enemyScoutID, c_cmdCurrent, NULL, c_cidDoNothing));

            // set its signature to infinity
            pGoal->AddStartAction (new SetSignatureAction (OT_ship, m_enemyScoutID, 1.0e6f));
            pGoalList->AddGoal (pGoal);
        }

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

		// tm_5_13
		// Most enemy ships can be considered a threat to your miners 
		// unless you have plenty of defending pilots ? which you 
		// don?t. So let's get those miners to shelter ? send all 
		// three of them to the base.
        pGoalList->AddGoal (CreatePlaySoundGoal (tm_5_13Sound));

		// tm_5_13r
		// Send all three of your miners to base for safety.
        {
            Condition*  pAndConditionA = new AndCondition (new GetCommandCondition (m_miner2ID, c_cidGoto), new GetCommandCondition (m_miner3ID, c_cidGoto));
            Condition*  pConditionB = new GetCommandCondition (m_miner4ID, c_cidGoto);
            Goal*       pGoal = new Goal (new AndCondition (pAndConditionA, pConditionB));
            pGoal->AddStartAction (new MessageAction ("Order all three miners back to base for safety."));
            pGoal->AddConstraintCondition (CreateTooLongCondition (30.0f, tm_5_13rSound));
            pGoalList->AddGoal (pGoal);
        }

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

		// tm_5_14
		// Good! Utility ships like miners and constructors are 
		// drones. They will always accept your orders.
        pGoalList->AddGoal (CreatePlaySoundGoal (tm_5_14Sound));

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

        return new Goal (pGoalList);
    }
HRESULT CprobeIGC::Initialize(ImissionIGC* pMission, Time now, const void* data, int dataSize)
{
    assert (pMission);
    m_pMission = pMission;

    ZRetailAssert (data && (dataSize > sizeof(DataProbeBase)));
    {
        DataProbeBase*  dataProbeBase = (DataProbeBase*)data;

        if ((dataProbeBase->exportF) && 
            ((DataProbeExport*)dataProbeBase)->createNow)
        {
            m_time0 = now;
        }
        else
        {
            m_time0 = pMission->GetIgcSite()->ClientTimeFromServerTime(dataProbeBase->time0);
        }
        TmodelIGC<IprobeIGC>::Initialize(pMission, now, data, dataSize);

        IshipIGC*       pshipLauncher;
        IsideIGC*       pside;
        IclusterIGC*    pcluster;
        if (dataProbeBase->exportF)
        {
            assert (dataSize == sizeof(DataProbeExport));

            DataProbeExport* dataProbeExport = (DataProbeExport*)dataProbeBase;

            m_probeType = (IprobeTypeIGC*)(pMission->GetExpendableType(dataProbeExport->probetypeID));
            pside = pMission->GetSide(dataProbeExport->sideID);
            pcluster = pMission->GetCluster(dataProbeExport->clusterID);

            pshipLauncher = pside->GetShip(dataProbeExport->shipID);

            if (m_probeType->HasCapability(c_eabmShootOnlyTarget))
                m_target = pMission->GetModel(dataProbeExport->otTarget, dataProbeExport->oidTarget);
        }
        else
        {
            assert (dataSize == sizeof(DataProbeIGC));

            DataProbeIGC*    dataProbe = (DataProbeIGC*)dataProbeBase;

            m_probeType = dataProbe->pprobetype;
            pside = dataProbe->pside;
            pcluster = dataProbe->pcluster;

            pshipLauncher = dataProbe->pship;

            if (m_probeType->HasCapability(c_eabmShootOnlyTarget))
                m_target = dataProbe->pmodelTarget;
        }

        assert (m_probeType);
        assert (m_probeType->GetObjectType() == OT_probeType);
        m_probeType->AddRef();

        m_ammo = m_probeType->GetAmmo();

        DataProbeTypeIGC*  dataProbeType = (DataProbeTypeIGC*)(m_probeType->GetData());
        m_projectileType = m_probeType->GetProjectileType();
        if (m_projectileType)
        {
            m_projectileType->AddRef();
            m_bSeenByAll = false;

            if (pshipLauncher && (dataProbeType->launcherDef.price == 0))
                m_launcher = pshipLauncher;
        }

        assert (pcluster);

        //Load the model for the probe
        assert (iswalpha(dataProbeType->modelName[0]));
        HRESULT hr = Load(0, dataProbeType->modelName,
                          dataProbeType->textureName,
                          dataProbeType->iconName, 
                          c_mtDamagable | c_mtHitable | c_mtStatic | c_mtSeenBySide | c_mtPredictable | c_mtScanner);
        assert (SUCCEEDED(hr));

        SetRadius(dataProbeType->radius);
        SetSignature(dataProbeType->signature);
        SetSide(pside);

        SetSecondaryName(dataProbeType->launcherDef.name);

        {
            //Parts get a random orientation
            Vector  v = Vector::RandomDirection();
            Orientation o(v);
            SetOrientation(o);
        }

        //lifespan == 0 => immortal probe that can hit until it gets terminated on the next update; this is bad
        assert (dataProbeType->lifespan > 0.0f);
        m_timeExpire = m_time0 + dataProbeType->lifespan;
        assert (m_timeExpire != m_time0);


        m_nextFire = m_time0 + (m_probeType->HasCapability(c_eabmQuickReady)
                                ? 5.0f        //5 second delay
                                : 30.0f);     //30 second delay before we start to shoot

        assert (GetSide());
        SetMass(0.0f);

        m_probeID = dataProbeBase->probeID;

        SetPosition(dataProbeBase->p0);
        SetCluster(pcluster);

        pMission->AddProbe(this);

        if ((dataProbeType->dtRipcord >= 0.0f) && ((GetMyLastUpdate() - m_time0) >= dataProbeType->dtRipcord))
        {
            pMission->GetIgcSite()->ActivateTeleportProbe(this);
        }
		// mmf 04/08 destroy any probe near aleph (warp) tip as this is viewed as an exploit as the enemy 
		//           often cannot delete it
		// 
		// if (experimental game type) mmf
		const MissionParams* pmp = pMission->GetMissionParams();

		if (pmp->bExperimental) {
			Vector dV, probeV, warpV, tipdistV;
			Vector bV, tipV;
			float warp_rad, distance;
			Orientation warp_orient;
			Rotation warp_rot;
			// loop through list of warps
            for (WarpLinkIGC*   pwl = pcluster->GetWarps()->first(); (pwl != NULL); pwl = pwl->next())
                {
					IwarpIGC*   pwarp = pwl->data();
					warp_rad = pwarp->GetRadius();
					warp_orient = pwarp->GetOrientation();
					warpV = pwarp->GetPosition();
					probeV = this->GetPosition();
					dV= warpV-probeV;
					distance = dV.Length();
					warp_rot = pwarp->GetRotation();

					// if rotating (i.e. rotation is other than 0 0 1 0) abort check
					if (!((warp_rot.x()==0) && (warp_rot.y()==0) && (warp_rot.z()==1) && (warp_rot.angle()==0)))
						break;
					if (distance < (warp_rad * 2) ) {  // only check if close to tip if reasonably close to warp center
						bV = warp_orient.GetBackward();
						tipV = warpV + (bV*warp_rad);
						tipdistV = tipV-probeV;
						distance = tipdistV.Length();
						if (distance < 30) {
							debugf("Destroying probe as it was dropped too close (within 30) of aleph(warp) tip. dist = $f\n",distance);
							return S_FALSE; // this will destroy the probe
						}
					}
				}
		}		
		// mmf end	

		// mmf added code to detect tp drop near asteroid and if too close destroy it
		//     leave ActivateTeleProbe code above so enemy is alerted to the drop even though it may be destroyed
		if (dataProbeType->dtRipcord >= 0.0f)  // check to see if this is a teleprobe
		{
			Vector dV;
			float asteroid_rad, distance;
			// loop through list of asteroids
            for (AsteroidLinkIGC*   pal = pcluster->GetAsteroids()->first(); (pal != NULL); pal = pal->next())
                {
                    asteroid_rad = (pal->data()->GetRadius());
                    dV=this->GetPosition() - pal->data()->GetPosition();
					distance = dV.Length();
					if (distance < (asteroid_rad-5)) {
						debugf("Teleprobe dropped too close to asteroid (within -5) destroying probe. dist = %f, asteroid rad = %f\n",
							distance,asteroid_rad);
						// this->Terminate(); should be terminated when missionigc processes S_FALSE
						return S_FALSE; 
					}
				}
		}		
		// mmf end	
	}

    return S_OK;
}
Beispiel #3
0
    //------------------------------------------------------------------------------
    Condition*  Mission5::CreateMission (void)
    {
        GoalList*           pGoalList = new GoalList;
        Goal*               pGoal = new Goal (pGoalList);
        ImissionIGC*        pMission = trekClient.GetCore ();
        IstationIGC*        pStationNeptune = pMission->GetStation (1050);
        IstationIGC*        pStationMars = pMission->GetStation (1052);
        IwarpIGC*           pAlephNeptune = pMission->GetWarp (1050);
        IwarpIGC*           pAlephMars = pMission->GetWarp (1052);

        // generate ship ids that we'll be using throughout the mission
        m_enemyScoutID = pMission->GenerateNewShipID ();
        m_miner1ID = pMission->GenerateNewShipID ();
        m_miner2ID = pMission->GenerateNewShipID ();
        m_miner3ID = pMission->GenerateNewShipID ();
        m_miner4ID = pMission->GenerateNewShipID ();
        m_scoutID = pMission->GenerateNewShipID ();
        m_builder1ID = pMission->GenerateNewShipID ();
        m_builder2ID = pMission->GenerateNewShipID ();
        m_builder3ID = pMission->GenerateNewShipID ();

        // add the goals to the list
        pGoalList->AddGoal (CreateGoal01 ());
        pGoalList->AddGoal (CreateGoal02 ());
        pGoalList->AddGoal (CreateGoal03 ());
        pGoalList->AddGoal (CreateGoal04 ());
        pGoalList->AddGoal (CreateGoal05 ());

        // create the tower builder drones
        Vector              pos = pStationNeptune->GetPosition () + Vector (random(-300.0f, 300.0f), random(-300.0f, 300.0f), random(-300.0f, 300.0f));
        CreateDroneAction*  pCreateDroneAction = new CreateDroneAction ("Tower Layer 01", m_builder1ID, 418, 0, c_ptLayer);
        pCreateDroneAction->SetExpendableType (431);
        pCreateDroneAction->SetCreatedLocation (GetStartSectorID (), pos);
        pGoal->AddStartAction (pCreateDroneAction);

		pos = pStationNeptune->GetPosition () + Vector (random(-300.0f, 300.0f), random(-300.0f, 300.0f), random(-300.0f, 300.0f));
		pCreateDroneAction = new CreateDroneAction ("Tower Layer 02", m_builder2ID, 418, 0, c_ptLayer);
        pCreateDroneAction->SetExpendableType (431);
        pCreateDroneAction->SetCreatedLocation (GetStartSectorID (), pos);
        pGoal->AddStartAction (pCreateDroneAction);

        pos = pStationNeptune->GetPosition () + Vector (random(-300.0f, 300.0f), random(-300.0f, 300.0f), random(-300.0f, 300.0f));
        pCreateDroneAction = new CreateDroneAction ("Tower Layer 03", m_builder3ID, 418, 0, c_ptLayer);
        pCreateDroneAction->SetExpendableType (431);
        pCreateDroneAction->SetCreatedLocation (GetStartSectorID (), pos);
        pGoal->AddStartAction (pCreateDroneAction);

        // create the miners
        pos = pStationNeptune->GetPosition () + Vector (random(-600.0f, 600.0f), random(-600.0f, 600.0f), random(-300.0f, 300.0f));
        pCreateDroneAction = new CreateDroneAction ("Miner 01", m_miner1ID, 438, 0, c_ptMiner);
        pCreateDroneAction->SetCreatedLocation (GetStartSectorID (), pos);
        pGoal->AddStartAction (pCreateDroneAction);

        pos = pStationMars->GetPosition () + Vector (random(-600.0f, 600.0f), random(-600.0f, 600.0f), random(-300.0f, 300.0f));
        pCreateDroneAction = new CreateDroneAction ("Miner 02", m_miner2ID, 438, 0, c_ptMiner);
        pCreateDroneAction->SetCreatedLocation (GetStartSectorID () + 1, pos);
        pGoal->AddStartAction (pCreateDroneAction);

        pos = pStationMars->GetPosition () + Vector (random(-600.0f, 600.0f), random(-600.0f, 600.0f), random(-300.0f, 300.0f));
        pCreateDroneAction = new CreateDroneAction ("Miner 03", m_miner3ID, 438, 0, c_ptMiner);
        pCreateDroneAction->SetCreatedLocation (GetStartSectorID () + 1, pos);
        pGoal->AddStartAction (pCreateDroneAction);

        pos = pStationMars->GetPosition () + Vector (random(-600.0f, 600.0f), random(-600.0f, 600.0f), random(-300.0f, 300.0f));
        pCreateDroneAction = new CreateDroneAction ("Miner 04", m_miner4ID, 438, 0, c_ptMiner);
        pCreateDroneAction->SetCreatedLocation (GetStartSectorID () + 1, pos);
        pGoal->AddStartAction (pCreateDroneAction);

        // create the scout
        pos = pStationMars->GetPosition () + ((pAlephMars->GetPosition () - pStationMars->GetPosition ()) * random (0.5f, 0.75f));
        pCreateDroneAction = new CreateDroneAction ("Stealth Fighter", m_scoutID, 411, 0, c_ptWingman);
        pCreateDroneAction->SetCreatedLocation (GetStartSectorID () + 1, pos);
        pGoal->AddStartAction (pCreateDroneAction);

        // tell all of these guys to do nothing
        pGoal->AddStartAction (new SetCommandAction (m_scoutID, c_cmdAccepted, NULL, c_cidDoNothing));
        pGoal->AddStartAction (new SetCommandAction (m_scoutID, c_cmdCurrent, NULL, c_cidDoNothing));

        pGoal->AddStartAction (new SetCommandAction (m_miner2ID, c_cmdAccepted, NULL, c_cidDoNothing));
        pGoal->AddStartAction (new SetCommandAction (m_miner2ID, c_cmdCurrent, NULL, c_cidDoNothing));

        pGoal->AddStartAction (new SetCommandAction (m_miner3ID, c_cmdAccepted, NULL, c_cidDoNothing));
        pGoal->AddStartAction (new SetCommandAction (m_miner3ID, c_cmdCurrent, NULL, c_cidDoNothing));

        pGoal->AddStartAction (new SetCommandAction (m_miner4ID, c_cmdAccepted, NULL, c_cidDoNothing));
        pGoal->AddStartAction (new SetCommandAction (m_miner4ID, c_cmdCurrent, NULL, c_cidDoNothing));

        pGoal->AddStartAction (new SetCommandAction (m_builder1ID, c_cmdAccepted, NULL, c_cidDoNothing));
        pGoal->AddStartAction (new SetCommandAction (m_builder1ID, c_cmdCurrent, NULL, c_cidDoNothing));

        pGoal->AddStartAction (new SetCommandAction (m_builder2ID, c_cmdAccepted, NULL, c_cidDoNothing));
        pGoal->AddStartAction (new SetCommandAction (m_builder2ID, c_cmdCurrent, NULL, c_cidDoNothing));

        pGoal->AddStartAction (new SetCommandAction (m_builder3ID, c_cmdAccepted, NULL, c_cidDoNothing));
        pGoal->AddStartAction (new SetCommandAction (m_builder3ID, c_cmdCurrent, NULL, c_cidDoNothing));

        return pGoal;
    }
Beispiel #4
0
//------------------------------------------------------------------------------
Goal*       Mission4::CreateGoal08 (void)
{
    GoalList*   pGoalList = new GoalList;

    // tm_4_31
    // Excellent work, Cadet! It looks like the other enemy miners
    // are running now. I'm ordering a constructor into this
    // sector to build a station here.
    {
        Goal*               pGoal = CreatePlaySoundGoal (tm_4_31Sound);

        // create the friendly builder
        IwarpIGC*           pAleph = trekClient.GetCore ()->GetWarp (1030);
        Vector              pos = pAleph->GetPosition () + (pAleph->GetOrientation ().GetForward () * 100.0f);
        CreateDroneAction*  pCreateDroneAction = new CreateDroneAction ("Constructor", m_builderID, 419, 0, c_ptBuilder);
        pCreateDroneAction->SetCreatedLocation (1030, pos);
        pCreateDroneAction->SetStationType (112);
        pGoal->AddStartAction (pCreateDroneAction);

        // command the builder to go to the asteroid on which it will build
        pGoal->AddStartAction (new SetCommandAction (m_builderID, c_cmdCurrent, OT_asteroid, static_cast<ObjectID>(10332), c_cidBuild));
        pGoal->AddStartAction (new SetCommandAction (m_builderID, c_cmdAccepted, OT_asteroid, static_cast<ObjectID>(10332), c_cidBuild));

        // create a waypoint for all of the miners to run to, and send them all there
        BuoyID              buoyID = trekClient.GetCore ()->GenerateNewBuoyID ();
        pGoal->AddStartAction (new CreateWaypointAction (buoyID, Vector (1000.0f, 1000.0f, 1000.0f), 1032));
        pGoal->AddStartAction (new SetCommandAction (m_enemyMiner1ID, c_cmdCurrent, OT_buoy, buoyID, c_cidGoto));
        pGoal->AddStartAction (new SetCommandAction (m_enemyMiner1ID, c_cmdAccepted, OT_buoy, buoyID, c_cidGoto));
        pGoal->AddStartAction (new SetCommandAction (m_enemyMiner2ID, c_cmdCurrent, OT_buoy, buoyID, c_cidGoto));
        pGoal->AddStartAction (new SetCommandAction (m_enemyMiner2ID, c_cmdAccepted, OT_buoy, buoyID, c_cidGoto));
        pGoal->AddStartAction (new SetCommandAction (m_enemyMiner3ID, c_cmdCurrent, OT_buoy, buoyID, c_cidGoto));
        pGoal->AddStartAction (new SetCommandAction (m_enemyMiner3ID, c_cmdAccepted, OT_buoy, buoyID, c_cidGoto));
        pGoal->AddStartAction (new SetCommandAction (m_enemyMiner4ID, c_cmdCurrent, OT_buoy, buoyID, c_cidGoto));
        pGoal->AddStartAction (new SetCommandAction (m_enemyMiner4ID, c_cmdAccepted, OT_buoy, buoyID, c_cidGoto));

        // clear the player command set
        pGoal->AddStartAction (new SetCommandAction (trekClient.GetShip (), c_cmdCurrent, NA, NA, c_cidDoNothing));
        pGoal->AddStartAction (new SetCommandAction (trekClient.GetShip (), c_cmdAccepted, NA, NA, c_cidDoNothing));

        pGoalList->AddGoal (pGoal);
    }

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

    // tm_4_32
    // I'm moving your ship around to protect the constructor.
    // Stay near it in case an enemy fighter comes in.
    // Constructors are very expensive, and we don't want to lose
    // it.
    {
        Goal*               pGoal = new Goal (new GetCommandCondition (trekClient.GetShip (), c_cidGoto));
        pGoal->AddStartAction (new SetCommandAction (trekClient.GetShip (), c_cmdQueued, OT_ship, m_builderID, c_cidGoto));
        pGoal->AddStartAction (new MessageAction ("Press the INSERT key to accept the command."));
        pGoal->AddStartAction (new PlaySoundAction (tm_4_32Sound));
        pGoal->AddConstraintCondition (CreateTooLongCondition (30.0f, tm_4_08rSound));
        pGoalList->AddGoal (pGoal);
    }

    // (Wait for enemy scout to get within range)
    {
        Goal*               pGoal = new Goal (new ObjectWithinRadiusCondition (trekClient.GetShip (), OT_ship, m_enemyScoutID, 1500.0f));
        Vector              pos (random(-300.0f, 300.0f), random(-300.0f, 300.0f), random(-300.0f, 300.0f));
        CreateDroneAction*  pCreateDroneAction = new CreateDroneAction ("Enemy Scout", m_enemyScoutID, 310, 1, c_ptWingman);
        pCreateDroneAction->SetCreatedLocation (1031, pos);
        pGoal->AddStartAction (pCreateDroneAction);
        pGoal->AddStartAction (new SetCommandAction (m_enemyScoutID, c_cmdCurrent, trekClient.GetShip (), c_cidAttack));
        pGoal->AddStartAction (new SetCommandAction (m_enemyScoutID, c_cmdAccepted, trekClient.GetShip (), c_cidAttack));
        pGoalList->AddGoal (pGoal);
    }

    // tm_4_33
    // Enemy scout detected! Intercept it!
    {
        Goal*               pGoal = new Goal (new GetCommandCondition (trekClient.GetShip (), c_cidAttack));
        pGoal->AddStartAction (new SetCommandAction (m_builderID, c_cmdCurrent, NA, NA, c_cidDoNothing));
        pGoal->AddStartAction (new SetCommandAction (m_builderID, c_cmdAccepted, NA, NA, c_cidDoNothing));
        pGoal->AddStartAction (new SetCommandAction (trekClient.GetShip (), c_cmdQueued, OT_ship, m_enemyScoutID, c_cidAttack));
        pGoal->AddStartAction (new MessageAction ("Press the INSERT key to accept the command."));
        pGoal->AddStartAction (new PlaySoundAction (tm_4_33Sound));
        pGoal->AddConstraintCondition (CreateTooLongCondition (30.0f, tm_4_33Sound));
        pGoalList->AddGoal (pGoal);
    }

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

    // tm_4_33r
    // Stop the scout from destroying the builder.
    {
        Goal*   pGoal = new Goal (new GetCommandCondition (m_enemyScoutID, c_cidGoto));
        pGoal->AddStartAction (new PlaySoundAction (tm_4_33rSound));
        pGoal->AddConstraintCondition (CreateTooLongCondition (45.0f, tm_4_33rSound));
        pGoalList->AddGoal (pGoal);
    }

    // wait half second
    {
        Goal*   pGoal = new Goal (new ElapsedTimeCondition (0.5f));

        // clear the player command set
        pGoal->AddStartAction (new SetCommandAction (trekClient.GetShip (), c_cmdCurrent, NA, NA, c_cidDoNothing));
        pGoal->AddStartAction (new SetCommandAction (trekClient.GetShip (), c_cmdAccepted, NA, NA, c_cidDoNothing));
        pGoalList->AddGoal (pGoal);
    }

    {
        Goal*   pGoal = new Goal (pGoalList);

        // show the eyeball if it is appropriate
        ObjectID            shipID = trekClient.GetShip ()->GetObjectID ();
        Condition*          pOrConditionA = new OrCondition (new ShipSeesObjectCondition (m_enemyMiner1ID, OT_ship, shipID), new ShipSeesObjectCondition (m_enemyMiner2ID, OT_ship, shipID));
        Condition*          pOrConditionB = new OrCondition (new ShipSeesObjectCondition (m_enemyMiner3ID, OT_ship, shipID), new ShipSeesObjectCondition (m_enemyMiner4ID, OT_ship, shipID));
        Condition*          pSeesCondition = new OrCondition (new OrCondition (pOrConditionA, pOrConditionB), new ShipSeesObjectCondition (m_enemyScoutID, OT_ship, shipID));
        pGoal->AddConstraintCondition (new ConditionalAction (pSeesCondition, new ShowEyeballAction (true)));
        pGoal->AddConstraintCondition (new ConditionalAction (new NotCondition (new ProxyCondition (pSeesCondition)), new ShowEyeballAction (false)));

        return pGoal;
    }
}
Beispiel #5
0
//------------------------------------------------------------------------------
Goal*       Mission4::CreateGoal05 (void)
{
    GoalList*   pGoalList = new GoalList;

    // tm_4_16
    // Excellent!
    pGoalList->AddGoal (CreatePlaySoundGoal (tm_4_16Sound));

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

    // tm_4_17
    // I'm enabling your controls. You can disengage autopilot by
    // moving your joystick.
    {
        Goal*   pGoal = CreatePlaySoundGoal (tm_4_17Sound);
        SetControlConstraintsAction*    pSetControlConstraintsAction = new SetControlConstraintsAction;
        pSetControlConstraintsAction->EnableInputAction (0xffffffff);
        pSetControlConstraintsAction->ScaleInputControl (c_axisYaw, 1.0f);
        pSetControlConstraintsAction->ScaleInputControl (c_axisPitch, 1.0f);
        pSetControlConstraintsAction->ScaleInputControl (c_axisRoll, 1.0f);
        pSetControlConstraintsAction->ScaleInputControl (c_axisThrottle, 1.0f);
        pGoal->AddStartAction (pSetControlConstraintsAction);
        pGoalList->AddGoal (pGoal);
    }

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

    // tm_4_17r
    // Go ahead and fly to the highlighted aleph. The aleph looks
    // like a whirlpool in space. It's a big swirling brown vortex,
    // with a bright spot in the center.
    {
        Goal*   pGoal = new Goal (new ObjectWithinRadiusCondition (static_cast<ImodelIGC*> (trekClient.GetShip ()), OT_warp, 1030, 750.0f));
        pGoal->AddStartAction (new MessageAction ("Fly to the aleph named 'Mars'."));
        pGoal->AddStartAction (new PlaySoundAction (tm_4_17rSound));
        pGoal->AddConstraintCondition (CreateTooLongCondition (60.0f, tm_4_17rSound));
        pGoalList->AddGoal (pGoal);
    }

    // tm_4_18
    // All right, see the aleph? It's right in front of us. I'm
    // going to fly us directly into it.
    {
        Goal*   pGoal = CreatePlaySoundGoal (tm_4_18Sound);
        pGoal->AddStartAction (new MessageAction ("Flying through the aleph to sector 'Mars'..."));
        // pkk - Disable controls, so can AP take over flying into aleph (mission will not hang)
        SetControlConstraintsAction*    pSetControlConstraintsAction = new SetControlConstraintsAction;
        pSetControlConstraintsAction->DisableInputAction (0xffffffff);
        pSetControlConstraintsAction->ScaleInputControl (c_axisYaw, 0.0f);
        pSetControlConstraintsAction->ScaleInputControl (c_axisPitch, 0.0f);
        pSetControlConstraintsAction->ScaleInputControl (c_axisRoll, 0.0f);
        pSetControlConstraintsAction->ScaleInputControl (c_axisThrottle, 0.0f);
        pGoal->AddStartAction (pSetControlConstraintsAction);
        TurnToAction*           pTurnToAction = new TurnToAction (trekClient.GetShip (), OT_warp, 1030);
        ConditionalAction*      pConditionalAction = new ConditionalAction (new TrueCondition, pTurnToAction);
        pGoal->AddConstraintCondition (pConditionalAction);
        pGoalList->AddGoal (pGoal);
    }

    // (Wait for sector change)
    {
        Goal*   pGoal = new Goal (new GetSectorCondition (trekClient.GetShip (), 1031));

        // turn the throttle to 0.5 to insure that they fly through
        SetControlsAction*  pSetControlsAction = new SetControlsAction;
        pSetControlsAction->SetInputControl (c_axisThrottle, 0.5f);
        pGoal->AddConstraintCondition (new ConditionalAction (new TrueCondition, pSetControlsAction));

        // create the enemy miners
        IwarpIGC*   pAleph = trekClient.GetCore ()->GetWarp (1032);
        {
            Vector              pos = pAleph->GetPosition () + Vector (random(-300.0f, 300.0f), random(-300.0f, 300.0f), random(-300.0f, 300.0f));
            CreateDroneAction*  pCreateDroneAction = new CreateDroneAction ("Enemy Miner 01", m_enemyMiner1ID, 338, 1, c_ptMiner);
            pCreateDroneAction->SetCreatedLocation (1031, pos);
            pGoal->AddStartAction (pCreateDroneAction);
        }

        {
            Vector              pos = pAleph->GetPosition () + Vector (random(-300.0f, 300.0f), random(-300.0f, 300.0f), random(-300.0f, 300.0f));
            CreateDroneAction*  pCreateDroneAction = new CreateDroneAction ("Enemy Miner 02", m_enemyMiner2ID, 338, 1, c_ptMiner);
            pCreateDroneAction->SetCreatedLocation (1031, pos);
            pGoal->AddStartAction (pCreateDroneAction);
        }

        {
            Vector              pos = pAleph->GetPosition () + Vector (random(-300.0f, 300.0f), random(-300.0f, 300.0f), random(-300.0f, 300.0f));
            CreateDroneAction*  pCreateDroneAction = new CreateDroneAction ("Enemy Miner 03", m_enemyMiner3ID, 338, 1, c_ptMiner);
            pCreateDroneAction->SetCreatedLocation (1031, pos);
            pGoal->AddStartAction (pCreateDroneAction);
        }

        {
            Vector              pos = pAleph->GetPosition () + Vector (random(-300.0f, 300.0f), random(-300.0f, 300.0f), random(-300.0f, 300.0f));
            CreateDroneAction*  pCreateDroneAction = new CreateDroneAction ("Enemy Miner 04", m_enemyMiner4ID, 338, 1, c_ptMiner);
            pCreateDroneAction->SetCreatedLocation (1031, pos);
            pGoal->AddStartAction (pCreateDroneAction);
        }

        // set the signature on all those enemy craft to something ridiculous
        pGoal->AddStartAction (new SetSignatureAction (OT_ship, m_enemyMiner1ID, 1.0e6));
        pGoal->AddStartAction (new SetSignatureAction (OT_ship, m_enemyMiner2ID, 1.0e6));
        pGoal->AddStartAction (new SetSignatureAction (OT_ship, m_enemyMiner3ID, 1.0e6));
        pGoal->AddStartAction (new SetSignatureAction (OT_ship, m_enemyMiner4ID, 1.0e6));

        // tell them all to do nothing for a little while
        pGoal->AddStartAction (new SetCommandAction (m_enemyMiner1ID, c_cmdAccepted, NULL, c_cidDoNothing));
        pGoal->AddStartAction (new SetCommandAction (m_enemyMiner1ID, c_cmdCurrent, NULL, c_cidDoNothing));

        pGoal->AddStartAction (new SetCommandAction (m_enemyMiner2ID, c_cmdAccepted, NULL, c_cidDoNothing));
        pGoal->AddStartAction (new SetCommandAction (m_enemyMiner2ID, c_cmdCurrent, NULL, c_cidDoNothing));

        pGoal->AddStartAction (new SetCommandAction (m_enemyMiner3ID, c_cmdAccepted, NULL, c_cidDoNothing));
        pGoal->AddStartAction (new SetCommandAction (m_enemyMiner3ID, c_cmdCurrent, NULL, c_cidDoNothing));

        pGoal->AddStartAction (new SetCommandAction (m_enemyMiner4ID, c_cmdAccepted, NULL, c_cidDoNothing));
        pGoal->AddStartAction (new SetCommandAction (m_enemyMiner4ID, c_cmdCurrent, NULL, c_cidDoNothing));

        pGoalList->AddGoal (pGoal);
    }

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

    // tm_4_19
    // Amazing. Millions of kilometers in the blink of an eye.
    // Here we are in sector Mars.
    {
        Goal*           pGoal = CreatePlaySoundGoal (tm_4_19Sound);
        pGoal->AddStartAction (new SetControlsAction);
        SetControlsAction*              pSetControlsAction = new SetControlsAction;
        SetControlConstraintsAction*    pSetControlConstraintsAction = new SetControlConstraintsAction;
        pSetControlConstraintsAction->DisableInputAction (0xffffffff);
        // pkk - Allow ship to turn again
        pSetControlConstraintsAction->ScaleInputControl (c_axisYaw, 1.0f);
        pSetControlConstraintsAction->ScaleInputControl (c_axisPitch, 1.0f);
        pSetControlConstraintsAction->ScaleInputControl (c_axisRoll, 1.0f);
        pSetControlConstraintsAction->ScaleInputControl (c_axisThrottle, 0.0f);
        GetWindow()->SetTarget(trekClient.GetShip(), c_cidNone); // pkk - Target nothing
        pGoal->AddStartAction (pSetControlsAction);
        pGoal->AddStartAction (pSetControlConstraintsAction);
        pGoal->AddStartAction (new ShowPaneAction (ofSectorPane));
        pGoal->AddStartAction (new SetHUDOverlayAction (SectorTrainingOverlay));
        pGoalList->AddGoal (pGoal);
    }

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

    return new Goal (pGoalList);
}
Beispiel #6
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);
}
void CFSShip::HitWarp(IwarpIGC * pwarp)
{
    //Ignore jumps that happen too closely together
    if (m_warpState == warpReady)
    {
		// Andon - Added check for aleph mass limits
		if (m_pShip->GetMass() <= pwarp->MassLimit() || !IsPlayer() && pwarp->MassLimit() > 0 || pwarp->MassLimit() < 0)
		{
			if (IsPlayer())
			{
				m_warpState = warpNoUpdate;
			}

			IwarpIGC *    pwarpDest    = pwarp->GetDestination();
			assert (pwarpDest);
			IclusterIGC * pclusterDest = pwarpDest->GetCluster();

			ShipStatusWarped(pwarp);

			Orientation alephOrientation = pwarpDest->GetOrientation();
			const Vector&   v = m_pShip->GetVelocity();
			float           speed2 = v.LengthSquared();
			float           speed  = float(sqrt(speed2));
			if (speed2 > 0)
			{
			  float           error;
			  {
				  //How close is the ship coming to the center of the warp?
				  Vector          dp = pwarp->GetPosition() - m_pShip->GetPosition();

				  float   t = (dp * v) / speed2;
				  float   d = (dp - t * v).LengthSquared();
				  float   r = pwarp->GetRadius();

				  error = (d / (r*r)) + 0.125f;      //Error ranges from 0.125 to 1.125
				  // yp: to prevent 'spin of death' in massive ships.
				  // This works and is explained in that the more massive the ship the less effect going through the aleph should have
				  // on its rotational velocity. The massive amount of inertia should decrease changes in rotational velocity.
				  if(m_pShip->GetMass() > 300.0f)
				  {
					error = error * (300.0f / m_pShip->GetMass()); // the greater the mass is above 750 the less error will be applied.
				  }
				  // yp end
			  }

			  alephOrientation.Pitch(random(-error, error));
			  alephOrientation.Yaw(random(-error, error));

			  m_pShip->SetCurrentTurnRate(c_axisRoll,
										  m_pShip->GetCurrentTurnRate(c_axisRoll) +
										  random(pi * 0.5f * error, pi * 1.5f * error));  //Must be less than 2.0 * pi
			}
			m_pShip->SetOrientation(alephOrientation);
			const Vector&   backward = alephOrientation.GetBackward();

			speed = -(speed + pwarp->GetMission()->GetFloatConstant(c_fcidExitWarpSpeed));
			m_pShip->SetVelocity(backward * speed);

			m_pShip->SetPosition(pwarpDest->GetPosition() +
								 (alephOrientation.GetUp() * random(2.0f, 5.0f)) +
								 (alephOrientation.GetRight() * random(2.0f, 5.0f)) -
								 (m_pShip->GetRadius() + 5.0f) * backward);

			GetIGCShip()->SetCluster(pclusterDest);
		}
    }
}