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

A Macro for a Specific Type of Game Mechanic

1589512916

Edited 1589513185
Ok, I got a fun one, considering it involves ONLY simple math, but seems like it is logically impossible to do with the syntax provided by roll20. Here's what the game mechanic does: A special kind of armor in the game first  negates damage AND THEN second  it does damage to the armor AND THEN finally the rest goes to the wearer. So, let's take 20 damage and the armor is 12|8 (Negate|Armor Damage). This would become 0 damage to the wearer and 8 to the armor. 13 damage = 00 damage to the wearer and 1 to the armor. 15 damage = 00 damage to the wearer and 3 to the armor. 18 damage = 00 damage to the wearer and 6 to the armor. 21 damage = 01 damage to the wearer and 8 to the armor. 25 damage = 05 damage to the wearer and 8 to the armor. 99 damage = 79 damage to the wearer and 8 to the armor. I should also probably note that the output should be something like "ArmorDmg: ## & PCdmg: ##" I think you see where I am going with this. I've tried writing equations every which way I could possible think of. I've also tried looking up math concepts that may apply (because I thought maybe the way I was thinking about the approach to this math issue is all wrong). No dice (pun intended), I've not found ANY way to write this in roll20. Anyone got any ideas? For reference, the closest I got was: [[[[?{Damage}-[[12]]]]-[[?{Damage}-[[8]]]]]] I figure some of the syntax is probably unnecessary, but I did all that just to keep track of what I was calculating with the equation. Obviously, I was wrong. Anyways, anyone got anything?
1589514655
GiGs
Pro
Sheet Author
API Scripter
I have a conclusion that is disappointing for you: you cannot do this with roll20 dice macros. This requires doing one operation on the starting number, generating a total, and then doing a second operation on the remainder. Roll20 doesnt support any kind of chaining of that nature. You can only do one operation on a given roll or number, and get only one result out of it. You cannot bypass those limits, unfortunately. If your GM is a Pro, the API feature lets someone create a script to do this, but that's not available to free users.
Can it be done by calling to another macro in some way?
1589516143

Edited 1589516197
GiGs
Pro
Sheet Author
API Scripter
No, it simply cannot be done without the API. Macros arent anything separate from the dice system - they are just dice expressions recorded for later use, and have the same limitations.
Well, alrighty then.
1589516555
GiGs
Pro
Sheet Author
API Scripter
Yeah, the limitations of roll20 dice can be pretty frustrating at times.
I just figure there was something. Because what I'm after is the display, not even the calculation really. So, I figured I could make it in some way so that if the output is above a certain number, just show a different number. Like, if the output is above 8, show 8 anyway. The calculated output would not change, just the displayed output to the chat.
1589517688
GiGs
Pro
Sheet Author
API Scripter
The closest you can get is to have it subtract the first step, and let the players handle the dividison between damage to armour and to themselves.
1589517906
Oosh
Sheet Author
API Scripter
I... think you could achieve something like this if you had a character sheet representing the armour itself? Unless I'm misunderstanding. So you roll the damage separately. Then you have a macro that queries how much damage was done, and compares it to the Armour Negate & Damage values stored in the character sheet. It would output to "ArmorDmg: ## & PCdmg: ##" Is this correct? I don't think you can get this to work as part of the damage roll without API, but if you're happy typing the damage that was rolled into a prompt, I think we can make it work.
1589517970

Edited 1589518151
Happy with typing the damage roll in the prompt. So, yeah, the players can type in the damage in query like from something like...   "?{Damage?}"   ... and go from there... ?{Damage?} - negated = no need to display ?{Damage?} - negated - damage to armor = display as damage to the target And then the problem: Displaying damage from 1-8, if after negating damage, there is 1-8 damage left (per the above example of 12|8).
1589519426

