Generic 5e Macro
Code: Select all
[h: abort(input(
"rollType|Advantage, Normal, Disadvantage|Roll Type|RADIO|SELECT=1 VALUE=STRING",
"d20Bonus|0|d20 Roll Bonus|TEXT|WIDTH=10",
"dmgRoll|0|Damage Roll (optional)|TEXT|WIDTH=10",
"critDamage|0|Critical Damage (optional)|TEXT|WIDTH=10"
))]
[h: d20roll1 = 1d20]
[h: d20roll2 = 1d20]
[h, if (! isNumber(dmgRoll)): dmgRoll = eval(dmgRoll)]
[h, if (! isNumber(critDamage)): critDamage = eval(critDamage)]
<table border="0">
<tr bgcolor="green">
<td style="padding:0px 5px;">
<span style="color:white"><b>[r: if(dmgRoll == 0, "Basic", "Attack")] Roll ([r:rollType])</b></td>
</tr>
[switch(rollType), code:
case "Advantage": {
[h,if(d20roll1 > d20roll2): d20roll=d20roll1; d20roll=d20roll2]
[h: rollTT = "Highest of ("+d20roll1+", "+d20roll2+")"]
};
case "Normal": {
[h:d20roll = d20roll1]
[h: rollTT = "single d20 roll ("+d20roll1+")"]
};
case "Disadvantage": {
[h,if(d20roll1 < d20roll2): d20roll=d20roll1; d20roll=d20roll2]
[h: rollTT = "Lowest of ("+d20roll1+", "+d20roll2+")"]
}]
[h:tooltip1 = strformat("<html><table><tr><td>+%{d20roll}: %{rollTT}</td></tr><tr><td>+%{d20Bonus}: Roll Bonus </td></tr></table></html>")]
<tr>
<td style="padding:0px 5px;" white-space: nowrap;>
<b>Roll:</b>
<span title="[r:tooltip1]">[r:d20roll + d20Bonus]</span>
[if(d20roll==20), CODE:
{
<font color=red>, <b>Critical Success!</b></font>
};{}]
[if(d20roll==1), CODE:
{
<font color=blue>, <b>Failure!</b></font>
};{}]
[if(dmgRoll!=0 && d20roll!=1 && d20roll!=20), CODE:
{
, [dmgRoll] damage.
};{}]
[if(dmgRoll!=0 && d20roll==20), CODE:
{
, [critDamage] damage.
};{}]
</table>
Roll Type: Advantage takes the highest of two d20 rolls, Normal just rolls 1d20, and Disadvantage takes the lowest of two d20 rolls. The option defaults to "Normal".
d20 Roll Bonus: text field for a numerical bonus to the roll
Damage Roll (optional): standard dice expression or flat number. Leave at zero if this is not an attack.
Critical Damage (optional): standard dice expression or flat number. If Damage Roll is zero, this does nothing.
The macro output is just two lines in the chat window.
The first line just a header describing the roll. If the Damage Roll box is left at 0, the header reads "Basic Roll (RollType)". If the Damage Roll box has anything other than 0, the header reads "Attack Roll (RollType)".
The second line holds the roll results. The d20 result comes first, with a Rumble Slim style tooltip. A roll of 1 or 20 will have either "Failure!" or "Critical Success!" just after this. If the Damage Roll box has anything other than 0, damage results are printed next, otherwise the line ends.
It's not much, but it should help run a playtest character.
EDIT: And I just realized I posted this in the User Creations forum instead of the Drop-In Resources forum... Sorry, mods