Skip to content

Commit

Permalink
Added template setter
Browse files Browse the repository at this point in the history
  • Loading branch information
draconas1 committed Dec 10, 2022
1 parent 0d53a8b commit add5240
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions packs/dracs-items.db
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
{"name":"MM3 Monster Stats Setter","type":"classFeats","img":"icons/svg/paralysis.svg","effects":[],"folder":null,"sort":0,"flags":{"core":{"sourceId":"Item.ySTciOf5109r86xA"}},"_id":"Y8SwNLZgul9Z1gq8","system":{"description":{"value":"<p>This feature contains a macro that will set the following stats according to the MM3 on a business card level.&nbsp;</p>\n<ul>\n<li>HP</li>\n<li>AC</li>\n<li>Fort, Ref, Will</li>\n<li>Surges</li>\n<li>Action Points</li>\n<li>Save Bonuses</li>\n</ul>\n<p>To use this:&nbsp;</p>\n<ol>\n<li>Set the level, primary role (brute, soldier etc...) and secondary role (minion, standard, elite etc...) on your monster.&nbsp;</li>\n<li>Drag this class feature onto the monster</li>\n<li>Run it <span style=\"font-family: var(--font-primary); font-size: var(--font-size-14);\">&nbsp;</span><span style=\"font-family: var(--font-primary); font-size: var(--font-size-14);\">(clicking the dice icon so you see this in chat, you should also see the stats change).</span></li>\n</ol>\n<p><span style=\"font-family: var(--font-primary); font-size: var(--font-size-14);\">You can delete this class feature once its run, it has served its purpose</span></p>\n<p>If you want different numbers (e.g. the reduced HP varients), then simply tweak the configs in classLookup at the top of the macro, they should be relatively self explanatory.&nbsp; A property in classLookup overrides a property with the same name in defaultLookup.&nbsp;&nbsp;</p>","chat":"","unidentified":""},"source":"Draconas","macro":{"type":"script","scope":"global","launchOrder":"post","command":"const classLookup = {\n artillery: {\n startingHP: 21,\n hpPerLevel: 6,\n acBase: 12\n },\n brute: {\n startingHP: 26,\n hpPerLevel: 10,\n acBase: 12\n },\n controller: {\n startingHP: 24,\n hpPerLevel: 8,\n },\n lurker: {\n startingHP: 21,\n hpPerLevel: 6,\n },\n skirmisher: {\n startingHP: 24,\n hpPerLevel: 8,\n },\n soldier: {\n startingHP: 24,\n hpPerLevel: 8,\n acBase: 16\n },\n}\nconst defaultLookup = {\n nadBase: 12,\n nadPerLevel: 1,\n acBase: 14,\n acPerLevel: 1,\n attackBase: 5,\n attackPerLevel: 1\n}\n\nconst getOrDefault = (role, attr) => {\n if (classLookup[role] && classLookup[role][attr]) {\n return classLookup[role][attr];\n }\n return defaultLookup[attr]\n}\n\nconst actor = this.actor;\nconst data = actor.system;\nconst updateData = { \"system.advancedCals\" : false };\nconst role = data.details.role.primary;\nconst secondary = data.details.role.secondary;\nconst level = data.details.level;\n\nconst hp = getOrDefault(role, \"startingHP\") + (level * getOrDefault(role, \"hpPerLevel\"))\nupdateData[\"system.attributes.hp.value\"] = hp;\nupdateData[\"system.attributes.hp.max\"] = hp;\n\nconst ac = getOrDefault(role, \"acBase\") + (level * getOrDefault(role, \"acPerLevel\"))\nupdateData[\"system.defences.ac.base\"] = ac;\n\nconst nads = getOrDefault(role, \"nadBase\") + (level * getOrDefault(role, \"nadPerLevel\"))\nupdateData[\"system.defences.fort.base\"] = nads;\nupdateData[\"system.defences.ref.base\"] = nads;\nupdateData[\"system.defences.wil.base\"] = nads;\n\nupdateData[\"system.details.surges\"] = ((level - 1) / 10) + 1;\nupdateData[\"system.actionpoints.value\"] = 0;\nupdateData[\"system.details.saves.bonus\"] = [];\n\nif (secondary === \"minion\") {\n updateData[\"system.attributes.hp.value\"] = 1;\n updateData[\"system.attributes.hp.max\"] = 1;\n}\n\nif (secondary === \"elite\") {\n updateData[\"system.attributes.hp.value\"] = hp * 2;\n updateData[\"system.attributes.hp.max\"] = hp * 2;\n updateData[\"system.actionpoints.value\"] = 1;\n updateData[\"system.details.saves.bonus\"] = [{active: true, name: \"elite\", value: \"2\"}];\n}\n\nif (secondary === \"solo\") {\n updateData[\"system.attributes.hp.value\"] = hp * 4;\n updateData[\"system.attributes.hp.max\"] = hp * 4;\n updateData[\"system.actionpoints.value\"] = 2;\n updateData[\"system.details.saves.bonus\"] = [{active: true, name: \"solo\", value: \"5\"}];\n}\n\nactor.update(updateData);","author":""},"class":"","hitFistLevel":10,"hitPerLevel":5,"surgePerDay":5,"skills":"<i class=\"fas fa-edit\"></i>","def":{"ac":0,"fort":0,"ref":0,"wil":0},"proficiencies":{"weapons":[],"armour":[]},"level":null},"ownership":{"default":0,"MZbxT6Tw0ZjDJstw":3},"_stats":{"systemId":"dnd4e","systemVersion":"0.3.3","coreVersion":"10.285","createdTime":null,"modifiedTime":1663421973770,"lastModifiedBy":"MZbxT6Tw0ZjDJstw"}}
{"name":"Masterplan V9 Imported Defences Updater","type":"classFeats","img":"icons/svg/ice-shield.svg","system":{"description":{"value":"<p>In v10 the system maths for defences for NPC's changed, such that they also took the NPC's attributes into account (same as players).&nbsp;&nbsp;</p>\n<p>&nbsp;</p>\n<p>This meant that any monsters imported using the Masterplan Importer for v9 (and importer version less than 2.0.0) suddenly had their defences bumped by the highest attribute mod for the relevant defence.&nbsp; (Just like a players would).</p>\n<p>This item contains a macro that will adjust the base values of the 4 defences to account for the system change, so they are back to what you would expect (and they show in masterplan).&nbsp;</p>\n<p>&nbsp;</p>\n<p>If you did not import your NPC from Masterplan, OR your importer version is 2.0.0 or greater, OR you are not using advanced math, you do not need to use this.&nbsp;&nbsp;</p>\n<p>&nbsp;</p>\n<p>To use:</p>\n<ol>\n<li>Drag this class feature onto the monster</li>\n<li>Run it (clicking the dice icon so you see this in chat, you should see the defences update)</li>\n</ol>\n<p>&nbsp;</p>\n<p>You can delete this class feature once its run, it has served its purpose.&nbsp;</p>\n<p>&nbsp;</p>\n<p>&nbsp;</p>","chat":"","unidentified":""},"source":"","macro":{"type":"script","scope":"global","launchOrder":"post","command":"actor = this.actor;\nconst updateBuilder = (defence, attr1, attr2, updates) => {\n const attrmod1 = actor.system.abilities[attr1].mod\n const attrmod2 = actor.system.abilities[attr2].mod\n const modifyDefenceBy = Math.max(attrmod1, attrmod2)\n const defenceBase = actor.system.defences[defence].base\n updates[`system.defences.${defence}.base`] = defenceBase - modifyDefenceBy\n}\n\nconst updates = {}\nupdateBuilder('fort', 'str', 'con', updates)\nupdateBuilder('ref', 'int', 'dex', updates)\nupdateBuilder('ac', 'int', 'dex', updates)\nupdateBuilder('wil', 'wis', 'cha', updates)\nupdates[\"flags.masterplan.importerVersion.major\"] = 2\nupdates[\"flags.masterplan.importerVersion.minor\"] = 0\nupdates[\"flags.masterplan.importerVersion.patch\"] = 1\nupdates[\"flags.masterplan.imported\"] = true\n\nawait actor.update(updates)","author":""},"class":"","hitFistLevel":10,"hitPerLevel":5,"surgePerDay":5,"skills":"<i class=\"fas fa-edit\"></i>","def":{"ac":0,"fort":0,"ref":0,"wil":0},"proficiencies":{"weapons":[],"armour":[]},"level":null},"effects":[],"ownership":{"default":0,"MZbxT6Tw0ZjDJstw":3},"flags":{"core":{"sourceId":"Item.leIcQ4hOcNib6u90"}},"_stats":{"systemId":"dnd4e","systemVersion":"0.3.12","coreVersion":"10.288","createdTime":1666205600747,"modifiedTime":1666207252243,"lastModifiedBy":"MZbxT6Tw0ZjDJstw"},"folder":null,"sort":0,"_id":"lFjgn47hxdARLpuJ"}
{"name":"Permanent DMs Template Settings","type":"destinyFeats","img":"icons/svg/statue.svg","system":{"description":{"value":"<p>This sets monster stats in accordance with a st of formula used by Perminant DM in their games.</p>\n<p>&nbsp;</p>\n<p>It is designed to be run as an item macro, but has the commented out code to run as a free macro on all selected tokens.&nbsp; Simply add this destiny to your monster, goto the effects and adjust the various variable values to suit then \"roll\" this destiny feature and it will set values as appropreate.&nbsp;&nbsp;</p>\n<p>&nbsp;</p>\n<p>To get the attack and damage modifiers set whatever your base attack / damage is and add @atkMod / @damMod to the roll formula.&nbsp;&nbsp;</p>\n<p>&nbsp;</p>\n<p>If you've read this in the chat, then it's done its job.</p>","chat":"","unidentified":""},"source":"","activation":{"type":"","cost":0,"condition":""},"duration":{"value":null,"units":""},"target":{"value":null,"width":null,"units":"","type":""},"range":{"value":null,"long":null,"units":""},"uses":{"value":0,"max":0,"per":null},"consume":{"type":"","target":null,"amount":null},"macro":{"type":"script","scope":"global","launchOrder":"post","command":"const classLookup = {\n artillery: {\n startingHP: 21,\n hpPerLevel: 6,\n acBase: 12\n },\n brute: {\n startingHP: 26,\n hpPerLevel: 10,\n acBase: 12\n },\n controller: {\n startingHP: 24,\n hpPerLevel: 8,\n },\n lurker: {\n startingHP: 21,\n hpPerLevel: 6,\n },\n skirmisher: {\n startingHP: 24,\n hpPerLevel: 8,\n },\n soldier: {\n startingHP: 24,\n hpPerLevel: 8,\n acBase: 16\n },\n}\nconst defaultLookup = {\n nadBase: 13,\n nadPerLevel: 1,\n acBase: 15,\n acPerLevel: 1,\n attackBase: 5,\n attackPerLevel: 1,\n initMod: 0\n}\n\nconst getOrDefault = (role, attr) => {\n if (classLookup[role] && classLookup[role][attr]) {\n return classLookup[role][attr];\n }\n return defaultLookup[attr]\n}\n\nconst varOrDefault = (variable) => {\n return variable ? variable : 0\n}\n\n\nconst updateActor = async (actor) => {\n const data = actor.system;\n const updateData = { \"system.advancedCals\" : false };\n const role = data.details.role.primary;\n const secondary = data.details.role.secondary;\n const level = data.details.level;\n const acBooster = varOrDefault(data.vars.ACBooster)\n const fortBooster = varOrDefault(data.vars.FortBooster)\n const refBooster = varOrDefault(data.vars.RefBooster)\n const willBooster = varOrDefault(data.vars.WillBooster)\n const initMod = varOrDefault(data.vars.RollInitMod)\n const mla = varOrDefault(data.vars.MLA)\n const tierBase = varOrDefault(data.vars.TierBase)\n\n\n const adjustedLevel = level + mla\n\n const hp = getOrDefault(role, \"startingHP\") + (adjustedLevel * getOrDefault(role, \"hpPerLevel\"))\n updateData[\"system.attributes.hp.value\"] = hp;\n updateData[\"system.attributes.hp.max\"] = hp;\n\n const ac = getOrDefault(role, \"acBase\") + (adjustedLevel * getOrDefault(role, \"acPerLevel\"))\n updateData[\"system.defences.ac.base\"] = ac + acBooster;\n\n const nads = getOrDefault(role, \"nadBase\") + (adjustedLevel * getOrDefault(role, \"nadPerLevel\"))\n updateData[\"system.defences.fort.base\"] = nads + fortBooster;\n updateData[\"system.defences.ref.base\"] = nads + refBooster;\n updateData[\"system.defences.wil.base\"] = nads + willBooster;\n\n\n const initBonus = getOrDefault(role, \"initMod\") + initMod + Math.floor((level + mla)/2)\n updateData[\"system.attributes.init.bonus\"] = [{active: true, name: \"Fluffiest Badger said so\", value: `${initBonus}`}]\n updateData[\"system.details.surges\"] = ((level - 1) / 10) + 1;\n updateData[\"system.actionpoints.value\"] = 0;\n updateData[\"system.details.saves.bonus\"] = [];\n\n const attackMod = level + mla - tierBase;\n const damageMod = level + mla - tierBase;\n\n updateData[\"system.modifiers.attack.bonus\"] = [{active: true, name: \"Fluffiest Badger said so\", value: `${attackMod}`}]\n updateData[\"system.modifiers.damage.bonus\"] = [{active: true, name: \"Fluffiest Badger said so\", value: `${damageMod}`}]\n\n if (secondary === \"minion\") {\n updateData[\"system.attributes.hp.value\"] = 1;\n updateData[\"system.attributes.hp.max\"] = 1;\n }\n\n if (secondary === \"elite\") {\n updateData[\"system.attributes.hp.value\"] = hp * 2;\n updateData[\"system.attributes.hp.max\"] = hp * 2;\n updateData[\"system.actionpoints.value\"] = 1;\n updateData[\"system.details.saves.bonus\"] = [{active: true, name: \"elite\", value: \"2\"}];\n }\n\n if (secondary === \"solo\") {\n updateData[\"system.attributes.hp.value\"] = hp * 4;\n updateData[\"system.attributes.hp.max\"] = hp * 4;\n updateData[\"system.actionpoints.value\"] = 2;\n updateData[\"system.details.saves.bonus\"] = [{active: true, name: \"solo\", value: \"5\"}];\n }\n\n await actor.update(updateData);\n}\n\n\n// let targets = canvas.tokens.controlled;\n// for( let i = 0; i < targets.length; i++) {\n// updateActor(targets[i].document.actor)\n// }\n\nupdateActor(this.actor)","author":""},"requirements":"","level":null},"effects":[{"label":"TemplateVariables","icon":"icons/svg/card-joker.svg","origin":"Item.IswEFRMrQYhx50NU","duration":{"startTime":null,"seconds":null,"combat":null,"rounds":null,"turns":null,"startRound":null,"startTurn":null},"disabled":false,"_id":"fsMKDTHbIXpEBtCf","changes":[{"key":"system.vars.ACBooster","mode":2,"value":"0","priority":null},{"key":"system.vars.FortBooster","mode":2,"value":"0","priority":null},{"key":"system.vars.RefBooster","mode":2,"value":"0","priority":null},{"key":"system.vars.WillBooster","mode":2,"value":"0","priority":null},{"key":"system.vars.RollInitMod","mode":2,"value":"0","priority":null},{"key":"system.vars.MLA","mode":2,"value":"0","priority":null},{"key":"system.vars.TierBase","mode":2,"value":"0","priority":null}],"tint":null,"transfer":true,"flags":{"dnd4e":{"effectData":{"equippedRec":false,"durationType":"","durationTurnInit":null,"startTurnInit":null}}}}],"ownership":{"default":0,"MZbxT6Tw0ZjDJstw":3},"flags":{"core":{"sourceId":"Item.IswEFRMrQYhx50NU"}},"_stats":{"systemId":"dnd4e","systemVersion":"0.3.15","coreVersion":"10.290","createdTime":1670668582740,"modifiedTime":1670669838393,"lastModifiedBy":"MZbxT6Tw0ZjDJstw"},"folder":null,"sort":0,"_id":"ZNFc14MikH2B15re"}

0 comments on commit add5240

Please sign in to comment.