yochaigal / Cairn-FoundryVTT

Cairn for FoundryVTT!
MIT License
26 stars 23 forks source link

[Bug] Apply Damage returns error when targeting NPC #89

Open cstby opened 9 months ago

cstby commented 9 months ago

System Info

Bug description

When I click the "apply damage" button in the chat after an attack on an NPC, nothing happens and the following error appears in the console:

image

HeroicCookie commented 3 months ago

I changed this function in damage.js to fix this issue on my end. I just removed the else section for synthetic actors. I believe this change only works for Foundry V11


        const tokenDoc = canvas.scene.tokens.get(target);

            const armor = tokenDoc.actor.system.armor;
            const hp = tokenDoc.actor.system.hp.value;
            const str = tokenDoc.actor.system.abilities.STR.value;

            let {dmg, newHp, newStr} = this._calculateHpAndStr(damage, armor, hp, str);

            tokenDoc.actor.update({'system.hp.value': newHp, 'system.abilities.STR.value': newStr});

            const actor = tokenDoc.actor;

            return { actor, dmg, damage, armor, hp, str, newHp, newStr };
    }```
cstby commented 3 months ago

Cheers! I appreciate you commenting with a fix!

By chance, do you know how Foundry changed in v11 in regard to synthetic actors?

HeroicCookie commented 3 months ago

Not really no, I’m pretty unfamiliar with foundry’s workings, I was just looking to fix a bug that my friends were experiencing and was bored and decided to look into yours as well lol. Looks like actorData is no longer a thing and you just access actor now, but I could be wrong.