Nowadays there are several bonuses that give a certain resource passively, mostly gold. To cite a few we have Poles stone miners, Portuguese foragers or Vietnamese lumberjacks. All these bonuses are implemented with Feitoria units, units that have the ability to generate a certain resource. To illustrate all the details of the implementation, let's look at the burgundian team bonus, that makes relics generate food.
We need to program the creation of a Feitoria unit only for burgundian allies. This unit will appear when a Monastery is built. If we look at the Monastery, unit 104, we can see that it has an annex unit, 903, called ``Burgundian relic annex (dummy)''. This unit does nothing and dies immediately, as most players should not get the bonus.
Whenever a player is allied to a burgundian, effect 738 upgrades the dummy annex to unit 1387, ``relic annex''. This unit dies immediately but turns into unit 1388, ``relic annex food''. With this, it separates from the monastery and won't die if the monastery is destroyed. Also, it triggers technology 805 to disable future monasteries to produce additional annex units.
This new unit has task ``Generate resources''. The fields that interest us are ``Productivity resource'', set to ``Relics captured'', and ``Work value 1'', set to 0.5. Also, the corresponding entry in the ``Looting Table'' must be set to 1. This means that, every second, the unit produces the amount of food equal to the work value multiplied by the productivity resource. Other bonuses like the vietnamese one have as productivity resource a resource that tracks the number of working lumberjacks.
Technically we are done as with this implementation, we obtain the generation of resources. Unfortunately, we still have three problems:
Problem 2 is solved by giving these units class 9, which corresponds to Prey animals such as deers. This makes enemies ignore it.
Problem 3 is solved via the patch, by instructing the game to kill the unit when all other units are dead.
We need to program the creation of a Feitoria unit only for burgundian allies. This unit will appear when a Monastery is built. If we look at the Monastery, unit 104, we can see that it has an annex unit, 903, called ``Burgundian relic annex (dummy)''. This unit does nothing and dies immediately, as most players should not get the bonus.
Whenever a player is allied to a burgundian, effect 738 upgrades the dummy annex to unit 1387, ``relic annex''. This unit dies immediately but turns into unit 1388, ``relic annex food''. With this, it separates from the monastery and won't die if the monastery is destroyed. Also, it triggers technology 805 to disable future monasteries to produce additional annex units.
This new unit has task ``Generate resources''. The fields that interest us are ``Productivity resource'', set to ``Relics captured'', and ``Work value 1'', set to 0.5. Also, the corresponding entry in the ``Looting Table'' must be set to 1. This means that, every second, the unit produces the amount of food equal to the work value multiplied by the productivity resource. Other bonuses like the vietnamese one have as productivity resource a resource that tracks the number of working lumberjacks.
Technically we are done as with this implementation, we obtain the generation of resources. Unfortunately, we still have three problems:
- The unit may die from splash damage if not provided with enough health.
- Although the unit is invisible, it can be detected by enemy units, thus distracting them.
- The unit belongs to the player and therefore has to die in order to eliminate a player. Finding and killing an invisible unit should not be a requirement.
Problem 2 is solved by giving these units class 9, which corresponds to Prey animals such as deers. This makes enemies ignore it.
Problem 3 is solved via the patch, by instructing the game to kill the unit when all other units are dead.