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 .
×

I need a complex macro but i am dumb

Hi roll20 i just discovered macro but i learn pretty slowly, and macro are a completely new language for me, could someone help with with this ? I need a macro to make an attack roll and then compare it to the bar2 and bar3, and then, if : you are below both : you failed: you are above both (or the highest one) : you roll damage you are between : you take damage equal to the highest value (which will always be bar2) minus 10 i don't know how to put all those condition,could you give me a hint (or the solution !!) thanks in advance everyone
1664139808
GiGs
Pro
Sheet Author
API Scripter
You wont be able to do that easily with a roll20 macro, because it doesnt handle if statements without some very kludgy work. "If you are both below, else if you are above both, else" is the kind of if statement you usually need a pro level script to solve.
1664143302
Gauss
Forum Champion
GiGs said: You wont be able to do that easily with a roll20 macro, because it doesnt handle if statements without some very kludgy work. "If you are both below, else if you are above both, else" is the kind of if statement you usually need a pro level script to solve. Or RainbowEncoder, they can do anything with macros! (Well, maybe not, but how often do we say 'you need the API for that' and RainbowEncoder comes along with a magical macro?)
1664145120
GiGs
Pro
Sheet Author
API Scripter
Gauss said: GiGs said: You wont be able to do that easily with a roll20 macro, because it doesnt handle if statements without some very kludgy work. "If you are both below, else if you are above both, else" is the kind of if statement you usually need a pro level script to solve. Or RainbowEncoder, they can do anything with macros! (Well, maybe not, but how often do we say 'you need the API for that' and RainbowEncoder comes along with a magical macro?) It's why there were some qualifications in my statement :)
The macro &{template:default} {{⚔[0](" hidden)}} {{⚔[1](" hidden)=**Failure**}} {{⚔[$[[7]]](" hidden)=**Success!** Causing $[[14.computed]] Damage}} {{⚔[$[[10]]](" hidden)=**Close.** Take $[[15.computed]] Damage}} {{⚔[0](" hidden)= $[[$[[3]]]] [[[ [[ 3+2+{ $[[2]] , @{target|bar2} }>[[1+@{target|bar2}]]f<[[-1+@{target|bar3}]] ]] Attack Roll: [[1d20+0]] [[ [[ [[0]] ]] ]] H([[1]][[0]][[0]]) M([[0]][[1]][[0]]) $[[13]] [[ [[ [[-1]] ]] ]] ]]] Damage Roll: [[2d6+0]] Self Damage: [[{@{target|bar2}-10,0}k1]] }} {{⚔[0](" hidden)=**Attack Roll** $[[2.computed]] vs @{target|bar2} & @{target|bar3}}} The attack and damage rolls I've used are just placeholder that will need to be changed. I also used target syntax to get the bar2/3 values as I'm guessing they are dependant on what you're attacking. The core comparison is simple. Since bar2 is always the highest checking for success is >[[bar2 + 1]] giving 1 on success which makes bar3 always the lowest so failure is f<[[bar3-1]] giving -1 on failure and the 'close' comparison when at or between either value gives the default 0. The trick is to then take this -1/0/1 value and display different things which requires a mix of Overwriting Template Fields and Roll Duplication since there are three possible outputs and only one can be the 'default' leaving two requiring comparative rolls.
Whoah, thanks a lot RainbowEncoder, This is amazing ! My brain will probably try to understand it later though ! :)  Thanks you amazing person
So I looked at it, and if the hit was between bar2 and bar3, it gave the damage reduction, instead of the damage minus damage reduction (damage reduction = AC/bar2 minus 10, so an AC of 14 is DR 4) Only the 2nd line has been changed, but i dunno how to compute the result of $[[14.computed]] - $[[15.computed]] in a number, but that is already working miraculously !! So thanks again to RainbowEncoder, you seem to have a hell of a reputation here !  &{template:default} {{⚔[0](" hidden)}} {{⚔[1](" hidden)=**Failure**}} {{⚔[$[[7]]](" hidden)=**Success!** Causing $[[14.computed]] Damage}} {{⚔[$[[10]]](" hidden)=**Close.** Take $[[14.computed]] - $[[15.computed]] Damage}} {{⚔[0](" hidden)= $[[$[[3]]]] [[[ [[ 3+2+{ $[[2]] , @{target|bar2} }>[[1+@{target|bar2}]]f<[[-1+@{target|bar3}]] ]] Attack Roll: [[1d20+0]] [[ [[ [[0]] ]] ]] H([[1]][[0]][[0]]) M([[0]][[1]][[0]]) $[[13]] [[ [[ [[-1]] ]] ]] ]]] Damage Roll: [[2d6+0]] Self Damage: [[{@{target|bar2}-10,0}k1]] }} {{⚔[0](" hidden)=**Attack Roll** $[[2.computed]] vs @{target|bar2} & @{target|bar3}}}
I didn't realise that had to be subtracted from the damage; it did seem a little odd. Here's an updated macro that handles it &{template:default} {{⚔[0](" hidden)}} {{⚔[1](" hidden)=**Failure**}} {{⚔[$[[7]]](" hidden)=**Success!** Causing $[[14.computed]] Damage}} {{⚔[$[[10]]](" hidden)=**Close.** Take $[[16.computed]] Damage}} {{⚔[0](" hidden)= $[[$[[3]]]] [[[ [[ 3+2+{ $[[2]] , @{target|bar2} }>[[1+@{target|bar2}]]f<[[-1+@{target|bar3}]] ]] Attack Roll: [[1d20+0]] [[ [[ [[0]] ]] ]] H([[1]][[0]][[0]]) M([[0]][[1]][[0]]) $[[13]] [[ [[ [[-1]] ]] ]] ]]] Full/Partial Damage Roll: [[ {[[2d6+0]][damage]-[[{@{target|bar2}-10,0}k1]][DR], 0 }k1]] }} {{⚔[0](" hidden)=**Attack Roll** $[[2.computed]] vs @{target|bar2} & @{target|bar3}}}
Hi rainbow encoder, this is amazing, I mean it, but could you explain to me or show a wiki that explain how work the  $[[x.computed]] things ? I searched everywhere for what it means, but I did not find anything ! Otherwise, the more I read it and the more I do research, the clearer the code and macros in general become !!
It's part of a the topic Reusing Rolls . In particular the .computed version is useful for display purposes since it doesn't interact with how the rest of the macro is run.
Thanks a lot !