How-to: Custom Starting Resources & Income rate

How-To: Custom Starting Resources

Basics

In this tutorial you will learn how to set custom starting resources for your map. To do this, 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 notepad-plus-plus.org

The Script File

All maps can be shipped with a custom script file. This file is always named as <mapname>.scar, where <mapname> is same as the name of your map's .sgb file. You can create this file by opening notepad or notepad++, and by saving a new blank document as <mapname>.scar to your map folder.

Adding code to override default starting resources

Open <mapname>.scar in notepad / notepad++ if you have closed it.

Copy and paste in the following code:
Alternatively you can also download this .zip archive, which contains a pre-made scar file with the following code. Extract it and move the .scar file to your map's folder and rename the .scar file to match your .sbg file name!

Code

function CustomStartingResources_Init() --[[ CustomStartingResource System created by Janne252. Visit COH2.ORG for more. Please do not remove this note.

Some information about income_modifier table and how to use it: - All resource income modifiers affect the # per minute value. - By default all resource income modifiers are set to 1 (value = 1, math_type = MUT_Multiplication). As you know, anything * 1 is the same value. - MUT_Multiplication multiplies the income rate and MUT_Addition adds to it. Here are some examples of that: - Let's say manpower income is 294 manpower per minute. With value = 10, math_type = MUT_Multiplication we will get 2940 manpower per minute, since 294 * 10 = 2940. Let's say manpower income is still 294 manpower per minute. With value = 10, math_type = MUT_Addition, we will get 304 manpower per minute, since 294 + 10 = 304.

Testing the results

Save the <mapname>.scar and close the file. Goto WorldBuilder and do File -> Export Package, run the game, start a match with your map. You should now be able to see custom starting resources. This example uses a pre-made set called ResourceSets.customSet_01, which sets the following:

Configuring the code to match your needs

This example comes with four pre-made resource sets, which are called standard, highResources, customSet_01, and customSet_02. First 2 are just copies of the already existing ones and the two customSets are there for customization.

To change which set to use, simply change g_ResourceSet to match the desired resource set, e.g.

Code

local g_ResourceSet = ResourceSets.customSet_02

You can edit any of the resource pre-sets by editing the values. They should be quite self-explanatory, but here they are:

Conclusions

In this tutorial you learned how to set custom starting resources for your map. I tried to spend some time to explain stuff a bit more briefly instead of making this tutorial as humanly short as 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, feed back, or suggestions for future tutorials, please let me know in this thread!

I was surprised for finding Notepad++ from university desktops. I guess it's unbeatable for vast amount of supported code languages and free cost.
I use it for all kind coding environments not having a built-in IDE. (e.g. Visual C# has IDE).

As my English is bad enough, I can not write out the lines
I want to know or do you replace it for resources numbers of departures exactly. I succeeded once but it was a fluke now when I launch the game it crashes
A (big) helping hand would be welcome
it does not work
WordBuilder in the west is called Oberkommando west_german and us forces is called aef, you do not replace it rather than those it marked?
Have not you made ​​a mistake on the first line because you deleted "function OnInitID ()"?

This thread has been super helpful and thank you for it greatly! However, I am having issues with setting the resource rates. I have set the starting resources, but I am not too exactly sure where to place the "Modify_PlayerResourceRate(World_GetPlayerAt(1), RT_Manpower, 2)" or if I have to do it for each player (looking at the get player at 1 part). Would love some clarification! Also, do bots use these same settings or is it simply for actual players? Not sure if bot build order is changed with increased resources. Thank you very much!

nigo: Furthermore, because developing digital games is less costly than developing packaged game software, the digital game market sees numerous title launchesToday, 17:41 PM

nigo: Developmental lead times for digital games, for which the main business model is F2P*, are relatively short compared with those for pay-to-play packaged game software. Furthermore, because developing digital games is less costly than developing packaged gaToday, 17:40 PM