-
Notifications
You must be signed in to change notification settings - Fork 102
Adding System Support
Automated Animations access to a few key pieces of information for the module to work.
- Item: The Item instance that is being used
- Source Token: The Token that is using the Item
- Target(s): The current targets when the Item is used/rolled
For MOST systems, this data is obtained using the createChatMessage hook. Other systems, such as Warhammer, provide system specific hooks that can be used to grab the information.
Furthermore, many systems roll separately for Attack and Damage. The Chat Message needs to be evaluated in these cases to determine if the player is rolling an Attack or Damage, OR in some cases the item has neither an Attack OR Damage roll, so that would need to be evaluated as well.
To check if your system has this data, you can start by putting CONFIG.debug.hooks = true
into the dev Console (F12). Now, every time you use an Item Hook calls will display and you can investigate and search for the data. Generally the createChatMessage
hook will contain some of the data. Using the DnD5e CORE system as an example:
- The
createChatMessage
hook has theItem ID
in the HTML. Reference thestatic async dnd5e(input, isChat)
function, line 49, insrc/system-handlers/getdata-by-system.js
. Using this I attempt to extract the Item ID. Then the following line first checks to see if theItem ID
was logged in the Chat Message data, then falls back to the HTML. - From there you will need to get the Token that is using the item, and then the list of Targets (if any) that are targetted.
-
Specific settings can be created in the
settings.js
file under thesrc
folder -
Hooks should be registered for the game system in the
autoAnimations.js
file also located in thesrc
folder. This starts on line 193. Create and reference specific functions that should be called when the Hook is activated. You can reference theDnD 5e
method at line 541 for handling all the different attack/damage rolls.
If you are using the createChatMessage
hook it is important to be able to separate out Attack and Damage rolls if your system has those and rolls them separately. Otherwise animations will fire every time something is rolled. At the start of the function you should also use if (msg.user.id !== game.user.id) { return };
to prevent animations being created from every connected client.
After registering the Hooks, and sending the hook data to a function, you'll need to call const handler = await systemData.make(message or hook data here)
. This then sends the data to system-data.js
in src/system-handlers
. The next step requires creating a static async
function in getdata-by-system.js
in the same folder location. Use the existing ones as an example of what should be returned.
The full workflow goes something like:
**Hook Fires => Function Runs and separates out attack/damage if needed => Send data to the system-data.js
file => system data is compiled in getdata-by-system.js
=> Handler is returned to the Function. Then finally a simple call of trafficCop(handler)
will get the animations started.