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

UnitPerks grant Promotions

Discussion in 'CivBE - Code Snippets' started by Machiavelli24, May 9, 2015.

  1. Machiavelli24

    Machiavelli24 Mod creator

    May 9, 2012
    This code is compatible with vanilla Beyond Earth. It is not compatible with Rising Tide. I am working on an update.

    CivFanatics Download
    Workshop Download

    What it does
    This mod contains code that defines a new XML table. By adding entries to this table mod makers can have UnitUpgrades grant Promotions. This works identically for UnitPerks that are inherently part of unit upgrades and UnitPerks that are choices. If an end-user is playing with multiple mods that use this snippet it will work properly.

    UnitPerks_UGP_FreePromotions: <PerkType, PromotionType>
    Any unit with the PerkType will automatically be given the PromotionType.

    How to incorporate into your mod
    Copy the "UnitPerks Grant Promotions", "UnitCreatedEvent" and "UnitUpgradedEvent" directory and all its contents to your mod. "UnitPerks Grant Promotions" will only work if you are also using the "UnitCreatedEvent" and "UnitUpgradedEvent" snippets. Have the XML file update the database (via the Action tab) and set the LUA file as an "InGameUIAddin" (via the Content tab).

    Make sure the XML files from this snippet that create the table update the database before any files attempt to add entries into the tables for this snippet.

    In the UI folder UnitUpgradePopup.lua will need to be added via "InGameUIAddin" and have VFS set to true. It will replace the existing UnitUpgradePopup.lua. Without it the help text from the promotions will not show up when a player is looking at perks in the unit upgrade UI (but the promotions will still be granted).

    How to use
    Add entries to one of the UnitPerks_UGP_FreePromotions table.

    How it works
    A collection of functions detect when a player creates a new unit or a unit is upgraded. When one of these happen it looks for all UnitPerks the unit has and gives the unit any promotions that match those UnitPerks in the UnitPerks_UGP_FreePromotions table. The algorithm does not poll every turn and units will be given the promotion right away, not next turn.

    If a UnitUpgrade does not change the art style of a unit (currently all in game UnitUpgrades do change the art of a unit) this code may not grant units that existed during the upgrade any promotions associated.

Share This Page