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] Weapon Damage (Tricky Math)

1389039949
Tom
Plus
Sheet Author
Well, since the thread this question was originally posed in died in the frozen holiday born wilderness, I figure I might as well pose it again in its own thread. Hopefully someone here with better math and macro skills than myself can figure this one out. I expect it can be done, it's just a matter of posing the formula correctly. So here goes: I'm looking to create a macro for generating weapon damage. The idea is to compare the player's roll to the target's Armor score and give a "net" result. What would be ideal would be for the macro to return a flat "0 successes" figure (rather than –1, –2, etc) for any roll that doesn't best the target's armor. Likewise, a result of success=armor (0 net successes) should indicate 1 success. I expect it would look something like this: /roll ([[2+@{Strength}]]d10!10>7sd)-@{target|Armor} vs @{target|token_name}'s Armor for Damage Dealt I just have no idea where to drop that +1 (to boost "0 successes" to "1 success") or how to not return a negative result in the case of failure. The latter isn't THAT important to the function of the macro, it would just be a nice way to clean up the results. Thanks!
Can't make it work without multiple inlines or roll groups allowing mixed number types which isn't allowed.
Alright, closest thing I can appromixate with the limitations I'm working with. /roll {([[{2, @{selected|Strength}}]]d10!10>7sd-@{target|Armor})+0.1, 0d1>7sd}kh1 0 is a failure, 0.1 is a net of 0 successes, and you'll have to ignore the additional 0.1 on results of 1 success or better.
1389068893
Tom
Plus
Sheet Author
Whoa. Ok Brandon, can you break down that macro for me? I understand some of it, but I'm hoping you can give me an idea if how all the components work together.
{2, @{selected|Strength}} is a roll group that adds 2 and your Strength variable for the selected token. [[{2, @{selected|Strength}}]] turns it inline for use in further rolls. [[{2, @{selected|Strength}}]]d10!10>7sd gives you the number of successes rolled. ([[{2, @{selected|Strength}}]]d10!10>7sd -@{target|Armor})+0.1 gives us the final possible number of successes after subtracting the target's armor. Here we add 0.1 to make it noticable if the final result here is 0 successes, which should be known as a success. 0d1>7sd is a requirement to get 0 successes. We put those last two together into another roll group and keep the higher one. This we actually have to roll since we can't double inline this. /roll {([[{2, @{selected|Strength}}]]d10!10>7sd -@{target|Armor})+0.1, 01d>7sd}kh1
1389110719
Tom
Plus
Sheet Author
Hmmm...getting an error when I test this. Could there be a problem with the bracketing?
1389111709
GiGs
Pro
Sheet Author
API Scripter
Make sure you have a token selected that has a Strength value. It works for me. Though it seems to return 0.1 on rolls that are failures as well as successes. Test it with 0 armour.
Bah. Just redid and this one works. Doesn't LOOK any different... /roll {([[{2, @{selected|Strength}}]]d10!10>7sd -@{target|Armor})+0.1, 0d1>7sd}kh1 If this doesn't work, try /roll ([[{2, @{selected|Strength}}]]d10!10>7sd -@{target|Armor})+0.1 And see if that works for you. If it does, there's something wonky with copy/paste directly into the chat window. Try putting it in a macro.
G G, a result of 0 net successes is considered a glancing success, or 1 success anyways. It's only negative results that actually end up in a miss. Give yourself a big negative on strength and it'll come up 0.
1389112582
Tom
Plus
Sheet Author
G G, I did drop the selected and just made it {2, @{Strength}} but I wouldn't think that would break the macro.
If you put it in an ability it shouldn't break dropping the select, but straight into a copy/paste it doesn't know whose @{Strength} to use. Granted, I didn't test with an ability.
1389113792
Tom
Plus
Sheet Author
Brandon, Ok! Worked that time. So how exactly does this work: 0d1>7sd By my reading it rolls 0 1-sided dice looking for rolls higher than 7, right? Is that the figure that sets a floor for successes (so no 0 successes)? How does that work exactly? Learning here. This is far and above the most complicated macro I've seen (which isn't saying much, but still...) and I really want to figure out how it all works. What would be the difference if instead of +0.1 I raised it to +1. Wouldn't then 1 become the threshold for success/damage rather than 0.1? Or does it blow a hole in the formula? Also, how does incorporating it into the brackets, but distinguishing it with a comma work? I don't remember seeing anything like that in the macro documentation. I was likewise surprised you used a comma after 2 rather than a +. So what do commas do in macro functions?
1389114404

Edited 1389114600
To answer the first question, I have to answer the third one first. :P Incorporating multiple rolls into brackets turns it into a roll group. So {1d10,2d20} will roll those two dice sets first, then add them together. If I add kh1 (keep highest 1), I only keep whichever is higher, 1d10 or 2d20. Additionally, roll groups require that you always use the same type of rolls in them. You can't mix math (just numbers), rolls, and success checks together. So by setting 0d1>7sd as part of the roll group with kh1, if the actual attack ever roll a negative number of successes, the roll group drops it and just reports 0 successes. You can swap the 2, @{Strength} to 2+ but I somewhat wanted to keep things looking the same through the macro. As for the second question, if you raised 0.1 to 1, then any time you roll an actual positive result, this macro reports 1 more success than you want it to. Roll group: {([[{2, @{selected|Strength}}]]d10!10>7sd -@{target|Armor})+0.1, 0d1>7sd}kh1 Roll 1 ([[{2, @{selected|Strength}}]]d10!10>7sd -@{target|Armor})+0.1 Roll 2 0d1>7sd kh1 Math both of the above rolls, compare them to each other. Give me just the higher one.
1389114665