Edited 1589520085
Oosh
Sheet Author
API Scripter
Ok so try this, it's just in the default template, can change it to a normal chat or another template easily enough. First create a character called Armour or whatever you want, and assign its Strength (value, not mod) to the Negate value. Assign its Dexterity to its Damage value. &{template:default}{{name=Armour Mitigation}}{{Damage to armour=[[{(?{How much damage was dealt?}-@{armour|strength}),@{armour|dexterity}}kl1},0]]}}{{Damage to wearer[[{(?{How much damage was dealt?}-@{armour|dexterity}-@{armour|strength}),0}kh1}]]}} Then try this code. Current limitation is that it will display a negative value for the Negated value if you take less than 8 damage - I've tried wrapping the kl1 check inside another {<value>,0}kh1 check but it doesn't seem to work. If anyone else can chime in with a solution here it'd be working as intended I believe? If there is no way to nest that inside another kh1, I think you'll just have to ignore any negative armour damage results, or just not run the macro if you take less than 8 damage (not too much mental arithmetic there). I don't know the mechanic you're using, but presumably the armour has limited HP of some kind if it's taking damage. In that case, you could track its HP (manually without API) either on the sheet again, or use one of your own character's unused token bars - if bar2 (blue) is your AC, bar2|max would be ideal for armour HP. edit - whups, just realised this is relying on using a character sheet which has strength and dexterity on it. If not, choose another 2 attributes to call on!
Showing a negative value is fine, because it means you've done "negative" damage to an armor. That's not possible, so my players can just ignore it. I'll give all this a shot and report back. Thanks
1589520666
Oosh
Sheet Author
API Scripter
Oh.. if the players are using it you will also need to give permission for the character sheet!
1589521090

Edited 1589521122
You DAMN GENIUS!!!!!! TOTAL EPIC SAUCE. It worked beautifully. Now, just to understand it all...
1589521935
Oosh
Sheet Author
API Scripter
Credit to Ziechael, it never occurred to me to use queries & commas with a keep lowest (kl1)/keep highest (kh1) comparison until I saw his utter beast of a macro in this other thread.
1589522133

Edited 1589522154
Ah... then he's a genius. Either way... epic sauce all around. I'd say you too though, for the adaptation.
1589527845

Edited 1589528216
Ziechael
Forum Champion
Sheet Author
API Scripter
Well gosh, it seems my work here is done... now to print this out and send it to everyone I know along with a note saying "See, I may be a nerd, but I'm a damn good one!" andrew p. said: Credit to Ziechael, it never occurred to me to use queries & commas with a keep lowest (kl1)/keep highest (kh1) comparison until I saw his utter beast of a macro in this other thread. PariahScion said: Ah... then he's a genius. Either way... epic sauce all around. I'd say you too though, for the adaptation.
1589538491

Edited 1589538718
Oosh
Sheet Author
API Scripter
Ziechael said: Well gosh, it seems my work here is done... Steady on there! Genius you may be, but you seem to have missed this bit where I couldn't finish the macro: Current limitation is that it will display a negative value for the Negated value if you take less than 8 damage - I've tried wrapping the kl1 check inside another {<value>,0}kh1 check but it doesn't seem to work. Any ideas? Maybe I just knackered the syntax and it should work? Code pasted again to save your mousewheel: &{template:default}{{name=Armour Mitigation}}{{Damage to armour=[[ {(?{How much damage was dealt?}-@{armour|strength}),@{armour|dexterity}}kl1} ,0]]}}{{Damage to wearer[[{(?{How much damage was dealt?}-@{armour|dexterity}-@{armour|strength}),0}kh1}]]}} The bold italics is the bit I was trying to wrap inside another kh1 to eliminate negative results. Interestingly, I left a ",0" fragment in there but it doesn't seem to have upset the rest of the macro.
1589539407

Edited 1589539740
Ziechael
Forum Champion
Sheet Author
API Scripter
Aw man... I can't just sit back and let you do it all :sigh: will take a look after my lunchtime game :P OP, how are the attributes listed on the sheet? As a value and Max for 'Armor' or as seperate attributes ('Negate' and 'Damage' perhaps)? Doesn't matter too much but may as well make it work out of the box.
1589540088

Edited 1589540296
Ziechael
Forum Champion
Sheet Author
API Scripter
Feels like something as simple as this would work: &{template:default} {{name=Damage}} {{Armour= [[ {?{Damage Taken|0} - @{negate},@{damage}}kl1 ]] }} {{Wearer= [[ {?{Damage Taken} - @{negate} - @{damage},0}kh1 ]] }} The armour takes up to it's max amount of damage (@{damage} for the sake of this example) and the wearer takes the result of the damage taken minus the negation value (@{negate}) and the armour damage which will be 0 as a minimum? Tested it using the examples in the OP and got the desired results:
1589542234

