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

API script for successful attack dam result

Hello all, Aaron, Hey buddy, I have a big favor to ask of you since I know very little about scripting at all. Would it be possible for you to please come up with a script that attacks but then only calculates damage for only a successful attack. This is what I have so far in macro but weather the attack is successful or not the damage is rolled thus cluttering up and sometimes confusing the chat window. EXAMPLE: Abilities Name - Attack-sword /roll 1d20+@{ Melee Tab } vs @{target|AC} if roll is higher than target AC @{target|AC} /roll 1 d 10 +@{ Melee Dam } Result rolling 1d20+8 vs 19 ( (17)+8 = 25 if roll is higher than target AC 19) rolling 1d10+4 ( 5)+4 = 9
1407504499
The Aaron
Roll20 Production Team
API Scripter
So, I was thinking about having an alternate roller which could add in some additional logic. It might look something like this: !roll attack: [[1d20+@{Melee Tab} --ge @{target|AC} !roll-if attack [[1d10+@{Melee Dam}]] So, the first command, !roll, would create a new roll instance for the current player named attack and store the number rolled and if it was greater than or equal to ( --ge ) the supplied AC, which would be considered as the truthiness of the roll. The second command, !roll-if, would take a named roll, attack , and check it's truthiness. If it was true, it would then send the results of the roll to the chat. This is just a first pass on the commands, but it gets the basic idea across. Tell me what you think about it, how you would improve it or expand it, and try to come up with cases it doesn't cover or uses it could be put to besides attack and damage. (Things like healing other tokens, setting statuses, etc)
oh im no programmer I know bupkis tis why i ask u :)
Aaron said: So, I was thinking about having an alternate roller which could add in some additional logic. It might look something like this: !roll attack: [[1d20+@{Melee Tab} --ge @{target|AC} !roll-if attack [[1d10+@{Melee Dam}]] So, the first command, !roll, would create a new roll instance for the current player named attack and store the number rolled and if it was greater than or equal to ( --ge ) the supplied AC, which would be considered as the truthiness of the roll. The second command, !roll-if, would take a named roll, attack , and check it's truthiness. If it was true, it would then send the results of the roll to the chat. This is just a first pass on the commands, but it gets the basic idea across. Tell me what you think about it, how you would improve it or expand it, and try to come up with cases it doesn't cover or uses it could be put to besides attack and damage. (Things like healing other tokens, setting statuses, etc) this is a call line to an api script yes? if so shouldnt and api script be needed? im confused
ok i made it a script and then it breaks automaticlly with a "unexpected identifier" error
1407505433
The Aaron
Roll20 Production Team
API Scripter
Right. Sorry. All API commands start with a ! (Insert Big Bang joke here) in proposing writing a script that would handle those commands, and giving an example if how I think the commands would be written in the macro to interface with the API. I like to make things as general purpose as possible, so discussing the uses and commands ahead of time is a good exercise to assist in generalizing the idea.
On the note of generalization: 1. The dam die would differ from chr to chr and weapon to weapon ie a separate macro for each type of attack and weapon . So if im not mistaken the script should not reflect any specifics on dam dice? 2. My current attribute lis is as follows HP Str Dex Initiative AC Melee Melee Dam Ranged Tab Ranged Dam
*tab (total attack bonus) = str mod + bab *melee = dex mod +bab *ranged
Id imagine this is about as general as one could be for attack unless im wronge /roll 1d20+@{ Melee Tab } vs @{target|AC}
I'm guessing a script like this would have to take a list of inputs: Why not merge it into one Aaron? !attack ATTACKDIE ATTACKMODIFIERSTOTAL AC #DICE DAMAGEDIE
so an example would be: !attack 20 5 14 1 12 Would roll 1d20 + 5, check if > 14 (send all except AC in chat), if so then send chat the roll of 1 d 12 ?
i dont understand any of that lol
1407507536
The Aaron
Roll20 Production Team
API Scripter
Because separated out, you have more options. Something like this could be a completely valid macro by splitting options out: !roll attack: [[1d20+@{Melee Tab} --ge @{target|AC} !roll-if attack [[1d10+@{Melee Dam}]] !roll-if-not attack [[3]] !note-if attack "This attack halts movement" !whisper-if attack gm "Remember, my attack steals life from my closest ally." !whisper-if attack me "Activate my rage ability if I've still got it and the target is bloodied by the attack." !whisper-if-not attack me "Don't forget to expend a charge on my ring to take another action." !em-if-not attack "catches his opponent with the spiked hilt of his sword, despite the miss." It would be cumbersome to try and stuff all of these options in one command, not to mention argument parsing would be a bitch. separating the various lines means large portions of the macro can be reused in other macros, and organized as the player wants. You could even split them across multiple macros if you had different effects you wanted, or you could put the attack in one macro and call it with #{macro name} and the damage or effects in another macro, then mix and match different attacks with the same result rules. For example, if you were using Brash Attack and got an extra bonus to hit but needed to note another status, while doing the same damage, etc.
1407507649
The Aaron
Roll20 Production Team
API Scripter
Bryan K. said: so an example would be: !attack 20 5 14 1 12 Would roll 1d20 + 5, check if > 14 (send all except AC in chat), if so then send chat the roll of 1 d 12 ? Right, I prefer to be more explicit in the arguments, to be more general. Your !attack makes a bunch of system assumptions, that higher is always better, that there is only one damage, that the damage dice are all the same. Splitting it out lets those all vary.
1407507676
The Aaron
Roll20 Production Team
API Scripter
Shaun Bradley (Elmo) said: i dont understand any of that lol =D Don't worry, worst case, we'll discuss the hell out of this topic before you know it and make something you can use. =D
Shaun Bradley (Elmo) said: Hello all, Aaron, Hey buddy, I have a big favor to ask of you since I know very little about scripting at all. Would it be possible for you to please come up with a script that attacks but then only calculates damage for only a successful attack. This is what I have so far in macro but weather the attack is successful or not the damage is rolled thus cluttering up and sometimes confusing the chat window. EXAMPLE: Abilities Name - Attack-sword /roll 1d20+@{ Melee Tab } vs @{target|AC} if roll is higher than target AC @{target|AC} /roll 1 d 10 +@{ Melee Dam } Basically this macro works but it deals dam even if the ac is missed i just want to make it so the dam is not rolled if the ac is not met. For each and every macro on each chr the dam is individually changed in the macro ie /roll #d#+@{Melee Dam} so thats not a big deal. Its just that middle line, the "if" line that has to be figured out. Some how can ya make the 1st line read to a script then the script read back to the 3rd line?
Hey My skype name is "Shaun.Bradley2012" if it would be easier to chat im down, always good to make new friends.
Yes Aaron, yours is way more system agnostic. I was just throwing out a quick and dirty. I am well aware quick and dirty is not your style. More like quick and complete. :)
1407510906
The Aaron
Roll20 Production Team
API Scripter
heheheh. So long as we understand each other! =D
1407511333
The Aaron
Roll20 Production Team
API Scripter
Shaun, while the API can intercept the /roll using on('chat:message',...), it can't prevent the output. With an API command, it can choose not to output anything. Additionally by using an API command for the initial attack, it makes the format explicit and allows choices to be made regarding it's output as well. For example: !roll attack: [[1d20+@{Melee Tab} --ge @{target|AC} --crit-on 17 !roll-if attack [[1d10+@{Melee Dam}]] --crit [[1d6+10]] ...could highlight the attack roll with the green box if the roll was 17,18,19 or 20, then roll extra damage in that case on the damage line.
1407511433

Edited 1409455406
The Aaron
Roll20 Production Team
API Scripter
It could also collect all the information at each stage and send a single chat message with a finalize command like: !roll attack: [[1d20+@{Melee Tab}]] --ge @{target|AC} !roll-if attack [[1d10+@{Melee Dam}]] !roll-if-not attack [[3]] !note-if attack "This attack halts movement" !whisper-if attack gm "Remember, my attack steals life from my closest ally." !whisper-if attack me "Activate my rage ability if I've still got it and the target is bloodied by the attack." !whisper-if-not attack me "Don't forget to expend a charge on my ring to take another action." !em-if-not attack "catches his opponent with the spiked hilt of his sword, despite the miss." !finalize attack
- Aaron: BRB - Writing my own roll 20.net. - leaves for 15 seconds to get coffee. - comes back 30 seconds later Aaron: Here you go. I have written an entire API for all of the systems listed on roll20. Everything is scripted for you, and is system agnostic. Enjoy! All you have to do is insert your 16 bit cartridge into your cartridge slot with your preference system.
1407512927
The Aaron
Roll20 Production Team
API Scripter
hahahaha. I do what I can. =D
soo?? whats the finished script?
its like reading greek lol
1407514443
The Aaron
Roll20 Production Team
API Scripter
I haven't written it yet. It takes several hours to write them, several days for bigger ones. Currently, I'm just trying to suss out what the script should do, then I can think about it's design and add it to my queue of projects. It might take me a few weeks to get rolling on it, particularly with Gencon next week (and my anniversary today!).
Well happy anniversary good sir, and I look forward to you much appreciated piece of work. thank you
1407518852
The Aaron
Roll20 Production Team
API Scripter
Thanks! =D