1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Culture Buildings - Vanilla and G&K cross-compatibility

Discussion in 'Civ5 - Modding Tutorials & Reference' started by whoward69, Jul 9, 2012.

  1. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,426
    Location:
    Near Portsmouth, UK
    You can create a single "Culture Building" mod that works with both "Vanilla 674/705" and "Gods and Kings" if 1) you're happy using sql and 2) you can accept one "Column does not exist" error in database.log

    Create three files, one for the main building data (UBDojo.xml below, but could be done with sql), one for the 674/705 culture value (UBDojo674.sql) and one for the G&K culture/faith yields (UBDojoGaK.sql)

    You cannot merge the two SQL files as the culture column does not exist in the G&K database so the resultant error will fail the entire file.

    You could include the main building data into the UBDojoGaK.sql file, but then you would have both common and G&K specific SQL statements in the same file, so I wouldn't recommend it from a maintainability point-of-view

    All three files need OnModActivated -> UpdateDatabase entries and the file with the common building data (UBDojo.xml below) MUST come first in the list

    UBDojo.xml

    Code:
    <GameData>
      <Buildings>
        <Row>
          <Type>BUILDING_DOJO</Type>
          <BuildingClass>BUILDINGCLASS_BARRACKS</BuildingClass>
          <Cost>75</Cost>
          <GoldMaintenance>1</GoldMaintenance>
          <PrereqTech>TECH_BRONZE_WORKING</PrereqTech>
          <!-- Culture is set via SQL
          <Culture>2</Culture>
          -->
    
    etc
    
        </Row>
      </Buildings>
    </GameData>
    
    UBDojo674.sql

    Code:
    -- This has to be in its own file so the "no such column: Culture" error can be ignored by Gods and Kings
    UPDATE Buildings
      SET Culture=2
      WHERE Type='BUILDING_DOJO'
      AND EXISTS (SELECT Value FROM Defines WHERE Name='MAX_HIT_POINTS' AND Value=10);
    
    UBDojoGaK.sql

    Code:
    INSERT INTO Building_YieldChanges(BuildingType, YieldType, Yield)
      SELECT Type, 'YIELD_CULTURE', 2 FROM Buildings
        WHERE Type='BUILDING_DOJO'
        AND EXISTS (SELECT Value FROM Defines WHERE Name='MAX_HIT_POINTS' AND Value=100);
    
    There may be a "better" way of detecting "674/705" vs "G&K" but the number of hit-points a unit has does the trick.

    Also the EXISTS clause is not strictly necessary in the UBDojo674.sql file but it adds to the clarity of the statement and defends against another mod altering the Buildings table
     

Share This Page