Handicap mode

The Handicap mode is a new feature introduced in Definitive Edition designed to balance teams where players have very different levels. It boosts some players in several ways:
  • Faster gather rate for villagers.
  • Higher carry capacity.
  • More starting resources.
  • Higher Villager HP.
  • Faster build speed.
  • More HP on all buildings.
  • More bonus damage for counter units.
  • Faster work rate for military buildings.
The handicaps levels are set via a percentage, 100% being no boost at all and 200% the maximum value.

Basic implementation of the handicap​

An implementation of the handicap mode is very straightforward to come up with. We just need several technologies, each with an effect that boosts the aforemontioned stats by the desired percentage. This technologies have positive research time so that they don’t activate on their own and no button to research it with, so that they are hidden from players.

Now, how can we have those technologies affect only specific players? If we were to program them in an scenario, that’s easy; we just need some triggers at the beginning of the game that research the handicap technologies for each player. With that in mind, I made sure that the handicap technologies are visible in the scenario editor, for people to access them easily.

The handicap mode in a random map​

Unfortunately, this idea of the technologies can not be ported to random maps. Random map scripts are very versatile in what you can modify from the game (names, stats, resources…) but all the changes affect all players, there is no way to control that effects only affect some of the players.

However, there is something that we can control for individual players: the units they receive. This either is a very simple concept, it uses several concepts of random map scripting:
  • Players have to be created with the “direct_placement” command.
  • We create lands and assing them for specific player numbers with the “ASSING_TO_AT COLOR” command.
  • Additionally, we need to identify those lands with the command “land_id”.
  • When creating objects, we can control which players receive them by using the command “place_on_specific_land_id”.
This method gives us a land for each player and the posibility to place individual units in that land that will appear only for the players owning them. These lands with id will be different from the actual player lands where the Town Center and villagers are placed.

Since the only thing we can link to these lands are units, we need units that trigger the handicap technologies. This is easy to do, as buildings have an “Inititates Technology” field. I have created several buildings with no volume, no graphics, that die instantly and that trigger the desired handicap technology.

Let’s see an example. Say you want the player using blue to receive a 120% handicap. In the map script we need to create a land, assign it to color 1 and give it an id. Then we create an object HANDICAP_120 and place it on that land id. Since the land belongs to color 1, it will have that color. When the game begins, the handicap unit will trigger its technology and die instantly, giving the handicap effect.

The handicap map creator​

The final problem we need to solve is the huge casuistic that comes with colors, teams and handicap levels. Since creating every combination on a map would result on a huge mod with too many files to be possible to find the correct one, I’ve created a program that creates the specific combination the players need. You can see the source code by downloading the mod.

The code reuses the circles and fixed positions code I’ve already shared and adds the extra lands with id for the handicap units. The program is comprised of 4 modules:
  • Handicap. Main one that creates the interface.
  • map_creator. That generates the rms file.
  • circle_creator. That generates the player lands, placing them around a circle. It also creates the lands with id, using the same terrain as the player lands and placing them on top of the player land.
  • indentation. That rewrites the rms to add indentation and help readability.
The program offers several maps that are accessed from the “maps_data” folder. This way, the source code doesn’t have to be modified to add new maps, only their information is needed. Each map is divided into 5 files:
  • constants: Initial constants to decide vegetation and animals.
  • land_generation: code for the <LAND_GENERATION> section that is not player lands.
  • objects_generation: code for the <OBJECTS_GENERATION> section.
  • other_generation: code for the TERRAIN, CLIFF, ELEVATION and CONNECTION sections.
  • main: specific pieces of code that have to be read by the program. The entries have comments and you only need to respect the empty lines between sections.
The map_creator module accesses each file and combines them into an rms file, adding the circle generation and the handicap units when needed.
Top Bottom