Login

russian armor

How-to: Custom Population Cap

26 Dec 2013, 21:22 PM
#1
avatar of Janne252
Admin Red  Badge
Patrion 15

Posts: 2601 | Subs: 5

How-To: Custom Population Cap



Basics



In this tutorial you will learn how to set a custom population cap limit 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

Important Note



One thing you should notice and understand before going any further:
Every time you save your map in WorldBuilder, yourMapname_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 yourMapname.sgb file, which is the main file containing all the data of your map. There are also other files, such as yourMapname.tga, yourMapname.info, yourMapname.options, and yourMapname_ID.scar.
The one we are interested in this tutorial is yourMapname_ID.scar.

yourMapname_ID.scar file



Well, what is this file in particular and why are we so interested about it?
yourMapname_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 very basic implementation.

Adding code to edit population cap



Open yourMapname_ID.scar in notepad / notepad++. It should look something like this:
Code

function OnInitID()

-- [[ Markers ]]

-- [[ Squad Groups ]]

-- [[ Entity Groups ]]

end


Normally, when no Scar markers are placed nor squad/entity groups assigned (sgroups and egroups) yourMapname_ID.scar will look exactly like this. Let's get into adding the custom population cap code!

Add the following code below the line function OnInitID():
Code

--Population cap override value
g_popCapOverRide = 200

for i = 1, World_GetPlayerCount() do
local player = World_GetPlayerAt(i)
Player_SetPopCapOverride(player, g_popCapOverRide)
end


The result should look something like this:
Code

function OnInitID()
--Population cap override value
g_popCapOverRide = 200

for i = 1, World_GetPlayerCount() do
local player = World_GetPlayerAt(i)
Player_SetPopCapOverride(player, g_popCapOverRide)
end

-- [[ Markers ]]

-- [[ Squad Groups ]]

-- [[ Entity Groups ]]

end


Testing the results



Save the yourMapname_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 see the population cap of 200 in your map.

Configuring the code to match your needs



I assume you are not happy with the population cap of 200. Perhaps you'd like to make it 300? Well, doing that is quite easy. I assume you already know how to do it if you spent some time reading the code you pasted into yourMapname_ID.scar. You can edit the population cap by changing the value of popCapOverRide, e.g. change it to 300 by doing following:
Code

g_popCapOverRide = 300


Hit save, Export package, run your map and voilà!


Conclusions


In this tutorial you learned how to set a custom population cap 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!


26 Dec 2013, 22:54 PM
#2
avatar of TheSphinx

Posts: 21

thx a lot for this instructions.

the popcap on standartmaps is too low.

thanks for the great work janne
26 Dec 2013, 23:00 PM
#3
avatar of Qvazar

Posts: 801

Are there any documentation for the API some where?
How do you know there's global functions named World_GetPlayerCount and Player_SetPopCapOverride?

I don't want the fish, I want to learn how to fish! :)
26 Dec 2013, 23:17 PM
#4
avatar of Janne252
Admin Red  Badge
Patrion 15

Posts: 2601 | Subs: 5

jump backJump back to quoted post26 Dec 2013, 23:00 PMQvazar
Are there any documentation for the API some where?
How do you know there's global functions named World_GetPlayerCount and Player_SetPopCapOverride?

I don't want the fish, I want to learn how to fish! :)


Here ya go, a very basic instructions on how to use a fishing rod.
26 Dec 2013, 23:19 PM
#5
avatar of Von Kluge
Director of Social Media Badge
Patrion 14

Posts: 2857 | Subs: 3

Imagine if Qvazar gets up to speed and forms an allegiance with Janne... Ultramegamoddingteam !
26 Dec 2013, 23:38 PM
#6
avatar of Qvazar

Posts: 801



Here ya go, a very basic instructions on how to use a fishing rod.

EXACTLY what I was asking for, thank you, instant bookmark! :wub:
26 Dec 2013, 23:44 PM
#7
avatar of Janne252
Admin Red  Badge
Patrion 15

Posts: 2601 | Subs: 5

jump backJump back to quoted post26 Dec 2013, 23:38 PMQvazar

EXACTLY what I was asking for, thank you, instant bookmark! :wub:


Keep in mind that some of those functions might be outdated. For example BP_IsPropertyBagGroupValid(groupname) does not exist in CoH2. That is the only major function missing. Others are more or less already useless.
11 Feb 2014, 21:04 PM
#8
avatar of ozzy1001

