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

Any macros for grouping PC and Enemies into initiative buckets? Extra points for flagging tokens with grouping

My group has been experimenting with group initiative.  Basically the rules are: Everyone rolls initiative like normal We bucket PCs and Enemies into 6 buckets 1-8 Enemies 1-8 PCs 9-18 Enemies 9-18 PCs 19+ Enemies 19+ PCs Whoever gets the single highest initiative starts us off, PCs or Enemies We then alternate buckets between PCs and Enemies, with everyone in that bucket going at the same time I was curious if there was any easy way for me to bucket these after rolling, especially considering I wasn't sure if Roll20 has a way of distinguishing a PC from an Enemy in initiative?   Additionally, it would be awesome if I had an easy way of labeling the tokens with the groups after initiative is done.  
1727831733
Andrew R.
Pro
Sheet Author
ScriptCards can manipulate the Tracker, so that might be a good place to start. 
When you ask for advice here, you should specify what game you're playing and with what sheet, because those can be very impactful. Either way, you can sort of do this without scripts with a custom initiative roll and initiative sorting - For each token, give an identifier at the start of the token name (you don't need to change the character name), for instance, (PC) and (Enemy). Then, use a custom initiative roll, something like this: [[{1,9,19}<[[1d20]]&{tracker}]] ($[[0]]) (replace the 1d20 with whatever initiative roll you use, and place the whole thing in a template of your liking if you want it prettier) This will give everyone an initiative of 1, 2 or 3, and when you click to sort the initiative, every two sorts it alternates between alphabetical sort and reverse alphabetical sort on top of the numerical sort, so tokens in the same bracket get sorted by their faction. You can then check the chat log for who had the highest roll, to see which way you should sort them.
1727907937

