From c00a6b11b7c83b8cbe0264b2a58819747809c251 Mon Sep 17 00:00:00 2001 From: macniel Date: Sun, 16 Nov 2025 13:35:39 +0100 Subject: [PATCH] fixes NPE as ranged items could be equipped when the actor doesnt even have the skill to do so. --- src/module/sheets/characterSheet.mjs | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/module/sheets/characterSheet.mjs b/src/module/sheets/characterSheet.mjs index f99cd01a..59320a07 100644 --- a/src/module/sheets/characterSheet.mjs +++ b/src/module/sheets/characterSheet.mjs @@ -479,17 +479,19 @@ class CharacterSheet extends HandlebarsApplicationMixin(ActorSheetV2) { if (fernkampf) { const fkitems = fernkampf.system.rangedSkills.map((skillInQuestion) => actorData.items.find(p => p.name === skillInQuestion)) - fkitems.forEach(skill => { - context.attacks.push({ - name: skill.name, - id: fernkampf._id, - skillId: skill._id, - using: fernkampf.name, - isRanged: true, - at: `${this.document.system.fk.aktuell + skill.system.at}`, - tp: `${fernkampf.system.rangedAttackDamage}`, - ini: `${context.inidice}w6 + ${context.inivalue + fernkampf.system.iniModifier ?? 0}`, - }) + fkitems?.forEach(skill => { + if (skill) { + context.attacks.push({ + name: skill.name, + id: fernkampf._id, + skillId: skill._id, + using: fernkampf.name, + isRanged: true, + at: `${this.document.system.fk.aktuell + skill.system.at}`, + tp: `${fernkampf.system.rangedAttackDamage}`, + ini: `${context.inidice}w6 + ${context.inivalue + fernkampf.system.iniModifier ?? 0}`, + }) + } }) } if (links) { @@ -500,7 +502,7 @@ class CharacterSheet extends HandlebarsApplicationMixin(ActorSheetV2) { meitems.push(item) } }) - meitems.forEach(skill => { + meitems?.forEach(skill => { const obj = skill context.attacks.push({ name: obj.name, @@ -523,7 +525,7 @@ class CharacterSheet extends HandlebarsApplicationMixin(ActorSheetV2) { meitems.push(item) } }) - meitems.forEach(skill => { + meitems?.forEach(skill => { const obj = skill context.attacks.push({ name: obj.name,