[
  {
    "type": "effect_on_condition",
    "id": "EOC_MELEE_PROF_ATTACK_MONSTER",
    "//": "If the player attacks a monster, and hits, run EOC to check what weapon type they're using.",
    "global": false,
    "eoc_type": "EVENT",
    "required_event": "character_melee_attacks_monster",
    "condition": { "math": [ "_hits", "==", "1" ] },
    "effect": [ { "run_eocs": "EOC_MELEE_PROF_WHAT_CATEGORY" } ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_MELEE_PROF_ATTACK_CHARACTER",
    "//": "If the player attacks a character, run EOC to check what weapon type they're using.",
    "global": false,
    "eoc_type": "EVENT",
    "required_event": "character_melee_attacks_character",
    "condition": { "math": [ "_hits", "==", "1" ] },
    "effect": [ { "run_eocs": "EOC_MELEE_PROF_WHAT_CATEGORY" } ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_MELEE_PROF_WHAT_CATEGORY",
    "//": "Checks what weapon categories are held, each increments experience, and defines lowest proficiency level of held weapon in the sub-EoCs.",
    "global": false,
    "effect": [
      { "math": [ "u_prof_lowest", "=", "4" ] },
      {
        "run_eocs": [
          "IS_AUTO_RIFLES",
          "IS_AUTO_PISTOLS",
          "IS_KNIVES",
          "IS_BATONS",
          "IS_FLAILS",
          "IS_MACES",
          "IS_MEDIUM_SWORDS",
          "IS_SHORT_SWORDS",
          "IS_LONG_SWORDS",
          "IS_QUARTERSTAVES",
          "IS_CLAWS",
          "IS_SHIVS",
          "IS_HOOKING",
          "IS_SPEARS",
          "IS_POLEARMS",
          "IS_FENCING",
          "IS_THRUSTING_SWORDS",
          "IS_BIONICS",
          "IS_BIONIC_SWORDS",
          "IS_GREAT_SWORDS",
          "IS_GREAT_HAMMERS",
          "IS_GREAT_AXES",
          "IS_HAND_AXES",
          "IS_UNARMED"
        ]
      },
      { "run_eocs": "EOC_MELEE_PROF_BENEFIT" }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "IS_AUTO_RIFLES",
    "global": false,
    "condition": { "u_has_wielded_with_weapon_category": "AUTOMATIC_RIFLES" },
    "effect": [
      {
        "if": { "math": [ "u_proficiency('prof_auto_rifles_familiar', 'format': 'percent')", ">=", "100" ] },
        "then": [
          {
            "if": { "math": [ "u_proficiency('prof_auto_rifles_pro', 'format': 'percent')", ">=", "100" ] },
            "then": [
              {
                "if": { "math": [ "u_proficiency('prof_auto_rifles_master', 'format': 'percent')", ">=", "100" ] },
                "then": [ { "math": [ "u_prof_level", "=", "3" ] }, { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] } ],
                "else": [
                  { "math": [ "u_proficiency('prof_auto_rifles_master', 'format': 'percent')", "+=", "rand(4) / 64" ] },
                  { "math": [ "u_prof_level", "=", "2" ] },
                  { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
                ]
              }
            ],
            "else": [
              { "math": [ "u_proficiency('prof_auto_rifles_pro', 'format': 'percent')", "+=", "rand(4) / 32" ] },
              { "math": [ "u_prof_level", "=", "1" ] },
              { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
            ]
          }
        ],
        "else": [
          { "math": [ "u_proficiency('prof_auto_rifles_familiar', 'format': 'percent')", "+=", "rand(4) / 16" ] },
          { "math": [ "u_prof_level", "=", "0" ] },
          { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
        ]
      }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "IS_AUTO_PISTOLS",
    "global": false,
    "condition": { "u_has_wielded_with_weapon_category": "AUTOMATIC_PISTOLS" },
    "effect": [
      {
        "if": { "math": [ "u_proficiency('prof_auto_pistols_familiar', 'format': 'percent')", ">=", "100" ] },
        "then": [
          {
            "if": { "math": [ "u_proficiency('prof_auto_pistols_pro', 'format': 'percent')", ">=", "100" ] },
            "then": [
              {
                "if": { "math": [ "u_proficiency('prof_auto_pistols_master', 'format': 'percent')", ">=", "100" ] },
                "then": [ { "math": [ "u_prof_level", "=", "3" ] }, { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] } ],
                "else": [
                  { "math": [ "u_proficiency('prof_auto_pistols_master', 'format': 'percent')", "+=", "rand(4) / 64" ] },
                  { "math": [ "u_prof_level", "=", "2" ] },
                  { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
                ]
              }
            ],
            "else": [
              { "math": [ "u_proficiency('prof_auto_pistols_pro', 'format': 'percent')", "+=", "rand(4) / 32" ] },
              { "math": [ "u_prof_level", "=", "1" ] },
              { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
            ]
          }
        ],
        "else": [
          { "math": [ "u_proficiency('prof_auto_pistols_familiar', 'format': 'percent')", "+=", "rand(4) / 16" ] },
          { "math": [ "u_prof_level", "=", "0" ] },
          { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
        ]
      }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "IS_KNIVES",
    "global": false,
    "condition": { "u_has_wielded_with_weapon_category": "KNIVES" },
    "effect": [
      {
        "if": { "math": [ "u_proficiency('prof_knives_familiar', 'format': 'percent')", ">=", "100" ] },
        "then": [
          {
            "if": { "math": [ "u_proficiency('prof_knives_pro', 'format': 'percent')", ">=", "100" ] },
            "then": [
              {
                "if": { "math": [ "u_proficiency('prof_knives_master', 'format': 'percent')", ">=", "100" ] },
                "then": [ { "math": [ "u_prof_level", "=", "3" ] }, { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] } ],
                "else": [
                  { "math": [ "u_proficiency('prof_knives_master', 'format': 'percent')", "+=", "rand(4) / 64" ] },
                  { "math": [ "u_prof_level", "=", "2" ] },
                  { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
                ]
              }
            ],
            "else": [
              { "math": [ "u_proficiency('prof_knives_pro', 'format': 'percent')", "+=", "rand(4) / 32" ] },
              { "math": [ "u_prof_level", "=", "1" ] },
              { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
            ]
          }
        ],
        "else": [
          { "math": [ "u_proficiency('prof_knives_familiar', 'format': 'percent')", "+=", "rand(4) / 16" ] },
          { "math": [ "u_prof_level", "=", "0" ] },
          { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
        ]
      }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "IS_BATONS",
    "global": false,
    "condition": { "u_has_wielded_with_weapon_category": "BATONS" },
    "effect": [
      {
        "if": { "math": [ "u_proficiency('prof_batons_familiar', 'format': 'percent')", ">=", "100" ] },
        "then": [
          {
            "if": { "math": [ "u_proficiency('prof_batons_pro', 'format': 'percent')", ">=", "100" ] },
            "then": [
              {
                "if": { "math": [ "u_proficiency('prof_batons_master', 'format': 'percent')", ">=", "100" ] },
                "then": [ { "math": [ "u_prof_level", "=", "3" ] }, { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] } ],
                "else": [
                  { "math": [ "u_proficiency('prof_batons_master', 'format': 'percent')", "+=", "rand(4) / 64" ] },
                  { "math": [ "u_prof_level", "=", "2" ] },
                  { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
                ]
              }
            ],
            "else": [
              { "math": [ "u_proficiency('prof_batons_pro', 'format': 'percent')", "+=", "rand(4) / 32" ] },
              { "math": [ "u_prof_level", "=", "1" ] },
              { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
            ]
          }
        ],
        "else": [
          { "math": [ "u_proficiency('prof_batons_familiar', 'format': 'percent')", "+=", "rand(4) / 16" ] },
          { "math": [ "u_prof_level", "=", "0" ] },
          { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
        ]
      }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "IS_FLAILS",
    "global": false,
    "condition": { "u_has_wielded_with_weapon_category": "FLAILS" },
    "effect": [
      {
        "if": { "math": [ "u_proficiency('prof_flails_familiar', 'format': 'percent')", ">=", "100" ] },
        "then": [
          {
            "if": { "math": [ "u_proficiency('prof_flails_pro', 'format': 'percent')", ">=", "100" ] },
            "then": [
              {
                "if": { "math": [ "u_proficiency('prof_flails_master', 'format': 'percent')", ">=", "100" ] },
                "then": [ { "math": [ "u_prof_level", "=", "3" ] }, { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] } ],
                "else": [
                  { "math": [ "u_proficiency('prof_flails_master', 'format': 'percent')", "+=", "rand(4) / 64" ] },
                  { "math": [ "u_prof_level", "=", "2" ] },
                  { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
                ]
              }
            ],
            "else": [
              { "math": [ "u_proficiency('prof_flails_pro', 'format': 'percent')", "+=", "rand(4) / 32" ] },
              { "math": [ "u_prof_level", "=", "1" ] },
              { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
            ]
          }
        ],
        "else": [
          { "math": [ "u_proficiency('prof_flails_familiar', 'format': 'percent')", "+=", "rand(4) / 16" ] },
          { "math": [ "u_prof_level", "=", "0" ] },
          { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
        ]
      }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "IS_MACES",
    "global": false,
    "condition": { "u_has_wielded_with_weapon_category": "MACES" },
    "effect": [
      {
        "if": { "math": [ "u_proficiency('prof_maces_familiar', 'format': 'percent')", ">=", "100" ] },
        "then": [
          {
            "if": { "math": [ "u_proficiency('prof_maces_pro', 'format': 'percent')", ">=", "100" ] },
            "then": [
              {
                "if": { "math": [ "u_proficiency('prof_maces_master', 'format': 'percent')", ">=", "100" ] },
                "then": [ { "math": [ "u_prof_level", "=", "3" ] }, { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] } ],
                "else": [
                  { "math": [ "u_proficiency('prof_maces_master', 'format': 'percent')", "+=", "rand(4) / 64" ] },
                  { "math": [ "u_prof_level", "=", "2" ] },
                  { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
                ]
              }
            ],
            "else": [
              { "math": [ "u_proficiency('prof_maces_pro', 'format': 'percent')", "+=", "rand(4) / 32" ] },
              { "math": [ "u_prof_level", "=", "1" ] },
              { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
            ]
          }
        ],
        "else": [
          { "math": [ "u_proficiency('prof_maces_familiar', 'format': 'percent')", "+=", "rand(4) / 16" ] },
          { "math": [ "u_prof_level", "=", "0" ] },
          { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
        ]
      }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "IS_MEDIUM_SWORDS",
    "global": false,
    "condition": { "u_has_wielded_with_weapon_category": "MEDIUM_SWORDS" },
    "effect": [
      {
        "if": { "math": [ "u_proficiency('prof_medium_swords_familiar', 'format': 'percent')", ">=", "100" ] },
        "then": [
          {
            "if": { "math": [ "u_proficiency('prof_medium_swords_pro', 'format': 'percent')", ">=", "100" ] },
            "then": [
              {
                "if": { "math": [ "u_proficiency('prof_medium_swords_master', 'format': 'percent')", ">=", "100" ] },
                "then": [ { "math": [ "u_prof_level", "=", "3" ] }, { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] } ],
                "else": [
                  { "math": [ "u_proficiency('prof_medium_swords_master', 'format': 'percent')", "+=", "rand(4) / 64" ] },
                  { "math": [ "u_prof_level", "=", "2" ] },
                  { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
                ]
              }
            ],
            "else": [
              { "math": [ "u_proficiency('prof_medium_swords_pro', 'format': 'percent')", "+=", "rand(4) / 32" ] },
              { "math": [ "u_prof_level", "=", "1" ] },
              { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
            ]
          }
        ],
        "else": [
          { "math": [ "u_proficiency('prof_medium_swords_familiar', 'format': 'percent')", "+=", "rand(4) / 16" ] },
          { "math": [ "u_prof_level", "=", "0" ] },
          { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
        ]
      }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "IS_SHORT_SWORDS",
    "global": false,
    "condition": { "u_has_wielded_with_weapon_category": "SHORT_SWORDS" },
    "effect": [
      {
        "if": { "math": [ "u_proficiency('prof_short_swords_familiar', 'format': 'percent')", ">=", "100" ] },
        "then": [
          {
            "if": { "math": [ "u_proficiency('prof_short_swords_pro', 'format': 'percent')", ">=", "100" ] },
            "then": [
              {
                "if": { "math": [ "u_proficiency('prof_short_swords_master', 'format': 'percent')", ">=", "100" ] },
                "then": [ { "math": [ "u_prof_level", "=", "3" ] }, { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] } ],
                "else": [
                  { "math": [ "u_proficiency('prof_short_swords_master', 'format': 'percent')", "+=", "rand(4) / 64" ] },
                  { "math": [ "u_prof_level", "=", "2" ] },
                  { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
                ]
              }
            ],
            "else": [
              { "math": [ "u_proficiency('prof_short_swords_pro', 'format': 'percent')", "+=", "rand(4) / 32" ] },
              { "math": [ "u_prof_level", "=", "1" ] },
              { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
            ]
          }
        ],
        "else": [
          { "math": [ "u_proficiency('prof_short_swords_familiar', 'format': 'percent')", "+=", "rand(4) / 16" ] },
          { "math": [ "u_prof_level", "=", "0" ] },
          { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
        ]
      }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "IS_LONG_SWORDS",
    "global": false,
    "condition": { "u_has_wielded_with_weapon_category": "LONG_SWORDS" },
    "effect": [
      {
        "if": { "math": [ "u_proficiency('prof_long_swords_familiar', 'format': 'percent')", ">=", "100" ] },
        "then": [
          {
            "if": { "math": [ "u_proficiency('prof_long_swords_pro', 'format': 'percent')", ">=", "100" ] },
            "then": [
              {
                "if": { "math": [ "u_proficiency('prof_long_swords_master', 'format': 'percent')", ">=", "100" ] },
                "then": [ { "math": [ "u_prof_level", "=", "3" ] }, { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] } ],
                "else": [
                  { "math": [ "u_proficiency('prof_long_swords_master', 'format': 'percent')", "+=", "rand(4) / 64" ] },
                  { "math": [ "u_prof_level", "=", "2" ] },
                  { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
                ]
              }
            ],
            "else": [
              { "math": [ "u_proficiency('prof_long_swords_pro', 'format': 'percent')", "+=", "rand(4) / 32" ] },
              { "math": [ "u_prof_level", "=", "1" ] },
              { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
            ]
          }
        ],
        "else": [
          { "math": [ "u_proficiency('prof_long_swords_familiar', 'format': 'percent')", "+=", "rand(4) / 16" ] },
          { "math": [ "u_prof_level", "=", "0" ] },
          { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
        ]
      }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "IS_QUARTERSTAVES",
    "global": false,
    "condition": { "u_has_wielded_with_weapon_category": "QUARTERSTAVES" },
    "effect": [
      {
        "if": { "math": [ "u_proficiency('prof_quarterstaves_familiar', 'format': 'percent')", ">=", "100" ] },
        "then": [
          {
            "if": { "math": [ "u_proficiency('prof_quarterstaves_pro', 'format': 'percent')", ">=", "100" ] },
            "then": [
              {
                "if": { "math": [ "u_proficiency('prof_quarterstaves_master', 'format': 'percent')", ">=", "100" ] },
                "then": [ { "math": [ "u_prof_level", "=", "3" ] }, { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] } ],
                "else": [
                  { "math": [ "u_proficiency('prof_quarterstaves_master', 'format': 'percent')", "+=", "rand(4) / 64" ] },
                  { "math": [ "u_prof_level", "=", "2" ] },
                  { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
                ]
              }
            ],
            "else": [
              { "math": [ "u_proficiency('prof_quarterstaves_pro', 'format': 'percent')", "+=", "rand(4) / 32" ] },
              { "math": [ "u_prof_level", "=", "1" ] },
              { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
            ]
          }
        ],
        "else": [
          { "math": [ "u_proficiency('prof_quarterstaves_familiar', 'format': 'percent')", "+=", "rand(4) / 16" ] },
          { "math": [ "u_prof_level", "=", "0" ] },
          { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
        ]
      }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "IS_CLAWS",
    "global": false,
    "condition": { "u_has_wielded_with_weapon_category": "CLAWS" },
    "effect": [
      {
        "if": { "math": [ "u_proficiency('prof_claws_familiar', 'format': 'percent')", ">=", "100" ] },
        "then": [
          {
            "if": { "math": [ "u_proficiency('prof_claws_pro', 'format': 'percent')", ">=", "100" ] },
            "then": [
              {
                "if": { "math": [ "u_proficiency('prof_claws_master', 'format': 'percent')", ">=", "100" ] },
                "then": [ { "math": [ "u_prof_level", "=", "3" ] }, { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] } ],
                "else": [
                  { "math": [ "u_proficiency('prof_claws_master', 'format': 'percent')", "+=", "rand(4) / 64" ] },
                  { "math": [ "u_prof_level", "=", "2" ] },
                  { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
                ]
              }
            ],
            "else": [
              { "math": [ "u_proficiency('prof_claws_pro', 'format': 'percent')", "+=", "rand(4) / 32" ] },
              { "math": [ "u_prof_level", "=", "1" ] },
              { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
            ]
          }
        ],
        "else": [
          { "math": [ "u_proficiency('prof_claws_familiar', 'format': 'percent')", "+=", "rand(4) / 16" ] },
          { "math": [ "u_prof_level", "=", "0" ] },
          { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
        ]
      }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "IS_SHIVS",
    "global": false,
    "condition": { "u_has_wielded_with_weapon_category": "SHIVS" },
    "effect": [
      {
        "if": { "math": [ "u_proficiency('prof_shivs_familiar', 'format': 'percent')", ">=", "100" ] },
        "then": [
          {
            "if": { "math": [ "u_proficiency('prof_shivs_pro', 'format': 'percent')", ">=", "100" ] },
            "then": [
              {
                "if": { "math": [ "u_proficiency('prof_shivs_master', 'format': 'percent')", ">=", "100" ] },
                "then": [ { "math": [ "u_prof_level", "=", "3" ] }, { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] } ],
                "else": [
                  { "math": [ "u_proficiency('prof_shivs_master', 'format': 'percent')", "+=", "rand(4) / 64" ] },
                  { "math": [ "u_prof_level", "=", "2" ] },
                  { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
                ]
              }
            ],
            "else": [
              { "math": [ "u_proficiency('prof_shivs_pro', 'format': 'percent')", "+=", "rand(4) / 32" ] },
              { "math": [ "u_prof_level", "=", "1" ] },
              { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
            ]
          }
        ],
        "else": [
          { "math": [ "u_proficiency('prof_shivs_familiar', 'format': 'percent')", "+=", "rand(4) / 16" ] },
          { "math": [ "u_prof_level", "=", "0" ] },
          { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
        ]
      }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "IS_HOOKING",
    "global": false,
    "condition": { "u_has_wielded_with_weapon_category": "HOOKING_WEAPONRY" },
    "effect": [
      {
        "if": { "math": [ "u_proficiency('prof_hooking_familiar', 'format': 'percent')", ">=", "100" ] },
        "then": [
          {
            "if": { "math": [ "u_proficiency('prof_hooking_pro', 'format': 'percent')", ">=", "100" ] },
            "then": [
              {
                "if": { "math": [ "u_proficiency('prof_hooking_master', 'format': 'percent')", ">=", "100" ] },
                "then": [ { "math": [ "u_prof_level", "=", "3" ] }, { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] } ],
                "else": [
                  { "math": [ "u_proficiency('prof_hooking_master', 'format': 'percent')", "+=", "rand(4) / 64" ] },
                  { "math": [ "u_prof_level", "=", "2" ] },
                  { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
                ]
              }
            ],
            "else": [
              { "math": [ "u_proficiency('prof_hooking_pro', 'format': 'percent')", "+=", "rand(4) / 32" ] },
              { "math": [ "u_prof_level", "=", "1" ] },
              { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
            ]
          }
        ],
        "else": [
          { "math": [ "u_proficiency('prof_hooking_familiar', 'format': 'percent')", "+=", "rand(4) / 16" ] },
          { "math": [ "u_prof_level", "=", "0" ] },
          { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
        ]
      }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "IS_SPEARS",
    "global": false,
    "condition": { "u_has_wielded_with_weapon_category": "SPEARS" },
    "effect": [
      {
        "if": { "math": [ "u_proficiency('prof_spears_familiar', 'format': 'percent')", ">=", "100" ] },
        "then": [
          {
            "if": { "math": [ "u_proficiency('prof_spears_pro', 'format': 'percent')", ">=", "100" ] },
            "then": [
              {
                "if": { "math": [ "u_proficiency('prof_spears_master', 'format': 'percent')", ">=", "100" ] },
                "then": [ { "math": [ "u_prof_level", "=", "3" ] }, { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] } ],
                "else": [
                  { "math": [ "u_proficiency('prof_spears_master', 'format': 'percent')", "+=", "rand(4) / 64" ] },
                  { "math": [ "u_prof_level", "=", "2" ] },
                  { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
                ]
              }
            ],
            "else": [
              { "math": [ "u_proficiency('prof_spears_pro', 'format': 'percent')", "+=", "rand(4) / 32" ] },
              { "math": [ "u_prof_level", "=", "1" ] },
              { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
            ]
          }
        ],
        "else": [
          { "math": [ "u_proficiency('prof_spears_familiar', 'format': 'percent')", "+=", "rand(4) / 16" ] },
          { "math": [ "u_prof_level", "=", "0" ] },
          { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
        ]
      }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "IS_POLEARMS",
    "global": false,
    "condition": { "u_has_wielded_with_weapon_category": "POLEARMS" },
    "effect": [
      {
        "if": { "math": [ "u_proficiency('prof_polearms_familiar', 'format': 'percent')", ">=", "100" ] },
        "then": [
          {
            "if": { "math": [ "u_proficiency('prof_polearms_pro', 'format': 'percent')", ">=", "100" ] },
            "then": [
              {
                "if": { "math": [ "u_proficiency('prof_polearms_master', 'format': 'percent')", ">=", "100" ] },
                "then": [ { "math": [ "u_prof_level", "=", "3" ] }, { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] } ],
                "else": [
                  { "math": [ "u_proficiency('prof_polearms_master', 'format': 'percent')", "+=", "rand(4) / 64" ] },
                  { "math": [ "u_prof_level", "=", "2" ] },
                  { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
                ]
              }
            ],
            "else": [
              { "math": [ "u_proficiency('prof_polearms_pro', 'format': 'percent')", "+=", "rand(4) / 32" ] },
              { "math": [ "u_prof_level", "=", "1" ] },
              { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
            ]
          }
        ],
        "else": [
          { "math": [ "u_proficiency('prof_polearms_familiar', 'format': 'percent')", "+=", "rand(4) / 16" ] },
          { "math": [ "u_prof_level", "=", "0" ] },
          { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
        ]
      }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "IS_FENCING",
    "global": false,
    "condition": { "u_has_wielded_with_weapon_category": "FENCING_WEAPONRY" },
    "effect": [
      {
        "if": { "math": [ "u_proficiency('prof_fencing_weapons_familiar', 'format': 'percent')", ">=", "100" ] },
        "then": [
          {
            "if": { "math": [ "u_proficiency('prof_fencing_weapons_pro', 'format': 'percent')", ">=", "100" ] },
            "then": [
              {
                "if": { "math": [ "u_proficiency('prof_fencing_weapons_master', 'format': 'percent')", ">=", "100" ] },
                "then": [ { "math": [ "u_prof_level", "=", "3" ] }, { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] } ],
                "else": [
                  { "math": [ "u_proficiency('prof_fencing_weapons_master', 'format': 'percent')", "+=", "rand(4) / 64" ] },
                  { "math": [ "u_prof_level", "=", "2" ] },
                  { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
                ]
              }
            ],
            "else": [
              { "math": [ "u_proficiency('prof_fencing_weapons_pro', 'format': 'percent')", "+=", "rand(4) / 32" ] },
              { "math": [ "u_prof_level", "=", "1" ] },
              { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
            ]
          }
        ],
        "else": [
          { "math": [ "u_proficiency('prof_fencing_weapons_familiar', 'format': 'percent')", "+=", "rand(4) / 16" ] },
          { "math": [ "u_prof_level", "=", "0" ] },
          { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
        ]
      }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "IS_THRUSTING_SWORDS",
    "global": false,
    "condition": { "u_has_wielded_with_weapon_category": "LONG_THRUSTING_SWORD" },
    "effect": [
      {
        "if": { "math": [ "u_proficiency('prof_thrusting_swords_familiar', 'format': 'percent')", ">=", "100" ] },
        "then": [
          {
            "if": { "math": [ "u_proficiency('prof_thrusting_swords_pro', 'format': 'percent')", ">=", "100" ] },
            "then": [
              {
                "if": { "math": [ "u_proficiency('prof_thrusting_swords_master', 'format': 'percent')", ">=", "100" ] },
                "then": [ { "math": [ "u_prof_level", "=", "3" ] }, { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] } ],
                "else": [
                  { "math": [ "u_proficiency('prof_thrusting_swords_master', 'format': 'percent')", "+=", "rand(4) / 64" ] },
                  { "math": [ "u_prof_level", "=", "2" ] },
                  { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
                ]
              }
            ],
            "else": [
              { "math": [ "u_proficiency('prof_thrusting_swords_pro', 'format': 'percent')", "+=", "rand(4) / 32" ] },
              { "math": [ "u_prof_level", "=", "1" ] },
              { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
            ]
          }
        ],
        "else": [
          { "math": [ "u_proficiency('prof_thrusting_swords_familiar', 'format': 'percent')", "+=", "rand(4) / 16" ] },
          { "math": [ "u_prof_level", "=", "0" ] },
          { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
        ]
      }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "IS_BIONICS",
    "global": false,
    "condition": { "or": [ { "u_has_wielded_with_weapon_category": "BIONIC_WEAPONRY" }, { "u_using_martial_art": "style_biojutsu" } ] },
    "effect": [
      {
        "if": { "math": [ "u_proficiency('prof_bionics_familiar', 'format': 'percent')", ">=", "100" ] },
        "then": [
          {
            "if": { "math": [ "u_proficiency('prof_bionics_pro', 'format': 'percent')", ">=", "100" ] },
            "then": [
              {
                "if": { "math": [ "u_proficiency('prof_bionics_master', 'format': 'percent')", ">=", "100" ] },
                "then": [ { "math": [ "u_prof_level", "=", "3" ] }, { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] } ],
                "else": [
                  { "math": [ "u_proficiency('prof_bionics_master', 'format': 'percent')", "+=", "rand(4) / 64" ] },
                  { "math": [ "u_prof_level", "=", "2" ] },
                  { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
                ]
              }
            ],
            "else": [
              { "math": [ "u_proficiency('prof_bionics_pro', 'format': 'percent')", "+=", "rand(4) / 32" ] },
              { "math": [ "u_prof_level", "=", "1" ] },
              { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
            ]
          }
        ],
        "else": [
          { "math": [ "u_proficiency('prof_bionics_familiar', 'format': 'percent')", "+=", "rand(4) / 16" ] },
          { "math": [ "u_prof_level", "=", "0" ] },
          { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
        ]
      }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "IS_BIONIC_SWORDS",
    "global": false,
    "condition": { "u_has_wielded_with_weapon_category": "BIONIC_SWORDS" },
    "effect": [
      {
        "if": { "math": [ "u_proficiency('prof_bionic_swords_familiar', 'format': 'percent')", ">=", "100" ] },
        "then": [
          {
            "if": { "math": [ "u_proficiency('prof_bionic_swords_pro', 'format': 'percent')", ">=", "100" ] },
            "then": [
              {
                "if": { "math": [ "u_proficiency('prof_bionic_swords_master', 'format': 'percent')", ">=", "100" ] },
                "then": [ { "math": [ "u_prof_level", "=", "3" ] }, { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] } ],
                "else": [
                  { "math": [ "u_proficiency('prof_bionic_swords_master', 'format': 'percent')", "+=", "rand(4) / 64" ] },
                  { "math": [ "u_prof_level", "=", "2" ] },
                  { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
                ]
              }
            ],
            "else": [
              { "math": [ "u_proficiency('prof_bionic_swords_pro', 'format': 'percent')", "+=", "rand(4) / 32" ] },
              { "math": [ "u_prof_level", "=", "1" ] },
              { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
            ]
          }
        ],
        "else": [
          { "math": [ "u_proficiency('prof_bionic_swords_familiar', 'format': 'percent')", "+=", "rand(4) / 16" ] },
          { "math": [ "u_prof_level", "=", "0" ] },
          { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
        ]
      }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "IS_GREAT_SWORDS",
    "global": false,
    "condition": { "u_has_wielded_with_weapon_category": "GREAT_SWORDS" },
    "effect": [
      {
        "if": { "math": [ "u_proficiency('prof_great_swords_familiar', 'format': 'percent')", ">=", "100" ] },
        "then": [
          {
            "if": { "math": [ "u_proficiency('prof_great_swords_pro', 'format': 'percent')", ">=", "100" ] },
            "then": [
              {
                "if": { "math": [ "u_proficiency('prof_great_swords_master', 'format': 'percent')", ">=", "100" ] },
                "then": [ { "math": [ "u_prof_level", "=", "3" ] }, { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] } ],
                "else": [
                  { "math": [ "u_proficiency('prof_great_swords_master', 'format': 'percent')", "+=", "rand(4) / 64" ] },
                  { "math": [ "u_prof_level", "=", "2" ] },
                  { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
                ]
              }
            ],
            "else": [
              { "math": [ "u_proficiency('prof_great_swords_pro', 'format': 'percent')", "+=", "rand(4) / 32" ] },
              { "math": [ "u_prof_level", "=", "1" ] },
              { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
            ]
          }
        ],
        "else": [
          { "math": [ "u_proficiency('prof_great_swords_familiar', 'format': 'percent')", "+=", "rand(4) / 16" ] },
          { "math": [ "u_prof_level", "=", "0" ] },
          { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
        ]
      }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "IS_GREAT_HAMMERS",
    "global": false,
    "condition": { "u_has_wielded_with_weapon_category": "GREAT_HAMMERS" },
    "effect": [
      {
        "if": { "math": [ "u_proficiency('prof_great_hammers_familiar', 'format': 'percent')", ">=", "100" ] },
        "then": [
          {
            "if": { "math": [ "u_proficiency('prof_great_hammers_pro', 'format': 'percent')", ">=", "100" ] },
            "then": [
              {
                "if": { "math": [ "u_proficiency('prof_great_hammers_master', 'format': 'percent')", ">=", "100" ] },
                "then": [ { "math": [ "u_prof_level", "=", "3" ] }, { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] } ],
                "else": [
                  { "math": [ "u_proficiency('prof_great_hammers_master', 'format': 'percent')", "+=", "rand(4) / 64" ] },
                  { "math": [ "u_prof_level", "=", "2" ] },
                  { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
                ]
              }
            ],
            "else": [
              { "math": [ "u_proficiency('prof_great_hammers_pro', 'format': 'percent')", "+=", "rand(4) / 32" ] },
              { "math": [ "u_prof_level", "=", "1" ] },
              { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
            ]
          }
        ],
        "else": [
          { "math": [ "u_proficiency('prof_great_hammers_familiar', 'format': 'percent')", "+=", "rand(4) / 16" ] },
          { "math": [ "u_prof_level", "=", "0" ] },
          { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
        ]
      }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "IS_GREAT_AXES",
    "global": false,
    "condition": { "u_has_wielded_with_weapon_category": "GREAT_AXES" },
    "effect": [
      {
        "if": { "math": [ "u_proficiency('prof_great_axes_familiar', 'format': 'percent')", ">=", "100" ] },
        "then": [
          {
            "if": { "math": [ "u_proficiency('prof_great_axes_pro', 'format': 'percent')", ">=", "100" ] },
            "then": [
              {
                "if": { "math": [ "u_proficiency('prof_great_axes_master', 'format': 'percent')", ">=", "100" ] },
                "then": [ { "math": [ "u_prof_level", "=", "3" ] }, { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] } ],
                "else": [
                  { "math": [ "u_proficiency('prof_great_axes_master', 'format': 'percent')", "+=", "rand(4) / 64" ] },
                  { "math": [ "u_prof_level", "=", "2" ] },
                  { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
                ]
              }
            ],
            "else": [
              { "math": [ "u_proficiency('prof_great_axes_pro', 'format': 'percent')", "+=", "rand(4) / 32" ] },
              { "math": [ "u_prof_level", "=", "1" ] },
              { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
            ]
          }
        ],
        "else": [
          { "math": [ "u_proficiency('prof_great_axes_familiar', 'format': 'percent')", "+=", "rand(4) / 16" ] },
          { "math": [ "u_prof_level", "=", "0" ] },
          { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
        ]
      }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "IS_HAND_AXES",
    "global": false,
    "condition": { "u_has_wielded_with_weapon_category": "HAND_AXES" },
    "effect": [
      {
        "if": { "math": [ "u_proficiency('prof_hand_axes_familiar', 'format': 'percent')", ">=", "100" ] },
        "then": [
          {
            "if": { "math": [ "u_proficiency('prof_hand_axes_pro', 'format': 'percent')", ">=", "100" ] },
            "then": [
              {
                "if": { "math": [ "u_proficiency('prof_hand_axes_master', 'format': 'percent')", ">=", "100" ] },
                "then": [ { "math": [ "u_prof_level", "=", "3" ] }, { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] } ],
                "else": [
                  { "math": [ "u_proficiency('prof_hand_axes_master', 'format': 'percent')", "+=", "rand(4) / 64" ] },
                  { "math": [ "u_prof_level", "=", "2" ] },
                  { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
                ]
              }
            ],
            "else": [
              { "math": [ "u_proficiency('prof_hand_axes_pro', 'format': 'percent')", "+=", "rand(4) / 32" ] },
              { "math": [ "u_prof_level", "=", "1" ] },
              { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
            ]
          }
        ],
        "else": [
          { "math": [ "u_proficiency('prof_hand_axes_familiar', 'format': 'percent')", "+=", "rand(4) / 16" ] },
          { "math": [ "u_prof_level", "=", "0" ] },
          { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
        ]
      }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "IS_UNARMED",
    "global": false,
    "condition": {
      "or": [
        { "and": [ { "not": "u_can_drop_weapon" }, { "not": { "u_has_wielded_with_weapon_category": "BIONIC_WEAPONS" } } ] },
        { "u_using_martial_art": "style_kicks" }
      ]
    },
    "effect": [
      {
        "if": { "math": [ "u_proficiency('prof_unarmed_familiar', 'format': 'percent')", ">=", "100" ] },
        "then": [
          {
            "if": { "math": [ "u_proficiency('prof_unarmed_pro', 'format': 'percent')", ">=", "100" ] },
            "then": [
              {
                "if": { "math": [ "u_proficiency('prof_unarmed_master', 'format': 'percent')", ">=", "100" ] },
                "then": [ { "math": [ "u_prof_level", "=", "3" ] }, { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] } ],
                "else": [
                  { "math": [ "u_proficiency('prof_unarmed_master', 'format': 'percent')", "+=", "rand(4) / 64" ] },
                  { "math": [ "u_prof_level", "=", "2" ] },
                  { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
                ]
              }
            ],
            "else": [
              { "math": [ "u_proficiency('prof_unarmed_pro', 'format': 'percent')", "+=", "rand(4) / 32" ] },
              { "math": [ "u_prof_level", "=", "1" ] },
              { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
            ]
          }
        ],
        "else": [
          { "math": [ "u_proficiency('prof_unarmed_familiar', 'format': 'percent')", "+=", "rand(4) / 16" ] },
          { "math": [ "u_prof_level", "=", "0" ] },
          { "math": [ "u_prof_lowest", "=", "min(u_prof_level, u_prof_lowest)" ] }
        ]
      }
    ]
  },
  {
    "type": "effect_on_condition",
    "id": "EOC_MELEE_PROF_BENEFIT",
    "//": "Refunds stamina based on the presumed model of stamina cost:  [ (((Item Weight / 16) + 50 ) * -1) + Melee Skill ]. This excludes the stance modifier, due to not being able to detect if the character is crouching at time of writing. ",
    "global": false,
    "condition": { "not": { "or": [ { "math": [ "u_prof_lowest", "==", "4" ] }, { "math": [ "u_prof_lowest", "==", "0" ] } ] } },
    "effect": [
      {
        "u_run_inv_eocs": "all",
        "search_data": [ { "wielded_only": true } ],
        "true_eocs": [
          {
            "id": "EOC_GET_WIELD_WEIGHT",
            "effect": [ { "math": [ "u_stamina_delta", "=", "max( 50, round(stamcost(n_val('weight'), u_skill('melee'))))" ] } ]
          }
        ]
      },
      { "math": [ "u_stamina_delta", "=", "round(stamrefund( u_stamina_delta, u_prof_lowest))" ] },
      { "math": [ "u_val('stamina')", "+=", "u_stamina_delta" ] }
    ]
  },
  {
    "type": "jmath_function",
    "id": "stamcost",
    "num_args": 2,
    "return": "_0 / 1000 / 16 + 50 - _1"
  },
  {
    "type": "jmath_function",
    "id": "stamrefund",
    "num_args": 2,
    "return": " _0 * ( .0125 * ( 2 ^ _1))"
  }
]
