Hi all, I'm trying to make a groupcheck scriptcard pretty similar to the script api, but that takes into consideration the immunities/resistances/vulnerabilities, and then have a button at the end of the first part of the scriptcard to applydamage... So here's where i'm at for my demand but I have a few issues that
i'll lisst after the code (i've used the Burning hands from kurt as a
base) !script {{ --/|Demande quel JP, quel DD, quels degats, quel effet sauvegarde, quel type dégats --=saveType|?{Quel JP?|Dexterité,dex|Constitution,con|Sagesse,wis} --=DC|?{DD ?|15} --=Damage|?{Dégats} --=DCeffect|?{Effet Sauvegarde ?|Annule,annule|Demi dégats,demi} --=damageType|?{Quel type de Dégats ?|Acide,acid|Contondant,bludgeoning|Feu,fire|Force,force|Foudre,lightning|Froid,cold|Nécrotique,necrotic|Perforant,piercing|Poison,poison|Psychique,psychic|Radiant,radiant|Tonnerre,thunder|Tranchant,slashing} --/|Get all of the tokens on the page so we can cache their positions --~|array;pagetokens;alltokens;@{selected|token_id} --#leftsub|DD [$DC] --#rightsub|Dégats: [$Damage] --#title|JP de Groupe --#titleCardBackground|#03038a --#oddRowBackground|#d8d8e6 --#evenRowBackground|#FFFFFF --#whisper|gm --/|Calculate damage --=HalfDamage|[$Damage.Total] \ 2 --=DoubleDamage|[$Damage.Total] * 2 --=QuarterDamage|[$Damage.Total] \ 4 --/|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] --+| --/|Create an array with the selected token --~tokenid|array;selectedtokens;Selected --/|The first item in the array will be a blank dummy item, so remove it. --~|array;removeat;selected;0 --/|Loop through the tokensHit tokens and roll saves for each one and apply damage --~tokenid|array;getfirst;Selected --?[&tokenid] -eq ArrayError|endOutput --:loopDisplay| --=SaveRoll|1d20 + [*[&tokenid]:npc_[&saveType]_save] --/|Compare the save roll to the save DC and either apply full or half damage --?"[*[&tokenid]:npc_immunities]" -inc "[&damageType]"|Immune --?"[*[&tokenid]:npc_resistances]" -inc "[&damageType]"|Resistant --?"[*[&tokenid]:npc_vulnerabilities]" -inc "[&damageType]"|Vulnerable --?[$SaveRoll.Total] -lt [&DC]|>ApplyDamageTokenmod;[&tokenid];1;-[$Damage.Total]|>ApplyDamageTokenmod;[&tokenid];1;-[$HalfDamage.Total] --?[$SaveRoll.Total] -ge [&DC]|madeSave --/|Here are various damage applications if the creature is immune, resistant, or vulnerable. In some cases, we will reuse output lines, --/|for example, a resistant creature that fails its save will jump to "madeSave", since that is the correct damage amount. (half), while --/|a vulnerable creature that makes its save will jump to "FailedSave" since that will be normal damage. --/|Output a line for a failed saving throw (we will also jump here for a vulnerable creature that MAKES its save) --:FailedSave| --+[*[&tokenid]:t-name]:|Save [$SaveRoll] [r][$Damage] [&damageType][/r] --^afterSave| --:Immune| --+[*[&tokenid]:t-name]:|n'est pas affecté par le sort ! --^afterSave| --:Resistant| --?[$SaveRoll.Total] -lt [&DC]|>ApplyDamageTokenmod;[&tokenid];1;-[$HalfDamage.Total]|>ApplyDamageTokenmod;[&tokenid];1;-[$QuarterDamage.Total] --?[$SaveRoll.Total] -lt [&DC]|madeSave --+[*[&tokenid]:t-name]:|Save [$SaveRoll] [r][$QuarterDamage] [&damageType][/r] --^afterSave| --:Vulnerable| --?[$SaveRoll.Total] -lt [&DC]|>ApplyDamageTokenmod;[&tokenid];1;-[$DoubleDamage.Total]|>ApplyDamageTokenmod;[&tokenid];1;-[$Damage.Total] --?[$SaveRoll.Total] -ge [&DC]|FailedSave --+[*[&tokenid]:t-name]:|Save [$SaveRoll] [r][$DoubleDamage] [&damageType][/r] --^afterSave| --/|Output a line for a successful saving throw --:madeSave| --+[*[&tokenid]:t-name]:|Save [$SaveRoll] [r][$HalfDamage] [&damageType][/r] --:afterSave| --~tokenid|array;getnext;Selected --?[&tokenid] -ne ArrayError|loopDisplay --:endOutput| --X| --:ApplyDamageTokenmod|Parameters are tokenid;bar#;amount --@token-mod|_ignore-selected _ids [%1%] _set bar[%2%]_value|[%3%] --<| }} So here are the issues i see so far (there might be more but i haven't tried every option yet) Damage calculation is always a quarter even if the creature made the save The bonus isn't calculated (always undefined) immunities are not noted when applyable, and thus damage still a quarter. FYI, i'm using the 5e OGL sheet According
to my script, when i prompt to dc effect, there's a possibilty to have
none damage (so basically same as immune) if i select "annule" but i
don't know how to get that in the loop. I'm also using a prompted DC because the selected token are the victims, not the caster... Also, i'd like to add a button at the bottom of the card, so i can click on it to THEN apply damages and not automatically. For the moment, the dmages are applied automatically, but i really don't know where and how in the script i can create this button or clickable line. I already know that my array for selected tokens is probably wrong, but i ca,'t find where it's wrong or what is the correct syntax. That array problem is probably why the bonus calculation isn't correct too... Hope you can help me correct what 'im doing wrong (and i'm sure there are quite a few mistakes unfortunately...) Thx