[bug] Actor bloodied properties/variables acting screwy
Opened this issue · 1 comments
A user on the Discord was having trouble with referencing bloodied status in powers and effects, beginning roughly here: https://discord.com/channels/415906830137556992/800019673713606717/1184645534082932756
After a fair bit of troubleshooting, we found discrepancies between when @bloodied
seemed to work (for them, in powers but not in effects; for me always) and when @details.isBloodied
seemed to work (for them, okay in effects, but in powers was sometimes 0 and sometimes null but never 1; for me, sometimes in effects but never in powers).
In the end I got them to send me the JSON export of the power they were working on (FerociousCharge-Troubleshooting.json). I started a fresh game world with no additional modules loaded to test. After a few fresh worlds and retries, I can reliably produce this behaviour:
- Fresh from import, the effect looks for
@details.isBloodied
and returns 0 regardless of bloodied status. - If I then change the effect to reference
@bloodied
, it evaluates correctly to 0 or 1 based on status. - If I then change it back to
@details.isBloodied
, it keeps working. - If I delete the power completely from both game and character, then re-import and re-add it, it works off the bat with either property.
- If I delete the character and make a new one, then add the power, it goes back to not working with
@details.isBloodied
, but does work with@bloodied
.
So it seems like replacing the character, not the power, seems to be what causes the problem. I'm wondering if there is something wrong with the actor's properties when it is newly-made? Though I don't understand why referencing @bloodied
would fix that, unless maybe looking for the variables performs some process that coincidentally updates whatever was wrong. Posting here in hopes somebody else has more insight into it that I do!
I may have found the issue. @bloodied
was calculated from system.attributes.hp.max
, a derived value when hp autocalc is on. Active effects seem to be applied before derived values are calculated. Changing this to use system.details.isBloodied
, which is written to the database and not calculated on the fly, solved the issue in my environment.
Not sure why @bloodied
worked under some conditions, though. I also observed this in another environment. I think it should never have worked, but maybe something asynchronous is going on under the hood...