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

Inputing Variables as set Modifiers for Weapons

August 19 (2 years ago)

Edited August 19 (2 years ago)

Hello
I am completely new to macros and honestly have a hard time understanding how to set them up. I was trying to figure out a way for the macro to roll a 1d4 and then add the result to any damage rolls made by a specific weapon. It would then reset when the macro is clicked again so that a new modifier/d4 could be run.

In my normal (poor) Python it would be like this:

import random

Weapon = random.randint(1,6)

Modifier = random.randint(1,4)

Total = 0

if Modifier == 1:

    Total = Weapon +1

elif Modifier == 2:

    Total = Weapon +2

elif Modifier == 3:
    Total = Weapon +3

elif Modifier == 4:
    Total = Weapon +4

else:
    print ("Error")

print (Total)

Is there any way to make a Macro that acts like this?
-Lisk

August 19 (2 years ago)
Gauss
Forum Champion

What is the game system and character sheet? 
Do you have a sample of the macro so far?

August 20 (2 years ago)
timmaugh
Forum Champion
API Scripter

There are lots of things you can do with rolls to accomplish simple (and not so simple) math operations. Not knowing your exact setup, I'll give examples that will hopefully let you fill in the blanks. Post back with questions.

Example 1: Weapon is a d6, Mod is a d4, no sheet interaction
[[1d4+1d6]]

...or, if you want labels (hover over the roll result to see):

[[1d4[Mod] + 1d6[Weapon]]]
Example 2: Weapon is an attribute named "Atlatl" on a character named "Bob the Hirsute" filled with value "1d6", Mod is 1d4
[[@{Bob the Hirsute|Atlatl} + 1d4]]
Example 3: Same as #2 except weapon value is a number intended to be the # of d6 to roll
[[@{Bob the Hirsute|Atlatl}d6 + 1d4]]
Example 4: Roll 1d6 to know the number of d6 to roll for the weapon
[[ [[1d6]]d6 + 1d4]]
Example 5: Atlatl attribute is "1d6" determining the number of d6 to roll (rolling between 1 and 6 d6)

...as Example 4...

Example 6: Query for Modifier of either 1d4, or 2d4s keeping high (adv) or 2d4s keeping low (disad)
[[1d6 + ?{Modifier|Standard,1d4|Advantage,2d4kh1|Disadvantage,2d4kl1}]]

More Reading

Those are starting to get more complicated, so I'll stop there... but you can read more on the wiki:

Also, rolls are just the getting-of-the-numbers. I'd also suggest reading about templates as a way to output information:

August 20 (2 years ago)

Edited August 20 (2 years ago)

Sorry that wasn't clear, and thanks for that plethora of examples!
This is for a D&D 5e character sheet. And no sample of the macro unfortunately.
I'll try and re-explain as I realised I made some mistakes in my last post. My goal is for something like this to happen:
-Bob clicks the Macro which rolls 1d4, getting the result of 3
-3 radiant damage is now added to every damage rolls he makes with Atlatl (a weapon on his sheet)
-If he clicks the Macro again, he gets a new result, +2, which replaces the +3 radiant damage bonus

Optional (forgot this the first time):
-Bob's hp (preferably in sheet) is reduced by 3 (the amount of damage rolled with the Macro)
-This damage is cumulative, each time he rolls the Macro he loses more health (-3 the first time, -2 the second time)


From your examples, it would seem like I would need to make a separate Ability for the Atlatl weapon rather than having one on the character sheet, and modifying that. A possible option could be to make the roll and 'save' it in one ability. Another ability then makes the attack roll (just the regular weapon) and adds the first ability's saved number. Then the first ability can be clicked to reroll/reset the number.

So I made a bit of a mess trying to adapt someone else's rolls. (Tanto is the weapon dealing 1d4 piercing damage, Blood-Radiance is the first ability which should do a set amount of radiant damage, Camilla is the player). It rolls the first damage (piercing) but not the second.

@{Camilla|wtype}&{template:atkdmg} {{mod=+1}} {{rname=Tanto}} {{r1=[[@{Camilla|d20}cs>20 + @{strength_mod}[STR] + @{pb}[PROF]]]}} @{Camilla|rtype}cs>20 + @{strength_mod}[STR] + @{pb}[PROF]]]}} {{attack=1}} {{range=Self}} {{damage=1}} {{dmg1flag=1}} {{dmg1=[[1d4+ @{strength_mod}[STR]]]}} {{dmg1type=Piercing}} 0 {{dmg2=%Blood-Radiance[[$[[0]]]]}} {{dmg2type=Radiant}} {{crit1=[[1d4[CRIT]]]}} {{crit2=[[0[CRIT]]]}} 0 {{desc=}}   {{spelllevel=}} {{innate=}}

