[
  {
    "type": "effect_on_condition",
    "id": "EOC_ROBOFAC_HQ_UPDATE_RECURRENCE",
    "recurrence": "12 hours",
    "global": true,
    "effect": { "run_eocs": [ "EOC_ROBOFAC_HQ_UPDATE_EVENT" ] }
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_ROBOFAC_HQ_UPDATE_EVENT",
    "global": true,
    "condition": {
      "and": [
        { "u_near_om_location": "robofachq_surface_road1", "range": 30 },
        { "not": { "u_near_om_location": "robofachq_surface_road1", "range": 4 } },
        { "compare_num": [ { "global_val": "var", "var_name": "robofac_destroyed" }, "!=", { "const": 1 } ] }
      ]
    },
    "effect": {
      "run_eocs": [
        {
          "id": "EOC_ROBOFAC_HQ_SURFACE_SANDBAGS",
          "condition": { "days_since_cataclysm": 20 },
          "effect": [
            { "mapgen_update": "window_sandbags_meteorology1", "om_terrain": "robofachq_meteorology1" },
            { "mapgen_update": "window_sandbags_meteorology2", "om_terrain": "robofachq_meteorology2" },
            { "mapgen_update": "window_sandbags_surface_road2", "om_terrain": "robofachq_surface_road2" }
          ]
        },
        {
          "id": "EOC_ROBOFAC_HQ_PLACE_ANCILLA_FORTRESS",
          "condition": {
            "and": [
              { "compare_num": [ { "global_val": "var", "var_name": "ancilla_fortress_placed" }, "!=", { "const": 1 } ] },
              { "days_since_cataclysm": 45 }
            ]
          },
          "effect": [
            { "mapgen_update": "robofachq_ancilla_fortress_basic", "om_terrain": "robofachq_meteorology2" },
            { "arithmetic": [ { "global_val": "var", "var_name": "ancilla_fortress_placed" }, "=", { "const": 1 } ] }
          ]
        },
        {
          "id": "EOC_ROBOFAC_HQ_PLACE_ANCILLA_BAR",
          "condition": { "and": [ { "math": [ "ancilla_bar_placed", "!=", "1" ] }, { "days_since_cataclysm": 60 } ] },
          "effect": [
            { "mapgen_update": "robofachq_ancilla_bar_basic", "om_terrain": "robofachq_subcc_a2" },
            {
              "u_location_variable": { "global_val": "ancilla_bar_loc" },
              "target_params": { "om_terrain": "robofachq_subcc_a2" }
            },
            { "math": [ "ancilla_bar_exists", "=", "1" ] },
            { "math": [ "ancilla_bar_placed", "=", "1" ] },
            { "run_eocs": [ "EOC_reroll_bar_mercs" ] }
          ]
        },
        {
          "id": "EOC_ROBOFAC_HQ_PLACE_ANCILLA_AUTODOC",
          "condition": {
            "and": [
              { "math": [ "ancilla_bar_exists", "==", "1" ] },
              { "math": [ "ancilla_autodoc_placed", "!=", "1" ] },
              { "days_since_cataclysm": 80 }
            ]
          },
          "effect": [
            { "mapgen_update": "robofachq_ancilla_bar_autodoc", "om_terrain": "robofachq_subcc_a1" },
            {
              "u_location_variable": { "global_val": "ancilla_autodoc_loc" },
              "target_params": { "om_terrain": "robofachq_subcc_a1" }
            },
            { "math": [ "ancilla_autodoc_placed", "=", "1" ] }
          ]
        }
      ]
    }
  }
]
