Victory and Defeat - You Have Done Well. Our Colony Is Doomed.
I've already shown you the standard LoS victory trigger, so let's just use that.
int InitProc()
{
// Code from previous lessons
Trigger trig; // Create a trigger variable. If you don't know what that means, don't worry about it.
trig = CreateOnePlayerLeftTrigger(1, 0, "NoResponseToTrigger"); // NoResponseToTrigger is a generic catch-all function that does nothing when invoked
CreateVictoryCondition(1, 0, trig, "Eliminate your opponents."); // Use that trigger to create a victory condition
}
Let's look at CreateVictoryCondition.
CreateVictoryCondition(1, 0, Trigger To Use, "Text");
The first option is enabled/disabled. There's no point making a disabled victory condition, so this will always be 1.
The second option is "must always be zero".
Next is the trigger we want to use. We created that trigger variable (trig) so OP2 could remember which trigger we wanted the victory condition to use.
Text is the text that gets displayed in the Mission Objectives list.
Creating a failure condition is the exact same thing. The only difference is the Text portion isn't used by OP2 (but you still have to type something in, so just write whatever). I usually write what conditions result in failure.
However, failure conditions aren't recommended for multiplayer maps for two reasons.
1) OP2 automatically fails all losing players as soon as another player or team achieves victory.
2) If only one player fails and the others are still in the game, the other games will think they "lost contact" with the defeated player, resulting in a jarring pause in the action as OP2 pauses in order to drop the "lost" player.
Something to keep in mind: OP2 places mission objectives on the list as they are created. You probably won't need to worry about that in most cases, though. Not yet anyways.
Here's another example (and I get to sneak in a description of more triggers, too!):
Trigger trig;
// Evacuation Module
trig = CreateCountTrigger(1, 1, -1, mapEvacuationModule, mapNone, 1, cmpGreaterEqual, "NoResponseToTrigger");
CreateVictoryCondition(1, 0, trig, "Evacuate 200 colonists to the starship.");
// Food Cargo
trig = CreateCountTrigger(1, 0, -1, mapFoodCargo, mapNone, 1, cmpGreaterEqual, "NoResponseToTrigger");
CreateVictoryCondition(1, 0, trig, "Evacuate 10000 units of food to the starship.");
// Rare Metals Cargo
trig = CreateCountTrigger(1, 0, -1, mapRareMetalsCargo, mapNone, 1, cmpGreaterEqual, "NoResponseToTrigger");
CreateVictoryCondition(1, 0, trig, "Evacuate 10000 units of Rare Metals to the starship.");
// Common Metals Cargo
trig = CreateCountTrigger(1, 0, -1, mapCommonMetalsCargo, mapNone, 1, cmpGreaterEqual, "NoResponseToTrigger");
CreateVictoryCondition(1, 0, trig, "Evacuate 10000 units of Common Metals to the starship.");
// Phoenix Module
trig = CreateCountTrigger(1, 0, -1, mapPhoenixModule, mapNone, 1, cmpGreaterEqual, "NoResponseToTrigger");
CreateVictoryCondition(1, 0, trig, "Launch the Phoenix Module.");
// Orbital Package
trig = CreateCountTrigger(1, 0, -1, mapOrbitalPackage, mapNone, 1, cmpGreaterEqual, "NoResponseToTrigger");
CreateVictoryCondition(1, 0, trig, "Launch the Orbital Package.");
// Stasis Systems
trig = CreateCountTrigger(1, 0, -1, mapStasisSystems, mapNone, 1, cmpGreaterEqual, "NoResponseToTrigger");
CreateVictoryCondition(1, 0, trig, "Launch the Stasis Systems.");
// Sensor Package
trig = CreateCountTrigger(1, 0, -1, mapSensorPackage, mapNone, 1, cmpGreaterEqual, "NoResponseToTrigger");
CreateVictoryCondition(1, 0, trig, "Launch the Sensor Package.");
// Habitat Ring
trig = CreateCountTrigger(1, 0, -1, mapHabitatRing, mapNone, 1, cmpGreaterEqual, "NoResponseToTrigger");
CreateVictoryCondition(1, 0, trig, "Launch the Habitat Ring.");
// Command Module
trig = CreateCountTrigger(1, 0, -1, mapCommandModule, mapNone, 1, cmpGreaterEqual, "NoResponseToTrigger");
CreateVictoryCondition(1, 0, trig, "Launch the Command Module.");
// Fueling Systems
trig = CreateCountTrigger(1, 0, -1, mapFuelingSystems, mapNone, 1, cmpGreaterEqual, "NoResponseToTrigger");
CreateVictoryCondition(1, 0, trig, "Launch the Fueling Systems.");
// Fusion Drive
trig = CreateCountTrigger(1, 0, -1, mapFusionDriveModule, mapNone, 1, cmpGreaterEqual, "NoResponseToTrigger");
CreateVictoryCondition(1, 0, trig, "Launch the Fusion Drive Module.");
// Ion Drive
trig = CreateCountTrigger(1, 0, -1, mapIonDriveModule, mapNone, 1, cmpGreaterEqual, "NoResponseToTrigger");
CreateVictoryCondition(1, 0, trig, "Launch the Ion Drive Module.");
// Skydock
trig = CreateCountTrigger(1, 0, -1, mapSkydock, mapNone, 1, cmpGreaterEqual, "NoResponseToTrigger");
CreateVictoryCondition(1, 0, trig, "Place the Skydock in orbit.");
That's a lot of triggers and victory conditions! But it's everything you need for a Starship or Space Race game. Well, give or take a few triggers. (Space Race: Remove the Evacuation Module, Common Metals Cargo, Rare Metals Cargo, and Food Cargo triggers/conditions.)
Well, lemme just explain the Count Trigger real quick.
CreateCountTrigger(Enabled, One-Time, Players, Unit Type, Cargo Type, How Many, Comparison Type, "Trigger Function);
You kn whow enabled and one-time work by now.
Players: Which players can make this trigger fire.
Unit Type: The type of unit (or thing) we're looking for. Can be a structure, vehicle, or starship component.
Cargo Type: Used to specify that the unit in question must also have a specific cargo. Useful for objectives like "Have 4 Rail Gun Panthers" or "Have a Command Center kit in a ConVec".
How Many: How many you want the player to have.
Comparison Type: Do you want the player to have exactly 5 Cargo Trucks? Maybe you want the player to have more than 7 Panthers. Or maybe the AI must build no more than 4 Spaceports. That's what this is for.
//Valid comparisons:
cmpEqual
cmpGreater
cmpLower
cmpLowerEqual
cmpGreaterEqual
Trigger Function: Please tell me you know what this is by now...
I think that's it for now. Questions, comments, or results? Post 'em!
Next Week: Your First Last One Standing