Basics
What is Classic population cap system?
Classic population cap system is a system where player population cap is based on the amount of territory sectors they own. If the player has no territory captured at all, the player will only have the basic population cap supplied by the base sector.
- Only territory sectors in supply (not cut-off) will grant additional population
- The more territory you own, the more additional population cap you have
- You can configure different population cap bonuses for both races
- This example code provides a very basic configuration. The amount of population granted per different sector type is up to you.
- This script only supports common multiplayer strategic points. Feel free to ask how to extend the support
- This system is called "Classic" due to its purpose of simulating COH1's population cap system
Tools you need
You will need a basic text editor. Microsoft Notepad is suitable for this job and you already have it. In case you'd like to consider getting a bit better tool for this, I would recommend using notepad++, which you can download from from notepad-plus-plus.org for free.
Important Note
One thing you should notice and understand before going any further:
Every time you save your map in WorldBuilder, _ID.scar will be re-generated by the WorldBuilder. This means you have to add the code every time after saving the map if you wish to export the package. If you haven't saved your map yet, do it now!
Every time you save your map in WorldBuilder, _ID.scar will be re-generated by the WorldBuilder. This means you have to add the code every time after saving the map if you wish to export the package. If you haven't saved your map yet, do it now!
Map Files
Have you ever looked into your map folder? Perhaps you have and you know there are bunch of files laying around related to your map. For example the .sgb file, which is the main file containing all the data of your map. There are also other files, such as .tga, .info, .options, and [b]_ID.scar.
The one we are interested in this tutorial is _ID.scar.
The one we are interested in this tutorial is _ID.scar.
_ID.scar file
Well, what is this file in particular and why are we so interested about it?
_ID.scar contains the list of Scar markers, entity groups aka. egroups, and squad groups aka. sgroups from your map. This file is sort of a directory of items listed above. This file also gives us the ability to include custom SCAR script to the map. In this tutorial we will use it for a bit more advanced implementation.
_ID.scar contains the list of Scar markers, entity groups aka. egroups, and squad groups aka. sgroups from your map. This file is sort of a directory of items listed above. This file also gives us the ability to include custom SCAR script to the map. In this tutorial we will use it for a bit more advanced implementation.
Adding the Code
Open _ID.scar in notepad / notepad++. It should look something like this:
Normally, when no Scar markers are placed nor squad/entity groups assigned (sgroups and egroups) _ID.scar will look exactly like this.
Let's get into adding code which creates the Classic population cap system:
Add the following code above last occurring "end"-word in the file:
Alternatively you can also obtain this code from pastebin.com.
and add the following code after last occurring "end"-word in the file:
Alternatively you can also obtain this code from pastebin.com.
The result should look something like this:
Alternatively you can also obtain this code from pastebin.com.
Code
function OnInitID()
-- [[ Markers ]]
-- [[ Squad Groups ]]
-- [[ Entity Groups ]]
end
Normally, when no Scar markers are placed nor squad/entity groups assigned (sgroups and egroups) _ID.scar will look exactly like this.
Let's get into adding code which creates the Classic population cap system:
Add the following code above last occurring "end"-word in the file:
Alternatively you can also obtain this code from pastebin.com.
and add the following code after last occurring "end"-word in the file:
Alternatively you can also obtain this code from pastebin.com.
The result should look something like this:
Alternatively you can also obtain this code from pastebin.com.
Testing the code
Save the _ID.scar and close the file. Goto WorldBuilder and DO NOT SAVE the map! You should have done that earlier. Just do File -> Export Package, run the game, start a match with your map. You should now be able to enjoy your map with the classic population cap system!
Configuring the code
This part in the code is all you need to edit in order to configure it:
It should be quite self-explanatory.
Code
_PopCapSystemConfig = {
default_basepop = {
[0] = 35,
[1] = 40,
},
grant_per_point = {
-- strategic
[1] = {
-- [0] = German, [1] = Soviet
[0] = 6,
[1] = 7,
},
-- fuel
[2] = {
[0] = 12,
[1] = 16,
},
-- muni
[3] = {
[0] = 12,
[1] = 16,
},
-- victory
[4] = {
[0] = 4,
[1] = 5,
},
},
}
It should be quite self-explanatory.
Conclusions
In this tutorial you learned how to add Classic population cap system to your custom map. I tried to spend some time to explain the important details instead of making this tutorial as short as humanly possible. Hopefully this will give you a better understanding of what you did instead of just adding the code to a file and getting results without knowing why. If you have any additional questions, feedback, or suggestions for future tutorials, please let me know in this thread!