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

Triggering Macros for other Players

Sorry to bug everyone, but I'm getting a little lost with how API interfaces with certain objects in a campaign. What I want to do is make attack macros that let's the players target a token, but with a script at the end that will automatically trigger a defense macro from their target's character sheet as though the player who controls that target token ran the defense macro themselves. If I could get confirmation that such a thing is possible I am willing to tackle the task head on myself, but if it's not it would save me time I could use looking for alternatives.
1412425490
The Aaron
Roll20 Production Team
API Scripter
Provided the defense macro in question does not need to query the defending player with ?{question|default}, @{target}, or @{selected}, such a thing is possible with a modest amount of work. The basic flow would be like this: 1) attacking player triggers a macro that uses @{target|token_id} and passes the result to an !api command. 2) api command looks up the token by Id. 3) api looks up the represented character 4) API looks for a defense macro with a known name 5) API sends the body of the macro to the chat system to be evaluated. It is still possible with the 3 specified macro constructs above, but moves from being modest to complicated. (Would require some special actions on the part of the defending player) hope that helps!
1412441814

Edited 1412442106
Will K.
Sheet Author
Prompting the defending player with ?{question|default} is exactly what I had in mind, unfortunately. But now I know its at least possible, so thanks!
You can't trigger a macro to run on someone else's screen. It is not possible.
1412443870
The Aaron
Roll20 Production Team
API Scripter
HoneyBadger said: You can't trigger a macro to run on someone else's screen. It is not possible. Right, but you can execute the contents of one, so it comes down to what you want to do with it.
So not possible, gotchya. Still, thanks you guys.
1412445086
The Aaron
Roll20 Production Team
API Scripter
It's not possible to execute a macro in the context of a specific player, but you can get close. You can get the contents of the macro and send them to sendChat() and it is equivalent to pasting them into the chat with nothing selected and no prompting of the player. You can pre-process the text of the macro and jump through some hoops to fill in things you would normally prompt for.
Nah, sounds like this idea is probably a bust. The system I'm trying to automate is built around opposed dice rolls, with a lot of modifiers to consider for both sides of a roll. I think I'll start looking in to a script to put at the end of the defense macro that will compare it's results to the results of a preceding attack macro.
1416338157

Edited 1416338274
I have a feeling this isn't exactly what you're looking for but this is generally how i handle this. (SR 5E uses limits on it's success tests) I first build two global macros that will handle dodging and armor rolls. Dodge /em @{target|name (or token_id) } Tries to Dodge! /roll (@{target|reaction} + @{target|intuition}+?{dodge modifier|0})d6>5k@{target|LimitPhysical} armordefend (If hit) /roll ((@{target|armor} - ?{Armor modifier|0})+@{target|body})d6>5f1 Then i stack those macros inside of the individual attack rolls macros. I also just use those attack macros inside the individual characters by pulling up the parent attack macros #pistol in this case, for the types of equipment people have. Pistol /em @{Selected|name} Fires their pistol at @{target|name}(or token_id) /roll (@{selected|pistols}+@{selected|agility}+?{Attack Modifier|0})d6>5k?{Accuracy|1} ([[10 &{tracker:-}]]) #dodge #armordefend When used the macro prompts for the various modifier to attack, dodge and armor. It shows the results next to each other but it would still require players to ask for any modifiers they are not aware of when using the macro. This is original intended only for me to see so the setup was with gmroll but it changed them to regular since I don't know if you hide your rolls like I do. The only issue with this set up (for me anyway) is that I can't figure out how to make a macro that will let me select which type of defense action a character takes so i just roll against a standard dodge for most attacks and have special defense macros for unique types of defense(at which point that ability to call back earlier rolls that you were looking for would REALLY come in handy.) I also realize that this won't be too helpful for systems that allow for the use of unique feats to modify all kinds of stuff since the macros won't execute if certain parameters are missing. The best i could say is to add a couple more modifiers(which isn't exactly simplifying things) to account for unique abilities and set their defaults at zero. ?{feat modifier|0} Just don't forget to give each modifier a distinct name if you don't want the the numbers repeated. Anyway, I hope this might help you get some ideas.