dhruv-tailor / excelmakesbelhappypack

Combination of Governments Expanded, Missions Expanded and Ideas Variation
36 stars 15 forks source link

Rewrite mission triggers to use the new buildings system #82

Closed Grociu closed 4 years ago

Grociu commented 4 years ago

ME mission system is referencing only vanilla buildings while we have the IV building system. If a mission trigger references a building by name:

trigger = {
    454 = {
        development = 30
        OR = {
            has_building = marketplace
            has_building = trade_depot
            has_building = stock_exchange
        }
        trade_share = {
            country = ROOT
            share = 75
        }
    }
}

It won't validate if you have trade_lvl_2 which is a tier2 trade building in the current system. Each building reference in missions needs to be reevaluated essentially case by case. I'm using the province_has_building_of_group scripted trigger to replace building references. This way, if in the future we decide to change the building system to something new (introduce a new tier for example) but keep the ME missions, it will be a much simpler adaptation.

Types of buildings:

Probably won't be affected, but still need double checking:

Methodology: The scripted trigger for province_has_building_of_group is described in the file missions_expanded_buildings_scripted_triggers.txt but here's the basics:

building groups (trade, government, navy, production, army, taxation, defense, all)
examples of usage:
province_has_building_of_group = { group = trade all = yes }
province_has_building_of_group = { group = trade equal_or_more_advanced_than = trade_depot }
province_has_building_of_group = { group = government all = yes }
province_has_building_of_group = { group = government equal_or_more_advanced_than = townhall }
province_has_building_of_group = { group = all all = yes }
when using "group = all", you have to use "all = yes", "equal_or_more_advanced_than" is not accepted here

If you put just province_has_building_of_group = { group = trade all = yes } as a check for trade buildings, tooltip looks like this: image so this syntax is required:

custom_trigger_tooltip = {
    tooltip = PROVINCE_HAS_BUILDING_OF_GROUP_TRADE_ALL
    province_has_building_of_group = { group = trade all = yes }
}

To see a tooltip like this: image

To count several instances of existing buildings in a province use:

calc_true_if = {
    all_owned_province = {
        custom_trigger_tooltip = {
            tooltip = PROVINCE_HAS_BUILDING_OF_GROUP_TRADE_ALL
            province_has_building_of_group = { group = trade all = yes }
        }
    }
    amount = 5
}

And the coolest, if the mission trigger calls for an upgraded building use this:

trigger = {
    calc_true_if = {
        all_owned_province = {
            custom_trigger_tooltip = {
                    tooltip = PROVINCE_HAS_BUILDING_OF_GROUP_TAXATION_EOMAT_cathedral
                province_has_building_of_group = { group = taxation equal_or_more_advanced_than all = cathedral }
            }
        }
        amount = 3
    }
}

Work so far: https://github.com/TheDivexz/excelmakesbelhappypack/tree/building-missions