Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Macro with even or odd or with the r (rest?) from a Division maybe...

Well, I'm no expert in mathematics and got stuck at this point the macro I am creating, maybe there's a simpler solution that also can not think. My problem: The Ten Dice Rule bonus (from L5R or 7th Sea) "No roll can ever use more than ten dice at a time. Additional rolled dice become kept dice at a ratio of one kept die per two additional rolled dice. If both rolled and kept dice already equal ten, then each additional die of both types converts to a bonus of +2 to the total of the roll. EXAMPLE: * A roll of 12k4 would become 10k5, because the two extra rolled dice that exceed the Ten Dice Rule become one extra kept die. * A roll of 13k9 would become 10k10 + 2, because the two extra rolled dice that exceed the Ten Dice Rule become one extra kept die, and the additional odd rolled die becomes a bonus of +2. * A roll of 10k12 would become 10k10 + 4, with each of the extra kept dice above the Ten Dice Rule becoming a bonus of +2. * A roll of 14k12 would become 10k10 +12. Since both rolled and kept dice exceed ten, the four additional rolled dice become a bonus of +8, and the two additional kept dice become a bonus of +4, for a total of +12." Part of the dice rolled that turn into kept dice is solved. My difficulty is added the bonus values. Now follows what I thought solution but I could not perform through my math limitation. X is the Roll X - 10 = even number, I need to result in 0. X - 10 = odd number, I need to result in 1. Both 0 and 1 It will be multiplied by 2 and will have the bonus from the Roll. The Roll bonus is add to the Kept bonus: Using my current roll formula, which turns 2 dices rolling on 1 kept, but without the "2 to 1", without transferring dividing. Example: 12k10 --> 10k12 So... I Subtract the kept by 10 and multiply the result by 2 getting the bonus from the Kept. Well, thats it. I cannot solve the part of getting 1 or 0. Hope someone can help me. I've been trying really hard to solve all system roll. Sorry the bad english, talk about mathematics in another language is not easy. Thank you!
1437719271
Lithl
Pro
Sheet Author
API Scripter
Assuming attribute names @{pool} and @{keep} (I'm not certain what the L5R sheet uses), this ought to work: [[[[{@{pool}, 10}kl1]]d10k[[{@{keep} + [[floor({@{pool} - 10, 0}k1 / 2)]], 10}kl1]] + [[[[{@{keep} + [[floor({@{pool} - 10, 0}k1 / 2) + ceil({@{pool} - 10, 0}k1 / 2) * floor(@{keep} / 10)]] - 10, 0}k1 * 2]] + [[@{pool} % 2 * (1 - floor(@{keep} / 10)) * 2]]]]]] It's got nested inline rolls a couple levels deep for both functionality and presentation. When you hover over the roll, you'll see 10d10k10+12 or whatever, rather than complicated formulas. Breaking it down, that's @{pool} dice, to a maximum of 10. Keep @{keep} dice, plus the number of @{pool} dice over 10 divided by 2 rounded down. Add [@{keep} plus half (round down) @{pool} in excess of 10 plus (if @{keep} is greater than 10) half (round up) @{pool} in excess of 10] in excess of 10, multiplied by 2. If @{keep} is less than 10 and @{pool} is odd, add 2. There might be edge cases, but the above roll passes your example tests, and a couple others I used based on my (admittedly limited) understanding of the system.
WOW! Pretty nice solution, the pool are the sum of 2 attributes, i put the sum and i think thats working great. :D smaller and more complete than the solution I could, like i show u before... without bonus lol Ex: [[[[floor(@{Awareness} + @{rank_Sincerity} - @{Fear} - ((@{Awareness} + @{rank_Sincerity} - @{Fear} -11) + abs(@{Awareness} + @{rank_Sincerity} - @{Fear} -10))/2))]]d10!!kh[[round((@{Awareness} + ((@{Awareness} + @{rank_Sincerity} - @{Fear} -11) + abs(@{Awareness} + @{rank_Sincerity} - @{Fear} -11))/2/2))]]]] | [[[[floor(@{Awareness} + @{rank_Sincerity} + @{VP} - @{Fear} - ((@{Awareness} + @{rank_Sincerity} + @{VP} - @{Fear} -11) + abs(@{Awareness} + @{rank_Sincerity} + @{VP} - @{Fear} -10))/2))]]d10!!kh[[round((@{Awareness} + @{VP} + ((@{Awareness} + @{rank_Sincerity} + @{VP} - @{Fear} -11) + abs(@{Awareness} + @{rank_Sincerity} + @{VP} - @{Fear} -11))/2/2))]]]] I guess that putting the bonus (VP) and the penalty (Fear) in ur solution will works great too. Thanks again, u're a genious! o/
Hmmm with the penalty saw a problem.. always give me the +2 at the end when the roll is odd, even when the roll is less than 10 (even without the fear penalty). [[[[{((@{Willpower}+@{rank_etiquette}) - @{Fear}), 10}kl1]]d10k[[{@{Willpower} + [[floor({((@{Willpower}+@{rank_etiquette}) - @{Fear}) - 10, 0}k1 / 2)]], 10}kl1]] + [[[[{@{Willpower} + [[floor({((@{Willpower}+@{rank_etiquette}) - @{Fear}) - 10, 0}k1 / 2) + ceil({((@{Willpower}+@{rank_etiquette}) - @{Fear}) - 10, 0}k1 / 2) * floor(@{Willpower} / 10)]] - 10, 0}k1 * 2]] + [[((@{Willpower}+@{rank_etiquette}) - @{Fear}) % 2 * (1 - floor(@{Willpower} / 10)) * 2]]]]]] Willpower = 4 rank_etiquette = 3 Fear = 2 Rolling: 5k4 +2 Only with roll above 10 receiving the bonus. 11k4 = 10k4 +2 12k4 = 10k5 15k5 = 10k7 + 2 12k12 = 10k10 + 8 12k10 = 10k10 + 4
1437737771

Edited 1437793836
Lithl
Pro
Sheet Author
API Scripter
Changing: @{pool} % 2 * (1 - floor(@{keep} / 10)) * 2 To: @{pool} % 2 * (1 - floor(@{keep} / 10)) *  floor(@{pool} / 10) * 2 Should fix that problem. (Naturally replacing @{pool} and @{keep} with the appropriate attribute sums.)
Man... perfect! For now.. working great with the Fear Penalty and... VP bonus too! ;D Brilliant, thanks again! o/