
So this is my first time trying out scriptcards, so I'll appreciate any and all pointers.
Basically, the script will be added a characters ability macros list, to be called from the token macro menu.
Thing to keep in mind:
(1) - Rolls will be made physically and inputted through --i:|q functions
(2) - The code utilizes a lot of [rbutton] --X functions to create card menus and are the primary way for players to conduct actions on their turn
The Problematic Code:
--:Damage| --#emotetext| --=TDAM|[&reentryval] --@token-mod|_ids [&EB-Target] _set bar1_value|-[$TDAM] --+|[$TDAM] Damage to [*T:t-name] --X|
So I'm calling token-mod to apply damage to a token that was previously selected in the code:
--:Attack| --i;select target|t;EB-Target;Choose Target --#title|Eye Beam vs [*[&EB-Target]:t-name] --#targettoken|[&EB-Target] --+|Ranged Attack, Agility +[*S:agility_action] --+|[rbutton]Regular::Roll;1[/rbutton][rbutton]Fantastic::Roll;2[/rbutton][rbutton]Marvelous::Roll;3[/rbutton] --X|
Breakdown:
!scriptcard {{ --/|Eye Beam, Cyclopes --#sourcetoken|-NGkazTUBF65pIkmRyPR --#reentrant|1 --#title|Eye Beam --+|[rbutton]make attack::Attack;4[/rbutton] --X|
Marco is Called
I'll have some other ways single powers are called through [sheetbutton] functions.
The first part of the suspect code
Other info about the card will be added, but basically the main function is this [rbutton]:
--:Attack| --i;select target|t;EB-Target;Choose Target --#title|Eye Beam vs [*[&EB-Target]:t-name] --#targettoken|[&EB-Target] --+|Ranged Attack, Agility +[*S:agility_action] --+|[rbutton]Regular::Roll;1[/rbutton][rbutton]Fantastic::Roll;2[/rbutton][rbutton]Marvelous::Roll;3[/rbutton] --X|
Target is Chosen
Due to how the game works, confirming the roll is broken down. The Regular attack roll calls for the most inputs, not super important, expect that it passes the calculated damage value to the last branch through [rbutton]; storing the damage value:
--:Regular| --i Make Regular Attack ;roll|q;rolled;Attack Roll||q;MDIER;Marvel Die --=RATK|[&rolled]+[*S:agility_action] --+|[$RATK] vs [*T:t-name] Agility Defense --?[$RATK] -ge [*T:agility_defense]|[ --#emotetext|HIT! --=REGDAM|[&MDIER]+[*S:agility_action] --+Damage|[$REGDAM] --+|[rbutton]Damage::Damage;[$REGDAM][/rbutton] --]|[ --+|...missed --]| --<| --:Fantastic| --#emotetext|FANTASTIC! --i Fantastic Attack ;roll|q;rolled;Attack Roll --=BROL1|[*S:agility_action]*[*S:rank] --=BROLL|[&rolled]+[$BROL1]+7 --=BROL2|[$BROLL] --+|[$BROL2] vs [*T:t-name] Agility Defense --?[$BROL2] -ge [*T:agility_defense]|[ --=REGDAM|7+[*S:agility_action] --=BONUSDAM|[$REGDAM]*2 --+Damage|[$BONUSDAM] --+|[rbutton]Damage::Damage;[$BONUSDAM][/rbutton] --]|[ --+|...missed --]| --<|Attack Made; Input Roll Values
everything is working up till this point.
Then the damage is applied, not to the target token, but the most recently selected token. Which usually will return to the token running the macro:
--:Damage| --#emotetext| --=TDAM|[&reentryval] --@token-mod|_ids [&EB-Target] _set bar1_value|-[$TDAM] --+|[$TDAM] Damage to [*T:t-name] --X| --/|END }}
Damage | HELP
Since Cyclopes was the most recently selected token, the damage was applied to that token, instead of the id value stored in [&EB_Target]; I've tried both [*T:t-id] and [*[&EB_Target]:t-id] to try and direct the script, but it always prefers the selected token. Adding _ignore-selected results in nothing happening.