[
  {
    "type": "effect_on_condition",
    "id": "EOC_ARVORE_ELEMENTAL_MAGIC_ADJUSTMENT_IN_THE_WILDERNESS",
    "eoc_type": "EVENT",
    "required_event": "opens_spellbook",
    "condition": {
      "and": [
        {
          "and": [
            "u_is_outside",
            { "test_eoc": "EOC_CONDITION_CHECK_ARVORE_ON_NATURAL_TERRAIN" },
            { "test_eoc": "EOC_CONDITION_CHECK_ARVORE_IN_THE_WILD" }
          ]
        },
        { "u_has_trait": "ARVORE" }
      ]
    },
    "effect": [
      {
        "math": [ "u_spellcasting_adjustment('difficulty', 'school': 'ARVORE' ) = (u_sum_traits_of_category_char_has('ARVORE') / -2)" ]
      }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_ARVORE_ELEMENTAL_MAGIC_PENALTY_IN_BUILDING",
    "eoc_type": "EVENT",
    "required_event": "opens_spellbook",
    "condition": {
      "and": [
        {
          "or": [
            {
              "and": [
                { "not": "u_is_outside" },
                { "or": [ { "u_is_on_terrain_with_flag": "FLAT" }, { "u_is_on_terrain_with_flag": "ROAD" } ] },
                { "not": { "u_is_on_terrain": "t_barkfloor" } },
                { "not": { "u_is_on_terrain": "t_floor" } },
                { "not": { "u_is_on_terrain": "t_wood_stairs_down" } },
                { "not": { "u_is_on_terrain": "t_wood_stairs_up" } },
                { "not": { "u_is_on_terrain": "t_door_o" } },
                { "not": { "u_is_on_terrain": "t_dirt_underground" } },
                { "not": { "u_is_on_terrain": "t_dirtfloor_thatchroof" } }
              ]
            },
            {
              "and": [
                {
                  "or": [
                    { "u_is_on_terrain": "t_barkfloor" },
                    { "u_is_on_terrain": "t_floor" },
                    { "u_is_on_terrain": "t_wood_stairs_down" },
                    { "u_is_on_terrain": "t_wood_stairs_up" },
                    { "u_is_on_terrain": "t_door_o" },
                    { "u_is_on_terrain": "t_dirt_underground" },
                    { "u_is_on_terrain": "t_dirtfloor_thatchroof" }
                  ]
                },
                { "u_near_om_location": "road", "range": 1 }
              ]
            }
          ]
        },
        { "u_has_trait": "ARVORE" }
      ]
    },
    "effect": [ { "math": [ "u_school_level_adjustment('ARVORE')", "-=", "4" ] } ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_HOMULLUS_MAGIC_ADJUSTMENT_IN_CIVILIZATION",
    "eoc_type": "EVENT",
    "required_event": "opens_spellbook",
    "condition": { "test_eoc": "EOC_HOMULLUS_IN_CIVILIZATION_CHECKER_CONDITION" },
    "effect": [
      {
        "math": [
          "u_spellcasting_adjustment('difficulty', 'school': 'HOMULLUS' ) = (u_sum_traits_of_category_char_has('HOMULLUS') / -2)"
        ]
      }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_HOMULLUS_ELEMENTAL_MAGIC_PENALTY_IN_THE_WILDERNESS",
    "eoc_type": "EVENT",
    "required_event": "opens_spellbook",
    "condition": {
      "and": [
        {
          "and": [
            { "not": { "test_eoc": "EOC_HOMULLUS_IN_CIVILIZATION_CHECKER_CONDITION" } },
            { "not": { "u_near_om_location": "road", "range": 1 } }
          ]
        },
        { "u_has_trait": "HOMULLUS" }
      ]
    },
    "effect": [ { "math": [ "u_school_level_adjustment('HOMULLUS')", "-=", "4" ] } ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_IERDE_ELEMENTAL_MAGIC_ADJUSTMENT_UNDERGROUND_OR_ON_DIRT",
    "eoc_type": "EVENT",
    "required_event": "opens_spellbook",
    "condition": {
      "and": [
        {
          "or": [
            { "math": [ "u_val('pos_z') <= -1" ] },
            { "u_is_on_terrain_with_flag": "DIGGABLE" },
            { "u_is_on_terrain": "t_rock_floor" },
            { "u_is_on_terrain": "t_railroad_rubble" },
            { "u_is_on_terrain": "t_dirt_underground" }
          ]
        },
        { "not": { "u_is_on_terrain": "t_vitrified_sand" } },
        { "not": { "u_is_on_terrain": "t_pit_corpsed" } },
        { "not": { "u_is_on_terrain": "t_fungus" } },
        { "not": { "u_is_on_terrain": "t_glassed_sand" } },
        { "not": { "u_is_on_terrain": "t_rubber_mulch" } },
        { "not": { "u_is_on_terrain": "t_swater_surf" } },
        { "not": { "u_is_on_terrain": "t_woodchips" } },
        { "u_has_trait": "IERDE" }
      ]
    },
    "effect": [
      {
        "math": [ "u_spellcasting_adjustment('difficulty', 'school': 'IERDE' ) = (u_sum_traits_of_category_char_has('IERDE') / -2)" ]
      }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_IERDE_ELEMENTAL_MAGIC_PENALTY_TOO_HIGH",
    "eoc_type": "EVENT",
    "required_event": "opens_spellbook",
    "condition": { "and": [ { "math": [ "u_val('pos_z') >= 1" ] }, { "u_has_trait": "IERDE" } ] },
    "effect": [ { "math": [ "u_school_level_adjustment('IERDE')", "-=", "4" ] } ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_SALAMANDER_ELEMENTAL_MAGIC_ADJUSTMENT_IN_FIRE_OR_HEAT",
    "eoc_type": "EVENT",
    "required_event": "opens_spellbook",
    "condition": {
      "and": [
        {
          "or": [
            { "u_is_in_field": "fd_hot_air1" },
            { "u_is_in_field": "fd_hot_air2" },
            { "u_is_in_field": "fd_hot_air3" },
            { "u_is_in_field": "fd_hot_air4" },
            { "u_is_in_field": "fd_fire" },
            { "math": [ "weather('temperature') >= from_fahrenheit( 80 )" ] }
          ]
        },
        { "u_has_trait": "SALAMANDER" }
      ]
    },
    "effect": [
      {
        "math": [
          "u_spellcasting_adjustment('difficulty', 'school': 'SALAMANDER' ) = (u_sum_traits_of_category_char_has('SALAMANDER') / -2)"
        ]
      }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_SALAMANDER_ELEMENTAL_MAGIC_PENALTY_IN_CHILL",
    "eoc_type": "EVENT",
    "required_event": "opens_spellbook",
    "condition": {
      "and": [
        { "math": [ "weather('temperature') <= from_fahrenheit( 32 )" ] },
        {
          "and": [
            { "not": { "u_is_in_field": "fd_hot_air1" } },
            { "not": { "u_is_in_field": "fd_hot_air2" } },
            { "not": { "u_is_in_field": "fd_hot_air3" } },
            { "not": { "u_is_in_field": "fd_hot_air4" } },
            { "not": { "u_is_in_field": "fd_fire" } },
            { "not": { "u_has_item": "torch_lit" } },
            { "not": { "u_has_item": "candle_lit" } },
            { "not": { "u_has_item": "oil_lamp_on" } },
            { "not": { "u_has_item": "oil_lamp_clay_on" } },
            { "not": { "u_has_item": "cigar_lit" } },
            { "not": { "u_has_item": "cig_lit" } }
          ]
        },
        { "u_has_trait": "SALAMANDER" }
      ]
    },
    "effect": [ { "math": [ "u_school_level_adjustment('SALAMANDER')", "-=", "4" ] } ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_SYLPH_ELEMENTAL_MAGIC_ADJUSTMENT_UP_HIGH_OR_UNDER_THE_SKY",
    "eoc_type": "EVENT",
    "required_event": "opens_spellbook",
    "condition": {
      "and": [
        {
          "or": [
            { "and": [ { "math": [ "u_val('pos_z') >= 1" ] }, "u_is_outside" ] },
            { "and": [ { "math": [ "weather('windpower') >= 15" ] }, "u_is_outside" ] }
          ]
        },
        { "u_has_trait": "SYLPH" }
      ]
    },
    "effect": [
      {
        "math": [ "u_spellcasting_adjustment('difficulty', 'school': 'SYLPH' ) = (u_sum_traits_of_category_char_has('SYLPH') / -2)" ]
      }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_SYLPH_ELEMENTAL_MAGIC_PENALTY_UNDERGROUND",
    "eoc_type": "EVENT",
    "required_event": "opens_spellbook",
    "condition": { "and": [ { "math": [ "u_val('pos_z') <= -1" ] }, { "not": "u_is_outside" }, { "u_has_trait": "SYLPH" } ] },
    "effect": [ { "math": [ "u_school_level_adjustment('SYLPH')", "-=", "4" ] } ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_UNDINE_ELEMENTAL_MAGIC_ADJUSTMENT_NEAR_OR_IN_WATER",
    "eoc_type": "EVENT",
    "required_event": "opens_spellbook",
    "condition": {
      "and": [
        {
          "or": [
            "u_is_underwater",
            { "u_is_on_terrain": "t_water_dp" },
            { "u_is_on_terrain": "t_water_sh" },
            { "u_is_on_terrain": "t_swater_dp" },
            { "u_is_on_terrain": "t_swater_dp_underground" },
            { "u_is_on_terrain": "t_water_dp_underground" },
            { "u_is_on_terrain": "t_water_pool" },
            { "u_is_on_terrain": "t_water_pool_outdoors" },
            { "u_is_on_terrain": "t_swater_dp_underground" },
            { "u_is_on_terrain": "t_water_hot" },
            { "u_is_on_terrain": "t_water_murky" },
            { "u_is_on_terrain": "t_water_sh_underground" },
            { "u_is_on_terrain": "t_swater_dp_underground" },
            { "u_is_on_terrain": "t_swater_sh_underground" },
            { "u_is_on_terrain": "t_swater_sh" },
            { "u_is_on_terrain": "t_water_pool_shallow" },
            { "u_is_on_terrain": "t_water_pool_shallow_outdoors" },
            { "u_is_on_terrain": "t_water_moving_dp" },
            { "u_is_on_terrain": "t_water_moving_dp_underground" },
            { "u_is_on_terrain": "t_water_sh_murky_underground" },
            { "u_near_om_location": "generic_river_bank", "range": 1 },
            { "u_near_om_location": "generic_river", "range": 1 },
            { "u_near_om_location": "river_center", "range": 1 },
            { "u_near_om_location": "river", "range": 1 },
            { "u_near_om_location": "river_c_not_ne", "range": 1 },
            { "u_near_om_location": "river_c_not_nw", "range": 1 },
            { "u_near_om_location": "river_c_not_se", "range": 1 },
            { "u_near_om_location": "river_c_not_sw", "range": 1 },
            { "u_near_om_location": "lake_shore", "range": 1 },
            { "u_near_om_location": "lake_surface", "range": 1 }
          ]
        },
        { "u_has_trait": "UNDINE" }
      ]
    },
    "effect": [
      {
        "math": [ "u_spellcasting_adjustment('difficulty', 'school': 'UNDINE' ) = (u_sum_traits_of_category_char_has('UNDINE') / -2)" ]
      }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_UNDINE_ELEMENTAL_MAGIC_PENALTY_TOO_DRY_TIMER",
    "eoc_type": "EVENT",
    "required_event": "avatar_moves",
    "condition": {
      "and": [
        {
          "or": [
            { "u_is_on_terrain": "t_water_dp" },
            { "u_is_on_terrain": "t_water_sh" },
            { "u_is_on_terrain": "t_swater_dp" },
            { "u_is_on_terrain": "t_swater_dp_underground" },
            { "u_is_on_terrain": "t_water_dp_underground" },
            { "u_is_on_terrain": "t_water_pool" },
            { "u_is_on_terrain": "t_water_pool_outdoors" },
            { "u_is_on_terrain": "t_swater_dp_underground" },
            { "u_is_on_terrain": "t_water_hot" },
            { "u_is_on_terrain": "t_water_murky" },
            { "u_is_on_terrain": "t_water_sh_underground" },
            { "u_is_on_terrain": "t_swater_dp_underground" },
            { "u_is_on_terrain": "t_swater_sh_underground" },
            { "u_is_on_terrain": "t_swater_sh" },
            { "u_is_on_terrain": "t_water_pool_shallow" },
            { "u_is_on_terrain": "t_water_pool_shallow_outdoors" },
            { "u_is_on_terrain": "t_water_moving_dp" },
            { "u_is_on_terrain": "t_water_moving_dp_underground" },
            { "u_is_on_terrain": "t_water_sh_murky_underground" },
            { "u_at_om_location": "generic_river_bank" },
            { "u_at_om_location": "generic_river" },
            { "u_at_om_location": "river_center" },
            { "u_at_om_location": "river" },
            { "u_at_om_location": "river_c_not_ne" },
            { "u_at_om_location": "river_c_not_nw" },
            { "u_at_om_location": "river_c_not_se" },
            { "u_at_om_location": "river_c_not_sw" },
            { "u_at_om_location": "lake_shore" },
            { "u_at_om_location": "lake_surface" }
          ]
        },
        { "u_has_trait": "UNDINE" }
      ]
    },
    "effect": [ { "math": [ "u_timer_undine_last_in_water = time('now')" ] } ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_UNDINE_ELEMENTAL_MAGIC_PENALTY_TOO_DRY",
    "eoc_type": "EVENT",
    "required_event": "opens_spellbook",
    "condition": { "and": [ { "math": [ "time_since(u_timer_undine_last_in_water) >= time('6 h')" ] }, { "u_has_trait": "UNDINE" } ] },
    "effect": [ { "math": [ "u_school_level_adjustment('UNDINE')", "-=", "4" ] } ]
  }
]
