Larkinabout / fvtt-token-action-hud-pf2e

Token Action HUD is a repositionable HUD of actions for a selected token.
10 stars 15 forks source link

Versatile Unarmed strikes cannot have their damage types toggled. #126

Closed vaguelyof closed 6 months ago

vaguelyof commented 6 months ago

Versatile unarmed strikes cannot have their damage types toggled through the Token Action HUD. This can be reproduced by creating a Fleshwarp character and adding the Living Weapon feat, choosing the Horn option on add. The toggle functions on the character sheet, and the strikes tab from the HUD accurately shows the state of the toggle, but attempting to use the toggle in the HUD causes nothing to happen and an error to appear in the console.

image

Silvertower commented 6 months ago

Thanks for the report. The problem is not with versatile, per se, because it works on normal weapons. Something to do with how Living Weapon is implemented. I am investigating.

vaguelyof commented 6 months ago

I initially noticed this bug when implementing the following AdjustStrike rule for unarmed attacks in my own game. Putting it here in case it helps.

{
  "key": "AdjustStrike",
  "definition": [
    "item:trait:unarmed"
  ],
  "mode": "add",
  "value": "versatile-cold",
  "property": "weapon-traits"
}
Silvertower commented 6 months ago

The Living Weapon "weapon" doesn't have the weapon.system.traits.toggles (toggles is missing) object, so the code fails to obtain the versatile information. This is different than how objects, such as a dagger, work. This will take some investigation of how upstream does it via the character sheet.

Silvertower commented 6 months ago

Not sure how to resolve yet, but the problem is that the ID of the feat and of the weapon are the same:

Feat Object: image

Weapon Object: image

At first glance, this appears to be an upstream flaw from PF2e system.

The only item on the actor with the ID is the feat item, not the weapon item. The weapon item doesn't actually exist in actor.items.

So, in this case, when the following code is called:

const weapon = coreModule.api.Utils.getItem(actor, itemId)

It is getting the feat object, not the weapon object.

I am not yet sure how to handle this. A fix may take some time.

Silvertower commented 6 months ago

Token Action HUD code will need to change from the current method of obtaining the weapon by ID to instead using multiple elements, similar to how rollStrike() handles it.