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

Macro Issue: Multiple Sets of Overlapping Square Brackets

1424793975

Edited 1424793993
Hello. Right now, I'm working on designing a very Macro-heavy game intended to replicate the gameplay style of Fire Emblem. Almost everything is done at this point, but when trying to implement the effect of Weapon Weight on Attack Speed, I ran into an unexpected problem: [[{1d1+((@{selected|SPD} - [[{(@{selected|WGT} - @{selected|STR})d1}>0]]) - (@{target|SPD} - [[{(@{target|WGT} - @{target|STR})d1}>0]])) - 1}>4 + 1]] I'm fairly sure this is a functional line, but it produces an error because there are two sets of [[]]'s, with one being inside the other. Is there any way to make this possible or to replicate the effect, or am I out of luck? Side note: The equation either produces a result of 1 for a single attack or a result of 2 for a double attack, and appears in a line such as the following: "Unit attacks [X] times."
Unfortunately, you can't nest inline rolls like that. If you're trying to separate sections of rolls for order of operations, use Parenthesis.
Mark G. said: Unfortunately, you can't nest inline rolls like that. If you're trying to separate sections of rolls for order of operations, use Parenthesis. Parenthesis aren't an option, I'm afraid. The only way this equation can work is if multiple sums are being expressed as a number of successes, and the only way to do that seems to be with square brackets. So is the project doomed?
1424797625
Lithl
Pro
Sheet Author
API Scripter
Looks like you're only trying to go one level deep. Replace the outermost level with the /roll command and it should work. You lose the ability to make the whole thing inline, but you get to make the roll as intended.
Brian said: Looks like you're only trying to go one level deep. Replace the outermost level with the /roll command and it should work. You lose the ability to make the whole thing inline, but you get to make the roll as intended. Just tested this; you're correct, it does work. It's good to see. Thank you. Unfortunately, this calculation with the speed and weights is one component of a macro that does about six other things. It's quite important than it be summed up in a single number, or it's going to make the data players receive too unwieldy and elaborate to be useful. <a href="http://s9.postimg.org/9xbevag7j/testdsad.png" rel="nofollow">http://s9.postimg.org/9xbevag7j/testdsad.png</a> That is the macro's effect in its entirety. This single part of it only affects the '2 time(s)' segment.
1424799729
The Aaron
Pro
API Scripter
The only way I know of to make this more compact and "pretty" is to write an API script to handle it, which requires Mentor Level Access .
1424809137

Edited 1424811329
I'm looking into alternate solutions for the weapon weight issue, but in the meantime, could I have some help with a related, but seperate problem? This one is much simpler, I think: Chance to Crit: [[{0+((((@{target|attacker|SKL} / 2) + @{Weapons|IronLanceCRT}) - @{target|defender|LCK}))d1}&gt;0]]%. (This translates as "Unit's Chance to Crit is [[{0+((((9 / 2) + 0) - 0))d1}&gt;0]]%.") (Which actually appears as "Unit's Chance to Crit is 5%." This is a functional script. However, I need to make sure the number that results from (@{target|attacker|SKL} / 2) is rounded down. As it stands, if the Attacker's skill stat is 9, this code will give a result of 5% chance to crit, because it's rounding up from 4.5. I have attempted to insert 'floor' into multiple parts of the code but it seems to crash the macro. For example: [[{0+((( floor (@{target|attacker|SKL} / 2) + @{Weapons|IronLanceCRT}) - @{target|defender|LCK}))d1}&gt;0]]%. EDIT: Thank you, GenKitty, that works perfectly. The only reason I didn't post a proper reply to say this is because I wouldn't want to double-post if I come up with another question later.
1424809705
Gen Kitty
Forum Champion
If you subtract .5 from the numbers you wish to then divide by 2, that should fix your rounding issues. Per your example, 9-.5=8.5 which rounds to 4. I hope this helps!
1424822139

