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

GroupInitiative and Multiple Turns in the Tracker

Hello! I was looking at trying to set up a quicker way to get initiative in the tracker for 7th Sea 1st Edition, where each round is divided into 10 phases and you act in as many phases as you have ranks in the Panache trait. Is there a way to (ideally) use GroupInitiative to automatically create more than 1 turn on the tracker at a time, or perhaps some macro-fu to make this happen? Thanks in advance!
1618875979
Kraynic
Pro
Sheet Author
The Aaron once wrote me a one-off script to duplicate initiative entries.&nbsp; It is a separate command, though.&nbsp; The script will take the initial value and will subtract 20 for each additional entry. <a href="https://app.roll20.net/forum/permalink/6817748/" rel="nofollow">https://app.roll20.net/forum/permalink/6817748/</a> Later, I asked by private message about being able to set an attribute for the script to check.&nbsp; I'll copy/paste that here. Here ya go, just add an attribute name after the number and it will default to using that value for each token, if it exists: !dup-turn 2 hth_numberattacks Script: on('ready', () =&gt; { const multiplyTurn = (token_id,count) =&gt; { let to = JSON.parse(Campaign().get('turnorder')||'[]'); let turn = {pr:-10000}; to = to.filter((o) =&gt; { if(o.id !== token_id){ return true; } if( o.id === token_id ) { if(o.pr&gt;turn.pr) { turn = o; } } return false; }); if(turn.id){ [...Array(parseInt(count)).keys()].forEach((n)=&gt;{ to.push(Object.assign({},turn,{pr:(parseInt(turn.pr)-(20*n))})); }); } Campaign().set({ turnorder: JSON.stringify(to.sort((a,b)=&gt;parseFloat(b.pr)-parseFloat(a.pr))) }); }; on('chat:message', (msg) =&gt; { if( 'api'===msg.type &amp;&amp; /^!dup-turn/.test(msg.content) ){ let args = msg.content.split(/\s+/); let count = args[1]||2; let attrname = args[2]||''; msg.selected.forEach((m)=&gt;{ let n = count; let token = getObj('graphic',m._id); if(token){ n = parseInt(getAttrByName(token.get('represents'),attrname)); } multiplyTurn(m._id,n||count); }); } }); }); You can see where the 20 is in the script, so you could edit that value to whatever differential you need between entries, and set up your command with the attribute you need. Or The Aaron may just show up with something more specific to your system that he dreamed up in his sleep while I was creating this reply...
Thanks, Kraynic. This gets me a lot closer! I'm having trouble getting the !dup-turn command to respond at all - I have the code you've made here in, do I need to add in group initiative as well?
1618877194
Kraynic
Pro
Sheet Author
No, I use it on player characters that roll their own.&nbsp; Do you already have them on the tracker?&nbsp; It needs an initial value for each token to already be on the tracker to work with.
Ahh, I see! That makes a bit more sense. Thank you! I'll see what I can do for this!
1618882496
The Aaron
Roll20 Production Team
API Scripter
If that doesn't work out, just post again and I'll see what I can come up with. =D
The Aaron said: If that doesn't work out, just post again and I'll see what I can come up with. =D What a champ! I'm a little out of my depth here, to be honest. Basically, I would need it to roll a number of 1d10s equal to a specified attribute and then throw those onto the tracker. Would that be doable?
1618967993
The Aaron
Roll20 Production Team
API Scripter
Hmm. I don't think there a good way to do that with GroupInitiative. Can you describe what a turn is like with those mechanics? &nbsp; Sounds like each token has some number of d10s rolled, then all are sorted (descending or ascending order?), then all the 10s (or 1s?) are handled, then all of the next ones, etc. At the end of a round, does everyone reroll? &nbsp;Are there NPCs with multiple rolls?
When initiative is rolled, everyone rolls a number of d10s equal to their ranks in Panache. It would then be sorted from lowest to highest, so we start in Phase 1 and everyone in Phase 1 acts, then move on to Phase 2, and so on until Phase 10. At the end of the round, we roll Initiative again and do it all again. Each Henchmen and Villain NPC is handled the same way, though there are some Brutes that use a different attribute to determine how many actions that they get.
1619010124

