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

!ammo and Power Cards?

Has anyone been able to do something similar to this macro using The Aaron's !ammo API? I love what !ammo does, but I'd really like to issue the command inside of a PowerCard interface and can't figure out how. !power {{ --name|Potion --leftsub|1 Bonus Action --rightsub|Self --tokenid|@{selected|token_id} --emote|@{selected|character_name} drinks a potion of healing --?? $potion == 0 ?? |~C//**Potion of Healing, ^^ common//**~C --?? $potion == 1 ?? |~C//**Potion of Greater Healing, ^^uncommon//**~C --?? $potion == 2 ?? |~C//**Potion of Superior Healing ^^rare//**~C --?? $potion == 3 ?? |~C//**Potion of Supreme Healing, ^^very rare//**~C --hroll|[[ [$potion] ?{Type|Potion of Healing, 0|Potion of Greater Healing, 1|Potion of Superior Healing, 2|Potion of Supreme Healing, 3} +0d0 ]] --?? $potion == 0 ?? Result:|@{target|character_name} regains [[ [$Healing0] 2d4 +2 ]] hit points. --?? $potion == 1 ?? Result:|@{target|character_name} regains [[ [$Healing1] 4d4 +4 ]] hit points. --?? $potion == 2 ?? Result:|@{target|character_name} regains [[ [$Healing2] 8d4 +8 ]] hit points. --?? $potion == 3 ?? Result:|@{target|character_name} regains [[ [$Healing3] 10d4 +20 ]] hit points. --?? $potion == 0 ?? alterbar1|_target|@{target|token_id} _bar|1 _amount|[^Healing0] _show|none --?? $potion == 1 ?? alterbar1|_target|@{target|token_id} _bar|1 _amount|[^Healing1] _show|none --?? $potion == 2 ?? alterbar1|_target|@{target|token_id} _bar|1 _amount|[^Healing2] _show|none --?? $potion == 3 ?? alterbar1|_target|@{target|token_id} _bar|1 _amount|[^Healing3] _show|none }} When done, I'd like this to allow my players to select one fo their ranged weapons, shoot, and deduct ammo.
1562163325
Ziechael
Forum Champion
Sheet Author
API Scripter
Back in my 3.5 game I did ammo management as per this very complex macro (The bits in bold are the important areas of how I handled repeating sections for ammo.): !power {{ --format|attack --emote|@{selected|token_name} attacks @{target|token_name} --charid|@{selected|character_id} --name|@{selected|weapon2name} --leftsub|@{selected|weapon2type} --rightsub|Crit: x@{selected|weapon2critmult} --hroll|[[ [$ammo] ?{Ammo Type?|@{selected|repeating_ammunition_$0_ammoname},0|@{selected|repeating_ammunition_$1_ammoname},1|@{selected|repeating_ammunition_$2_ammoname},2|@{selected|repeating_ammunition_$3_ammoname},3|@{selected|repeating_ammunition_$4_ammoname},4|@{selected|repeating_ammunition_$5_ammoname},5|@{selected|repeating_ammunition_$6_ammoname},6} + 0d0]] --?? $ammo.base == 0 ?? !ammo0|**Ammunition used:** @{selected|repeating_ammunition_$0_ammoname} ^^ **Notes:** @{selected|repeating_ammunition_$0_ammonotes} --?? $ammo.base == 1 ?? !ammo1|**Ammunition used:** @{selected|repeating_ammunition_$1_ammoname} ^^ **Notes:** @{selected|repeating_ammunition_$1_ammonotes} --?? $ammo.base == 2 ?? !ammo2|**Ammunition used:** @{selected|repeating_ammunition_$2_ammoname} ^^ **Notes:** @{selected|repeating_ammunition_$2_ammonotes} --?? $ammo.base == 3 ?? !ammo3|**Ammunition used:** @{selected|repeating_ammunition_$3_ammoname} ^^ **Notes:** @{selected|repeating_ammunition_$3_ammonotes} --?? $ammo.base == 4 ?? !ammo4|**Ammunition used:** @{selected|repeating_ammunition_$4_ammoname} ^^ **Notes:** @{selected|repeating_ammunition_$4_ammonotes} --?? $ammo.base == 5 ?? !ammo5|**Ammunition used:** @{selected|repeating_ammunition_$5_ammoname} ^^ **Notes:** @{selected|repeating_ammunition_$5_ammonotes} --?? $ammo.base == 6 ?? !ammo6|**Ammunition used:** @{selected|repeating_ammunition_$6_ammoname} ^^ **Notes:** @{selected|repeating_ammunition_$6_ammonotes} ?{Attack Type?| Standard, --Standard Attack:|[[ [$att] 1d20 + @{selected|bab} + @{selected|size} + @{selected|weapon2stat} + @{selected|weapon2enh} + @{selected|bar3} + @{selected|weapon2focus} + @{Buff|attbuff} ]] vs [[ [$tac] @{target|armorclass} +0d0 ]] AC --?? $att.base == 1 ?? !fumble|[[ 1t[misstable] ]] ^^ **Fumble Check:** [[ [$fbl] 1d20 ]] --?? $att.base == 1 AND $fbl.base == 1 ?? !fumbled|[[ 1t[Fumble] ]] --?? $att.base <> 1 AND $att.total < $tac.total ?? !miss|[[ 1t[misstable] ]] --?? $att.base <> 1 AND $att.total >= $tac.total OR $att.base == 20 ?? !hit|[[ 1t[hittable] ]] ^^ [[ 1@{selected|weapon2damage} + @{selected|bar2} + @{selected|weapon2damagestat} + @{selected|weapon2enh} + @{selected|weapon2specialize} + @{Buff|dambuff} ]] @{selected|weapon2type} damage! --?? $att.base >= @{selected|weapon2critmin} ?? Critical Threat:| [[ [$crit] 1d20 + @{selected|bab} + @{selected|bar3} + @{selected|size} + @{selected|weapon2stat} + @{selected|weapon2enh} + @{selected|weapon2focus} + @{Buff|attbuff} ]] --?? $att.base >= @{selected|weapon2critmin} AND $crit.total >= $tac.total ?? Critical Hit:|Additional [[ [[ @{selected|weapon2critmult} -1 ]]@{selected|weapon2damage} ]] @{selected|weapon2type} damage! | BAB2, --BAB2:|[[ [$att] 1d20 + @{selected|bab2} + @{selected|size} + @{selected|weapon2stat} + @{selected|weapon2enh} + @{selected|bar3} + @{selected|weapon2focus} + @{Buff|attbuff} ]] vs [[ [$tac] @{target|armorclass} +0d0 ]] AC --?? $att.base == 1 ?? !fumble|[[ 1t[misstable] ]] ^^ **Fumble Check:** [[ [$fbl] 1d20 ]] --?? $att.base == 1 AND $fbl.base == 1 ?? !fumbled|[[ 1t[Fumble] ]] --?? $att.base <> 1 AND $att.total < $tac.total ?? !miss|[[ 1t[misstable] ]] --?? $att.base <> 1 AND $att.total >= $tac.total OR $att.base == 20 ?? !hit|[[ 1t[hittable] ]] ^^ [[ 1@{selected|weapon2damage} + @{selected|weapon2damagestat} + @{selected|weapon2enh} + @{selected|bar2} + @{selected|weapon2specialize} + @{Buff|dambuff} ]] @{selected|weapon2type} damage! --?? $att.base >= @{selected|weapon2critmin} ?? Critical Threat:| [[ [$crit] 1d20 + @{selected|bab2} + @{selected|size} + @{selected|weapon2stat} + @{selected|weapon2enh} + @{selected|bar3} + @{selected|weapon2focus} + @{Buff|attbuff} ]] --?? $att.base >= @{selected|weapon2critmin} AND $crit.total >= $tac.total ?? Critical Hit:|Additional [[ [[ @{selected|weapon2critmult} -1 ]]@{selected|weapon2damage} ]] @{selected|weapon2type} damage! | Sneak Attack, --Sneak Attack:|[[ [$att] 1d20 + @{selected|bab} + @{selected|bar3} + @{selected|size} + @{selected|weapon2stat} + @{selected|weapon2enh} + @{selected|weapon2focus} + @{Buff|attbuff} ]] vs [[ [$tac] @{target|armorclass} +0d0 ]] AC --?? $att.base == 1 ?? !fumble|[[ 1t[misstable] ]] ^^ **Fumble Check:** [[ [$fbl] 1d20 ]] --?? $att.base == 1 AND $fbl.base == 1 ?? !fumbled|[[ 1t[Fumble] ]] --?? $att.base <> 1 AND $att.total < $tac.total ?? !miss|[[ 1t[misstable] ]] --?? $att.base <> 1 AND $att.total >= $tac.total OR $att.base == 20 ?? !hit|[[ 1t[hittable] ]] ^^ [[ 1@{selected|weapon2damage} + @{selected|bar2} + @{selected|weapon2damagestat} + @{selected|weapon2enh} + @{selected|weapon2specialize} + @{Buff|dambuff} + [[ ceil(@{selected|level}/2) ]]d6 ]] @{selected|weapon2type} damage! --?? $att.base >= @{selected|weapon2critmin} ?? Critical Threat:| [[ [$crit] 1d20 + @{selected|bab} + @{selected|bar3} + @{selected|size} + @{selected|weapon2stat} + @{selected|weapon2enh} + @{selected|weapon2focus} + @{Buff|attbuff} ]] --?? $att.base >= @{selected|weapon2critmin} AND $crit.total >= $tac.total ?? Critical Hit:|Additional [[ [[ @{selected|weapon2critmult} -1 ]]@{selected|weapon2damage} ]] @{selected|weapon2type} damage! } --?? $att.base == 1 AND $fbl.base == 1 ?? soundfx1|_play,delay:2|critmiss --?? $att.base >= @{selected|weapon1critmin} AND $crit.total >= $tac.total ?? soundfx2|_play,delay:2|Critical Hit --Notes|@{selected|weapon2specialproperties} }} !power --name|SR: @{target|spellresistance} DR: @{target|damagereduction} --whisper|GM !playsound Arrow !ammo @{selected|token_id} repeating_ammunition_$?{Ammo Type?}_ammoquantity -1
So this is very nice, I'm not 100% sure I understand how this:  repeating_ammunition_$?{Ammo Type?}_ammoquantity calculates what ammo type you used, and reduces it. I don't use repeating fields, so for example assuming I only had a few... If I have two attribute fields: ranged1_ammoname which contains "bullet" ranged1_ammoquantity which contains "25" and so on Your Ammo Type? question will show "bullet" as my first option. However, when you get here: !ammo @{selected|token_id} repeating_ammunition_$?{Ammo Type?}_ammoquantity -1 How does that translate into: !ammo @{selected|token_id} ranged1_ammoquantity -1 How does $?{Ammo Type?} know to get the field name and the not field value? Am I making any sense?
1562174337
Ziechael
Forum Champion
Sheet Author
API Scripter
It's a bit of a learning curve i agree lol... will try to break it down into the important parts using relevant examples based on your use case. So first we set up a tag in powercards that assigns a numerical value to the query result using the names as labels in the query itself: --hroll|[[ [$ammo] ?{Ammo Type|@{selected|ranged1_ammoname},1|@{selected| ranged2_ammoname },2} + 0d0]] With is numerical value we can then display key information in the powercard itself: --?? $ammo.base == 0 ?? !ammo0|**Ammunition used:** @{selected|ranged1_ammoname}; Quantity Available: @{selected|ranged1_ammoquantity} And... because the query results in a numerical value and our attribute is only different based on that number we can influence the actions of ammo accordingly: !ammo @{selected|token_id} ranged?{Ammo Type}_ammoquantity -1 So in the above ?{Ammo Type} can only result in a 1 or a 2 which will resolve to being the right attribute depending on your choice... of course this can be expanded to any number of attributes as long as they follow a common naming convention with only a number as the difference :) I hope any of that makes sense!!!
OK, now this makes 100% sense...  I need to (example) name my weapons such as ranged1_name, ranged2_name, so that I can reference my ammo as ranged1_ammo, ranged2_ammo Perfect!