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

!Scriptcard auto damage help request

I've come a long way in scripting knowledge thanks to Joshua N. In the following script, everything seems too work except the auto damage. I've looked and looked but don't see the issue. Does anyone happen to see an issue?  Thank you :) !scriptcard  {{   --#title|Flame Blade   --#leftsub|Melee Attack   --#sourceToken|@{selected|token_id}   --#targetToken|@{target|token_id}   --#emoteText|@{selected|token_name} attacks @{target|token_name}   --=TargetAC|@{target|npc_ac}   --?[$TargetAC.Total] -gt 0|DoneWithAC   --=TargetAC|@{target|ac}   --:DoneWithAC| --=EnergyDice|1 --=EnergyDamageDiceSize|6 --= EnergyDamage|[$EnergyDice]d[$EnergyDamageDiceSize]   --=AttackRoll|?{Attack|Standard,1d20|Advantage,2d20kh1|Disadvantage,2d20kl1} + @{selected|strength_mod} [STR] + @{selected|pb} [PROF]   --+Attack|@{selected|token_name} rolls [$AttackRoll] vs AC [$TargetAC].   --?[$AttackRoll.Base] -eq 20|Crit   --?[$AttackRoll.Base] -eq 1|Fumble   --?[$AttackRoll.Total] -ge [$TargetAC.Total]|Hit   --+Miss|The attack missed.   --^Final|   --:Fumble|   --+Fumble!|The attack went horribly wrong.   --^Final|   --:Hit| --=Damage|1d8 + @{selected|strength_mod} [STR] --= AllDamageIncludingRegular |[$Damage] + [$EnergyDamage] --+ HIT|[$Damage] ``slashing`` damage plus [$EnergyDamage] ``fire`` damage for a total of [$AllDamageIncludingRegular] points of damage. --&AutoApplyDamage|true --&HPBar|1 --?"[&AutoApplyDamage]" -ne "true"|Done --!t:[*T:t-id]|bar[&HPBar]_value:-=[$ AllDamageIncludingRegular]   --^Final| --:Crit| --=Damage|1d8 + @{selected|strength_mod} [STR] --=CritDmg|1m8 [CRIT] --=TotalWeaponDmg|[$Damage] + [$CritDmg] [CRIT] --=AllDamageIncludingCritical|[$CritDmg] + [$Damage] + [$EnergyDamage] --+CRITICAL HIT|[$Damage] + [$CritDmg] for [$TotalWeaponDmg] ``slashing`` damage plus [$EnergyDamage] ``fire`` damage for a total of [$AllDamageIncludingCritical] points of damage. --&AutoApplyDamage|true --&HPBar|1 --?"[&AutoApplyDamage]" -ne "true"|Done --!t:[*T:t-id]|bar[&HPBar]_value:-=[$ AllDamageIncludingCritical]   --^Final|   --:Final| }}
1705273351

Edited 1705274053
So let me start with channeling my inner Gauss and say I think they want to post API/Mod specific questions in the Mods (API Scripts) Forum. Also  ScriptCards has its own thread that can be used for questions as well. Now on to your ScriptCard. I made some changes: !scriptcard {{ --/|VARIABLES TO SET --&AutoApplyDamage|true --&HPBar|1 --#title|Flame Blade --#leftsub|Melee Attack --#sourceToken|@{selected|token_id} --#targetToken|@{target|token_id} --#emoteText|@{selected|token_name} attacks @{target|token_name} --=TargetAC|@{target|npc_ac} --?[$TargetAC.Total] -gt 0|DoneWithAC --=TargetAC|@{target|ac} --:DoneWithAC| --=EnergyDice|1 --=EnergyDamageDiceSize|6 --=EnergyDamage|[$EnergyDice]d[$EnergyDamageDiceSize] --=AttackRoll|?{Attack|Standard,1d20|Advantage,2d20kh1|Disadvantage,2d20kl1} + @{selected|strength_mod} [STR] + @{selected|pb} [PROF] --+Attack|@{selected|token_name} rolls [$AttackRoll] vs AC [$TargetAC]. --?[$AttackRoll.Base] -eq 20|Crit --?[$AttackRoll.Base] -eq 1|Fumble --?[$AttackRoll.Total] -ge [$TargetAC.Total]|Hit --+Miss|The attack missed. --^Final| --:Fumble| --+Fumble!|The attack went horribly wrong. --^Final| --:Hit| --=Damage|1d8 + @{selected|strength_mod} [STR] --=AllDamageIncludingRegular|[$Damage] + [$EnergyDamage] --+HIT|[$Damage] ``slashing`` damage plus [$EnergyDamage] ``fire`` damage for a total of [$AllDamageIncludingRegular] points of damage. --?"[&AutoApplyDamage]" -ne "true"|Final --!t:[*T:t-id]|bar[&HPBar]_value:-=[$AllDamageIncludingRegular] --^Final| --:Crit| --=Damage|1d8 + @{selected|strength_mod} [STR] --=CritDmg|1m8 [CRIT] --=TotalWeaponDmg|[$Damage] + [$CritDmg] [CRIT] --=AllDamageIncludingCritical|[$CritDmg] + [$Damage] + [$EnergyDamage] --+CRITICAL HIT|[$Damage] + [$CritDmg] for [$TotalWeaponDmg] ``slashing`` damage plus [$EnergyDamage] ``fire`` damage for a total of [$AllDamageIncludingCritical] points of damage. --?"[&AutoApplyDamage]" -ne "true"|Final --!t:[*T:t-id]|bar[&HPBar]_value:-=[$AllDamageIncludingCritical] --^Final| --:Final| }} I'm not sure how much was changed since you didn't paste it in a code block so maybe the formatting was lost but you had a number of variable references that had spaces in them. Like  --!t:[*T:t-id]|bar[&HPBar]_value:-=[$ AllDamageIncludingCritical] and  --!t:[*T:t-id]|bar[&HPBar]_value:-=[$ AllDamageIncludingRegular]. So I got rid of all those spaces in variable references. I also moved  --&AutoApplyDamage|true and  --&HPBar|1 to the top of the script and removed the redundant variables you were setting in multiple locations. Since those are global for the whole ScriptCard it's generally better to set those once and not in multiple places throughout the script as that can break or not get set properly if you ever make changes to the script. Also your check for auto-apply damage was  --?"[&AutoApplyDamage]" -ne "true"|Done but you didn't have a code branch named Done in this ScriptCard. This ScriptCard uses a branch named Final. Done is my convention and Final is the convention of whoever wrote the example in the wiki so just need to pick one. In this case I removed the references to Done and replaced them with Final. After those changes it seems to work fine for me. You would want to confirm that your game has HP on the token bar 1. EDIT: A little bit more on the Done label there. If you were to check the Mod Output Console when running something like that you would see an error from ScriptCards similar to: "ScriptCards Error: Label Done is not defined on line And that would let you know you are trying to jump to an undefined label with the name Done. Just a bit of help when you are trying to troubleshoot your ScriptCards in development.
Thank you Joshua
You're welcome. I'll also mention this as you continue on your ScriptCards path. ScriptCards has the option to include code in handouts called  Libraries . This includes a D&D 5e library that Kurt J wrote that you can use to check for resistances, immunities, and vulnerabilities. This can come in handy especially when you are using auto-apply damage. So you could look at incorporating something like this eventually so that you aren't auto-applying say Fire damage to a Fire Elemental or something that is immune to Fire damage. Just something to check on as you keep learning and refining your ScriptCards.
Oh wow! that is great news. Thanks for sharing this