RequireVersions "1.9.32.0", "", "", "303" ; Skyrim version, SKSE, (SKGE doesn't exist yet), Wrye Bash 
DeSelectAll

hcomp = False
hdawn = False
hfrost = False
hrnd = False
hrequiem = False

SelectSubPackage "00 Core"

If DataFileExists ("Dawnguard.esm") ; Dawnguard is present
	hcomp = True
	hdawn = True
EndIf
If DataFileExists ("Chesko_Frostfall.esp") ; Frostfall is present
	hcomp = True
	hfrost = True
EndIf
If DataFileExists ("RealisticNeedsandDiseases.esp") ; RND is present
	hcomp = True
	hrnd = True
EndIf
If DataFileExists ("Requiem.esp") ; Requiem is present
	hcomp = True
	hrequiem = True
EndIf

If hcomp
	SelectOne "Install patches for compatible mods?", \
		"|Yes", "Will install all compatibility patches necessary.", "", \
		"No", "Does not install any compatiblity patches.", ""
		Case "Yes"
			hcomp = True
		Break
	EndSelect
EndIf

; # Compatibility Patches

If hcomp
	If hdawn
		SelectSubPackage "41 Dawnguard"
	EndIf
	If hfrost
		SelectSubPackage "42 Frostfall"
	EndIf
	If hrnd
		SelectSubPackage "43 RND"
	EndIf
	If hrequiem
		SelectSubPackage "44 Requiem"
	EndIf
EndIf
