diff --git a/SPID/include/Distribute.h b/SPID/include/Distribute.h
index 9c2c2ed..f840a3e 100644
--- a/SPID/include/Distribute.h
+++ b/SPID/include/Distribute.h
@@ -235,6 +235,8 @@ namespace Distribute
}
#pragma endregion
- void Distribute(NPCData& a_npcData, const PCLevelMult::Input& a_input);
- void Distribute(NPCData& a_npcData, bool a_onlyLeveledEntries);
+ void Distribute(NPCData& npcData, const PCLevelMult::Input& input);
+ void Distribute(NPCData& npcData, bool onlyLeveledEntries);
+
+ void DistributeDeathItems(NPCData& npcData, const PCLevelMult::Input& input);
}
diff --git a/SPID/include/FormData.h b/SPID/include/FormData.h
index 780725e..3d46c05 100644
--- a/SPID/include/FormData.h
+++ b/SPID/include/FormData.h
@@ -31,6 +31,25 @@ namespace Forms
{}
};
+ ///
+ /// An exception thrown when actual form's type does not match the form type excplicilty defined in the config.
+ /// E.g. Spell = 0x12345, but the 0x12345 form is actually a Perk.
+ ///
+ struct MismatchingFormTypeException : std::exception
+ {
+ const RE::FormType expectedFformType;
+ const RE::FormType actualFormType;
+ const FormOrEditorID formOrEditorID;
+ const std::string path;
+
+ MismatchingFormTypeException(RE::FormType expectedFformType, RE::FormType actualFormType, const FormOrEditorID& formOrEditorID, const std::string& path) :
+ expectedFformType(expectedFformType),
+ actualFormType(actualFormType),
+ formOrEditorID(formOrEditorID),
+ path(path)
+ {}
+ };
+
struct InvalidKeywordException : std::exception
{
const RE::FormID formID;
@@ -68,6 +87,9 @@ namespace Forms
{}
};
+ ///
+ /// An exception thrown when actual form's type is not in the whitelist.
+ ///
struct InvalidFormTypeException : std::exception
{
const RE::FormType formType;
@@ -182,15 +204,22 @@ namespace Forms
// Either 0x1235 or 0x1235~MyPlugin.esp
if (formID) {
+ RE::TESForm* anyForm;
if (modName) {
- form = as_form(dataHandler->LookupForm(*formID, *modName));
+ anyForm = dataHandler->LookupForm(*formID, *modName);
} else {
- form = as_form(RE::TESForm::LookupByID(*formID));
+ anyForm = RE::TESForm::LookupByID(*formID);
}
- if (!form) {
+
+ if (!anyForm) {
throw UnknownFormIDException(*formID, path, modName);
}
+ form = as_form(anyForm);
+ if (!form) {
+ throw MismatchingFormTypeException(anyForm->GetFormType(), Form::FORMTYPE, FormModPair{ *formID, modName }, path);
+ }
+
if constexpr (std::is_same_v