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

Help with my ranged macro

1716769762

Edited 1716769790
I use a homebrew system in which special bonuses accrue when rolling more than needed to hit with ranged attacks. The problem is getting the macro to show both bonuses. I don't really need the actual for or 'hit surplus' to show. If the bonuses are negative I know the shot missed. My system also tracks the number of actions used for a shot, rolling a d10 per action and keeping the best 2.  I've been trying to do something like this: &{template:default} {{name=@{selected|token_name}'s Shot}} {{ [[ ( ?{Actions Spent?|2,2|3,3|4,4|5,5|6,6}d10kh2+(@{selected|ranged bonus}-?{total penalty?|0}-15) )*floor(@{selected|Bonus 1 )+ (@{selected|fixed bonus 1}  }} {  $[[0]]* {floor(@{selected|Bonus Damage}) ]]+  [[@{selected|ranged_damage} ]] }} Obviously this doesn't work, but I think it shows what I'm trying to accomplish more clearly than any of my attempts to use nested rolls and triple brackets. Specifically I need to take  ( ?{Actions Spent?|2,2|3,3|4,4|5,5|6,6}d10kh2+(@{selected|ranged bonus}-?{total penalty?|0}-15) which gives the Hit Surplus and multiply it by @{bonus1} and then add a fixed bonus, and also multiply the hit bonus by @{bonus2} and add another fixed bonus. If I need API for this that's fine, if I can figure out how/which one. Is this possible?
1716775683
Gauss
Forum Champion
Hi Morgan, By the looks of it your [[ in the first section do not have an ending ]]. So that is a problem. Second, you do not have a second { in your second section (starting with $[[0]]).  Third, you cannot use reused numbers (ie: $[[0]] ) in calculations. But, there is a way around that.  And you are missing various other symbols (like an ending } for an attribute).  Also, why are you using floor on certain attributes? Are do they have a calculation inside? If so please show the attributes anytime you do this. It matters.  Every attribute should be fully explained.  So assuming I understood all your stuff correctly this should work:  &{template:default} {{name=@{selected|token_name}'s Shot}} [[ [[ (?{Actions Spent?|2,2|3,3|4,4|5,5|6,6}d10kh2 +@{selected|ranged bonus} -?{total penalty?|0} -15) *floor(@{selected|Bonus 1})+ @{selected|fixed bonus 1}]] *  floor(@{selected|Bonus Damage}) +@{selected|ranged_damage} ]] {{$[[0]]}} {{$[[1]]}} Note: this also depends on what your attributes contain. 
Thank you so much, I should have been more clear. Here is the actual macro, based on the one you posted: &{template:default} {{name=@{selected|token_name}'s Shot}} [[ [[ floor((?{Actions Spent?|2,2|3,3|4,4|5,5|6,6}d10kh2 +@{selected|ranged bonus} -?{total penalty?|0} -15) *(@{selected|MoVLC})+@{selected|ranged_LC}) ]] * (@{selected|MoVDamage}) +@{selected|ranged_damage} ]] {{Location=[[1t[@{target|table type}] ]] +/- $[[0]] }} {{Damage = $[[1]] }} The @{ranged bonus}, @{ranged LC}, and @{ranged damage} fields are whole numbers. The @MoVLC and @MoVDamage fields are often not whole numbers, which is why I was using floor. (in the wrong places.) Their values in my testing character are 1.34 and 0.68. They will always be a multiple of 1/3. the table type pulls a percentile location name from a roll table with appropriate locations for the particular creature. (winged, humanoid, blob etc.) Right now the entire location section is working perfectly. (Thank you!) The Damage number is a bit off. The @{ranged LC} is included in the Hit Surplus calculation for the Damage. I also can't figure out how to round down the damage figure, although that's not crucial. Thanks again for the help and the education.
1716848308
Gauss
Forum Champion
How is the damage number off?  If you could provide all the attributes sample values (and sample query values), then the expected result I can troubleshoot where the problem may be. 
The formula for Damage is:  ( ?{Actions Spent?|2,2|3,3|4,4|5,5|6,6}d10kh2 +@{selected|ranged bonus} -?{total penalty?|0} -15) * (@{selected|MoVDamage}) ) +@{selected|ranged_damage} The formula for location control is:  ( ?{Actions Spent?|2,2|3,3|4,4|5,5|6,6}d10kh2 +@{selected|ranged bonus} -?{total penalty?|0} -15) *  (@{selected|MoVLC}) )+@{selected|ranged_LC} As things are *   (@{selected|MoVLC}) )+@{selected|ranged_LC} is included in both numbers.  for example, let's set all of the variables, saying that the d10 rolls total 17, the total penalties = 2,   @{selected|ranged bonus}=4,  @{selected|MoVDamage}=0.67,  @{selected|ranged_damage}=6,  @{selected|MoVLC}=1.34, and  @{selected|ranged_LC}=8 The macro I posted previously calculates damage as ( ( 17+4-2-15)*(1.34)+8)*(0.67)+6 = 14.95 It should calculate damage as (14+4-2-15)*(0.67)+6 = 8.68
1716851817

Edited 1716851875
Gauss
Forum Champion
Alright, please state clearly what the formula for damage is. Do NOT  include ANY Roll20 jargon, macro information, etc. Pretend Roll20 does not exist. Use words and numbers only please, as if you and I were sitting with paper and dice at a kitchen table.  Right now you have conflicting examples. 
The formula for both location control include what I call hit surplus. Hit surplus= (the die roll+ the character's bonuses-the situation specific penalties-15.) The formula for damage is the (hit surplus)*(the per point of hit surplus damage bonus) +(the fixed ranged damage bonus). The formula for location control is the (hit surplus)*(the per point of hit surplus location control bonus) +(the fixed ranged location control bonus) So specifically the formula for damage is:  (the die roll+ the character's bonuses-the situation specific penalties-15.) *(the per point of hit surplus damage bonus) +(the fixed ranged damage bonus)
1716861420

Edited 1716862654
Gauss
Forum Champion
Alright, lets go back to the start so I can understand:  Damage is: (Actions Spent + Ranged Bonus - Total Penalty) * MoVDamage + Ranged Damage Next, you added something called Location control? I didn't see that as part of this discussion until a couple of posts ago.  Location Control is:  (Actions Spent + Ranged Bonus - Total Penalty -15) * MoVLC + RangedLC Are those correct? If that is all correct I think I have the solution:  [[((([[AB+C]]-C)/B) - 15)*D +E]] A = (Actions Spent + Ranged Bonus - Total Penalty) B = MoVDamage C = Ranged Damage D = MoVLC E = RangedLC Giving us: [[((([[(Actions Spent + Ranged Bonus - Total Penalty) * MoVDamage + Ranged Damage]] - Ranged Damage)/MoVDamage)-15) *MoVLC +RangedLC]] Then you simply pull the values out via $[[0]] and $[[1]]. How it works: A*B-C is calculated first, and being in an inline brackets spits out an answer.  Then using math we reverse A*B-C to get back to A. Then we do the math functions of -15, *D, and +E Note I haven't tested this but the math seems solid. 
Brilliant. Thank you so much. 
1716868078
Gauss
Forum Champion
Let me know if you need help implementing it. 
So this is working perfectly now: &{template:default} {{name=@{selected|token_name}'s Shot}} [[ floor((( [[ floor((?{Actions Spent?|2,2|3,3|4,4|5,5|6,6}d10kh2 +@{selected|ranged bonus} -?{total penalty?|0} -15 ) *(@{selected|MoVLC})+@{selected|ranged_LC}) ]]-@{selected|ranged_LC})/@{selected|MoVLC}) * (@{selected|MoVDamage}) +@{selected|ranged_damage}) ]] {{Location=[[1t[@{target|table type}] ]] +/- $[[0]]}}  {{Damage = $[[1]]}} I decided I'd like to be able to see the Hit surplus as well so I changed it to this: &{template:default} {{name=@{selected|token_name}'s Shot}}  [[ floor(([[ floor([[?{Actions Spent?|2,2|3,3|4,4|5,5|6,6}d10kh2 +@{selected|ranged bonus} -?{total penalty?|0} -15 ]]*@{selected|MoVLC} +@{selected|ranged_LC}) )]]-@{selected|ranged_LC})/@{selected|MoVLC}*@{selected|MoVDamage}+@{selected|ranged_damage})  ]] {{Hit Surplus = $[[0]]}} {{Location=[[1t[@{target|table type}] ]] +/-  $[[1]]}} {{ Damage=$[[2]]}}  Thanks a million Gauss!