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

Macro (how?): Selected PC to attack against target Monster AC with full results

What I want: (background: Pathfinder I; I am a total noob at macros) (1) A macro which I can copy to all PCs and NPCs doing the most basic attack routine. It shall execute on the PC token I have selected and then ask for a target token (monster) - no hardcoded names. It then shall take the first "attack" weapon definition on my PC character sheet, roll the dice and compare it to the AC of the targeted monster. It shall tell me if it did hit and then the damage (best: only show damage if the attack did hit). (2) Bonus question: Would there be any way to automatically adjust the hitpoints of the target as a consequence? As far as I read the documentation this (at least 1) should be doable. But I have no clue what the correct syntax is. Any help appreciated.
1614191677
GiGs
Pro
Sheet Author
API Scripter
This cant be done. It's the using the attack definitions on the sheet that is the issue: the way roll20 macros are built, you need to have the selected and target functions built into the macro from the start. If they aren't in the attack definition already, you are stuck with that definition. What you can do is build new macros. You can get attributes from the acting character by using @{ selected |attribute-name} and attributes on  a target by using (say) @{ target |attribute-name} For your Bonus question: macros cannot change attributes, they can only print dice rolls to chat. You neeed to be a Pro subscriber, and use API scripts, to be able to alter attributes.
Guido, GiGs is correct in that the sheet determines what macros will be able to access. On the 5e OGL sheet this macro works for very simple attack against another character's AC /em @{selected|token_name} slashes at @{target|token_name} with her rapier! &{template:default} {{name=Rapier Attack}} {{Target AC=@{target|ac}}} {{Attack Roll=[[1d20]]}} {{Damage=[[1d8+@{selected|dexterity_mod}]] slashing}} And looks like this in the chat window: To use, you select the attacker, click the macro button, and you'll be prompted to click a target token. Note that a rapier is used for example purposes, and it's got no bonuses to hit or damage because you were asking about a simple approach. It always rolls damage, and it doesn't affect the HP of the target. I'm not familiar with the Pathfinder sheet, but that might allow you to start in a direction at least. Good luck! M
Thank you both. :-) So I understand that I can not access "the first attack" abstractly from my macro. This means I would have to create a macro for each character personally, which is fine for my PC (as that is just one) but less good for a GM's many NPCs (too much work). In that case the @selected part is not required as the macro is dedicated to a specific PC. Markie thanks for the sample code. Yes, that works well on PF 1 as well and is a good starting point. Is there a way to do parts of a macro only on conditions? For example only calculate and show damage if the attack is > AC? 
As far as I know, the setup of character abilities is different between PC and NPCs, so only NPCs have the repeating attack setup. You're right that you'll need to specify the attack type for the PC. Glad that might help get you going. There are no if/then or conditional constructions possible in the macros. You are not the first to lament their absence. There are hacks some people have done to imitate them in certain conditions, but it quickly becomes unwieldy for most of us mortals. If you upgrade to be able to use the API, there is supposedly conditional execution possible there, but not at the first two levels of subscription. Good luck! M
1614309533

Edited 1614309600
If you are a Pro subscriber the API gives you access to a script called PowerCards which allows for conditionals and much more, it's successor ,Scriptcards, which is in development offers more.  It's not exactly "plug-and-play" and requires some detailed scripting, but there's a dedicated forum community that helps out on this, and once you have a template setup, it's easy to adjust for lots of different attacks and spells.  The advanced logic for some spells and abilities can be difficult to code up.
Hm. I had a look at the Wiki for the Pathfinder sheet and it list the following for PCs: Repeating Weapons/Attacks, Full Attack: %{selected|repeating_attacks_$id_fullattack} Repeating Weapons/Attacks, Attack 1: %{selected|repeating_attacks_$id_attack1} Repeating Weapons/Attacks, Attack 2: %{selected|repeating_attacks_$id_attack2} Repeating Weapons/Attacks, Attack 3: %{selected|repeating_attacks_$id_attack3} It seems I can get a D20+Base attack bonus with  %{selected|melee}, but the above items only throw errors. What are the above items then and how to make them work?
1614447532
Kraynic
Pro
Sheet Author
Did you change the $id part to the actual row index or row id? <a href="https://wiki.roll20.net/Macros#Referencing_Repeating_Attributes" rel="nofollow">https://wiki.roll20.net/Macros#Referencing_Repeating_Attributes</a>