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

NPC type based attack macro

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!
1538596159
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
What you are asking for could be done with the API, but unfortunately, the macro language has no conditional ability. You cannot do any kind of If-then-else sort of programming. The best you could achieve is a macro that reports back the creature type from a targeted token (the exact wording would depend on the character sheet you are using), and then you could choose from among your attack macros accordingly.
I think I may have a non-api solution but I have to think about it for a bit.
1538601195

Edited 1538607427
Thank you both. I'll find out later this evening if the GM has API access. Either way, I'm interested in what you come up with Phnord. While not a programmer, I can appreciate creative coding tricks!
I would like to visit your game and see the sheets. I think something like this should be doable with simple macros. Calls to the sheet looking for an attribute, if there could be a numerical value to the attribute that would be better. Then a simple addition of the various damage values, and you're pretty much set.
OK, I'll get with my GM and figure out how to get you in. We're using the shaped character sheet for players, but I'm not sure what is being used for monsters on the GM's side.
Sounds good. It's going to depend on what info the GM is willing to share with you. I'm thinking something simple, but will need to know the attributes to call from the sheet.
So on further inspection, a "Type" value was added to some character sheets, but not all. A universal macro that sought 'type' from a target sheet would throw an error if said value was not found. Hence, this would require a lot of work from the GM of the game, to ensure every token had said value. Alternate options are being considered. Sorry Takryn! Good luck!
So there is also "npc_type" which includes "<size> <type>,<alignment". Is that one universal?(also, where did you find the info about what is included vs not?) I think I'm just now catching up to your thought process implementation, but is there a way for macros to convert string into an integer? thinking something like (str2int(@{character|fav_en_type} / str2int(@{target|type})*(bonus roll) then using some math tricks to see if you end up exactly equal to 1
I recognize it's no longer a pure macro, but the ExtendedExpressions script lets us compare strings. I think I can use that to build out the macro based on default monster and added as needed character attributes.
1538680311
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Is the campaign one created by a user with a Pro subscription? If not, you won't be able to employ a script. I had briefly considered that you might be able to build your macros using the type names as the name of the macro, and then using the targeted type to fill in the appropriate macro ability name. But I don't think that the macro language supports meta variables like that. I would really suggest that you make a chat menu with your four damage attack macros and just run it from the chat. Not as automatic, but then, that's the advantage of being able to script.
My GM does have Pro, so it's a workaround for the moment. That being said, #@{target|type} is correctly calling my #undead macro when targeting a skeleton. Now the issue of parsing strings really comes into play, since my party member has humanoids as a favored enemy, and it would seem the default templating includes the subtype, ie. humanoid (goblinoid). In order for the macro name to be generic, I need a way to cut out the subtype.