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

Trying to "Apply Damage" for Fireball

How do I get Kurt Jaegers Version 1.1 5e Fireball script to apply damage? I am using Scriptcards on 5e 2014 character sheets with Jumpgate.&nbsp; Currently a player will run the Fireball Script and the after I will have to run GroupCheck&nbsp; so I can apply damage to all with just a click.&nbsp;&nbsp; The Fireball script is&nbsp; &nbsp; --/|Script Name : 5E Fireball &nbsp; --/|Version&nbsp; &nbsp; &nbsp;: 1.1 &nbsp; --/|Requires SC : 1.3.1+ &nbsp; --/|Author&nbsp; &nbsp; &nbsp; : Kurt Jaegers &nbsp; There is a line that says its supposed to apply damage combatable with Token Mod (I am using Token mod) &nbsp; --/|Subroutine to apply damage with TokenMod. Could be replcaed with alterbars or chatsetattr &nbsp; --:ApplyDamageTokenmod|Parameters are tokenid;bar#;amount &nbsp; --@token-mod|_ignore-selected _ids [%1%] _set bar[%2%]_value|[%3%] &nbsp; --&lt;| but it does not apply damage and I don't know coding enough to know what's broken.&nbsp; Here is a link to the full Fireball script if you need that:&nbsp; <a href="https://github.com/kjaegers/ScriptCards/blob/main/ScriptCards_Examples/dnd5e/5e_Spell_Fireball.txt" rel="nofollow">https://github.com/kjaegers/ScriptCards/blob/main/ScriptCards_Examples/dnd5e/5e_Spell_Fireball.txt</a> Extra info:&nbsp; I tried to just pull out the lines from GroupCheck (Jakob) but that code is even further beyond me.&nbsp;&nbsp; ... ~saves RESULTS(,) ~ids IDS(,) ... WTH???? pure sorcery.
So that ScriptCard you posted does not actually call that&nbsp;ApplyDamageTokenmod label in the ScriptCard. ScriptCards process top to bottom but when they hit `--X|` it stops processing so anything below that will need to be called specifically. So above that ApplyDamageTokenmod is a MakeSavingThrow and that is called above and returns when it hits the `--&lt;|` So if you want to use that to apply damage with TokenMod you can. Alternatively ScriptCards can now adjust token properties or attributes on its own without need of any other Mods being installed. Also that token-mod line doesn't have a minus sign so it would not subtract the damage, it would set it. So with a couple small changes here is that ScriptCard but set to subtract the fireball damage from each token assuming the HP is linked via bar 1 !script {{ --/|CONFIGURATION --&amp;HPBar|1 --/|Script Name : 5E Fireball --/|Version : 1.1 --/|Requires SC : 1.3.1+ --/|Author : Kurt Jaegers --/|Description : Deals fireball damage to all tokens that represent creations in a 20' radius around target token --/|Set up the card appearance --#title|@{selected|character_name} casts Fireball! --#bodyFontSize|12px --#titlecardbackground|#800000 --#leftsub|Save DC @{selected|spell_save_dc} --/|Get a spell slot level from the caster. --=SpellLevel|?{Spell Slot Level?|3|4|5|6|7|8|9} --#rightsub|Slot Level: [$SpellLevel] --/|Calculate damage based on spell slot. Fireball is 8d6 for 3rd level, so 5+SpellLevel d6 total. --=DamageDice|[$SpellLevel.Total] + 5 --=Damage|[$DamageDice.Total]d6 --=HalfDamage|[$Damage.Total] \ 2 --/|Since we want to be able to hover over a roll and see the dice details, output the rolled damage at the --/|top of the card. If all critters make their save, the half damage roll won't contain the details. --+|[c][b]Damage Roll: [/b][$Damage][/c] --+|&amp;nbsp; --/|Get all tokens on the page into the "alltokens" array --~|array;pagetokens;alltokens;@{target|token_id} --/|Create the "inRange" array. It will have a blank item in it to begin with, which we will remove later. --~|array;define;inRange; --/|Loop through all of the tokens in "alltokens" to check their distance --~tokenid|array;getfirst;alltokens --?[&amp;tokenid] -eq ArrayError|endOutput --:loopCheck| --/|Skip targets that are not on the token layer or that don't represent creatures --?[*[&amp;tokenid]:t-layer] -ne objects|continue --?"[*[&amp;tokenid]:t-represents]" -ninc "-"|continue --/|Check the distance between the target token and the current array token. 20 feet is 4 units --~dist|distance;@{target|token_id};[&amp;tokenid] --?[$dist] -gt 4|continue --/|If we didn't skip over this part, the token is within 20 feet, so add it to the inRange array --~|array;add;inRange;[&amp;tokenid] --:continue| --~tokenid|array;getnext;alltokens --?[&amp;tokenid] -ne ArrayError|loopCheck --/|Remove the dummy first item in the inRange array --~|array;removeat;inRange;0 --/|Loop through the inRange tokens and roll saves for each one and apply damage --~tokenid|array;getfirst;inRange --?[&amp;tokenid] -eq ArrayError|endOutput --:loopDisplay| --&gt;MakeSavingThrow|[&amp;tokenid];dexterity;@{selected|spell_save_dc};[$Damage.Total];fire;thisTokenDamage;saveResult;dex --+[*[&amp;tokenid]:character_name]:|Save [$savingThrow] [r][$thisTokenDamage] fire damage[/r] --&gt;ApplyDamageTokenmod|[&amp;tokenid];[&amp;HPBar];[$thisTokenDamage.Raw] --/|Put a burn-fire visual effect on impacted tokens --vtoken|[&amp;tokenid] burn-fire --/|Get the next token and continue the loop until we run out. --~tokenid|array;getnext;inRange --?[&amp;tokenid] -ne ArrayError|loopDisplay --/|Add some extra visual effects - a nova-fire at the target, and a beam-fire from source to target --vtoken|@{target|token_id} nova-fire --vbetweentokens|@{selected|token_id} @{target|token_id} beam-fire --:endOutput| --X| --/|Subroutine to make saving throws and calculate damage amounts --:MakeSavingThrow|tokenid;savetype;dc;damage;damagetype;damagevariable;saveresultvariable;shortabilityname --?"X[*[%1%]:npc_[%8%]_save_base]" -eq "X"|&gt;set_string;baseSaveBonus;|&gt;set_string;baseSaveBonus; + + [*[%1%]:npc_[%8%]_save_base] --=savingThrow|1d20 + [*[%1%]:[%2%]_save_bonus] [&amp;baseSaveBonus] --&amp;dmgmult| --?[$savingThrow] -ge [%3%]|&gt;set_string;dmgmult; \ 2 --?[$savingThrow] -lt [%3%]|&gt;set_string;[%7%];fail --?[$savingThrow] -ge [%3%]|&gt;set_string;[%7%];success --?"[*[%1%]:npc_resistances]" -inc "[%5%]" -and [$savingThrow] -lt [%3%]|&gt;set_string;dmgmult; \ 2 --?"[*[%1%]:npc_resistances]" -inc "[%5%]" -and [$savingThrow] -ge [%3%]|&gt;set_string;dmgmult; * 0 --?"[*[%1%]:npc_vulnerabilities]" -inc "[%5%]" -and [$savingThrow] -ge [%3%]|&gt;set_string;dmgmult; --?"[*[%1%]:npc_vulnerabilities]" -inc "[%5%]" -and [$savingThrow] -lt [%3%]|&gt;set_string;dmgmult; * 2 --?"[*[%1%]:npc_immunities]" -inc "[%5%]"|&gt;set_string;dmgmult; * 0 --=[%6%]|[%4%] [&amp;dmgmult] --&lt;| --:set_string|mod_variable;value --&amp;[%1%]|[%2%] --&lt;| --/|Subroutine to apply damage with TokenMod. Could be replcaed with alterbars or chatsetattr --:ApplyDamageTokenmod|Parameters are tokenid;bar#;amount --@token-mod|_ignore-selected _ids [%1%] _set bar[%2%]_value|-[%3%] --&lt;| }} Just change&nbsp;--&amp;HPBar|1 at the top of the ScriptCard to match whatever bar you use for HP. This is the line that needed to be added to call the ApplyDamage --&gt;ApplyDamageTokenmod|[&amp;tokenid];[&amp;HPBar];[$thisTokenDamage.Raw] That was the main change, then added a minus sign to the token-mod set bar value to subtract the damage rolled and added the HPBar variable. That all works for me in a quick test. Let me know if you have any questions.
@Joshua&nbsp; &nbsp;Thank you for taking the time to look at this.&nbsp; I cut and pasted&nbsp; the above but it is still not subtracting damage&nbsp;:(
Can you take a screenshot of your token setup? Do you have HP mapped to bar number 1? Presumably you have both ScriptCards and TokenMod mods installed but do you have TokenMod configured to allow players to use IDs? You can check that with: !token-mod --config It should be set to ON like so:
I pulled a section out of the Updated Magic Missile for the Apply Damage subroutine&nbsp; and it started adding damage then I change thi: --&gt;ApplyDamageTokenmod|[&amp;tokenid];[&amp;HPBar];[$thisTokenDamage.Raw] to&nbsp; --&gt;ApplyDamageTokenmod|[&amp;tokenid];[&amp;HPBar];-[$thisTokenDamage.Raw] &nbsp;and now it works.&nbsp; !script {{ --/|CONFIGURATION --&amp;HPBar|1 --/|Script Name : 5E Fireball --/|Version : 1.1 --/|Requires SC : 1.3.1+ --/|Author : Kurt Jaegers --/|Description : Deals fireball damage to all tokens that represent creations in a 20' radius around target token --/|Set up the card appearance --#title|@{selected|character_name} casts Fireball! --#bodyFontSize|12px --#titlecardbackground|#800000 --#leftsub|Save DC @{selected|spell_save_dc} --/|Get a spell slot level from the caster. --=SpellLevel|?{Spell Slot Level?|3|4|5|6|7|8|9} --#rightsub|Slot Level: [$SpellLevel] --/|Calculate damage based on spell slot. Fireball is 8d6 for 3rd level, so 5+SpellLevel d6 total. --=DamageDice|[$SpellLevel.Total] + 5 --=Damage|[$DamageDice.Total]d6 --=HalfDamage|[$Damage.Total] \ 2 --/|Since we want to be able to hover over a roll and see the dice details, output the rolled damage at the --/|top of the card. If all critters make their save, the half damage roll won't contain the details. --+|[c][b]Damage Roll: [/b][$Damage][/c] --+|&amp;nbsp; --/|Get all tokens on the page into the "alltokens" array --~|array;pagetokens;alltokens;@{target|token_id} --/|Create the "inRange" array. It will have a blank item in it to begin with, which we will remove later. --~|array;define;inRange; --/|Loop through all of the tokens in "alltokens" to check their distance --~tokenid|array;getfirst;alltokens --?[&amp;tokenid] -eq ArrayError|endOutput --:loopCheck| --/|Skip targets that are not on the token layer or that don't represent creatures --?[*[&amp;tokenid]:t-layer] -ne objects|continue --?"[*[&amp;tokenid]:t-represents]" -ninc "-"|continue --/|Check the distance between the target token and the current array token. 20 feet is 4 units --~dist|distance;@{target|token_id};[&amp;tokenid] --?[$dist] -gt 4|continue --/|If we didn't skip over this part, the token is within 20 feet, so add it to the inRange array --~|array;add;inRange;[&amp;tokenid] --:continue| --~tokenid|array;getnext;alltokens --?[&amp;tokenid] -ne ArrayError|loopCheck --/|Remove the dummy first item in the inRange array --~|array;removeat;inRange;0 --/|Loop through the inRange tokens and roll saves for each one and apply damage --~tokenid|array;getfirst;inRange --?[&amp;tokenid] -eq ArrayError|endOutput --:loopDisplay| --&gt;MakeSavingThrow|[&amp;tokenid];dexterity;@{selected|spell_save_dc};[$Damage.Total];fire;thisTokenDamage;saveResult;dex --+[*[&amp;tokenid]:character_name]:|Save [$savingThrow] [r][$thisTokenDamage] fire damage[/r] --&gt;ApplyDamageTokenmod|[&amp;tokenid];[&amp;HPBar];-[$thisTokenDamage.Raw] --/|Put a burn-fire visual effect on impacted tokens --vtoken|[&amp;tokenid] burn-fire --/|Get the next token and continue the loop until we run out. --~tokenid|array;getnext;inRange --?[&amp;tokenid] -ne ArrayError|loopDisplay --/|Add some extra visual effects - a nova-fire at the target, and a beam-fire from source to target --vtoken|@{target|token_id} nova-fire --vbetweentokens|@{selected|token_id} @{target|token_id} beam-fire --:endOutput| --X| --/|Subroutine to make saving throws and calculate damage amounts --:MakeSavingThrow|tokenid;savetype;dc;damage;damagetype;damagevariable;saveresultvariable;shortabilityname --?"X[*[%1%]:npc_[%8%]_save_base]" -eq "X"|&gt;set_string;baseSaveBonus;|&gt;set_string;baseSaveBonus; + + [*[%1%]:npc_[%8%]_save_base] --=savingThrow|1d20 + [*[%1%]:[%2%]_save_bonus] [&amp;baseSaveBonus] --&amp;dmgmult| --?[$savingThrow] -ge [%3%]|&gt;set_string;dmgmult; \ 2 --?[$savingThrow] -lt [%3%]|&gt;set_string;[%7%];fail --?[$savingThrow] -ge [%3%]|&gt;set_string;[%7%];success --?"[*[%1%]:npc_resistances]" -inc "[%5%]" -and [$savingThrow] -lt [%3%]|&gt;set_string;dmgmult; \ 2 --?"[*[%1%]:npc_resistances]" -inc "[%5%]" -and [$savingThrow] -ge [%3%]|&gt;set_string;dmgmult; * 0 --?"[*[%1%]:npc_vulnerabilities]" -inc "[%5%]" -and [$savingThrow] -ge [%3%]|&gt;set_string;dmgmult; --?"[*[%1%]:npc_vulnerabilities]" -inc "[%5%]" -and [$savingThrow] -lt [%3%]|&gt;set_string;dmgmult; * 2 --?"[*[%1%]:npc_immunities]" -inc "[%5%]"|&gt;set_string;dmgmult; * 0 --=[%6%]|[%4%] [&amp;dmgmult] --&lt;| --:set_string|mod_variable;value --&amp;[%1%]|[%2%] --&lt;| --/|Subroutine to apply damage with TokenMod. Could be replcaed with alterbars or chatsetattr --:ApplyDamageTokenmod|Parameters are tokenid;bar#;amount --@token-mod|_ignore-selected _ids [%1%] _set bar[%2%]_value|-[%3%] --:ApplyDamageScriptCards|Parameters are tokenid;bar#;amount --=applyValue|[%3%] --=newValue|[*[%1%]:t-bar[%2%]_value] + [$applyValue] --?[$newValue] -lt 0|=newValue;0 --?[$newValue] -gt [*[%1%]:t-bar[%2%]_max]|=newValue;[*[%1%]:t-bar[%2%]_max] --!t:[%1%]|bar[%2%]_value:[$newValue.Raw] --&lt;| }}
My IDs are set to off TokenMod v0.8.85 Players can IDs is currently&nbsp; OFF Toggle
1765792961

Edited 1765793733
Kofi said: My IDs are set to off TokenMod v0.8.85 Players can IDs is currently&nbsp; OFF Toggle Hiya, ScriptCards can natively deduct damage and whilst you can add the code for it to your script, I personally prefer making the libraries Kurt recommends, that way you only have one place to edit code should it change.&nbsp; Libraries are Handouts titled ScriptCards Library &lt;Title&gt; and are very definitely case sensitive.&nbsp; If you copy the text for SNlib and 5elib and make those in your game life will become very sweet. then add this as the first line of your script - there's a 3rd library there, not needed today, but worth also making though Kurt is phasing it out +++5Elib;snlib;dnd5elib+++ Next, if you want to autodeduct spell slots, set up your source with this line nice and early --#sourceToken|@{selected|token_id} then set this bit to --/|Get a spell slot level from the caster. --=SpellLevel|?{Spell Slot Level?|3|4|5|6|7|8|9} --#rightsub|Slot Level: [$SpellLevel] --&gt;Lib5E_EXPEND_SPELL_SLOT|[*S:character_id];[$SpellLevel] for damage application change this section to read --/|Loop through the inRange tokens and roll saves for each one and apply damage --~tokenid|array;getfirst;inRange --?[&amp;tokenid] -eq ArrayError|endOutput --:loopDisplay| --&gt;MakeSavingThrow|[&amp;tokenid];dexterity;@{selected|spell_save_dc};[$Damage.Total];fire;thisTokenDamage;saveResult;dex --/|Subroutine to apply damage with ScriptCards. Could be replaced with tokenmod, alterbars or chatsetattr --&gt;LibSN_APPLY_DAMAGE_OR_HEALING|[&amp;tokenid];1;-[$thisTokenDamage];0 --+[*[&amp;tokenid]:character_name]:|Save [$savingThrow] [r][$thisTokenDamage] fire damage[/r] and finally, when I tested this (I use SmartAoE instead, but that's just a preference, both do the deed) the saves were doing some funky things - retaining the previous tokens Dex modifier and adding that to their own etc and so I changed it to this --:MakeSavingThrow|tokenid;savetype;dc;damage;damagetype;damagevariable;saveresultvariable;shortabilityname --/|Subroutine to make saving throws and calculate damage amounts --/|let's check target to see if they have an enhanced save eg Assassin with Dex +6 not +3 --&amp;SaveType|dex --c[&amp;SaveType]|str:&amp;Save2;strength|dex:&amp;Save2;dexterity|con:&amp;Save2;constitution|int:&amp;Save2;intelligence|wis:&amp;Save2;wisdom|cha:&amp;Save2;charisma --?[*[&amp;tokenid]:npc] -eq 1 -and [*[&amp;tokenid]:npc_[&amp;SaveType]_save_flag] -gt 0|&amp;Save;npc_[&amp;SaveType]_save|&amp;Save;[&amp;Save2]_save_bonus --=savingThrow|1d20 + [*[&amp;tokenid]:[&amp;Save]] --&amp;dmgmult| --?[$savingThrow] -ge [%3%]|&gt;set_string;dmgmult; \ 2 --?[$savingThrow] -lt [%3%]|&gt;set_string;[%7%];fail --?[$savingThrow] -ge [%3%]|&gt;set_string;[%7%];success --?"[*[%1%]:npc_resistances]" -inc "[%5%]" -and [$savingThrow] -lt [%3%]|&gt;set_string;dmgmult; \ 2 --?"[*[%1%]:npc_resistances]" -inc "[%5%]" -and [$savingThrow] -ge [%3%]|&gt;set_string;dmgmult; * 0 --?"[*[%1%]:npc_vulnerabilities]" -inc "[%5%]" -and [$savingThrow] -ge [%3%]|&gt;set_string;dmgmult; --?"[*[%1%]:npc_vulnerabilities]" -inc "[%5%]" -and [$savingThrow] -lt [%3%]|&gt;set_string;dmgmult; * 2 --?"[*[%1%]:npc_immunities]" -inc "[%5%]"|&gt;set_string;dmgmult; * 0 --=[%6%]|[%4%] [&amp;dmgmult] --&amp;baseSaveBonus| --&lt;| that dmgmult isn't really necessary, that can also be dealt with via a library if you want, but I just didn't want to make too many changes : ) Anyway, that's my two penneth, quick test looks OK to me