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

Calculating a separate secondary total using RowIndex?

So Ive been working on this macro for Pathfinder 2e for a while now, and I can't seem to crack the final step.  I am relatively new to coding in general, and really have just brute forced my way through most macros Ive written in my games, and unfortunately this one has me beat. My player is the party healer, and has a a multitude of feats that can modify the way the Heal spell will function for them on the fly. I figured rather than them having to keep track of everything, Id whip up a handy flow-chart style drop down menu option, so each time they cast it they can choose which version it is, rather than having a different spell button for each version (and then consequently for each level) The varieties of the spell are as follows: Healing or Damage, then under those headings we have Healing (touch range), Healing (single target 30ft range), Healing (60ft Cone Aoe), Healing (30ft Aoe) Damage (touch range), Damage (single target 30ft range), Damage (60ft Cone Aoe), Damage (30ft Aoe) The problem lies in the fact that when any of the Aoe options are chosen, the spell does do BOTH Healing and Damage (depending on the type of the target in the area). Normally this is not a problem as the amount is equal by default (healing and damage are the same number), but due to another feat they have, when dealing damage they add the level of the spell to the amount they deal (and also sets them on fire for ongoing damage equal to that same additional amount) So for example, an AoE usage would Heal allies for 1d10, and Damage enemies for 1d10+1 (plus set them on fire for 1 ongoing) Below is the macro text I've managed so far. It works GREAT for every other aspect, but I can't figure out how to modify it so that the Damage amount is the SAME ROLL as the Heal amount +1 (or in the case of the Damage version, the Heal amount is Damage roll -1) Any help would be greatly appreciated (bonus points if you know how to get the bonus ongoing fire damage to auto match the bonus regular damage so I dont have to change the number multiple times per level of the spell). As I mentioned, Im new to coding so Im sure there is a far easier and cleaner way to have written the code below, but if it aint broke and all that.... ?{Purpose of Spell|    Healing, ?{Range of Healing|       Touch (1 Action), Touch Heal Heals [[1d10]]|       30ft Single Target (2 Actions), 30ft Single Target Heal Heals [[1d10+8]]|       60ft Cone AOE (2 Actions), 60ft Cone AOE Heals living creatures in cone for [[1d10]] %NEWLINE%  %NEWLINE% ALSO damages Undead and Fiends in cone (basic Fort save DC @{spell_dc}) for $[[0]] positive damage PLUS setting them on fire for [[1]] persistent Fire damage|       30ft AOE (2 Actions), 30ft AOE Emanation Heals living creatures in emanation for [[1d10]] %NEWLINE% %NEWLINE% ALSO damages Undead and Fiends in emanation (basic Fort save DC @{spell_dc}) for $[[0]] positive damage PLUS setting them on fire for [[1]] persistent Fire damage } |    Damage, ?{Range of Damage|       Touch (1 Action), Touch Damage Basic Fortitude DC:[[@{spell_dc}]] Damage:[[1d10]] positive PLUS setting them on fire for [[1]] persistent Fire damage|       30ft Single Target (2 Actions), 30ft Single Target Damage Basic Fortitude DC:[[@{spell_dc}]] Damage:[[1d10]] positive PLUS setting them on fire for [[1]] persistent Fire damage|       60ft Cone AOE (2 Actions), 60ft Cone AOE Basic Fortitude DC:[[@{spell_dc}]] Damage:[[1d10]] positive %NEWLINE% PLUS setting them on fire for [[1]] persistent Fire damage %NEWLINE%  %NEWLINE% ALSO Heals all living creatures in the cone for $[[1]]|        30ft AOE (2 Actions), 30ft AOE Basic Fortitude DC:[[@{spell_dc}]] Damage:[[1d10]] %NEWLINE% PLUS setting them on fire for [[1]] persistent Fire damage %NEWLINE%  %NEWLINE% ALSO Heals all living creatures in the cone for $[[1]]} }
1684422266
timmaugh
Forum Champion
API Scripter
Hey, Joshua... a couple of things I notice about this is that it doesn't matter whether the character casts it as Healing or Damage except for as a single-target spell (either touch or at range)... For range/AoE casts it's the same effect. It's the same spell, and the numbers are the same. It doesn't matter if you construct the Damage as Healing + feats (ongoing damage), or you construct the Healing as Damage - feats (ongoing damage)... the numbers are the same. That let me simplify things quite a bit. Then, to simplify it more, I put it in a roll template and used ZeroFrame and APILogic (2 metascripts) to handle some global variables and some conditional logic. The end result is something like this: !{{   {&global ([spellRange] ?{Range|Heal: Touch (1 Action),HealTouch|Damage: Touch (1 Action),DmgTouch|Heal: 30ft Single Target,Heal30ftSingle|Damage: 30ft Single Target,Dmg30ftSingle|60ft Cone AoE (2 Actions),60ftAoE|30ft AoE (2 actions),30ftAoE}) ([baseRoll] [[1d10]]) ([ongoingDmg] ?{Ongoing damage|0|1|2|3|4|5|6|7|8|9|10})}   {\&global ([dmgRoll] [\][\]baseRoll + ongoingDmg \]\]) ([baseSingleRoll] [\][\]baseRoll + 8\]\]) }   {&template:default}({)name=@{character_name} Casts Healing{&if spellRange ~ Dmg} for Damage!{&end}(})({)Range={&if spellRange ~ Touch}Touch{&elseif spellRange ~ 30ftSingle}30ft, Single Target (2 Actions){&elseif spellRange = 60ftAoE}60ft Cone AoE (2 Actions){&else}30ft AoE (2 Actions){&end}(}) {&if spellRange ~ Heal || spellRange ~ AoE} ({)Healing={&if spellRange ~ Touch}baseRoll to touched target{&elseif spellRange ~ 30ftSingle}baseSingleRoll to a single target within 30ft{&elseif spellRange = 60ftAoE}baseRoll to living creatures in a 60ft cone{&else}baseRoll to living creatures in a 30ft emanation{&end}(}) {&end} {&if spellRange ~ Dmg} ({)Damage=dmgRoll to target Undead or Fiend(}) ({)Ongoing Damage=[\\][\\]ongoingDmg\\]\\] persistent fire damage to target Undead or Fiend(}) {&elseif spellRange ~ AoE} ({)Damage=dmgRoll to Undead and Fiends in a {&if spellRange ~ 60}60ft cone{&else}30ft emanation{&end}(}) ({)Ongoing Damage=Sets Undead and Fiends on fire for [\\][\\]ongoingDmg\\]\\] persistent fire damage(}) {&end} {&if spellRange !~ Heal}({)Basic Fortitude Save DC=@{spell_dc}(}){&end} }} This bundles up Range and  Purpose into a single choice (touch healing, touch damage, range healing single, range damage single, range cone, and range emanation), then prompts for an ongoing damage amount between 0 and 10. Here are some screenshots of each option being run, and the typical output you get (I chose different ongoing damages for these). Here are Healing Touch and Damage Touch, run back to back: And here are the ranged versions of Heal Single and Damage Single: And finally the two AoE options, 60 ft Cone and 30ft Emanation: The only thing I don't like about this is that you get prompted for the ongoing damage even if you cast the spell for healing, but that's a quirk of Roll20 queries you'd have to live with, for now, if you go this route. It gives me an idea for global variable declaration where you can do parsing of strings, but that will take a minute to put together. For now, like I said, this would require ZeroFrame (and the associated support scripts: libInline, Messenger, libTokenMarkers), and APILogic.