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 .
×

Earthdawn - Using Group Initiative API (with unique "Step" system for Dice)

1563977933

Edited 1564006885
(This is my 1st time posting on the forums) Greetings everyone! I had a question regarding the "Group Initiative" script, that was created by The Aaron. I would love to use this in my game, Earthdawn 4th edition, but Earthdawn's dice rules are different than other games. It follows a step system. Here is a sample of what it looks like, if you were to check your initiative bonus (or any other roll). Another rule is:&nbsp; if the maximum number on a Dice is rolled, that dice should be rolled one more time and added to the previous maximum value. For example, d8, rolling an 8 would be rolled again. If it rolled a 5 on the second roll, the final value would be 13. When I click the buttons on my character sheet, the correct calculations / dice are already used for me, just by inputting the Step number. I would like to use the Group Initiative because it can generate initiatives at once and add them to the tracker, however, I'm not sure if it's possible to tie this to the dice calculations being done within the character sheet. Here is the character sheet I'm using. (I hope it's ok to link this) <a href="https://github.com/Roll20/roll20-character-sheets/tree/master/Earthdawn-4E" rel="nofollow">https://github.com/Roll20/roll20-character-sheets/tree/master/Earthdawn-4E</a> The scrips I'm using are: PowerCards.js&nbsp; &nbsp; &nbsp;TokenMod&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ChatSetAttr&nbsp; &nbsp; &nbsp;(Group Initiative) If I've failed to provide any information that would be helpful, please let me know what I can add. Please let me know if the Group Initiative script can be used as it is, or if I would need to try to figure out another way. Thanks for reading and helping.&nbsp; =)
1564006317
The Aaron
Roll20 Production Team
API Scripter
GroupInitiative doesn't support that style of rolling (yet, I'd love it but time constraints...).&nbsp; I have ANOTHER script that does.&nbsp; I wrote it a long time ago, so it's not quite as full-featured as more recent scripts, but I'm totally up to using it as a jumping off point for something nicer, or even rolling into GroupInitiative (I'd love to add a pluggable, extensible roller system for things like this). Commands: !step &lt;NUMBER&gt; -- does a roll publicly with the given step number, outputs results to chat. !gstep &lt;NUMBER&gt; -- does a roll privately with the given step number, outputs results to GM !istep &lt;NUMBER&gt; -- does a roll publicly with the given step number, outputs results to chat and puts all selected tokens into the initiative order with the result. All outputs can be hovered to see what was rolled, a little rudimentarily. Here's the code: on('ready',function(){ "use strict"; var stepRolls = [ '1d4!-2' , '1d4!-1' , '1d4!' , '1d6!' , '1d8!' , '1d10!' , '1d12!' , '2d6!' , '1d8!+1d6!' , '2d8!' , '1d10!+1d8!' , '2d10!' , '1d12!+1d10!' , '2d12!' , '1d12!+2d6' , '1d12!+1d8!+1d6!' , '1d12!+2d8!' , '1d12!+1d10!+1d8!' , '1d20!+2d6!' , '1d20!+1d8!+1d6!' , '1d20!+2d8!' , '1d20!+1d10!+1d8!' , '1d20!+2d10!' , '1d20!+1d12!+1d10!' , '1d20!+2d12!' , '1d20!+1d12!+2d6!' , '1d20!+1d12!+1d8!+1d6!' , '1d20!+1d12!+2d8!' , '1d20!+1d12!+1d10!+1d8!' , '2d20!+2d6!' , '2d20!+1d8!+1d6!' , '2d20!+2d8!' , '2d20!+1d10!+1d8!' , '2d20!+2d10!' , '2d20!+1d12!+1d10!' , '2d20!+2d12!' , '2d20!+1d12!+2d6!' , '2d20!+1d12!+1d8!+1d6!' , '2d20!+1d12!+2d8!' , '1d20!+1d12!+1d10!+1d8!' ], ch = function (c) { var entities = { '&lt;' : 'lt', '&gt;' : 'gt', "'" : '#39', '@' : '#64', '{' : '#123', '|' : '#124', '}' : '#125', '[' : '#91', ']' : '#93', '"' : 'quot', '-' : 'mdash', ' ' : 'nbsp' }; if(_.has(entities,c) ){ return ('&amp;'+entities[c]+';'); } return ''; }, getFormatForDice = function (dice) { var maxroll = 0, minroll = 0, dicePart = _.chain(dice.results.rolls) .map(function(r){ return '(' + _.map(r.results, function(r2) { maxroll += ( r.sides === r2.v ? 1 : 0 ); minroll += ( 1 === r2.v ? 1 : 0 ); return r2.v; }).join('+')+')'; }) .reject(function(r){ return '()'===r; }) .value().join('+'), rollOut = '&lt;span style="text-align: center; vertical-align: text-top; display: inline-block; min-width: 1.75em; border-radius: 5px; padding: 0px 2px; border-width: 2px; border-color: ' + ( maxroll &amp;&amp; minroll ? '#4A57ED' : ( maxroll ? '#3FB315' : (minroll ? '#B31515' : '') ) ) + '" title="Rolling '+dice.expression+' = ' + dicePart + '" class="a inlinerollresult showtip tipsy-n ' + ( maxroll &amp;&amp; minroll ? 'importantroll' : ( maxroll ? 'fullcrit' : (minroll ? 'fullfail' : '') ) ) + '"&gt;' + dice.results.total + '&lt;/span&gt;'; return rollOut; }; on('chat:message', function(msg){ var args = msg.content.split(/\s+/), turnorder, stepNum; if('api' !== msg.type) { return; } switch(args.shift()) { case '!step': stepNum=parseInt(args.shift(),10); if(stepNum &gt;= 1 &amp;&amp; stepNum &lt;= 40) { sendChat(msg.who, 'Step '+ stepNum + '&lt;br&gt;' +' [['+stepRolls[stepNum-1]+']]'); } else { stepNum = stepNum || '&lt;blank&gt;'; sendChat(msg.who, '&lt;b&gt;Error:&lt;/b&gt; Step Number '+stepNum+' is not valid!'); } break; case '!gstep': stepNum=parseInt(args.shift(),10); if(stepNum &gt;= 1 &amp;&amp; stepNum &lt;= 40) { sendChat(msg.who, '/w gm Step '+ stepNum + '&lt;br&gt;' +' [['+stepRolls[stepNum-1]+']]'); } else { stepNum = stepNum || '&lt;blank&gt;'; sendChat(msg.who, '/w gm &lt;b&gt;Error:&lt;/b&gt; Step Number '+stepNum+' is not valid!'); } break; case '!istep': stepNum=parseInt(args.shift(),10); if(stepNum &gt;= 1 &amp;&amp; stepNum &lt;= 40) { sendChat('', '[['+stepRolls[stepNum-1]+']]',function(msgs) { var msg2 = msgs.pop(), idx = msg2.content.match(/\$\[\[(\d+)\]\]/)[1], rolls=msg2.inlinerolls[idx]; if(rolls) { turnorder = Campaign().get('turnorder'); turnorder = ('' === turnorder) ? [] : JSON.parse(turnorder); Campaign().set({ turnorder: JSON.stringify( _.chain(msg.selected) .map(function(s){ return getObj(s._type,s._id); }) .reject(_.isUndefined) .map(function(s){ return { token: s, character: getObj('character',s.get('represents')) }; }) .reduce(function(m,s){ let entry=_.findWhere(m,{id: s.token.id}); if(entry){ entry.pr = rolls.results.total; } else { m.push({ id: s.token.id, pr: rolls.results.total, custom: '' }); } return m; },turnorder) .value() ) }); sendChat(msg.who, '/direct Inititative roll: '+getFormatForDice(rolls)); } }); } else { stepNum = stepNum || '&lt;blank&gt;'; sendChat(msg.who, '&lt;b&gt;Error:&lt;/b&gt; Step Number '+stepNum+' is not valid!'); } break; } }); });
Hello Aaron, Thanks a bunch for all the work you did. I was blown away when I saw your response and the code. I've added your script into the game and tested out the "istep" which is the main one I would be using in games. It works perfectly. I also like the fact that I can hover over it to see what was rolled. (The maximum number results are also being rolled again, which is wonderful.&nbsp; ^_^ ) As a note about Earthdawn combat mechanics, the NPC's get re-rolled every round. So this is a script that I will be using a ton. Two potential things that would be on my "wish list" that I wanted to ask you about were: On each of my NPC's character sheets, there is an attribute which specifies the NPC's initiative step number. It's called Init_Mod. Would it be possible to pull this value as a variable, instead of me having to type a number into the macro? So instead of typing "!istep 10", it could be "!istep Init_Mod". If this were true, then I could simple click the token, run the macro, click the next token, click the macro, and it would pull in all their different numbers. This would help a ton, since I wouldn't have to manually check the character sheet each time to see what each different NPC's value was. The second thing, (which is probably more difficult) is that I really liked the functionality of your Group Initiative script. Mainly the ability to select multiple tokens and generate all their values and add them to the tracker at the same time.&nbsp; So if I dragged a box around a group of NPC's 1,2, 3, 4, and 5, and somehow was able to roll their Init_Mod, which might have values of something like: step 6 for the first guy, step 8 for the second, step 9, for the third, step 5 for the fourth, and step 10 for the 5th. If the script could roll the corresponding dice, and add the rolled value alongside the NPC that rolled it, into the tracker, then that would be amazing. Please let me know your thoughts if this script can be taken further. Thanks for your help!
1564053750
The Aaron
Roll20 Production Team
API Scripter
Those are absolutely possible. You can do the first one now, just make a macro with: !step @{selected|Init_Mod} The second requires code, but can still be done without too much trouble. I'll see what I can whip up in the next few days.&nbsp;