Edited 1389115628
GiGs
Pro
Sheet Author
API Scripter
Brandon W. said: G G, a result of 0 net successes is considered a glancing success, or 1 success anyways. It's only negative results that actually end up in a miss. Give yourself a big negative on strength and it'll come up 0. my impression is that what Tom wants is for any roll that gets at least 1 success, but is reduced to 0 or less by armour be reported as a hit but no damage (as you did with 0.1 successes). But any result that fails outright (0 successes before armour) needs to be recognised as a miss. I can't see any way to do this. It's easy with the kh1 method to avoid reporting negative results when armour exceeds damage, but I cant see any way to distinguish between a miss, and a hit that is blocked by armour.
Ah, I didn't think of that. Crap. Back to the mathing board. Give me a bit.
1389115711

Edited 1389115826
Fixed. And now it doesn't report 0.1 success anymore. it'll report the correct number of actual successes, even at 0 armor. /roll {ceil([[{2, @{selected|Strength}}]]d10!10>7sd +0.1) -@{target|Armor} -1, 0d1>7sd}kh1 Crap, nope. I lose the hits=armor is 1 success now.
Yeah, I think 0 Armor and 0 successes may just have to be an edge case to watch for, outside of the API.
1389117859
Tom
Plus
Sheet Author
Gah! Damn you API! OK look, maybe I'm overthinking this...a lot. The real trick has always been returning a negative result as 0. If you ignore that, then really all you have to do is redo the basic macro with a +1 in there so that a result of 0 becomes 1 and the player can read it as damage easier. So then this out to work, right? /roll ([[{2+@{Strength}]]d10!10>7sd+1)}-@{target|Armor} vs @{target|token_name}'s Armor for Damage Dealt
1389118215

Edited 1389118292
Tom
Plus
Sheet Author
Wait, before I call it a day... Brandon, so the limiter here is really the 0d1>7sd}kh1 feature, right? Is there a way to adjust that to make it a constant 1 result? Ergo, if the original roll returns a result of 0, the total is 1. If the original roll is 1 or more, it returns a result of 1 or more. Or wait, no because that will always return a result of 1. Hmmm...
1389118276

Edited 1389118496
With that macro, if I roll 4 successes against an Armor of 1, then I get 4 successes. You can change it to 1d1>1sd to always get 1 success minimum, but then it'll never tell you if you have zero or less successes so you'll never know if you miss. What I lined out a few posts above fixes the 0 armor/0 hits check, but loses the successes=armor notification. I think it may be a one or the other choice. And no, you can't reference rolls into another roll and use both.
1389121762
Tom
Plus
Sheet Author
Just a thought. Originally the formula you presented distinguished a 0.1 as a success vs. 0. Is it possible to reset that to .5 then use the rounding feature (ceil) to round that figure up to 1? -1.5 would still round up to 0 and be cancelled out. Or would that put me right back in the "4 successes vs Armor 1 is 4 damage" boat?
Yeah, since it's still a component of 1.1 and more successes it'd screw that up.
1390071926
Tom
Plus
Sheet Author
Holy crap! It finally hit me this morning after our game last night, I've been approaching this backwards! See, the way Witch Hunter works is that when you roll an Ability test, you have to meet or exceed the target number in successes. In the ca of combat, your have to meet or beat the target's Avoidance stat. Damage is different. Armor reduces damage by a like value. So if I take 5 points of damage and have 1 point of armor protection, the damage is reduced by 1 point to 4. So rather than adjusting the damage to account for a floating point, it's the Attack roll that needs to e boosted by 1. So 0 successes vs Avoidance would be a hit, with additional successes being applied to bonus damage. And the reason this works is because Avoidance is never zero, so you never have to deal with the zero successes vs zero Avoidance issue. ill have to test it, but it should work just fine. Tom
Thanks Gauss. I'll make sure to support Roll 20 as soon as possible (I am unable to use funds over the internet due to circumstances beyond my control). I guess I'll just have to do the slower version of rolling the damage, and setting an attribute as "Incoming damage" and continue the formula from there. I.e. /r 1d1*@{damage}-(1d1*@{damage}*(@{armor}*1.3)/100). Thanks again!
1391132659
Gauss
Forum Champion
Black.k.9, I think you mightve posted that in the wrong thread. :)
Tom Said: Thanks guys. After this thread was quiet for so long, I bumped it over to a new thread. In the end, I had a revelation that I had things backwards. The damage roll works just fine with 0 successes. It was the to hit roll that needed a bump. Here is a link to the follow up thread if anyone is interested in how things worked out. Brandon W outdid himself with the formula gymnastics! Tom moved the thread to this... =/
1391146921
Gauss
Forum Champion
Ahhhh, ok :)