<abilities>
  <ability>
    <clone>tumbling</clone>
    <key>tumbling_2</key>
    <description>
      Whenever an enemy would hit you with a melee attack, you have a 15% chance to roll aside and avoid the
      attack, plus 0.5% per Athletics level.
      [p]Costs ⮃1.5⮃ energy per turn and ⮃4 energy per roll⮃.
      [p]Each successful roll increases roll chance by 2% and adds 1 energy cost. Resets when toggled off.
    </description>
    <cost>1.5</cost>
    <toggleInfo>
      <xpGain>
        <skill>athletics</skill>
        <displayAmount>{xp} xp on tumble</displayAmount>
        <amount>0.0</amount>
        <amountToDisplay>5.0</amountToDisplay>
      </xpGain>
      <description>
        Consume {{global_flag -> key:tumbling_energy_cost}} energy on roll.
      </description>
      <modifiers>
        <modifiers>
          <type>EscapeAttackChance</type>
          <amount>0.15</amount>
        </modifiers>
        <modifiers>
          <type>EscapeAttackChance</type>
          <amount>0.0</amount>
          <modifierConversion>
            <type>Flag</type>
            <flag>tumbling_roll_bonus</flag>
            <multiplier>0.02</multiplier>
          </modifierConversion>
        </modifiers>
        <modifiers>
          <type>EscapeAttackChance</type>
          <amount>0.005</amount>
          <multiplier>Athletics</multiplier>
        </modifiers>
      </modifiers>
      <triggers>
        <triggers>
          KEY tumbling_trigger;
          WHEN PlayerEscapeAttacks;
          THEN RewardExperience -> skill:athletics, xp:5, reason:Tumbling;
          THEN GiveEnergy -> amount:-{{G:tumbling_energy_cost}}, target:player;
          THEN ModifyGlobalFlag -> global_flag:tumbling_energy_cost, operation:add, amount:1;
          THEN ModifyGlobalFlag -> global_flag:tumbling_roll_bonus, operation:add, amount:1;
        </triggers>
      </triggers>
      <onEffects>
        <onEffects>
          ModifyGlobalFlag -> global_flag:tumbling_energy_cost, operation:set, amount:4;
          ModifyGlobalFlag -> global_flag:tumbling_roll_bonus, operation:set, amount:0;
        </onEffects>
      </onEffects>
    </toggleInfo>
    <unlockInfo>
      <autoUnlock>-1</autoUnlock>
      <autoDiscover>0</autoDiscover>
      <unlockRequirements>
        <requiredPoints>1</requiredPoints>
      </unlockRequirements>
      <replaces>tumbling</replaces>
    </unlockInfo>
  </ability>
</abilities>