Edited 1424827033
EDIT: Disregard everything I said below. I did it! If anyone runs into a similar problems and would like to know the solution, here is the code I ended up using: [[floor({{(@{target|attacker|SPD} - ({@{target|attacker|WGT} - @{target|attacker|STR}, 0}kh1)) - (@{target|defender|SPD} - ({@{target|defender|WGT} - @{target|defender|STR}, 0}kh1)), 4d1}dh1 / 4, 1d0}dl1 + 1)]] Alright, I've realized that having two sets of square brackets does not seem to be completely crucial to this equation. However, I have no idea how to accomplish what I want to do without them. I'd like to put out an open request for anyone to successfully turn the following into a functioning Macro: (There are only two reasons I can think of that anyone would attempt this: either they are exceedingly helpful, or they would like to test their skill with an incredibly convoluted challenge.) Each character has a Speed stat, a Strength stat and a Weapon Weight stat. One character is attacking another. If the attacking character's Strength stat is less than their Weapon Weight stat, they suffer a penalty to their Speed equal to the remaining Weight after it is subtracted against Strength. For example, if a character has 10 Strength and their Weapon Weight is 15, they suffer a 5 point penalty to their Speed. This is because they aren't strong enough to efficiently wield the weapon. If the character's Strength is more than their Weapon Weight, Speed is not affected. It does not receive a boost rather than a penalty. After the Weight calculation is concluded; if an attacking character has 4 more Speed than their target, they will be able to attack twice. Otherwise, they will attack once. It is impossible for a character to attack more than twice, or to attack zero times. All of this needs to be contained within a single set of square brackets, and preferably needs to return either a '1' for when the character is only able to attack once, and a '2' when the character is able to attack twice. This is because it will be implemented into the following Macro: [Click Here] From the image: "Avery deals 5 damage to Camilla 2 time(s) , dealing critical damage if they roll 4 or below." The bolded text is the part this Macro will be determining. The rest is already finished and functional, thankfully. The variables you will need are as follows: @{target|attacker|SPD} - Represents the attacking unit's Speed stat. @{target|attacker|STR} - Represents the attacking unit's Strength stat. @{target|attacker|WGT} - Represents the attacking unit's Weapon Weight stat. @{target|defender|SPD} - Represents the defending unit's Speed stat. @{target|defender|STR} - Represents the defending unit's Strength stat. @{target|defender|WGT} - Represents the defending unit's Weapon Weight stat. And here are my two failed attempts so you have an idea of what should be going on: 1. [[{1d1+((@{target|attacker|SPD} - ((@{target|attacker|STR}) - (@{target|attacker|WGT}))) - (@{target|defender|SPD} - (@{target|defender|WGT}) - (@{target|defender|STR}))) - 1}&gt;4 + 1]] 2. [[{1d1+((@{target|attacker|SPD} - [[{(@{target|attacker|WGT} - @{target|attacker|STR})d1}&gt;0]]) - (@{target|defender|SPD} - [[{(@{target|defender|WGT} - @{target|defender|STR})d1}&gt;0]])) - 1}&gt;4 + 1]] Here is the Macro that this will be implemented into in its entirety: /w self If @{target|attacker|character_name} were to attack @{target|defender|character_name} with an Iron Lance... @{target|attacker|character_name}'s Chance to Hit: [[((@{Weapons|IronLanceHIT})+(@{target|attacker|SKL}*2)+(@{target|attacker|LCK})-(?{Would they have Weapon Disadvantage?|0}0)-(@{target|defender|SPD}*2)-(@{target|defender|LCK})-(@{target|defender|TER}*10))]]%. @{target|attacker|character_name}'s Damage: [[(@{Weapons|IronLanceMGT}+@{target|attacker|STR}-(?{Would they have Weapon Disadvantage?|0})) - @{target|defender|DEF}]]. @{target|attacker|character_name}'s Number of Attacks: [[ EQUATION GOES HERE ]]. @{target|attacker|character_name}'s Chance to Crit: [[{0+((((@{target|attacker|SKL} / 2) - .5) + @{Weapons|IronLanceCRT}) - @{target|defender|LCK})d1}&gt;0]]%. If anyone actually manages this, I will be blown away. (If someone requires additional motivation to take on this ridiculously complicated challenge: my campaign will be completely ready to play once this is done. This one Macro is the only remaining hurdle.)