[
  {
    "id": "overcharge_yrax",
    "type": "SPELL",
    "name": { "str": "▙▜▛▘▜▝▞▟▘▜", "//~": "NO_I18N" },
    "description": { "str": " ▘▙▚▛▜▝▞▟", "//~": "NO_I18N" },
    "valid_targets": [ "self", "ally", "hostile" ],
    "targeted_monster_ids": [ "mon_yrax_delta", "mon_yrax_quadraphract" ],
    "flags": [ "NO_HANDS", "NO_LEGS" ],
    "effect": "attack",
    "effect_str": "yrax_overcharged",
    "shape": "blast",
    "affected_body_parts": [ "torso" ],
    "base_casting_time": 100,
    "base_energy_cost": 100,
    "energy_source": "MANA",
    "difficulty": 1,
    "max_level": 1,
    "min_aoe": 40,
    "max_aoe": 40,
    "min_range": 10,
    "max_range": 10,
    "//": "duration is in moves",
    "min_duration": 500,
    "max_duration": 500
  },
  {
    "id": "activate_yrax",
    "type": "SPELL",
    "name": { "str": "Base activate Yrax", "//~": "NO_I18N" },
    "description": { "str": "Base spell for Yrax (de)activation.", "//~": "NO_I18N" },
    "valid_targets": [ "hostile", "ally", "self" ],
    "flags": [ "SILENT", "NO_HANDS", "NO_LEGS", "NO_PROJECTILE", "NO_EXPLOSION_SFX" ],
    "effect": "targeted_polymorph",
    "effect_str": "",
    "shape": "blast",
    "base_casting_time": 15,
    "max_level": 1,
    "min_damage": 10000000,
    "max_damage": 10000000,
    "damage_type": "pure",
    "min_aoe": 50,
    "max_aoe": 50
  },
  {
    "type": "SPELL",
    "id": "quadraphract_smoke_mortar",
    "name": { "str": "Quadraphract Smoke Mortar", "//~": "NO_I18N" },
    "description": { "str": "Throws several smoke bombs in a large area and with high scatter.", "//~": "NO_I18N" },
    "extra_effects": [
      { "id": "quadraphract_smoke_bomb_repeat" },
      { "id": "quadraphract_smoke_bomb_repeat" },
      { "id": "quadraphract_smoke_bomb_repeat" },
      { "id": "quadraphract_smoke_bomb_repeat" },
      { "id": "quadraphract_smoke_bomb_repeat" }
    ],
    "valid_targets": [ "hostile", "ground", "self", "ally" ],
    "effect": "attack",
    "shape": "blast",
    "damage_type": "bash",
    "min_damage": 1,
    "max_damage": 5,
    "flags": [ "LOUD", "RANDOM_TARGET", "RANDOM_DAMAGE", "RANDOM_AOE" ],
    "base_casting_time": 100,
    "min_aoe": 4,
    "max_aoe": 8,
    "min_range": 40,
    "max_range": 40,
    "field_id": "fd_smoke",
    "field_chance": 1,
    "min_field_intensity": 3,
    "max_field_intensity": 3
  },
  {
    "type": "SPELL",
    "id": "quadraphract_smoke_bomb_repeat",
    "name": { "str": "Quadraphract Smoke Mortar - repeat", "//~": "NO_I18N" },
    "description": { "str": "A single bomblet from the mortar strike.", "//~": "NO_I18N" },
    "valid_targets": [ "hostile", "ground", "self", "ally" ],
    "effect": "attack",
    "shape": "blast",
    "message": "",
    "damage_type": "bash",
    "min_damage": 1,
    "max_damage": 5,
    "flags": [ "LOUD", "RANDOM_TARGET", "RANDOM_DAMAGE", "RANDOM_AOE" ],
    "base_casting_time": 100,
    "min_aoe": 4,
    "max_aoe": 8,
    "min_range": 40,
    "max_range": 6,
    "field_id": "fd_smoke",
    "field_chance": 1,
    "min_field_intensity": 3,
    "max_field_intensity": 3
  },
  {
    "id": "sphenocorona_active",
    "type": "SPELL",
    "name": { "str": "Activate Sphenocorona", "//~": "NO_I18N" },
    "description": { "str": "Golden monoliths to Sphenocoronae.", "//~": "NO_I18N" },
    "copy-from": "activate_yrax",
    "targeted_monster_ids": [ "mon_yrax_sphenocorona_inert" ],
    "effect_str": "mon_yrax_sphenocorona"
  },
  {
    "id": "sphenocorona_inactive",
    "type": "SPELL",
    "name": { "str": "Activate Sphenocorona", "//~": "NO_I18N" },
    "description": { "str": "Sphenocoronae to Golden monoliths.", "//~": "NO_I18N" },
    "copy-from": "activate_yrax",
    "targeted_monster_ids": [ "mon_yrax_sphenocorona" ],
    "effect_str": "mon_golden_monolith"
  },
  {
    "type": "SPELL",
    "id": "release_the_deltas",
    "name": { "str": "Release the deltas!", "//~": "NO_I18N" },
    "description": { "str": "Summons a varying amount of Yrax deltas.", "//~": "NO_I18N" },
    "flags": [ "HOSTILE_SUMMON", "PERMANENT", "NO_EXPLOSION_SFX" ],
    "valid_targets": [ "ground", "self" ],
    "//": "make sure to only summon a prime number of deltas or I'll be mad",
    "min_damage": 2,
    "max_damage": 23,
    "damage_increment": 1,
    "max_level": 21,
    "min_aoe": 2,
    "max_aoe": 2,
    "base_casting_time": 500,
    "shape": "blast",
    "effect": "summon",
    "effect_str": "mon_yrax_delta"
  },
  {
    "id": "quadraphract_control",
    "type": "SPELL",
    "name": { "str": "Quadraphract control", "//~": "NO_I18N" },
    "description": { "str": "Quadraphracts control themselves using this one.", "//~": "NO_I18N" },
    "valid_targets": [ "self" ],
    "flags": [ "SILENT", "NO_EXPLOSION_SFX" ],
    "shape": "blast",
    "min_range": 1,
    "max_range": 1,
    "message": "",
    "effect": "effect_on_condition",
    "effect_str": "EOC_QUADRAPHRACT_CONTROL"
  },
  {
    "type": "SPELL",
    "id": "quadraphract_hurt_self",
    "name": { "str": "Wretch Hurt Self", "//~": "NO_I18N" },
    "description": { "str": "Hurts yourself.", "//~": "NO_I18N" },
    "flags": [ "RANDOM_DAMAGE", "NO_PROJECTILE", "NO_EXPLOSION_SFX" ],
    "min_damage": 1200,
    "max_damage": 1500,
    "damage_type": "pure",
    "valid_targets": [ "hostile", "ally", "self", "ground" ],
    "shape": "blast",
    "effect": "attack"
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_QUADRAPHRACT_CONTROL",
    "effect": [
      {
        "run_eocs": [
          {
            "id": "eoc_start_update_quadraphract_walkers",
            "condition": { "math": [ "updating_quadraphracts != 1" ] },
            "effect": [ { "run_eocs": "eoc_update_quadraphract_walkers" } ]
          },
          {
            "id": "quadraphract_setup",
            "condition": { "math": [ "u_setup != 1" ] },
            "effect": [
              {
                "run_eocs": [
                  {
                    "id": "avatar_sees_quadraphract_setup",
                    "condition": "player_see_u",
                    "effect": [ { "message": "You see the alien construct unfold itself in a single graceful motion." } ]
                  }
                ]
              },
              { "math": [ "_quad_uid = rand(1200)" ] },
              { "math": [ "u_quad_uid = _quad_uid" ] },
              { "math": [ "u_setup = 1" ] },
              { "u_spawn_monster": "mon_yrax_quadraphract_leg", "real_count": 4, "min_radius": 1, "max_radius": 1 },
              {
                "u_run_monster_eocs": [ { "id": "quadraphract_leg_assign", "effect": [ { "math": [ "u_quad_id = _quad_uid" ] } ] } ],
                "monster_range": 2,
                "mtype_ids": [ "mon_yrax_quadraphract_leg" ]
              },
              { "math": [ "u_timer_quadraphract_deltas = time('now')" ] },
              { "math": [ "u_timer_quadraphract_smoke = time('now')" ] }
            ]
          },
          {
            "id": "quadraphract_combat_strategy",
            "effect": [
              {
                "//": "QCQ combat strategy, for when stuff is too close for the main cannon.",
                "switch": { "math": [ "u_monsters_nearby('radius': 10)" ] },
                "cases": [
                  { "case": 6, "effect": [ { "run_eocs": [ "eoc_quadraphract_deltas" ] } ] },
                  {
                    "case": 15,
                    "effect": [ { "u_cast_spell": { "id": "overcharge_yrax" } }, { "run_eocs": [ "eoc_quadraphract_deltas" ] } ]
                  }
                ]
              },
              {
                "//": "Mid range combat strategy, for when stuff is too close for the main cannon.",
                "switch": { "math": [ "u_monsters_nearby('radius': 30)" ] },
                "cases": [ { "case": 20, "effect": { "run_eocs": [ "eoc_quadraphract_smoke" ] } } ]
              }
            ]
          }
        ]
      }
    ]
  },
  {
    "id": "eoc_update_quadraphract_walkers",
    "type": "effect_on_condition",
    "global": true,
    "condition": { "math": [ "u_monsters_nearby('mon_yrax_quadraphract', 'radius': 60) >= 1" ] },
    "effect": [
      { "math": [ "updating_quadraphracts = 1" ] },
      { "run_eocs": "eoc_update_quadraphract_walkers", "time_in_future": 1 },
      {
        "u_run_monster_eocs": [ "eoc_quadraphract_walker" ],
        "monster_range": 65,
        "mtype_ids": [ "mon_yrax_quadraphract" ]
      }
    ],
    "false_effect": [ { "math": [ "updating_quadraphracts = 0" ] } ]
  },
  {
    "id": "eoc_quadraphract_walker",
    "type": "effect_on_condition",
    "effect": [
      { "math": [ "_quad_uid = u_quad_uid" ] },
      { "u_location_variable": { "context_val": "quad_pos_1" }, "x_adjust": 1 },
      { "u_location_variable": { "context_val": "quad_pos_2" }, "x_adjust": -1 },
      { "u_location_variable": { "context_val": "quad_pos_3" }, "y_adjust": 1 },
      { "u_location_variable": { "context_val": "quad_pos_4" }, "y_adjust": -1 },
      {
        "u_run_monster_eocs": [
          {
            "id": "quadraphract_leg_tp",
            "condition": { "math": [ "u_quad_id == _quad_uid" ] },
            "effect": [
              { "u_teleport": { "context_val": "quad_pos_1" } },
              { "u_teleport": { "context_val": "quad_pos_2" } },
              { "u_teleport": { "context_val": "quad_pos_3" } },
              { "u_teleport": { "context_val": "quad_pos_4" } }
            ]
          }
        ],
        "monster_range": 20,
        "mtype_ids": [ "mon_yrax_quadraphract_leg" ]
      }
    ]
  },
  {
    "id": "EOC_QUADRAPHRACT_HURT",
    "type": "effect_on_condition",
    "global": true,
    "effect": [
      { "math": [ "_uid = n_quad_id" ] },
      {
        "u_run_monster_eocs": [
          {
            "id": "quadraphract_leg_hurt",
            "condition": { "math": [ "u_quad_uid == _uid" ] },
            "effect": [ { "u_cast_spell": { "id": "quadraphract_hurt_self" } } ]
          }
        ],
        "monster_range": 60,
        "mtype_ids": [ "mon_yrax_quadraphract" ]
      }
    ]
  },
  {
    "id": "EOC_QUADRAPHRACT_DIES",
    "type": "effect_on_condition",
    "global": true,
    "effect": [
      { "math": [ "_uid = n_quad_uid" ] },
      {
        "u_run_monster_eocs": [
          {
            "id": "quadraphract_leg_dies",
            "condition": { "math": [ "u_quad_id == _uid" ] },
            "effect": [ { "u_cast_spell": { "id": "quadraphract_hurt_self" } } ]
          }
        ],
        "monster_range": 20,
        "mtype_ids": [ "mon_yrax_quadraphract_leg" ]
      }
    ]
  },
  {
    "id": "eoc_quadraphract_deltas",
    "type": "effect_on_condition",
    "condition": {
      "and": [
        { "math": [ "time_since(u_timer_quadraphract_deltas) > time(' 1 m')" ] },
        { "math": [ "u_monsters_nearby('mon_yrax_delta', 'radius': 40) < 3" ] }
      ]
    },
    "effect": [
      { "math": [ "u_timer_quadraphract_deltas = time('now')" ] },
      {
        "u_spawn_monster": "mon_yrax_delta",
        "real_count": 5,
        "min_radius": 1,
        "max_radius": 2,
        "spawn_message": "Shards of gleaming alloy detach from the quadraphract's surface!"
      }
    ]
  },
  {
    "id": "eoc_quadraphract_smoke",
    "type": "effect_on_condition",
    "condition": { "and": [ { "math": [ "time_since(u_timer_quadraphract_smoke) > time(' 40 s')" ] } ] },
    "effect": [
      { "math": [ "u_timer_quadraphract_smoke = time('now')" ] },
      { "u_cast_spell": { "id": "quadraphract_smoke_mortar" } },
      {
        "run_eocs": [
          {
            "id": "avatar_sees_quadraphract_smoke",
            "condition": "player_see_u",
            "effect": [ { "message": "Several bomblets are expelled from the quadraphract's crown!" } ]
          }
        ]
      }
    ]
  }
]
