Another bug... hitchance can go negative, which does bizarre things to some of the other calculations. I've replaced the following line:
Code:
return minmax((6.0 + attack - max(monster_stat("def"),0.0))/10.5,0.0,1.0) - fumble_chance(); // change minimum to critchance
with this:
Code:
return max(((9+numeric_modifier("Critical Hit Percent"))*(numeric_modifier("Critical")+1)/100), minmax((6.0 + attack - max(monster_stat("def"),0.0))/10.5,0.0,1.0) - fumble_chance()); // change minimum to critchance
Basically, take the higher of critchance or the actual calculation... I believe that the critchance is correct. It starts with a 9% chance + percentage modifiers, multiplied by 1+critical multipliers, divided by 100 to provide just a percentage chance.
Might be better to do that as a separate function though... critical_chance... Let me work that up.
Edit: Have these showing like this now:
> ash import <batbrain> hitchance(1)
Returned: 1.0
> ash import <batbrain> critical_chance()
Returned: 0.09
> ash import <batbrain> fumble_chance()
Returned: 0.045454547
This is just below fumbles, since I thought they were related... anything similar to Dr. Awkward's fumble code probably needs to be added. At the very least, Dr. Awkward probably forces critical chance to 0.
Code:
// ======= CRITICALS =======
float critical_chance() {
return (9+numeric_modifier("Critical Hit Percent"))*(numeric_modifier("Critical")+1)/100;
}
I've replaced the line above with this, which should hopefully be more accurate...
Code:
return minmax((6.0 + attack - max(monster_stat("def"),0.0))/10.5 + critical_chance() - fumble_chance(),0.0,1.0); // change minimum to critchance
After deciding if it will hit or miss with normal chances, add the chance of a critical hit, subtract fumbles... though this might be better?
Code:
return minmax((6.0 + attack - max(monster_stat("def"),0.0))/10.5 + critical_chance() - fumble_chance(),critical_chance(),1.0-fumble_chance()); // change minimum to critchance
Since your lowest chance to hit should be only getting criticals, and your highest chance to hit shouldn't be higher than your chance of fumbling...