Results 1 to 4 of 4

Thread: Demolition script help

  1. #1

    Default Demolition script help

    I've been trying to write a script to have the AI destroy buildings of a different religion. I would like the script to trigger when the AI takes over any province. Either destroy any building that doesn't have the same religion as the state religion or a specific building chain and or building level. I know the AI already does this with the current religions and religious buildings. I cannot figure out how it's triggered in the game. I think a good script would be the easiest way to solve this issue. I've spent hours testing and still coming up empty. If someone could point me in the right direction I'd be very grateful!

  2. #2

    Default Re: Demolition script help

    I'm updating this post for anyone that is curious. I'm fairly close to figuring out the script, I've cracked the major problem of destroying a specific building at a specific slot. By working backwards from this point, I should be finished in a few days.

    The script below will instantly destroy the market chain in Satsuma. It's only the level 1 version of the chain but you can easily add all levels to this script.

    events.SlotTurnStart[#events.SlotTurnStart+1] = function(context)
    if conditions.SlotName("settlement:jap_satsuma:kagoshima:settlement_sho_generic:0", context) and conditions.BuildingTypeExistsAtSlot("SHO_Crafts_1_Market", context) then
    scripting.game_interface:instantly_dismantle_building("settlement:jap_satsuma:kagoshima:settlement_sho_generic:0")
    end
    if conditions.SlotName("settlement:jap_satsuma:kagoshima:settlement_sho_generic:1", context) and conditions.BuildingTypeExistsAtSlot("SHO_Crafts_1_Market", context) then
    scripting.game_interface:instantly_dismantle_building("settlement:jap_satsuma:kagoshima:settlement_sho_generic:1")
    end
    if conditions.SlotName("settlement:jap_satsuma:kagoshima:settlement_sho_generic:2", context) and conditions.BuildingTypeExistsAtSlot("SHO_Crafts_1_Market", context) then
    scripting.game_interface:instantly_dismantle_building("settlement:jap_satsuma:kagoshima:settlement_sho_generic:2")
    end
    if conditions.SlotName("settlement:jap_satsuma:kagoshima:settlement_sho_generic:3", context) and conditions.BuildingTypeExistsAtSlot("SHO_Crafts_1_Market", context) then
    scripting.game_interface:instantly_dismantle_building("settlement:jap_satsuma:kagoshima:settlement_sho_generic:3")
    end
    if conditions.SlotName("settlement:jap_satsuma:kagoshima:settlement_sho_generic:4", context) and conditions.BuildingTypeExistsAtSlot("SHO_Crafts_1_Market", context) then
    scripting.game_interface:instantly_dismantle_building("settlement:jap_satsuma:kagoshima:settlement_sho_generic:4")
    end

    end

  3. #3

    Default Re: Demolition script help

    I finished the script but it's quite long... over a million characters. Pastebin wouldn't let me post it because it's over 512kb. If anyone is interested in this script, you can friend me on steam or PM me.

    I had to create definitions for each major faction and province. 65x12 = 780 definitions.

    The example below is just 1/780th of the actual script but will give you an idea of how it works. There's probably a less tedious way of writing it but I couldn't figure a way to make it easier than this.

    Spoiler Alert, click show to read: 

    events.NewCampaignStarted[#events.NewCampaignStarted+1] = function(context)
    satsuma_mori = false
    end

    events.CharacterEntersGarrison[#events.CharacterEntersGarrison+1] = function(context)
    if conditions.CharacterInRegion("jap_satsuma", context) then
    if conditions.CharacterFactionName("mori", context) then
    satsuma_mori = true
    end
    end
    end

    events.SlotTurnStart[#events.SlotTurnStart+1] = function(context)
    if not satsuma_mori then
    if conditions.SlotName("settlement:jap_satsuma:kagoshima:settlement_sho_generic:0", context) and (conditions.BuildingTypeExistsAtSlot("TEA_1_mori", context) or conditions.BuildingTypeExistsAtSlot("TEA_2_mori", context) or conditions.BuildingTypeExistsAtSlot("TEA_3_mori", context)) then
    scripting.game_interface:instantly_dismantle_building("settlement:jap_satsuma:kagoshima:settlement_sho_generic:0")
    end
    if conditions.SlotName("settlement:jap_satsuma:kagoshima:settlement_sho_generic:1", context) and (conditions.BuildingTypeExistsAtSlot("TEA_1_mori", context) or conditions.BuildingTypeExistsAtSlot("TEA_2_mori", context) or conditions.BuildingTypeExistsAtSlot("TEA_3_mori", context)) then
    scripting.game_interface:instantly_dismantle_building("settlement:jap_satsuma:kagoshima:settlement_sho_generic:1")
    end
    if conditions.SlotName("settlement:jap_satsuma:kagoshima:settlement_sho_generic:2", context) and (conditions.BuildingTypeExistsAtSlot("TEA_1_mori", context) or conditions.BuildingTypeExistsAtSlot("TEA_2_mori", context) or conditions.BuildingTypeExistsAtSlot("TEA_3_mori", context)) then
    scripting.game_interface:instantly_dismantle_building("settlement:jap_satsuma:kagoshima:settlement_sho_generic:2")
    end
    if conditions.SlotName("settlement:jap_satsuma:kagoshima:settlement_sho_generic:3", context) and (conditions.BuildingTypeExistsAtSlot("TEA_1_mori", context) or conditions.BuildingTypeExistsAtSlot("TEA_2_mori", context) or conditions.BuildingTypeExistsAtSlot("TEA_3_mori", context)) then
    scripting.game_interface:instantly_dismantle_building("settlement:jap_satsuma:kagoshima:settlement_sho_generic:3")
    end
    if conditions.SlotName("settlement:jap_satsuma:kagoshima:settlement_sho_generic:4", context) and (conditions.BuildingTypeExistsAtSlot("TEA_1_mori", context) or conditions.BuildingTypeExistsAtSlot("TEA_2_mori", context) or conditions.BuildingTypeExistsAtSlot("TEA_3_mori", context)) then
    scripting.game_interface:instantly_dismantle_building("settlement:jap_satsuma:kagoshima:settlement_sho_generic:4")
    end
    end

    end

    local function OnSavingGame(context)
    scripting.game_interface:save_named_value("satsuma_mori", satsuma_mori, context)
    end

    local function OnLoadingGame(context)
    satsuma_mori = scripting.game_interface:load_named_value("satsuma_mori", false, context)

    end

  4. #4

    Default Re: Demolition script help

    Thanks for sharing this, could be very useful indeed!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •