Skip to content

Commit d9ebc62

Browse files
committed
Add Crime System, Improve PapyrusUtils detection, bug fixes
1 parent 0bef008 commit d9ebc62

20 files changed

+730
-29
lines changed

MinAI.esp

16 Bytes
Binary file not shown.

Scripts/Source/minai_AIFF.psc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ minai_Relationship relationship
1212
minai_EnvironmentalAwareness envAwareness
1313
minai_Util MinaiUtil
1414
minai_CombatManager combat
15+
minai_Crime crimeController
1516

1617
; Per-actor mutex for SetContext
1718
int Property contextMutexMap Auto ; JMap of actor names to mutex states
@@ -162,6 +163,7 @@ Function Maintenance(minai_MainQuestController _main)
162163
combat = (Self as Quest) as minai_CombatManager
163164
followers = Game.GetFormFromFile(0x0913, "MinAI.esp") as minai_Followers
164165
reputation = (Self as Quest) as minai_Reputation
166+
crimeController = (Self as Quest) as minai_Crime
165167
if (!followers)
166168
Main.Fatal("Could not load followers script - Mismatched script and esp versions")
167169
EndIf
@@ -459,6 +461,7 @@ Function SetContext(actor akTarget)
459461
sex.SetContext(akTarget)
460462
StoreKeywords(akTarget)
461463
StoreFactions(akTarget)
464+
crimeController.SetContext(akTarget)
462465
JMap.setFlt(updateTracker, actorKey + "_low", currentGameTime)
463466
endif
464467

Scripts/Source/minai_Config.psc

Lines changed: 78 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ minai_Sex sex
66
minai_DeviousStuff devious
77
bool Property ActionRegistryIsDirty = false Auto
88
minai_SapienceController sapience
9+
minai_Crime crimeController
910

1011
; OID definitions
1112
int logLevelOID
@@ -239,7 +240,7 @@ bool Property enableAIAgentRequestMessage = True Auto
239240
bool Property enableAIAgentRecordSoundEx = True Auto
240241
bool Property enableAIAgentStopRecording = True Auto
241242

242-
; Add these OIDs near the other OID definitions
243+
; Add these OIDs near the other OID declarations
243244
int enableAIAgentRequestMessageOID
244245
int enableAIAgentRecordSoundExOID
245246
int enableAIAgentStopRecordingOID
@@ -281,6 +282,17 @@ int Property lowFrequencyUpdateIntervalOID Auto
281282
int Property contextUpdateIntervalOID Auto
282283
int Property highPerformanceModeOID Auto
283284

285+
int SmallBountyAmountDefault = 50
286+
int Property SmallBountyAmount = 50 Auto
287+
int smallBountyAmountOID
288+
289+
int MediumBountyAmountDefault = 200
290+
int Property MediumBountyAmount = 200 Auto
291+
int mediumBountyAmountOID
292+
293+
int LargeBountyAmountDefault = 1000
294+
int Property LargeBountyAmount = 1000 Auto
295+
int largeBountyAmountOID
284296

285297
Event OnConfigInit()
286298
main.Info("Building mcm menu.")
@@ -290,6 +302,7 @@ EndEvent
290302
Function InitializeMCM()
291303
minai_UseOStim = Game.GetFormFromFile(0x0906, "MinAI.esp") as GlobalVariable
292304
aiff = Game.GetFormFromFile(0x0802, "MinAI.esp") as minai_AIFF
305+
crimeController = Game.GetFormFromFile(0x0802, "MinAI.esp") as minai_Crime
293306
sex = Game.GetFormFromFile(0x0802, "MinAI.esp") as minai_Sex
294307
main = Game.GetFormFromFile(0x0802, "MinAI.esp") as minai_MainQuestController
295308
devious = Game.GetFormFromFile(0x0802, "MinAI.esp") as minai_DeviousStuff
@@ -306,19 +319,21 @@ EndFunction
306319

307320
Function SetupPages()
308321
if sex.IsNSFW()
309-
Pages = new string[6]
322+
Pages = new string[7]
310323
Pages[0] = "General"
311324
Pages[1] = "Physics (CBPC)"
312325
Pages[2] = "Devious Stuff"
313326
Pages[3] = "Sex Settings"
314-
Pages[4] = "Action Registry"
315-
Pages[5] = "Performance"
327+
Pages[4] = "Crime Settings"
328+
Pages[5] = "Action Registry"
329+
Pages[6] = "Performance"
316330
Else
317-
Pages = new string[4]
331+
Pages = new string[5]
318332
Pages[0] = "General"
319333
Pages[1] = "Physics (CBPC)"
320-
Pages[2] = "Action Registry"
321-
Pages[3] = "Performance"
334+
Pages[2] = "Crime Settings"
335+
Pages[3] = "Action Registry"
336+
Pages[4] = "Performance"
322337
EndIf
323338
EndFunction
324339

@@ -339,6 +354,8 @@ Event OnPageReset(string page)
339354
RenderDeviousPage()
340355
elseif page == "Sex Settings"
341356
RenderSexPage()
357+
elseif page == "Crime Settings"
358+
RenderCrimePage()
342359
elseif page == "Action Registry"
343360
RenderActionsPage();
344361
elseif page == "Performance"
@@ -1053,6 +1070,18 @@ Event OnOptionDefault(int oid)
10531070
elseif oid == logLevelOID
10541071
logLevel = logLevelDefault
10551072
SetSliderOptionValue(oid, logLevelDefault, "{0}")
1073+
elseif oid == smallBountyAmountOID
1074+
SmallBountyAmount = SmallBountyAmountDefault
1075+
SetSliderOptionValue(oid, SmallBountyAmount, "{0} gold")
1076+
crimeController.StoreCrimeVariables()
1077+
elseif oid == mediumBountyAmountOID
1078+
MediumBountyAmount = MediumBountyAmountDefault
1079+
SetSliderOptionValue(oid, MediumBountyAmount, "{0} gold")
1080+
crimeController.StoreCrimeVariables()
1081+
elseif oid == largeBountyAmountOID
1082+
LargeBountyAmount = LargeBountyAmountDefault
1083+
SetSliderOptionValue(oid, LargeBountyAmount, "{0} gold")
1084+
crimeController.StoreCrimeVariables()
10561085
EndIf
10571086
EndEvent
10581087

@@ -1207,6 +1236,12 @@ Event OnOptionHighlight(int oid)
12071236
SetInfoText("Hotkey to speak as the dungeon master")
12081237
elseif oid == dungeonMasterTextKeyOID
12091238
SetInfoText("Hotkey to type as the dungeon master")
1239+
elseif oid == smallBountyAmountOID
1240+
SetInfoText("Amount of gold given for minor infractions (trespassing, petty theft, etc.)")
1241+
elseif oid == mediumBountyAmountOID
1242+
SetInfoText("Amount of gold given for moderate crimes (assault, significant theft, etc.)")
1243+
elseif oid == largeBountyAmountOID
1244+
SetInfoText("Amount of gold given for serious crimes (murder, grievous assault, etc.)")
12101245
EndIf
12111246
int i = 0
12121247
string[] actions = JMap.allKeysPArray(aiff.actionRegistry)
@@ -1396,6 +1431,21 @@ Event OnOptionSliderOpen(int oid)
13961431
SetOptionFlags(lowFrequencyUpdateIntervalOID, OPTION_FLAG_NONE)
13971432
SetOptionFlags(contextUpdateIntervalOID, OPTION_FLAG_NONE)
13981433
endif
1434+
elseif oid == smallBountyAmountOID
1435+
SetSliderDialogStartValue(SmallBountyAmount)
1436+
SetSliderDialogDefaultValue(SmallBountyAmountDefault)
1437+
SetSliderDialogRange(10, 1000)
1438+
SetSliderDialogInterval(10)
1439+
elseif oid == mediumBountyAmountOID
1440+
SetSliderDialogStartValue(MediumBountyAmount)
1441+
SetSliderDialogDefaultValue(MediumBountyAmountDefault)
1442+
SetSliderDialogRange(100, 10000)
1443+
SetSliderDialogInterval(50)
1444+
elseif oid == largeBountyAmountOID
1445+
SetSliderDialogStartValue(LargeBountyAmount)
1446+
SetSliderDialogDefaultValue(LargeBountyAmountDefault)
1447+
SetSliderDialogRange(100, 50000)
1448+
SetSliderDialogInterval(100)
13991449
EndIf
14001450
EndEvent
14011451

@@ -1522,6 +1572,18 @@ Event OnOptionSliderAccept(int oid, float value)
15221572
SetOptionFlags(lowFrequencyUpdateIntervalOID, OPTION_FLAG_NONE)
15231573
SetOptionFlags(contextUpdateIntervalOID, OPTION_FLAG_NONE)
15241574
endif
1575+
elseif oid == smallBountyAmountOID
1576+
SmallBountyAmount = value as int
1577+
SetSliderOptionValue(oid, SmallBountyAmount, "{0} gold")
1578+
crimeController.StoreCrimeVariables()
1579+
elseif oid == mediumBountyAmountOID
1580+
MediumBountyAmount = value as int
1581+
SetSliderOptionValue(oid, MediumBountyAmount, "{0} gold")
1582+
crimeController.StoreCrimeVariables()
1583+
elseif oid == largeBountyAmountOID
1584+
LargeBountyAmount = value as int
1585+
SetSliderOptionValue(oid, LargeBountyAmount, "{0} gold")
1586+
crimeController.StoreCrimeVariables()
15251587
EndIf
15261588
EndEvent
15271589

@@ -1578,4 +1640,12 @@ event OnOptionKeyMapChange(int a_option, int a_keyCode, string a_conflictControl
15781640
main.SetDungeonMasterTextKey(true)
15791641
endIf
15801642
endIf
1581-
EndEvent
1643+
EndEvent
1644+
1645+
Function RenderCrimePage()
1646+
SetCursorFillMode(TOP_TO_BOTTOM)
1647+
AddHeaderOption("Bounty Settings")
1648+
smallBountyAmountOID = AddSliderOption("Small Bounty Amount", SmallBountyAmount, "{0} gold")
1649+
mediumBountyAmountOID = AddSliderOption("Medium Bounty Amount", MediumBountyAmount, "{0} gold")
1650+
largeBountyAmountOID = AddSliderOption("Large Bounty Amount", LargeBountyAmount, "{0} gold")
1651+
EndFunction

0 commit comments

Comments
 (0)