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

API Question: Is it possible to code Selectable Targets?

1497410344

Edited 1497410373
In the shortest way I can possibly think of: Is there a way to code every token currently created as a clickable entity for the players and GM(s) to select after choosing to use a specific ability / attack / spell etc.? This would be extremely helpful to significantly speed up combat, simply allowing a player to select an ability to use, clicking a target then letting the system sort the rest out.
1497414323
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
There's the @{target} syntax which might do what you are hoping for, or at least make the script your envisioning easier (there can be a lot of tokens on a map after all). What system do you play? Most of the solutions for this are going to be character sheet specific (as the script needs to know what to compare to what and what to affect).
1497414932

Edited 1497415076
Well, I am hoping to create a custom Pokemon RPG system. Basically the code is supposed to work like this: Player chooses an Ability, Player Selects a target.  This goes through the calculation of what that ability does while also comparing effectiveness due to type vs. type. In functionality, player clicks the ability button, then the game will prompt the player to click a target.  After which that player's token's attributes will be compared against the required attributes of the target.  Then rolls will happen in accordance. This will also help with D&D as it will significantly speed up how fast combat flows without the DM having to check if the target's AC is lower or higher than the roll specified, or lowering the HP accordingly, making caluclations due to DR and such. All of this would be handled by the system, making a single roll that would last 2 - 3 minutes of calculations happen in mere seconds.
I think the better way to phrase this would be: I just need a way to allow players and gms to select targets of an attack by clicking tokens, other than that I'm pretty sure I can handle the rest of the calculations and formulas.
1497429219
Ziechael
Forum Champion
Sheet Author
API Scripter
The @{target...} syntax Scott mentioned allows you to do just that. Using @{target|<attribute name>} you can call attributes from target tokens sheets or simply use @{target|bar1} etc to reference information on the target token specifically. Check out the  wiki for more information, the sky is the limit :) @{target} etc syntax dice reference
1497461917
Lithl
Pro
Sheet Author
API Scripter
Also, useful for an API script, you can use @{target|token_id} or @{target|character_id} (if the token is linked to a character), to get the unique id of the token/character, which you can then use in the API with getObj to get a reference to the token/character object being targeted.
1497929819

Edited 1497929962
Scott C. said: There's the @{target} syntax which might do what you are hoping for, or at least make the script your envisioning easier (there can be a lot of tokens on a map after all). What system do you play? Most of the solutions for this are going to be character sheet specific (as the script needs to know what to compare to what and what to affect). The pokemon System I am trying to code will require this targeting macro: ((2*(@{level})/5+2)*@{AType}*@{APower})/@{Target|Def})/50)+2)*@{STAB})*(@{Target|Typemod1}*@{Target|Typemod2})*(1d39+216))/255 @{level} = The PC's level. @{AType} = Either Atk or Sp.Atk, chosen by a drop-down menu when "creating" a move. @{APower} = The base power of a move, I.e. Surf = 95 @{Target|Def} = This one is tricky as the player must state weather the Move is targeting Def or Sp.Def @{STAB} = Either 1 or 1.5 if the pokemon using the move is the same type as the move. @{Target|Typemod1} and @{Target|Typemod2} = This is even trickier than @{Target|Def} as it needs to respond to the type of attack being used on the target.  Both Values must result in 2, 1, 0.5, 0.25 or 0 depending on the Attack type being used on the Target.  Additionally if a pokemon has no secondary type, @{Target|Typemod2} must register as a 1. I.e. a Fire-Type move targeting a Water-type pokemon will deal 0.5x normal damage.  If a fire-type move is used on a Water / Ground type, it will deal 0.25x normal damage (0.5 x 0.5 = 0.25)