Swamp Slogger
Posts: 139
Joined: Friday, 13th March 2015, 13:33
If it doesn't fit anywhere else, it belongs here. Also, come here if you just need to get hammered.
Swamp Slogger
Posts: 139
Joined: Friday, 13th March 2015, 13:33
Dungeon Master
Posts: 625
Joined: Thursday, 23rd October 2014, 03:08
Abyss Ambulator
Posts: 1193
Joined: Friday, 16th January 2015, 20:20
Ziggurat Zagger
Posts: 4432
Joined: Friday, 8th May 2015, 17:51
Abyss Ambulator
Posts: 1233
Joined: Wednesday, 23rd April 2014, 21:57
Ziggurat Zagger
Posts: 4432
Joined: Friday, 8th May 2015, 17:51
Abyss Ambulator
Posts: 1233
Joined: Wednesday, 23rd April 2014, 21:57
Ziggurat Zagger
Posts: 4432
Joined: Friday, 8th May 2015, 17:51
Abyss Ambulator
Posts: 1233
Joined: Wednesday, 23rd April 2014, 21:57
Ziggurat Zagger
Posts: 4432
Joined: Friday, 8th May 2015, 17:51
/**
* Compute success chance for MR-checking spells and abilities.
*
* @param mr The magic resistance of the target.
* @param powc The enchantment power.
* @param scale The denominator of the result.
* @param round_up Should the resulting chance be rounded up (true) or
* down (false, the default)?
*
* @return The chance, out of scale, that the enchantment affects the target.
*/
int hex_success_chance(const int mr, int powc, int scale, bool round_up)
{
const int pow = ench_power_stepdown(powc);
const int target = mr + 100 - pow;
const int denom = 101 * 100;
const int adjust = round_up ? denom - 1 : 0;
if (target <= 0)
return scale;
if (target > 200)
return 0;
if (target <= 100)
return (scale * (denom - _triangular_number(target)) + adjust) / denom;
return (scale * _triangular_number(201 - target) + adjust) / denom;
Abyss Ambulator
Posts: 1233
Joined: Wednesday, 23rd April 2014, 21:57
Dungeon Master
Posts: 502
Joined: Wednesday, 7th March 2012, 13:25
Location: Lexington, KY, US
Tartarus Sorceror
Posts: 1698
Joined: Saturday, 18th June 2016, 13:57
Ziggurat Zagger
Posts: 4432
Joined: Friday, 8th May 2015, 17:51
Blades Runner
Posts: 568
Joined: Wednesday, 5th March 2014, 03:52
Users browsing this forum: No registered users and 73 guests