Mod for no obsolete units?

str1k6r

Chieftain
Joined
Aug 9, 2021
Messages
1
Idk guys, but it seems for me a great idea to make a mod which cancels obsoletion. The main two issues are inability to build units if you're outta strategic resources, and the second one are unique units, which are often a big reason when choosing a nation. Also, sometimes is essential to build quickly. For example, one has enemy near the city borders, and building rifleman would take for too long, and resources for instant buy are unsufficient. But if building kinda musketman or crossbowman, which will be protected by city walls, it can gain enough time to reinforcements arrive
 
I got an idea and started experiments, no mod on workshop yet.

The basic idea is simply to remove upgrade paths where one of the conditions is true:
  1. Required strategic resources to build are different - is this necessary or allowed by the game?
  2. Upgrade would cost more strategic resource to build
  3. Upgrade would consume a different strategic resource per turn, e.g. ironclad (coal) and destroyer (oil)
  4. Upgrade would consume more strategic resource per turn. This is for my own use only as I made e.g. jet bombers consumer 5 oil per turn while bombers only 3
It'd remove a lot of upgrade paths, many of them are unrealistic but a few are, e.g. warrior to swordsman (iron).

The SQL is:
SQL:
DELETE FROM UnitUpgrades WHERE Unit IN (
    SELECT upgrade.Unit FROM UnitUpgrades AS upgrade
      LEFT JOIN Units AS old ON old.UnitType = upgrade.Unit
      LEFT JOIN Units AS new ON new.UnitType = upgrade.UpgradeUnit
      LEFT JOIN Units_XP2 AS old_xp2 ON old_xp2.UnitType = upgrade.Unit
      LEFT JOIN Units_XP2 AS new_xp2 ON new_xp2.UnitType = upgrade.UpgradeUnit
     WHERE (new.StrategicResource IS NOT NULL
            AND ifnull(old.StrategicResource, '') <> ifnull(new.StrategicResource, ''))
        OR (new_xp2.ResourceCost IS NOT NULL
            AND old_xp2.ResourceCost < new_xp2.ResourceCost)
        OR (new_xp2.ResourceMaintenanceType IS NOT NULL
            AND ifnull(old_xp2.ResourceMaintenanceType, '') <> ifnull(new_xp2.ResourceMaintenanceType, ''))
        OR (new_xp2.ResourceMaintenanceAmount IS NOT NULL
            AND old_xp2.ResourceMaintenanceAmount < new_xp2.ResourceMaintenanceAmount)
);

Since it's not a mod, I just list it in my DLC\Expansion2\Expansion2.modinfo where I can keep updating and test existing save games:
XML:
<!-- FIND THIS ORIGINAL SECTION IN FILE -->
<UpdateDatabase id="Expansion2MajorContent" criteria="Expansion2AndBeyond">
    <File>Data/Expansion2_Agendas_Major.xml</File>
    <File>Data/Expansion2_Buildings_Major.xml</File>
    <File>Data/Expansion2_Civilizations_Major.xml</File>
    <File>Data/Expansion2_Districts_Major.xml</File>
    <File>Data/Expansion2_Improvements_Major.xml</File>
    <File>Data/Expansion2_Leaders_Major.xml</File>
    <File>Data/Expansion2_Units_Major.xml</File>
    <File>Data/Expansion2_UnitAbilities_Major.xml</File>
    <File>Data/Expansion2_UnitPromotions_Major.xml</File>
</UpdateDatabase>
<!-- ADD THIS NEW SECTION BELOW -->
<UpdateDatabase id="Expansion2CustomChanges" criteria="Expansion2AndBeyond">
    <Properties>
        <LoadOrder>10601</LoadOrder>
    </Properties>
    <File>CustomChanges.sql</File>
</UpdateDatabase>
 
Last edited:
Top Bottom