
I'm copying my help request over from the macro forums now that I know my GM has access to API scripts. I'm leaving it intact for reference sake and have included a pseudocode layout of my end goal. I'm at a bit of a loss as to how to start with the scripting; I've looked at the wiki's for powercards and extended expressions but I guess I need to be even more basic than that.
/-/-/-/-/-/-/-/
I'm playing my first game on Roll20 tonight (5e) and I'm trying to streamline my experience as I'm picking up with a group that's been on it for years. As a novice, I'm not sure my goal is even possible. I've tried searching this forum, but get repeated gateway errors instead of results, so I apologize if this has been answered before.
My understanding is that I'll be able to select the enemy token and then run a global macro not assigned to my PC token.
I'd like to make an attack macro that checks creature type from token "npc type" attribute and adds additional dice and/or damage if it meets a criteria. Examples are ranger favored enemy or a sun blade that deals extra vs undead, or ideally a combination of the two. The specific weapon attributes means I have to split out the attacks between favored enemies.
As it stands I have 6 attack variants for a single weapon (basic, basic + planar warrior from horizon walker, basic vs undead, basic vs undead + pw, basic vs fiend, basic + PW vs fiend) so cutting that back down to 2 would be great. It would also reduce the likelihood of me forgetting to add a bonus, confusion with damage types, or just missclicking in general.
Assuming I can even set it up, I'll have to filter the attribute data to skip the first word, since it goes <size> <type>,<alignment>. Or perhaps request the DM create a new attribute that is just the type.
From what I've gathered I could do something similar with drop-down requests when I make the attack, but I don't want to have to toggle them each time I attack. Using the attribute is the crux. If that's the only way, I'll probably be back looking for help setting it up.
Any help is appreciated!
/-/-/-/-/-/-/-/
I'll apologize up front for the idea being more convoluted than necessary as a starting point, but it's exactly what my character is set up for.
Ref:
Sun Blade: 1d8 radiant (+1d8 radiant if target is undead)
Planar Warrior: convert all damage of the attack to force and +1d8 force
Favored Enemy: +4 damage to rolls against favored enemies (Undead & Fiends in this case)
Player has own token selected (or hardcoded for self)
Player chooses attack (currently from offense section of shaped character sheet, could be from macro on table top view)
*ie. Sun Blade or Sun Blade + Planar Warrior
Player chooses target token for the attack
Script pulls npc_type data from target token into a string
Script truncates string to parse out <type> only
*ie. will omit everything up to and including the first space as well as the comma and everything after
*"Large undead, chaotic evil"
Script checks if weapon conditional special case and character conditional special case **exist**
*i assume these would need to be custom created attributes on the character sheet
*ie. Sun Blade cares about Undead, and/or character cares about Undead & Fiends (from favored enemy)
*ie. Sun_Blade_type_conditional_trigger (value would be "undead") & Sun_Blade_type_conditional_effect (value would be "1d8") & Sun_Blade_type_conditional_effect_type (value would be "radiant")
*ie. Char_favored_enemy_type (multiple, in this case; would use OR for comparison; value would be "undead, fiends") & Char_favored_enemy_effect (value would be "4")
*may need to go even more general if unable to check two attribute values in one attribute
*ie. number_conditional_types (value would be 2) then char_conditional_1 (value = "undead") & char_conditional_2 (value = "fiend")
Script checks against weapon conditional special case and character conditional special case
*these would have to be chosen for comparison based on the attack chosen in step 2, presumably hard coded into the macro since various characters will have differently named conditionals and effects
*ie. character case would be checked for all attacks, weapon case would be specific to the attack selected
*ie. i wouldn't want a standard short sword attack to use the sun blade bonus, but i would want it to get the favored enemy bonus
Script rolls attack dice (no changes here since all dependent effects in this example are bonus damage)
Script rolls appropriate dice and added damage per options above
*if chosen attack = Sun Blade & Target = undead: basic radiant damage roll (1d8) + added radiant bonus vs undead damage roll (1d8) + favored enemy damage (+4)
*if chosen attack = Sun Blade + PW & Target = undead: basic force (due to conversion from PW) damage roll (1d8) + added PW force damage roll (1d8) + added radiant bonus vs undead damage roll (1d8) (GM has adjudicated the bonus remains radiant) + favored enemy damage (+4)