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

Using Power Cards with 5e OGL Companion to track ammo

Everything is working great now with Craven's assistance on understanding Power Cards but now I am trying to implement part of the 5e OGL Companion API into my Power Card as I love the Power Card look over the 5e OGL template. In my macro, the Power Card calculates damage and automatically reduces the targets HP but I need to make sure the ranged ammo (dagger) gets reduced too. Daggers are listed in @{repeating_resource_$0_resource_right} (2nd row, right) on the Core tab. Currently: !power {{ --titlefontshadow|none --tokenid|@{selected|token_id} --format|atwill --corners|10 --name|Dagger --leftsub|Ranged Attack --rightsub|Dagger --Range| 20' / 60' --Attack|[[ [$Atk] ?{Advantage?| Normal, 1d20 + [[@{selected|dexterity_mod}]] [DEX] + [[@{selected|pb}]] [PROF]] | Advantage, 2d20KH1 + [[@{selected|dexterity_mod}]] [DEX] + [[@{selected|pb}]] [PROF]] | Disadvantage, 2d20KL1 + [[@{selected|dexterity_mod}]] [DEX] + [[@{selected|pb}]] [PROF]]} ]] vs **AC** [[@{target||npc_ac}]] --?? $Atk < @{target||npc_ac} ?? !Missed|**You missed!** --?? $Atk >= @{target||npc_ac} AND $Atk.base <> 20 ?? Hit:|[[ [$Dmg] 1d4 + [[@{selected|dexterity_mod}]] ]] piercing damage --?? $Atk >= @{target||npc_ac} AND $Atk.base <> 20 ?? alterbar1|_target|@{target||token_id} _bar|3 _amount|-[^Dmg] _show|all --?? $Atk.base == 20 ?? Critical Hit:|[[ [$CritDmg] 2d4+[[@{selected|dexterity_mod}]] ]] piercing damage --?? $Atk.base == 20 ?? alterbar2|_target|@{target||token_id} _bar|3 _amount|-[^CritDmg] _show|all --?? $Atk.base == 1 ?? !|**Fumble:** --Daggers Left:|[[@{repeating_resource_$0_resource_right}-1]] }}
Has anyone thought of how this could be done?
1512901475
Jakob
Sheet Author
API Scripter
You probably cannot use the Companion script to do this, but Ammo or ChatSetAttr could do the trick. I'm slightly biased in favour of CSA, the command would be !modattr --charid @{character_id} --repeating_resource_$0_resource_right|-1
1512902397

Edited 1512902549
I looked at that actually but am running into the issue that it won't input into a Power Card easily: Code: !power {{ --titlefontshadow|none --tokenid|@{selected|token_id} --format|atwill --corners|10 --name|Caim --leftsub|Ranged Attack --rightsub|Dagger --Range| 20' / 60' --Attack|[[ [$Atk] ?{Advantage?| Normal, 1d20 + [[@{selected|dexterity_mod}]] [DEX] + [[@{selected|pb}]] [PROF]] | Advantage, 2d20KH1 + [[@{selected|dexterity_mod}]] [DEX] + [[@{selected|pb}]] [PROF]] | Disadvantage, 2d20KL1 + [[@{selected|dexterity_mod}]] [DEX] + [[@{selected|pb}]] [PROF]]} ]] vs **AC** [[@{target||npc_ac}]] --?? $Atk < @{target||npc_ac} ?? !Missed|**You missed!** --?? $Atk >= @{target||npc_ac} AND $Atk.base <> 20 ?? Hit:|[[ [$Dmg] 1d4 + [[@{selected|dexterity_mod}]] ]] piercing damage --?? $Atk >= @{target||npc_ac} AND $Atk.base <> 20 ?? alterbar1|_target|@{target||token_id} _bar|3 _amount|-[^Dmg] _show|all --?? $Atk.base == 20 ?? Critical Hit:|[[ [$CritDmg] 2d4+[[@{selected|dexterity_mod}]] ]] piercing damage --?? $Atk.base == 20 ?? alterbar2|_target|@{target||token_id} _bar|3 _amount|-[^CritDmg] _show|all --?? $Atk.base == 1 ?? !|**Fumble:** !modattr --charid @{character_id} --repeating_resource_$0_resource_right|-1 }} Output:
1512904174

Edited 1512904607
Jakob
Sheet Author
API Scripter
You need to put it on a new line after the whole power card. EDIT: And add --silent once you know it works to suppress output.
OK. A few minor edits later and I finally have the result I wanted: Code: !modattr --charid @{character_id} --repeating_resource_$0_resource_right|-1 --silent !power {{ --titlefontshadow|none --tokenid|@{selected|token_id} --format|encounter --corners|10 --name|Caim --leftsub|Ranged Attack --rightsub|Dagger --Range| 20' / 60' --Attack|[[ [$Atk] ?{Advantage?| Normal, 1d20 + [[@{selected|dexterity_mod}]] [DEX] + [[@{selected|pb}]] [PROF]] | Advantage, 2d20KH1 + [[@{selected|dexterity_mod}]] [DEX] + [[@{selected|pb}]] [PROF]] | Disadvantage, 2d20KL1 + [[@{selected|dexterity_mod}]] [DEX] + [[@{selected|pb}]] [PROF]]} ]] vs **AC** [[@{target||npc_ac}]] --?? $Atk < @{target||npc_ac} ?? !Missed|**You missed!** --?? $Atk >= @{target||npc_ac} AND $Atk.base <> 20 ?? Hit:|[[ [$Dmg] 1d4 + [[@{selected|dexterity_mod}]] ]] piercing damage --?? $Atk >= @{target||npc_ac} AND $Atk.base <> 20 ?? alterbar1|_target|@{target||token_id} _bar|3 _amount|-[^Dmg] _show|all --?? $Atk.base == 20 ?? Critical Hit:|[[ [$CritDmg] 2d4+[[@{selected|dexterity_mod}]] ]] piercing damage --?? $Atk.base == 20 ?? alterbar2|_target|@{target||token_id} _bar|3 _amount|-[^CritDmg] _show|all --?? $Atk.base == 1 ?? !|**Fumble:** --Daggers Left:|[[@{repeating_resource_$0_resource_right}-1]] }} Output:
1512905909
Jakob
Sheet Author
API Scripter
Awesome! By the way, since you're running this from an ability anyway, you can get rid of all the "selected|" statements, then it will work even if you don't have the token selected. So just @{pb} instead of @{selected|pb}, and so on.
My Power Card requires a selection for self vs target so it really doesn't matter either way.