[
  {
    "type": "effect_on_condition",
    "id": "afs_night_messages",
    "recurrence": [ "8 hours", "72 hours" ],
    "condition": { "and": [ { "one_in_chance": 3 }, { "not": "is_day" }, "u_can_see", { "is_weather": "clear" }, "u_is_outside" ] },
    "effect": [ { "u_message": "AFS_NIGHT_MESSAGES_1", "snippet": true } ]
  },
  {
    "type": "effect_on_condition",
    "id": "afs_motion_sensor_eoc",
    "condition": { "u_has_items": { "item": "afs_motion_sensor_on", "charges": 1 } },
    "effect": [
      {
        "run_eocs": [
          {
            "id": "afs_motion_sensor_audio_warning_high",
            "condition": { "math": [ "u_monsters_nearby('radius': 24) > 15" ] },
            "effect": [ { "u_message": "The motion detector whines distressingly!", "type": "warning" } ],
            "false_effect": {
              "run_eocs": [
                {
                  "id": "afs_motion_sensor_audio_warning_medium",
                  "condition": { "math": [ "u_monsters_nearby('radius': 24) > 5" ] },
                  "effect": [ { "u_message": "The motion detector emits a short series of warning beeps.", "type": "warning" } ],
                  "false_effect": {
                    "run_eocs": [
                      {
                        "id": "afs_motion_sensor_audio_warning_low",
                        "condition": { "math": [ "u_monsters_nearby('radius': 24) > 1" ] },
                        "effect": [ { "u_message": "The motion detector emits a single warning beep.", "type": "info" } ]
                      }
                    ]
                  }
                }
              ]
            }
          }
        ]
      },
      { "math": [ "u_flag_motion_sensor_afs_motion_sensor_ping++" ] },
      { "run_eocs": "afs_motion_sensor_eoc_end_ping", "time_in_future": "2 seconds" }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "afs_motion_sensor_eoc_end_ping",
    "effect": [ { "math": [ "u_flag_motion_sensor_afs_motion_sensor_ping = 0" ] } ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_ESCAPE_POD_CHAIR",
    "effect": [
      {
        "u_location_variable": { "context_val": "escape_pod_crate" },
        "target_params": { "om_terrain": "crashing_ship_4", "z": -10 },
        "terrain": "t_escape_pod_floor",
        "target_max_radius": 24
      },
      {
        "u_map_run_item_eocs": "all",
        "loc": { "context_val": "escape_pod_crate" },
        "min_radius": 0,
        "max_radius": 0,
        "true_eocs": [ { "id": "EOC_AFS_ESCAPE_POD_CARGO_TP", "effect": [ { "npc_teleport": { "global_val": "new_map" } } ] } ]
      },
      {
        "u_message": "You make sure that all equipment is strapped down and loose items are put away to avoid projectiles during launch before you strap yourself into the escape pod seat and press the launch button.  With an incredibly loud roar and a massive acceleration that presses you into the seat, the escape pod fires from the ship, plummeting towards the planet below.",
        "popup": true
      },
      { "u_teleport": { "global_val": "new_map" }, "force": true }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_CRASHING_SHIP_SETUP",
    "effect": [
      {
        "u_location_variable": { "global_val": "new_map" },
        "target_params": { "om_terrain": "afs_crashed_escape_pod", "z": 0 },
        "terrain": "t_metal_floor",
        "target_max_radius": 30,
        "min_radius": 0,
        "max_radius": 0
      },
      { "run_eocs": "EOC_CRASHING_SHIP_U_DIE", "time_in_future": "7 minutes" }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_CRASHING_SHIP_U_DIE",
    "condition": { "u_near_om_location": "crashing_ship_5", "range": 1 },
    "effect": [
      {
        "u_message": "A large boom rocks the hull, fire engulfs the decks.  You can do nothing but watch as a wall of burning gas rushes towards you, consumes you as fast as it came, and then all is black.",
        "popup": true
      },
      "u_die"
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_ESPER_SCENARIO_SETUP",
    "effect": [
      { "math": [ "u_hp('head')", "-=", "rand(5)" ] },
      { "math": [ "u_hp('torso')", "-=", "rand(5)" ] },
      { "math": [ "u_hp('arm_r')", "-=", "rand(5)" ] },
      { "math": [ "u_hp('arm_l')", "-=", "rand(5)" ] },
      { "math": [ "u_hp('leg_l')", "-=", "rand(5)" ] },
      { "math": [ "u_hp('leg_r')", "-=", "rand(5)" ] }
    ]
  },
  {
    "id": "EOC_vahagn_check_shootfoes",
    "type": "effect_on_condition",
    "condition": { "and": [ { "not": { "u_has_effect": "vahagan_fired_at" } } ] },
    "effect": [
      { "u_add_effect": "vahagan_fired_at", "duration": "1 seconds" },
      { "math": [ "times_firing = 0" ] },
      { "u_location_variable": { "context_val": "shooter" } },
      {
        "u_run_monster_eocs": [
          {
            "id": "_vahagn_shootfoes",
            "condition": {
              "and": [
                { "u_has_effect": "smart_targeted" },
                { "math": [ "u_hp('ALL') > 1" ] },
                { "math": [ "times_firing < 9" ] },
                { "not": { "u_has_effect": "vahagan_fired_at" } }
              ]
            },
            "effect": [
              { "u_add_effect": "vahagan_fired_at", "duration": "1 seconds" },
              { "math": [ "times_firing++" ] },
              {
                "run_eocs": [ "EOC_vahagn_shootfoes" ],
                "alpha_loc": { "context_val": "shooter" },
                "beta_talker": "u"
              }
            ]
          }
        ],
        "monster_range": 45,
        "monster_must_see": true
      },
      { "math": [ "times_firing = 0" ] }
    ]
  },
  {
    "id": "EOC_vahagn_shootfoes",
    "type": "effect_on_condition",
    "effect": [ "u_ranged_attack" ]
  }
]
