 |
castledoom.com Castle Doom
|
| View previous topic :: View next topic |
| Author |
Message |
Brf
Joined: 07 Nov 2004
Posts: 3754
Location: Belvidere, Illinois
|
| Posted: Fri Nov 19, 2004 8:56 pm Post subject: Tropico Scenario Scripting -- How-to for Dummies |
|
|
This thread will be an in-depth How-To on Tropico User Scenarios, with examples and stuff so everyone will have the enjoyment of writing their own scenarios.
For now. The official unsupported Tropico editor files can be downloaded from the Poptop website at http://tropico.godgames.com/scenarios/tedit103.exe or from my website at http://home.insightbb.com/~b.fermanich/EDITOR.zip |
|
| Back to top |
|
Brf
Joined: 07 Nov 2004
Posts: 3754
Location: Belvidere, Illinois
|
| Posted: Fri Nov 19, 2004 8:59 pm Post subject: User Scenarios - Basic framework and eventget.exe |
|
|
Ok ok.....your breath is steaming up my glasses. We can start into scenarios.
First we need to setup a directory on your computer for your scenario work. I would recommend a directory under the ProgramFiles\Tropico\ so we dont lose it. This thread will assume you created a directory under your Tropico directory called \MyScenarios\
Take the Editor zipfile you downloaded from the above message and unzip all the files into your new MyScenarios directory.
Now we will try out the eventget.exe utility. This utility will rip a copy of all the events and stuff in a scenario so we can examine or modify it.
Select a scenario from your Tropico\maps\ directory. "Yes we Have no Bananas" is a good one for a beginner. Right-click on Bananas.mp2 and choose "Copy". Click on your new MyScenarios directory and choose "Paste".
Now comes the fun part. Click-and-hold on the new Bananas.mp2 file and drag-and-drop it onto the Eventget.exe file. The Eventget utility will create a new Bananas directory in your MyScenarios directory filled with the events that make up the "Yes we Have no Bananas" scenario. All of the files are plain-text, so you will be able to open them with Notepad. Feel free to examine them to see how the scenario works. |
|
| Back to top |
|
Brf
Joined: 07 Nov 2004
Posts: 3754
Location: Belvidere, Illinois
|
| Posted: Fri Nov 19, 2004 9:03 pm Post subject: Eventadd.exe and making your own scenario |
|
|
Making your own scenario involves a few simple steps: make your map, write your events, run eventadd.
First make your map. Start up Tropico and make a random map. The important things are the map size on the first page, Special Circumstances on the second page, and the Dictator traits. Pretty much everything else can be be changed with the Editor. Pause the game and run Editor to adjust it to fit your scenario's needs and save with Editor running. Choose a short name appropriate for your scenario -- I will call mine Noname.
From within Windows Explorer, Copy your game savefile (Noname.GM2) from the \ProgramFiles\Tropico\Games directory and Paste it into your new MyScenarios directory. Change the extension of the game from NoName.gm2 to NoName.mp2
Create a new directory under your MyScenarios directory that is identical to your new scenario file's name. For instance, I create a new directory \Programfiles\Tropico\MyScenarios\Noname. Use Notepad to create two new files within the new NoName directory: name.oth and desc.oth
Name.oth will contain the name that is shown in the select-scenario list within Tropico -- the name of your scenario. In my name.oth I type in simply: NoName Island
Desc.oth will contain the description that is shown in the window beside the map when selecting a scenario in Tropico. In my desc.oth I type in: NoName Island, run by a NoName dictator who is trying to make a name for himself.
Then you make all your events... We will skip that for right now. We have all the required elements.
Now.... From within Windows Explorer. Click-and-hold on your map file, Noname.mp2 and drag-and-drop it onto the eventadd.exe file. Eventadd.exe will incorporate your name,desc, and event files into your map file. Copy your map file from the MyScenarios directory and Paste it into your \Programfiles\Tropico\Maps directory.
Now you can start up the Tropico game and you will see your new scenario, NoName Island, on the list with the others. Play and enjoy. |
|
| Back to top |
|
Brf
Joined: 07 Nov 2004
Posts: 3754
Location: Belvidere, Illinois
|
| Posted: Fri Nov 19, 2004 9:05 pm Post subject: Introduction to Events |
|
|
A scenario just isn't a scenario without events.
An event is "something" that "happens" at a particular time. In Tropico you can create events that show a message, set game parameters, affect treasury and swiss accounts, change the environmental factors for individuals or everyone, along with other periodic or one-time happenings.
Event files can be created with any text editor, such as Notepad and saved with a one to eight letter name with an .evt extension in your scenario's directory (with the name.oth and desc.oth files) or in subdirectories under that directory.
As explained in the post above, when you click on your scenario's .MP2 file and drag it onto the eventadd.exe program, all the events in its directory and subdirectories will be incorporated into the MP2 file. Then you can copy and paste your scenario into the Tropico\maps\ directory. |
|
| Back to top |
|
Brf
Joined: 07 Nov 2004
Posts: 3754
Location: Belvidere, Illinois
|
| Posted: Fri Nov 19, 2004 9:05 pm Post subject: Anatomy of an Event |
|
|
An event file consists of several plain-text script command lines. Each command must span only one text-line with no carriage-returns within that line...but that line can be of any length.
The basic structure of an eventfile is as follows:CheckFrequencyxxxxx
This is when the game engine checks to see it the event should be run. This is the only Mandatory script command. All of the others are optional.Condition xxxxxxxxxxxxx
This is a true-false condition that determines if the event should run at this timeGeneralEffect xxxxxxxxxx
This is what "happens" when the event is run, changing game parameters and suchMessagetypexxxxxxx
This is where the message showsMessagetext xxxxxxxxxxxxx
This is the message to showChoicexxxxxx
This is a list of choices for the Player to choose from and their effects.
There are a few variants, but most events will look like this.
You can put in blank lines to make it easier to read, plus you can put in comments with a semi-colon ( ; ). Anything on that line after the semi-colon will be ignored.
I have also gotten into the habit of putting one extra space ( ) at the end of every line. I have noticed strange errors can occur if the last character of a command-line isn't a space. |
|
| Back to top |
|
Brf
Joined: 07 Nov 2004
Posts: 3754
Location: Belvidere, Illinois
|
| Posted: Fri Nov 19, 2004 9:16 pm Post subject: CheckFrequency and Condition |
|
|
The CheckFrequency command must be the first line in each event file, and tells the game engine when it should run that script. The valid frequency commands are:CheckFrequencyDayBeginCheckFrequencyDayEndCheckFrequencyWeekBeginCheckFrequencyWeekEndCheckFrequencyMonthBeginCheckFrequencyMonthEndCheckFrequencyYearBeginCheckFrequencyYearEnd
Which are all self-explainingCheckFrequencyAlmanacScore
This event will calculate and display the score pageCheckFrequencyBriefing
This event will display a message at the beginning of the game, and maybe set environment variables.CheckFrequencyOnlyWhenCalled
This event is called from another event.
The timing of the calendar events is as follows:
January 1
YearBegin
MonthBegin
WeekBegin
DayBegin
AlmanacScore
DayEnd
January 2
DayBegin
DayEnd
......
January 7
DayBegin
DayEnd
WeekEnd
January 8
WeekBegin
............
January 28
DayBegin
DayEnd
WeekEnd
MonthEnd
February 1
MonthBegin
..........
So each week has 7 days and each month has 4 even weeks (28 days). The year is 336 days long altogether.
YearBegin is before MonthBegin which is before WeekBegin which is before Daybegin. YearEnd is after MonthEnd which is after WeekEnd which is after DayEnd.
AlmanacScore is always triggered by the game on January 1, after DayBegin and before DayEnd... but the player triggers it every time they visit the score page.
There are Day, Month and Year variables which can be interrogated with a condition or generaleffect command.
At YearBegin always Day=1 and Month=1
At MonthBegin always Day=1
At WeekBegin always Day=1 or 8 or 15 or 22
At WeekEnd always Day=7 or 14 or 21 or 28
At MonthEnd always Day=28
At YearEnd always Month=12 and Day=28
The Condition command, if any, will determine whether the event should be run or not, and should evaluate to a true-false condition....for instance:
CheckFrequencyMonthBegin
Condition Month=3
Will be run at the beginning of every March.
You can use complex conditions such as:
CheckFrequencyWeekBegin
Condition ((month=7) or (day=1))
Will run on the first week of every month and all 4 weeks in July. Ands and ors can be included.....and additions and subtractions and stuff:
CheckFrequencyDayBegin
Condition ((month=1) and ((day+1)=(year - 1950)))
Will probably execute on Jan 1, 1952...Jan 2, 1953....etc if the game doesnt crash from all the parenthesis.
If you include more than one condition line, then all of them must be true to run the event:
CheckFrequencyYearBegin
Condition Year>=1960
Condition Money>100000
ExecuteOnlyOnce
Will check each year starting in 1960, and only execute if the treasury has more than 100,000 pesos. The ExecuteOnlyOnce line insures that this event does not execute more than once... Otherwise it would run on every year starting in 1960 when the treasury is large enough.
The game variables that can be interrogated in a condition are included in the EDCONDIT.TXT file, plus a few more in the Editor Changes file.
There is one more condition command:
AlwaysTrue
If this line is included, then the event will always be executed, even if one or more of the conditions are false. This advanced technique will be discussed in a later post. |
|
| Back to top |
|
Brf
Joined: 07 Nov 2004
Posts: 3754
Location: Belvidere, Illinois
|
| Posted: Fri Nov 19, 2004 9:22 pm Post subject: Effects, Messages, and variables |
|
|
Now that we have used the CheckFrequency and Condition commands to determine when our event will happen, we have to tell what our event will do.
The most visible effect of an event is its message. A message is constructed like this:
MessageTypexxxxx
MessageText "xxxxxxxxxxx"
The Valid message types are:MessageTypeDossier - Which creates a pop-up message.MessageTypeBottomRight - The message will show in the bottom-right status window.MessageTypeSpecial - Used with CheckFrequencyAlmanacScore to display the message on the score page.
MessageText has the message to display in double quotes (") and must be all on one line. You can turn on Word Wrap in Notepad to see your entire message at once, but be sure to turn off Word Wrap before you save to be assured that the entire message is on one line.
Here is a sample Briefing event, which will pop up a message when your scenario first starts up:
CheckFrequencyBriefing
MessageTypeDossier
MessageText "This scenario is a test, only a test"
To put a carriage return in your message put in "\n".
For instance:
Messagetext "This is one line\nAnd this is another"
will be displayed as:
This is one line
And this is another
You can also display Game variables in your messages, by putting the variable name in Brackets []. The valid variable names for messages are:[Money][Swiss_Money][Population][Year][Month_year][day_month_year]
So this event:
CheckFrequencyYearBegin
MessageTypeDossier
MessageText "So....it is already [year] and you have [population] people, but only [money] in your treasury...\n\nwhat a pathetic dictator you are"
Will pop-up a message every year like this:
So.... it is already 1951 and you have 53 people, but only $7,321 in your treasury...
what a pathetic dictator you are
You can display any of the game variables from the EDCONDIT.TXT, but they must first be copied to an Event Variable. There are two types of event variables: Regular Event variables and Group Variables. For now, we will discuss the regular event variables, which are numbered 1 through 4.
To copy a game variable to an event variable, we use the command GeneralEffect SetTo:
CheckFrequencyYearBegin
Condition year>=1960
Condition GsAverageHappiness<50
GeneralEffect SetTo Eventvariable1 GSAverageHappiness
MessageTypeDossier
MessageText "Presidente, it is already [year] and the people are not happy. Their average happiness is only [trigger_event_variable_1]!"
Will check every year, starting in 1960, and pop-up a messagebox if the average happiness is less than 50. It will look something like this:
Presidente, it is already 1961 and the people are not happy. Their average happiness is only 49!"
Note that most game variables have a decimal portion. That decimal portion will be considered in the Condition, but will be rounded to the nearest whole number for the message....so if their happiness is 49.6, for instance, this event will be triggered and state their happiness is 50.
In addition to SetTo, there are several other GeneralEffect types:GeneralEffect SetTo xxxx yyyy GeneralEffect AddTo xxxx yyyy GeneralEffect MultiplyBy xxxx yyyy GeneralEffect CallEvent xxxxGeneralEffect GameWonGeneralEffect GameLost 1
MultiplyBy must have an EventVariable or GroupVariable as the first part.
SetTo can have an Eventvariable, GroupVariable, Money, SwissBank, or GameScore.
AddTo can be used with most anything in the EDEFFECT.TXT file. For instance:
GeneralEffect AddTo CigerRevenue 30
Will raise the selling price of cigars by 30%. Additional AddTo's will be counted against the base price.....so:
GeneralEffect Addto CigarRevenue -10
Will set the Cigar selling price to 120% of the original, if executed after the +30 one.
GeneralEffect CallEvent will immediately call a different event for this same scenario. The new event does not have to be in the same SubDirectory as the caller. For example:
CheckFrequencyBriefing
GeneralEffect CallEvent Setup1
GeneralEffect CallEvent Setup2
GeneralEffect CallEvent Brief1
Will execute two setup events and an event which will give the briefing message. It is assumed that there are three event files called setup1.evt, setup2.evt, and brief1.evt. All three files must start with:
CheckFrequencyOnlyWhenCalled
GeneralEffect GameWon
causes the player to win immediately, while
GeneralEffect GameLost 1
cases the player to get the Rowboat. The message in MessageText will be displayed. The MessageType command should be omitted for either GameWon or Gamelost....For instance:
CheckFrequencyWeekEnd
Condition Money>1000000
MessageText "Woohoo!!! You did it"
GeneralEffect GameWon
CheckFrequencyYearEnd
Condition Year>=1980
MessageText "Too Bad : ( "
GeneralEffect GameLost 1
Will cause the player to win the game if he has a treasury of 1,000,000 pesos before the end of 1980, and lose if he takes too long. |
|
| Back to top |
|
Brf
Joined: 07 Nov 2004
Posts: 3754
Location: Belvidere, Illinois
|
| Posted: Fri Nov 19, 2004 9:27 pm Post subject: A sample scenario |
|
|
Ok....enough blabbing....Now we can write a scenario together.
The first thing you need is a storyline or some sort of theme..... Lets make any easy one with a military goal for all you warmongers....
You have had a bad dream.... a premonition to an attack. You must build up your army to fend off the attack....
This scenario only requires four or five events: The briefing - to explain the scenarioThe attack - add a bunch of rebels to the mapThe winning condition - when the rebels are eliminatedThe scoreOptional losing event - took too long to get rid of the rebels.
First you need to make a good map. It can be a smallish one if you like, since it will probably be a short scenario. Pick dictator traits that favor the military, and for heavens sake do not pick Coward or your guys will be running away from the rebels instead of killing them. Save the map (with editor running) using the name "Dream". Copy the Dream.GM2 file from the \ProgramFiles\Tropico\Games\ directory to your \myscenarios\ directory and rename it to Dream.MP2. Create a \Dream\ directory under your \Myscenarios\ directory and create these files using notepad:
Name.oth
Bad Dream
Desc.oth
You have had a bad dream -- a premonition of an attack. You must build up your army to prevent this attack
Briefing.evt
CheckFrequencyBriefing
MessageTypeDossier
MessageText "You have had a terrible dream of being attacked by killer bees. The local soothsayer claims it is a premonition of an attack. By interpreting other symbols in your dream, she divines that the attack will occur sometime in 1965. You have 15 years to build up your army to fend off the attack. "
Then we must decide when to have the attack....lets just say July 1965 to make it easy. We also have to decide where the rebels will appear. Pick a good spot on your map and press the I-key. At the bottom of the screen will be the (X,Y) coordinates of that spot. For this example, my map uses (43,37)
Attack.evt
CheckFrequencyMonthBegin
Condition Year>=1965
Condition Month>=7
ExecuteOnlyOnce
GeneralEffect SetTo LocationX 43
GeneralEffect SetTo LocationY 37
GeneralEffect SetTo AddRebel 25
MessageTypeDossier
MessageText "Your scouts have reported seeing rebels. The Attack is on!!!!"
We dont really need a score for this game, but it would be nice to report the number of soldiers and rebels we have. It isnt necessary to report zero rebels before the attack, so we will have two separate score events with conditions.
score.evt
CheckFrequencyAlmanacScore
GeneralEffect CallEvent Score1
GeneralEffect CallEvent Score2
score1.evt
CheckFrequencyOnlyWhenCalled
Condition ((Year<1965) or (month<7))
GeneralEffect SetTo Eventvariable1 GSNumberSoldiers
MessageTypeSpecial
MessageText "You must build up your army before the attack in 1965. So far you have [trigger_event_variable_1] soldiers."
score2.evt
CheckFrequencyOnlyWhenCalled
Condition ((year>1965) or ((year=1965) and (month>=7)))
GeneralEffect SetTo Eventvariable1 GSNumberSoldiers
GeneralEffect SetTo Eventvariable2 GSNumberRebels
MessageTypeSpecial
MessageText "The attack is on!!!. You have [trigger_event_variable_1] soldiers, but there are still [trigger_event_variable_2] rebels."
Checkwin.evt
CheckFrequencyMonthEnd
Condition ((year > 1965) or ((year=1965) and (month>=7)))
Condition GSNumberRebels = 0
MessageText "Yay!!!! You have eliminated the rebels!!!"
GeneralEffect GameWon
GeneralEffect SetTo GameScore 1000
And that is it!!!! Drag and drop your Dream.MP2 file on the eventadd.exe file. Copy your Dream.MP2 file to the \tropico\maps\ directory and give it a try :) |
|
| Back to top |
|
Brf
Joined: 07 Nov 2004
Posts: 3754
Location: Belvidere, Illinois
|
| Posted: Fri Nov 19, 2004 9:35 pm Post subject: Variable Scope |
|
|
Now that everyone has made their own scenario -- with events -- we need to look at the Scope of variables. Scope describes where a variable's value exists. For instance if we have the following events:
event1.evt
CheckFrequencyBriefing
GeneralEffect CallEvent event2
GeneralEffect CallEvent event3
event2.evt
CheckFrequencyOnlyWhenCalled
generalEffect SetTo EventVariable1 GSNumberResidents
MessageTypeDossier
MessageText "You start with [trigger_event_variable_1] residents"
event3.evt
CheckFrequencyOnlyWhenCalled
MessageTypeDossier
MessageText "You start with [trigger_event_variable_1] residents"
Will pop up two messages when the game starts. The first box will say something like You start with 40 residents, but the second box will say You start with 0 residents.
That is because the scope of an eventvariable is only for the current event. Eventvariable1 was set to the number of residents in Event2, but will have that value only in event2. In event3, eventvariable1 has not been set, so it has a value of zero.
Also, each Eventvariable will hold its value between calls to the same event, so if we have this event:
Weekcnt.evt
CheckFrequencyWeekEnd
GeneralEffect AddTo EventVariable1 1
MessageTypeBottomRight
MessageText "So far [trigger_event_variable_1] weeks have gone by"
Will correctly count and display the number of weeks that have gone by. That is because the value that EventVariable1 has at the end of the event, will be EventVariable1's value at the beginning of its next execution the next week.
In addition to Eventvariable1-4, there are also GroupVariable1-4. A Groupvariable's scope exists in the entire subdirectory the events are in....so in the preceding example, if event2 and event3 are in the same subdirectory and event2 sets Groupvariable1 to a value, then event3 could interrogate that value. Each subdirectory in your scenario has its own Groupvariable1-4, just as each event has its own separate Eventvariable1-4.
One of the most handy uses for a GroupVariable is to communicate a value from one event to another. For instance, if we go through a complex calculation to report the game score, it would be ugly to have to put those calculations in two different events (AlmanacScore and GameWin). It would be easier to calculate the score in one event which is called from both of the other ones, like this:
Score.evt
CheckFrequencyAlmanacScore
GeneralEffect CallEvent CalcScor
GeneralEffect CallEvent ShowScor
Calcscor.evt
;This is a bunch of calculations that puts the score in Groupvariable1
Showscor
CheckFrequencyOnlyWhenCalled
MessageTypeDossier
MessageText "Your score is [trigger_group_variable_1]"
CheckWin.evt
CheckFrequencyMonthEnd
Condition .....whatever the win conditions are .....
GeneralEffect CallEvent CalcScor
GeneralEffect CallEvent WinGame
WinGame.evt
CheckFrequencyOnlyWhenCalled
MessageText "You Won!!!!!! Your final score is [trigger_group_variable_1]"
generaleffect gamewon
Another use for a GroupVariable is to set a GameState, where an event Now will affect what happens in the future...but the Tropico game-engine has a flaw which prevents this from happening properly... so we will investigate Gamestates in a later post. |
|
| Back to top |
|
Brf
Joined: 07 Nov 2004
Posts: 3754
Location: Belvidere, Illinois
|
| Posted: Fri Nov 19, 2004 9:37 pm Post subject: Complex Calculations |
|
|
The Tropico GameEngine is really picky about what kind of calculations will or will-not work. For instance:
GeneralEffect SetTo Eventvariable1 ((GSNumberresidents + 3) / 7)
will probably work OK.
GeneralEffect SetTo Eventvariable1 ((GSNumberresidents * 3) + 7)
will not.
In my experience, you cannot put a plus (+) or minus (-) outside of a parenthesis. If you can get a complex equation to work, that is great....but if you cannot, it will almost certainly work ok if you split it up into small pieces. The preceding example can be split up like this if necessary:
GeneralEffect SetTo EventVariable1 GSNumberResidents
GeneralEffect MultiplyBy EventVariable1 3
GeneralEffect AddTo EventVariable1 7
In most cases, if something will not work, it will blow up as the map is starting. You will get the error Cannot resolve to one value, or Divide by zero. In those cases, try splitting the formula into smaller pieces.
Also: Although any gamevariable can hold a decimal portion, decimals are ignored in literals....so the command:
GeneralEffect MultiplyBy EventVariable1 17.9
Will only multiply by 17. If you wish to use a decimal portion, you can use a fraction. The preceding command can be replaced by:
GeneralEffect MultiplyBy EventVariable1 (179/10)
and it will work correctly. |
|
| Back to top |
|
Brf
Joined: 07 Nov 2004
Posts: 3754
Location: Belvidere, Illinois
|
| Posted: Fri Nov 19, 2004 9:39 pm Post subject: Displaying prettier messages |
|
|
We have seen how to display a variable in a message like this:
messagetext "EventVariable 1 has the value [trigger_event_variable_1] and GroupVariable3 has the value [trigger_group_variable_3]"
But we can also display as a money value:
generaleffect SetTo eventvariable1 (LTDGSRevMining - LTDGSExpMining)
Messagetext "Total mining profit is [trigger_money_event_variable_1]"
There are also a bunch of other undocumented message features that have been discovered:
To make neat, tabular output, use [hjl] to create a left-justified column and [hjr] for a right-justified column and [hjc] for center-aligned. Successive rows of columns will be aligned with the preceeding rows. For instance:
messagetext "[hjl]Var 1[hjr][trigger_event_variable_1]\n[hjl]Var 2[hjr][trigger_event_variable_2]\n[hjl]Var 3[hjr][trigger_event_variable_3]"
Will create a neatly aligned table of the eventvariables 1-3.
[u1] will underline the following text and [u0] will cancel the underline.
[c00] through [c99] Will change the color of the text. For a full list of colors check out this: Tropico Message Colors
To delimit one style of text from another....you can use curly braces {}:
messagetext "This is regular color {[c44]This is dark blue} and {[c77]This is orange}"
One warning: If you misspell anything inside of brackets, it will not create an error when your map loads. Instead, your game will freeze when that message is called, and you will have to end-task it from the <ctrl><alt>< del> menu or task manager.
For instance, putting in [trigger_event_variable1] will freeze your game because you forgot the "_" in variable_1. |
|
| Back to top |
|
Brf
Joined: 07 Nov 2004
Posts: 3754
Location: Belvidere, Illinois
|
| Posted: Fri Nov 19, 2004 9:51 pm Post subject: Choices and GameState |
|
|
Events which give the player a choice can add more variety to a scenario. A choice event starts with a CheckFrequency and optional conditions and generaleffects. Then comes messagetypedossier, a message, and a set of 1 to 5 choices and their effects.
If the effects are simple, the effects can be included in-line like this:
CheckFrequencyYearBegin
Condition Year=1960
Condition LTDGSExpIndustry<0 ;Expense is negative
MessageTypeDossier
MessageText "Presidente, the inspectors state that we must supply safety devices, such as safety glasses and steel-toed shoes to our factory workers"
Choice1Text "Ridiculous!! Our factories are safe enough already"
Choice1Effect AddTo FactoryRate -10
Choice2Text "Yes! We will make sure all of our workers are safe!"
Choice2Effect AddTo FactoryRate 5
Choice2Effect AddTo FactoryMaintenance 25
Theoretically, you can have as many Choice?Effect lines as you like, and their syntax is identical to a GeneralEffect command, so you can have:
Choice1Effect AddTo
Choice1Effect SetTo
Choice1Effect MultiplyBy
Choice1Effect CallEvent
Choice1Effect GameWon
or
Choice1Effect GameLost 1
The CallEvent option is probably the most useful, then you can put complicated actions for each choice. For instance, we could change the previous example to this:
CheckFrequencyYearBegin
Condition Year=1960
Condition LTDGSExpIndustry<0 ;Expense is negative
MessageTypeDossier
MessageText "Presidente, the inspectors state that we must supply safety devices, such as safety glasses and steel-toed shoes to our factory workers"
Choice1Text "Ridiculous!! Our factories are safe enough already"
Choice1Effect CallEvent N_Safety
Choice2Text "Yes! We will make sure all of our workers are safe!"
Choice2Effect CallEvent Y_Safety
Y_safety.evt
CheckfrequencyOnlyWhenCalled
GeneralEffect AddTo FactoryRate 5
GeneralEffect AddTo FactoryMaintenance 25
MessageTypeDossier
Messagetext "The maintenance costs in your factories have increased by 25%, but the rise in moral has increased output by 5%"
N_safety.evt
CheckfrequencyOnlyWhenCalled
GeneralEffect AddTo FactoryRate -10
MessageTypeDossier
MessageText "An increase in accidents has led to more employee downtime. Your factory output has been lowered by 10%"
A choice can also set a Gamestate.
A gamestate is when an event or choice will effect what happens later in the game. A Gamestate is typically stored in a GroupVariable, which is used in the Conditions for one or more future events. These events must all be stored in the same subdirectory to make use of the same GroupVariable.
For example, my just-for-yucks scenario Super Dude has 6 possible GameStates to ensure sensible messages are displayed:
State-0 - Starting State
State-1 - SuperDude is invited
State-2 - SuperDude was turned down but player can re-summon
State-3 - Stork has been summoned, but turned down
State-4 - Stork is paying-off
State-5 - SuperDude has been re-summoned.
The State number is stored in a GroupVariable and used as a condition in future months:
Month0.evt
CheckFrequencyMonthEnd
Condition year>1950
GeneralEffect CallEvent State5
GeneralEffect CallEvent State4
GeneralEffect CallEvent State3
GeneralEffect CallEvent State2
GeneralEffect CallEvent State1
Where each State? event only runs for its State condition
State1.evt
CheckFrequencyOnlyWhenCalled
;This is the routine where SuperDude has been invited
Condition GroupVariable1 = 1 ; Only run for GameState=1
Condition Random0to100<20 ; 20% chance of running
GeneralEffect CallEvent SDStrike ;SuperDude strikes
Notice the second condition line.....
Condition Random0to100<20
Random0to100 is a function which returns a more-or-less random decimal-pointed number between 0 and 100. So Random0to100<20 should be true approximately 20% of the time. The valid random functions are:
Random0to100 Good for percentages
Random0to100000 Good for cash penalties)
Random0toMapWidth Good for picking random spots to add
Random0toMapHeight rebels, unemployed, pollution or crime
Warning: There is a GameEngine problem which prevents GroupVariables from being stored with Gamesaves if the events are not in a subdirectory of the scenario. Therefore, you must always create subdirectories for your events. |
|
| Back to top |
|
Brf
Joined: 07 Nov 2004
Posts: 3754
Location: Belvidere, Illinois
|
| Posted: Fri Nov 19, 2004 10:00 pm Post subject: Looping and Context |
|
|
The looping commands allow a one-by-one interrogation of people or buildings. The looping commands for Tropico are:
LoopThroughAllBuildings - which loops through all the buildings :D who woulda thunk!
and
LoopThroughAllUnits - which loops through all the people.
The looping command should be the second line in the event, immediately after the CheckFrequencyxxxx line. Then the remaining lines are executed once for every building or person.
CheckFrequencyMonthEnd
LoopThroughAllBuildings
Condition BldgType=BldgTypeArmory
Condition BldgPay<25
ExecuteOnlyOnce
GeneralEffect AddTo UnitUIFactionSupportMilitary -10
MessageTypeDossier
MessageText "Your Militarists are angered that you would attempt to attract generals with such a low salary."
Will run through all the buildings and look for an armory with a payscale less than 25. The ExecuteOnlyOnce line assures that the event is only run for the first armory found if there are more than 1.
Note: Loopthroughallbuildings will NOT iterate through unfinished buildings or individual parts of large buildings. This also means it will not include unimproved Archeological Sites and Colonial Forts.
Some fun commands for buildings are: BldgCollapse, BldgFireWorkers and BldgEvictResidents.
Used like this:
CheckFrequencyYearEnd
LoopThroughAllBuildings
Condition Random0to100<5
GeneralEffect SetTo BldgCollapse 1
Will cause approximately 5% of the buildings to collapse.
LoopThruAllUnits will loop through all of the living people. Dead people, despite their having a clickable icon on the map, will not be included in the loop. Animals are not included either.
The fun unit loop command is unitdiefromsickness:
CheckFrequencyMonthEnd
LoopThroughAllUnits
Condition UnitType=UnitTypeSoldier
GeneralEffect SetTo UnitDiefromSickness 1
Will kill off all the soldiers.
Context- If you are in a looping event and you call another event, then the pointer is still pointed at that one particular building or unit.
Here is an event group that will count the respect of the military (including police) and the supression of the civilians:
Check0.evt
CheckFrequencyOnlyWhenCalled
GeneralEffect SetTo Groupvariable1 0 ; Count Army
GeneralEffect SetTo Groupvariable2 0 ; Total Respect
GeneralEffect SetTo Groupvariable3 0 ; Count Civilians
GeneralEffect SetTo Groupvariable4 0 ; Total Repression
GeneralEffect CallEvent LoopAll
GeneralEffect CallEvent Report1
Loopall.evt
CheckFrequencyOnlyWhenCalled
LoopThroughAllUnits
GeneralEffect CallEvent Check1 ; Count army
GeneralEffect CallEvent Check2 ;Count Civilians
Check1.evt
CheckFrequencyOnlyWhenCalled
Condition ((unittype=Unittypesoldier or unittype=unittypegeneral) or unittype=unittypepoliceman)
generaleffect addto groupvariable1 1
generaleffect addto groupvariable2 unituirespect
check2.evt
CheckFrequencyOnlyWhenCalled
Condition ((unittype!=Unittypesoldier and unittype!=unittypegeneral) and unittype!=unittypepoliceman)
generaleffect addto groupvariable3 1
generaleffect addto groupvariable4 unituisupression
report1.evt
Checkfrequencyonlywhencalled
generaleffect setto Eventvariable1 groupvariable2
generaleffect setto Eventvariable2 GroupVariable1
generaleffect multiplyby eventvariable1 (1/groupvariable2)
generaleffect setto Eventvariable3 groupvariable4
generaleffect setto Eventvariable4 GroupVariable3
generaleffect multiplyby eventvariable3 (1/groupvariable4)
MessageTypeDossier
Messagetext "You have [trigger_group_variable_1] soldiers with an average respect of [trigger_event_variable 1] and [trigger_group_variable_3] civilians with an average suppresion of [trigger_event_variable 3]"
Note: The UnitUIxxxx variables are intended to be used in a loop. BUT if you attempt to change them with GeneralEffect Addto UnitUIxxxxx and you are NOT in a loop, then ALL of your people will be affected:
For example:
LoopThruAllUnits
Condition UnitType=UnitTypePoliceman
GeneralEffect AddTo UnitUIRespect 25
will add 25% to your respect rating for any policeman...but if you are NOT in a loop and execute something like this:
GeneralEffect AddTo UnitUIOverallHappiness -50
that will subtract 50 points from EVERY person's happiness.....so you better be ready for Coups and Revolts. |
|
| Back to top |
|
Brf
Joined: 07 Nov 2004
Posts: 3754
Location: Belvidere, Illinois
|
| Posted: Fri Nov 19, 2004 10:00 pm Post subject: Miscellaneous |
|
|
The Condition Variable
We have seen how to display any Game variable by copying it to EventVariable1-4 or GroupVariable1-4, but there is a ninth variable which can be displayed in messages. This is the Condition Variable.
The Condition Variable is the evaluation of the Conditions for the event. If the condition is "true", then the Condition Variable will be set to one (1). If there are multiple Conditions, the Condition variable will be set to the value of the last condition, unless any of the conditions evaluates to zero or false...Then the Condition Variable will be set to zero.
If you wish the event to run even when the Condition Variable is zero, you must include the command:
AlwaysTrue
Which will cause the event to run even with a false condtion.
To display the Condition variable, you can use any of these message tokens:
[trigger]Displays is a whole number[trigger_money]Displays is a whole number cash value[trigger_float]Displays with decimal portion[trigger_tf]Displays False if the variable is zero and True otherwise
For instance:
CheckFrequencyMonthEnd
Condition GSNumberResidents
Condition Money
MessageTypeBottomRight
MessageText "Cash is [trigger_money]"
Will display the treasury total, unless the cash exactly equals zero, or the population is zero.
CheckFrequencyWeekEnd
Condition GSAverageHappiness
Condition 3=2
Condition GSBuildingsValue
AlwaysTrue
MessageTypeBottomRight
MessageText "Value is [trigger_money]"
Will always display "Value is $0", because the Condition 3=2 will always be false and evaluate to zero.
A few Miscellaneous commands:
GeneralEffect SetTo AddRebel number
GeneralEffect SetTo AddUnemployed number
These will add the number of rebels or umemployed immigrants to the map spot specified by
GeneralEffect SetTo LocationX number
GeneralEffect SetTo LocationY number
You can find the locations by pressing the I-key on your map when editor is activated.
GeneralEffect AddTo Pollution number
GeneralEffect AddTo Crime number
these will increase the pollution or crime in the area specified by the number. In addition to setting LocationX and LocationY, for these you need to set the radius-of-effect with:
GeneralEffect SetTo Range number
Free Buildings:
GeneralEffect AddTo Freexxxx number
Will let the player build that number of those buildings free of charge, and without having to be constructed -- as if the RAPIDO cheat were being used.
GeneralEffect AddTo FreeDock 1
GeneralEffect AddTo FreeFarm 3
will let the player build one dock and three farms free of charge. |
|
| Back to top |
|
Brf
Joined: 07 Nov 2004
Posts: 3754
Location: Belvidere, Illinois
|
| Posted: Fri Nov 19, 2004 10:04 pm Post subject: Calendar Cheats and Debug Mode |
|
|
Calendar cheats allow you to set your game calendar ahead, so you can test future events without having to play the game all the way through. To activate one of these cheats, hold down the <ctrl> key and type one of these:
ONEMONTH
SIXMONTHS
ONEYEAR
FIVEYEARS
TENYEARS
TWENTYYEARS
THIRTYYEARS
and the almanac will immediately be advanced by that time. Therefore, to test the rebels arriving in 1965 in our practice scenario, we could have activated tenyears, followed by fiveyears, to advance the year to 1965.
Debug Mode was discovered by Cafe Dave, and is totally undocumented. The Cafe thread describing this discovery is here: Debug Mode
Basically it works like this: Create a directory under your \ProgramFiles\Tropico\ directory called \ProgramFiles\Tropico\Events\Cut-and-Paste or Copy-and-Paste a copy of your scenario's directory, \Dream for example, under that \Events directoryWhen you startup Tropico it will immediately syntax-check your events, even before you get to choose an islandRun your save map from the saved games list -- or any other map for that matter -- and your events will be included!!!
This is a huge timesaver if you have a lot of events to debug....no more having to drag-and-drop your mp2 file on eventadd, and no more having to copy the file to the maps directory. Just remember, once you have everything working properly, you need to put your scenario directory back under your \myscenarios\ where it belongs and drag-and-drop your MP2 file on eventadd to create your distributable scenario.
Also, with this mode, you can have fun by adding new events to existing scenarios or maps. That is what I did when I created the Stork module. I made sure my events were generic enough to run with any scenario and the names of the events were specific enough to avoid clashing with the names of existing events. |
|
| Back to top |
|
Brf
Joined: 07 Nov 2004
Posts: 3754
Location: Belvidere, Illinois
|
| Posted: Fri Nov 19, 2004 10:05 pm Post subject: BUG: IsImmigrant/IsHomeless |
|
|
The flags IsImmigrant and IsHomeless are reversed. If you are doing LoopThroughAllUnits and either of these flags is set, the other is true.
When an immigrant arrives on the dock, his/her IsHomeless flag is set, and will remain set for the whole game.
When someone has no home, including no shack, his/her IsImmigrant flag will be set.
I wondered why I was having problems detecting Immigrants several months ago when I was working on a scenario, and now I know why. I was monitoring several different flags along with IsJobless while working on separating out prisoners. The erroneous IsHomeless flag lead me to this discovery. It is funny that the game is been going for so many years without someone mentioning this before. |
|
| Back to top |
|
| |
phpBB Search Engine Indexer © phpRebel
Powered by phpBB 2.0.21 © 2001, 2002 phpBB Group
|