# Difference between revisions of "Useful Macros"

## Useful Macros for Players

Work in progress (use for general systems only, if system specific add to that page!)

### D20 Based Systems

Generic Roller:

"20": /me rolls a [[1d20+?{modifier|0}]] for ?{reason|no reason}.

When clicked, this macro will prompt the user to enter a number, which represents the skill modifier to be added to a d20 roll.
Then it will ask the user to explain why this die was rolled.

For example, if the player is making a SWIM check with a swimming skill of 4, they'd type 4, enter, swimming, enter.
The results will look something like:

Phnord rolls a 17 for swimming!

If the user enters nothing for both prompts, the results will look something like:

Phnord rolls a 13 for no reason!

-Phnord Prephect--Phnord P. (talk) 21:01, 18 December 2013 (EST)

### Pathfinder

useful Pathfinder macros here: Macros - Pathfinder Examples

### Conditional Statements

Using the multiplicative properties of 0(absorption) and 1(identity) you can write conditional statements for integer values(and to some extent floating point values too)

An example of this is the formula if x greater than or equal to A then T else F where T,F are some values

This can be written as a macro with

```[[-floor((A-x-0.1)/(abs(A-x-0.1)+0.001))*T - floor((x+0.1-A)/(abs(x+0.1-A)+0.001))*F]]
```

Similarly x greater than A then T else F is written

```[[-floor((A-x+0.1)/(abs(A-x+0.1)+0.001))*T - floor((x-0.1-A)/(abs(x-0.1-A)+0.001))*F]]
```

x equals A is slightly more complicated. It can be written as (x greater than or equal to A then T else F) - (x greater than A then T-F else 0) or as a macro

```[[-floor((A-x-0.1)/(abs(A-x-0.1)+0.001))*T - floor((x+0.1-A)/(abs(x+0.1-A)+0.001))*F - (-floor((A-x+0.1)/(abs(A-x+0.1)+0.001))*(T-F))]]
```

Now for some identities, x less than A is the inverse of x greater than or equal to A so the conditional can be written as x greater than or equal to A then F else T using the formulas above, similar with A less than or equal to A and x greater than A, and similar with x not equal to A and x equal to A.

## Useful Macros for GMs

Work in progress (use for general systems only, if system specific add to that page!)

Initiative roller for d20 systems:

For GM-Controlled Tokens:
"GM INIT": /emas @{selected|token_name} rolls a [[1d20+?{modifier|0}&{tracker}]] for initiative!

Make sure to select "Token Action" before saving!

For GM use only; see below for players.
To use, select the token. Hit the button (GM INIT). When prompted, enter the total initiative modifier for the token. Token will automatically be added to turn order.

For Player-Controlled Tokens:
"Initiative": @{selected|token_name} rolls a [[1d20+@{selected|initiative}&{tracker}]] for initiative!

Make sure to select "Token Action" before saving!
Make sure to select "Visible to Players: All Players" before saving!

For Player Use:
To use, have an Attribute in Journal Entry linked to that token called 'initiative', which represents that characters total initiative modifier. Select token, hit the button "Initiative". Token will automatically be added to turn order.

Improved Version:

This does the same thing, but then adds the initiative bonus as a decimal after the initial roll (in cases of a tie, the higher initiative bonus is sorted to go first.)

Initiative: [[1d20+@{Initiative}+(@{initiative}/100)&{tracker} ]]

-by Phnord Prephect--Phnord P. (talk) 19:15, 18 December 2013 (EST)

Generic roll that asks player / gm how many dice to throw to determine hits:

/r ?{Modifier|0}d6>5

Add as a macro and enable "in bar" so that the shortcut shows up below the player profiles.

--Moritz J. (talk) 06:27, 7 February 2014 (EST)
/roll {@{Character Name|Attribute}d@{Character|Physique}}>4

## Other Macro Related Information

Work in progress (use for general systems only, if system specific add to that page!)

### Common Macro/Dice Issues

These are a list of common pitfalls when creating complex macros or dice rolls.

#### Subtracting a Negative Attribute

When subtracting an attribute it is best to put parentheses around the attribute. What this is preventing from happening is a double subtraction instead of the subtraction of a negative. For example let's say our THAC0 attribute is negative two. /r 1d20-@{THAC0} translates into /r 1d20--2, which is bad syntax and will fail. /r 1d20-(@{THAC0}) translates into /r 1d20-(-2), which is good syntax and will give you the desired result.

### Custom Power Cards

Custom Power Cards are not macros, they are an API script for apply html and css to output of a macro in the chat pane.

Sample of a standard macro and its output.

• Standard macro that will including an emote, plus my attack and damage rolls it would look like this:
Macro Name:
`dagger`
Macro Body:
`/me rams his dagger home`
`/roll 1d20+10 vs AC`
`/roll 1d4+9 Damage`
• The output would look like:

Sample of a standard macro action with Custom Power Cards.

• With Custom Power Cards the macro would be constructed as an API command using Custom Power Cards markup tags:
Macro Name:
`dagger`

Macro Body:
`!power --emote|@{selected|token_name} rams his dagger home --name|Short Sword --leftsub|Melee --rightsub|Main Hand --attack|[[1d20+10]] --defense|AC --damage|[[1d4+9]] --dmgtype|piercing`
• The output would look like: