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

Displaying Results for Multiple Targets

1630122125

Edited 1630125528
I've been working on an Autofire macro for a Savage Worlds conversion and, after much wailing and gnashing of teeth, I'm 99% to where I want to be.  I thought I was 100% there, but I just encountered some unexpected behavior which is dragging me right back to the brink... The Autofire action allows a player to fire a number of "shots" with a weapon up to that weapon's rate-of-fire, and to allocate these shots among possible targets.  A player may choose to allocate more than one (or even all) of those shots to a single target. My macro rolls the dice, computes the modifiers for each individual target, and displays the results in a roll template.  So long as different targets are selected for each shot, everything works fine, and the results display correctly for each roll and each target.  However, in certain circumstances, if multiple shots are allocated to the same target, the 3D dice roll but the results do not display in the roll template output. I've been testing with four shots on three targets ( A , B , and C ), with the following results: Targeting AAAA  outputs results for  AA and the Wild Die  in the results roll template.  (In all of the below cases, the Wild Die also displays correctly, but I'll omit for brevity...) Targeting  AAAB  outputs results for  AAB ; Targeting  AABA  outputs results for  AAB ; Targeting  AABB  outputs results for  AAB ; Targeting  ABAA  outputs results for  ABA ; Targeting  ABAB  outputs results for  ABA ; Targeting ABBA  outputs results for ABA ; Targeting  ABCA  outputs results for  ABCA ; (yay!) Targeting  ABCB  outputs results for  ABC ; Targeting  BACB  outputs results for  BACB ; (yay!) Targeting  ABCC  outputs results for  ABC ; etc. In each case, all five 3D dice roll correctly (one Shooting die for each target plus one Wild Die), but as you can see above, only some of the results display.  So what this tells me is that something is discarding any shots at a given target beyond the first unless  that target happens to match the first target selected, in which case it displays a single additional instance and discards the rest.  As far as I can tell (which admittedly isn't very far), there isn't anything in my macro that would result in this behavior, but I'll include it below just in case.  (I apologize in advance; it's long and inelegant and kludgy, but it [mostly] does what it's supposed to do.) !token-mod --ids @{selected|token_id} --set bar1_value|-16 /emas @{selected|token_name} rakes the enemy with a blistering volley from the M249! !roll20AM --audio,nomenu,play|SFX_XCOM_M249_Auto !delay .8 --!cfx AutoMuzzleFlashM249 @{selected|token_id} @{target|1|token_id} &{template:default} {{name=M249 Autofire 4x}} {{**@{target|1|token_name}** = [[1d@{selected|shooting} + ([[(-4) [Base TN] + ?{Bipod?|No, -2|Yes, -1} [Recoil] + ?{Moved this Round?|No, 0|Yes, -2} [Snapfire] + (@{selected|wounds}-@{selected|wounds|max}) [Wounds] + @{selected|encumbranceMod} [Encumbrance] + ((@{target|1|size})-(@{selected|size})) [Size Difference] + @{selected|aim} [Aiming] + @{selected|fatigue} [Fatigue] + @{target|1|vulnerable} [Vulnerable] + @{selected|distracted} [Distracted] + @{selected|adrenaline} [Adrenaline] + ?{Multiple Actions?|No, 0|2 Actions, -2|3 Actions, -4|4 Actions, -6} [Multiple Actions] + ?{Optics?|None, 0|Laser Sight (short range only), 1|ACOG (stationary, med/long range), 1} [Optics] + ?{Range to Target 1?|Short, 0|Medium, -2|Long, -4|Extreme, -8} [Range] + ?{Target 1 has Cover?|No, 0|Light, -2|Medium, -4|Heavy, -6} [Cover] + ?{Misc. Modifers for Target 1 (e.g. called shot, dim lighting, etc)?|0} [Misc. Modifiers]]])]]}} {{**@{target|2|token_name}**= [[1d@{selected|shooting} + ([[(-4) [Base TN] + ?{Bipod?|No, -2|Yes, -1} [Recoil] + ?{Moved this Round?|No, 0|Yes, -2} [Snapfire] + (@{selected|wounds}-@{selected|wounds|max}) [Wounds] + @{selected|encumbranceMod} [Encumbrance] + ((@{target|2|size})-(@{selected|size})) [Size Difference] + @{selected|aim} [Aiming] + @{selected|fatigue} [Fatigue] + @{target|2|vulnerable} [Vulnerable] + @{selected|distracted} [Distracted] + @{selected|adrenaline} [Adrenaline] + ?{Multiple Actions?|No, 0|2 Actions, -2|3 Actions, -4|4 Actions, -6} [Multiple Actions] + ?{Optics?|None, 0|Laser Sight (short range only), 1|ACOG (stationary, med/long range), 1} [Optics] + ?{Range to Target 2?|Short, 0|Medium, -2|Long, -4|Extreme, -8} [Range] + ?{Target 2 has Cover?|No, 0|Light, -2|Medium, -4|Heavy, -6} [Cover] + ?{Misc. Modifers for Target 2 (e.g. called shot, dim lighting, etc)?|0} [Misc. Modifiers]]])]]}} {{**@{target|3|token_name}**= [[1d@{selected|shooting} + ([[(-4) [Base TN] + ?{Bipod?|No, -2|Yes, -1} [Recoil] + ?{Moved this Round?|No, 0|Yes, -2} [Snapfire] + (@{selected|wounds}-@{selected|wounds|max}) [Wounds] + @{selected|encumbranceMod} [Encumbrance] + ((@{target|3|size})-(@{selected|size})) [Size Difference] + @{selected|aim} [Aiming] + @{selected|fatigue} [Fatigue] + @{target|3|vulnerable} [Vulnerable] + @{selected|distracted} [Distracted] + @{selected|adrenaline} [Adrenaline] + ?{Multiple Actions?|No, 0|2 Actions, -2|3 Actions, -4|4 Actions, -6} [Multiple Actions] + ?{Optics?|None, 0|Laser Sight (short range only), 1|ACOG (stationary, med/long range), 1} [Optics] + ?{Range to Target 3?|Short, 0|Medium, -2|Long, -4|Extreme, -8} [Range] + ?{Target 3 has Cover?|No, 0|Light, -2|Medium, -4|Heavy, -6} [Cover] + ?{Misc. Modifers for Target 3 (e.g. called shot, dim lighting, etc)?|0} [Misc. Modifiers]]])]]}} {{**@{target|4|token_name}**= [[1d@{selected|shooting} + ([[(-4) [Base TN] + ?{Bipod?|No, -2|Yes, -1} [Recoil] + ?{Moved this Round?|No, 0|Yes, -2} [Snapfire] + (@{selected|wounds}-@{selected|wounds|max}) [Wounds] + @{selected|encumbranceMod} [Encumbrance] + ((@{target|4|size})-(@{selected|size})) [Size Difference] + @{selected|aim} [Aiming] + @{selected|fatigue} [Fatigue] + @{target|4|vulnerable} [Vulnerable] + @{selected|distracted} [Distracted] + @{selected|adrenaline} [Adrenaline] + ?{Multiple Actions?|No, 0|2 Actions, -2|3 Actions, -4|4 Actions, -6} [Multiple Actions] + ?{Optics?|None, 0|Laser Sight (short range only), 1|ACOG (stationary, med/long range), 1} [Optics] + ?{Range to Target 4?|Short, 0|Medium, -2|Long, -4|Extreme, -8} [Range] + ?{Target 4 has Cover?|No, 0|Light, -2|Medium, -4|Heavy, -6} [Cover] + ?{Misc. Modifers for Target 4 (e.g. called shot, dim lighting, etc)?|0} [Misc. Modifiers]]])]]}} {{**Wild Die**=[[1d@{selected|wilddie}]] **UNMODIFIED**}} {{``0-3``= ``Hit``}} {{``4-7``= ``Hit + 1 Raise``}} {{``8-11``= ``Hit + 2 Raises...``}} ``Choose the best four results and discard the fifth, then click below to roll damage for each hit:`` [Roll Damage](~Weapons|M249-auto-damage) Any advice is appreciated!  Thanks in advance!
1630142674

Edited 1630142953
Oosh
Sheet Author
API Scripter
A template can only have a single instance of each property. For example, if you try this: &{template:default} {{name=Original Name}} {{name=Overwritten}} {{notes=Original description}} {{notes=Description overwritten}} You'll see that you lose all the 'original' data. The reason a couple of those examples are working is the extra space after target|1|token_name - this is a distinct key name due to the extra character. In all other cases you're overwriting the first instance of "A" with the next instance of "A" since the key names are identical. You'll need to change the names - either "Shot 1: @{token_name}=" or some such, to distinguish each one when the same token is selected. More info here , including some ways to exploit the behaviour.
Perfect -- that's just the information I was looking for.  Changing to  **1: @{target|1|token_name}* ,  **2: @{target|1|token_name}* , etc. seems to be working perfectly.  Thanks, Oosh!