diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..0c72597 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,12 @@ +{ + // created by vscode papyrus-lang papyrus.skyrimSpecialEdition.generateProject + "version": "0.2.0", + "configurations": [ + { + "name": "Skyrim SE", + "type": "papyrus", + "request": "attach", + "game": "skyrimSpecialEdition" + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..9f5b188 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,18 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "type": "pyro", + "projectFile": "skyrimse.ppj", + "gamePath": "C:\\Steam\\steamapps\\common\\Skyrim Special Edition\\", + "problemMatcher": [ + "$PapyrusCompiler" + ], + "label": "pyro: Compile Project (skyrimse.ppj)", + "group": { + "kind": "build", + "isDefault": true + } + } + ] +} \ No newline at end of file diff --git a/NoKids.esp b/NoKids.esp new file mode 100644 index 0000000..b5ea924 Binary files /dev/null and b/NoKids.esp differ diff --git a/Scripts/NoKids.pex b/Scripts/NoKids.pex new file mode 100644 index 0000000..a4a46d0 Binary files /dev/null and b/Scripts/NoKids.pex differ diff --git a/Scripts/NoKidsMCM.pex b/Scripts/NoKidsMCM.pex new file mode 100644 index 0000000..926d7da Binary files /dev/null and b/Scripts/NoKidsMCM.pex differ diff --git a/Scripts/NoKids_KidDetectionScript.pex b/Scripts/NoKids_KidDetectionScript.pex new file mode 100644 index 0000000..e18538f Binary files /dev/null and b/Scripts/NoKids_KidDetectionScript.pex differ diff --git a/Scripts/Source/NoKids.psc b/Scripts/Source/NoKids.psc new file mode 100644 index 0000000..b86aff8 --- /dev/null +++ b/Scripts/Source/NoKids.psc @@ -0,0 +1,75 @@ +scriptName NoKids hidden +{Stores the tracked children} + +int function NoKidsStorage() global + int kidsStorage = JDB.solveObj(".noKids") + if ! kidsStorage + kidsStorage = JMap.object() + JDB.solveObjSetter(".noKids", kidsStorage, createMissingKeys = true) + JMap.setObj(kidsStorage, "kidsByName", JMap.object()) + JMap.setObj(kidsStorage, "kidsEnabledByName", JMap.object()) + endIf + return kidsStorage +endFunction + +int function KidsByNameMap() global + return JMap.getObj(NoKidsStorage(), "kidsByName") +endFunction + +int function KidsEnabledByNameMap() global + return JMap.getObj(NoKidsStorage(), "kidsEnabledByName") +endFunction + +function TrackChild(Actor child) global + string name = child.GetActorBase().GetName() + JMap.setForm(KidsByNameMap(), name, child) + JMap.setInt(KidsEnabledByNameMap(), name, 0) +endFunction + +int function GetTrackedChildCount() global + return JMap.count(KidsByNameMap()) +endFunction + +string[] function SearchChildrenByName(string query) global + string[] kidNames = JMap.allKeysPArray(KidsByNameMap()) + int matchingNames = JArray.object() + + int i = 0 + while i < kidNames.Length + string name = kidNames[i] + if StringUtil.Find(name, query) > -1 + JArray.addStr(matchingNames, name) + endIf + i += 1 + endWhile + + return JArray.asStringArray(matchingNames) +endFunction + +bool function IsChildEnabled(string name) global + return JMap.getInt(KidsEnabledByNameMap(), name) == 1 +endFunction + +bool function IsChildTracked(Actor child) global + return JMap.hasKey(KidsByNameMap(), child.GetActorBase().GetName()) +endFunction + +; Returns enabled state +bool function ToggleChildEnabled(string name) global + Actor kiddo = JMap.getForm(KidsByNameMap(), name) as Actor + bool enabled = JMap.getInt(KidsEnabledByNameMap(), name) == 1 + if enabled + ; Disable + JMap.setInt(KidsEnabledByNameMap(), name, 0) + kiddo.Disable() + else + ; Enable + JMap.setInt(KidsEnabledByNameMap(), name, 1) + kiddo.Enable() + endIf + return ! enabled +endFunction + +; Hmmmmm? Will all children have unique names? +Actor function GetChildByName(string name) global +endFunction diff --git a/Scripts/Source/NoKidsMCM.psc b/Scripts/Source/NoKidsMCM.psc new file mode 100644 index 0000000..3fa8b85 --- /dev/null +++ b/Scripts/Source/NoKidsMCM.psc @@ -0,0 +1,111 @@ +scriptName NoKidsMCM extends SKI_ConfigBase +{SkyUI Mod Configuration Menu for "No Kids"} + +int CurrentReplacementOptionIndex = 0 +Form property CurrentChildReplacementBaseForm auto + +string[] ChildReplacementOptionNames +int[] ChildReplacementOptionFormIDs + +int oid_ChildCounter +int oid_SearchInput +int oid_ReplacementMenu + +string[] CurrentSearchResultNames +int[] CurrentSearchResultOptions +bool IsDispayingSearchResults + +event OnConfigInit() + ModName = "No Kids" + CurrentChildReplacementBaseForm = Game.GetForm(0xA91A0) + ChildReplacementOptionNames = new string[6] + ChildReplacementOptionNames[0] = "Chicken" + ChildReplacementOptionNames[1] = "Dog" + ChildReplacementOptionNames[2] = "Mudcrab" + ChildReplacementOptionNames[3] = "Hod" + ChildReplacementOptionNames[4] = "(Random)" + ChildReplacementOptionNames[5] = "(None)" + ChildReplacementOptionFormIDs = new int[5] + ChildReplacementOptionFormIDs[0] = 0xA91A0 + ChildReplacementOptionFormIDs[1] = 0x23A92 + ChildReplacementOptionFormIDs[2] = 0xE4010 + ChildReplacementOptionFormIDs[3] = 0x1347D + ChildReplacementOptionFormIDs[4] = 0x0 + ChildReplacementOptionFormIDs[5] = 0x0 +endEvent + +event OnPageReset(string _) + SetCursorFillMode(TOP_TO_BOTTOM) + LeftColumn() + SetCursorPosition(1) + RightColumn() +endEvent + +function LeftColumn() + oid_ChildCounter = AddTextOption("Count of tracked children", NoKids.GetTrackedChildCount()) + oid_SearchInput = AddInputOption("Search for child by name", "SEARCH") + if IsDispayingSearchResults + IsDispayingSearchResults = false + ShowSearchResults() + endIf +endFunction + +function RightColumn() + AddHeaderOption("Choose Child Replacement") + oid_ReplacementMenu = AddMenuOption("Select what to replace childen with", ChildReplacementOptionNames[CurrentReplacementOptionIndex]) +endFunction + +function ShowSearchResults() + CurrentSearchResultOptions = Utility.CreateIntArray(CurrentSearchResultNames.Length) + if CurrentSearchResultNames + AddEmptyOption() + AddHeaderOption("Search Results:") + int i = 0 + while i < CurrentSearchResultNames.Length + string kidName = CurrentSearchResultNames[i] + CurrentSearchResultOptions[i] = AddToggleOption(kidName, NoKids.IsChildEnabled(kidName)) + i += 1 + endWhile + endIf +endFunction + +event OnOptionMenuOpen(int _) + SetMenuDialogOptions(ChildReplacementOptionNames) +endEvent + +event OnOptionMenuAccept(int _, int index) + if index == -1 + return + endIf + CurrentReplacementOptionIndex = index + string name = ChildReplacementOptionNames[index] + int formId + if name == "(Random)" + int randomIndex = Utility.RandomInt(0, 3) + formId = ChildReplacementOptionFormIDs[randomIndex] + else + formId = ChildReplacementOptionFormIDs[index] + endIf + SetMenuOptionValue(oid_ReplacementMenu, name) + if formId + CurrentChildReplacementBaseForm = Game.GetForm(formId) + else + CurrentChildReplacementBaseForm = None + endIf +endEvent + +event OnOptionInputAccept(int _, string text) + CurrentSearchResultNames = NoKids.SearchChildrenByName(text) + if ! CurrentSearchResultNames + Debug.MessageBox("No tracked childen found matching name:\n" + text) + endIf + IsDispayingSearchResults = true + ForcePageReset() +endEvent + +event OnOptionSelect(int optionId) + int childNameIndex = CurrentSearchResultOptions.Find(optionId) + string kidName = CurrentSearchResultNames[childNameIndex] + bool enabled = NoKids.ToggleChildEnabled(kidName) + SetToggleOptionValue(optionId, enabled) +endEvent diff --git a/Scripts/Source/NoKids_KidDetectionScript.psc b/Scripts/Source/NoKids_KidDetectionScript.psc new file mode 100644 index 0000000..3148a98 --- /dev/null +++ b/Scripts/Source/NoKids_KidDetectionScript.psc @@ -0,0 +1,16 @@ +scriptName NoKids_KidDetectionScript extends ActiveMagicEffect + +NoKidsMCM property Config auto + +event OnEffectStart(Actor target, Actor caster) + if ! NoKids.IsChildTracked(target) + NoKids.TrackChild(target) + + target.Disable() + + Form replacement = Config.CurrentChildReplacementBaseForm + if replacement + target.PlaceAtMe(replacement, 60) + endIf + endIf +endEvent diff --git a/SkyrimSE.code-workspace b/SkyrimSE.code-workspace new file mode 100644 index 0000000..37cebe1 --- /dev/null +++ b/SkyrimSE.code-workspace @@ -0,0 +1,13 @@ +{ + // created by vscode papyrus-lang papyrus.skyrimSpecialEdition.generateProject + "folders": [ + { + "path": "." + } + ], + "settings": { + "papyrus.skyrimSpecialEdition.enabled": true, + "papyrus.fallout4.enabled": false, + "papyrus.skyrim.enabled": false + } +} \ No newline at end of file diff --git a/meta.ini b/meta.ini new file mode 100644 index 0000000..55a1c1d --- /dev/null +++ b/meta.ini @@ -0,0 +1,9 @@ +[General] +modid=0 +version= +newestVersion= +category=0 +installationFile= + +[installedFiles] +size=0 diff --git a/skyrimse.ppj b/skyrimse.ppj new file mode 100644 index 0000000..4f0dc32 --- /dev/null +++ b/skyrimse.ppj @@ -0,0 +1,67 @@ + + + + + + + + + + + + + @ModsFolder\SKSE64\Scripts\Source + + + + @ImportsFolder\SkyUI_SDK\Scripts\Source + @ImportsFolder\JContainers\Scripts\Source + + + + + + + + + + + C:\Steam\steamapps\common\Skyrim Special Edition\Data\Scripts\Source + + + + ./Scripts/Source + + + + + *.pex + + + + + + + + + @ModName.esp + *.bsa + *.psc + + + + + del *.bsa + + \ No newline at end of file