Event scripting: How-to guide!
Posted: Sat May 09, 2020 11:18 am
I have never seen an accessible guide on "how to do event scripting" for the SC series. So, here goes! My 1911 mod uses scripts extensively so for the last 6 weeks or so I have been teaching myself this. Here is what I have learned, with some worked examples.
The structure of the events is really similar across all the SC3 series games, so this guide should work for all of them. There will be differences of detail though.
Background & tips
Event scripts live in: "C:\Users\You\Documents\My Games\Strategic Command Version Name\Campaigns\_ScenarioName\Scripts\Events" - at least mine do.
There are about 22 files in that folder, each for a different format of event. AI scripts are in a separate folder - I won't cover that for now. There are also localisation subfolders with names like DE, EN, ec, you can safely ignore them too.
You can also locate the scripts in the Editor via >Campaign>Edit Event Scripts . You can open them from here as well but they will probably open in Notepad.
I recommend that for effective scripting:
1. Have the Editor itself open - you will need it heavily to find locations etc
2. Open the script files from your file folder (not via the editor) using a good text editor. I recommend Notepad++ - it has tools like multiple tabs, line numbers, and automatic bracket completion that is really helpful for this work.
3. Also have the Manual open, as it has some helpful reference notes.
Script file structure
The top of the file is a Usage Guide for each event type. This is really helpful to guide you as to what to do with each kind of event file - it will have more technical detail than I will cover here.
Then there are a list of reference values e.g. Nation IDs.
Then there are the events themselves.
Note that a line that starts with a ; is a comment line - you can leave notes for yourself for instance with
; note to self
Updating, Debugging, Saving
Changing the contents of the script file by itself does not update the scenario. What you need to do to put your changes into effect is:
a) Save the text script file you have been working on.
b) In the Editor, open Edit Event Scripts
c) You will see that the file you've worked on (and maybe others) now has a * at the end in the left-hand column. This means the Editor thinks it needs to be re-integrated with the campaign file before it will load.
d) You will also see two Update buttons and an Update All button.
e) The bottom left Update button will debug your file and give an error message for the first error it encounters (if it encounters any). These messages are usually pretty handy. They tell you the line number of the event that failed, and which field behaved unexpectedly. If you have missed brackets or put in an invalid ID or something, it will tell you. If there are no errors, the Editor will be happy and will remove the * from the file on the list, indicating that the updated script file is good to go.
f) the right-hand Update and Update All buttons do the same thing more quickly. But they do not report errors. If there are errors, you will know because there will be files whose *s remain in place, but the errors found are not reported to you. You need to go back over them with the other Update button.
g) Once your script has no * in the list, you can then save the campaign you are working on in the Editor. The new script is now updated in the campaign file and will load when you start a new game using your campaign.
If you start a campaign and events you created are not appearing, there is a possibility you didn't complete these steps.
OK - now on to the fun part - actually editing events!
The structure of the events is really similar across all the SC3 series games, so this guide should work for all of them. There will be differences of detail though.
Background & tips
Event scripts live in: "C:\Users\You\Documents\My Games\Strategic Command Version Name\Campaigns\_ScenarioName\Scripts\Events" - at least mine do.
There are about 22 files in that folder, each for a different format of event. AI scripts are in a separate folder - I won't cover that for now. There are also localisation subfolders with names like DE, EN, ec, you can safely ignore them too.
You can also locate the scripts in the Editor via >Campaign>Edit Event Scripts . You can open them from here as well but they will probably open in Notepad.
I recommend that for effective scripting:
1. Have the Editor itself open - you will need it heavily to find locations etc
2. Open the script files from your file folder (not via the editor) using a good text editor. I recommend Notepad++ - it has tools like multiple tabs, line numbers, and automatic bracket completion that is really helpful for this work.
3. Also have the Manual open, as it has some helpful reference notes.
Script file structure
The top of the file is a Usage Guide for each event type. This is really helpful to guide you as to what to do with each kind of event file - it will have more technical detail than I will cover here.
Then there are a list of reference values e.g. Nation IDs.
Then there are the events themselves.
Note that a line that starts with a ; is a comment line - you can leave notes for yourself for instance with
; note to self
Updating, Debugging, Saving
Changing the contents of the script file by itself does not update the scenario. What you need to do to put your changes into effect is:
a) Save the text script file you have been working on.
b) In the Editor, open Edit Event Scripts
c) You will see that the file you've worked on (and maybe others) now has a * at the end in the left-hand column. This means the Editor thinks it needs to be re-integrated with the campaign file before it will load.
d) You will also see two Update buttons and an Update All button.
e) The bottom left Update button will debug your file and give an error message for the first error it encounters (if it encounters any). These messages are usually pretty handy. They tell you the line number of the event that failed, and which field behaved unexpectedly. If you have missed brackets or put in an invalid ID or something, it will tell you. If there are no errors, the Editor will be happy and will remove the * from the file on the list, indicating that the updated script file is good to go.
f) the right-hand Update and Update All buttons do the same thing more quickly. But they do not report errors. If there are errors, you will know because there will be files whose *s remain in place, but the errors found are not reported to you. You need to go back over them with the other Update button.
g) Once your script has no * in the list, you can then save the campaign you are working on in the Editor. The new script is now updated in the campaign file and will load when you start a new game using your campaign.
If you start a campaign and events you created are not appearing, there is a possibility you didn't complete these steps.
OK - now on to the fun part - actually editing events!