Muttley / foundryvtt-ac2d20

Achtung! Cthulhu 2d20 System for Foundry VTT
MIT License
3 stars 3 forks source link

Actor items not draggable or allowed to be "stashed" #126

Open tak5haka opened 1 month ago

tak5haka commented 1 month ago

Once items (gear, weapons, etc) are placed on the Actor sheet, they cannot be dragged off. This prevents the use of a module such as Item Piles where PCs can store items they are not carrying in a vault or container.

If it is too system breaking to enable this function, a simpler solution could be to use a similar function that the armour items have, where there is an icon to click that shows the item is in storage and does not affect encumbrance (like the "stashed" icon on the Fallout 2d20 actor sheet).

tak5haka commented 1 month ago

Looking at the json for weapons, equipment and skill kits, there is a system.equipped and a system.stashed option already there (in the same manner as for armour). I am thinking adjusting the sheet so that this can be used with every item of gear, might be the easiest route to allow players to stash items that they are not carrying with them and manage their weight allowance. However, there is also some code in the ac2d20-compiled.mjs that allows inventory items to be stashed, so that might also be a starting point just to implement this in the inventory partials?

tak5haka commented 1 month ago

I have worked out some solutions to activating the "stashed" option on the actor sheet on my local install of the system, but am not sure of the best way to hand that over to you. Let me know how you would like my suggestions. Thanks!

tak5haka commented 1 month ago

I have done some fiddling around on my local install and this seems to work (at least for me), although you would have to test rigorously as I am not a professional developer (at least not any more) ... I have hooked on to the existing code for stashed items rather than try to introduce anything new in the process.


templates/actor/parts/actor-skillkit.hbs

insert at line 24 (after {{item.name}}):

<a class="item-control item-stash {{#unless item.system.stashed}}item-unstashed{{/unless}}" title='{{localize "AC2D20.TEMPLATES.stashed"}}'>&nbsp;&nbsp;&nbsp;&nbsp;<i class="fas fa-briefcase"></i></a>


templates/actor/parts/actor-weapons.hbs

insert at line 55 (after {{this.name}}):

<a class="item-control item-stash {{#unless this.system.stashed}}item-unstashed{{/unless}}" title='{{localize "AC2D20.TEMPLATES.stashed"}}'>&nbsp;&nbsp;&nbsp;&nbsp;<i class="fas fa-briefcase"></i></a>


templates/actor/parts/actor-equipment.hbs

insert at line 15:

<a class="item-control item-stash {{#unless item.system.stashed}}item-unstashed{{/unless}}" title='{{localize "AC2D20.TEMPLATES.stashed"}}'>&nbsp;&nbsp;&nbsp;&nbsp;<i class="fas fa-briefcase"></i></a>


i18n/en.json (you will have to include localised variants)

insert at line 278:

"AC2D20.TEMPLATES.stashed": "stashed",


src/sheets/ACActorSheet.mjs (I also changed this on ac2d20-compiled.mjs at line 1189, although this is probably done as part of the packaging process?)

replace encumberingItems formula found at line 138 with:

        let encumberingItems = physicalItems.filter(i => {
            if (i.type !== "armor" && !i.system.stashed) {
                return true;
            }
            else if ((i.type === "armor" &&  !i.system.equipped) || (i.type === "armor" && i.system.equipped && i.system.qualities.heavy.value)) {
                return true;
            }
            else {
                return false;
            }
        });

src/sheets/ACActorSheet.mjs (I also changed this on ac2d20-compiled.mjs at line 1595, but I guess that's normally just part of the package process?)

change line 542 to:

await item.update({"system.stashed": !item.system.stashed});


css/ac2d20.css

at line 1409, remove space between .item-control and .item-unstashed

.ac2d20 .item-control.item-unstashed,


As I said, this seems to work fine for me, adjusting the encumbrance depending on whether or not a weapon, skillkit or piece of equipment is stashed or not. Please do test thoroughly though as I tend to use a lot of gaffer tape, glue and sawdust ... :)