Skip to content

Commit

Permalink
#25 use internal item charges (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
PwQt authored Jan 10, 2025
2 parents 32a96e0 + f6f373b commit 614be27
Show file tree
Hide file tree
Showing 63 changed files with 2,100 additions and 1,017 deletions.
1 change: 1 addition & 0 deletions src/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"MAGICITEMS.SheetActivation": "Activation Options",
"MAGICITEMS.SheetActivationEquipped": "Equipped",
"MAGICITEMS.SheetActivationAttuned": "Attuned",
"MAGICITEMS.SheetInternalCharges": "Use item internal charges?",
"MAGICITEMS.SheetTot": "total",
"MAGICITEMS.SheetActives": "active",
"MAGICITEMS.SheetUses": "Uses",
Expand Down
8 changes: 8 additions & 0 deletions src/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,14 @@ Hooks.on("updateItem", async (item, change, options, userId) => {
if (item.actor) {
const actor = item.actor;
const miActor = MagicItemActor.get(actor.id);
if (miActor && item.flags.magicitems?.internal) {
const miItem = miActor.magicItem(item.id);
if (miItem) {
await miItem.updateInternalCharges(item.flags.magicitems?.internal, item);
miItem.rechargeableLabel = miItem.getRechargeableLabel();
miItem.update();
}
}
if (miActor && miActor.listening && miActor.actor.id === actor.id) {
setTimeout(miActor.buildItems.bind(miActor), 500);
}
Expand Down
65 changes: 45 additions & 20 deletions src/packs/_source/magicitem-feats/ball-lightning.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
{
"_id": "CGBGCevjRO22mf7V",
"name": "Ball Lightning",
"permission": {
"default": 0,
"e1GJldqKX2xtXEGs": 3
},
"type": "feat",
"system": {
"description": {
"value": "<p style=\"box-sizing: border-box; user-select: text; color: #191813; font-size: 13px;\">You can create one to four 3-foot-diameter spheres of lightning. The more spheres you create, the less powerful each sphere is individually.</p>\n<p style=\"box-sizing: border-box; user-select: text; color: #191813; font-size: 13px;\">Each sphere appears in an unoccupied space you can see within 120 feet of you. The spheres last as long as you concentrate (as if concentrating on a spell), up to 1 minute. Each sphere sheds dim light in a 30-foot radius.</p>\n<p style=\"box-sizing: border-box; user-select: text; color: #191813; font-size: 13px;\">As a bonus action, you can move each sphere up to 30 feet, but no farther than 120 feet away from you. When a creature other than you comes within 5 feet of a sphere, the sphere discharges lightning at that creature and disappears. That creature must make a DC 15 Dexterity saving throw. On a failed save, the creature takes lightning damage based on the number of spheres you created.</p>\n<table style=\"user-select: text; width: 176px; color: #191813; font-size: 13px; height: 123px;\" border=\"1\">\n<tbody style=\"box-sizing: border-box; user-select: text;\">\n<tr style=\"box-sizing: border-box; user-select: text;\">\n<td style=\"box-sizing: border-box; user-select: text; width: 58px; height: 23px;\"><strong style=\"box-sizing: border-box; user-select: text;\">Spheres</strong></td>\n<td style=\"box-sizing: border-box; user-select: text; width: 117px; height: 23px;\"><strong style=\"box-sizing: border-box; user-select: text;\">Lightning Damage</strong></td>\n</tr>\n<tr style=\"box-sizing: border-box; user-select: text;\">\n<td style=\"box-sizing: border-box; user-select: text; width: 58px; height: 23px;\">4</td>\n<td style=\"box-sizing: border-box; user-select: text; width: 117px; height: 23px;\">[[/r 2d4]]</td>\n</tr>\n<tr style=\"box-sizing: border-box; user-select: text;\">\n<td style=\"box-sizing: border-box; user-select: text; width: 58px; height: 23px;\">3</td>\n<td style=\"box-sizing: border-box; user-select: text; width: 117px; height: 23px;\">[[/r 2d6]]</td>\n</tr>\n<tr style=\"box-sizing: border-box; user-select: text;\">\n<td style=\"box-sizing: border-box; user-select: text; width: 58px; height: 23px;\">2</td>\n<td style=\"box-sizing: border-box; user-select: text; width: 117px; height: 23px;\">[[/r 5d4]]</td>\n</tr>\n<tr style=\"box-sizing: border-box; user-select: text;\">\n<td style=\"box-sizing: border-box; user-select: text; width: 58px; height: 27px;\">1</td>\n<td style=\"box-sizing: border-box; user-select: text; width: 117px; height: 27px;\">[[/r 4d12]]</td>\n</tr>\n</tbody>\n</table>",
"chat": "",
"unidentified": ""
"chat": ""
},
"source": {
"custom": ""
},
"source": "",
"activation": {
"type": "action",
"cost": 1,
"condition": ""
},
"duration": {
"value": null,
"value": "",
"units": ""
},
"target": {
"value": 30,
"value": "30",
"width": null,
"units": "ft",
"type": "sphere"
"type": "sphere",
"prompt": true
},
"range": {
"value": 120,
Expand All @@ -35,19 +32,24 @@
},
"uses": {
"value": null,
"max": 0,
"per": ""
"max": "",
"per": null,
"recovery": "",
"prompt": true
},
"consume": {
"type": "",
"target": "",
"amount": null
"amount": null,
"scale": false
},
"ability": "dex",
"actionType": "save",
"attackBonus": 0,
"chatFlavor": "",
"critical": null,
"critical": {
"threshold": null,
"damage": ""
},
"damage": {
"parts": [],
"versatile": ""
Expand All @@ -63,12 +65,35 @@
"value": null,
"charged": false
},
"attributes": {
"spelldc": 10
}
"attack": {
"bonus": "",
"flat": false
},
"cover": null,
"crewed": false,
"enchantment": null,
"summons": null,
"type": {
"value": "",
"subtype": ""
},
"prerequisites": {
"level": null
},
"properties": []
},
"flags": {},
"img": "icons/magic/light/explosion-star-large-blue-yellow.webp",
"effects": [],
"_stats": {
"coreVersion": "12.331",
"systemId": null,
"systemVersion": null,
"createdTime": null,
"modifiedTime": null,
"lastModifiedBy": null
},
"folder": null,
"_id": "CGBGCevjRO22mf7V",
"_key": "!items!CGBGCevjRO22mf7V"
}
}
65 changes: 45 additions & 20 deletions src/packs/_source/magicitem-feats/cone-of-fear.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
{
"_id": "7khqOxRGYGa8sZ3D",
"name": "Cone of Fear",
"permission": {
"default": 0,
"e1GJldqKX2xtXEGs": 3
},
"type": "feat",
"system": {
"description": {
"value": "<p><span style=\"color: #191813; font-size: 13px;\">While holding the wand, you can use an action to expend 2 charges, causing the wand's tip to emit a 60-foot cone of amber light. Each creature in the cone must succeed on a DC 15 Wisdom saving throw or become frightened of you for 1 minute. While it is frightened in this way, a creature must spend its turns trying to move as far away from you as it can, and it can't willingly move to a space within 30 feet of you. It also can't take reactions. For its action, it can use only the Dash action or try to escape from an effect that prevents it from moving. If it has nowhere it can move, the creature can use the Dodge action. At the end of each of its turns, a creature can repeat the saving throw, ending the effect on itself on a success.</span></p>",
"chat": "",
"unidentified": ""
"chat": ""
},
"source": {
"custom": ""
},
"source": "",
"activation": {
"type": "action",
"cost": 1,
"condition": ""
},
"duration": {
"value": 1,
"value": "1",
"units": "minute"
},
"target": {
"value": 60,
"value": "60",
"width": null,
"units": "ft",
"type": "cone"
"type": "cone",
"prompt": true
},
"range": {
"value": null,
Expand All @@ -35,19 +32,24 @@
},
"uses": {
"value": null,
"max": 0,
"per": ""
"max": "",
"per": null,
"recovery": "",
"prompt": true
},
"consume": {
"type": "",
"target": "",
"amount": null
"amount": null,
"scale": false
},
"ability": "",
"actionType": "save",
"attackBonus": 0,
"chatFlavor": "",
"critical": null,
"critical": {
"threshold": null,
"damage": ""
},
"damage": {
"parts": [],
"versatile": ""
Expand All @@ -63,12 +65,35 @@
"value": null,
"charged": false
},
"attributes": {
"spelldc": 10
}
"attack": {
"bonus": "",
"flat": false
},
"cover": null,
"crewed": false,
"enchantment": null,
"summons": null,
"type": {
"value": "",
"subtype": ""
},
"prerequisites": {
"level": null
},
"properties": []
},
"flags": {},
"img": "icons/magic/control/fear-fright-shadow-monster-red.webp",
"effects": [],
"_stats": {
"coreVersion": "12.331",
"systemId": null,
"systemVersion": null,
"createdTime": null,
"modifiedTime": null,
"lastModifiedBy": null
},
"folder": null,
"_id": "7khqOxRGYGa8sZ3D",
"_key": "!items!7khqOxRGYGa8sZ3D"
}
}
65 changes: 45 additions & 20 deletions src/packs/_source/magicitem-feats/enemy-detection.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
{
"_id": "UcWBTBiKlEMthYSh",
"name": "Enemy Detection",
"permission": {
"default": 0,
"e1GJldqKX2xtXEGs": 3
},
"type": "feat",
"system": {
"description": {
"value": "<p><span style=\"color: #191813; font-size: 13px;\">You can use an action and expend 1 charge to speak its command word. For the next minute, you know the direction of the nearest creature hostile to you within 60 feet, but not its distance from you. The wand can sense the presence of hostile creatures that are ethereal, invisible, disguised, or hidden, as well as those in plain sight. The effect ends if you stop holding the wand.</span></p>",
"chat": "",
"unidentified": ""
"chat": ""
},
"source": {
"custom": ""
},
"source": "",
"activation": {
"type": "action",
"cost": 1,
"condition": ""
},
"duration": {
"value": 1,
"value": "1",
"units": "minute"
},
"target": {
"value": 60,
"value": "60",
"width": null,
"units": "ft",
"type": "radius"
"type": "radius",
"prompt": true
},
"range": {
"value": null,
Expand All @@ -35,19 +32,24 @@
},
"uses": {
"value": null,
"max": 0,
"per": ""
"max": "",
"per": null,
"recovery": "",
"prompt": true
},
"consume": {
"type": "",
"target": "",
"amount": null
"amount": null,
"scale": false
},
"ability": null,
"actionType": "",
"attackBonus": 0,
"chatFlavor": "",
"critical": null,
"critical": {
"threshold": null,
"damage": ""
},
"damage": {
"parts": [],
"versatile": ""
Expand All @@ -63,12 +65,35 @@
"value": null,
"charged": false
},
"attributes": {
"spelldc": 10
}
"attack": {
"bonus": "",
"flat": false
},
"cover": null,
"crewed": false,
"enchantment": null,
"summons": null,
"type": {
"value": "",
"subtype": ""
},
"prerequisites": {
"level": null
},
"properties": []
},
"flags": {},
"img": "icons/tools/scribal/magnifying-glass.webp",
"effects": [],
"_stats": {
"coreVersion": "12.331",
"systemId": null,
"systemVersion": null,
"createdTime": null,
"modifiedTime": null,
"lastModifiedBy": null
},
"folder": null,
"_id": "UcWBTBiKlEMthYSh",
"_key": "!items!UcWBTBiKlEMthYSh"
}
}
Loading

0 comments on commit 614be27

Please sign in to comment.