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

[Script] 5e Automatic Attack Script (compares roll to target ac and deducts damage)

1586885946

Edited 1591318439
Hello everyone,&nbsp; I messed around yesterday and wrote this script for a 5e game that rolls to attack, compares the roll against the target token's armor class and, on a hit, automatically deducts the damage done from the token's Bar3 (the red, leftmost bar which my group always uses for health). The attacking character will give a message with the attack's results. It's pretty simple compared to some of the stuff I've seen here, but I still thought someone might get some use out of it. My players definitely enjoyed it in our game last night and it sped up combat considerably. The script is invoked with a macro in this format:&nbsp; !attack @{selected|token_id} @{target|token_id} [[&lt; attack roll&gt; ]] &lt;attack bonus&gt; [[&lt; damage roll&gt; ]] [[&lt; crit damage roll&gt; ]] &lt;attack description (one word)&gt; Here is an example with actual values:&nbsp; !attack @{selected|token_id} @{target|token_id} [[d20]] 7 [[1d8+3]] [[1d8]] longsword To give the attack advantage or disadvantage, you simply change the attack roll like so, respectively:&nbsp; !attack @{selected|token_id} @{target|token_id} [[2d20k1]] 7 [[1d8+3]] [[1d8]] longsword !attack @{selected|token_id} @{target|token_id} [[2d20kl1]] 7 [[1d8+3]] [[1d8]] longsword This does unfortunately require that you have 3 macros/abilities set up for each attack type, but I still prefer this to using queries as it reduces the number of steps an action takes, which was the goal of the script. If you're averse to that many buttons, you could also adjust the attack inline roll on the fly before using or, more easily, change it to a query. This script also assumes that every token represents a character, and that said character has an armor class value. This does mean you need to make a character for each monster type and set the tokens to represent them, but all you need to fill out is their armor class, so set up is minimal. You can also use the monster character type to set up macros/abilities for this script, so both players and enemies both use it for much faster combat.&nbsp; With all the explanations out of the way, here is the script: <a href="https://gist.github.com/Dylan-Hodge/57b4088b24a3ec9288a00e2049ac6d41" rel="nofollow">https://gist.github.com/Dylan-Hodge/57b4088b24a3ec9288a00e2049ac6d41</a> EDIT: Here is a variant that uses the same logic, but deducts from Bar1:&nbsp; <a href="https://gist.github.com/Dylan-Hodge/b078519812c242c7ea283f2cd06e697f" rel="nofollow">https://gist.github.com/Dylan-Hodge/b078519812c242c7ea283f2cd06e697f</a> And here is one that deducts from Bar2:&nbsp; <a href="https://gist.github.com/Dylan-Hodge/3118d390816573f50aacbe59a73cf3ca" rel="nofollow">https://gist.github.com/Dylan-Hodge/3118d390816573f50aacbe59a73cf3ca</a>
1586942001

Edited 1586948179
Does this reduce the hp for monsters when you attack them? Cause if it does this is a major game changer for sure! I think there is something that you got good here. I'll say that this will be a tremendous time saver of both calculations and time. Just tested it on the attack description, and even auto calculates health too WHICH IS NICE! Tho there is one thing i might ask, Is it possible to add 2? damage types instead of one. If so? How can i do it?
Yes, it will reduce the target token's Bar3 (health) on a successful hit, even if the player can't see the monster's health (because they don't control it).&nbsp; What do you mean by damage types? If you mean the description, then no, at present the description can only be one word, but I've considered ways to change this. If you mean damage dice, you can just change the inline roll for damage to whatever you need. If you mean actual mechanical damage types (slashing, etc), there isn't any support for this yet. This is something I can add, but it would need the character sheet for the monster to have additional information (resistances/vulnerabilities).&nbsp; Let me know if you think of any other improvements I can make!
Any way to change what bar the health is set on? I have lots of scripts setup with bar1 as the health bar. Was just curious if you planned on making it to where you can assign what bar it was on? I haven't tried your script yet but sounds really awesome. I had asked a while ago if a script like this existed but no one had one. So kudos to you sir.
Here is a variant that uses Bar1 instead:&nbsp; <a href="https://gist.github.com/Dylan-Hodge/b078519812c242c7ea283f2cd06e697f" rel="nofollow">https://gist.github.com/Dylan-Hodge/b078519812c242c7ea283f2cd06e697f</a> .&nbsp; Note: I didn't test it, just replaced "bar3" in the original script with "bar1", so let me know if it doesn't work, but it should work just fine.&nbsp;
Thanks, man I'll test it later this evening.
1586985345

Edited 1586985442
Ah sorry for the late response, i was asleep during that time, now i am awake. What i mean by damage types are is a second damage line like most of my weapons consists with 2 damage types while attacking. Like. For instance. 1d8 + Str +6 Bludgeoning 1d4 + Wis + 6 Fire &lt;= This is what i mean by a second damage roll or more, to help with automating the combat faster, while i suffered for the last 3 years running my campaign along with my friends. while being able to also labeling the damage type while rolling against the enemy creature.&nbsp; If this is implemented, that will help tremendously for me throughout my game. While also having it calculating the damage total for the attack for both damage types. This will also help if it could be implemented in for AOE attacks too. If it were to be possible.
If resistances/vulnerabilities aren't a concern, you can group all the damage together in one inline roll, like [[1d8+6+1d4+6]]. Otherwise, I'll need to modify the script to account for damage resistances and vulnerabilities. For AOEs, I am planning on doing something similar for spells, but it will be a separate script that rolls a saving throw for the target and deducts damage accordingly.&nbsp;
Ah i see, well that is promising to hear, let me lend a thank you for this script. Dylan. This has helped me in so many ways to make combat much faster in a underlining bloated campaign of mine. Please continue upon on what you do, Creating these scripts really do help out alot. Hopefully that this will continue to develop.
1586995539
Dumbhuman
Pro
Marketplace Creator
Dylan H. said: If resistances/vulnerabilities aren't a concern, you can group all the damage together in one inline roll, like [[1d8+6+1d4+6]]. Otherwise, I'll need to modify the script to account for damage resistances and vulnerabilities. For AOEs, I am planning on doing something similar for spells, but it will be a separate script that rolls a saving throw for the target and deducts damage accordingly.&nbsp; You might want to take a peak here and there .
KC . said: Dylan H. said: If resistances/vulnerabilities aren't a concern, you can group all the damage together in one inline roll, like [[1d8+6+1d4+6]]. Otherwise, I'll need to modify the script to account for damage resistances and vulnerabilities. For AOEs, I am planning on doing something similar for spells, but it will be a separate script that rolls a saving throw for the target and deducts damage accordingly.&nbsp; You might want to take a peak here and there . Very nice! Thanks for the heads up.&nbsp;