From d5a4419f46fd8275fffd7d6a6020e58d2f6750ba Mon Sep 17 00:00:00 2001
From: DameryDad <74715860+DameryDad@users.noreply.github.com>
Date: Sat, 24 Feb 2024 09:19:25 +0000
Subject: [PATCH] Better handling of hidden items
* Improvements to management of hidden items.
* Config item to set default reveal type to on use or manually.
* Better support for data attribute hide: - force hiding with 'hide', default to auto-hide state with no definition, or force no hiding with anything else.
* Improve parseStr() handling of undefined or empty strings.
---
MagicMaster/3.2.1/MagicMaster.js | 9579 ++++++++++++++++++++++++++++++
MagicMaster/MagicMaster.js | 75 +-
MagicMaster/magicMaster.js | 75 +-
MagicMaster/script.json | 4 +-
4 files changed, 9679 insertions(+), 54 deletions(-)
create mode 100644 MagicMaster/3.2.1/MagicMaster.js
diff --git a/MagicMaster/3.2.1/MagicMaster.js b/MagicMaster/3.2.1/MagicMaster.js
new file mode 100644
index 000000000..6e28f6c9d
--- /dev/null
+++ b/MagicMaster/3.2.1/MagicMaster.js
@@ -0,0 +1,9579 @@
+// Github: https://github.com/Roll20/roll20-api-scripts/tree/master/MagicMaster
+// Beta: https://github.com/DameryDad/roll20-api-scripts/tree/MagicMaster/MagicMaster
+// By: Richard @ Damery
+// Contact: https://app.roll20.net/users/6497708/richard-at-damery
+
+var API_Meta = API_Meta||{}; // eslint-disable-line no-var
+API_Meta.MagicMaster={offset:Number.MAX_SAFE_INTEGER,lineCount:-1};
+{try{throw new Error('');}catch(e){API_Meta.MagicMaster.offset=(parseInt(e.stack.split(/\n/)[1].replace(/^.*:(\d+):.*$/,'$1'),10)-8);}}
+
+/**
+ * MagicMaster.js
+ *
+ * * Copyright 2020: Richard @ Damery.
+ * Licensed under the GPL Version 3 license.
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ * This script is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This script is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ * The goal of this script is to create and automate aspects of magic spell & item
+ * discovery, storage & use, initially for the ADnD 2e game in Roll20
+ *
+ * v0.001-v2.042 Removed previous change history - see v2.048 for detail
+ * v2.043 01/01/2022 Prioritise user-defined database items over provided ones
+ * Add spell weapons to the provided weapons database (e.g. Ice Knife)
+ * Add all remaining spells from the PHB to the databases
+ * v2.044 08/01/2022 Added index of database ability objects to improve performance.
+ * v2.045 14/01/2022 Fixes to multiclass spell level calculation and non-MU/non-Priest
+ * spellcaster spell numbers, and force container type when adding items.
+ * v2.046 23/01/2022 Fixed illegal characters not rendered by One-Click installation
+ * Corrected definitions of Spear and Lightning-Bolt
+ * Added menu for adding Spells & Powers to magic items
+ * v2.047 02/02/2022 Added --config command and menu for DM to alter some API behavior
+ * Fixed Shocking Bracers LB error & enhanced Rage power
+ * Multiple weapon and magic item definition updates
+ * v2.048 24/02/2022 Fixed bug with prioritising user-defined database entries
+ * v3.050 27/02/2022 Added Class-DB as a standard database. Added Class Powers to
+ * Powers-DB. Updated abilityLookup()
+ * to cope with missing databases and abilities that were previously indexed.
+ * Fixed multiple Magic Item issues, esp. Spell Storing MIs.
+ * Restricted spellcasters to allowed spells (configurable via --config menu).
+ * Split Weapon & Armour DBs to AttackMaster.
+ * v3.051 10/03/2022 Make database load an asynchronous process to eliminate invalid
+ * "infinite loop" errors. Introduced "Creature" character class.
+ * Fixed issues with handling manual updates to Character Sheet tables.
+ * Added support for Attacks-DB. Synchronised DB Indexing between APIs
+ * to ensure all DBs loaded before indexing.
+ * v3.060 28/03/2022 Moved all Table Mgt, Ability Mgt, Chat Mgt, Database Mgt to a
+ * shared library
+ * v3.061 25/04/2022 Fixed all errors found in 3.060, and moved all game-specific and
+ * character sheet specific data structures to RPG-specific shared library
+ * v3.062 16/05/2022 Added function to configure output by player so players can choose their
+ * own output type.
+ * v3.063 18/05/2022 Updated menu & item display to use RPGM roll templates. Improved error
+ * message for character classes that cast spells at levels they've not
+ * yet attained.
+ * v3.064 14/07/2022 Removed whispers from database entries and changed to direct to
+ * appropriate player programmatically so that GM can test locally
+ * v0.3.65 19/07/2022 Converted to use revised internal database structures
+ * v0.3.66 17/09/2022 Optionally allow semi-colon as an escape character terminator. Updated dB
+ * functions to copy items used by a character to their sheet so can be moved
+ * to new campaigns easily. Added more RPGMaster common functions to library.
+ * Moved help handouts to Library. Support editing martial MIs and other MIs
+ * separately. Improved handling of MIs with spells & powers. Support only
+ * showing item types when searching containers. Allow spell name as parameter
+ * for --cast-again. Improved menu processing for viewing & using MIs. Added
+ * renaming, auto-reveal, and type-only containers to --GM-edit-MI menu. Added
+ * --tidy command to remove attributes and ability macros no longer needed on
+ * specified Character Sheets. Updated --help command to display handouts.
+ * Added --extract-db command to generate a Character Sheet version of a database
+ * if GM wants it.
+ * v1.3.00 17/09/2022 Brought version numbering in line with other APIs. First release using
+ * RPGMaster RPG-version-specific Library.
+ * v1.3.01 07/10/2022 Allow spells to be set as powers, and fix clashes between MIs that use the
+ * same powers and spells, and improve CS --tidy function
+ * v1.3.02 09/10/2022 Support spell level absorbing magic items, and spells as weapons. Fixed
+ * regular expression for database Specs parsing
+ * v1.3.03 11/11/2022 Add a button to the Memorise Powers menu to memorise all currently valid powers.
+ * Fixed some error messages. Added response to --index-db command. Added
+ * config option for restricting powers to valid level or not.
+ * v1.3.04 24/11/2022 Skipped, to keep in line with versions of other APIs
+ * v1.3.05 24/11/2022 Added new --level-change command to allow level-drain by creatures.
+ * v1.4.01 28/11/2022 Support for the extended Creatures database & fighting styles. Extended String
+ * prototype with dbName() method.
+ * v1.4.02 13/11/2022 Added ability to specify "cast as level" in Class/Race/Creature powers
+ * v1.4.03 24/01/2023 Fixed bugs in getting class/race default power uses per day, and in
+ * finding blank/extended rows in the Items table to store items in.
+ * v1.4.04 24/01/2023 Added support for configurable default token bar mapping. Added separate
+ * Ammo list to Change MI menu (appears if AttackMaster is not loaded).
+ * v1.4.05 02/03/2023 Moved character level parsing to library. Added charge type override to
+ * --mi-charges command. If casting level of MI powers/spells not specified
+ * default to that of character. Fix removeMIpowers() to deal with spaces.
+ * Added 'perm-' charge type qualifier to prevent any MI from disappearing at
+ * zero charges. Add destination command to --message syntax. Add --mi-rest
+ * command to reset single MI or single MI power.
+ * v1.4.06 08/04/2023 Fixed bug with item search introduced by v1.4.05. Added magic item bag
+ * creation to support Bags of Holding, and MIs that contain other MIs. Fixed
+ * inconsistencies with hyphenated item names and spell / power storing items.
+ * v1.4.07 15/04/2023 Added 'discharging' and 'cursed-uncharged' item types which do not divide. Added
+ * ability for items to store spells as powers using --store-spells command.
+ * Added current qty of currently selected MI to MIct|max attribute (itemQty field)
+ * on the character sheet.
+ * v1.4.08 16/04/2023 Fixed issues with hiding and revealing cursed items. Added alphabeticised lists
+ * and item review to the GM Add Items menu.
+ * v1.5.01 17/05/2023 Added 'qty:' data tag to specify initial quantity of any item. Added support
+ * for 'Looks Like' template tag supporting auto-hiding of items. Added 'st:'
+ * data tag to specify displayed type of a hidden item. Added RPGM config options
+ * for 'Allow Any Power', 'alpha lists' & 'auto-hide items'. Added the
+ * 'single-uncharged' item charge type to designate uncursed uncharged items that
+ * do not stack or divide when looted or stored, and perhaps discharge
+ * unconventionally. Moved getShownType() to library so can be used from
+ * other APIs. Improved tidying of MI ability macros on character sheets. Added
+ * auto-hiding of items with the 'Looks Like' template tag. Return to GM Add Items
+ * dialog if GM is reviewing MI spells. Use a GM whisper when GM is viewing the
+ * description of a spell or item a character has just used. Default casting level
+ * of a power to that of the caster if level is not specified in definition. Extended
+ * --mi-power and --mi-rest commands to support powers able to drain multiple charges
+ * and set new maximums per day. Fixed --tidy command and auto-tidying of character
+ * sheets. Prevented --tidy from accidentally tidying any db character sheet that
+ * had been dropped as a token. Allow --message to take a character ID or a token ID
+ * to send the message to
+ * v1.5.02 24/05/2023 Fixed tableLookup() reference for storing spells in spell-storing MIs. Fixed use
+ * of alphabetical lists in the GM's Add Items dialog.
+ * v1.5.03 08/06/2023 Fixed error where a self-hidden item name does not have a db definition.
+ * v2.1.0 21/07/2023 Extend the --mem-spell command with -ADD and -ANY command qualifiers that give
+ * players the ability to add additional spells to a spell storing MI, and/or
+ * change the existing spells. Weaponised spells cast from spell-storing MIs now
+ * restrict the "Change Weapon" lists to only include weponised spells from the MI.
+ * Made many more functions asynchronous to multi-thread. Fixed bug setting non-MU
+ * and non-PR spell-casters to incorrectly have MU or PR spell level. Fixed issue
+ * of trying to display non-hyphenated abilities from char sheet. Fixed container
+ * type not updating when items are stored in it to become searchable.
+ * v2.2.0 21/07/2023 Implemented The Aaron's API_Meta error handling. Added senderId override capability
+ * as id immediately after !magic & before 1st --cmd. Added –learn command to run a
+ * “learn a spell” process for wizards. Added –find-traps command to support finding
+ * traps separately from –search command, and allow it on non-type 4 containers.
+ * Moved reACspecs, reSpellSpecs & reClassSpecs to library. Added Skill-based roll
+ * configuration option switching GM-rolled thieving actions (Find Traps) with player
+ * rolled. Converted some messages to use new sendMsgToWho() function to improve
+ * message addressing. Several bug fixes. Fixed checkValidSpell() and changeMIspells()
+ * to support new –learn command. Support better management of Magic Item spells,
+ * using similar approach as to Powers. Removed potential setTimeout() issues with
+ * asynchronous use of variable values – passed as parameters instead. Improved
+ * --search processing to ensure works for both search & store. Fixed button case error.
+ * v2.3.0 19/09/2023 Fixed spell-storing magic item issue with '-ADD' and '-ANY' capabilities. Added
+ * '-CHANGE' capability to spell-storing MIs. Added 'store' and 'lvl' attributes to
+ * MI data definitions to set the 'add', 'any' and 'change' status (defaults to 'none'),
+ * and to restrict the number of spell levels stored (defaults to 99).Extend
+ * handleAddAllPowers() to also deal with MU & PR spells at all levels, and made it
+ * asynchronous. Fixed checking valid spells & valid powers. Use stored spell
+ * row/column data to build item-specific spell lists. Ensure that --change-attr
+ * command rounds correctly for odd/even scores.
+ * v2.3.1 19/10/2023 For --extract-db if multiple databases start with the supplied name, ask which to extract
+ * v2.3.2 25/10/2023 Fixed hyphenation of reviewed weapons, items, spells & powers. Changed behavior of
+ * menu to memorise spells & powers so more intuitive.
+ * v2.3.3 05/11/2023 Fixed issue with case mismatch on looking up SpellsPerLevel.
+ * v2.3.4 12/11/2023 Fixed issue with level at which Powers are cast.
+ * v3.0.0 31/10/2023 Added support for other character sheets and game systems. Corrected how the
+ * casting level of spells used as powers are calculated. Fixed storing items in
+ * type 6 or 7 containers. Added query: attribute to magic items to add Roll Queries
+ * to adding a new MI to a sheet to drive variable data. Moved parseData() to library.
+ * Fixed Long Rest for MI spells & powers. Added config option for magical weapon plus
+ * affecting weapon speeds, and corrected --config command documentation.
+ * v3.1.0 17/12/2023 Added additional support for other character sheets. Moved configuation menu to
+ * library. Added support for an "item carried" flag as used on the AD&D1e sheet.
+ * v3.1.2 15/01/2024 Implemented inheritance for magic item database objects. Implemented magic item
+ * query: and variables. Implemented "change-last" and "cursed+change-last" magic item
+ * classes for items that change to a different item when reaching zero charges. Added
+ * "Remove Curse" option to GM-only MI menu. Use evalAttr() when specifying qty for
+ * storing an MI
+ * v3.2.0 08/02/2024 New recharge types 'enable' and 'disable' which are uncharged but allow c:
+ * charge comparisons to support enabling and disabling of weapon attack rows. Fix
+ * moving hidden db item variables to always move with the trueName of the weapon
+ * (not the name). Added swordType as a shorthand query tag. Fixes to do with handling
+ * hidden equipment items. Add optional API command as a 5th parameter to --message
+ * command.
+ * v3.2.1 11/02/2024 Improvements to management of hidden items. Config item to set default reveal type
+ * to on use or manually. Better support for data attribute hide: - force hiding with
+ * 'hide', default to auto-hide state with no definition, or force no hiding with
+ * anything else. Improve parseStr() handling of undefined or empty strings.
+ */
+
+var MagicMaster = (function() {
+ 'use strict';
+ var version = '3.2.1',
+ author = 'RED',
+ pending = null;
+ const lastUpdate = 1708765145;
+
+ /*
+ * Define redirections for functions moved to the RPGMaster library
+ */
+
+ const getRPGMap = (...a) => libRPGMaster.getRPGMap(...a);
+ const getHandoutIDs = (...a) => libRPGMaster.getHandoutIDs(...a);
+ const setAttr = (...a) => libRPGMaster.setAttr(...a);
+ const attrLookup = (...a) => libRPGMaster.attrLookup(...a);
+ const setAbility = (...a) => libRPGMaster.setAbility(...a);
+ const abilityLookup = (...a) => libRPGMaster.abilityLookup(...a);
+ const doDisplayAbility = (...a) => libRPGMaster.doDisplayAbility(...a);
+ const getAbility = (...a) => libRPGMaster.getAbility(...a);
+ const getTableField = (...t) => libRPGMaster.getTableField(...t);
+ const getTable = (...t) => libRPGMaster.getTable(...t);
+ const getLvlTable = (...t) => libRPGMaster.getLvlTable(...t);
+ const initValues = (...v) => libRPGMaster.initValues(...v);
+ const checkDBver = (...a) => libRPGMaster.checkDBver(...a);
+ const saveDBtoHandout = (...a) => libRPGMaster.saveDBtoHandout(...a);
+ const buildCSdb = (...a) => libRPGMaster.buildCSdb(...a);
+ const checkCSdb = (...a) => libRPGMaster.checkCSdb(...a);
+ const getDBindex = (...a) => libRPGMaster.getDBindex(...a);
+ const updateHandouts = (...a) => libRPGMaster.updateHandouts(...a);
+ const findThePlayer = (...a) => libRPGMaster.findThePlayer(...a);
+ const findCharacter = (...a) => libRPGMaster.findCharacter(...a);
+ const fixSenderId = (...a) => libRPGMaster.fixSenderId(...a);
+ const evalAttr = (...a) => libRPGMaster.evalAttr(...a);
+ const getCharacter = (...a) => libRPGMaster.getCharacter(...a);
+ const characterLevel = (...a) => libRPGMaster.characterLevel(...a);
+ const caster = (...a) => libRPGMaster.caster(...a);
+ const getTokenValue = (...a) => libRPGMaster.getTokenValue(...a);
+ const classObjects = (...a) => libRPGMaster.classObjects(...a);
+ const redisplayOutput = (...a) => libRPGMaster.redisplayOutput(...a);
+ const getMagicList = (...a) => libRPGMaster.getMagicList(...a);
+ const getShownType = (...a) => libRPGMaster.getShownType(...a);
+ const addMIspells = (...a) => libRPGMaster.addMIspells(...a);
+ const handleCheckWeapons = (...a) => libRPGMaster.handleCheckWeapons(...a);
+ const handleCheckSaves = (...a) => libRPGMaster.handleCheckSaves(...a);
+ const parseClassDB = (...a) => libRPGMaster.parseClassDB(...a);
+ const parseData = (...a) => libRPGMaster.parseData(...a);
+ const resolveData = (...a) => libRPGMaster.resolveData(...a);
+ const makeConfigMenu = (...a) => libRPGMaster.makeConfigMenu(...a);
+ const sendToWho = (...m) => libRPGMaster.sendToWho(...m);
+ const sendMsgToWho = (...m) => libRPGMaster.sendMsgToWho(...m);
+ const sendPublic = (...m) => libRPGMaster.sendPublic(...m);
+ const sendAPI = (...m) => libRPGMaster.sendAPI(...m);
+ const sendFeedback = (...m) => libRPGMaster.sendFeedback(...m);
+ const sendResponse = (...m) => libRPGMaster.sendResponse(...m);
+ const sendResponsePlayer = (...p) => libRPGMaster.sendResponsePlayer(...p);
+ const sendResponseError = (...e) => libRPGMaster.sendResponseError(...e);
+ const sendError = (...e) => libRPGMaster.sendError(...e);
+ const sendCatchError = (...e) => libRPGMaster.sendCatchError(...e);
+ const sendParsedMsg = (...m) => libRPGMaster.sendParsedMsg(...m);
+ const sendGMquery = (...m) => libRPGMaster.sendGMquery(...m);
+ const sendWait = (...m) => libRPGMaster.sendWait(...m);
+
+ /*
+ * Handle for reference to character sheet field mapping table.
+ * See RPG library for your RPG/character sheet combination for
+ * full details of this mapping. See also the help handout on
+ * RPGMaster character sheet setup.
+ */
+
+ var fields = {
+ defaultTemplate: 'RPGMdefault',
+ spellTemplate: 'RPGMspell',
+ potionTemplate: 'RPGMpotion',
+ menuTemplate: 'RPGMmenu',
+ warningTemplate: 'RPGMwarning',
+ };
+
+ /*
+ * List of the "standard" RPGMaster databases to support identification of
+ * custom user databases and db entries to give priority to.
+ */
+
+ const stdDB = ['MU_Spells_DB','PR_Spells_DB','Powers_DB','MI_DB','MI_DB_Ammo','MI_DB_Armour','MI_DB_Light','MI_DB_Potions','MI_DB_Rings','MI_DB_Scrolls_Books','MI_DB_Wands_Staves_Rods','MI_DB_Weapons','Attacks_DB','Class_DB'];
+
+ /*
+ * Handle for reference to database data relevant to MagicMaster.
+ * Actual data is held in the relevant RPG-specific library. Refer
+ * to the library for full details. See also the help handout for
+ * each database.
+ */
+
+ var dbNames;
+
+ /*
+ * Handle for the Database Index, used for rapid access to the character
+ * sheet ability fields used to hold database items.
+ */
+
+ var DBindex = {};
+
+ /*
+ * Handle for the library object used to pass back RPG & character sheet
+ * specific data tables.
+ */
+
+ var RPGMap = {};
+
+ /*
+ * MagicMaster related help handout information.
+ */
+
+ const handouts = Object.freeze({
+ MagicMaster_Help: {name:'MagicMaster Help',
+ version:3.05,
+ avatar:'https://s3.amazonaws.com/files.d20.io/images/257656656/ckSHhNht7v3u60CRKonRTg/thumb.png?1638050703',
+ bio:'
'
+ +'
MagicMaster API v'+version+'
'
+ +'
and later
'
+ +'
The MagicMaster API provides functions to manage all types of magic, including Wizard & Priest spell use and effects; Character, NPC & Monster Powers; and discovery, looting, use and cursing of Magic Items. All magical aspects can work with the RoundMaster API to implement token markers that show and measure durations, and produce actual effects that can change token or character sheet attributes temporarily for the duration of the spell or permanently if so desired. They can also work with the InitiativeMaster API to provide menus of initiative choices and correctly adjust individual initiative rolls, including effects of Haste and Slow and similar spells. This API can also interact with the MoneyMaster API (under development) to factor in the passing of time, the cost of spell material use, the cost of accommodation for resting, and the cost of training for leveling up as a spell caster (Wizard, Priest or any other).
'
+ +'
Syntax of MagicMaster calls
'
+ +'
The MagicMaster API is called using !magic (or the legacy command !mibag).
'
+ +'
!magic --help
'
+ +'
Commands to be sent to the MagicMaster API must be preceded by two hyphens \'--\' as above for the --help command. Parameters to these commands are separated by vertical bars \'|\', for example:
'
+ +'
!magic --mi-power token_id|power_name|mi_name|[casting-level]
'
+ +'
If optional parameters are not to be included, but subsequent parameters are needed, use two vertical bars together with nothing between them, e.g.
'
+ +'
!magic --cast-spell MI|[token_id]||[casting_name]
'
+ +'
Commands can be stacked in the call, for example:
'
+ +'
!magic --spellmenu [token_id]|[MU/PR/POWER] --mimenu [token_id]
'
+ +'
When specifying the commands in this document, parameters enclosed in square brackets [like this] are optional: the square brackets are not included when calling the command with an optional parameter, they are just for description purposes in this document. Parameters that can be one of a small number of options have those options listed, separated by forward slash \'/\', meaning at least one of those listed must be provided (unless the parameter is also specified in [] as optional): again, the slash \'/\' is not part of the command. Parameters in UPPERCASE are literal, and must be spelt as shown (though their case is actually irrelevant).
'
+ +'
'
+ +'
Roll Query Extension
'
+ +'
The syntax of the Roll20 Roll Query has been extended within the RPGMaster MagicMaster API to support !magic API commands with Roll Queries that the GM is invited to answer, rather than the player, regardless of who issued the command. The standard syntax and the extended syntax is shown below:
'
+ +'
Standard Syntax: ?{Query text|option1|option2|...}
'
+ +'Extended syntax: gm{Query text/option1/option2/...}
'
+ +'
When used in a !magic API command, the extended Roll Query will prompt the GM with a button in the Chat Window for the GM to answer the question posed by the query text. The result will be fed into the action taken by the API command. This allows the GM to be involved when, for instance, a Staff of the Magi absorbs levels of spells cast at a character that the character & player can\'t know.
'
+ +'
'
+ +'
Overriding the Controlling Player
'
+ +'
When a command is sent to Roll20 APIs / Mods, Roll20 tries to work out which player or character sent the command and tells the API its findings. The API then uses this information to direct any output appropriately. However, when it is the API itself that is sending commands, such as from a {{successcmd=...}} or {{failcmd=...}} sequence in a RPGMdefault Roll Template, Roll20 sees the API as the originator of the command and sends output to the GM by default. This is not always the desired result.
'
+ +'
To overcome this, or when output is being misdirected for any other reason, a Controlling Player Override Syntax (otherwise known as a SenderId Override) has been introduced (for RPGMaster Suite APIs only, I\'m afraid), with the following command format:
'
+ +'
!magic [sender_override_id] --cmd1 args1... --cmd2 args2...
'
+ +'
The optional sender_override_id (don\'t include the [...], that\'s just the syntax for "optional") can be a Roll20 player_id, character_id or token_id. The API will work out which it is. If a player_id, the commands output will be sent to that player when player output is appropriate, even if that player is not on-line (i.e. no-one will get it if they are not on-line). If a character_id or token_id, the API will look for a controlling player who is on-line and send appropriate output to them - if no controlling players are on-line, or the token/character is controlled by the GM, the GM will receive all output. If the ID passed does not represent a player, character or token, or if no ID is provided, the API will send appropriate output to whichever player Roll20 tells the API to send it to.
'
+ +'
'
+ +'
Using Character Sheet Ability/Action buttons
'
+ +'
The most common approach for the Player to run these commands is to use Ability macros on their Character Sheets which are flagged to appear as Token Action Buttons: Ability macros & Token Action Buttons are standard Roll20 functionality, refer to the Roll20 Help Centre for information on creating and using these.
'
+ +'
In fact, the simplest configuration is to provide only Token Action Buttons for the menu commands: --spellmenu and --mimenu. From these, most other commands can be accessed. If using the CommandMaster API, its character sheet setup functions can be used to add the necessary Ability Macros and Token Action Buttons to any Character Sheet.
'
+ +'
'
+ +'
How MagicMaster works
'
+ +'
Race, Class, Item, Spell and Power databases
'
+ +'
MagicMaster uses a large range of items held in databases. The current versions of these databases are distributed with the game-version-specific RPGMaster Library, updated as new versions are released via Roll20. The provided databases are held in memory, but can be extracted to ability macros in database character sheets using the !magic --extract-db command. These macros can do anything that can be programmed in Roll20 using ability macros and calls to APIs, and are found (either in the Character Sheet database or the internal database in memory) and called by the MagicMaster API when the Player selects them using the menus provided by the MagicMaster functions. The GM can add to the provided items in the databases using standard Roll20 Character Sheet editing, following the instructions provided in the Magic Database Handout.
'
+ +'
Races & Classes
'
+ +'
The definitions for character Races & Classes held in the Race-DB and Class-DB databases include a description of the race and class and its capabilities, the powers/non-weapon proficiencies that it comes with, any restrictions on weapons, armour and spells that it is subject to, and other class-specific aspects such as alignments and races. As you might expect, these are not just descriptions, but restrict the player character to the characteristics defined (alterable by using the !magic --config command). The Class & Race Database Help handout provides information on the structure of the race & class specifications and how the GM / game creator can add their own races and classes and alter those provided.
'
+ +'
Spells and Powers
'
+ +'
The Ability Macros for spells and powers include descriptions of the spell they represent (limited, I\'m afraid, to avoid copyright issues), and also can optionally have API Buttons embedded in them which, if selected by the Player, can enact the actions of the spell or power. The API Buttons call one or more of the API commands listed in this document, or commands provided by other APIs. This is most powerful when combined with the RoundMaster API to implement token statuses and status markers with durations and effect macros, enabling the spells & powers to make temporary (or permanent, if desired) changes to the targeted creature\'s token and character sheet attributes.
'
+ +'
The best way to learn about these capabilities is to look at example spell definitions in the databases and use those spells or powers to see what they do.
'
+ +'
Types of Item Provided
'
+ +'
The Item database is currently split into nine parts: Weapons, Ammunition, Armour, Lights, Potions, Scrolls & Spellbooks, Wands Staves & Rods, Rings, and Miscellaneous. More might be added in future releases, and any DM can add more databases with their own items.
'
+ +'
Many magic items have actions that they can perform in the same way as Spells & Powers, using API Buttons in their macros that call MagicMaster API commands, or commands from other APIs. As with spells & powers, this is most powerful when combined with the capabilities of the RoundMaster API.
'
+ +'
Items can have stored spells (like Rings of Spell Storing) and the spells can be cast from them, and/or can have powers that can be consumed and are refreshed each day. Again, using the RoundMaster API, the spells and powers can have temporary or permanent effects on Tokens and Character Sheets, if desired.
'
+ +'
Adding Items to the Character
'
+ +'
Classes are set using the CommandMaster API or via the AttackMaster !attk --other-menu menu (or can be set manually on the Character Sheet). Classes can be those provided in the Class-DB, or any other class. Class names that are not in the database will adopt the attributes of the standard classes depending on the character sheet field the class name and level are entered into: Warrior, Wizard, Priest, Rogue, and Psion. Depending on the settings selected by the GM under the --config menu, the choise of class will restrict or grant the character\'s ability to use certain items and cast certain spells.
'
+ +'
The MagicMaster API provides commands to perform menu-driven addition of items to the Character Sheet. Using these commands will set up all the necessary fields so that the Player can use the items with the other APIs - if using MagicMaster then items should not be added directly to the Character Sheet.
'
+ +'
Items can also be acquired by finding them in chests or on tables (simply tokens with images of chests or tables that represent Character Sheets with items added to them) that can be looted, or even dead bodies of NPCs that have been killed in battle. MagicMaster provides commands that support a menu-driven way to perform looting. Characters, especially Rogues, can even try to Pick Pockets to take items from NPCs (or even other Characters...), though failure may alert the DM (or other Player) to the attempt. Containers can even be trapped, with magical consequences if the trap goes off! On the other hand, Characters can also put items away into chests or onto tables or other storage places, or give them to other Characters or NPCs.
'
+ +'
Adding Spells & Powers to the Character
'
+ +'
Spells need to be added in two steps: 1. adding to a Character\'s or NPC\'s spell book; and 2. Memorising the spells each day.
'
+ +'
The simplest way to add spells to a Character\'s spell books is to use the CommandMaster API functions that set up Character Sheets from scratch. However, spells can be added to the Character Sheet manually: see the RPG Master CharSheet Setup handout for details of how to do this. Either approach results in the Character having a list of spells at each spell level they can use that they have available to memorise.
'
+ +'
Spells can be memorised using the MagicMaster menus or via the !magic --mem-spell MagicMaster command. This limits the number of spells memorised at each level to the number that is valid for the Character, with their specific characteristics, class, level and other valid adjustments (though it is possible to add a "fudge factor" if needed). Once memorised, they can be rememorised or changed at any time, though the DM usually limits this in game play to once each in-game day. If a Player is happy with the spells a Character has, the Character just needs to rest at the end of the day to regain their spells (and powers, and recharging magic item charges).
'
+ +'
Powers are added in exactly the same way as Spells. The difference between the two is that Powers are granted to a Character, either as a function of the class they have adopted, or from being granted powers in game-play. Of course, NPCs and creatures also have many various powers. Some Powers can be used more than once a day, or even \'at will\' (an example is Priests turning undead).
'
+ +'
Using Items
'
+ +'
Items possessed by the Character can be used to perform their functions, using MagicMaster menus. When used with the InitiativeMaster API, the action for the next round can be the use of a specific item the Character has on them, with the speed of that item. This may use charges or consume quantities of the item, and these charges may or may not be regained overnight, or through other means. The items use Roll20 ability macros that can be as simple as putting text in the chat window explaining what the item does, through to much more complex targeting of effects on the user, a single other target, or all tokens in a defined area. When used with the RoundMaster API, targeted tokens can have a status marker applied with a pre-determined duration and associated effects at the start, each round and when it finishes. Items that are totally consumed will automatically disappear from the Character Sheet.
'
+ +'
Casting spells and using powers
'
+ +'
Spells memorised by the Character can be cast using MagicMaster menus. As with items, when used with the InitiativeMaster API with Group or Individual initiative, the action for the next round can be the casting of a specific spell with the speed of the Casting Time. Casting a spell will remove it from memory for the rest of the day, but a rest will bring it back. Like items, spells use Roll20 ability macros and thus can perform any function a macro or an API call can achieve. The same capability to affect tokens and Character Sheets is available if used with the RoundMaster API.
'
+ +'
Dynamic lighting for tokens
'
+ +'
MagicMaster API provides commands to change the lighting settings of the token to reflect illumination, as if holding various light sources. This includes both radiant light sources such as hooded lanterns, torches, continual light gems, magic items and magic armour, and also directed light sources such as beacon lanterns and bullseye lanterns which only illuminate in beams.
'
+ +'
DM tools
'
+ +'
The DM is provided with tools to be able to add items to chests, NPCs, Characters etc. These tools allow the DM to also change certain aspects of the items, including the displayed name and the cursed status of the item. Items that are cursed are not obvious to Characters and Players, and such items can be \'hidden\' and appear to be other items until revealed as the cursed item by the DM.
'
+ +'
The tools also allow the DM to increase or restrict the number of items Characters can have on their person: it is then possible to give each Character a \'backpack\' token/character sheet, which the Character can store items to and get items from - of course, retrieving an item from the backpack takes a round (at the DM\'s discression - the system does not impose this).
'
+ +'
DMs can also add their own items, spells and powers to additional databases (the provided databases should not be added to, but entries can be replaced by new entries in your own databases - updates will not replace your own databases - see the Magic Database Help handout). This requires some knowledge of Roll20 macro programming and use of APIs. See the Roll20 Help Centre for information.
'
+ +'
'
+ +'
Command Index
'
+ +'
1.Spell and Power management
'
+ +'
--spellmenu [token_id]|[MU/PR/POWER]
'
+ +'--mem-spell (MU/PR/POWER)|[token_id]
'
+ +'--view-spell (MU/PR/POWER)|[token_id]
'
+ +'--cast-spell (MU/PR/POWER/MI)|[token_id]|[casting_level]|[casting_name]
'
+ +'--cast-again (MU/PR/POWER)|token_id|[spell_name]
'
+ +'--mem-all-powers token_id
'
+ +'
2.Magic Item management
'
+ +'
--mimenu [token_id]
'
+ +'--edit-mi [token_id]
'
+ +'--view-mi [token_id]
'
+ +'--use-mi [token_id]
'
+ +'--add-mi [token_id]|(mi-to-replace/row#)|mi-to-add|quantity|hand#|[NOCURSE]|[SILENT]
'
+ +'--mi-charges token_id|value|[mi_name]|[maximum]|[charge_override]
'
+ +'--mi-power token_id|power_name|mi_name|[casting-level]
'
+ +'--store-spells token_id|mi-name
'
+ +'--mem-spell (MI-MU/MI-PR)[-ANY/-ADD/-CHANGE]|[token_id]|[mi-name]
'
+ +'--view-spell (MI/MI-MU/MI-PR/MI-POWER)|[token_id]|[mi-name]
'
+ +'--cast-spell (MI/MI-POWER)|[token_id]|[casting_level]|[casting_name]|[CHARGED]|[mi-name]
'
+ +'--learn-spell [token_id]|spell_name
'
+ +'
3.Spell, power & magic item effects and resting
'
+ +'
!rounds --target CASTER|caster_token_id|caster_token_id|spell_name|duration|increment|[msg]|[marker]
'
+ +'!rounds --target (SINGLE/AREA)|caster_token_id|target_token_id|spell_name|duration|increment|[msg]|[marker]
'
+ +'--touch token_id|effect-name|duration|per-round|message|marker
'
+ +'--level-change [token_id]|[# of levels]
'
+ +'--change-attr [token_id]|change|[field]|[SILENT]
'
+ +'--rest [token_id]|[SHORT/LONG]|[MU/PR/MU-PR/POWER/MI/MI-POWER]|[timescale]
'
+ +'--mi-rest [token_id]|mi_name|[charges]|[power_name]
'
+ +'
4.Treasure & Item container management
'
+ +'
--gm-edit-mi [token_id]
'
+ +'--find-traps token_id|pick_id|put_id
'
+ +'--search token_id|pick_id|put_id
'
+ +'--pickorput token_id|pick_id|put_id|[SHORT/LONG]
'
+ +'
5.Light source management
'
+ +'
--lightsources [token_id]
'
+ +'--light token_id|(NONE/WEAPON/TORCH/HOODED/CONTLIGHT/BULLSEYE/BEACON)
'
+ +'
6.Other commands
'
+ +'
--help
'
+ +'--message [who|][token_id]|title|message|[command]
'
+ +'--display-ability [who|][token_id]|database|db_item|[dice_roll1]|[dice_roll2]|[target_id]
'
+ +'--tidy [token_id]|[SILENT]
'
+ +'--config [FANCY-MENUS/SPECIALIST-RULES/SPELL-NUM/ALL-SPELLS/ALL-POWERS/CUSTOM-SPELLS/AUTO-HIDE/ALPHA-LISTS/GM-ROLLS] | [TRUE/FALSE]
'
+ +'--check-db [db-name]
'
+ +'--extract-db [db-name]
'
+ +'--handshake from | [cmd]
'
+ +'--hsq from | [cmd]
'
+ +'--hsr from | [cmd] | [TRUE/FALSE]
'
+ +'--debug (ON/OFF)
'
+ +'
'
+ +'
1. Spell management
'
+ +'
1.1 Display a menu to do actions with spells
'
+ +'
--spellmenu [token_id]|[MU/PR/POWER]
'
+ +'
Takes an optional token ID and an optional menu type as arguments. If token ID is not specified, uses the selected token.
'
+ +'
'
+ +' MU: | displays buttons for Magic User/Wizard spells for casting, resting (short or long), memorising spells from the character\'s spell book, or viewing the memorised spells. |
'
+ +' PR: | displays buttons for Priest spells for casting, resting (short or long), memorising spells from the character\'s spell book, or viewing the memorised spells. |
'
+ +' POWER: | displays buttons for using powers, doing a long rest, changing/resetting powers from the character\'s granted powers, or viewing the granted powers. |
'
+ +' None of the above: | the system will check the class(es) of the character and display the appropriate menu, or if a multi-class character including both a Wizard and a Priest, ask if the player wants to display Magic User or Priest menus. |
'
+ +'
'
+ +'
If the specified token is not associated with a character that has a spell book of the chosen type, or any granted powers, an error message is displayed.
'
+ +'
1.2 Display a menu to memorise spells from the Character\'s spell book
'
+ +'
--mem-spell (MU/PR/POWER/MI-MU/MI-PR)|[token_id]|[mi-name]
'
+ +'
Takes a mandatory spell book type, an optional token ID, and an optional magic item name as arguments. If token ID is not specified, uses the selected token.
'
+ +'
The Character Sheet associated with the token must have spell books specified for the relevant types of spells or powers. These are lists of spells from the spell macro databases (see Section 7) specified by level (powers are all 1 level) and as lists separated by \'|\'. E.g. Charm-Person|Light|Sleep. If the CommandMaster API is installed, the GM can use its menus to set up character spell books and granted powers.
'
+ +'
Initially displays a menu for memorising Level 1 spells (the only level for powers), with buttons to: choose a spell from the Level 1 spell book on the character sheet; review the chosen spell; and one for each memorising slot the Character has at this level. Other buttons to memorise or remove spells become available when spells or slots are chosen. Another button goes to the next available level with slots. When a granted power is memorised to a slot, a quantity per day can be specified: -1 will grant unlimited uses of the power per day. Memorising any other type of spell is limited to 1 use per slot.
'
+ +'
Depending on the settings on the --config menu, the character will be limited to memorising spells and powers allowed to their character class and level.
'
+ +'
MI-MU and MI-PR have a special function: these are used to cast memorised spells into the named spell-storing magic item (if no item is named, the last item selected by the Character running the command will be used instead), such as a Ring-of-Spell-Storing. Magic Item spells are stored in an unused level of the Character Sheet. This command displays both all memorised spells and all spell-storing magic item spell slots, and allows a memorised spell to be selected, a slot (for the same spell name) to be selected, and the spell cast from one to the other. Spells can only be replaced by the same spell that was in the slot previously (unless this is the first time spells have been stored in a blank spell-storing item).
'
+ +'
1.3 View the memorised spells or granted powers
'
+ +'
--view-spell (MU/PR/POWER/MI-MU/MI-PR/MI-POWER)|[token_id]|[mi-name]
'
+ +'
Takes a mandatory spell type, an optional token ID, and an optional magic item name. If token ID is not specified, uses the selected token.
'
+ +'
Displays a menu of all levels of memorised spells of the selected type (there is only 1 level of powers). Spells that have already been cast appear as greyed out buttons, and can\'t be selected. Spells that are still available to cast that day can be selected and this runs the spell or power macro from the relevant database without consuming the spell, so that the Player can see the specs.
'
+ +'
Adding MI- before any of the types of spell views the spells or powers available for the specified magic item, or the last Magic Item used by the Character if no magic item name is provided. Generally this version of the command is only called from API Buttons from the magic item\'s ability macro.
'
+ +'
1.4 Cast a memorised spell or use a granted power
'
+ +'
--cast-spell (MU/PR/POWER/MI/MI-POWER)|[token_id]|[casting_level]|[casting_name]|[CHARGED]|[mi-name]
'
+ +'
Takes a mandatory spell type, an optional token ID (if not specified, uses the selected token), an optional casting level, and an optional caster name, an optional \'CHARGED\' command, and an optional magic item name.
'
+ +'
This displays a menu of all levels of the memorised spells/powers of the relevant type. MI displays the spell book for spells stored on the specified magic item, or the last magic item used or viewed if not specified (both MU & PR), and MI-POWER all stored powers in the specified or last selected magic item, (this version of the command is generally called using an API Button in the magic item ability macro). The player can select a spell/power and then a button becomes available to cast it, using up that slot/deducting a power charge until the next long rest (or until the item is recharged).
'
+ +'
If a casting_level is specified, the spell will be cast as if by a caster of that level, and if a casting_name is specified, that name will be displayed in the spell macro information. These functions are often used for magic items that cast at specific levels of use, or magic artefacts that are named and/or sentient. If these are not specified, the caster name and relevant class level are used. In either case, specified or not, the character\'s Character Sheet Attributes called @{Casting-name} and @{Casting-level} are set to the values used, and can be used in spell, power, or magic item macros.
'
+ +'
If the optional CHARGED parameter is specified (only relevant to spells and powers stored on magic items), this specifies that the Magic Item from which the spell or power is cast is charged, and looses one charge when that cast is made. This is generally the case when the spell or power is on a Scroll. When the charge quantity reaches zero, the item will follow the behaviour determined by its charge type (charged, uncharged, rechargeable, recharging, self-charging) - see section 4.1 for more information on charges and charge types.
'
+ +'
1.5 Cast the last used spell or power again
'
+ +'
--cast-again (MU/PR/POWER)|token_id|[spell_name]
'
+ +'
Takes a mandatory spell type, a mandatory token ID and an optional spell name.
'
+ +'
This command is used for certain spells and powers that, once cast, allow continuing effects in the same or subsequent rounds, without using additional charges. If the optional spell name is not used, the command just casts again the same spell as the last spell cast by the character associated with the selected token, at the same casting level and casting name. If a spell name is specified, this spell is cast instead as if it were the same spell: this is used where different spell macros are required to specify subsequent spell effects.
'
+ +'
1.6 Memorise All Valid Powers
'
+ +'
--mem-all-powers token_id
'
+ +'
Takes a mandatory token_id.
'
+ +'
Reviews all the Powers currently in the Powers Spellbook, checking for Race, Creature, Class and user-added Powers, and checks them against their respective definitions in the various databases to assess if they can be used at the level of experience/Hit Dice of the character / creature. Memorises each valid power for the number of uses per day specified in the Race, Class or Creature database definition: user-added powers are memorised at unlimited uses per day unless a default is otherwise specified in the Powers database, on the basis that DMs/Players will either change this by rememorising them individually, or otherwise play to the agreed limits of use.
'
+ +'
'
+ +'
2. Magic Item management
'
+ +'
2.1 Display a menu of possible Magic Item actions
'
+ +'
--mimenu [token_id]
'
+ +'
Takes an optional token ID as an argument. If token ID is not specified, uses the selected token.
'
+ +'
Displays a menu with the following actions: Use a magic item, Search for magic items & treasure, Store magic items in a container, Edit the contents of a character\'s magic item bag, and View the contents of a character\'s magic item bag.
'
+ +'
Searching & Storing are explained in section 4.
'
+ +'
2.2 Edit a Magic Item bag
'
+ +'
--edit-mi [token_id]|[MARTIAL/MAGICAL/ALL]
'
+ +'
Takes an optional token ID, and an optional item type as arguments. If token ID is not specified, uses the selected token. If the item type is not specified, defaults to MAGICAL.
'
+ +'
Displays a menu similar to editing memorised spells. At the top are buttons to choose different types of magic items which have macros in the magic item databases. If the optional item type is MARTIAL, only weapons, ammo and armour are listed; if ALL is specified, lists of all items are shown; otherwise only non-MARTIAL items are listed. The slots available in the bag are shown (with their current contents) and, when magic items and/or slots are chosen buttons become selectable below to store, review, or remove magic items in/from the bag.
'
+ +'
Storing a magic item will ask for a number - either a quantity or a number of charges. Magic Items can be of various types: Charged (is used up when reaches 0), Uncharged (a number is a pure quantity that is not consumed), Recharging (regains charges after each long rest), Rechargable (is not used up when reaches 0, stays in bag and can be recharged when the DM allows), Self-charging (recharge at a rate per round determined by the item) and can also be Cursed - more under section 4.
'
+ +'
This menu is generally used when Magic Item & treasure containers (such as Treasure Chests and NPCs/monsters with treasure) have not been set up in a campaign as lootable, and provides a means of giving found magic items to characters. The DM just tells the Player that they have found a magic item, and the Player adds it to their Character Sheet using this command (more likely accessed via the Magic Item menu).
'
+ +'
2.3 View a character\'s Magic Item Bag
'
+ +'
--view-mi [token_id]
'
+ +'
Takes an optional token ID as an argument. If token ID is not specified, uses the selected token.
'
+ +'
Displays a menu of items in the character\'s magic item bag, with the quantity possessed or the number of charges. Pressing a button displays the named Magic Item specs without using any charges so that the Player can review the specifications of that item. Items for which all charges have been consumed are greyed out, and cannot be viewed as the character can no longer use them. They will become viewable again if they gain charges.
'
+ +'
2.4 Use a Magic Item from the bag
'
+ +'
--use-mi [token_id]
'
+ +'
Takes an optional token ID as an argument. If token ID is not specified, uses the selected token.
'
+ +'
Displays a similar menu as for viewing the contents of the Magic Item Bag, but when an item is selected, a button is enabled that uses the Magic Item and consumes a charge. Other buttons specified in the item macro might use additional charges to perform additional effects. See section 3.
'
+ +'
Items with 0 quantity or charges left are greyed out and cannot be selected, unless they have abilities to regain charges such as "spell absorbing" items. When a Charged Item reaches 0 charges left, it is removed from the character\'s Magic Item Bag automatically.
'
+ +'
2.5 Add an Item to a Character / Container
'
+ +'
--add-mi [token_id]|(mi-to-replace/row#)|mi-to-add|[quantity]|[hand#]|[NOCURSE]|[SILENT]
'
+ +'
Takes an optional token ID (if not provided, uses selected token), then either the name of the item to be replaced or the row number of the item in the equipment list, the name of the item to add, the quantity to add (defaults to 1), optionally a hand number to use to take in-hand (0=prime hand,1=offhand,2=both,3 onwards for other hands), optionally NOCURSE if replacement of cursed items is possible, and optionally SILENT to not trigger messages, menus or dialogs.
'
+ +'
This command can be used to add a named item from the databases to a character, NPC, creature or other container without going through other dialogs to select the item. It will add the item to a numbered row in the equipment list or, more usefully, replace a named item that already exists in the list (or \'-\' to find an empty row). If the item is one that can be taken in-hand (e.g. a weapon or a shield, or a magic item like a wand or staff), the optional \'hand number\' can be used to specify which hand to take it in - if blank or the item is not one that can be held the item will not be taken in-hand. If the item to be replaced is cursed, it will not be replaced and an error message will be displayed unless the NOCURSE option is used. Finally, the command will pop up the edit-mi dialog or the gm-edit-mi dialog (if NOCURSE is specified) showing the resulting equipment list unless the SILENT flag is also used.
'
+ +'
2.6 Add, set or deduct Magic Item charges
'
+ +'
--mi-charges token_id|[+/-]value|[mi_name]|[maximum]|[charge_override]
'
+ +'
Takes a mandatory token ID, a mandatory value preceeded by an optional + or -, an optional magic item name, an optional maximum value, and an optional magic item charge type override as arguments.
'
+ +'
Does not display anything but alters the number of current or recoverable charges on an item. By default, alters the last magic item used by the character, or will affect the named magic item. Warning: a character can have two items of the same name, and there is no guarantee which will be affected if the name is used.
'
+ +'
Remember: using a Charged, Recharging, Rechargeable or Self-Charging Magic Item will automatically use 1 charge on use (unless the ItemData specification includes the field c:0, in which case no charges will automatically be deducted on use). If the c: tag is not used, or is anything other than 0, then charges will be deducted (default 1 charge) on use of the item. In addition, that one charge deduction always happens - if an effect of a Magic Item uses 2 charges, only 1 more needs to be deducted.
'
+ +'
Note: \'-\' reduces current remaining charges, \'+\' adds to the maximum recoverable charges, and no + or - sets the maximum recoverable charges. This command cannot be used to increase the current remaining charges unless the item is of type absorbing.
'
+ +'
Using minus \'-\' before the value will deduct charges from the current quantity/charges: e.g. if using an optional power of the item that uses more than 1 charge. Using + before the value will add the value to the number of recoverable charges (overnight or rechargeable to), up to any specified maximum (often used for magic items that regain variable numbers of charges overnight). Just using the value without + or - will just set the number of recoverable charges to the given value. This command is not required to recharge self-charging items but can be used to change the maximum number of charges they will self-charge up to.
'
+ +'
Absorbing items can gain charges in use from other sources, so the --mi-charges command works differently: \'-\' reduces both current and maximum charges and \'+\' only increases current charges (but only to maximum and not beyond). Using neither \'-\' or \'+\' will set the current charges (but, again, only up to the maximum).
'
+ +'
The charge-override can be used to temporarily change the charge behaviour of the magic item. Specifying an override will cause the magic item to behave as if its charging type was that of the override only for this call. Thus charges could be deducted from an uncharged item by overriding by rechargeable or charged.
'
+ +'
2.7 Use a Magic Item power
'
+ +'
--mi-power token_id|[type-]power_name|mi_name|[casting-level]
'
+ +'
Takes a mandatory token ID, mandatory power name (optionally prefixed by a power type), mandatory magic item name, and an optional casting level as parameters.
'
+ +'
Magic Items, especially artefacts, can have their own powers that can be used a specified number of times a day, or at will. This command can be used in API buttons in the Magic Item macro to call on that power. The power name and the magic item name must be specified to select the right power. If a casting level is specified, any relevant impacts on use of the power will be taken into account: it is often the case that magic items use powers at specific levels. If not specified, the item using Character\'s level is used (user does not need to be a spell caster).
'
+ +'
Generally, magic item powers have unique names, though they do not have to. Such magic items require specific setting up by the DM - see later sections. However, powers can have a prefix that indicates a power type that specifies the power is in fact a Wizard spell (MU-), a Priest spell (PR-), or a Magic Item (MI-) or (for completeness) confirmed as a Power (PW-). Specifying a power type prefix means the appropriate database types will be searched for the named power - thus (for instance) a Wizard or Priest spell can be specified as a Magic Item power without having to program a duplicate in the Powers Databases. If no power type prefix is specified, the system will first search for a matching power in the Powers Databases (both API-supplied and user-supplied), then all Wizard spell databases, then Priest spell databases, then all Magic Item databases, and finally the character sheet of the creature wielding the Magic Item.
'
+ +'
2.8 Add spells to a spell-storing Magic Item
'
+ +'
--store-spells token_id|mi_name
'
+ +'
Takes a mandatory token ID and a mandatory magic item name.
'
+ +'
This command presents a dialog in the chat window that stores spells or powers in any magic item that has been defined as being able to cast stored spells/powers. The item definition must include somewhere in its definition the command call !magic --cast-spell MI|
or !magic --cast-spell MI-POWER|
, (or either of their --view-spell
equivalents) generally as part of an API button, or spells/powers cannot be stored. If the command is for MI, the dialog defaults to Level 1 Wizard spells, and has buttons to switch level and to Priest spells. If the command is for MI-POWER, the dialog allows powers to be stored, but Wizard and Priest spells can also be stored as powers, and the dialog will prompt for a number of uses per day for each.
'
+ +'
Once a spell is cast from a spell-storing item, the spell is spent and does not return on a long or short rest: the spell must be refreshed using the --mem-spell command (see below). If a power is used from a power-storing item, the power will have a number of uses per day (or be "at will"), and will refresh on a long rest.
'
+ +'
2.9 Restore spells in a spell-storing Magic Item
'
+ +'
--mem-spell (MI-MU/MI-PR)[-ADD/-ANY/-CHANGE]|[token_id]|[mi-name]
'
+ +'
Takes a mandatory spell type (optionally followed by -ADD or -ANY or -CHANGE), an optional Token ID for the character, and an optional magic item name. If token ID is not provided, it uses the selected token, and if the magic item name is not specified, the last used magic item is assumed.
'
+ +'
MI-MU and MI-PR mem-spell types are used to cast memorised spells into a spell-storing magic item, such as a Ring of Spell Storing. Magic Item spells are stored in an unused spell level of the Character Sheet (by default Wizard Level 15 spells). This command displays both all the character\'s memorised spells and the spell-storing magic item spell slots in the specified magic item (or the last one used if not specified), and allows a memorised spell to be selected, a slot to be selected (for the same spell name - limiting the item to only store certain defined spells unless "-ANY" or "-CHANGE" is added to the command), and the spell cast from one to the other.
'
+ +'
If either "-ANY" or "-ADD" are added to the spell type string, the player can just select a memorised spell and then immediately cast it into the device without choosing a slot: this will add the spell to the device. If the extension is "-ADD" then existing spells need to be refreshed with an identical spell, the same way as if -ADD was not specified. If "-ANY" is specified, not only can the player extend the spells stored, they can replace expended spell slots with any spell, not just the one previously stored in the slot. "-CHANGE" will allow different spells to be stored in a slot, but not give the ability to add to the number of slots. If none of these qualifiers are specified in the command, spell slots cannot be added, and slots have to be refreshed with the same spell - just like a normal Ring of Spell Storing. Generally, the GM will state that the device used for storing the spells will have a limited capacity of some type - number of spell levels, number of spells, types or spheres of spell, etc. The number of levels can be set in the database entry for the magic item (see the Magic Database Help handout) and the caster\'s spells of higher level than can be stored will not be available. The number of spells can be restricted by using the "-CHANGE" qualifier or no qualifier. Alternatively the GM can just tell the players to do so manually.
'
+ +'
Unlike some other menus, however, magic item spell slots that are full are greyed out and not selectable - their spell is intact and does not need replacing. Spell slots that need replenishing are displayed as selectable buttons with the spell name that needs to be cast into the slot.
'
+ +'
The level of the caster at the time of casting the spell into the magic item is stored in the magic item individually for each spell - when it is subsequently cast from the spell-storing magic item it is cast as if by the same level caster who stored it.
'
+ +'
A spell-storing magic item can hold spells from one or both of Wizard and Priest spells. The database where the spell is defined is also stored in the magic item with the spell, so the correct one is used when at some point in the future it is cast. A copy of the spell macro is also stored on the Character Sheet of the character that has the spell-storing magic item. If, when cast, the system can\'t find the database or the spell in that database (perhaps the character has been moved to a different campaign with different databases), and it can\'t use the copy on its own character sheet for some reason, the system will search all databases for a spell with the same name - this does not guarantee that the same spell will be found: the definition used by a different DM could be different - or the DM may not have loaded the database in question into the campaign for some reason. In this case, an error will occur when the spell is cast.
'
+ +'
See the Magic Items Database documentation for how spell-storing magic items are defined.
'
+ +'
2.10 Casting a spell from a spell-storing magic item
'
+ +'
--cast-spell (MI/MI-POWER)|[token_id]|[casting_level]|[casting_name]|[CHARGED]|[mi-name]
'
+ +'
Takes a mandatory casting type of \'MI\', an optional Token ID (if token ID is not provided, it uses the selected token), an optional casting level (which will be ignored in favour of the level of the caster of the spell who cast it into the item), an optional casting name which, if not specified, will be the name of the wielder of the magic item, an optional \'CHARGED\' command, and an optional magic item name (if not provided, uses name of the last magic item the character selected, viewed or used).
'
+ +'
This command works in the same way as for casting other spells. However, spells cast from a spell-storing magic item are not regained by resting - either short or long rests. The only way to regain spells cast from such an item is to cast them back into the item from the character\'s own memorised spells: see the --mem-spell command above. If the character does not have these spells in their spell book or is not of a level able to memorise them, then they will not be able to replace the spells and will have to get another spell caster to cast them into the item (by giving the item to the other Character and asking nicely for it back again) or wait until they can get the spells.
'
+ +'
If the optional parameter \'CHARGED\' is used, spells on the magic item are not re-storable. The spells will be deleted after they are all used up and the magic item will not be able to store any more spells. This is mainly used for Scrolls with multiple spells.
'
+ +'
2.11 Learning a spell in a spellbook (or other MI)
'
+ +'
--learn-spell [token_id]|spell_name
'
+ +'
Takes an optional token_id which defaults to that of the currently selected token, followed by a mandatory spell name.
'
+ +'
This command is intended for use with magic items of the type spellbook (listed in the GM\'s Add Items dialog under Scrolls), although any spell storing magic item that has the Data tag learn: set to 1 (as in learn:1) will prompt the player with a [Learn this spell] button when stored spells are viewed. If the GM stores a spellbook item in a container or adds it to an NPC character sheet, and then stores Wizard spells in the spellbook (all of this by using the GM\'s Add Items dialog), any Wizard spell-casting character looting the spellbook will gain access to view the spells the GM stored in it. Viewing any of the spells in a spellbook will display a [Learn this spell] button at the bottom of the spell description. Selecting this button runs this command, which will:
'
+ +'
- Check the spell is not already in the character\'s spellbook;
'
+ +'- Check that the spell is of a school the character can use;
'
+ +'- Check that the spell is of a level the character can cast;
'
+ +'- Present a dialog to the player to roll "Spell Knowledge" with a target pre-adjusted for specialism;
'
+ +'- If all of the above checks are passed, add the spell to the character\'s correct level of spellbook.
'
+ +'
'
+ +'
3.Spell, power & magic item effects and resting
'
+ +'
If this API is used in conjunction with the RoundMaster API, Magic Items, Spells & Powers can all place status markers on tokens, and also cause real Effects to alter token & character sheet attributes and behaviours: when cast; during each round of their duration; and when they expire. See the RoundMaster documentation for further information, especially on Effects and the Effects Database.
'
+ +'
3.1 Target spell effects on a token (with RoundMaster API only)
'
+ +'
!rounds --target CASTER|caster_token_id|[caster_token_id|]spell_name|duration|[+/-]increment|[msg]|[marker]
'
+ +'!rounds --target (SINGLE/AREA)|caster_token_id|target_token_id|spell_name|duration|increment|[msg]|[marker]
'
+ +'
Takes mandatory CASTER, SINGLE or AREA command, a mandatory caster token ID, for SINGLE/AREA a mandatory target token ID, mandatory spell name, duration & increment (preceeded by an optional +/-), and an optional message and optional token marker name.
'
+ +'
If using the RoundMaster API, this command targets one, or a sequential set of tokens and applies a token marker to the token for the specified duration number of rounds, with the increment applied each round. The optional message will be shown below that token\'s turn announcement each round. The marker used will either be the one specified or if not specified a menu to choose one will be shown.
'
+ +'
'
+ +' CASTER | will just take one Token ID and apply the marker to that token. |
'
+ +' SINGLE | will take both the Token ID of the caster, and the Token ID of a target of the spell/power/MI. The marker will be applied to that of the target. |
'
+ +' AREA | will take the Token ID of the caster, and one Token ID of the first token in the area of effect. As each token is specified the command will ask the Player to select subsequent tokens in the area of effect. Once all relevant tokens have been selected, just ignore the next prompt. |
'
+ +'
'
+ +'
If the Player is not the DM/GM, the system will ask the DM/GM to approve the marker/effect for each token - this allows the DM to make saving throws for monsters/NPCs affected where appropriate.
'
+ +'
See the RoundMaster API documentation for full details.
'
+ +'
3.2 Cast a spell that requires a "touch" attack roll
'
+ +'
--touch token_id|effect-name|duration|per-round|[message]|[marker]
'
+ +'
Takes mandatory token ID, effect name, duration of the effect, an increment to the duration per round (often -1), an optional message each round for the targeted token, and an optional status marker to use (if not supplied, the DM or user will be asked to select one).
'
+ +'
Note: this command requires RoundMaster API to also be loaded, but is a !magic command.
'
+ +'
Sets up the Character represented by the specified token ready for an "Attack Roll" to deliver a touch attack for a spell or power or magic item use that requires an attack. The parameters are those that will be passed to the !rounds --target command if the attack is successful (see above).
'
+ +'
To use this command, add it as part of a spell, power or MI macro in the appropriate database, before or after the body of the macro text (it does not matter which, as long as it is on a separate line in the macro - the Player will not see the command). Then include in the macro (in a place the Player will see it and be able to click it) an API Button call [Button name](~Selected|To-Hit-Spell) which will run the Ability "To-Hit-Spell" on the Character\'s sheet (which has just been newly written there or updated by the --touch command).
'
+ +'
Thus, when the Player casts the Character\'s spell, power or MI, they can then press the API Button when the macro runs and the attack roll will be made. If successful, the Player can then use the button that appears to mark the target token and apply the spell effect to the target.
'
+ +'
See the RoundMaster API documentation for further information on targeting, marking and effects.
'
+ +'
3.3 Change the Experience Level
'
+ +'
--level-change [token_id]|[# of levels]
'
+ +'
Takes an optional Token ID (if not specified, uses the selected token), and an optional number of levels (plus or minus: if not specified assumes -1).
'
+ +'
Mainly used for attacks and spell-like effects that drain levels from opponents, this command undertakes all the calculations and Character Sheet updates that can automatically be done when a character or creature changes experience level. Saving throw targets are reassessed, weapon attacks per round recalculated, numbers of memorised spells changed, Race & Class powers checked for level appropriateness, etc. Asks for number of hit points to reduce or add to current and maximum values. If the character is multi- or dual-class, asks which class to add/drain levels to/from and the hit points for each.
'
+ +'
3.4 Change an Attribute Value
'
+ +'
--change-attr [token_id]|change|[STRENGTH/DEXTERITY/CONSTITUTION/INTELLIGENCE/WISDOM/CHARISMA]
'
+ +'
Takes an optional Token ID (if not specified, uses the selected token), and a mandatory change value (plus, minus, or zero), and an optional attribute name (defaults to STRENGTH)
'
+ +'
Mainly used to support magical effects and creature attacks that drain or add to attributes such as Strength, this command specifically deals with aspects such as Exceptional Strength, remembering if a Character has exceptional strength as a characteristic and taking it into account as the value is changed. Going up or down from the original rolled value and then back the other way will include as a step the exceptional, percentage value. If the change requested would take the value past the original rolled value, the change will only go as far as the original value, whatever change was requested. However, the change can then continue with subsequent calls to beyond the original value with subsequent calls.
'
+ +'
Note:Should the rolled value need to change permanently to a new rolled value, the change value of 0 (zero) will reset the remembered original rolled value to the current value of the attribute - this is not needed the first time the command is used on a character sheet, which will trigger this value to be remembered for the first time.
'
+ +'
3.5 Perform Short or Long Rests
'
+ +'
--rest [token_id]|[SHORT/LONG]|[MU/PR/MU-PR/POWER/MI/MI-POWER]|[timescale]
'
+ +'
Takes an optional token ID (if not specified, uses the selected token), an optional rest type, short or long, an optional magic type to regain charges for, and an optional timescale for days passing.
'
+ +'
Most magic requires the character to rest periodically to study spell books, rememorise spells, and regain powers and charges of magic items. This command implements both Short and Long rests.
'
+ +'
The type of rest (short or long) can be specified or, if not specified, the system will ask the Player what type of rest is to be undertaken - though Long Rests will be disabled if the Timescale (either the optional value or the character sheet attribute) is not 1 or more days (see below). The type of magic to be affected can also be specified or, if not specified, all types of magic are affected.
'
+ +'
A Short rest is deemed to be for 1 hour (though this is not a restriction of the system and is up to the DM), and allows spell casters (such as Wizards and Priests, as well as others) to regain their 1st level spells only. This can happen as often as the DM allows.
'
+ +'
A Long rest is considered to be an overnight activity of at least 8 hours (though again this is not a restriction of the system and is up to the DM). A Long rest allows spell casters to regain all their spells, all character and magic item powers to be regained to full uses per day, and for recharging magic items to regain their charges up to their current maximum. After a long rest, ammunition that has been used but not recovered can no longer be recovered using the Ammunition Management command (see AttackMaster API documentation): it is assumed that other creatures will have found the ammo, or it has been broken or otherwise lost in the 8 hours of the long rest.
'
+ +'
A Long rest can only be undertaken if certain conditions are met: either the optional Timescale (in days) must be specified as 1 or more days, or the Character Sheet must have a Roll20 attribute called Timescale, current, set to a value of 1 or more (can be set by InitiativeMaster API --end-of-day command). An internal date system is incremented: an attribute on the Character Sheet called In-Game-Day is incremented by the Timescale, and Timescale is then set to 0.
'
+ +'
If the InitiativeMaster API is being used, the system will interact with the "End of Day" command to allow rests to be coordinated with the choice of accommodation (and its cost...!) or with earnings made for the day\'s adventuring.
'
+ +'
3.6 Perform a Single Item Rest
'
+ +'
--mi-rest [token_id]|mi_name|[charges]|[power_name]
'
+ +'
Takes an optional Token ID (defaults to the selected token), a mandatory magic item name (case insensitive), an optional number of charges to recharge to, and an optional power name (case insensitive).
'
+ +'
This command restores the powers for a single magic item, or even a single power of a single magic item. If the optional number of charges is specified, this is the number of charges set for the power, otherwise the power is restored to its original max uses. If a power name is specified, and the item has a power of the same name, only that power will be affected. Otherwise, all powers of the item will be restored.
'
+ +'
'
+ +'
4.Treasure & Item container management
'
+ +'
4.1 DM/GM version of Magic Item management
'
+ +'
--gm-edit-mi [token_id]
'
+ +'
Takes an optional token ID. If token ID is not specified, uses the selected token.
'
+ +'
This command opens a menu showing all the items in the Items table of the character sheet associated with the specified token. Unlike the Player version of the command (--edit-mi), this command shows all attributes of every magic item, including those of hidden and cursed items, and also offers an additional list of "DM Only" magic items from the magic item databases.
'
+ +'
The following functions are available once both a magic item is selected from the lists, and a slot to store it in are selected:
'
+ +'
'
+ +' Store item: | Select a magic item from the databases and store it in a slot - this is the same as the Player version. |
'
+ +' Hide item as different item: | The magic item already in the selected bag slot is given the displayed name of the magic item selected from the databases - the Player will only see the Magic Item selected (Displayed Name), and not the hidden actual name. The MI will behave exactly like the selected, displayed item until the DM reverts the item to the hidden version using the [Reset Single MI] button. This is generally used for items in containers, especially Cursed items, so that the real nature of the item is hidden until the character uses it or the DM wants them to. Once an item has been marked as hidden, the DM can see the name it will be displayed to the palyer as by selecting that slot - the displayed name will appear on the menu, and other options for hidden items will become selectable. |
'
+ +' Rename MI: | Allows the DM to change the actual and displayed name of an item. This will create a unique item (existing item names cannot be used) stored on the character\'s/container\'s Character Sheet which will work in exactly the same way as the original item. This can be used to resolve duplicate magic items, such as two rings of spell storing can be given different names. This is different from hiding - the actual name of the item is changed. |
'
+ +' Remove MI: | Blanks the selected Bag slot, removing all details, both displayed & actual. |
'
+ +' Change MI Type: | This allows the type of the item in the selected Bag slot to be changed. It can be one of the following - Charged, Discharging, Uncharged, Recharging, Rechargeable, Self-charging, Absorbing, Cursed, Cursed-Charged, Cursed-Self-charging, Cursed-Recharging, Cursed-Absorbing (cursed rechargeable items behave in exactly the same way as Cursed-Charged items). Cursed versions of items cannot be removed from the character\'s MI Bag, given away, stored or deleted by the Player, even when all their charges are depleted. Otherwise, they act in the same way as other magic items. Charged, Discharging, and Rechargeable items disappear if they reach zero charges, unless preceeded by \'perm-\'. Charged, Uncharged and Cursed items can be divided when picked up by Searching or Storing, other types cannot. |
'
+ +' Change Displayed Charges: | Changes the number of displayed/current charges for the item in the selected Bag slot. This can be used to set the quantity of Uncharged items, or the current charges of other types. It also allows charged items in containers to be stored as a single item, for instance single Wands (current/displayed qty = 1) with multiple charges (max qty = n): when picked up the current qty is always set to the actual value - see the --pickorput command below. |
'
+ +' Change Actual Charges: | Setting this allows the actual quantity of Uncharged items in containers to be hidden, or the maximum number of charges to be set for other types. When the item is picked up from a container, the actual number of charges will be set as the current value. |
'
+ +' Store Spells/Powers in MI | Only enabled for items that can store & cast spells or powers: the item definition must have a call to !magic --cast-spell MI for spell storing, or !magic --cast-spell MI-POWER for powers, associated with an API button. If this is the case, this option opens a menu to select Wizard or Priest spells, or powers as appropriate. A blank Ring-of-Spell-Storing and a blank Scroll-of-Spells are both included in the databases, allowing GMs to build their own unique items and then give them a unique new name using the Rename function described above. |
'
+ +' Change Item Cost: | Items can have a cost in GP (fractions allowed which get converted to SP & CP). When an item is picked up from a container, the cost will be multiplied by the quantity picked up and the Player will be asked if they want the character to pay the cost. If confirmed, the cost will be deducted from the money values on the character sheet. 0 and negative values are allowed. This supports merchants and shops to be created in the campaign. |
'
+ +' Reset Qty to Max: | Allows the DM to reset the quantity of the selected Bag slot to the actual (max) values. |
'
+ +' Reveal Now: | Only available when a hidden item is selected. Reveals the item, setting the displayed name to the actual name, which will function as the revealed item from that point on. |
'
+ +' Reveal MI | Allows selection of when a hidden item is revealed: MANUALLY by DM (the default) using the Reveal Now button; on VIEWING the item; or on USING the item. From the point the item is revealed onwards, the item will behave as the revealed item. |
'
+ +' Edit Treasure: | Mainly for use on Magic Item containers, such as Treasure Chests, but also useful for NPCs and Monsters. Allows the DM to add text only treasure descriptions to the container. The displayed menu allows [Add], [Edit], and [Delete] functions to manage multiple lines/rows of treasure description. |
'
+ +' Container Type: | Sets the type of the Magic Item container or Bag. Available choices are: Untrapped container, Trapped container, Force to be an Inanimate Container, Force to be a Sentient creature. If searched, Inanimate objects can be looted without penalty; Sentient beings require a Pick Pockets check; Trapped containers call a Trap ability macro on the container\'s character sheet to determine the effect. See the --search command below. |
'
+ +' Container Size: | Sets the maximum number of items that can be stored in the selected Character\'s/containers bag. The default is 18 items, though identical items can be stacked. |
'
+ +' Show As: | Sets what level of item description a Player sees when looting a container. Either "Show as Item Types" (e.g. potion, scroll, melee weapon, etc), or "Show as Item Names" (default) which shows the display names of the items. Once picked up from the container, will always show their display names. |
'
+ +'
'
+ +'
4.2 Check a token for traps
'
+ +'
--find-traps token_id|check_id|searcher_id
'
+ +'
Takes a mandatory token ID of the character\'s token, mandatory token ID of the token to check for traps, mandatory token ID of the token doing the checking.
'
+ +'
This command will check a token for any traps. If the container represented by the token was created using the Drag & Drop container system (see CommandMaster API documentaion for details of the Drag & Drop container system) this command will start the selected container\'s "Find & Remove Traps" programmed sequence, with a (small) chance of the trap (if any) being triggered. If the trap is successfully removed, the container may still be locked but will no longer be trapped. If the token represents any other type of character, container, creature or object a standard "Find/Remove Traps" sequence will ensue, resulting in the party (and the GM) being alerted to the success or otherwise of the outcome.
'
+ +'
In either case, the default approach to the Find Traps roll is that the GM is asked to make it - being presented with a drop-down list of options that includes (a) just rolling 1d100 against the character\'s chance, (b) forcing a successful roll (e.g. if they were meant to find it), and (c) forcing a failure to find a trap (e.g. if there is no trap to be found). The GM can use the !magic --config command to change this action so that the player always rolls to Find Traps, though this might result in an indication for a (non-Drag & Drop) container indicating success for a container that is not trapped!
'
+ +'
4.3 Searching/Storing tokens with Items and Treasure
'
+ +'
--search token_id|pick_id|put_id
'
+ +'
Takes a mandatory token ID of the character\'s token, mandatory token ID of the token to search and pick up items from, mandatory token ID of the token to put picked up items into.
'
+ +'
This command can be used to pick the pockets of an NPC or even another Player Character, as well as to loot magic item and treasure containers such as Chests and dead bodies. It can also be used for putting stuff away, storing items from the character\'s Magic Item Bag into a container, for instance if the MI Bag is getting too full (it is limited to the number of items specified via the --gm-edit-mi menu, though similar items can be stacked). The effect of this command depends on the type of the container: intelligent characters, NPCs and creatures (even if only with animal intelligence of 1) are considered sentient unless they are dead (Hit Points equal to or less than zero). The trapped container status is set by any Drag & Drop container, or via the GM\'s [Add Items] button or !magic --gm-edit-mi command. All other containers (tokens with character sheets) are considered inanimate and untrapped. Any status status can also be overridden if so desired by resetting the container type using the Add Items dialog to set the type to a different value - a sentient creature can be forced to be inanimate (i.e. does not need a pick pockets roll), and visa-versa (e.g. luggage Terry Pratchett style).
'
+ +'
'
+ +' Inanimate container: | a message is shown to the Player saying the container is empty or the items in the container are displayed, and the character doing the search (associated with the put_id token ID) can pick them up and store them in their own Magic Item Bag or, if storing, put items from their character into the container. |
'
+ +' Sentient Creature: | if searching, a Pick Pockets check is undertaken - the Player is asked to roll a dice and enter the result (or Roll20 can do it for them), which is compared to the Pick Pockets score on their character sheet. If successful, a message is displayed in the same way as an Inanimate object. If unsuccessful, a further check is made against the level of the being targeted to see if they notice, and the DM is informed either way. The DM can then take whatever action they believe is needed. Of course, you can always freely give/store items to another creature. |
'
+ +' Trapped container: | Traps can be as simple or as complex as the DM desires. Traps may be nothing more than a lock that requires a Player to say they have a specific key, or a combination that has to be chosen from a list, and nothing happens if it is wrong other than the items in the container not being displayed. Or setting a trap off can have damaging consequences for the character searching or the whole party. It can just be a /whisper gm message to let the DM know that the trapped container has been searched. Searching a trapped container with this command calls an ability macro called "Trap-@{container_name|version}" on the container\'s character sheet: if this does not exist, it calls an ability macro just called "Trap". The first version allows the Trap macro to change the behaviour on subsequent calls to the Trap functionality (if using the ChatSetAttr API to change the version attribute), for instance to allow the chest to open normally once the trap has been defused or expended. This functionality requires confidence in Roll20 macro programming. Important Note: all Character Sheets representing Trapped containers must have their \'ControlledBy\' value (found under the [Edit] button at the top right of each sheet) set to \'All Players\'. Otherwise, Players will not be able to run the macros contained in them that operate the trap! |
'
+ +'
'
+ +'
4.4 Looting and storing without searching a container
'
+ +'
--pickorput token_id|pick_id|put_id|[SHORT/LONG]
'
+ +'
Takes a mandatory token ID for the Player\'s character, a mandatory token ID for the token to pick items from, a mandatory token ID for the token to put items in to, and an optional argument specifying whether to use a long or a short menu.
'
+ +'
This command displays a menu from which items on the character sheet associated with the Pick token can be selected to put in the character sheet associated with the Put token. The Player\'s character\'s token can be either the Put token (if picking up items from a container) or the Pick token (if storing items from their sheet into the container). The other token can be another Player Character (useful for one character giving a magic item to another character) or any other selectable token with a character sheet. No traps or sentient being checks are made by this command - this allows the DM to allow Players to bypass the searching functionality when looting a container or storing items in it. Note: the Player\'s Magic Item menu (accessed via the --mimenu command) does not have an option to loot without searching.
'
+ +'
There are two forms of this menu - the Long form displays all items in the container as individual buttons for the Player to select from, and a single button to store the item: this is generally OK when looting containers with not much in them. The Short form of the menu shows only two buttons: one button which, when clicked, brings up a pick list of all the items in the Pick container, and another button to store the item in the Put container: this is generally best for when a character is storing something from their character sheet items into a chest or other container, or giving an MI to another character, as a character\'s sheet often has many items in it which can make a Long menu very long. Each type of menu has a button on it to switch to the other type of menu without re-issuing the command. If not specified in the command, the type of menu the Player last used in this campaign is remembered and used by the system.
'
+ +'
'
+ +'
5.Light source management
'
+ +'
These functions use Roll20 Dynamic Lighting to provide a token with a light source. If your campaign does not use Dynamic Lighting, they will not function. They can also be accessed through the menu displayed by the AttackMaster API !attk --other-menu command.
'
+ +'
5.1 Show a menu of Light Sources to select from
'
+ +'
--lightsources [token_id]
'
+ +'
Takes an optional token ID as an argument. If token ID is not specified, uses the selected token.
'
+ +'
This command brings up a menu showing a selection of various light sources that a character can use. Selecting one will change the Roll20 Dynamic Lighting values on the Token identified to provide this lighting effect. These are:
'
+ +'
'
+ +' - Magic Weapon or Magical Armour (5ft radius circle),
'
+ +' - Torch (15ft radius circle),
'
+ +' - Hooded Lantern (30ft radius circle),
'
+ +' - Continual Light lantern (60ft radius circle),
'
+ +' - Bullseye Lantern (cone of light, 20 degrees wide and 60ft long),
'
+ +' - Beacon Lantern (cone of light, 20 degrees wide and 240ft long).
'
+ +'
'
+ +'
The menu shows [ON] and [OFF] buttons for each type. Only one type can be ON for each Token: selecting an ON button for any light source turns OFF the others for that Token. Turning the current light source off will turn off all lighting effects on the identified token.
'
+ +'
5.2 Set a lightsource for a token
'
+ +'
--light token_id|(NONE/WEAPON/TORCH/HOODED/CONTLIGHT/BULLSEYE/BEACON)
'
+ +'
Takes a mandatory token ID, and a mandatory type of light source.
'
+ +'
This command sets the light source type that the identified token is using, and changes the Roll20 Dynamic Lighting settings of the token to the relevant value shown under section 5.1, or turn off all lighting effects for the selected token if NONE is specified.
'
+ +'
'
+ +'
6.Other commands
'
+ +'
6.1 Display help on these commands
'
+ +'
--help
'
+ +'
This command does not take any arguments. It displays the mandatory and optional arguments, and a brief description of each command.
'
+ +'
6.2 Display a formatted message in chat
'
+ +'
--message [who|][token_id]|title|message|[command]
'
+ +'
This command takes an optional parameter stating who to send the message to, which defaults to depending on who owns the character represented by the token, an optional token_id which defaults to a selected token, a title for the message which can be an empty string, the message to display, and an optional API command string to be sent at the same time that the message is sent (can use standard & extended escape characters).
'
+ +'
The "who" parameter can be one of:
'
+ +'
'
+ +' gm | Send only to the GM |
'
+ +' whisper | Send only to the players that control the character represented by the token |
'
+ +' w | Short for "whisper" and does the same |
'
+ +' public | Send to all players and the GM |
'
+ +' standard | Check which players/GMs control the character represented by the token. If the GM controls, or no-one, or the controlling player is not on-line, or the token does not represent a character, send to the GM; otherise make public. |
'
+ +' Anything else | Same as Standard |
'
+ +'
'
+ +'
6.3 Display a database item or Character Sheet ability
'
+ +'
--display-ability [who|][token_id]|database|db_item|[dice_roll1]|[dice_roll2]|[target_id]
'
+ +'
This command takes an optional parameter stating who to send the output to, which defaults to depending on who owns the character represented by the token, an optional token_id which defaults to a selected token, the mandatory name or ID of a database or character sheet, the mandatory name of a database item or character sheet ability macro, two optional dice roll results (or Roll20 in-line roll specifications), and an optional token_id of a target token.
'
+ +'
This command can be used to extract database items wherever they are currently stored and display them to a player, character, the GM, or publicly - the options are the same as for the --message command above. If the "database" parameter has a name that includes "-DB" the db_item is read from the databases. This includes extracting database items from the databases held in code by the APIs and displaying them, as if they were ability macros in a Character Sheet, or from a Character Sheet database if the db_item exists there. If the "database" parameter is not for a database, but instead represents the name of a Character Sheet that does not include "-DB", the command will look for and display an ability macro with name "db_item" from that character sheet.
'
+ +'
Whether from the databases or from a character sheet ability macro, the item retrieved can optionally have up to two dice roll values and/or a target token ID passed to it. The dice roll parameters will replace the place-holders %%diceRoll1%% and %%diceRoll2%% in the retrieved item. The parameters can be plain numbers, roll queries (which will be resolved if the command is passed via the chat window or an API button), or in-line roll calculations in Roll20 format (using [[...]]). The target token_id will replace anywhere the @{target|...|token_id} syntax is used.
'
+ +'
6.4 Tidy one or more character sheets
'
+ +'
--tidy [token_id]
'
+ +'
This command takes an optional token_id. If not specified, the command will act on the character sheets represented by all currently selected tokens.
'
+ +'
This command tidies up the character sheet, removing Spell and Magic Item attribute and ability objects that are no longer for items held, and for spells no longer in any spell book. Attack ability objects will also all be removed. All of these will be recreated as and when these items, spells or attacks are again picked up, added to spell books, or used for attacks. This simplifies and speeds up the system, removing redundant processing and memory usage.
'
+ +'
Note: this command is automatically run whenever the DM moves the "Player Ribbon" to a new map page, for every token on that map page that represents a character sheet, and also whenever a character token is dragged onto the active Player page. This continually tidies the system while not imposing a heavy overhead on processing.
'
+ +'
6.5 Configure API behavior
'
+ +'
--config [FANCY-MENUS/SPECIALIST-RULES/SPELL-NUM/ALL-SPELLS/ALL-POWERS/CUSTOM-SPELLS/AUTO-HIDE/ALPHA-LISTS/GM-ROLLS] | [TRUE/FALSE]
'
+ +'
Takes two optional arguments, the first a switchable flag name, and the second TRUE or FALSE.
'
+ +'
Allows configuration of several API behaviors. If no arguments given, displays menu for DM to select configuration. Parameters have the following effects:
'
+ +'
'
+ +' Flag | True | False |
'
+ +' FANCY-MENUS | Use chat menus with a textured background | Use chat menus with a plain background |
'
+ +' SPECIALIST-RULES | Only Specialist Wizards specified in the PHB get an extra spell per spell level | Any non-Standard Wizard gets an extra spell per spell level |
'
+ +' SPELL-NUM | Spellcaster spells per level restricted to PHB rules | Spellcaster spells per level alterable using Misc Spells button |
'
+ +' ALL-SPELLS | Spellcaster spell schools are unrestricted | Spellcaster spell schools are restricted by class rules |
'
+ +' ALL-POWERS | Class powers not restricted by level | Class powers are restricted by level as per spec |
'
+ +' CUSTOM-SPELLS | No distributed custom spells/items allowed (but CS DB allowed) | All custom spells and items allowed |
'
+ +' AUTO-HIDE | Items defined to be hideable will be automatically hidden when added to containers | Hideable items must be hidden manually if desired |
'
+ +' ALPHA-LISTS | Long lists will automatically be split into alpha lists | Whole long lists will be displayed for selection |
'
+ +' GM-ROLLS | GM is asked to roll thievish skill-based chances when using Find Traps | Player rolls skill-based chances for Find Traps |
'
+ +'
'
+ +'
6.6 Check database completeness & integrity (GM only)
'
+ +'
--check-db [ db-name ]
'
+ +'
Takes an optional database name or part of a database name: if a partial name, checks all character sheets with the provided text in their name that also have \'-db\' as part of their name. If omitted, checks all character sheets with \'-db\' in the name. Not case sensitive. Can only be used by the GM.
'
+ +'
This command finds all databases that match the name or partial name provided (not case sensitive), and checks them for completeness and integrity. The command does not alter any ability macros, but ensures that the casting time (\'ct-\') attributes are correctly created, that the item lists are sorted and complete, and that any item-specific power & spell specifications are correctly built and saved.
'
+ +'
This command is very useful to run after creating/adding new items as ability macros to the databases (see specific database documentation). It does not check if the ability macro definition itself is valid, but if it is then it ensures all other aspects of the database consistently reflect the new ability(s).
'
+ +'
6.7 Extract database for Editing
'
+ +'
--extract-db [db-name]
'
+ +'
Takes an optional database name or part of a database name: if a partial name, extracts all character sheets with the provided text in their name that also have \'-db\' as part of their name. If omitted, checks all character sheets with \'-db\' in the name. Not case sensitive. Can only be used by the GM.
'
+ +'
Extracts a named database or all provided databases from the loaded RPGMaster Library, and builds the database(s) in a Character Sheet format: see the Database specific help handouts for further details of this format. This allows editing of the standard items in the databases, adding additional items to the databases, or for items to be copied into the GM\'s own databases. Unlike with previous versions of the Master Series APIs, these extracted databases will not be overwritten automatically by the system. However: using extracted databases will slow the system down - the use of the internal API databases held in memory is much faster. The best use for these extracts is to examine how various items have been programmed so that the GM can create variations of the standard items in their own databases by copying and making small alterations to the definitions, and then the extracted databases can be deleted.
'
+ +'
Important: Once a Character Sheet database is changed or deleted, run the !magic --check-db command against any database (especially a changed one) to prompt the APIs to re-index the objects in all databases.
'
+ +'
6.8 Handshake with other APIs
'
+ +'
-hsq from|[command]
'
+ +'-handshake from|[command]
'
+ +'
Either form performs a handshake with another API, whose call (without the \'!\') is specified as from in the command parameters (the response is always an -hsr command). The command calls the from API command responding with its own command to confirm that this API is loaded and running: e.g.
'
+ +'
- Received:
- !magic -hsq init
'
+ +'- Response:
- !init -hsr magic
'
+ +'
Optionally, a command query can be made to see if the command is supported by MagicMaster if the command string parameter is added, where command is the MagicMaster command (the \'--\' text without the \'--\'). This will respond with a true/false response: e.g.
'
+ +'
- Received:
- !magic -handshake init|menu
'
+ +'- Response:
- !init -hsr magic|menu|true
'
+ +'
6.9 Switch on or off Debug mode
'
+ +'
--debug (ON/OFF)
'
+ +'
Takes one mandatory argument which should be ON or OFF.
'
+ +'
The command turns on a verbose diagnostic mode for the API which will trace what commands are being processed, including internal commands, what attributes are being set and changed, and more detail about any errors that are occurring. The command can be used by the DM or any Player - so the DM or a technical advisor can play as a Player and see the debugging messages.
'
+ +'
'
+ +'
',
+ },
+ });
+
+ /*
+ * Handles for other RPG and Character Sheet specific data tables
+ * obtained from the RPGMaster Library.
+ */
+
+ var fieldGroups;
+ var miTypeLists;
+ var clTypeLists;
+ var spTypeLists;
+ var reSpellSpecs;
+ var reClassSpecs;
+ var saveFormat;
+ var spellsPerLevel;
+ var casterLevels;
+ var specMU;
+ var ordMU;
+ var wisdomSpells;
+ var spellLevels;
+
+ /*
+ * MagicMaster specific global data tables and variables.
+ */
+
+ const MIB_StateEnum = Object.freeze({
+ NOBAG: 0,
+ OLDBAG: 6,
+ V4BAG: 12,
+ });
+
+ const PR_Enum = Object.freeze({
+ YESNO: 'YESNO',
+ CUSTOM: 'CUSTOM',
+ });
+
+ const messages = Object.freeze({
+ header: '&{template:'+fields.defaultTemplate+'} {{name=^^cname^^\'s\nMagic Item Bag}}',
+ restHeader: '&{template:'+fields.defaultTemplate+'} {{name=^^cname^^ is Resting}}',
+ noChar: '&{template:'+fields.warningTemplate+'} {{name=^^cname^^\'s\nMagic Items Bag}}{{desc=^^cname^^ does not have an associated Character Sheet, and so cannot have a Magic Item Bag.}}',
+ noMIBag: '&{template:'+fields.warningTemplate+'} {{name=^^cname^^\'s\nMagic Items Bag}}{{desc=^^cname^^ does not have a Magic Item bag! Perhaps you ought to invest in one... Go and find an appropriate vendor (ask the DM).}}',
+ oldMIBag: '&{template:'+fields.warningTemplate+'} {{name=^^cname^^\'s\nMagic Item Bag}}{{desc=^^cname^^ has an old v3 Magic Item bag, which will not hold the latest, cutting edge Magic Items! Perhaps you ought to invest in a new one... Go and find an appropriate vendor (ask the DM).}}',
+ cursedSlot: '&{template:'+fields.warningTemplate+'} {{name=^^cname^^\'s\nMagic Item Bag}}{{desc=Oh what a shame. No, you can\'t overwrite a cursed item with a different item. You\'ll need a *Remove Curse* spell or equivalent to be rid of it!}}',
+ cursedItem: '&{template:'+fields.warningTemplate+'} {{name=^^cname^^\'s\nMagic Item Bag}}{{desc=Oh no! You try putting this away, but is seems to be back where it was... Perhaps you need a *Remove Curse* spell or equivalent to be rid of it!}}',
+ nothingToPick: '&{template:'+fields.warningTemplate+'} {{name=^^cname^^\'s\nMagic Item Bag}}{{desc=You seem to be trying to pick up something invisible, even to me! I can\'t pick up thin air...}}',
+ slotFull: '&{template:'+fields.warningTemplate+'} {{name=^^cname^^\'s\nMagic Item Bag}}{{desc=The slot you chose is already full.}}',
+ fruitlessSearch: 'does not have a store of Magic Items}}',
+ noSpellbooks: '&{template:'+fields.warningTemplate+'} {{name=Spellbooks}}{{desc=^^cname^^ does not have any spellbooks!}}',
+ noMUspellbook: '&{template:'+fields.warningTemplate+'} {{name=Spellbooks}}{{desc=^^cname^^ does not have a Wizard\'s spellbook. Do they want one? Speak to the Arch-Mage (or, failing that, the DM)}}',
+ noPRspellbook: '&{template:'+fields.warningTemplate+'} {{name=Spellbooks}}{{desc=^^cname^^ does not have a Priest\'s spellbook. Do they want one? Pray to your god (or, failing that, the DM)}}',
+ chooseSpellMenu: '&{template:'+fields.menuTemplate+'} {{name=Spellbooks}}{{section1=^^cname^^ has both Wizard and Priest spellbooks. Which do you want to use?}}{{section2=[Wizard](!magic --spellmenu ^^tid^^|MU) or [Priest](!magic --spellmenu ^^tid^^|PR)}}',
+ shortRest: '&{template:'+fields.defaultTemplate+'} {{name=^^cname^^ is Resting}}{{desc=After a short rest, ^^cname^^ has rememorised all their 1st level spells}}',
+ longRest: 'After a good long rest, ^^cname^^ has regained their powers, read their spellbooks and rememorised their spells, and magic items that recharge have regained their charges.}}',
+ noLongRest: '&{template:'+fields.warningTemplate+'} {{name=^^cname^^ is Unable to Rest}}{{desc=I don\'t think the DM has declared it is time for a rest yet, perhaps due to system lag.}}{{desc1=[Try Again](!magic --rest ^^tid^^|long) once the DM says you can}}',
+ noMoreCharges: '&{template:'+fields.warningTemplate+'} {{name=^^cname^^ Has No Charges}}{{desc=^^cname^^ has used all the charges of the Power, Spell or Magic Item that they are using, and needs to rest before any charges are available again.}}',
+ miBagFull: '&{template:'+fields.warningTemplate+'} {{name=^^c2name^^ MI Bag Full}}{{desc=There are no slots left in the selected container for any more items to store}}',
+ fixedSpell: '&{template:'+fields.warningTemplate+'} {{name=Fixed MI Spell Slot}}{{desc=The chosen slot in your spell-storing Magic Item is fixed to be the named spell. You may only refresh it with the same spell}}',
+ notSpellCaster: '&{template:'+fields.warningTemplate+'} {{name=^^cname^^ is Not a Spell Caster}}{{desc=^^cname^^ may aspire to be a wonderful Wizard or powerful Priest, but has yet to fulfil those desires. Until then, refrain from pretending - you will be found out!}}',
+ notYetSpellCaster: '&{template:'+fields.warningTemplate+'} {{name=^^cname^^ can\'t cast spells yet}}{{desc=^^cname^^ is eager to reach a level of experience at which they can cast spells: keep adventuring and you\'ll get there soon!}}',
+ castSpellClass: '&{template:'+fields.menuTemplate+'} {{name=Spellbooks}}{{desc=^^cname^^ has both Wizard and Priest spellbooks. Which do you want to use?}}{{desc1=[Wizard](!magic --cast-spell MU|^^tid^^) or [Priest](!magic --cast-spell PR|^^tid^^)}}',
+ memSpellClass: '&{template:'+fields.menuTemplate+'} {{name=Spellbooks}}{{desc=^^cname^^ has both Wizard and Priest spellbooks. Which do you want to use?}}{{desc1=[Wizard](!magic --mem-spell MU|^^tid^^) or [Priest](!magic --mem-spell PR|^^tid^^)}}',
+ viewSpellClass: '&{template:'+fields.menuTemplate+'} {{name=Spellbooks}}{{desc=^^cname^^ has both Wizard and Priest spellbooks. Which do you want to view?}}{{desc1=[Wizard](!magic --view-spell MU|^^tid^^) or [Priest](!magic --view-spell PR|^^tid^^)}}',
+ });
+
+ const BT = Object.freeze({
+ ADD_MIROW: 'ADD_MIROW',
+ ADD_TO_STORE: 'ADD_TO_STORE',
+ ADD_AS_POWER: 'ADD_AS_POWER',
+ MON_ATTACK: 'MON_ATTACK',
+ MON_INNATE: 'MON_INNATE',
+ MON_MELEE: 'MON_MELEE',
+ MELEE: 'MELEE',
+ MW_DMGSM: 'MW_DMGSM',
+ MW_DMGL: 'MW_DMGL',
+ MON_RANGED: 'MON_RANGED',
+ RANGED: 'RANGED',
+ RANGEMOD: 'RANGEMOD',
+ RW_DMGSM: 'RW_DMGSM',
+ RW_DMGL: 'RW_DMGL',
+ MI_SPELL: 'MI_SPELL',
+ MI_POWER: 'MI_POWER',
+ MI_POWER_USED: 'MI_POWER_USED',
+ MI_POWER_CHARGE_USED:'MI_POWER_CHARGE_USED',
+ MU_SPELL: 'MU_SPELL',
+ MU_TO_STORE: 'MU_TO_STORE',
+ MU_TO_STORE_ANY: 'MU_TO_STORE_ANY',
+ MU_TO_STORE_ADD: 'MU_TO_STORE_ADD',
+ MU_MI_SLOT: 'MU_MI_SLOT',
+ MU_MI_SLOT_ANY: 'MU_MI_SLOT_ANY',
+ MU_MI_SLOT_ADD: 'MU_MI_SLOT_ADD',
+ PR_SPELL: 'PR_SPELL',
+ PR_TO_STORE: 'PR_TO_STORE',
+ PR_TO_STORE_ANY: 'PR_TO_STORE_ANY',
+ PR_TO_STORE_ADD: 'PR_TO_STORE_ADD',
+ PR_MI_SLOT: 'PR_MI_SLOT',
+ PR_MI_SLOT_ANY: 'PR_MI_SLOT_ANY',
+ PR_MI_SLOT_ADD: 'PR_MI_SLOT_ADD',
+ CAST_MUSPELL: 'CAST_MUSPELL',
+ CAST_PRSPELL: 'CAST_PRSPELL',
+ CAST_MISPELL: 'CAST_MISPELL',
+ CAST_MIPOWER: 'CAST_MIPOWER',
+ CAST_SCROLL: 'CAST_SCROLL',
+ CHOOSE_MUSPELL: 'CHOOSE_MUSPELL',
+ CHOOSE_PRSPELL: 'CHOOSE_PRSPELL',
+ CHOOSE_POWER: 'CHOOSE_POWER',
+ CHOOSE_MI: 'CHOOSE_MI',
+ CHOOSE_MARTIAL_MI: 'CHOOSE_MARTIAL_MI',
+ CHOOSE_ALLITEMS_MI: 'CHOOSE_ALLITEMS_MI',
+ REDO_CHOOSE_MI: 'REDO_CHOOSE_MI',
+ REDO_MARTIAL_MI: 'REDO_MARTIAL_MI',
+ REDO_ALLITEMS_MI: 'REDO_ALLITEMS_MI',
+ CHOOSE_VIEW_MI: 'CHOOSE_VIEW_MI',
+ CHOOSE_USE_MI: 'CHOOSE_USE_MI',
+ CHOOSE_TO_STORE: 'CHOOSE_TO_STORE',
+ REVIEW_MUSPELL: 'REVIEW_MUSPELL',
+ REVIEW_PRSPELL: 'REVIEW_PRSPELL',
+ REVIEW_POWER: 'REVIEW_POWER',
+ REVIEW_MI: 'REVIEW_MI',
+ REVIEW_MARTIAL_MI: 'REVIEW_MARTIAL_MI',
+ REVIEW_ALLITEMS_MI: 'REVIEW_ALLITEMS_MI',
+ REVIEW_MIPOWER: 'REVIEW_MIPOWER',
+ REVIEW_STORE: 'REVIEW_STORE',
+ LEARNT_MUSPELL: 'LEARNT_MUSPELL',
+ SLOT_MUSPELL: 'SLOT_MUSPELL',
+ SLOT_PRSPELL: 'SLOT_PRSPELL',
+ SLOT_POWER: 'SLOT_POWER',
+ SLOT_MI: 'SLOT_MI',
+ SLOT_MARTIAL_MI: 'SLOT_MARTIAL_MI',
+ SLOT_ALLITEMS_MI: 'SLOT_ALLITEMS_MI',
+ MISC_SPELL: 'MISC_SPELL',
+ MEM_MUSPELL: 'MEM_MUSPELL',
+ MEM_PRSPELL: 'MEM_PRSPELL',
+ MEM_POWER: 'MEM_POWER',
+ MEM_MIPOWER: 'MEM_MIPOWER',
+ MEMALL_POWERS: 'MEMALL_POWERS',
+ EDIT_MUSPELLS: 'EDIT_MUSPELLS',
+ EDIT_PRSPELLS: 'EDIT_PRSPELLS',
+ EDIT_NOSPELLS: 'EDIT_NOSPELLS',
+ EDIT_POWERS: 'EDIT_POWERS',
+ EDIT_MIMUSPELLS: 'EDIT_MIMUSPELLS',
+ EDIT_MIPRSPELLS: 'EDIT_MIPRSPELLS',
+ EDIT_MIPOWERS: 'EDIT_MIPOWERS',
+ EDIT_MI: 'EDIT_MI',
+ EDIT_MARTIAL: 'EDIT_MARTIAL',
+ EDIT_ALLITEMS: 'EDIT_ALLITEMS',
+ EDITMI_OPTION: 'EDITMI_OPTION',
+ EDITMARTIAL_OPTION: 'EDITMARTIAL_OPTION',
+ EDITALLITEMS_OPTION:'EDITALLITEMS_OPTION',
+ ALPHALIST_OPTION: 'ALPHALIST_OPTION',
+ REMOVE_MUSPELL: 'REMOVE_MUSPELL',
+ REMOVE_PRSPELL: 'REMOVE_PRSPELL',
+ REMOVE_POWER: 'REMOVE_POWER',
+ REMOVE_MI: 'REMOVE_MI',
+ REMOVE_MARTIAL_MI: 'REMOVE_MARTIAL_MI',
+ DEL_STORED: 'DEL_STORED',
+ STORE_MI: 'STORE_MI',
+ STORE_MARTIAL_MI: 'STORE_MARTIAL_MI',
+ STORE_ALLITEMS_MI: 'STORE_ALLITEMS_MI',
+ MISTORE_MUSPELL: 'MISTORE_MUSPELL',
+ MISTORE_PRSPELL: 'MISTORE_PRSPELL',
+ MISTORE_MUSPELL_ANY:'MISTORE_MUSPELL_ANY',
+ MISTORE_PRSPELL_ANY:'MISTORE_PRSPELL_ANY',
+ VIEW_MUSPELL: 'VIEW_MUSPELL',
+ VIEW_PRSPELL: 'VIEW_PRSPELL',
+ VIEW_POWER: 'VIEW_POWER',
+ VIEW_MI_POWER: 'VIEW_MI_POWER',
+ VIEW_MI_SPELL: 'VIEW_MI_SPELL',
+ VIEW_MI_MUSPELL: 'VIEW_MI_MUSPELL',
+ VIEW_MI_PRSPELL: 'VIEW_MI_PRSPELL',
+ VIEW_MI: 'VIEW_MI',
+ VIEWMI_OPTION: 'VIEWMI_OPTION',
+ VIEWMEM_MUSPELLS: 'VIEWMEM_MUSPELLS',
+ VIEWMEM_PRSPELLS: 'VIEWMEM_PRSPELLS',
+ VIEWMEM_POWERS: 'VIEWMEM_POWERS',
+ VIEWMEM_MI_POWERS: 'VIEWMEM_MI_POWERS',
+ VIEWMEM_MI_SPELLS: 'VIEWMEM_MI_SPELLS',
+ VIEWMEM_MI_MUSPELLS:'VIEWMEM_MI_MUSPELLS',
+ VIEWMEM_MI_PRSPELLS:'VIEWMEM_MI_PRSPELLS',
+ POP_PICK: 'POP_PICK',
+ POP_STORE: 'POPsubmit',
+ PICKMI_OPTION: 'PICKMI_OPTION',
+ PUTMI_OPTION: 'PUTMI_OPTION',
+ POWER: 'POWER',
+ USE_POWER: 'USE_POWER',
+ USE_MI: 'USE_MI',
+ USEMI_OPTION: 'USEMI_OPTION',
+ MI_BAG: 'MI_BAG',
+ THIEF: 'THIEF',
+ MOVE: 'MOVE',
+ CHG_WEAP: 'CHG_WEAP',
+ STAND: 'STAND',
+ SPECIFY: 'SPECIFY',
+ CARRY: 'CARRY',
+ SUBMIT: 'SUBMIT',
+ RIGHT: 'PRIMARY',
+ LEFT: 'OFFHAND',
+ BOTH: 'BOTH',
+ HAND: 'HAND',
+ AB_ASK_TOKENBARS: 'AB_ASK_TOKENBARS',
+ });
+
+ const reIgnore = /[\s\-\_]*/gi;
+ const reCastMIspellCmd = /!magic\s+--(?:cast|view)-spell\s+MI(?:-SPELLS)?\s*\|/im;
+ const reCastMIpowerCmd = /!magic\s+--(?:cast|view)-spell\s+MI-POWERS?\s*\|/im;
+ const reLooksLike = /Looks\s?Like=/im;
+ const reInitMIqty = /}}\s*?\w*?data\s*?=.*?[\[,]\s*?qty:([d\d\+\-\*\/.]+?)[,\s\]]/im;
+ const reSpecs = /}}\s*?specs\s*?=(.*?){{/im;
+ const reSpecsAll = /\[\s*?(\w[-\+\s\w\|]*?)\s*?,\s*?(\w[-\s\w\|]*?\w)\s*?,\s*?(\w[\s\w\|]*?\w)\s*?,\s*?(\w[-\+\s\w\|]*?\w)\s*?\]/g;
+ const reSpecClass = /\[\s*?\w[\s\|\w\-\+]*?\s*?,\s*?(\w[\s\|\w\-]*?)\s*?,.*?\]/g;
+ const reSpecSuperType = /}}\s*Specs=\s*?\[\s*?\w[-\+\s\w\|]*?\s*?,\s*?\w[-\s\w\|]*?\w\s*?,\s*?\d+H(?:\|\d*H)\s*?,\s*?(\w[-\+\s\w\|]*?\w)\s*?\]/im;
+ const reDataSpeed = /}}\s*?\w*?data\s*?=.*?[\[,]\s*?sp:([d\d\+\-\*\/.]+?)[,\s\]]/im;
+ const reDataCost = /}}\s*?\w*?data\s*?=.*?[\[,]\s*?gp:(\d+?\.?\d*?)[,\s\]]/im;
+ const reDataLevel = /}}\s*?\w*?data\s*?=.*?[\[,]\s*?lv:(\d+?)[,\s\]]/im;
+ const reLevel = /[\[,]\s*?lv:(\d+?)[,\s\]]/im;
+ const reClassData = /}}\s*?ClassData\s*?=(.*?){{/im;
+ const reRaceData = /}}\s*?(?:Class|Race)Data\s*?=(.*?){{/im;
+ const reSpellData = /}}\s*?SpellData\s*?=(.*?){{/im;
+ const reRepeatingTable = /^(repeating_.*)_\$(\d+)_.*$/;
+ const reItemData = /}}[\s\w\-]*?(?"],
+ [/\\lt;?/gm, "<"],
+ [/¦/g, "|"],
+ ];
+
+ const msgReplacers = [
+ [/\\api;?/g, "!"],
+ [/\\lbrc;?/g, "{"],
+ [/\\rbrc;?/g, "}"],
+ [/\\gt;?/gm, ">"],
+ [/\\lt;?/gm, "<"],
+ [/<<|«/g, "["],
+ [/\\lbrak;?/g, "["],
+ [/>>|»/g, "]"],
+ [/\\rbrak;?/g, "]"],
+ [/\\\^/g, "?"],
+ [/\\ques;?/g, "?"],
+ [/`/g, "@"],
+ [/\\at;?/g, "@"],
+ [/~/g, "-"],
+ [/\\dash;?/g, "-"],
+ [/\\n/g, "\n"],
+ [/¦/g, "|"],
+ [/\\vbar;?/g, "|"],
+ [/\\clon;?/g, ":"],
+ [/\\amp;?/g, "&"],
+ [/\\lpar;?/g, "("],
+ [/\\rpar;?/g, ")"],
+ [/\\cr;?/g, "
"],
+ [/&&/g, "/"],
+ [/%%/g, "%"],
+ ];
+
+
+ const dbEncoders = [
+ [/\r?\n/gm,'\\n'],
+ [/'/gm,"\\'"],
+ [/&/gm,"\\\\amp;"],
+ [/>/gm,"\\\\gt;"],
+ [/',
+ grey_button: '"display: inline-block; background-color: lightgrey; border: 1px solid black; padding: 4px; color: dimgrey; font-weight: extra-light;"',
+ dark_button: '"display: inline-block; background-color: lightgrey; border: 1px solid black; padding: 4px; color: black; font-weight: normal;"',
+ selected_button: '"display: inline-block; background-color: white; border: 1px solid red; padding: 4px; color: red; font-weight: bold;"',
+ green_button: '"display: inline-block; background-color: white; border: 1px solid lime; padding: 4px; color: darkgreen; font-weight: bold;"',
+ boxed_number: '"display: inline-block; background-color: yellow; border: 1px solid blue; padding: 2px; color: black; font-weight: bold;"',
+ success_box: '"display: inline-block; background-color: yellow; border: 1px solid lime; padding: 2px; color: green; font-weight: bold;"',
+ failure_box: '"display: inline-block; background-color: yellow; border: 1px solid red; padding: 2px; color: maroon; font-weight: bold;"',
+ };
+
+ var apiCommands = {},
+ slotCounts = {},
+ apiDBs = {magic:false,attk:false},
+ GMalphaLists = true,
+ msg_orig = {},
+ time = Date.now();
+
+ var flags = {
+ mib_state: MIB_StateEnum.STOPPED,
+ feedbackName: 'MagicMaster',
+ feedbackImg: 'https://s3.amazonaws.com/files.d20.io/images/5063/thumb.png?1336230370',
+ image: false,
+ archive: false,
+ // RED: v1.207 determine if ChatSetAttr is present
+ canSetAttr: true,
+ // RED: v1.207 determine if MI-DB character sheet is present
+ FoundMagicItemDB: true,
+ // RED: v3.060 determine if missing libraries should be notified
+ notifyLibErr: true,
+ noWaitMsg: true,
+ };
+
+ var MagicMaster_tmp = (function() {
+ var templates = {
+ button: _.template('