@@ -217,25 +217,27 @@ namespace FormSwap
217217 return { nullptr , std::nullopt };
218218 };
219219
220+ // references -> conditional forms -> forms
220221 if (!a_ref->IsDynamicForm ()) {
221222 swapData = get_swap_base (a_ref, swapRefs);
222223 }
223-
224224 if (!swapData.first ) {
225225 swapData = GetSwapFormConditional (a_ref, a_base);
226226 }
227-
228227 if (!swapData.first ) {
229228 swapData = get_swap_base (a_base, swapForms);
230229 }
231230
231+ // process leveled swaps. do not swap if leveled item has encounter zone
232232 if (const auto swapLvlBase = swapData.first ? swapData.first ->As <RE::TESLevItem>() : nullptr ) {
233233 if (a_ref->GetEncounterZone () == nullptr ) {
234234 RE::BSScrapArray<RE::CALCED_OBJECT> calcedObjects{};
235235 swapLvlBase->CalculateCurrentFormList (a_ref->GetCalcLevel (false ), 1 , calcedObjects, 0 , true );
236236 if (!calcedObjects.empty ()) {
237237 swapData.first = static_cast <RE::TESBoundObject*>(calcedObjects.front ().form );
238238 }
239+ } else {
240+ swapData.first = nullptr ;
239241 }
240242 }
241243
@@ -255,14 +257,13 @@ namespace FormSwap
255257 return a_result && a_result->IsValid ();
256258 };
257259
260+ // references -> conditional forms -> forms
258261 if (!has_properties (swapData.second ) && !a_ref->IsDynamicForm ()) {
259262 swapData.second = get_properties (a_ref);
260263 }
261-
262264 if (!has_properties (swapData.second )) {
263265 swapData.second = GetObjectPropertiesConditional (a_ref, a_base);
264266 }
265-
266267 if (!has_properties (swapData.second )) {
267268 swapData.second = get_properties (a_base);
268269 }
0 commit comments