Skip to content

Commit

Permalink
No Kids in Skyrim
Browse files Browse the repository at this point in the history
  • Loading branch information
mrowrpurr committed Oct 2, 2021
1 parent b2ec848 commit a8a84e6
Show file tree
Hide file tree
Showing 12 changed files with 321 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
18 changes: 18 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -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
}
}
]
}
Binary file added NoKids.esp
Binary file not shown.
Binary file added Scripts/NoKids.pex
Binary file not shown.
Binary file added Scripts/NoKidsMCM.pex
Binary file not shown.
Binary file added Scripts/NoKids_KidDetectionScript.pex
Binary file not shown.
75 changes: 75 additions & 0 deletions Scripts/Source/NoKids.psc
Original file line number Diff line number Diff line change
@@ -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
111 changes: 111 additions & 0 deletions Scripts/Source/NoKidsMCM.psc
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions Scripts/Source/NoKids_KidDetectionScript.psc
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions SkyrimSE.code-workspace
Original file line number Diff line number Diff line change
@@ -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
}
}
9 changes: 9 additions & 0 deletions meta.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[General]
modid=0
version=
newestVersion=
category=0
installationFile=

[installedFiles]
size=0
67 changes: 67 additions & 0 deletions skyrimse.ppj
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version='1.0'?>
<PapyrusProject xmlns="PapyrusProject.xsd"
Flags="TESV_Papyrus_Flags.flg"
Game="sse"
Anonymize="true"
Output="Scripts"
Optimize="false"
Release="false"
Zip="false"
Package="false"
Final="false">
<Variables>
<!-- Set the name of your mod: -->
<Variable Name="ModName" Value="CHANGE THE MOD NAME HERE" />
<!-- The folder where you store all of your mods -->
<Variable Name="ModsFolder" Value="C:\Users\mrowr\Dropbox\Skyrim\Mods" />
<!-- Optional folder with additional source code for imports -->
<Variable Name="ImportsFolder" Value="C:\Users\mrowr\Dropbox\Skyrim\Imports" />
</Variables>
<Imports>
<!-- To require SKSE dynamically, extract its Scripts/ directory into a new mod folder -->
<Import>@ModsFolder\SKSE64\Scripts\Source</Import>

<!-- These mods come with source directories by default with required .psc files -->
<!-- <Import>@ModsFolder\PapyrusUtil\Scripts\Source</Import> -->
<Import>@ImportsFolder\SkyUI_SDK\Scripts\Source</Import>
<Import>@ImportsFolder\JContainers\Scripts\Source</Import>
<!-- <Import>@ModsFolder\iWantWidgets\Source\Scripts</Import> -->
<!-- <Import>@ModsFolder\iWantStatusBars\Source\Scripts</Import> -->
<!-- <Import>@ModsFolder\FISSES\scripts\source</Import> -->

<!-- These mods DO NOT come with loose .psc files or are not "mods" and need to be setup manually -->
<!-- <Import>@ImportsFolder\SkyUI_5.1_SDK\Scripts\Source</Import> -->
<!-- <Import>@ImportsFolder\ConsoleUtil</Import> -->
<!-- <Import>@ImportsFolder\UIExtensions\scripts\source</Import> -->

<!-- Change this to be your default Skyrim install directory's Scripts\Source path -->
<Import>C:\Steam\steamapps\common\Skyrim Special Edition\Data\Scripts\Source</Import>
</Imports>
<Folders>
<!-- Relative path to folder containing .psc Papyrus source code files for this project -->
<Folder>./Scripts/Source</Folder>
</Folders>
<!-- The following section is for .bsa archives. You can enable it by setting Package="true" in the PapyrusProject -->
<Packages Output=".">
<Package Name="@ModName" RootDir=".">
<Match In="Scripts">*.pex</Match>
<!-- <Match In="interface\translations">*.txt</Match> -->
</Package>
<!-- If you have any texture files, uncomment the following to create a Textures .bsa archive with texture files -->
<!-- <Package Name="@ModName - Textures" RootDir=".">
<Include>*.dds</Include>
</Package> -->
</Packages>
<!-- The following section is for .zip archive. You can enable it by setting Zip="true" in the PapyrusProject -->
<ZipFiles Output="Build">
<ZipFile Name="@ModName" RootDir="." Compression="deflate">
<Include>@ModName.esp</Include>
<Include NoRecurse="true">*.bsa</Include>
<Match In="Scripts\Source">*.psc</Match>
</ZipFile>
</ZipFiles>
<!-- This will remove any *.bsa files in this directory *after* the build, if there are any. Set UseInBuild="false" to disable. -->
<PostBuildEvent Description="Post-Build Remove BSA Files" UseInBuild="true">
<Command>del *.bsa</Command>
</PostBuildEvent>
</PapyrusProject>

0 comments on commit a8a84e6

Please sign in to comment.