diff --git a/src/app/helpers/validate.ts b/src/app/helpers/validate.ts index 96cd20a..d3c8583 100644 --- a/src/app/helpers/validate.ts +++ b/src/app/helpers/validate.ts @@ -49,6 +49,10 @@ export function validationMessagesForMod( nonexistentRecipes(mod), ]; + validationContainer.forEach((v) => { + v.messages = sortBy(v.messages, 'message'); + }); + validationContainer.forEach((v) => { if (v.messages.length !== 0) return; diff --git a/src/app/helpers/validators/item.ts b/src/app/helpers/validators/item.ts index 54690d1..d604baf 100644 --- a/src/app/helpers/validators/item.ts +++ b/src/app/helpers/validators/item.ts @@ -2,6 +2,7 @@ import { get, groupBy } from 'lodash'; import { IItemDefinition, IModKit, + ItemSlot, ItemSlotType, ValidationMessage, ValidationMessageGroup, @@ -96,15 +97,45 @@ export function checkItemUses(mod: IModKit): ValidationMessageGroup { }); }); - Object.keys(itemCounts).forEach((item) => { - if (itemCounts[item] > 0) return; + mod.dialogs.forEach((dialog) => { + Object.keys(dialog.items?.equipment ?? {}).forEach((slot) => { + if (!dialog.items.equipment[slot as ItemSlot]) return; - itemValidations.messages.push({ - type: 'warning', - message: `${item} is unused.`, + addItemCount(dialog.items.equipment[slot as ItemSlot]); + }); + + Object.keys(itemCounts).forEach((item) => { + if (itemCounts[item] > 0) return; + + const dialogText = JSON.stringify(dialog.dialog ?? {}); + const dialogBehavior = JSON.stringify(dialog.behaviors ?? {}); + + if (dialogText.includes(item) || dialogBehavior.includes(item)) { + addItemCount(item); + } }); }); + Object.keys(itemCounts) + .sort() + .forEach((item) => { + if (itemCounts[item] > 0) return; + + // autogenerated items dont count against warnings + if ( + item.includes('Lore Scroll') || + item.includes('Rune Scroll') || + item.includes('Solokar') || + item.includes('Orikurnis') + ) + return; + + itemValidations.messages.push({ + type: 'warning', + message: `${item} is unused.`, + }); + }); + return itemValidations; } diff --git a/src/app/helpers/validators/spawner.ts b/src/app/helpers/validators/spawner.ts index 60c9aff..8c95619 100644 --- a/src/app/helpers/validators/spawner.ts +++ b/src/app/helpers/validators/spawner.ts @@ -21,7 +21,10 @@ export function checkSpawners(mod: IModKit): ValidationMessageGroup { }); } - if (!spawner.npcAISettings?.includes('default')) { + if ( + spawner.npcAISettings?.length > 0 && + !spawner.npcAISettings?.includes('default') + ) { itemValidations.messages.push({ type: 'warning', message: `Spawner ${spawner.tag} does not have the default AI setting.`,