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

Roll Comparison API Help

So I saw a thread by Ryan L. about a Roll Comparison script he had made. I am brand new to API, but my friend and I are trying to design a homebrew system. Combat is based around an attacker and defender each rolling a die to determine hits and misses. I was wondering if there is an existing API which could automatically take my macros, or some variation of them and compare the results. Attacker Roll Macro: /em attacks with ?{Skill?|Unarmed}!! [[1d8+?{Weapon Tier?}+?{Wager (Stamina/Mana)?|0}]] Defender Roll Macro: /em defends with ?{Which Type of Defense?|Block|Dodge|Parry}! [[1d8+?{Skill Tier?}+?{Wager (Stamina/Mana)?|0}]] The emote could be removed, and currently (as I am also new to macros) this is a rather input heavy setup. But basically, the attacker types in the name of the weapon skill they use, and the value of that skill. (Didn't want to have a 19 item drop down menu or 19 separate macros), and the Defender chooses their type of defense and inputs the value of that skill. The value of that skill is a static modifier that changes only when a player "levels-up" The wager value is something they can draw from their resource pools (ie Stamina and Mana). And the character would input the wager amount they wanted then go in and subtract those values from the token's corresponding bars...... (something to automatically reduce their health, stamina and/or mana when appropriate would be cool, but I imagine that is a totally different script and not my priority) Sorry for all the superfluous information, not exactly sure what is relevant to the scripts and what is not. Here's the real question: 1) Is there a script which could allow for these rolls to initiated automatically and then compared telling everyone whether the attack was a hit or a miss? 2) As a workaround or other solution, could the attacker macro include a target token in the macro that would then be able to automatically prompt the targeted token's controlling player or GM to put in the input for their defender's roll? 
1453142978
The Aaron
Pro
API Scripter
1) I think you'd need to write something custom for this.  Certainly, API scripts can evaluate rolls and make comparisons, but what you have going on likely would need to be very custom. 2) there are some things you could do here.  =D Probably what you want to do is write a script to automate this work.  You'll have a command like !attack to which you might pass the relevant information: !attack @{character_id} @{target|token_id} Axe 3 (I'm assuming that Axe would let you look up the weapon's damage, and having the character id would let you figure out the weapon tier and skill required.  3 in this case represents the wager, and could easily be a ?{Wager|0} instead. ) Your script could then figure out who the controllers of the token are (gm, or characters) and whisper to them something like: [Defend yourself](!defend 423123 ?{Which Type of Defense?|Block|Dodge|Parry} ?{wager|0}) Which would be a button that would then prompt you for the type of defense and wager amount, then call a !defend command.  The 423123 is a unique id generated by the script to match it up to the !attack from above.  The first !defend for the id would then result in resolving the action and printing the results. Hopefully that makes sense and is somewhat helpful.  Let me know if you wanna chat more about it! =D
Actually that make a lot of sense, I'll get to work seeing what I can do to get it working = )
1453149693
The Aaron
Pro
API Scripter
Cool!  Feel free to use me as a resource if you get stuck or want a sounding board.  =D
Awesome = D thank you
I'm not sure if this does exactly what's desired, but PowerCards is great with simple conditionals, so I'll throw this out there (requires installation of the PowerCards API Script to be used): /w gm [Defend](!power --name|?{Skill|Unarmed} Attack --!Attack|@{selected|token_name} attacks with ?{Skill|Unarmed}! [[ [$A] 1d8 + ?{Weapon tier|0} + ?{Wager|0} ]] --!Defense|The target defends with ?{Defense|Block|Dodge|Parry}! [[ [$D] 1d8 + ?{Skill tier|0} + ?{Wager|0} ]] -- ?? $A >= $D ?? !Hit|The attack hits! -- ?? $A < $D ?? !Miss|The attack misses...) This macro is quite advanced (on top of using PowerCards, it also uses API Command Buttons and HTML entities), so I'm of course happy to answer any questions about it.