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] GroupInitiative - Roll initiative for a group of tokens, take the lowest value and add them to the turn order.

1407244907

Edited 1430683229
The Aaron
Roll20 Production Team
API Scripter
Update v0.8.1 - Removed dependency on isGM, added --bonus to add a number to the rolls: !group-init --bonus 5 Inline rolls are fine too (but note that the same bonus is applied to all selected in that case): !group-init --bonus [[1d4]] Update v0.6 - Minor Bugfix to handling of second tier attributes. (Thanks Naz!) Update v0.41 - Minor fix. HTML Special characters were getting subsisted for their values and breaking the Javascript. I've changed how they are generated to get rid of the "Unexpected identifier" error. (Thanks al e!) Update v0.4 - Minor fix. A UTF-8 character had slipped into one of the strings. It shouldn't have caused any issues, but just in case, I've pulled it out in v0.4. Update v0.3 - This version is so different, it's practically a full rewrite. See Below! Overview: This script adds a command for rapidly adding large groups of tokens into the turn order. As of v0.3, there are quite a few configuration commands (see Commands below). The basic process followed by the script is this: Remove any tokens that already have a turn. For all selected tokens, find the character they represent. For each character, figure out the initiative bonus. Initiative bonuses are calculated using Bonus Stat Groups . Each Bonus Stat Group is a collection of Attribute Names and Stat Adjustment operations to apply to them. Bonus Stat Groups are evaluated in order. The first one that produces a bonus is used. If a character doesn't have one of the Attribute Names listed in the Bonus Stat Group (or that Attribute Name does not contain a valid number), that group does not produce a bonus. The selected Roller is used to generate the rolls for each token, with the bonus for its character applied (or 0 if it doesn't have a character). Add each token to the turn order. Commands: !group-init This is the root api command. If you have any tokens selected, it will add them to the initiative order. If you don't have anything selected, it will show the help. !group-init --help This shows the help, which includes state information about the currently selected Roller , available Stat Adjustment Options , and the ordered list of Bonus Stat Groups . !group-init --add-group --&lt;adjustment&gt; [--&lt;adjustment&gt;] &lt;attribute name[|&lt;max|current&gt;]&gt; ... This command adds another Bonus Stat Group to the end of the list. Examples and further explanation below. !group-init --del-group &lt;number&gt; Removes the Bonus Stat Group identified by number. !group-init --promote &lt;number&gt; Moves the Bonus Stat Group identified by number up one slot. !group-init --set-roller &lt;roller name&gt; Sets the Roller to use for figuring initiative. Rollers: There are currently 4 different Rollers: Least-All-Roll -- Roll 1d20+Bonus for every token, then take the lowest number as the initiative for all tokens. (Bryan K.) Mean-All-Roll -- Roll 1d20+Bonus for every token, then take the average (rounded down) roll as the initiative for all tokens. Individual-Roll -- Roll 1d20+Bonus for each token and set each token's initiative to whatever it rolled. (James the DM, GenKitty, etc) Constant-By-Stat -- Set the initiative to whatever the Bonus for that token is. (Michael H.) Add-Group Detailed Explanation: The --add-group command creates a new Bonus Stat Group . It takes one or more attribute specifications. An attribute specification is made up of one or more Stat Adjustment Options , followed by an Attribute Name (optionally with |max on the end). Stat Adjustment Options Bare -- Use this when you want just the attributes value. This will add a Bonus Stat Group with just the attribute dexterity in it. !group-init --add-group --Bare dexterity Floor -- Use this to compute the floor of the value. This is useful when you have attributes that are decimal values, but you want a whole integer. Ceiling -- The same as Floor, but returns the next highest whole integer. The Bonus Stat Group added by this command would turn the attribute skill bonus from 2.35 to 3: !group-init --add-group --Ceiling skill bonus Bounded:&lt;low&gt;:&lt;high&gt; -- Use this to restrict the value of an attribute to a particular range. This would specify a Bonus Stat Group where dexterity can only be between -2 and +2: !group-init --add-group --Bounded:-2:2 dexterity To leave a value unrestricted, you can leave the bound for that side empty. This would specify a Bonus Stat Group where dexterity has a maximum value of +4, but can be as low as it wants: !group-init --add-group --Bounded::4 dexterity Stat-DnD -- Use this to convert an attribute from a Dungeons and Dragons Stat into the Stat's associated bonus. 18 becomes 4, 7 becomes -2, etc. This would specify a Bonus Stat Group which finds the stat bonus for the dexterity stat: !group-init --add-group --Stat-DnD dexterity Advanced Examples You can chain multiple Stat Adjustment Options together. This would specify a Bonus Stat Group where dexterity is first converted to a Dungeons and Dragons stat bonus, and then is bounded to a maximum of +2: !group-init --add-group --Bounded::2 --Stat-DnD dexterity Stat Adjustment Options always operate on the value to the right. In the example above, Bounded would be applied to whatever is returned from Stat-DnD. You can also chain multiple attribute specifications together. The Bonus is calculated by adding the results of each together. This would create a Bonus Stat Group that is the sum of the dexterity and initiative stats: !group-init --add-group --Bare dexterity --Bare initiative A more complicated example. This would specify a Bonus Stat Group which consists of the sum of the Dungeons and Dragons stat bonus computed for the max field of dexterity , the Dungeons and Dragons stat bonus computed from the max field of wisdom limited to a maximum of +2, and the current value of initiative . !group-init --add-group --Stat-DnD dexterity|max --Bounded::2 --Stat-DnD wisdom|max --Bare initiative Computing the Bonus When the Bonus is computed for a character, the Bonus Stat Groups are considered in order. The first Bonus Stat Group to produce a number is used. When a Bonus Stat Group is evaluated, it will produce a number as long as every referenced attribute is present and numeric on the character. Example. Assume you have the following 3 stat groups: dexterity |current + initiative |current + rage |current dexterity |current + initiative |current dexterity |current If a character has attributes named both dexterity and initiative , but doesn't have one named rage , the first Bonus Stat Group would not produce a number. In that case, the second Bonus Stat Group would produce a number, which would then be used as the Bonus. Hopefully that will be enough documentation that people can use this! If you have any issues, just let me know! Git: <a href="https://github.com/shdwjk/Roll20API/blob/master/GroupInitiative/GroupInitiative.js" rel="nofollow">https://github.com/shdwjk/Roll20API/blob/master/GroupInitiative/GroupInitiative.js</a>
Aaron comes through yet again, I'll have to test it out tonight and let you know if I see any potential / necessary changes.
1407248683
The Aaron
Roll20 Production Team
API Scripter
Sounds good, just let me know!
1407300346
The Aaron
Roll20 Production Team
API Scripter
I've got to say that it's a bit weird to take the lowest of N rolls. that pretty much guarantees the group will go last. I made a modification of this for Fear the Alpaca and in it I put an option for rolling once per group and taking the lowest dex mod, which seems to me to be a bit more reasonable. Other options might be to take the median or mean value. Probably will add that as a config option at some point given enough feedback...
Hmm, it's tough since I want creatures who are acting together to "wait" to work together.
Median will be midlke, lowest, low :/
1407323770
The Aaron
Roll20 Production Team
API Scripter
Yeah. Sort them, take the one in the middle.
Right, but I mean, it would typically average around the middle. I guess maybe a 3 tier system following 5e more closely???? Perhaps just 1 roll, and advantage roll (for trained groups), and disadvantage roll for untrained groups? 1d20 + Dex, 2d20kh1 + Dex, 2d20Kl1 + dex as the 3 options? I think larger groups in my system while fair to the party by penalizing the group with a low initiative would too often be guaranteed to be low. What do you think?
1407331068
The Aaron
Roll20 Production Team
API Scripter
The probability of rolling a 5 or less by number of creatures: Group Size % Roll &lt;= 5 1 25.00% 2 43.75% 3 57.81% 4 68.36% 5 76.27% 6 82.20% 7 86.65% 8 89.99% 9 92.49% 10 94.37% 11 95.78% 12 96.83% 13 97.62% 14 98.22% 15 98.66% 16 99.00% 17 99.25% 18 99.44% 19 99.58% 20 99.68% So, how do you propose to tell which type of roll to use?
I would think it would be a parameter. With a macro I would probably have a popup box asking for a # between 1 and 3? 1 for Disadvantage, 2 for Normal, 3 for Advantage? Too complicated?
1407334314

