New units conforming to VP

Murderologist

Warlord
Joined
Jul 14, 2014
Messages
162
Just wondering how one would go about adjusting a mod that includes many new units to conform to VP standards. Mainly the giving the new units the proper starting free promotions for each unit type. I can edit the XML and change things like range, strength etc but the free promotions are a little more complicated.

Thank you
 
I think this works the same as in vanilla -- you'll have to add the unit/promo combo to Unit_FreePromotions table. There are ways to do this in SQL in a very efficient way for a lot of units, or if you have a lot of patience/time, you can just use the XML method to do each one individually.

For example, the following SQL deletes "ignore terrain cost" free promo on all recon units:
Code:
DELETE FROM Unit_FreePromotions
        WHERE PromotionType="PROMOTION_IGNORE_TERRAIN_COST" AND UnitType IN (SELECT Type FROM Units
        WHERE CombatClass='UNITCOMBAT_RECON');

You can nest the SELECT/DELETE FROM WHERE IN etc. operators as much as you like to create a very clever database command, and save yourself dozens of individual xml lines. The logic for these requires a little more thought to get right, but if you can figure out how to do these you'll save yourself a ton of time and tedium
 
When you add a new unit, I recommend first adding the basic information (text, graphics etc.) of the unit via XML.

Something like this:
XML:
<Row>
    <Type>UNIT_NEW_CRUISER</Type>
    <Description>TXT_KEY_NEW_CRUISER</Description>
    <Civilopedia>TXT_KEY_NEW_CRUISER_PEDIA</Civilopedia>
    <Strategy>TXT_KEY_NEW_CRUISER_STRATEGY</Strategy>
    <Help>TXT_KEY_NEW_CRUISER_HELP</Help>
    <Class>UNITCLASS_CRUISER</Class>
    <UnitArtInfo>ART_DEF_UNIT_NEW_CRUISER</UnitArtInfo>
    <UnitFlagAtlas>NEW_CRUISER_FLAG_ATLAS</UnitFlagAtlas>
    <UnitFlagIconOffset>12</UnitFlagIconOffset>
    <IconAtlas>NEW_CRUISER_ATLAS</IconAtlas>
    <PortraitIndex>16</PortraitIndex>
</Row>

Make sure you have the text and art already added to the database.

