Re: Events
Here's an example of Civ2's macro language (from p32 of the Conflicts in Civilization Instruction
Manual):
Code:
@IF
CityTaken
city=New York
attacker=English
defender=Americans
@THEN
Text
New York captured by the Redcoats! Enraged local citizens join the fight for liberty!
EndText
CreateUnit
unit=Militia
owner=Americans
veteran=false
homecity=none
locations
84,22
84,23
79,31
endlocations
@ENDIF
Here's what that looks like when written in BHS:
Code:
trigger sample_trigger (city_captured_by( 1, 2, "New York" ) ) {
popup_dialog(" New York captured by the Redcoats! Enraged local citizens join the
fight for liberty!");
create_unit( 1, 84, 22, "Militia", 1 );
create_unit( 1, 84, 23, "Militia", 1 );
create_unit( 1, 79, 31, "Militia", 1 );
}
Here "1" is the player ID of the Americans and "2" is the player ID of the English.
"city_captured_by" is a function defined as:
Code:
int city_captured_by(int who_defend, int who_attack, string city_name);
Returns 1 if who_attack captures city_name from who_defend.
And here's what that Civ2 example looks like when written in SLIC:
Code:
HandleEvent(CaptureCity) 'SampleHandler' pre {
if (PlayerCivilization(player[0]) == CivilizationIndex("English")
&& PlayerCivilization(city[0].owner) == CivilizationIndex("American")
&& city[0].location==NewYorkLoc ){
message(city[0].owner,'NewYorkCaptured');
event:CreateUnit(city[0].owner,UnitDB(UNIT_MILITIA),SpawnRebelsLoc,0);
}
}
messagebox 'NewYorkCaptured' {
Show();
Text (ID_NewYorkCapturedMessage);
// NewYorkCapturedMessage "New York captured by the Redcoats!
// Enraged local citizens join the fight for liberty!"
}
where:
i) NewYorkLoc is a (global) location variable that you've set to be New York's location,
ii) SpawnRebelsLoc is a (global) location variable that you've set to be the place where you want the
Militia to appear,
and,
iii) the outcommented lines appear in the .txt file that you're using to save your text
in.
The "CaptureCity" event occurs whenever a city is captured: player[0] is the capturing
player and city[0] is the city (so city[0].owner is it's owner and city[0].location is
it's location).
As indicated, that's written in the language SLIC (Scripting Language Interface Convention). Joe Rumsey,
the lead programmer for Call To Power II, created the language so that this game would be the most
mod-friendly Civ style game around. It is FAR more powerful than the triggers mechanism of Civ2. For one
thing, the latter had seven events: CityTaken, Negotiation, RandomTurn, ScenarioLoaded, Turn,
TurnInterval, and UnitKilled. SLIC has well over 200 events. Not all of them are interesting, nor even all
that usable, but each of them is a 'hook' into the executable: they (and the ones in BHS and Civ2 for that
matter) allow you to change the actual game's program.
'Actions' Once you've set your hook, Civ2 gave you 9 types of 'action' that you can perform:
ChangeMoney, CreateUnit, DontPlayWonders, JustOnce, MakeAgression, MoveUnit, PlayCDTrack, PlayWaveFile,
and Text/EndText. With SLIC and BHS what corresponds to an action is just any acceptable block of SLIC or BHS
code. From this point of view there are literally infinitely many types of SLIC/BHS 'actions' because as
proper scripting languages they have all sorts of resources that enable you to specify what it is that you
want the computer to do.
I don't think you're going to see Civ3 get a scripting language. But if you lobby enough you might get one
in Civ4. The point of providing the above examples is to show you what, IMO, the sort of language you
should be lobbying for should be like.