Edited 1410057765
The Aaron
Roll20 Production Team
API Scripter
Nope, pretty straight forward. I'll probably adjust it to use normal for the bare call, but support some additional parameters to change the behavior, then you can have your macro feed it values as you said. =D
I might take a look at this tonight if I have time. It seems like you said it should be pretty straight forward.
1407503591
The Aaron
Roll20 Production Team
API Scripter
When's your next game?
Sunday, but I wanted to test these two out. this one is more plug and play but the other I actually have to convert ahead of time. Sadly I think I just have to convert two fields for the monsters, just name and armor class.
1407504842
The Aaron
Roll20 Production Team
API Scripter
Ok. I can probably knock these out today. At a minimum I can get you a less polished version. :)
Any update with this? I took a look at this, and all I spotted was a random d20 + dex roll. I didn't see how in this version you were taking the lowest from all of them.
If I comment out the .min line it will just take whatever was rolled last right? Your abbreviations are quite nasty in this one Java Master. :)
1407779285
The Aaron
Roll20 Production Team
API Scripter
Java SCRIPT ! =D .min() takes the current list of values in the chain and replaces it with the minimum value. Commenting it out will mean that instead of getting one value in the .map() function that sets the token's priority, it will attempt to set it to an array. No idea what that will do, probably fail to add them to the initiative correctly at a minimum. I've got a bit of work into this, but you know I don't like to do anything halfway...
Dang your chain. Sounds like I'd have to pull that out. Was hoping to use it tonight. Combat really bogged down when we had 20+ creatures in a fight last night. My nephew was bouncing all around for initiatives. (he was DM)
1407780104
The Aaron
Roll20 Production Team
API Scripter
Would you be happy with just getting a version that gave a single roll for all the selected group?
1407781091