Edited 1727907957
timmaugh
Pro
API Scripter
Here is a metascript solution for this. What it Does This will gather and roll 1d20 for all PC tokens without you having to select them on the VTT (a different roll equation could be substituted, or it could be changed to an individualized reference to an attribute). The token must have a bar1 value over 0. Separately, it will gather and roll 1d20 for all NPC tokens without you having to select them on the VTT (same substitution options are available). The token must have a bar1 value over 0. It will track each return to see if it is higher than the previously best number (tracking highest initiative). It will track the number of NPCs (Enemies) and PCs (Party) tokens that rolled at that highest value for tie-breaking purposes. It will tag tag each token with a status marker and number for their group, red for Enemies and blue for Party (so an Enemy token having rolled a 20 would be in group 1, and would get a red marker with the number "1" on it). It will build the Turn Tracker with 6 entries, three Enemy entries and three Party entries, alternating (Enemies 1, Party 1, Enemies 2, Party 2, etc.); it will choose the starting group based on the tie-breaker methodology listed below in Assumptions . It will output a panel at the end showing the highest initiative rolled, how many Enemies and how many Party tokens rolled that value, as well as each group of tokens, listed by name and showing the initiative that token rolled. Assumptions In the case of ties for the highest initiative rolled between enemies and the party, I assumed that the group with *more* members having rolled that highest value should go first... so if the highest overall Initiative was a 16 and the Enemies had 2 tokens roll that value while the Party only had 1, the Enemies should go first. In a case where even the number of tokens having rolled that highest initiative was tied between Enemies and Party, I assumed the Party would get the benefit of the doubt and could go first. Also, inherent in the SelectManager selection criteria for determining a PC token vs an NPC token, is certain assumptions about how to determine if a token is one or the other. From the SelectManager documentation for the feature: PC - This criteria tests that the object is a token, is on the objects layer, represents a character, and that there is at least one non-gm player with controlling rights to the token. NPC -  This criteria simply requires that the object be a token and that there are no non-GM players with controlling rights to the token (or associated character, if the token represents a character). There is no implicit layer requirement. I am also assuming that you're using bar1 for "hit points," and that you don't want to include a token if the bar1 value is 0 or below (ie, no hit points left). Scripts Required These are all available in the 1-click repository: The Metascript Toolbox TokenMod AddCustomTurn Pics or It Didn't Happen For this battle between 4 party tokens and 5 enemy tokens, I got this result: That shows me the party should go first (they had 1 member roll a 20 while the enemies had none), which is what the Turn Tracker shows: Again, based on that result, the Party has one token in group 1, two tokens in group 2, and one token in group 3. You can see that reflected with blue markers on the tokens: ...and the Enemies have no tokens in their first group, two in the second, and three in the third group. You can see that reflected with red markers on the tokens: Setup Required First, make sure your tokens have a "Can be controlled by" setting conforming to the PC or NPC requirements mentioned, above (see the But if you leave the camera rolling...  section, below for one way to expand this). Install the required Scripts. Create a character named "InitiativeMule" (no quotation marks). On this character, create 4 Abilities. Name them and fill them with the contents as follows: Initiative Best=0 CountPC=0 CountNPC=0 NPC1=none NPC2=none NPC3=none PC1=none PC2=none PC3=none GroupAssignment >=19=1 >=9=2 >0=3 CustomTurns !{{   !dct Enemies 1   !dct Enemies 2   !dct Enemies 3   !dct Party 1   !dct Party 2   !dct Party 3   {\&if get.InitiativeMule.Initiative.CountPC/get >= get.InitiativeMule.Initiative.CountNPC/get}     !act 0 1 --Enemies 3     !act 0 1 --Party 3     !act 0 9 --Enemies 2     !act 0 9 --Party 2     !act 0 19 --Enemies 1     !act 0 19 --Party 1   {\&else}     !act 0 1 --Party 3     !act 0 1 --Enemies 3     !act 0 9 --Party 2     !act 0 9 --Enemies 2     !act 0 19 --Party 1     !act 0 19 --Enemies 1   {\&end} }} GroupCombat !{{(~)   set.InitiativeMule.Initiative.Best=0/set   set.InitiativeMule.Initiative.CountPC=0/set   set.InitiativeMule.Initiative.CountNPC=0/set   set.InitiativeMule.Initiative.NPC1=none/set   set.InitiativeMule.Initiative.NPC2=none/set   set.InitiativeMule.Initiative.NPC3=none/set   set.InitiativeMule.Initiative.PC1=none/set   set.InitiativeMule.Initiative.PC2=none/set   set.InitiativeMule.Initiative.PC3=none/set   !forselected(^) token-mod --set statusmarkers|red;get^.InitiativeMule.GroupAssignment.[^[^1d20^]^].value/get {^&if $[^[^0^]^] > get^.InitiativeMule.Initiative.Best/get} set\\\\^.InitiativeMule.Initiative.Best=$[^[^0^]^].value/set set\\\\^.InitiativeMule.Initiative.CountNPC=1/set set\\\\^.InitiativeMule.Initiative.CountPC=0/set {^&elseif $[^[^0^]^] = get^.InitiativeMule.Initiative.Best/get} set\\\\^.InitiativeMule.Initiative.CountNPC={^&math get^.InitiativeMule.Initiative.CountNPC/get + 1}/set {^&end} {^&if $[^[^0^]^] >= 19} {^&if "get^.InitiativeMule.Initiative.NPC1/get"="none"} set\\\\^.InitiativeMule.Initiative.NPC1=@^(selected.character_name) ($[^[^0^]^].value)/set {^&else} set\\\\^.InitiativeMule.Initiative.NPC1=get^.InitiativeMule.Initiative.NPC1/get, @^(selected.character_name) ($[^[^0^]^].value)/set {^&end} {^&elseif $[^[^0^]^] >= 9} {^&if "get^.InitiativeMule.Initiative.NPC2/get"="none"} set\\\\^.InitiativeMule.Initiative.NPC2=@^(selected.character_name) ($[^[^0^]^].value)/set {^&else} set\\\\^.InitiativeMule.Initiative.NPC2=get^.InitiativeMule.Initiative.NPC2/get, @^(selected.character_name) ($[^[^0^]^].value)/set {^&end} {^&else} {^&if "get^.InitiativeMule.Initiative.NPC3/get"="none"} set\\\\^.InitiativeMule.Initiative.NPC3=@^(selected.character_name) ($[^[^0^]^].value)/set {^&else} set\\\\^.InitiativeMule.Initiative.NPC3=get^.InitiativeMule.Initiative.NPC3/get, @^(selected.character_name) ($[^[^0^]^].value)/set {^&end} {^&end} {~&select *,+npc,+bar1>0}   !forselected(^) token-mod --set statusmarkers|blue;get^.InitiativeMule.GroupAssignment.[^[^1d20^]^].value/get {^&if $[^[^0^]^] > get^.InitiativeMule.Initiative.Best/get} set\\\\^.InitiativeMule.Initiative.Best=$[^[^0^]^].value/set set\\\\^.InitiativeMule.Initiative.CountPC=1/set set\\\\^.InitiativeMule.Initiative.CountNPC=0/set {^&elseif $[^[^0^]^] = get^.InitiativeMule.Initiative.Best/get} set\\\\^.InitiativeMule.Initiative.CountPC={^&math get^.InitiativeMule.Initiative.CountPC/get + 1}/set {^&end} {^&if $[^[^0^]^] >= 19} {^&if "get^.InitiativeMule.Initiative.PC1/get"="none"} set\\\\^.InitiativeMule.Initiative.PC1=@^(selected.character_name) ($[^[^0^]^].value)/set {^&else} set\\\\^.InitiativeMule.Initiative.PC1=get^.InitiativeMule.Initiative.PC1/get, @^(selected.character_name) ($[^[^0^]^].value)/set {^&end} {^&elseif $[^[^0^]^] >= 9} {^&if "get^.InitiativeMule.Initiative.PC2/get"="none"} set\\\\^.InitiativeMule.Initiative.PC2=@^(selected.character_name) ($[^[^0^]^].value)/set {^&else} set\\\\^.InitiativeMule.Initiative.PC2=get^.InitiativeMule.Initiative.PC2/get, @^(selected.character_name) ($[^[^0^]^].value)/set {^&end} {^&else} {^&if "get^.InitiativeMule.Initiative.PC3/get"="none"} set\\\\^.InitiativeMule.Initiative.PC3=@^(selected.character_name) ($[^[^0^]^].value)/set {^&else} set\\\\^.InitiativeMule.Initiative.PC3=get^.InitiativeMule.Initiative.PC3/get, @^(selected.character_name) ($[^[^0^]^].value)/set {^&end} {^&end} {~&select *,+pc,+bar1>0}   !%~(InitiativeMule.CustomTurns) {~&delay 3}   /w gm {~&template:default} ({)name=Initiative Report(}) ({)Winning Initiative=get~.InitiativeMule.Initiative.Best/get (}) ({)Enemies Count=get~.InitiativeMule.Initiative.CountNPC (}) ({)Party Count=get~.InitiativeMule.Initiative.CountPC (}) ({)Enemies 1 (19+)=get~.InitiativeMule.Initiative.NPC1/get (}) ({)Enemies 2 (9-18)=get~.InitiativeMule.Initiative.NPC2/get (}) ({)Enemies 3 (1-8)=get~.InitiativeMule.Initiative.NPC3/get (}) ({)Party 1 (19+)=get~.InitiativeMule.Initiative.PC1/get (}) ({)Party 2 (9-18)=get~.InitiativeMule.Initiative.PC2/get (}) ({)Party 3 (1-8)=get~.InitiativeMule.Initiative.PC3/get (}) {~&delay .3} }} Usage When you're ready, run the GroupCombat ability (you can put it into your macro bar so you don't have to have the character open). Explanation I could... if you really want me to and if you're enough of a masochist that you're willing to sit through it. Let me know. But if you leave the camera rolling... Originally, this was built to allow for NPC style tokens that are friends of the Party (but GM-controlled) to be included on the Party side of the initiative count. I managed this by including a tag on those characters for "friend". In other words, the "party" tokens would be all PC tokens, plus any NPC tokens that were tagged as "friend." The NPC tokens were all NPC tokens *except* those tagged as "friend". However, this enhanced selection criteria for SelectManager requires the Experimental Sandbox (the tags aren't available in the default script sandbox), but my Experimental Sandbox refused to boot up. So for now I stripped that portion out. If you go with this solution and you want to implement that feature, let me know. I've opened a ticket with Roll20 to get the Experimental Sandbox functional again, so hopefully at some point I'll be able to test out the "friend" variation and share it, too.