Edited 1589542380
Oosh
Sheet Author
API Scripter
Well that's just a significantly tidier version of what I did :) If you take 3 damage, the armour line will still output -5 damage, because it's a keeplowest check. It doesn't matter, OP is happy with how it's working. I just thought you might know how to use another kh1 around that kl1 check to stop the negative results. Didn't mean to interrupt your lunch...
1589547867

Edited 1589547876
Ziechael
Forum Champion
Sheet Author
API Scripter
andrew p. said: Well that's just a significantly tidier version of what I did :) If you take 3 damage, the armour line will still output -5 damage, because it's a keeplowest check. It doesn't matter, OP is happy with how it's working. I just thought you might know how to use another kh1 around that kl1 check to stop the negative results. Didn't mean to interrupt your lunch... Oh yeah, lol... serves me right for trying to fit an answer in BEFORE lunch (and I'm always interrupted during lunch don't worry... world building session today so nothing to prep for at least!). Here is a version that will not accept a negative: &{template:default} {{name=Damage}} {{Armour= [[ {[[{?{Damage Taken|0} - @{negate},@{damage}}kl1 ]],0}kh1 ]] }} {{Wearer= [[ {?{Damage Taken} - @{negate} - @{damage},0}kh1 ]] }}
1589548516
Oosh
Sheet Author
API Scripter
Aha! I reckon I messed up the order of the [[ and { outside the kl1 when I tried it, the macro still worked but it was ignoring the kh1. Legend!
That is a rather nifty version of that code... Is it possible to do this without using an Ability?, just as a single Macro?
1589869607
Oosh
Sheet Author
API Scripter
Hmmmm... well it is a single macro. What exactly do you mean? Without the template? You can just run [[ {[[{?{Damage Taken|0} - @{negate},@{damage}}kl1 ]] as an inline roll, if that's what you're referring to, or change the Attributes it calls on to dice rolls or whatever.
1589876742
Ziechael
Forum Champion
Sheet Author
API Scripter
If you mean that you require dynamic references so that any character can use it: &{template:default} {{name=Damage}} {{Armour= [[ {[[{?{Damage Taken|0} - @{selected|negate},@{ selected| damage}}kl1 ]],0}kh1 ]] }} {{Wearer= [[ {?{Damage Taken} - @{ selected| negate} - @{ selected| damage},0}kh1 ]] }} or &{template:default} {{name=Damage}} {{Armour= [[ {[[{?{Damage Taken|0} - @{target|negate},@{ target  | damage}}kl1 ]],0}kh1 ]] }} {{Wearer= [[ {?{Damage Taken} - @{ target  | negate} - @{ target  | damage},0}kh1 ]] }} These do require a token to select or click as a target that is tied to a sheet with those attributes as values on them.
More like this (mind you, this worked for me and thanks A BILLION for the help, you have no idea how appreciative I am): &{template:default}{{name=:: Damaging Armored Targets ::}} {{Armour= [[ {[[{?{Damage} - ?{negated},?{armor}}kl1 ]],0}kh1 ]] }}  {{Wearer= [[ {?{Damage} - ?{negated} -?{armor},0}kh1 ]] }} This way, if the characters end up with armor that changes in some way AND is temporary, they can just create/fill in the blanks on the fly.
1589883811
Ziechael
Forum Champion
Sheet Author
API Scripter
Ah, I see what you mean, no abilities at all and works without even needing a sheet etc... I'd suggest using default values for the queries as rapid pressing enter will result in null values which will break the macro: &{template:default}{{name=:: Damaging Armored Targets ::}} {{Armour= [[ {[[{?{Damage |0 } - ?{negated |0 },?{armor |0 }}kl1 ]],0}kh1 ]] }}  {{Wearer= [[ {?{Damage} - ?{negated} -?{armor},0}kh1 ]] }} Because the 'wearer' section is reusing the same query results you don't need to add defaults to them.
And then I supervillain laugh... ha ha haaa Ha Ha Haaa HA HA HA HAAAA HAAAAAAAA!!!!!!!!!!!!!!!!!
1589960742
Ziechael
Forum Champion
Sheet Author
API Scripter
too bad we can't put a "[Solved]" on this...