API pointers for Golden Age, Movement

aerojockey

Chieftain
Joined
Sep 2, 2014
Messages
3
Hi. I have the XML part of the modding down pat now, but there are a few things I expect that Lua (at least) would be needed for. Would like pointers on where to start. (In terms of API, what hooks should I use. I already know how to program in Lua.)

1. First time a city builds a certain civilization-specific building, it triggers a Golden age. The building is not a Wonder, it's a regular building that any city in the civilization can build, and obviously I don't want a golden age every time a city builds it, just the first time.

2. I would like for there to be no movement penalty for units (domestic or foregin) to cross rivers inside the civilization's territory, and for this to be completely transparent (so that the AI can take advantage of it and the motion command takes it into account when drawing). Having browsed through some messages I would guess this is quite difficult, in which case I probably won't bother.
 
0) This will be your best friend!

1) Machiavelli's BuildingCreated snippet will do wonders for you.

2) If I'm not mistaken, there is already a tag in Traits for no movement cost when crossing rivers, so, you want to dabble in the DLL, this is a good place to start. There is also a <River/> boolean in the Promotions sections, I don't know how it works, but it may be what you want; so you just need to check an unit moving (GameEvents.UnitSetXY) and give it the promotion if within borders, removing if outside and having the Promotion.
 
Depending on what exactly you want to do you may not need lua (or the building created event). You can have a building start a Golden Age via XML (see the Taj Mahal as an example). I believe a building that is given by "FreeBuildingThisCity" can not be sold so what you'll want to try is:

1) Create a buildingClass (called say: building_civilizationName_golden_age) and building that can't be built (cost = -1, nukeImmune = true, ConquestProb=100) that starts a Golden Age.
2) Have your building give "FreeBuildingThisCity" -> "building_civilizationName_golden_age".
-------------
As for the no movement penalty for rivers (even for hostile players who are invading?) you will need to mod the DLL.
 
Only several months later I have a followup question, w.r.t. to the hidden building. I did what I think were suggesting, see XML below.


Code:
  <!-- So I define a building class here for a hidden building that will trigger a golden age -->
  <!-- It has MaxPlayerInstances at one so only one can be "built" -->

  <BuildingClasses>
    <Row>
      <Type>BUILDINGCLASS_FIRST_OBELISK</Type>
      <Description>TXT_KEY_FIRST_OBELISK_CLASS</Description>
      <DefaultBuilding>BUILDING_FIRST_OBELISK</DefaultBuilding>
      <MaxPlayerInstances>1</MaxPlayerInstances>
    </Row>
  </BuildingClasses>

  <!-- Now I define the actual building that implements the class and triggers the golden age -->
  <!-- It's marked as Cost=-1 so that it can't be built by normal means. Plus some other stuff
        so that it never disappears. -->

  <Buildings>
    <Row>
      <Type>BUILDING_FIRST_OBELISK</Type>
      <BuildingClass>BUILDINGCLASS_FIRST_OBELISK</BuildingClass>
      <Cost>-1</Cost>
      <Description>TXT_KEY_BUILDING_FIRST_OBELISK</Description>
      <Civilopedia>TXT_KEY_BUILDING_FIRST_OBELISK_NOTHING</Civilopedia>
      <Strategy>TXT_KEY_BUILDING_FIRST_OBELISK_NOTHING</Strategy>
      <Help>TXT_KEY_BUILDING_FIRST_OBELISK_NOTHING</Help>
      <NukeImmune>true</NukeImmune>
      <ConquestProb>100</ConquestProb>
      <MinAreaSize>-1</MinAreaSize>
      <GoldenAge>true</GoldenAge>
      <IconAtlas>CIV_COLOR_ATLAS_OBELISKISTAN</IconAtlas>
      <PortraitIndex>12</PortraitIndex>
    </Row>
  </Buildings>

  <!-- Then, under a real building which is Civilization-specific, I give the player the hidden building
       above for free. Presumably, since the building class for the hidden building is
       MaxPlayerInstances=1, the hidden building will be given for free only the first time the real
       building is built. -->

  <Buildings>
    <Row>
      <Type>BUILDING_OBELISK</Type>
      <BuildingClass>BUILDINGCLASS_MONUMENT</BuildingClass>
      <!-- etc. etc. -->
      <FreeBuildingThisCity>BUILDINGCLASS_FIRST_OBELISK</FreeBuildingThisCity>
    </Row>
  </Buildings>

That's how I understand it, and it seems to make sense. However, two problems. First, the hidden building isn't actually hidden. It appears in the city's list of buildings. This is minor and I can live with it.

Second, it seems as if the MaxPlayerInstances isn't being respected in this case. I get the hidden building for free (and thus a golden age) every time I build the real building. That would be a deal breaker for this technique.

But I am wondering if I understood you correctly, or if I am missing something. Thanks.
 
The building is not actually hidden because it's missing a <GreatWorkCount> of -1. Check LeeS' building guide for the minimum columns needed for a hidden building.

FreeBuilding (and stuff given in Lua) overrides / ignores limits placed in the XML, as those limits are generally only respected under "normal" circumstances (building or buying.) "Free" buildings are counted as exceptions by the game, and appear as a separate entity.
 
Back
Top Bottom