Posts: 1

cant get it to work.

function OnInitID()
--Population cap override value
g_popCapOverRide = 200

for i = 1, World_GetPlayerCount() do
local player = World_GetPlayerAt(i)
Player_SetPopCapOverride(player, g_popCapOverRide)
end

-- [[ Markers ]]

-- [[ Squad Groups ]]

-- [[ Entity Groups ]]

end

this is the code in my testmap file. Also i cant find downloaded maps with worldbuilder

is it still possible to increase popcap?
11 Feb 2014, 22:32 PM
#9
avatar of Janne252
Admin Red  Badge
Patrion 15

Posts: 2601 | Subs: 5

Are you sure you have exported the map after saving <mapname>_ID.scar with that content? The code seems fine to me. Please note you have to add the code again if you save the map in the WorldBuilder.
24 Jun 2014, 20:47 PM
#10
avatar of RivetrPlate12

Posts: 4

Thank you very much !
3 Oct 2014, 03:59 AM
#11
avatar of AxeMan

Posts: 3

Hi there.
i used this and it worked very well so thanks for that but... now the ai just sits there on the spawn point and just is well stalled any way to fix this and keep the pop cap?
4 Oct 2014, 02:42 AM
#12
avatar of Srinidhalaya
Mapmaker Badge

Posts: 342 | Subs: 1

23 Dec 2014, 08:57 AM
#13
avatar of paddlefiddle

Posts: 6

This works very well, thanks. Would you happen to know how or even if it is possible to increase the manpower rate independent of the points?

24 Dec 2014, 07:23 AM
#14
avatar of Mirage357
Mapmaker Badge

Posts: 331

@paddlefiddle, here's a link to another helpful tutorial about Resources by Janne.

How-To: Custom Starting Resources (have no fear if you read through it a little way you will find the resource rates Janne added to the page)
1 user is browsing this thread: 1 guest
$3912.51
Contribute!
Operation Charlie Fox registration opens in...

SHOUT IT OUT!

No Profanity Number of Shouts
Refresh Shout Box
QueenRatchet123: Like there's no debate. Rifle weren't cutting it, so they are getting buffed. :romeoMug:
Today, 03:39 AM
velmarg: Dem changes though. Freedom will ring.
Today, 03:36 AM
velmarg: I mean, it's the unit with arguably the best scaling into the late game, with low recruit/reinforce costs being compared to the unit with the WORST scaling, lowest durability and highest recruit/reinforce costs of any of the core combat units.
Today, 03:36 AM
QueenRatchet123: It not a "gigantic deal". But its massive when an inf squad is cheaper than yours and can scale better. Again, it doesnt matter, usf is getting massive buffs.
Today, 03:35 AM
iTzDusty: Yes, grens are pretty nuts, don't get me wrong. People make it sound like the end of the world though, and thats where it gets annoying to argue when one person thinks its a gigantic deal.
Today, 03:10 AM
QueenRatchet123: Grens are a huge reason why usf gets raped by Ost. It doesnt matter, usf is getting massive buffs :romeoMug:
Today, 03:04 AM
iTzDusty: I mean when you are trying to address for the 60th time why Gren LMGs are more cost efficient and it isn't the reason they are losing as USF, I guess you lose your mind.
Today, 02:53 AM
iTzDusty: No dude Im totally an elitist prick when it comes to arguing, I'll admit. I'll dismiss 90% of peoples arguments without telling them why they are wrong because I don't find it worth my time and point to my stats.
Today, 02:52 AM
FestiveLongJohns: @Dusty, You're not an elitist prick? Just embrace it man!
Today, 02:50 AM
iTzDusty: Man, I don't really know to argue on the coh subreddit without sounding like an elitist prick. Like, quoting unit stats or explaining abilities get met with the dumbest remarks.
Today, 02:45 AM

Ladders Top 10

  • #
    Steam Alias
    W
    L
    %
    Streak
Data provided by Relic Relic Entertainment

Replay highlight

VS
  • U.S. Forces flag RUKAclNoggano
  • Oberkommando West flag Jesulin va to' burlao'
uploaded by jesulin

Board Info

972 posts in the last 24h
5104 posts in the last week
18052 posts in the last month
Registered members: 11733
Welcome our newest member, Blaine
Most online: 775 users on 26 Oct 2014, 01:01 AM