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

[SCRIPT] ScriptCards + Token-Mod ; Need Help Applying Damage to Targeted Token

November 17 (2 years ago)

Edited November 17 (2 years ago)

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. 

November 17 (2 years ago)

(11/17)
Full Code:

!scriptcard {{ --/|Eye Beam, Cyclopes
	--#sourcetoken|-NGkazTUBF65pIkmRyPR
	--#reentrant|1
	--#title|Eye Beam
	--+|[rbutton]make attack::Attack;4[/rbutton]
	--X|

	--: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|

--:Roll|
--#emotetext|
--c[&reentryval]|1:>Regular|2:>Fantastic|3:>Marvelous
--X|	
	--: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 	--]|
	--<|

	--:Marvelous|
	--#emotetext|MARVELOUS!
	--=REGDAM|7+[*S:agility_action]
	--=REGDAM2|[$REGDAM]*2
	--=BONUSDAM|[$REGDAM2]*[*S:rank]
	--=MDAM|[$BONUSDAM]
	--+Damage|[$MDAM]
	--+|[rbutton]Damage::Damage;[$MDAM][/rbutton]
	--<|

--:Damage|
--#emotetext|
--=TDAM|[&reentryval]
--@token-mod|_ids [&EB-Target] _set bar1_value|-[$TDAM]
--+|[$TDAM] Damage to [*T:t-name]
--X|

--/|END }}

November 17 (2 years ago)

My API-Mod Library

November 17 (2 years ago)
timmaugh
Forum Champion
API Scripter

TokenMod is set up to always act on the selected token(s) unless you use the --ignore-selected, and SelectManager's job is to make sure that there is still a selected token when TokenMod runs. Without SM, ScriptCards-calling-TokenMod would be a script calling a script... Resulting in no selected tokens.

So you're definitely going to want to use the ignore-selected switch.

After that, I would put a log statement just above the TokenMod line to see what is being sent. Just copy the verbiage of that TM line completely so you can see what is being handed off in the [&EB-Target] syntax.

I am not a ScriptCards wizard, but I suspect the problem is in how you are filling that info... I'm not sure what the "select" is doing in the line where you trigger the targeting, but SM will handle the selected tokens. I think you need to assign the token_id to a ScriptCards variable and then use that in your TokenMod line, but I'll leave that part to people more familiar with SC to say for certain.

November 17 (2 years ago)
timmaugh
Forum Champion
API Scripter

Also make sure you have the *playerscanIDs" setting enabled in TokenMod, or that you're a GM, otherwise TM won't let you do this.

November 17 (2 years ago)

Edited November 17 (2 years ago)



It looks right by all accounts. Matches the right id.


But the --ids function doesn't seem to take the passed token id. I'm assuming I should be using a " ^ " somewhere. 

--:Damage|
--#emotetext|
--=TDAM|[&reentryval]
--+|@token-mod|_ignore-selected _set bar1_value|-[$TDAM] _ids [&EB-Target]
--@token-mod|_ignore-selected _set bar1_value|-[$TDAM] _ids [&EB-Target]
--+|[$TDAM] Damage to [*T:t-name]
--X|

November 17 (2 years ago)
--:Damage|
--#emotetext|
--=TDAM|[&reentryval]
--@alter|_target|[&EB-Target] _bar|1 _amount|-[$TDAM]
--+|[$TDAM] Damage to [*T:t-name]
--X|

--/|END }}
Worked when calling @alter. More updates to come
November 17 (2 years ago)
timmaugh
Forum Champion
API Scripter

I don't think you're going to need a '^' character... those are used to conceal syntax structures until the outbound call is dispatched. You don't have anything in that token-mod call that requires disguising. Nothing will be detected in the initial pass of ScriptCards.

Did you make sure "players-can-ids" is on, or that you're a GM?

!token-mod --config players-can-ids|on
November 17 (2 years ago)

Kurt J, Found a typo in your !sc-reloadtemplates command output.

(From ScriptCards): (GM) Templates mule reloaded. 15 defined tempates.

thx

November 17 (2 years ago)

The problem might be token-mod. This particular token id has multiple hyphens after the lead hyphen, and I seem to recall that token-mod has issues handling those--though I thought that was fixed?

Try running just the token-mod command, without the ScriptCard syntax:

!token-mod --ignore-selected --set bar1_value|-56 --ids -NH0xtuORmd-a0G2g9-O


Kyle D. said:



November 18 (2 years ago)