[
  {
    "id": "void_spider_test_item",
    "type": "ITEM",
    "subtypes": [ "TOOL" ],
    "name": { "str_sp": "void weaver effigy" },
    "description": "The severed leg of a void weaver, turned into some macabre ornament.",
    "weight": "1 g",
    "volume": "250 ml",
    "price": "30 USD",
    "price_postapoc": "100 USD",
    "symbol": "!",
    "color": "light_red",
    "use_action": {
      "type": "effect_on_conditions",
      "description": "Touch the effigy.",
      "effect_on_conditions": [
        {
          "id": "VOID_SPIDER_TEST_MAP",
          "effect": [
            { "u_message": "The world warps." },
            {
              "u_location_variable": { "global_val": "spider_map" },
              "target_params": { "om_terrain": "void_spider_lair_entrance", "z": -5, "min_distance": 1 }
            },
            { "u_teleport": { "global_val": "spider_map" }, "force": true }
          ]
        }
      ]
    }
  },
  {
    "type": "monster_attack",
    "attack_type": "melee",
    "id": "void_spider_bite",
    "cooldown": 1,
    "move_cost": 100,
    "damage_max_instance": [ { "damage_type": "stab", "amount": 12, "armor_penetration": 30000 } ],
    "hitsize_min": 4,
    "effects": [ { "id": "venom_blind", "duration": 120 } ],
    "hit_dmg_u": "%1$s's immaterial limbs crawl over you and sink their fangs in your %2$s!",
    "hit_dmg_npc": "%1$s buries its beak in <npcname>!",
    "miss_msg_u": "%1$s's hanging limbs try to bite you, but you dodge!",
    "miss_msg_npc": "%1$s's hanging limbs try to bite <npcname>, but they dodge!",
    "no_dmg_msg_u": "%1$s's hanging limbs try to bite your %2$s, but fails to penetrate your armor!",
    "no_dmg_msg_npc": "%1$s's hanging limbs try to bite <npcname>, but fails to penetrate their armor!",
    "condition": { "or": [ { "npc_has_effect": "WEBBED" }, { "npc_has_effect": "GRABBED" } ] }
  },
  {
    "type": "ter_furn_transform",
    "id": "cavern_emptiness",
    "terrain": [ { "result": [ "t_nether_glass_floor_basalt" ], "valid_terrain": [ "t_nether_basalt" ] } ]
  },
  {
    "type": "ter_furn_transform",
    "id": "cavern_emptiness_revert",
    "terrain": [ { "result": [ "t_nether_basalt" ], "valid_terrain": [ "t_nether_glass_floor_basalt" ] } ]
  },
  {
    "id": "void_spider_empty",
    "name": { "str": "Void spider emptiness", "//~": "NO_I18N" },
    "description": { "str": "Constantly empties the area around the spider.", "//~": "NO_I18N" },
    "valid_targets": [ "ally", "self", "hostile", "ground" ],
    "type": "SPELL",
    "flags": [ "SILENT", "NO_EXPLOSION_SFX", "IGNORE_WALLS" ],
    "effect": "ter_transform",
    "effect_str": "cavern_emptiness",
    "shape": "blast",
    "min_aoe": 5,
    "max_aoe": 5
  },
  {
    "id": "void_spider_empty_revert",
    "name": { "str": "Void spider revert emptiness", "//~": "NO_I18N" },
    "description": { "str": "Constantly empties the area around the spider.", "//~": "NO_I18N" },
    "valid_targets": [ "ally", "hostile", "ground" ],
    "type": "SPELL",
    "effect": "ter_transform",
    "effect_str": "cavern_emptiness_revert",
    "flags": [ "SILENT", "NO_EXPLOSION_SFX" ],
    "shape": "blast",
    "min_aoe": 35,
    "max_aoe": 35
  },
  {
    "id": "void_spider_control",
    "type": "SPELL",
    "name": { "str": "Void spider control", "//~": "NO_I18N" },
    "description": { "str": "Void spiders 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_VOID_SPIDER_CONTROL"
  },
  {
    "type": "SPELL",
    "id": "place_void_spider",
    "name": { "str": "Place Void Spider", "//~": "NO_I18N" },
    "description": { "str": "Spawns a void spider.", "//~": "NO_I18N" },
    "flags": [ "SILENT", "HOSTILE_SUMMON", "PERMANENT", "NO_EXPLOSION_SFX" ],
    "valid_targets": [ "ground" ],
    "max_level": 1,
    "min_damage": 1,
    "max_damage": 1,
    "min_range": 0,
    "max_range": 0,
    "min_aoe": 10,
    "max_aoe": 10,
    "base_casting_time": 3,
    "shape": "blast",
    "effect": "summon",
    "effect_str": "mon_void_spider"
  },
  {
    "type": "SPELL",
    "id": "mon_void_weaver_death",
    "name": { "str": "Void Weaver Death", "//~": "NO_I18N" },
    "description": { "str": "Ends the fight.", "//~": "NO_I18N" },
    "valid_targets": [ "self", "hostile", "ally" ],
    "max_level": 1,
    "flags": [ "SILENT", "NO_HANDS", "NO_LEGS" ],
    "base_casting_time": 75,
    "min_range": 15,
    "max_range": 15,
    "min_aoe": 30,
    "max_aoe": 30,
    "shape": "blast",
    "effect": "effect_on_condition",
    "effect_str": "EOC_VOID_SPIDER_ON_DEATH"
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_ENTER_VOID_SPIDER_LAIR",
    "eoc_type": "EVENT",
    "required_event": "avatar_enters_omt",
    "condition": { "or": [ { "u_at_om_location": "void_spider_lair_a1" }, { "u_at_om_location": "void_spider_lair_a2" } ] },
    "effect": [
      {
        "run_eocs": [
          {
            "id": "seal_void_spider_lair",
            "condition": { "math": [ "spider_lair_sealed != 1" ] },
            "effect": [
              { "mapgen_update": "void_spider_lair_entrance_shift", "om_terrain": "void_spider_lair_entrance" },
              { "math": [ "spider_lair_sealed = 1" ] },
              { "run_eocs": "EOC_IN_VOID_SPIDER_LAIR", "time_in_future": "1 seconds" },
              { "run_eocs": "EOC_VOID_SPIDER_EMPTY_REVERT", "time_in_future": "25 seconds" }
            ]
          }
        ]
      }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_IN_VOID_SPIDER_LAIR",
    "condition": {
      "or": [
        { "u_at_om_location": "void_spider_lair_entrance" },
        { "u_at_om_location": "void_spider_lair_a1" },
        { "u_at_om_location": "void_spider_lair_a2" }
      ]
    },
    "deactivate_condition": {
      "not": {
        "or": [
          { "u_at_om_location": "void_spider_lair_entrance" },
          { "u_at_om_location": "void_spider_lair_a1" },
          { "u_at_om_location": "void_spider_lair_a2" }
        ]
      }
    },
    "effect": [
      { "place_override": { "global_val": "place_name", "default": "strange cavern" }, "length": "10 seconds" },
      { "run_eocs": "EOC_IN_VOID_SPIDER_LAIR", "time_in_future": "1 seconds" },
      {
        "run_eocs": [
          {
            "id": "webbed_place_void_spider",
            "condition": {
              "and": [
                { "u_has_effect": "webbed" },
                { "one_in_chance": 6 },
                { "math": [ "u_monsters_nearby('mon_void_spider') < 1" ] },
                { "math": [ "void_spider_killed != 1" ] }
              ]
            },
            "effect": [
              { "u_message": "The emptiness shifts unnervingly, something is nearby.", "popup": true },
              { "u_cast_spell": { "id": "place_void_spider", "hit_self": true } }
            ]
          },
          {
            "id": "time_place_void_spider",
            "condition": {
              "and": [
                { "one_in_chance": 120 },
                { "math": [ "u_monsters_nearby('mon_void_spider') < 1" ] },
                { "math": [ "void_spider_killed != 1" ] }
              ]
            },
            "effect": [
              { "u_message": "The emptiness shifts unnervingly, something is nearby.", "popup": true },
              { "u_cast_spell": { "id": "place_void_spider", "hit_self": true } }
            ]
          },
          {
            "id": "webbed_place_void_maw",
            "condition": {
              "and": [
                { "or": [ { "u_has_effect": "webbed" }, { "u_has_effect": "grabbed" } ] },
                { "math": [ "u_monsters_nearby('mon_void_spider') == 1" ] },
                { "math": [ "u_monsters_nearby('mon_void_spider_maw') < 4" ] }
              ]
            },
            "effect": [
              {
                "u_spawn_monster": "mon_void_spider_maw",
                "real_count": 1,
                "min_radius": 2,
                "max_radius": 4,
                "lifespan": [ "15 seconds", "25 seconds" ]
              }
            ]
          }
        ]
      }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_VOID_SPIDER_CONTROL",
    "effect": [
      {
        "run_eocs": [
          {
            "id": "void_spider_life_remaining",
            "condition": { "and": [ { "math": [ "u_hp('ALL') < 350" ] }, { "math": [ "u_void_spider_nest_disturbed != 1" ] } ] },
            "effect": [
              { "u_make_sound": "the spider mimic an anguished scream", "volume": 60, "type": "speech" },
              { "run_eocs": [ "EOC_VOID_SPIDER_DISTURBED_NEST" ] },
              { "math": [ "u_void_spider_nest_disturbed = 1" ] }
            ]
          },
          {
            "id": "kaleidoscope_horror",
            "effect": [
              {
                "u_spawn_monster": "mon_void_spider_maw",
                "real_count": { "math": [ "(u_hp('ALL') / 300)" ] },
                "min_radius": 1,
                "max_radius": 1,
                "lifespan": [ "1 seconds", "3 seconds" ]
              },
              {
                "//": "6 of these at the start, looses one for every 100 hp lost, monster starts at 600 hp",
                "u_spawn_monster": "mon_void_spider_limb",
                "real_count": { "math": [ "u_hp('ALL') / 100" ] },
                "min_radius": 2,
                "max_radius": 2,
                "lifespan": [ "1 seconds", "3 seconds" ]
              }
            ]
          }
        ]
      },
      { "u_cast_spell": { "id": "void_spider_empty", "hit_self": true } }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_VOID_SPIDER_DISTURBED_NEST",
    "global": true,
    "condition": { "math": [ "u_monsters_nearby('mon_void_spider') >= 1" ] },
    "effect": [
      { "u_message": "The shadows of frenzied limbs slip into reality", "type": "info" },
      {
        "u_spawn_monster": "mon_void_spider_spiderling",
        "real_count": [ 1, 3 ],
        "min_radius": 6,
        "max_radius": 12,
        "lifespan": [ "10 seconds", "25 seconds" ]
      },
      {
        "run_eocs": [
          {
            "id": "EOC_VOID_SPIDER_CHAOS_SWAP",
            "condition": { "one_in_chance": 10 },
            "effect": [ { "run_eocs": [ "EOC_VOID_SPIDER_CAST_CHAOS_SWAP" ] } ]
          },
          {
            "id": "EOC_VOID_SPIDER_SPAWN_HURT_JUVENILE",
            "condition": { "one_in_chance": 10 },
            "effect": [ { "u_spawn_monster": "mon_void_spider_spiderling_skewered", "real_count": 1, "min_radius": 6, "max_radius": 12 } ]
          },
          {
            "id": "EOC_VOID_SPIDER_SPAWN_EGGS",
            "condition": { "and": [ { "one_in_chance": 3 }, { "math": [ "void_spider_nest_eggs_spawned != 1" ] } ] },
            "effect": [
              { "mapgen_update": "void_spider_lair_eggs", "om_terrain": "void_spider_lair_a2" },
              { "math": [ "void_spider_nest_eggs_spawned = 1" ] }
            ]
          },
          {
            "id": "EOC_VOID_SPIDER_SPAWN_CORPSES",
            "condition": { "and": [ { "one_in_chance": 6 }, { "math": [ "void_spider_nest_corpses_spawned != 1" ] } ] },
            "effect": [
              { "mapgen_update": "void_spider_lair_corpses", "om_terrain": "void_spider_lair_a1" },
              { "math": [ "void_spider_nest_corpses_spawned = 1" ] }
            ]
          }
        ]
      },
      { "run_eocs": "EOC_VOID_SPIDER_DISTURBED_NEST", "time_in_future": [ "8 seconds", "10 seconds" ] }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_VOID_SPIDER_CAST_CHAOS_SWAP",
    "global": true,
    "effect": [
      { "u_location_variable": { "global_val": "void_spider_chaos_point_player" }, "min_radius": 5, "max_radius": 12 },
      { "u_teleport": { "global_val": "void_spider_chaos_point_player" } },
      { "u_message": "The cavern shifts under unseen pressure." }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_VOID_SPIDER_EMPTY_REVERT",
    "global": true,
    "condition": {
      "or": [
        { "u_at_om_location": "void_spider_lair_entrance" },
        { "u_at_om_location": "void_spider_lair_a1" },
        { "u_at_om_location": "void_spider_lair_a2" }
      ]
    },
    "effect": [
      { "u_cast_spell": { "id": "void_spider_empty_revert", "hit_self": true } },
      { "run_eocs": "EOC_VOID_SPIDER_EMPTY_REVERT", "time_in_future": "25 seconds" }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_VOID_SPIDER_ON_DEATH",
    "effect": [
      { "run_eocs": "EOC_VOID_SPIDER_KILLED", "time_in_future": "0 seconds" },
      { "run_eocs": "EOC_VOID_SPIDER_RESET_VARS", "time_in_future": "2 hours" },
      { "run_eocs": "EOC_DISSOLVE_VOID_SPIDER_LAIR", "time_in_future": "20 minutes" }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_DISSOLVE_VOID_SPIDER_LAIR",
    "effect": [
      { "u_message": "The cavern folds itself beyond perception.", "popup": true },
      {
        "u_location_variable": { "global_val": "nether_glass" },
        "target_params": { "om_terrain": "nether_glass_deep", "z": -10, "min_distance": 1 }
      },
      { "u_teleport": { "global_val": "nether_glass" }, "force": true },
      {
        "mapgen_update": "microlab_portal_elevator_physics_shift",
        "om_terrain": "microlab_portal_elevator_physics_glass"
      }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_VOID_SPIDER_KILLED",
    "global": true,
    "effect": [ { "math": [ "void_spider_killed = 1" ] }, { "u_add_var": "general_talk_killed_a_void_spider", "value": "yes" } ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_VOID_SPIDER_RESET_VARS",
    "global": true,
    "//": "Reset in case someone finds a second lair under some extraneous circumstances.",
    "effect": [
      { "math": [ "spider_lair_sealed = 0" ] },
      { "math": [ "void_spider_killed = 0" ] },
      { "math": [ "void_spider_nest_eggs_spawned = 0" ] },
      { "math": [ "void_spider_nest_corpses_spawned = 0" ] }
    ]
  }
]
