[
  {
    "type": "effect_on_condition",
    "id": "EOC_AFS_TELEKINETIC_FAR_HAND_SELECTOR",
    "effect": {
      "run_eoc_selector": [ "EOC_AFS_TELEKINETIC_FAR_HAND_SELECTOR_PULL", "EOC_AFS_TELEKINETIC_FAR_HAND_SELECTOR_PUSH" ],
      "names": [ "Pull", "Push" ],
      "keys": [ "1", "2" ],
      "descriptions": [ "Pull a set of items to you.", "Push a set of items away from you." ]
    }
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_AFS_TELEKINETIC_FAR_HAND_SELECTOR_PULL",
    "effect": { "u_cast_spell": { "id": "afs_telekinetic_item_pull_real" }, "targeted": true }
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_AFS_TELEKINETIC_FAR_HAND_SELECTOR_PUSH",
    "effect": { "u_cast_spell": { "id": "afs_telekinetic_item_push_real" }, "targeted": true }
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_AFS_TELEKINETIC_FORCE_SHOVE_SELECTOR",
    "effect": {
      "run_eoc_selector": [ "EOC_AFS_TELEKINETIC_FORCE_SHOVE_SELECTOR_PUSH", "EOC_AFS_TELEKINETIC_FORCE_SHOVE_SELECTOR_PULL" ],
      "names": [ "Push", "Pull" ],
      "keys": [ "1", "2" ],
      "descriptions": [ "Shove a target away from you.", "Grab a target and pull them towards you." ]
    }
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_AFS_TELEKINETIC_FORCE_SHOVE_SELECTOR_PUSH",
    "effect": { "u_cast_spell": { "id": "afs_telekinetic_force_shove_away_target" }, "targeted": true }
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_AFS_TELEKINETIC_FORCE_SHOVE_SELECTOR_PULL",
    "effect": { "u_cast_spell": { "id": "afs_telekinetic_force_shove_toward_target" }, "targeted": true }
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_AFS_TELEKINETIC_FORCE_SHOVE_PUSH_CHECKER",
    "effect": [
      { "math": [ "u_telekinesis_intelligence = ( ( n_val('intelligence') + 10) / 20 )" ] },
      { "math": [ "u_telekinesis_power_level = n_spell_level('afs_telekinetic_move_creature')" ] },
      {
        "math": [
          "u_weight_ratio",
          "=",
          "(((u_telekinesis_power_level * 25) * u_telekinesis_intelligence) + 10) / (u_weight() / 1000000)"
        ]
      },
      { "math": [ "u_afs_telekinesis_shove_spell_level = clamp(((u_weight_ratio - 1) * 2), 0, 30)" ] },
      { "u_location_variable": { "context_val": "loc" } },
      {
        "if": { "math": [ "u_afs_telekinesis_shove_spell_level < 1" ] },
        "then": { "run_eocs": "EOC_AFS_TELEKINETIC_PUSH_DOWN_CHECKER" },
        "else": [
          {
            "if": "npc_is_avatar",
            "then": [
              { "npc_message": "You hurl your target.", "type": "good" },
              {
                "run_eocs": [
                  {
                    "id": "EOC_AFS_TELEKINETIC_PUSH_DIRECTION_PICKER",
                    "effect": [
                      { "u_location_variable": { "context_val": "u_pos" } },
                      {
                        "npc_choose_adjacent_highlight": { "context_val": "push_direction_incorrect" },
                        "target_var": { "context_val": "u_pos" },
                        "message": "Select direction."
                      },
                      {
                        "mirror_coordinates": { "context_val": "push_direction_correct" },
                        "center_var": { "context_val": "u_pos" },
                        "relative_var": { "context_val": "push_direction_incorrect" }
                      },
                      {
                        "u_knockback": { "math": [ "u_afs_telekinesis_shove_spell_level" ] },
                        "stun": 1,
                        "dam_mult": 2,
                        "direction_var": { "context_val": "push_direction_correct" }
                      }
                    ]
                  }
                ]
              }
            ],
            "else": [
              {
                "npc_cast_spell": { "id": "afs_telekinetic_force_shove_away", "min_level": { "math": [ "u_telekinesis_shove_spell_level" ] } },
                "loc": { "context_val": "loc" }
              },
              { "run_eocs": "EOC_AFS_TELEKINETIC_PUSH_DOWN_CHECKER" }
            ]
          }
        ]
      }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_AFS_TELEKINETIC_PUSH_DOWN_CHECKER",
    "condition": { "x_in_y_chance": { "x": { "math": [ "u_weight_ratio * 1000" ] }, "y": 1000 } },
    "effect": [
      { "u_add_effect": "downed", "duration": 2 },
      { "npc_message": "You shove your target off their feet.", "type": "good" }
    ],
    "false_effect": [ { "npc_message": "You attempt to shove your target but they are too heavy!", "type": "bad" } ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_AFS_TELEKINETIC_FORCE_SHOVE_PULL_CHECKER",
    "effect": [
      { "math": [ "u_telekinesis_intelligence = ( ( n_val('intelligence') + 10) / 20 )" ] },
      { "math": [ "u_telekinesis_power_level = n_spell_level('afs_telekinetic_move_creature')" ] },
      {
        "math": [
          "u_weight_ratio",
          "=",
          "(((u_telekinesis_power_level * 25) * u_telekinesis_intelligence ) + 10) / (u_weight() / 1000000)"
        ]
      },
      { "math": [ "u_telekinesis_pull_spell_level = clamp(((u_weight_ratio - 1) * 2), 0, 30)" ] },
      { "u_location_variable": { "context_val": "loc" } },
      {
        "if": { "math": [ "u_telekinesis_pull_spell_level < 1" ] },
        "then": { "run_eocs": "EOC_AFS_TELEKINETIC_PUSH_DOWN_CHECKER" },
        "else": [
          {
            "npc_cast_spell": { "id": "afs_telekinetic_force_shove_toward", "min_level": { "math": [ "u_telekinesis_shove_spell_level" ] } },
            "loc": { "context_val": "loc" }
          },
          { "npc_message": "You pull your target towards you.", "type": "good" },
          { "run_eocs": "EOC_AFS_TELEKINETIC_PUSH_DOWN_CHECKER" }
        ]
      }
    ]
  }
]