Edited 1407781105
Definitely. I don't need the advantage / disadvantage stuff. Just a 1d20+ mod (it would only be used for creatures with the same mod). It seems a lot easier to get nearby creatures the same initiative so they can go together.
1407781457
The Aaron
Roll20 Production Team
API Scripter
v.2 uploaded. Enjoy!
Thank you, sorry for being such a hassle :/
1407783301
The Aaron
Roll20 Production Team
API Scripter
=D
Aaron, I think I love your scripts too much. Again, I asked in your other post if replacing the ! command would be functionnal, you said yes. Now I'm wondering if I replaced anything [dexterity] with a [Initiative] instead would work. Basically I want the script to search for Initiative when rolling, not dex. Would it work, or would it break?
1407802942
The Aaron
Roll20 Production Team
API Scripter
Yeah, it will totally work. The next version will allow you to set it. =D
Oooooooh sweet, looking forward to it.
god I feel like i'm just using you now. I play gurps as well as dnd, and I need to be able to pull a characters speed score and print that to the counter for the first game. There is no random roll for this, it just needs to pull the characters stat from the sheet and put that in order into the initiative tracker. I have something that does this awkwardly, but I have not been able to satisfyingly edit anyone elses code to duplicate this. My question is would this be possible using this script, and if not, would you be able willing to code it in?
1408057683

