[
  {
    "type": "effect_on_condition",
    "id": "EOC_NONE",
    "//": "Empty EoC, use it if you need to run EoC with no effect for any reason",
    "effect": [  ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_RandEnc",
    "condition": {
      "and": [
        { "expects_vars": [ "map_update", "omt", "map_removal", "chance", "days_till_spawn" ] },
        { "one_in_chance": { "context_val": "chance" } },
        { "u_near_om_location": { "context_val": "omt" }, "range": 30 },
        { "days_since_cataclysm": { "context_val": "days_till_spawn" } },
        {
          "not": { "u_compare_time_since_var": "RandEnc", "type": "timer", "context": "caravan", "op": "<", "time": "1 d" }
        },
        { "not": { "u_near_om_location": { "context_val": "omt" }, "range": 2 } },
        { "get_condition": "random_enc_condition" }
      ]
    },
    "effect": [
      { "mapgen_update": [ { "context_val": "map_update" } ], "om_terrain": { "context_val": "omt" } },
      { "u_add_var": "RandEnc", "type": "timer", "context": "caravan", "time": true },
      {
        "u_location_variable": { "global_val": "randenc_loc" },
        "target_params": { "om_terrain": { "context_val": "omt" } }
      },
      { "arithmetic": [ { "global_val": "var", "var_name": "RandEnc" }, "=", { "const": 1 } ] },
      { "set_string_var": { "context_val": "omt" }, "target_var": { "global_val": "random_encounter_omt" } },
      {
        "set_string_var": { "context_val": "map_removal" },
        "target_var": { "global_val": "random_encounter_map_remove" }
      }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_RandEnc_remove",
    "recurrence": 200,
    "global": true,
    "condition": {
      "and": [
        { "u_compare_time_since_var": "RandEnc", "type": "timer", "context": "caravan", "op": ">", "time": "1 h" },
        { "not": { "u_near_om_location": { "global_val": "random_encounter_omt" }, "range": 2 } },
        { "compare_num": [ { "global_val": "var", "var_name": "RandEnc" }, "==", { "const": 1 } ] }
      ]
    },
    "effect": [
      {
        "mapgen_update": [ { "global_val": "random_encounter_map_remove" } ],
        "om_terrain": { "global_val": "random_encounter_omt" },
        "target_var": { "global_val": "randenc_loc" }
      },
      { "arithmetic": [ { "global_val": "var", "var_name": "RandEnc" }, "=", { "const": 0 } ] }
    ]
  }
]
