How do I mark a unit as being off-limits for Barbarian spawns?

Gubbey

Chieftain
Joined
Apr 25, 2014
Messages
12
My mod includes a new melee unit that becomes available with a religious belief, but this unit is spawning in Barbarian camps. Which is hilarious, but also pretty imbalanced in the early game.

I know Warrior Monks (also a religious-exclusive unit) never spawn in Barbarian camps or raids, but I can't seem to find where and how this restriction is referenced. I know Barbarian camps will spawn units of the CLASS_MELEE class, but commenting out this class didn't fix the issue.

Any help would be appreciated. I can also provide my files if need be.

Thanks in advance!
 
Warrior Monks are not part of CLASS_MELEE. The only class they are attached to is CLASS_WARRIOR_MONK. They also have their own unique promotion tree
Code:
PromotionClass="PROMOTION_CLASS_MONK"
In table units they have
Code:
<Row UnitType="UNIT_WARRIOR_MONK" Cost="100" Maintenance="2" BaseMoves="3" BaseSightRange="2" ZoneOfControl="true" Domain="DOMAIN_LAND" Combat="35"
	FormationClass="FORMATION_CLASS_LAND_COMBAT" PromotionClass="PROMOTION_CLASS_MONK" Name="LOC_UNIT_WARRIOR_MONK_NAME"
	Description="LOC_UNIT_WARRIOR_MONK_DESCRIPTION" PurchaseYield="YIELD_FAITH" TrackReligion="TRUE" MustPurchase="TRUE" EnabledByReligion="true"/>
Columns TrackReligion and EnabledByReligion appear to be the important ones for tying a unit to a specific belief. TrackReligion is used by Missionaries, Inquisitors, Gurus, etc. also, but none of them also has EnabledByReligion. Warrior Monks are in fact the only unit where EnabledByReligion is set to true.

Generally, unless a unit is assigned to a TraitType, if it is a FORMATION_CLASS_LAND_COMBAT or FORMATION_CLASS_NAVAL then the Barbs seem able to use it. Resource requirements also appear to affect whether the barbs can use a unit, but the problem with which units barbs can use and how this is defined keeps evolving in the code. The Units column AllowBarbarians was used upon initial game release but now does not appear to be used as all units have this column set to false.
 
Last edited:
Since I used the Warrior Monk as a template, the unit already had EnabledByReligion = 1, so I can confirm that this does not deter the barbs from sending them forth.

Removing CLASS_MELEE and leaving it only with its unique class seems to have fixed the issue, though. Thanks for the help!
 
Top Bottom