Edited 1410057974
The Aaron
Roll20 Production Team
API Scripter
I'm happy to help with some custom code. I'm at GenCon now so my attention span is limited. Leave me a more thorough description of what it needs to do and I'll see what I can work out. :)
Aaron, the jesus of Roll20.
1408065204
The Aaron
Roll20 Production Team
API Scripter
(Insert joke about being dead for three days at GenCon here.) :)
The YODA of roll20!!!
1408066270
The Aaron
Roll20 Production Team
API Scripter
Ha.
its quite simple. it is literally pulling the value of one stat from the character sheet and putting that number as their initiative. nothing else, no die rolls or anything else. might have to make accommodation for some math (i think the actual speed stat is an abs() equation based on another number in the sheet, and is disabled, so will need to be worked out via math, but the point is its static, doesn't have any random variable to it at all.)
1408220805
The Aaron
Roll20 Production Team
API Scripter
Can you invite me to a game with characters set up and GM me? Probably won't be able to look at it until after GenCon.
Aaron, What would I need to change to have the individual results show up in the turn tacker? Thanks!
1410057607
The Aaron
Roll20 Production Team
API Scripter
@James -- As in, having all of the individual results at the averaged initiative, or having individual initiatives?
Sorry I took so long, I thought I would get alert that you had replied... Anyways I am looking for the individual initiatives rolls. Thanks for all the work you do to better the playing experience on roll20.
1410721547
The Aaron
Roll20 Production Team
API Scripter
Ah, no worries. You can watch a thread by clicking "Follow This Topic" at the top right corner of the thread: As for your question, I can make a version of this script that does that. I have several enhancements I want to make to it already, and that's going on my list. =D I'll try to get that out shortly.
Great, looking forward to it. Thank you, I found the follow this topic way at the top of the thread.
1412730336
Gen Kitty
Forum Champion
Heeeeeyyyyyy Aaron. How is it going modding this script? I'd love to use this script if I could have ungrouped inits, like James is asking for :&gt;
1412732256
The Aaron
Roll20 Production Team
API Scripter
It's on my list. :) I'll try to get something this week...
1412732648
Gen Kitty
Forum Champion
I wonder if 'init' and 'initiative' could be added to your list to look for?
1412888772
The Aaron
Roll20 Production Team
API Scripter
Teaser Update : I have a version of this script now that does: Group initiative, taking the lowest value for everyone in the group Group initiative taking the average value for everyone in the group Individual Initiative for each person in the group Constant Initiative (just the stats) for each person in the group. Additionally, it has groups of stats for creating the bonus, such that you can say something like "The bonus is equal to the standard DnD bonus for the dexterity stat + the standard dnd bonus for the wisdom stat bounded between -2 and +2 plus the initiative stat, provided they have all three stats, otherwise its the value of the dex stat + the maximum from the initiative stat, otherwise it's 0". Now I just need to write an interface to let you lovely people set all that.. =D
I like the old Aaron better, this new "The Aaron" doesn't give as much!
1412892554
The Aaron
Roll20 Production Team
API Scripter
Ha! I got tired of trying to figure out which of us last commented on a thread and didn't want to lose my identity. (If I switched to 'shdwjk', everyone would be as confused as if HoneyBadger went back to Johnathan!) Anyway, you'll get all kinds of great stuff when I get the chance to polish. :)
1412901733
Gen Kitty
Forum Champion
Only THE Aaron has that skeptical look on his face, as if he's trying to determine what shenanigans we're pulling now :&gt;
1412909712
The Aaron
Roll20 Production Team
API Scripter
@GenKitty! Hahaha! Yeah, I'm talking about the name in the thread lists. =D It was mainly in the new Suggestions forum, where things where changing so often.
1413004619
The Aaron
Roll20 Production Team
API Scripter
Ok. Version 0.3 is live! It seems a bit complicated, but it should make sense after you try it a bit. Let me know if you need any help. I think I covered all the requested features and then some. Let me know if there are any other Rollers or Stat Adjustments Options you want added! I'm thinking about adding a Card based Roller for Deathlands/Savage Worlds. Let me know if you're interested in such a thing!
1413005810
Gen Kitty
Forum Champion
I will poke at this over the weekend and see if I can make heads or tails of it before I cry for help. :&gt;
1413009188
The Aaron
Roll20 Production Team
API Scripter
:)