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

Area of Effect and Tokens

Trying to think how to produce a list of tokens 'caught' in an area of effect (to which I could then do things like apply damage) Would I be better to use a large token and then look for collisions with others (using Token Collision for instance or by checking range between tokens)? And can someone point me to a way to produce a list of tokens on a layer/page (to check against a reference point or token)? (and if I am reinventing the wheel let me know). Thanks
When I type "path" into the search box on the library tab I get a set of "subscription assets" from Toasty Thaumaturgy that cover the token needs you have in mind.  I don't remember paying for them -- I think they came with being a Pro subscriber, so you may have them too?  They need to be sized appropriately though.  You can store them on the GM layer.
Also this might be helpful:&nbsp; <a href="https://app.roll20.net/forum/post/5059805/finding-the-token-id" rel="nofollow">https://app.roll20.net/forum/post/5059805/finding-the-token-id</a>
I may have found an answer - Kaboom. Since I only started learning Javascript about 2 weeks ago, it's still a bit of a learning curve, but I think I can use Kaboom for what I want. My goal is to write an API that can be called as a macro/player ability. So the player clicks on the macro, which is "Throw Grenade"&nbsp; The macro will have as parameters the selected and target tokens (the target being a 'grenade' token the player places). Then I'll use the selected tokens stats, range etc to figure out if the grenade 'hits' or scatters (which will move the grenade token). Then I'll use Kaboom with its nice visual effects, impart a slight movement to the affected tokens and then pass back the list of affected tokens to apply damage to. I'll then use Powercards to display the damage results, since there's no way I can duplicate that kind of script.&nbsp; I've already written an API script which works for targeted ranged weapons (this is a Warhammer 40k/Dark Heresy campaign) - in which the player clicks their macro with their token selected and then is prompted for target(s). It passes the weapon info and target info to the API, which works out range, to hit roll and damage to each target and then uses Powercards (I had to modify Powercards slightly to get the GM and player colours to show up) to display the results in a nice Powercard format. I used the --title tag in powercard to include a tooltip that shows the rolls and math in case a player wants to see. Then the fun stuff was putting different weapon abilities into the script (like flame or melta weapons for instance) and righteous fury (criticals).&nbsp; Learning curve but thankfully I have this wonderful forum and scripts to draw on or adapt from to help me. I only wish javascript had better or more specific error codes (ie what line would be nice) rather than ones like my favourite "Unexpected Token" lol. I think I spend most of my time hunting for missing } or typos. My mantra is now 'just a little bit of code' then test. And save a copy of the script in an editor each time I make a change and it does work so I have something to fall back on (to look for those stupid brackets).
1582660918
The Aaron
Roll20 Production Team
API Scripter
You can put your code in the Google Closure Compiler to check for missing tokens and such. Also, using a linter like ESLint helps quite a bit, particularly if it's integrated with your editor.&nbsp;
Can you suggest an editor (that works on OSX/Chrome). Right now I am just using Pages to write in, then copy/pasting... (try not to chuckle too much) Ty by the way for suggestions.
1582673242
The Aaron
Roll20 Production Team
API Scripter
I edit in VIM, but it's not for the faint of heart (though if you put a few years into it, it's AWESOME!) Sublime text powerful and approachable.&nbsp;
So I have a script that does mostly what I want. Players place a target token where they want the grenade to land, then use a macro to throw the grenade. Kaboom does its thing and the script calculates damage on affected tokens in the blast radius.&nbsp;&nbsp; Right now when a player 'throws the grenade' (ie clicks on the macro) if they fail their ballistic skill test (basically a to hit roll done by the API) the grenade will scatter. I use the tokens 'top' and 'left' properties to move the token (before Kaboom etc). So my question - is there an easy way to keep the scattering target token inside dynamic lighting walls? Sometimes the scatter takes it out through a wall (presumably because its not really 'moving', just changing its coordinates).&nbsp;
1582793370
The Aaron
Roll20 Production Team
API Scripter
There is not an easy way. You would need to compute the intercept point between the vector of movement and each segment of the DL lines. There is a vector math script in the repo that can likely help with that.&nbsp;
Thanks Aaron. I ended up taking an easy way out for now. Now if there is scatter, the script ends, putting a Command Button up in chat. Then I or the player moves the target token to an appropriate place (if it scattered through walls for instance), and when the Command Button is clicked it calls the script again, passing back the needed info (shooter, grenade type etc) with a tag to skip the scatter roll and proceed to damage.Works well enough. Mastering the vector/path stuff is beyond me at this point; I can revisit it as I get more comfortable. My last real programming was in the days of Basic...&nbsp; Your suggestions re Closure Compiler and Sublime have been very helpful, speeding me up tremendously and reducing my frustrations! Cheers!