From b30186d686f793b02ffd017e8aa1ceb8d614caf5 Mon Sep 17 00:00:00 2001 From: MetricExpansion <> Date: Tue, 3 Nov 2020 21:51:08 -0800 Subject: [PATCH] Add location change hooks and round-off C++ implementation --- mod_files/SkyrimOutfitSystem.esp | Bin 1927 -> 2143 bytes src/OutfitSystem.cpp | 51 +++++++++++++++------ src/papyrus/skyoutsysautoswitchtrigger.psc | 7 +++ 3 files changed, 44 insertions(+), 14 deletions(-) create mode 100644 src/papyrus/skyoutsysautoswitchtrigger.psc diff --git a/mod_files/SkyrimOutfitSystem.esp b/mod_files/SkyrimOutfitSystem.esp index 32abfe4417bf671ea65c9c9cf180db69f3af7605..9b790a2acd730804cb0753ea3d4106f0e7a86d46 100644 GIT binary patch delta 298 zcmZqYzb`OBiH(3wqn1K;&4#*UcAR~hmLveOxerZW@WpQF@Nq%v8W=V2JNl|8cdTJ2^1A~j7qc1NH z10xH=f3QXdhRJ4Z^4jbS0Xd14sYMKKevZB@U>QfBP)8O9c90W8oV{UUt}dH7S?d@9 DE7v?A delta 107 zcmcaF(9S5i@0RGCIbT_BO{}GP-wtq z1_lNW1_lOZ1_p-s$%ZVuGetNumKeywords(); for (std::uint32_t i = 0; i < max; i++) { RE::BGSKeyword* keyword = location->GetKeywordAt(i).value(); + + /* char message[100]; - _MESSAGE("Location has Keyword %s", keyword->GetFormEditorID()); - sprintf(message, "Location has Keyword %s", keyword->GetFormEditorID()); + _MESSAGE("SOS: Location has Keyword %s", keyword->GetFormEditorID()); + sprintf(message, "SOS: Location has keyword %s", keyword->GetFormEditorID()); RE::DebugNotification(message, nullptr, false); + */ + keywords.insert(keyword->GetFormEditorID()); } } // Location Type Logic - std::string type; + std::string type_str; + LocationType type; if (keywords.empty()) { - type = "worldcell"; + type_str = "worldcell"; + type = LocationType::World; } else if (keywords.count("LocTypeHabitation")) { - type = "town"; + type_str = "town"; + type = LocationType::Town; } else if (keywords.count("LocTypeDungeon")) { - type = "dungeon"; + type_str = "dungeon"; + type = LocationType::Dungeon; } else { - type = "worldcell"; + type_str = "worldcell"; + type = LocationType::World; } + char message[100]; - sprintf(message, "This location is a %s.", type.c_str()); + sprintf_s(message, "SOS: This location is a %s.", type_str.c_str()); RE::DebugNotification(message, nullptr, false); + + auto& service = ArmorAddonOverrideService::GetInstance(); + service.setOutfitUsingLocation(type); } void SetLocationOutfit(VMClassRegistry* registry, UInt32 stackId, StaticFunctionTag*, UInt32 location, BSFixedString name) { - + if (strcmp(name.data, "")) { + // Location outfit assignment is never allowed to be empty string. Use unset instead. + return; + } + return ArmorAddonOverrideService::GetInstance().setLocationOutfit(LocationType(location), name.data); } void UnsetLocationOutfit(VMClassRegistry* registry, UInt32 stackId, StaticFunctionTag*, UInt32 location) { - + return ArmorAddonOverrideService::GetInstance().unsetLocationOutfit(LocationType(location)); } BSFixedString GetLocationOutfit(VMClassRegistry* registry, UInt32 stackId, StaticFunctionTag*, UInt32 location) { - return ""; + auto outfit = ArmorAddonOverrideService::GetInstance().getLocationOutfit(LocationType(location)); + if (outfit.has_value()) { + return BSFixedString(outfit.value().c_str()); + } else { + // Empty string means "no outfit assigned" for this location type. + return BSFixedString(""); + } } } diff --git a/src/papyrus/skyoutsysautoswitchtrigger.psc b/src/papyrus/skyoutsysautoswitchtrigger.psc new file mode 100644 index 0000000..d78143d --- /dev/null +++ b/src/papyrus/skyoutsysautoswitchtrigger.psc @@ -0,0 +1,7 @@ +Scriptname SkyOutSysAutoSwitchTrigger extends ReferenceAlias + +Event OnLocationChange(Location akOldLoc, Location akNewLoc) + Debug.Notification("SOS: Running OnLocationChange") + Debug.Trace("SOS: Running OnLocationChange") + SkyrimOutfitSystemNativeFuncs.SetOutfitUsingLocation(akNewLoc) +endEvent