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 .
Advertisement Create a free account Compendium in Game, Join Today

Marco help, not sure where to start on this one.

1508121107
Not sure where to start on this one. I have powercards, OGL 5e, TokenMob, ChatSetAttr, GroupCheck, altbars API's To be fair to my players when I attack with a monster I assign the targets in range a number and randomly roll to see whom gets attack unless the monsters are very intelligent, There for I am look for a way the I could select the targets that would be in ranger and this number would vary. Example if it was a range attack then 1d5 or 1d6 PC might be in ranger. If melee 1d2 or 1d3. Selecting the targets would vary 1d2 to 1d10. Then out of the selected target it would randomly select one and whisper the name to me preferably in a power card format. Any ideas please? Craven
1508122436
Scott C.
Forum Champion
Sheet Author
API Scripter
For the exact functionality you want, you'll need a custom API script. It's possible one of the scripts you already have installed could do this, but I don't believe they can. I can see an ugly way to sort of do it with macros: Macro Name: 3 targets /w gm ?{Roll 1d3 and attack|1: @{target|One|character_name}|2: @{target|Two|character_name}|3: @{target|Three|character_name}} You would need to make a macro like the above for each likely combo of possible targets. Like I said, ugly way to do it via just macros.
I don't have the greatest knowledge of/access to API so I may not be that useful but I feel like you could frankenstein a way of doing this using Token Mod to select tokens within range of a target token and then Group Check the selected tokens to make a flat d20 roll. Then the highest, or the lowest if you wanted, of the d20 rolls is the 'winner'. If that works you may even be able to use it with intelligent monsters by giving advantage/disadvantage (or some other bonus or penalty) on the roll to PCs that are less/more likely to be targeted.
Another way to do it, which wouldn't require any API, would be to create a rollable table with 1 instance of each of the PCs names on it.  Then you could create a macro like this: /w gm The enemy attacks [[1t[PCNames]]]! Obviously, the table you create would have to be named "PCNames".  If the name comes up as someone out of range, just hit the macro again.
1508164315
The Aaron
Forum Champion
API Scripter
So, if you just need to randomly pick between N different tokens, how about this: Select the tokens and run this command to get them whispered to you in a random order: !pick Read from the top down to get the number of random targets you need.  Script: on('ready', ()=>{     const outer = (contents) => `<div style="margin-bottom: .3em;border:1px solid #999;background-color: #ffe;padding: .2em; border-radius:.2em;">${contents}</div>`;     const icon = (img)=>`<img style="max-height:2.6em;max-width:4em; float:left;" src="${img}">`;     const formatToken = (token) => `<div style="border: 1px solid #999;background-color:#eff;border-radius:.4em;padding: .1em .4em;">${icon(token.get('imgsrc'))} ${token.get('name')}<div style="clear:both;"></div></div> `; on('chat:message', (msg)=>{ if(/^!pick\b/i.test(msg.content)){ let who=(getObj('player',msg.playerid)||{get:()=>'API'}).get('_displayname'); _.chain(msg.selected) .map((o)=>getObj('graphic',o._id)) .reject(_.isUndefined) .shuffle() .map(formatToken) .tap((ts)=>sendChat('Pick',`/w "${who}" ${outer(ts.join(''))}`)) ; } }); });
1508165029
The Aaron said: So, if you just need to randomly pick between N different tokens, how about this: Select the tokens and run this command to get them whispered to you in a random order: !pick Read from the top down to get the number of random targets you need.  Script: on('ready', ()=>{     const outer = (contents) => `<div style="margin-bottom: .3em;border:1px solid #999;background-color: #ffe;padding: .2em; border-radius:.2em;">${contents}</div>`;     const icon = (img)=>`<img style="max-height:2.6em;max-width:4em; float:left;" src="${img}">`;     const formatToken = (token) => `<div style="border: 1px solid #999;background-color:#eff;border-radius:.4em;padding: .1em .4em;">${icon(token.get('imgsrc'))} ${token.get('name')}<div style="clear:both;"></div></div> `; on('chat:message', (msg)=>{ if(/^!pick\b/i.test(msg.content)){ let who=(getObj('player',msg.playerid)||{get:()=>'API'}).get('_displayname'); _.chain(msg.selected) .map((o)=>getObj('graphic',o._id)) .reject(_.isUndefined) .shuffle() .map(formatToken) .tap((ts)=>sendChat('Pick',`/w "${who}" ${outer(ts.join(''))}`)) ; } }); }); OMG Thank you, you are amazing.
1508165236
The Aaron
Forum Champion
API Scripter
=D  Cheers.