Skip to content

Commit

Permalink
V9 -> v10 defence migrator
Browse files Browse the repository at this point in the history
New item in Drac's Items compendium that updates defence numbers for monsters imported under v10 to be correct under the new v10 maths.
  • Loading branch information
draconas1 committed Oct 19, 2022
1 parent 0a85f2a commit c722b07
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion module/screens/creature-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ export default class CreatureImporterScreen extends FormApplication {
// also to get the token size to update properly
actor.update({
"system.advancedCals" : true,
"system.details.size" : creature.Data.details.size
"system.details.size" : creature.Data.details.size,
"flags.masterplan.imported" : true
}, { forceSizeUpdate: true})
}

Expand Down
1 change: 1 addition & 0 deletions packs/dracs-items.db
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
{"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"}

0 comments on commit c722b07

Please sign in to comment.