Edited 1619139715
The Aaron
Roll20 Production Team
API Scripter
Ok, here's super rough little snippet that should give the functionality you want.&nbsp; See if this works for you. Commands !7si --clear Usable by the GM only, clears the turn order !7si --sort Usable by the GM only, sorts the turn order in ascending order !7si ATTR_NAME Usable by anyone, for each selected token, gets the attribute specified and rolls that many d10s (default 1), then adds each token to the turn order with each of those rolls. Code: on('ready',()=&gt;{ /* eslint-disable no-unused-vars */ const getTurnArray = () =&gt; ( '' === Campaign().get('turnorder') ? [] : JSON.parse(Campaign().get('turnorder'))); const setTurnArray = (ta) =&gt; Campaign().set({turnorder: JSON.stringify(ta)}); const addTokenTurn = (id, pr) =&gt; setTurnArray([...getTurnArray(), {id,pr}]); const addCustomTurn = (custom, pr) =&gt; setTurnArray([...getTurnArray(), {id:"-1",custom,pr}]); const removeTokenTurn = (tid) =&gt; setTurnArray(getTurnArray().filter( (to) =&gt; to.id !== tid)); const removeCustomTurn = (custom) =&gt; setTurnArray(getTurnArray().filter( (to) =&gt; to.custom !== custom)); const clearTurnOrder = () =&gt; Campaign().set({turnorder:'[]'}); const sorter_asc = (a, b) =&gt; a.pr - b.pr; const sorter_desc = (a, b) =&gt; b.pr - a.pr; const sortTurnOrder = (sortBy = sorter_desc) =&gt; Campaign().set({turnorder: JSON.stringify(getTurnArray().sort(sortBy))}); /* eslint-enable no-unused-vars */ const times = (n,f) =&gt; Array(n).fill(n).map(f); const d10 = ()=&gt;randomInteger(10); on('chat:message',msg=&gt;{ if('api'===msg.type &amp;&amp; /^!7si(\b\s|$)/i.test(msg.content) ){ let who = (getObj('player',msg.playerid)||{get:()=&gt;'API'}).get('_displayname'); let args = msg.content.split(/\s+/).slice(1); if(args.includes('--sort')){ if(playerIsGM(msg.playerid)){ sortTurnOrder(sorter_asc); } else { sendChat('',`/w "${who}" &lt;div&gt;&lt;code&gt;Only the GM can sort the turn order.&lt;/code&gt;&lt;/div&gt;`); } } else if(args.includes('--clear')){ if(playerIsGM(msg.playerid)){ clearTurnOrder(); } else { sendChat('',`/w "${who}" &lt;div&gt;&lt;code&gt;Only the GM can clear the turn order.&lt;/code&gt;&lt;/div&gt;`); } } else { (msg.selected || []) .map(o=&gt;getObj('graphic',o._id)) .filter(g=&gt;undefined !== g) .map(o=&gt;({ t: o, a: (findObjs({name:args[0], type: 'attribute', characterid: o.get('represents')})[0] || {get:()=&gt;1}) })) .forEach( o =&gt; times(parseInt(o.a.get('current'))||1,d10).forEach( n =&gt; addTokenTurn(o.t.id,n))) ; } } }); });
Unbelievable. You are such a gift. Thank you so much!
1619025453
The Aaron
Roll20 Production Team
API Scripter
Cool.&nbsp; =D&nbsp; No problem.
The Aaron said: Cool.&nbsp; =D&nbsp; No problem. I haven't had a chance to sit down and look at things until this morning, but it looks like the !7si ATTR_NAME only adds someone to the turn order once no matter what they have in there. I've tried it both as !7si --Panache and !7si Panache with multiple different tokens and characters. The sort and the clear functions seem to work great. Any ideas?
1619096279
The Aaron
Roll20 Production Team
API Scripter
If you try this: @{selected|Panache} do you get a number other than 0 or 1?
I can try when I get home. I did make sure everyone had the correct showing on the attribute screen, between 2 and 4 for the characters I grabbed.
1619117532
The Aaron
Roll20 Production Team
API Scripter
If you want to PM me an invite and GM me, I can take a look directly.
1619139763
The Aaron
Roll20 Production Team
API Scripter
Fixed!&nbsp; The attribute's number was a string, so I had to convert it, now it should work just fine!&nbsp; (I left the copy in yoru game corrected and corrected the script above).
Checked it out just now. Thanks so much! What a cool guy. I hope everything you eat from now on tastes slightly better than you expect.
1619180930
The Aaron
Roll20 Production Team
API Scripter
Lol! &nbsp;Me too, that sounds great! Glad it's working for you now!