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

[D&D5E] Modifying dmg Rolls depending on To-Hit roll

I am wondering if it is possible to make it so an attacks To-Hit roll can determine the outcome of a damage die (or any die). ie, if my base to-hit die (1d20) rolls a 1-6, it only adds *1 to a multiplier, if it's 7-13, *2, and if it's 14-20, *3. I was brainstorming some attribute ideas on how this might work, but it's difficult, and in all honesty I would like some assistance with this. I am sure this is possible, but in terms of how, I need some advice. (brainstorming) @Test 2    [[{{@{Hit},13}>14}]] @Test 1     [[{{@{Hit},6}>7}]] @Hit         !wammo @{character_id} Hitd [[1d20]] rolled before the to-hit, if possible r1=@{Hitd}cs>20 dmg1=[[(damage stuff)*[[1+@{Test 1}+@{Test 2}]]]] This feels tricky, yet so doable. I hpe it can be done, and although this does use the !ammo api, I'm all for figuring out how to go about this in a way that doesn't require api's - though that'd be hard
1715086646
timmaugh
Pro
API Scripter
I'm not sure what the ammo script is doing for you, there? You don't need it specifically for the math, so is it modifying the character sheet in some way? Here is the basic roll that will durn a d20 into the range of numbers you specify (with breakpoints at 7 and 14): [[floor(([[1d20]]/7)+1)]] Then  you can extract the roll using $[[0]] (if this is the only roll in your command line).
timmaugh said: [[floor(([[1d20]]/7)+1)]] That is a very cool formula for that, thank you for sharing this. I am a little familiar with roll re-using from previous macro testing, but I may need an example on how it is used for this. I am not sure I understand quite yet. I have a hopefully better way to explain what I am aiming to do with this (actual example may not really work, but it's for an idea) Weapon Attack (These are all in character sheet btw) @{wtype}&{template:atk} {{mod=+[[[[@{spell_attack_bonus}-@{pb}]][SPELL] + [[5+7]][MOD] + @{pb}[PROF]]]}} {{rname=[attack](~dmg)}} {{rnamec=[attack](~dmg_crit)}} {{r1=[[1d20cs>20 + [[@{spell_attack_bonus}-@{pb}]][SPELL] + [[5+7]][MOD] + @{pb}[PROF]]]}} @{rtype}cs>20 + [[@{spell_attack_bonus}+@{spell_attack_mod}-@{pb}]][SPELL] + [[5+3]][MOD] + @{pb}[PROF]]]}} {{range=120ft}} {{desc=}} {{innate=}} {{globalattack=@{global_attack_mod}}} # Note the r1=1d20 Damage Roll @{wtype}&{template:dmg} {{attack=1}} {{dmg1flag=1}} {{dmg1=[[@{DMG} + [[@{spell_attack_bonus}-@{pb}]][SPELL] + [[5+7]][MOD]}} {{dmg1type=Type}} {{globaldamage=[[@{global_damage_mod_roll}]]}} {{globaldamagetype=@{global_damage_mod_type}}} # Note the @{DMG} Attribute Attributes Attribute        Value DMG             @{weap1}+@{weap2} weap1            [[5@{Multi}]] weap2            [[2@{Multi}]] Multi            *[[floor(([[1d20]]/7)+1)]] The idea for @{Multi}'s 1d20 would be to represent the 1d20 that is being rolled in the Weapon Attack Roll, somehow, then be ( consistently ) added onto @{weap1} and @{weap2}s damage (if 1d20 = 6, @[weap1} = "[[5*1]]", and weap2 = "[[2*1]]") The desire to have it in an attribute instead of being apart of the macro itself is so that I can put it inside of the actual damage attribute itself (ie @{DMG}), and have it multiply the damage value from within (5*3 showing in the Inline Damage Roll as 15 instead of (5*3)), as that is much easier to read since the math is already done. This is mostly due to the planned weapon (an arm-cannon with many weapon upgrades) adding more damage types, and it'd be far easier to have it all mathed-out if the DM has to calculate the damages against resistances/vulnerabilities etc. It's also the reason I was initially thinking the !ammo API would come in handy, since it's able to modify attributes directly and may be easier to work with. (Although again, if it's doable w/o apis, I am inclined to do that instead)
1715179207
timmaugh
Pro
API Scripter
Hmm... so... some general points... 1) The gold standard in attribute modification is ChatSetAttr. Ammo scripts have particular usages for tracking ammunition resources, but for general attribute modification, I would tend toward CSA. If you find yourself using the ammo script just for modifying attributes, I would strongly suggest switching to CSA as it tends to be more stable and flexible. 2) I understand what you're trying to do with the attributes, and if you only needed to build a single stack of math it would work. Unfortunately you need to use the original d20 in two separate equations (weap1 and weap2). That is going to force a re-roll of the d20 every time it's used. Without scripts, roll re-use is only available within the same command line where the roll is made... so for your example, you could only reuse that d20 roll if all of your to-hit and damage was in the same template command. That much can be managed: [[ ([[5 * [[1d20]] ]] / 5) * 2]] That would have the d20 at roll $[[x]], weap1 at roll $[[x+1]], and weap2 at roll $[[x+2]]. What it does not do is add weap1 and weap2... which, short of RainbowEncoder having an arcane roll ritual up their sleeve, will not be possible. So what can you do? You can still do this, using either CSA to set an attribute (which your later rolls later use), or using metascripts. ChatSetAttr Using CSA, you can embed an api command in your first template statement (your to-hit). This is a unique ability of CSA (to run a script command even if the original message doesn't start out as intended for the Script Moderator). To make it work, you'd want one more attribute in your attribute set, and you'd reference it in your Multi attribute: Attribute        Value DMG             @{weap1}+@{weap2} weap1            [[5@{Multi}]] weap2            [[2@{Multi}]] Multi            *[[floor((@{tohitd20}/7)+1)]] tohitd20 << ...numeric value... >> The idea is that once CSA sets the value of tohitd20, it will be the same when it is pulled into both weap1 and weap2. To use CSA to write the value to the attribute in your to hit command, you'd add the following to the command: !setattr --name @{character_name} --tohitd20|$[[3]] --silent!!! Note the 3 closing bangs, necessary when you're embedding the CSA command in a template. Also note that the $[[3]] is my quick counting of the number of rolls present in your command line. I count 3 rolls occurring before the parser would find the d20. Also-also note that in order to reference the d20 separately from the rest of the math involved in the r1 template part, you're going to have to give it its own inline roll bracketing (which will make it the $[[3]] roll). That means that the r1 part should read: {{r1=[[ [[1d20cs>20]] + [[@{spell_attack_bonus}-@{pb}]][SPELL] + [[5+7]][MOD] + @{pb}[PROF]]]}} If you install CSA and make all of those changes, everything should work. Metascript Solution Using metascripts, the basic changes would be: 1) isolating the d20 roll with its own inline brackets (as in the CSA solution, above) 2) using less attributes (weap1 and weap2 math will be in the command line, and we'll hide the math by nesting inline rolls, instead) 3) using ZeroFrame batching to send both templates in the same command (so we can use the roll across command lines) 4) using an APILogic conditional to only run the damage command if the to-hit "scores" In this case, the CSA option seems simpler (and requiring less changes to your current setup), but if you want to try the metascript approach, tell me what would constitute a "hit" so I know how to build the conditional statement.