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 for what I think are If/Then statements within an If/Then?

1763871610

Edited 1763871647
Dink
Pro
Not the greatest at searching for references, and I've searched but can't find reference to this problem.... if there is already a post,.. please direct me to it.. Can't get a script to work... e.g.  Script asks type of attack... Normal, Advantage, Disadvantage  and rolls accordingly,..  the If/Then is... if  roll is 1 - Fumble section if roll is 20 - Crit section If roll is >Target AC - Hit section... default if none of above. - Miss How do i implement as question of whether the target is hexxed or not?  so to add another set of the above, but split into two versions in order to not have to have separate token buttons for normal attack and attack against a hexxed foe?   when I try to do same "If/Then".... it either just doesn't work at all.. or it flows through and uses the last entry which would be the Crit section of the Hexxed section... e.g. !scriptcard {{ --lSettings|BlahBlah --/| Polearm Master --#title|BlahBlah --#leftsub|Bonus Melee Attack --#sourceToken|@{selected|token_id} --#targetToken|@{target|token_id} --#emoteText|@{selected|token_name} delivers an additional attack with the butt end of his weapon! --=TargetAC|@{target|npc_ac} --?[$TargetAC.Total] -gt 0|DoneWithAC --=TargetAC|@{target|ac} --:DoneWithAC| --=CurseVal|?{Target Cursed?|no,0|Hex,1} --?[$CurseVal] -eq 0|no --?[$CurseVal] -eq 1|Hex --:no| --&AtkDice|?{Roll Type?|Normal,1d20|Advantage,2d20kh1|Disadvantage,2d20kl1} --=AttackRoll|[&AtkDice] + @{selected|strength_mod} [STR] + @{selected|pb} [PROF] + 3 [WPN BNS] --+Attack|@{selected|token_name} rolls [$AttackRoll] vs the Bad Guy. --?[$AttackRoll.Base] -ge 20|Crit --?[$AttackRoll.Base] -eq 1|Fumble --?[$AttackRoll.Total] -ge [$TargetAC.Total]|Hit --/|BlahBlah --+Miss!| --^EndAttack| --:Fumble| --/|BlahBlah --+Fumble! --^Final| --:Hit| --=BlahBlah --+Hit! --^Final| --:Crit| --/| BlahBlah --+Critical Hit!| --^Final| --:Hex| --&AtkDice|?{Roll Type?|Normal,1d20|Advantage,2d20kh1|Disadvantage,2d20kl1} --=AttackRoll|[&AtkDice] + @{selected|strength_mod} [STR] + @{selected|pb} [PROF] + 3 [WPN BNS] --+Attack|@{selected|token_name} rolls [$AttackRoll] vs the Bad Guy. --?[$AttackRoll.Base] -ge 19|Crit --?[$AttackRoll.Base] -eq 1|Fumble --?[$AttackRoll.Total] -ge [$TargetAC.Total]|Hit --&BlahBlah --+Miss!| --^Final| --:Fumble| --/BlahBlah --+Fumble!| --^Final| --:Hit| --=BlahBlah --+Hit!| --^Final| --:Crit| --/| BlahBlah --+Critical Hit!| --^Final| --:Final| }}
1763887007

Edited 1763903351
Hi DInk, I would strongly recommend Kurt's Discord server for SC questions as there are a lot of people there that are amazing scripters who don't regularly look at R20 forums, perhaps because it is so easy for your query to be lost here. Secondly I would recommend Kurt's 5e Character Action Menu (CAM) for most everything a token does in combat, that's on their Github <a href="https://github.com/kjaegers" rel="nofollow">https://github.com/kjaegers</a> Thirdly, how will you be handling resistances etc as it is likely that multiple damage types will be coming into play, for example piercing from a weapon and necrotic from the Hex? Fourthly, Kurt has several libraries that do the heavy lifting for you... set them up as directed in Github and start every script that will use them with !script{{ +++5Elib;snlib;ActionMenuAddons;dnd5elib+++ If/Then can be written as&nbsp; --&amp;CurseVal|?{Target Cursed?|no|Hex} --?"[&amp;CurseVal]" -inc "no"|no|Hex It is good practice to use the "" around text entries in case of spaces in the searched for text, not that I do that all the time!!&nbsp; This will leap to your relevant branch as needed. I would be tempted to use 5eCAM for the base attack and then have an ability on a character (either the Warlock in question or a mule) that runs the Hex script.&nbsp; The player can click to run this on a successful hit and it can question whether it was a crit or not and roll damage, checking for resistances as required. Alternatively you could have your base script do the attack and query damage type --&amp;DamageType|?{what damage type|0} but that is prone to typos and thus misfires You can set a status marker on the target using this notation --!t:[*T:t-id]|statusmarkers:stunned::6747881 stunned::6747881 &nbsp;is a custom marker in my games, but you get the idea.&nbsp;
Hello!&nbsp; and thanx Muchly for the reply! As far as damage types and resistances and such....&nbsp; I'm not that deep in it and do most of that calculating {or un-calculating??} manually,.. also haven't gotten into figureing out the script looking for a token marker yet... will get there eventually too.. lol As for the separate ability to run the "hex burn" for additional damage,.. that's fine for Hex and my straight up warlock uses it that way.... she casts it which marks the target, and when needed uses the other button for the burn to apply,.. or define the amount of damage dealt...&nbsp;&nbsp; However,... what I'm trying to build is a script for my other Warlock who is a "Pact of the Blade"...&nbsp; which has "Hexblade's Curse"... which is not just a hex burn...&nbsp; I need the script to run a separate attack section since it changes the Crit range to 19-20,.. and it adds Proficiency bonus as damage... this last part could just be added manually pretty easily,... but the Crit Range part is something that is only active against that one hexxed foe... if he attacks a different target... he doesn't get the enhanced Crit range...&nbsp; For now I've just provided him with separate buttons to use against regular foes.. or the hexxed one and they have their own scripts in them... was just looking to put it all into one button so he'd just click it and when asked.... select Hexxed or not,.. and have it all in one button... Will look into the discord for sure... Thanx again.. Muchly!!!&nbsp;
Am out rn, but will see what I can piece together when I get home&nbsp;
!script{{ +++5Elib;snlib;ActionMenuAddons;dnd5elib+++ --#title|Hexblade's Curse --#leftsub|Bonus Melee Attack --#sourceToken|@{selected|token_id} --#targetToken|@{target|token_id} --&amp;EnergyType|bludgeoning --&amp;DieName|1d4 --&amp;RollType|?{NADE?|Normal,1d20|Advantage,2d20kh1|Disadvantage,2d20kl1|Elven Accuracy,3d20kh1} --=MaxTargets|1 --#emoteText|[*S:t-name] delivers an additional attack with the butt end of his weapon! --&gt;Lib5E_FIND_ACTIVE_GLOBAL_ATTACK_MODS|@{selected|character_id};AtkMods --&gt;Lib5E_FIND_ACTIVE_GLOBAL_DAMAGE_MODS|@{selected|character_id};DmgMods --/|Now let's grab Warlock level --:/|Lib5E_FIND_CLASS_LEVEL|characetrid;class;Return String Var --&gt;Lib5E_FIND_CLASS_LEVEL|[*S:character_id]; warlock;WLVL --&lt;| --&gt;AttackBranch| --X| --:AttackBranch| --+Target|[$DisplayCount] [*T:t-name] --=Roll|[&amp;RollType] --+d20 Roll|[$Roll] --=Atk|[$Roll] + [*S:pb] + [*S:strength_mod] [&amp;AtkMods] --=dmg|[&amp;DieName] --=CritDmg|[&amp;DieName] --&gt;RollDamage| --%| --=TargetAC|[*T:npc_ac] --?[$TargetAC.Total] -gt 0|DoneWithAC --=TargetAC|[*T:ac] --:DoneWithAC| --+Attack|[*S:t-name] rolls [$Atk] to hit --?[$Roll.Raw] -ge 19|Crit --?[$Roll.Raw] -eq 1|Fumble --?[$Atk.Total] -ge [$TargetAC.Total]|Hit --?[$Atk.Total] -lt [$TargetAC.Total] -and [$Atk.Base] -ne 1|Miss --&gt;AttackBranch| --&lt;| --:End| --X| --:Fumble| --+Fumble!|Your attempt is no better than that of a child --&lt;| --:Miss| --+Miss!|Your blow is weak and bounces off harmlessly --&lt;| --:Hit| --=Damage|[$AdjDmg] --+Base Damage|[$DmgBase] --+Hit!|The blow hits home against [*T:t-name] causing [$Damage] points of damage --/| LibSN_APPLY_DAMAGE_OR_HEALING|tokenid;bar#;amount;display (0 or 1);Allow Overhealing (0 or 1); Allow negative hp (0 or 1) --/| Applies damage (negative number) or healing (positive number) to (tokenid)'s (bar#) token bar. --&gt;LibSN_APPLY_DAMAGE_OR_HEALING|[*T:t-id];1;-[$Damage];0;0;0 --?[*T:t-bar1_value] -eq 0|Heal --&lt;| --:Crit| --=Damage|[$FinCrit] [Critical Hit!] --+Base Damage|[$DmgBase]+[$CritBase] --+Critical Hit!|A beautiful strike hits [*T:t-name] violently, causing extra damage for a total [$Damage] points of damage! --/| LibSN_APPLY_DAMAGE_OR_HEALING|tokenid;bar#;amount;display (0 or 1);Allow Overhealing (0 or 1); Allow negative hp (0 or 1) --/| Applies damage (negative number) or healing (positive number) to (tokenid)'s (bar#) token bar. --&gt;LibSN_APPLY_DAMAGE_OR_HEALING|*T:t-id];1;-[$Damage];0;0;0 --?[*T:t-bar1_value] -eq 0|Heal --&lt;| --:RollDamage| --&gt;Lib5E_CheckDamageModifiers|ResistType;[&amp;EnergyType] --=DmgBase|[$dmg.Raw] [&amp;DmgMods] + [*S:strength_mod] + [*S:pb] --=CritBase|[$CritDmg.Raw] [&amp;DmgMods] --=DamageRoll|[$DmgBase][&amp;ResistType] --=AdjDmg|[$DamageRoll] --=Critical|[$DmgBase]+[$CritBase] --=FinCrit|[$Critical][&amp;ResistType] --&lt;| --:Heal| --/| LibSN_APPLY_DAMAGE_OR_HEALING|tokenid;bar#;amount;display (0 or 1);Allow Overhealing (0 or 1); Allow negative hp (0 or 1) --/| Applies damage (negative number) or healing (positive number) to (tokenid)'s (bar#) token bar. --&amp;Heal|[*S:charisma_mod] + [&amp;WLVL] --+Healing|[&amp;Heal] --&gt;LibSN_APPLY_DAMAGE_OR_HEALING|[*S:t-id];1;+[&amp;Heal];0;0;0 --&lt;| --X| }}
1763911822

Edited 1763912355
That's a script that just fires if the target has Hexblade Curse on them, obviously you could put your query in about whether that status is in effect and have alternative branches if so, in fact, using Kurt's libraries, if you have a status marker you only use for HB Curse, then you could just have the script check the target for that token marker and branch automatically.&nbsp; It also checks the target after the hit and if HP=0 (I use Bar 1) then the Warlock gets the healing auto-applied
1763926536

Edited 1763935449
Made a couple of tweaks - if we assume we use the red status marker solely for Hexblade's Curse, then this checks the target, if that marker is present then the Crit Rang changes to 19 and 20, if not, it stays at 20.&nbsp; It also only applies the healing if that marker is active.&nbsp; As it stands you would need to make one of these scripts for each warlock weapon and have it as an ability on the character sheet.&nbsp; It relies on ScriptCards Library 5elib and also ScriptCards Library snlib, but once set in each game they will make your life much easier; my Eldritch Blast script went from 113 lines to 33! !script{{ +++5Elib;snlib;ActionMenuAddons;dnd5elib+++ --#title|Hexblade's Curse --#leftsub|Bonus Melee Attack --#sourceToken|@{selected|token_id} --#targetToken|@{target|token_id} --/|Let's check our target to see if Hexblade Curse is active --/|LibSN_CHECK_STATUS_MARKER|TokenID;MarkerToFind;ExistsVariable (string);CountVariable (string) --&gt;LibSN_CHECK_STATUS_MARKER|[*T:t-id];red;HBCurse --?[&amp;HBCurse] -eq 1|&amp;Curse;[*T:t-name] is Hexblade Cursed|&amp;Curse;[*T:t-name] is NOT Hexblade Cursed --+|[&amp;Curse] --?[&amp;HBCurse] -eq 1|&amp;CRng;19|&amp;CRng;20 --&amp;EnergyType|bludgeoning --&amp;DieName|1d4 --&amp;RollType|?{NADE?|Normal,1d20|Advantage,2d20kh1|Disadvantage,2d20kl1|Elven Accuracy,3d20kh1} --=MaxTargets|1 --#emoteText|[*S:t-name] delivers an additional attack with the butt end of his weapon! --&gt;Lib5E_FIND_ACTIVE_GLOBAL_ATTACK_MODS|@{selected|character_id};AtkMods --&gt;Lib5E_FIND_ACTIVE_GLOBAL_DAMAGE_MODS|@{selected|character_id};DmgMods --/|Now let's grab Warlock level --:/|Lib5E_FIND_CLASS_LEVEL|characetrid;class;Return String Var --&gt;Lib5E_FIND_CLASS_LEVEL|[*S:character_id]; warlock;WLVL --&gt;AttackBranch| --X| --:AttackBranch| --+Target|[$DisplayCount] [*T:t-name] --=Roll|[&amp;RollType] --+d20 Roll|[$Roll] --=Atk|[$Roll] + [*S:pb] + [*S:strength_mod] [&amp;AtkMods] --=dmg|[&amp;DieName] --=CritDmg|[&amp;DieName] --&gt;RollDamage| --%| --=TargetAC|[*T:npc_ac] --?[$TargetAC.Total] -gt 0|DoneWithAC --=TargetAC|[*T:ac] --:DoneWithAC| --+Attack|[*S:t-name] rolls [$Atk] to hit --?[$Roll.Raw] -ge [&amp;CRng]|Crit --?[$Roll.Raw] -eq 1|Fumble --?[$Atk.Total] -ge [$TargetAC.Total]|Hit --?[$Atk.Total] -lt [$TargetAC.Total] -and [$Atk.Base] -ne 1|Miss --X| --:Fumble| --+Fumble!|Your attempt is no better than that of a child --&lt;| --:Miss| --+Miss!|Your blow is weak and bounces off harmlessly --&lt;| --:Hit| --=Damage|[$AdjDmg] --+Base Damage|[$DmgBase] --+Hit!|The blow hits home against [*T:t-name] causing [$Damage] points of damage --/| LibSN_APPLY_DAMAGE_OR_HEALING|tokenid;bar#;amount;display (0 or 1);Allow Overhealing (0 or 1); Allow negative hp (0 or 1) --/| Applies damage (negative number) or healing (positive number) to (tokenid)'s (bar#) token bar. --&gt;LibSN_APPLY_DAMAGE_OR_HEALING|[*T:t-id];1;-[$Damage];0;0;0 --?[*T:t-bar1_value] -eq 0|Heal --&lt;| --:Crit| --=Damage|[$FinCrit] [Critical Hit!] --+Base Damage|[$DmgBase]+[$CritBase] --+Critical Hit!|A beautiful strike hits [*T:t-name] violently, causing extra damage for a total [$Damage] points of damage! --/| LibSN_APPLY_DAMAGE_OR_HEALING|tokenid;bar#;amount;display (0 or 1);Allow Overhealing (0 or 1); Allow negative hp (0 or 1) --/| Applies damage (negative number) or healing (positive number) to (tokenid)'s (bar#) token bar. --&gt;LibSN_APPLY_DAMAGE_OR_HEALING|[*T:t-id];1;-[$Damage];0;0;0 --?[*T:t-bar1_value] -eq 0|Heal --&lt;| --:RollDamage| --&gt;Lib5E_CheckDamageModifiers|ResistType;[&amp;EnergyType] --=DmgBase|[$dmg.Raw] [&amp;DmgMods] + [*S:strength_mod] + [*S:pb] --=CritBase|[$CritDmg.Raw] [&amp;DmgMods] --=DamageRoll|[$DmgBase][&amp;ResistType] --=AdjDmg|[$DamageRoll] --=Critical|[$DmgBase]+[$CritBase] --=FinCrit|[$Critical][&amp;ResistType] --&lt;| --:Heal| --?[&amp;HBCurse] -eq 0|END --/| LibSN_APPLY_DAMAGE_OR_HEALING|tokenid;bar#;amount;display (0 or 1);Allow Overhealing (0 or 1); Allow negative hp (0 or 1) --/| Applies damage (negative number) or healing (positive number) to (tokenid)'s (bar#) token bar. --&amp;Heal|[*S:charisma_mod] + [&amp;WLVL] --+Healing|[&amp;Heal] --&gt;LibSN_APPLY_DAMAGE_OR_HEALING|[*S:t-id];1;+[&amp;Heal];0;0;0 --&lt;| --:END| --X| }} EDIT - also noticed some leftover characters in there from am edit, have removed those and also missed a [ in the Crit section, so have corrected that