<commit_before>(function() {
  var Sim = Simulator;
  var affixes = Sim.affixes;
  var gems = Sim.gems;

  Sim.register("init", function() {
    var fx = {
      hitfear: {status: "feared", duration: 180},
      hitstun: {status: "stunned", duration: 180},
      hitblind: {status: "blinded", duration: 180},
      hitfreeze: {status: "frozen", duration: 180},
      hitchill: {status: "chilled", duration: 180},
      hitslow: {status: "slowed", duration: 180},
      hitimmobilize: {status: "rooted", duration: 180},
      hitknockback: {status: "knockback", duration: 30},
    };
    for (var id in fx) {
      if (this.stats[id]) {
        Sim.pushCastInfo({triggered: id});
        this.register("onhit_proc", (function(id, fx) {
          return function(data) {
            if (Sim.random(id, 0.01 * Sim.stats[id] * data.proc, data.targets / Sim.target.count)) {
              Sim.addBuff(fx.status, undefined, fx.duration);
            }
          };
        })(id, fx[id]));
        Sim.popCastInfo();
      }
    }
    if (this.stats.bleed) {
      Sim.pushCastInfo({triggered: "bleed"});
      this.register("onhit_proc", function(data) {
        if (Sim.random("bleed", 0.01 * Sim.stats.bleed.chance * data.proc, data.targets / Sim.target.count)) {
          Sim.addBuff("bleed", undefined, {duration: 300, tickrate: 15, data: {amount: Sim.stats.bleed.amount}, ontick: function(data) {
            Sim.damage({elem: "phy", targets: Sim.target.count, coeff: data.amount * 0.01 / 20, orphan: true});
          }});
        }
      });
      Sim.popCastInfo();
    }
  });

  gems.powerful = function(level) {
    if (level >= 25) Sim.addBaseStats({edmg: 15});
    if (Sim.params.powerful && Sim.params.powerful[0]) {
      Sim.addBuff("powerful", {damage: 20});
    }
  };
  gems.trapped = function(level) {
    if (level >= 25 && Sim.target.distance - Sim.target.size < 15) {
      Sim.addBuff("slowed");
    }
    Sim.register("updatestats", function(data) {
      if (data.stats.chilled || data.stats.frozen ||
          data.stats.blinded || data.stats.stunned ||
          data.stats.slowed || data.stats.knockback ||
          data.stats.charmed || data.stats.feared || data.stats.rooted) {
        data.stats.add("dmgmul", 15 + 0.3 * level);
      }
    });
  };
  gems.enforcer = function(level) {
    Sim.addBaseStats({petdamage: 15 + 0.3 * level});
  };
  gems.toxin = function(level) {
    var buffs = (level >= 25 ? {dmgtaken: 10} : undefined);
    function onrefresh(data, newdata) {
      data.targets = Math.max(data.targets, newdata.targets);
    }
    function ontick(data) {
      Sim.damage({targets: data.targets, elem: "psn", coeff: (20 + level * 0.5) / 40});
    }
    Sim.register("onhit", function(data) {
      Sim.addBuff("toxin", buffs, {
        duration: 600,
        data: {targets: Math.min(Sim.target.count, data.targets)},
        tickrate: 15,
        ontick: ontick,
        onrefresh: onrefresh,
      });
    });
  };
  gems.gogok = function(level) {
    var buffs = (level >= 25 ? {ias: 1, cdr: 1} : {ias: 1});
    Sim.register("onhit_proc", function(data) {
      var stacks = Sim.random("gogok", data.proc * (0.5 + 0.01 * level), data.targets, true);
      if (stacks) {
        Sim.addBuff("gogok", buffs, {duration: 240, maxstacks: 15, stacks: stacks});
      }
    });
  };
  gems.mirinae = function(level) {
    var coeff = 20 + 0.4 * level;
    Sim.register("onhit_proc", function(data) {
      Sim.damage({count: data.targets * data.proc * 0.15, elem: "hol", coeff: coeff});
    });
    if (level >= 25) {
      Sim.after(300, function ontick() {
        Sim.damage({elem: "hol", coeff: coeff});
        Sim.after(300, ontick);
      });
    }
  };
  gems.pain = function(level) {
    var coeff = (12 + 0.3 * level) / 12;
    var buffs = undefined;
    if (level >= 25 && Sim.target.distance - Sim.target.size < 20) {
      buffs = {ias: 3};
    }
    function ontick(data) {
      Sim.damage({elem: "phy", coeff: coeff});
    }
    Sim.register("onhit", function(data) {
      var stacks = Sim.random("pain", data.chc, data.targets, true);
      Sim.addBuff("pain", buffs, {
        duration: 180,
        refresh: false,
        maxstacks: Sim.target.count,
        stacks: stacks,
        tickrate: 15,
        tickkeep: true,
        ontick: ontick,
      });
    });
  };
  gems.simplicity = function(level) {
    var stats = {};
    for (var id in Sim.skills) {
      var skill = Sim.skills[id];
      if (Sim.skills[id].signature) {
        stats["skill_" + Sim.stats.charClass + "_" + id] = 25 + 0.5 * level;
      }
    }
    Sim.addBaseStats(stats);
  };
  gems.taeguk = function(level) {
    var buffs = (level >= 25 ? {damage: 0.5, armor_percent: 0.5} : {damage: 0.5});
    Sim.register("oncast", function(data) {
      if (data.cost) {
        Sim.addBuff("taeguk", buffs, {maxstacks: 20 + level, duration: 180});
      }
    });
  };
  gems.wreath = function(level) {
    var coeff = (6 + 0.1 * level) / 5;
    function ontick(data) {
      Sim.damage({targets: 2, elem: "lit", coeff: coeff});
    }
    Sim.register("onhit_proc", function(data) {
      if (Sim.random("wreath", data.proc * 0.15, data.targets)) {
        Sim.addBuff("wreath", undefined, {
          duration: 180,
          tickrate: 12,
          ontick: ontick,
        });
      }
    });
  };
  gems.iceblink = function(level) {
    Sim.register("onhit", function(data) {
      if (data.elem === "col") {
        Sim.addBuff("chilled", undefined, {duration: 180});
      }
    });
    if (level >= 25) {
      Sim.register("updatestats", function(data) {
        if (data.stats.chilled) {
          data.stats.add("chctaken", 10);
        }
      });
    }
  };
  gems.stricken = function(level) {
    var next = 0;
    var counter = 0;
    Sim.register("onhit_proc", function(data) {
      if (Sim.time >= next) {
        if (--counter < 0) {
          Sim.addBuff("stricken", {dmgmul: 0.8 + level * 0.01}, {
            maxstacks: 9999,
          });
          counter = Sim.target.count - 1;
        }
        var aps = (data.castInfo && data.castInfo.speed || 1);
        next = Sim.time + Math.floor(54 / aps);
      }
    });
    if (level >= 25) {
      Sim.addBaseStats({bossdmg: 25});
    }
  };
  gems.boyarsky = function(level) {
    Sim.addBaseStats({thorns: 16000 + 800 * level});
  };

  affixes.leg_wandofwoh = function() {
    function docast(data) {
      Sim.cast("explosiveblast", data.rune);
    }
    Sim.register("oncast", function(data) {
      if (data.skill === "explosiveblast") {
        Sim.after(30, docast, {rune: data.rune});
        Sim.after(60, docast, {rune: data.rune});
        Sim.after(90, docast, {rune: data.rune});
      }
    });
  };

  affixes.leg_thefurnace = function(amount) {
    Sim.addBaseStats({edmg: amount});
  };
  affixes.leg_triumvirate = affixes.leg_triumvirate_p2 = function(amount) {
    Sim.register("oncast", function(data) {
      if (Sim.skills[data.skill] && Sim.skills[data.skill].signature) {
        Sim.addBuff("triumvirate", {dmgmul: {skills: ["arcaneorb"], percent: amount}}, {maxstacks: 3, duration: 360});
      }
    });
  };
  affixes.leg_stormcrow = function(amount) {
    var prev;
    Sim.register("onhit_proc", function(data) {
      if ((prev === undefined || Sim.time - prev > 240) && Sim.random("stormcrow", 0.01 * amount, data.targets)) {
        Sim.damage({type: "line", elem: "fir", coeff: 1.15, speed: 0.75, area: 10});
        prev = Sim.time;
      }
    });
  };

  affixes.leg_shimizushaori = function(amount) {
    if (Sim.params.leg_shimizushaori && Sim.params.leg_shimizushaori[0]) {
      Sim.addBaseStats({extrachc: 100});
    }
  };
  affixes.leg_ingeom = function(amount) {
    if (Sim.params.leg_ingeom && Sim.params.leg_ingeom[0]) {
      Sim.addBaseStats({cdrint: amount});
    }
  };
  affixes.leg_eunjangdo = function(amount) {
    Sim.register("onhit_proc", function(data) {
      if (Sim.targetHealth < 0.01 * amount) {
        Sim.addBuff("frozen", undefined, 180);
      }
    });
  };
  affixes.leg_frostburn = function(amount) {
    Sim.register("onhit_proc", function(data) {
      if (data.elem === "col" && Sim.random("frostburn", 0.01 * amount * data.proc, data.targets / Sim.target.count)) {
        Sim.addBuff("frozen", undefined, 36);
      }
    });
  };
  affixes.leg_conventionofelements = function(amount) {
    var rot = {
      wizard: ["arc", "col", "fir", "lit"],
      demonhunter: ["col", "fir", "lit", "phy"],
      witchdoctor: ["col", "fir", "phy", "psn"],
      monk: ["col", "fir", "hol", "lit", "phy"],
      barbarian: ["col", "fir", "lit", "phy"],
      crusader: ["fir", "hol", "lit", "phy"],
    }[Sim.stats.charClass];
    var current = 0;
    (function refresh() {
      var elem = rot[current++];
      if (current >= rot.length) current = 0;
      Sim.addBuff("coe_" + elem, {dmgmul: {elems: [elem], percent: amount}}, {duration: 240, onexpire: refresh});
    })();
  };
  affixes.leg_obsidianringofthezodiac = function() {
    var rot = [];
    for (var id in Sim.stats.skills) rot.push(id);
    var current = 0;
    Sim.register("onhit", function(data) {
      if (data.castInfo && data.castInfo.cost && !data.castInfo.pet &&
          data.castInfo.user && !data.castInfo.user.zodiac) {
        data.castInfo.user.zodiac = true;
        for (var iter = 0; iter < 6; ++iter) {
          var cur = rot[current];
          current = (current + 1) % rot.length;
          if (Sim.getCooldown(cur) >= 60) {
            Sim.reduceCooldown(cur, 60);
            break;
          }
        }
      }
    });
  };
  affixes.leg_wyrdward = affixes.leg_wyrdward_p2 = function(amount) {
    Sim.register("onhit_proc", function(data) {
      if (data.elem === "lit" && Sim.random("wyrdward", 0.01 * amount * data.proc, data.targets / Sim.target.count)) {
        Sim.addBuff("stunned", undefined, 90);
      }
    });
  };
  affixes.leg_overwhelmingdesire = function(amount) {
    Sim.register("onhit_proc", function(data) {
      if (Sim.random("overwhelmingdesire", 0.05 * data.proc, data.targets / Sim.target.count)) {
        Sim.addBuff("overwhelmingdesire", {dmgtaken: 35}, {duration: 180, status: "charmed"});
      }
    });
  };
  affixes.leg_pridesfall = function(amount) {
    Sim.addBaseStats({rcr: 30});
  };
  affixes.leg_hexingpantsofmryan = function(amount) {
    if (Sim.params.leg_hexingpantsofmryan && Sim.params.leg_hexingpantsofmryan[0]) {
      Sim.addBaseStats({damage: 25, resourcegen: 25});
    } else {
      Sim.addBaseStats({damage: -amount, resourcegen: -amount});
    }
  };
  affixes.leg_bloodbrother = function(amount) {
    Sim.addBaseStats({block: amount});
  };
  affixes.leg_andarielsvisage = affixes.leg_andarielsvisage_p2 = function(amount) {
    var next = 0;
    Sim.register("onhit_proc", function(data) {
      if (next <= data.time) {
        Sim.damage({type: "area", range: 10, self: true, elem: "psn", coeff: 0.01 * amount});
        next = data.time + Math.floor(54 / Sim.stats.info.aps);
      }
    });
  };
  affixes.leg_bandofhollowwhispers = function(amount) {
    Sim.addBuff("bandofhollowwhispers", undefined, {
      tickrate: 90,
      ontick: function(data) {
        Sim.damage({elem: "arc", coeff: 1.5 * Sim.stats.info.aps});
      },
    });
  };
  affixes.leg_bulkathossweddingband = function(amount) {
    Sim.addBuff(undefined, undefined, {
      tickrate: 12,
      ontick: function(data) {
        Sim.damage({type: "area", range: 8, self: true, elem: "phy", coeff: 4});
      },
    });
  };
  affixes.leg_hellfirering = function(amount) {
    var next = 0;
    Sim.register("onhit_proc", function(data) {
      if (next <= Sim.time && Sim.random("hellfirering", 0.5 * data.proc, data.targets)) {
        Sim.addBuff("hellfirering", undefined, {
          duration: 360,
          tickrate: 30,
          ontick: function(data) {
            Sim.damage({type: "area", range: 16, elem: "fir", coeff: 1});
          },
        });
        next = Sim.time + 2700;
      }
    });
  };
  affixes.leg_nagelring = function(amount) {
    Sim.addBuff(undefined, undefined, {
      tickrate: amount * 60,
      ontick: function(data) {
        Sim.damage({type: "area", range: 10, type: "phy", coeff: 100});
      },
    });
  };
  affixes.leg_firewalkers = affixes.leg_firewalkers_p2 = function(amount) {
    amount = Math.max(amount, 100);
    Sim.addBuff(undefined, undefined, {
      tickrate: 18,
      ontick: function(data) {
        Sim.damage({type: "area", range: 5, type: "fir", coeff: amount * 0.003});
      },
    });
  };
  affixes.leg_poxfaulds = affixes.leg_poxfaulds_p2 = function(amount) {
    var delay = (this == "leg_poxfaulds" ? 900 : 300);
    var duration = (this == "leg_poxfaulds" ? 600 : 300);
    (function trigger() {
      if (Sim.getTargets(12, Sim.target.distance) >= 3) {
        Sim.addBuff("poxfaulds", undefined, {
          duration: duration,
          tickdelay: 30,
          ontick: function() {
            Sim.damage({type: "area", range: 15, elem: "psn", coeff: amount * 0.005});
          },
        });
      }
      Sim.after(delay, trigger);
    })();
  };
  affixes.leg_moonlightward = function(amount) {
    Sim.register("onhit_proc", function(data) {
      if (Sim.random("moonlightward", data.proc, data.targets)) {
        Sim.addBuff("moonlightward", undefined, {
          duration: 7200,
          maxstacks: 4,
          tickrate: 30,
          ontick: function() {
            if (Sim.getTargets(15, Sim.target.distance) >= 0.5) {
              Sim.damage({type: "area", range: 15, self: true, elem: "arc", coeff: amount * 0.01});
              Sim.removeBuff("moonlightward", 1);
            }
          },
        });
      }
    });
  };
  affixes.leg_scourge = function(amount) {
    var next = 0;
    Sim.register("oncast", function(data) {
      if (Sim.time >= next && data.offensive && Sim.random("scourge", amount * 0.01)) {
        Sim.damage({type: "area", range: 13, self: true, elem: "fir", coeff: 19});
        next = Sim.time + 150;
      }
    });
  };
  affixes.leg_stalgardsdecimator = function(amount) {
    var next = 0;
    Sim.register("oncast", function(data) {
      if (Sim.time >= next && data.melee) {
        Sim.damage({type: "line", pierce: true, speed: 1, elem: "phy", coeff: amount * 0.01});
        next = Sim.time + Math.floor(54 / Sim.stats.info.aps);
      }
    });
  };
  affixes.leg_schaefershammer_p2 = function(amount) {
    Sim.register("oncast", function(data) {
      if (data.elem === "lit") {
        Sim.addBuff("schaefershammer", undefined, {
          duration: 300,
          tickrate: 60,
          ontick: function(data) {
            Sim.damage({type: "area", range: 20, self: true, elem: "lit", coeff: amount * 0.01});
          },<commit_msg>Sash of Knives affix proc<commit_after>(function() {
  var Sim = Simulator;
  var affixes = Sim.affixes;
  var gems = Sim.gems;

  Sim.register("init", function() {
    var fx = {
      hitfear: {status: "feared", duration: 180},
      hitstun: {status: "stunned", duration: 180},
      hitblind: {status: "blinded", duration: 180},
      hitfreeze: {status: "frozen", duration: 180},
      hitchill: {status: "chilled", duration: 180},
      hitslow: {status: "slowed", duration: 180},
      hitimmobilize: {status: "rooted", duration: 180},
      hitknockback: {status: "knockback", duration: 30},
    };
    for (var id in fx) {
      if (this.stats[id]) {
        Sim.pushCastInfo({triggered: id});
        this.register("onhit_proc", (function(id, fx) {
          return function(data) {
            if (Sim.random(id, 0.01 * Sim.stats[id] * data.proc, data.targets / Sim.target.count)) {
              Sim.addBuff(fx.status, undefined, fx.duration);
            }
          };
        })(id, fx[id]));
        Sim.popCastInfo();
      }
    }
    if (this.stats.bleed) {
      Sim.pushCastInfo({triggered: "bleed"});
      this.register("onhit_proc", function(data) {
        if (Sim.random("bleed", 0.01 * Sim.stats.bleed.chance * data.proc, data.targets / Sim.target.count)) {
          Sim.addBuff("bleed", undefined, {duration: 300, tickrate: 15, data: {amount: Sim.stats.bleed.amount}, ontick: function(data) {
            Sim.damage({elem: "phy", targets: Sim.target.count, coeff: data.amount * 0.01 / 20, orphan: true});
          }});
        }
      });
      Sim.popCastInfo();
    }
  });

  gems.powerful = function(level) {
    if (level >= 25) Sim.addBaseStats({edmg: 15});
    if (Sim.params.powerful && Sim.params.powerful[0]) {
      Sim.addBuff("powerful", {damage: 20});
    }
  };
  gems.trapped = function(level) {
    if (level >= 25 && Sim.target.distance - Sim.target.size < 15) {
      Sim.addBuff("slowed");
    }
    Sim.register("updatestats", function(data) {
      if (data.stats.chilled || data.stats.frozen ||
          data.stats.blinded || data.stats.stunned ||
          data.stats.slowed || data.stats.knockback ||
          data.stats.charmed || data.stats.feared || data.stats.rooted) {
        data.stats.add("dmgmul", 15 + 0.3 * level);
      }
    });
  };
  gems.enforcer = function(level) {
    Sim.addBaseStats({petdamage: 15 + 0.3 * level});
  };
  gems.toxin = function(level) {
    var buffs = (level >= 25 ? {dmgtaken: 10} : undefined);
    function onrefresh(data, newdata) {
      data.targets = Math.max(data.targets, newdata.targets);
    }
    function ontick(data) {
      Sim.damage({targets: data.targets, elem: "psn", coeff: (20 + level * 0.5) / 40});
    }
    Sim.register("onhit", function(data) {
      Sim.addBuff("toxin", buffs, {
        duration: 600,
        data: {targets: Math.min(Sim.target.count, data.targets)},
        tickrate: 15,
        ontick: ontick,
        onrefresh: onrefresh,
      });
    });
  };
  gems.gogok = function(level) {
    var buffs = (level >= 25 ? {ias: 1, cdr: 1} : {ias: 1});
    Sim.register("onhit_proc", function(data) {
      var stacks = Sim.random("gogok", data.proc * (0.5 + 0.01 * level), data.targets, true);
      if (stacks) {
        Sim.addBuff("gogok", buffs, {duration: 240, maxstacks: 15, stacks: stacks});
      }
    });
  };
  gems.mirinae = function(level) {
    var coeff = 20 + 0.4 * level;
    Sim.register("onhit_proc", function(data) {
      Sim.damage({count: data.targets * data.proc * 0.15, elem: "hol", coeff: coeff});
    });
    if (level >= 25) {
      Sim.after(300, function ontick() {
        Sim.damage({elem: "hol", coeff: coeff});
        Sim.after(300, ontick);
      });
    }
  };
  gems.pain = function(level) {
    var coeff = (12 + 0.3 * level) / 12;
    var buffs = undefined;
    if (level >= 25 && Sim.target.distance - Sim.target.size < 20) {
      buffs = {ias: 3};
    }
    function ontick(data) {
      Sim.damage({elem: "phy", coeff: coeff});
    }
    Sim.register("onhit", function(data) {
      var stacks = Sim.random("pain", data.chc, data.targets, true);
      Sim.addBuff("pain", buffs, {
        duration: 180,
        refresh: false,
        maxstacks: Sim.target.count,
        stacks: stacks,
        tickrate: 15,
        tickkeep: true,
        ontick: ontick,
      });
    });
  };
  gems.simplicity = function(level) {
    var stats = {};
    for (var id in Sim.skills) {
      var skill = Sim.skills[id];
      if (Sim.skills[id].signature) {
        stats["skill_" + Sim.stats.charClass + "_" + id] = 25 + 0.5 * level;
      }
    }
    Sim.addBaseStats(stats);
  };
  gems.taeguk = function(level) {
    var buffs = (level >= 25 ? {damage: 0.5, armor_percent: 0.5} : {damage: 0.5});
    Sim.register("oncast", function(data) {
      if (data.cost) {
        Sim.addBuff("taeguk", buffs, {maxstacks: 20 + level, duration: 180});
      }
    });
  };
  gems.wreath = function(level) {
    var coeff = (6 + 0.1 * level) / 5;
    function ontick(data) {
      Sim.damage({targets: 2, elem: "lit", coeff: coeff});
    }
    Sim.register("onhit_proc", function(data) {
      if (Sim.random("wreath", data.proc * 0.15, data.targets)) {
        Sim.addBuff("wreath", undefined, {
          duration: 180,
          tickrate: 12,
          ontick: ontick,
        });
      }
    });
  };
  gems.iceblink = function(level) {
    Sim.register("onhit", function(data) {
      if (data.elem === "col") {
        Sim.addBuff("chilled", undefined, {duration: 180});
      }
    });
    if (level >= 25) {
      Sim.register("updatestats", function(data) {
        if (data.stats.chilled) {
          data.stats.add("chctaken", 10);
        }
      });
    }
  };
  gems.stricken = function(level) {
    var next = 0;
    var counter = 0;
    Sim.register("onhit_proc", function(data) {
      if (Sim.time >= next) {
        if (--counter < 0) {
          Sim.addBuff("stricken", {dmgmul: 0.8 + level * 0.01}, {
            maxstacks: 9999,
          });
          counter = Sim.target.count - 1;
        }
        var aps = (data.castInfo && data.castInfo.speed || 1);
        next = Sim.time + Math.floor(54 / aps);
      }
    });
    if (level >= 25) {
      Sim.addBaseStats({bossdmg: 25});
    }
  };
  gems.boyarsky = function(level) {
    Sim.addBaseStats({thorns: 16000 + 800 * level});
  };

  affixes.leg_wandofwoh = function() {
    function docast(data) {
      Sim.cast("explosiveblast", data.rune);
    }
    Sim.register("oncast", function(data) {
      if (data.skill === "explosiveblast") {
        Sim.after(30, docast, {rune: data.rune});
        Sim.after(60, docast, {rune: data.rune});
        Sim.after(90, docast, {rune: data.rune});
      }
    });
  };

  affixes.leg_thefurnace = function(amount) {
    Sim.addBaseStats({edmg: amount});
  };
  affixes.leg_triumvirate = affixes.leg_triumvirate_p2 = function(amount) {
    Sim.register("oncast", function(data) {
      if (Sim.skills[data.skill] && Sim.skills[data.skill].signature) {
        Sim.addBuff("triumvirate", {dmgmul: {skills: ["arcaneorb"], percent: amount}}, {maxstacks: 3, duration: 360});
      }
    });
  };
  affixes.leg_stormcrow = function(amount) {
    var prev;
    Sim.register("onhit_proc", function(data) {
      if ((prev === undefined || Sim.time - prev > 240) && Sim.random("stormcrow", 0.01 * amount, data.targets)) {
        Sim.damage({type: "line", elem: "fir", coeff: 1.15, speed: 0.75, area: 10});
        prev = Sim.time;
      }
    });
  };

  affixes.leg_shimizushaori = function(amount) {
    if (Sim.params.leg_shimizushaori && Sim.params.leg_shimizushaori[0]) {
      Sim.addBaseStats({extrachc: 100});
    }
  };
  affixes.leg_ingeom = function(amount) {
    if (Sim.params.leg_ingeom && Sim.params.leg_ingeom[0]) {
      Sim.addBaseStats({cdrint: amount});
    }
  };
  affixes.leg_eunjangdo = function(amount) {
    Sim.register("onhit_proc", function(data) {
      if (Sim.targetHealth < 0.01 * amount) {
        Sim.addBuff("frozen", undefined, 180);
      }
    });
  };
  affixes.leg_frostburn = function(amount) {
    Sim.register("onhit_proc", function(data) {
      if (data.elem === "col" && Sim.random("frostburn", 0.01 * amount * data.proc, data.targets / Sim.target.count)) {
        Sim.addBuff("frozen", undefined, 36);
      }
    });
  };
  affixes.leg_conventionofelements = function(amount) {
    var rot = {
      wizard: ["arc", "col", "fir", "lit"],
      demonhunter: ["col", "fir", "lit", "phy"],
      witchdoctor: ["col", "fir", "phy", "psn"],
      monk: ["col", "fir", "hol", "lit", "phy"],
      barbarian: ["col", "fir", "lit", "phy"],
      crusader: ["fir", "hol", "lit", "phy"],
    }[Sim.stats.charClass];
    var current = 0;
    (function refresh() {
      var elem = rot[current++];
      if (current >= rot.length) current = 0;
      Sim.addBuff("coe_" + elem, {dmgmul: {elems: [elem], percent: amount}}, {duration: 240, onexpire: refresh});
    })();
  };
  affixes.leg_obsidianringofthezodiac = function() {
    var rot = [];
    for (var id in Sim.stats.skills) rot.push(id);
    var current = 0;
    Sim.register("onhit", function(data) {
      if (data.castInfo && data.castInfo.cost && !data.castInfo.pet &&
          data.castInfo.user && !data.castInfo.user.zodiac) {
        data.castInfo.user.zodiac = true;
        for (var iter = 0; iter < 6; ++iter) {
          var cur = rot[current];
          current = (current + 1) % rot.length;
          if (Sim.getCooldown(cur) >= 60) {
            Sim.reduceCooldown(cur, 60);
            break;
          }
        }
      }
    });
  };
  affixes.leg_wyrdward = affixes.leg_wyrdward_p2 = function(amount) {
    Sim.register("onhit_proc", function(data) {
      if (data.elem === "lit" && Sim.random("wyrdward", 0.01 * amount * data.proc, data.targets / Sim.target.count)) {
        Sim.addBuff("stunned", undefined, 90);
      }
    });
  };
  affixes.leg_overwhelmingdesire = function(amount) {
    Sim.register("onhit_proc", function(data) {
      if (Sim.random("overwhelmingdesire", 0.05 * data.proc, data.targets / Sim.target.count)) {
        Sim.addBuff("overwhelmingdesire", {dmgtaken: 35}, {duration: 180, status: "charmed"});
      }
    });
  };
  affixes.leg_pridesfall = function(amount) {
    Sim.addBaseStats({rcr: 30});
  };
  affixes.leg_hexingpantsofmryan = function(amount) {
    if (Sim.params.leg_hexingpantsofmryan && Sim.params.leg_hexingpantsofmryan[0]) {
      Sim.addBaseStats({damage: 25, resourcegen: 25});
    } else {
      Sim.addBaseStats({damage: -amount, resourcegen: -amount});
    }
  };
  affixes.leg_bloodbrother = function(amount) {
    Sim.addBaseStats({block: amount});
  };
  affixes.leg_andarielsvisage = affixes.leg_andarielsvisage_p2 = function(amount) {
    var next = 0;
    Sim.register("onhit_proc", function(data) {
      if (next <= data.time) {
        Sim.damage({type: "area", range: 10, self: true, elem: "psn", coeff: 0.01 * amount});
        next = data.time + Math.floor(54 / Sim.stats.info.aps);
      }
    });
  };
  affixes.leg_bandofhollowwhispers = function(amount) {
    Sim.addBuff("bandofhollowwhispers", undefined, {
      tickrate: 90,
      ontick: function(data) {
        Sim.damage({elem: "arc", coeff: 1.5 * Sim.stats.info.aps});
      },
    });
  };
  affixes.leg_bulkathossweddingband = function(amount) {
    Sim.addBuff(undefined, undefined, {
      tickrate: 12,
      ontick: function(data) {
        Sim.damage({type: "area", range: 8, self: true, elem: "phy", coeff: 4});
      },
    });
  };
  affixes.leg_hellfirering = function(amount) {
    var next = 0;
    Sim.register("onhit_proc", function(data) {
      if (next <= Sim.time && Sim.random("hellfirering", 0.5 * data.proc, data.targets)) {
        Sim.addBuff("hellfirering", undefined, {
          duration: 360,
          tickrate: 30,
          ontick: function(data) {
            Sim.damage({type: "area", range: 16, elem: "fir", coeff: 1});
          },
        });
        next = Sim.time + 2700;
      }
    });
  };
  affixes.leg_nagelring = function(amount) {
    Sim.addBuff(undefined, undefined, {
      tickrate: amount * 60,
      ontick: function(data) {
        Sim.damage({type: "area", range: 10, type: "phy", coeff: 100});
      },
    });
  };
  affixes.leg_firewalkers = affixes.leg_firewalkers_p2 = function(amount) {
    amount = Math.max(amount, 100);
    Sim.addBuff(undefined, undefined, {
      tickrate: 18,
      ontick: function(data) {
        Sim.damage({type: "area", range: 5, type: "fir", coeff: amount * 0.003});
      },
    });
  };
  affixes.leg_poxfaulds = affixes.leg_poxfaulds_p2 = function(amount) {
    var delay = (this == "leg_poxfaulds" ? 900 : 300);
    var duration = (this == "leg_poxfaulds" ? 600 : 300);
    (function trigger() {
      if (Sim.getTargets(12, Sim.target.distance) >= 3) {
        Sim.addBuff("poxfaulds", undefined, {
          duration: duration,
          tickdelay: 30,
          ontick: function() {
            Sim.damage({type: "area", range: 15, elem: "psn", coeff: amount * 0.005});
          },
        });
      }
      Sim.after(delay, trigger);
    })();
  };
  affixes.leg_moonlightward = function(amount) {
    Sim.register("onhit_proc", function(data) {
      if (Sim.random("moonlightward", data.proc, data.targets)) {
        Sim.addBuff("moonlightward", undefined, {
          duration: 7200,
          maxstacks: 4,
          tickrate: 30,
          ontick: function() {
            if (Sim.getTargets(15, Sim.target.distance) >= 0.5) {
              Sim.damage({type: "area", range: 15, self: true, elem: "arc", coeff: amount * 0.01});
              Sim.removeBuff("moonlightward", 1);
            }
          },
        });
      }
    });
  };
  affixes.leg_sashofknives_p2 = function(amount) {
    var next = 0;
    Sim.register("onhit_proc", function(data) {
      if (Sim.time >= next) {
        Sim.damage({range: 50, self: true, elem: "phy", coeff: 0.01 * amount});
        next = Sim.time + Math.floor(54 / Sim.stats.info.aps);
      }
    });
  };
  affixes.leg_scourge = function(amount) {
    var next = 0;
    Sim.register("oncast", function(data) {
      if (Sim.time >= next && data.offensive && Sim.random("scourge", amount * 0.01)) {
        Sim.damage({type: "area", range: 13, self: true, elem: "fir", coeff: 19});
        next = Sim.time + 150;
      }
    });
  };
  affixes.leg_stalgardsdecimator = function(amount) {
    var next = 0;
    Sim.register("oncast", function(data) {
      if (Sim.time >= next && data.melee) {
        Sim.damage({type: "line", pierce: true, speed: 1, elem: "phy", coeff: amount * 0.01});
        next = Sim.time + Math.floor(54 / Sim.stats.info.aps);
      }
    });
  };
  affixes.leg_schaefershammer_p2 = function(amount) {
    Sim.register("oncast", function(data) {
      if (data.elem === "lit") {
        Sim.addBuff("schaefershammer", undefined, {
          duration: 300,
          tickrate: 60,
          ontick: function(data) {
            Sim.damage({type: "area", range: 20, self: true, elem: "lit", coeff: amount * 0.01});
          },
{'fraction_non_alphanumeric': 0.17511289513296538, 'fraction_numerical': 0.025656464291687574, 'mean_word_length': 2.4706292082656143, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 38, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2850007', 'n_tokens_mistral': 11291, 'n_tokens_neox': 10553, 'n_words': 2047}