summaryrefslogtreecommitdiff
path: root/tgscripts/fvtt-Macro-weapon-select.json
blob: 4db9192ca50ba419fc94287763f667fb1181803d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{
  "name": "Weapon-Select",
  "type": "script",
  "scope": "global",
  "author": "3r8Uo5wkrb6EqEZc",
  "img": "icons/svg/dice-target.svg",
  "command": "let applyWeaponChanges = false;\nlet applyFistChanges = false;\nconst his = game.actors.getName(\"Hisui\");\n\nlet style = '<h2 style=\"font-family:mason-serif; background-image:linear-gradient(45deg, #25003c, rgba(220, 159, 241, 0.6509803922)); color:#fff; padding-left: 4px; text-shadow: 1px 1px 2px #000\">'\n\nlet message = style + 'Weapon Select</h2>\\n<p style=\"font-family:warnock-pro;\">Hisui is using ';\n\n\n\nnew Dialog({\n        title : `Improvised Weapon Select`,\n        content : `<label>Weapon type: </label>\n                   <select name=\"attackmod\" id=\"attackmod\">\n                   <option value=\"2h\">Two-Handed</option>\n                   <option value=\"1h\">One-handed</option>\n                   </select>\n                   <label> Weapon damage: </label>\n                   <select name=\"dice\" id=\"dice\">\n                   <option value=\"d4\">d4</option>\n                   <option value=\"d6\">d6</option>\n                   <option value=\"d8\">d8</option>\n                   <option value=\"d10\">d10</option>\n                   </select>`,\n        buttons : {\n            weapon : {\n                icon : \"<i class='fas fa-check'></i>\",\n                label : `Equip Weapon`,\n                callback : () => { applyWeaponChanges = true; applyFistChanges = false; }\n            },\n            fists : {\n                icon : \"<i class='fas fa-skull-crossbones'></i>\",\n                label : `Equip Hands`,\n                callback : () => { applyWeaponChanges = false; applyFistChanges = true; }\n            },\n            cancel : {\n                icon : \"<i class='fas fa-times'></i>\",\n                label : `Cancel`,\n                callback : () => { applyWeaponChanges = false; applyFistChanges = false; }\n            }\n        },\n        default : \"weapon\",\n        close : html => {\n            if (applyWeaponChanges || applyFistChanges) {\n                if(applyWeaponChanges) {\n                    let die = ( html.find('[name=\"dice\"]')[0].value || \"d8\" );\n                    let hand = ( html.find('[name=\"attackmod\"]')[0].value || \"1h\" );\n                    let mod = ( hand == \"2h\" ) ? (his.data.data.abilities.str.mod - his.data.data.abilities.dex.mod) : 0; \n\n                    his.system.attributes.weapon.melee.dice = die;\n                    his.system.attributes.attackMod.value = mod;\n\n                    his.update({'system.attributes.weapon.melee.dualwield' : (hand == \"1h\") ? 'true' : 'false' });\n\n                    message += 'a '+ ( hand == \"1h\" ? '<strong>one-handed</strong> ' : '<strong>two-handed</strong> ') + 'weapon with a <strong>' + die + '</strong> damage die.</p>';\n\n                    \n                } else {\n                    his.system.attributes.attackMod.value = 0;\n                    his.update({'system.attributes.weapon.melee.dualwield' : 'true' });\n                    \n                    message += 'her bare hands.</p>'\n                }\n\n                his.update({'system.resources.spendable.custom2.current' : (applyWeaponChanges == true) ? 1 : 0});\n\n                ChatMessage.create({\n                user: game.user._id,\n                speaker: ChatMessage.getSpeaker({token: actor}),\n                content: message\n                });\n\n\n            }\n        }\n    }).render(true);",
  "flags": {
    "exportSource": {
      "world": "valoran",
      "system": "archmage",
      "coreVersion": "10.291",
      "systemVersion": "1.23.1"
    }
  },
  "_stats": {
    "systemId": "archmage",
    "systemVersion": "1.23.1",
    "coreVersion": "10.291",
    "createdTime": 1670059784200,
    "modifiedTime": 1670152580815,
    "lastModifiedBy": "3r8Uo5wkrb6EqEZc"
  }
}