Making New Promotions

CivOasis

Ahuizotl
Joined
Jun 22, 2011
Messages
3,005
Location
Sawaiki
Ok, so, I'm trying to add a unique ability for a new civ. Therefore, I would like to make two new promotions.
First up, a 50% combat penalty for all units.
Secondly, a 150% combat bonus for one unit (50% of that is to counter the other promotion), when in friendly territory.

How would one do this?
 
First up, a 50% combat penalty for all units.
Secondly, a 150% combat bonus for one unit (50% of that is to counter the other promotion), when in friendly territory.

The first is trivial to do, just create a promotion with a -50 value in the <CombatPercent> field. Giving it to all of your units isn't hard; you can either use XML (say, use the <FreePromotion> tab in the Buildings table on the Palace, so that every unit always gets it) or give it through Lua (SerialEventUnitCreated).

The second's a lot more problematic. You can add a bonus for friendly territory easily enough, but it depends on what you mean by "for one unit". Is this bonus only against a certain type of unit? In that case no, you can't make it only work when within friendly territory; the stub used for one is incompatible with the table used for the other. Or more specifically you CAN make it work, but only with a large amount of Lua hacking.
 
Ok, so, one question, one response.
First off, the question: I don't know how to make a promotion, period. How do I do that?
Second, the response: I'm trying to add it to one unit, not against one unit (I.E., the UU will get a bonus in friendly territory).
 
First off, the question: I don't know how to make a promotion, period. How do I do that?

Same way you make a unit, building, etc. Add a new Row, just like the ones in the existing UnitPromotions table. If it's something you don't want other units to get, just make sure you add the <CannotBeChosen> flag. And if it cannot be chosen through normal means, then you have no need to give it flavor values or UnitCombat restrictions.

If you want all units to get the promotion, then you'd have to bestow it using one of the methods I've mentioned previously. But if you only want this to be specifically given to a single unit, all you need is a single entry in the <Unit_FreePromotions> table expressing the unit type name and promotion type name.

Second, the response: I'm trying to add it to one unit, not against one unit (I.E., the UU will get a bonus in friendly territory).

Then all you need is to use the <FriendlyLandsModifier> entry, or if you only want it to apply when attacking, the <FriendlyLandsAttackModifier>. In the vanilla game, these are already used for the Himeji Castle (wonder) and Nationalism (policy) promotions respectively; at one point the Minuteman (American UU) had the FriendlyLandsModifier as well, but they changed that unit to a movement bonus long ago.

For instance, from my own mod, here's a promotion that I give to every unit in the game, through the Palace. It gives each unit +10% when fighting in friendly territory, plus an additional +10% when ATTACKING in friendly territory (i.e., counterattacking an invasion force), using both of the stubs mentioned above.
Code:
<GameData>
  <UnitPromotions>
    <Row>
      <Type>PROMOTION_HOME_FIELD</Type>
      <Description>TXT_KEY_PROMOTION_HOME_FIELD</Description>
      <Help>TXT_KEY_PROMOTION_HOME_FIELD_HELP</Help>
      <Sound>AS2D_IF_LEVELUP</Sound>
      <CannotBeChosen>true</CannotBeChosen>
      <FriendlyLandsModifier>10</FriendlyLandsModifier>
      <FriendlyLandsAttackModifier>10</FriendlyLandsAttackModifier>
      <PortraitIndex>59</PortraitIndex>
      <IconAtlas>ABILITY_ATLAS</IconAtlas>
      <PediaType>PEDIA_SHARED</PediaType>
      <PediaEntry>TXT_KEY_PROMOTION_HOME_FIELD</PediaEntry>
    </Row> 
  </UnitPromotions>
</GameData>

(ABILITY ATLAS #59 is the generic gold up-arrow icon. 56 is the red down-arrow used for generic penalties.)

Now, one thing: -50% and 150% are absolutely HUGE modifiers, drowning out everything else in the game. This is generally bad, since the AI isn't built to handle that sort of variation in power; it doesn't do rock-paper-scissors very well.
 
Thanks for the help Spatz, I think that should be all I need.
And, I realize these are massive modifiers, they're just part of a UA. I'll probably (99%) change these before I'm done.
 
Additional questions:
How do you improve the yields of tiles, through buildings?
Same goes for through a UA, though, since I know that's got some issues, what's "the best" way to do that?
 
Back
Top Bottom