Unique unit not replacing existing

Atlantiantokra

Chieftain
Joined
Oct 11, 2022
Messages
1
I'm trying to add 2 custom units to a custom civ, one which replaces an existing unit and one which is a new upgrade of an existing unit. Everything about them works except that the replacement unit appears instead as a new unit.
Searches on here for this error suggest that TraitType is missing but it's the 4th line(field/entry?) of <Units> and the units are only appearing for my civ.
If there's a mistake with <UnitReplaces> I can't see what it is


SQL:
INSERT INTO Types
        (Type,                                                Kind                    )
VALUES    ('TRAIT_CIVILIZATION_JB_LONGBOWMAN',                'KIND_TRAIT'            ),
        ('UNIT_JB_LONGBOWMAN',                                'KIND_UNIT'                ),
        ('TRAIT_CIVILIZATION_JB_SNIPER',                    'KIND_TRAIT'            ),
        ('UNIT_JB_SNIPER',                                    'KIND_UNIT'                );

INSERT INTO TypeTags (Type,        Tag)
SELECT     'UNIT_JB_LONGBOWMAN',    Tag
FROM     TypeTags
WHERE     Type = 'UNIT_CROSSBOWMAN';

INSERT INTO TypeTags (Type,        Tag)
SELECT     'UNIT_JB_SNIPER',    Tag
FROM     TypeTags
WHERE     Type = 'UNIT_RANGER';

 
INSERT INTO Traits
        (TraitType,                                Name,                                Description                                )
VALUES    ('TRAIT_CIVILIZATION_JB_LONGBOWMAN',    'LOC_UNIT_JB_LONGBOWMAN_NAME',        'LOC_UNIT_JB_LONGBOWMAN_DESCRIPTION'    ),
        ('TRAIT_CIVILIZATION_JB_SNIPER',        'LOC_UNIT_JB_SNIPER_NAME',            'LOC_UNIT_JB_SNIPER_DESCRIPTION'        );

    
INSERT INTO CivilizationTraits
        (CivilizationType,                    TraitType                                )
VALUES    ('CIVILIZATION_JB_CUSTOM',        'TRAIT_CIVILIZATION_JB_LONGBOWMAN'        ),
        ('CIVILIZATION_JB_CUSTOM',        'TRAIT_CIVILIZATION_JB_SNIPER'            );

 
INSERT INTO Units    (
        UnitType,
        Name,
        Description,
        TraitType,
        BaseMoves,
        Cost,
        PurchaseYield,
        AdvisorType,
        Combat,
        RangedCombat,
        Range,
        BaseSightRange,
        ZoneOfControl,
        Domain,
        FormationClass,
        PromotionClass,
        Maintenance,
        MandatoryObsoleteTech,
        PrereqTech
        )
VALUES    ('UNIT_JB_LONGBOWMAN',
        'LOC_UNIT_JB_LONGBOWMAN_NAME',
        'LOC_UNIT_JB_LONGBOWMAN_DESCRIPTION',
        'TRAIT_CIVILIZATION_JB_LONGBOWMAN',
        2,
        200,
        'YIELD_GOLD',
        'ADVISOR_CONQUEST',
        30,
        45,
        3,
        2,
        0,
        'DOMAIN_LAND',
        'FORMATION_CLASS_LAND_COMBAT',
        'PROMOTION_CLASS_RANGED',
        3,
        'TECH_ADVANCED_BALLISTICS',
        'TECH_MACHINERY');

INSERT INTO Units (
        UnitType,
        Name,
        Description,
        TraitType,
        BaseMoves,
        Cost,
        PurchaseYield,
        AdvisorType,
        Combat,
        RangedCombat,
        Range,
        BaseSightRange,
        ZoneOfControl,
        Domain,
        FormationClass,
        PromotionClass,
        Maintenance,
        PrereqTech
        )
VALUES    (
        'UNIT_JB_SNIPER',
        'LOC_UNIT_JB_SNIPER_NAME',
        'LOC_UNIT_JB_SNIPER_DESCRIPTION',
        'TRAIT_CIVILIZATION_JB_SNIPER',
        3,
        580,
        'YIELD_GOLD',
        'ADVISOR_CONQUEST',
        45,
        90,
        3,
        3,
        0,
        'DOMAIN_LAND',
        'FORMATION_CLASS_LAND_COMBAT',
        'PROMOTION_CLASS_RECON',
        8,
        'TECH_ADVANCED_BALLISTICS');
    
    
INSERT INTO UnitUpgrades
        (Unit,            UpgradeUnit)
VALUES    ('UNIT_JB_LONGBOWMAN', 'UNIT_FIELD_CANNON'),
        ('UNIT_RANGER',    'UNIT_JB_SNIPER');


    
INSERT INTO UnitReplaces
        (CivUniqueUnitType,        ReplacesUnitType)
VALUES    ('UNIT_JB_LONGBOWMAN',    'UNIT_CROSSBOWMAN'    );

    

INSERT INTO UnitAiInfos (UnitType,    AiType)
SELECT     'UNIT_JB_LONGBOWMAN',        AiType
FROM     UnitAiInfos
WHERE     UnitType = 'UNIT_CROSSBOWMAN';

INSERT INTO UnitAiInfos (UnitType,    AiType)
SELECT     'UNIT_JB_SNIPER',        AiType
FROM     UnitAiInfos
WHERE     UnitType = 'UNIT_RANGER';
 
Last edited:
Top Bottom