Then you copy and modify stats from the default unit of the same UnitClass, using SQL:
SQL:
UPDATE Units
SET
    Domain = (SELECT Domain FROM Units WHERE Type = 'UNIT_CRUISER'),
    CombatClass = (SELECT CombatClass FROM Units WHERE Type = 'UNIT_CRUISER'),
    IsMounted = (SELECT IsMounted FROM Units WHERE Type = 'UNIT_CRUISER'),
    DefaultUnitAI = (SELECT DefaultUnitAI FROM Units WHERE Type = 'UNIT_CRUISER'),
    Special = (SELECT Special FROM Units WHERE Type = 'UNIT_CRUISER'),
    PrereqTech = (SELECT PrereqTech FROM Units WHERE Type = 'UNIT_CRUISER'),
    -- UUs always obsolete at the same time as their upgrade unit
    -- If you want to be extra compatible (even if VP changes what Cruiser upgrades into), you can use more complicated SQL for that
    ObsoleteTech = (SELECT Domain FROM Units WHERE Type = 'UNIT_BATTLESHIP'),
    MoveRate = (SELECT MoveRate FROM Units WHERE Type = 'UNIT_CRUISER'),
    Moves = (SELECT Moves FROM Units WHERE Type = 'UNIT_CRUISER'),
    BaseSightRange = (SELECT BaseSightRange FROM Units WHERE Type = 'UNIT_CRUISER'),
    Combat = (SELECT Combat FROM Units WHERE Type = 'UNIT_CRUISER') + 3,
    RangedCombat = (SELECT RangedCombat FROM Units WHERE Type = 'UNIT_CRUISER') + 5,
    "Range" = (SELECT "Range" FROM Units WHERE Type = 'UNIT_CRUISER'),
    BaseLandAirDefense = (SELECT BaseLandAirDefense FROM Units WHERE Type = 'UNIT_CRUISER'),
    MilitarySupport = (SELECT MilitarySupport FROM Units WHERE Type = 'UNIT_CRUISER'),
    MilitaryProduction = (SELECT MilitaryProduction FROM Units WHERE Type = 'UNIT_CRUISER'),
    NoMaintenance = (SELECT NoMaintenance FROM Units WHERE Type = 'UNIT_CRUISER'),
    NoSupply = (SELECT NoSupply FROM Units WHERE Type = 'UNIT_CRUISER'),
    Pillage = (SELECT Pillage FROM Units WHERE Type = 'UNIT_CRUISER'),
    MoveAfterPurchase = (SELECT MoveAfterPurchase FROM Units WHERE Type = 'UNIT_CRUISER'),
    PurchaseCooldown = (SELECT PurchaseCooldown FROM Units WHERE Type = 'UNIT_CRUISER'),
    GlobalFaithPurchaseCooldown = (SELECT GlobalFaithPurchaseCooldown FROM Units WHERE Type = 'UNIT_CRUISER'),
    HurryCostModifier = (SELECT HurryCostModifier FROM Units WHERE Type = 'UNIT_CRUISER'),
    RequiresFaithPurchaseEnabled = (SELECT RequiresFaithPurchaseEnabled FROM Units WHERE Type = 'UNIT_CRUISER'),
    MinAreaSize = (SELECT MinAreaSize FROM Units WHERE Type = 'UNIT_CRUISER'),
    AirInterceptRange = (SELECT AirInterceptRange FROM Units WHERE Type = 'UNIT_CRUISER'),
    AirUnitCap = (SELECT AirUnitCap FROM Units WHERE Type = 'UNIT_CRUISER')
FROM Units
WHERE Type = 'UNIT_NEW_CRUISER';

Yes, that's every column normal military units of VP may have. Other units may have some extra special abilities on the Units table, but you can always find out in the database yourself.

Next, you copy entries of other unit tables:
SQL:
INSERT INTO Unit_FreePromotions
    (UnitType, PromotionType)
SELECT
    'UNIT_NEW_CRUISER', PromotionType
FROM Unit_FreePromotions
WHERE UnitType = 'UNIT_CRUISER';

INSERT INTO Unit_ResourceQuantityRequirements
    (UnitType, ResourceType, Cost)
SELECT
    'UNIT_NEW_CRUISER', ResourceType, Cost
FROM Unit_ResourceQuantityRequirements
WHERE UnitType = 'UNIT_CRUISER';
etc.

Have fun modding!
 
Last edited:
Why would a mod not reference its own XML inserted free promotions when VP is engaged? I have a mod that adds a unit with is own XML that includes free unit promotions with VP enabled. And another mod that has units with xml set up with free promotions but when VP is enabled all of them (the free promotions) are disabled. Any help would be appreciated.
 
Why would a mod not reference its own XML inserted free promotions when VP is engaged? I have a mod that adds a unit with is own XML that includes free unit promotions with VP enabled. And another mod that has units with xml set up with free promotions but when VP is enabled all of them (the free promotions) are disabled. Any help would be appreciated.
Vox Populi for some reason has a setting that deletes all free promotions (probably easier to clean up but whatever)

Your mod must load after Vox Populi is loaded by setting it as a dependency.
 
Vox Populi for some reason has a setting that deletes all free promotions (probably easier to clean up but whatever)

Your mod must load after Vox Populi is loaded by setting it as a dependency.
You could also have it reference, rather than dependency, if you want it to work both with/without VP

I think the delete occurs in the first module of the mod? ie the (1) Community Patch part; just adding this one as dependency is usually sufficient
 
It's actually easier to delete and then re-add everything for most non-main tables.

And it's better to show that a modmod isn't balanced with VP in mind, by breaking it :p
 
Top Bottom