After looking at your links, I assume this is the simple roll with the last bit making it callable. But from there, sheet weapons don't seem to have their own code if you hover over them so I'm not sure how I can add the callable as additional damage during the weapon roll.
&{template:default} {{name=Blood Damage}} {{Damage=[[1d4]]}}= $[[0]]

(BTW this is what I have currently set up in the 'Blood-Radiance' ability macro).

August 20 (2 years ago)
timmaugh
Forum Champion
API Scripter

A couple of things...

1) Without a script, macros don't have a way to change a character sheet or token. You'll have to manually track the loss of HP.

2) You can't reuse rolls like this: [[$[[0]]]]. You can reuse the roll by invoking the roll marker ($[[0]]), just not in another roll. Typically if you want to reuse a roll in another roll, you structure as much of the roll as nested, first, because if it happens at once the roll will be interpreted. That way you can pull out the bits you want, later. This one doesn't make a whole lot of sense (for reasons I'll say in a minute), so let's say that what you really wanted was to take roll $[[0]] and add 2 to it. You might be tempted to right it: [[ $[[0]] + 2]] ... but that wouldn't work. Instead, take advantage of the fact that text you put between the double braces of a roll template won't show up:

@{Camilla|wtype}&{template:atkdmg} this text won't show up. put anything here{{mod=+1}} this is also hidden {{rname=Hidden  Stuff}}

Stuff the roll into one of those gaps and stack all of it up the first time it shows up. Your roll $0 is the first roll in your macro, which I'll use, below:

[[ [[@{Camilla|d20}cs>20 + @{strength_mod}[STR] + @{pb}[PROF]]] + 2]]

Provided this is the first roll in your macro, your Roll $0 is still the same roll. But now your Roll $1 is the value of Roll $0 + 2. So you can use these things in your template between the double braces:

@{Camilla|wtype}&{template:atkdmg}[[ [[@{Camilla|d20}cs>20 + @{strength_mod}[STR] + @{pb}[PROF]]] + 2]]{{mod=+1}}{{r1=$[[0]]}}.....{{somewhere else=$[[1]]}}...

3) As for why that doesn't make sense, it looks like you're trying to implement a particular Blood Radiance ability on the sheet (maybe identified by the number on the back end of the name)... but that number will never be rendered to the template. Even when you enclose it in more double brackets of another inline roll, all you're doing is changing the roll marker that gets left in the line. Nothing in a standard macro/ability can extract the value of an inline roll. Scripts can do that... my ZeroFrame script lets you append .value to any inline roll to extract the value in situ, after inline rolls are parsed but before the line is given to the chat output. Short of something like that -- or me better understanding what you're trying to do there, I'm not sure what to do with this part

4) You don't have the leading double brackets for the bit of text after that r1 part. R1 looks closed:

{{r1=[[@{Camilla|d20}cs>20 + @{strength_mod}[STR] + @{pb}[PROF]]]}}

...but then the next bit looks like the same roll, but without being in a template part (no opening double braces) and without being in an inline roll (no double brackets):

@{Camilla|rtype}cs>20 + @{strength_mod}[STR] + @{pb}[PROF]]]}}

5) Finally, after all of that, I'm not terribly familiar with that sheet, so while I can help spot syntax errors, reaching into the sheet to know whether it will take a completely new ability is above my pay grade.

August 20 (2 years ago)

Edited August 20 (2 years ago)

You say a couple... ha :P

1) That's fine we'll do that manually then.

2) I'm not really clear what you're referencing here. It was more the other way round. Making a roll of a d4 and storing the result. Then adding the result to every other damage roll made by a certain weapon. (So if the result is $0=2, then +2 to $1 multiple times until $0 is rerolled for a new number). I get you were trying to explain it to me by adding +2 (and thanks for that), but right now my brain will not expand that far. The way you've written it right now with $0 and $1, does that mean $0 will be a new number each time the macro is rolled?

3) I'm not trying to add Blood Radiance to the sheet, I'm more trying to add the result of its roll to the damage done by a weapon that is accessed through the sheet. If that makes sense. Oh, it can't? How come? Doesn't it have to know the roll result to be able to display it? How do you access Scripts, is it part of Pro?

4) Oh my bad that's probably a syntax issue then, although it didn't come up with anything about it. How would that affect it?

5) No problem, I appreciate you trying to help me out nonetheless! What games do you play?