Aouregan Posted 11 hours ago Posted 11 hours ago (edited) Disclaimer: This is interesting mostly for the KW code maintainers or anyone who wants more granular control over student assignment and has an idea on how to decompile and recompile DLLs and .package files. SchoolLocation.cs — Disable automatic nightly student assignment Purpose This modification disables KW's automatic nightly student reassignment at 23:00. The existing immediate student assignment when High School is enabled (happens when High School is enabled via settings or when a save game is loaded with High School already enabled) is intentionally retained. Resulting behavior Enabling High School still calls SchoolLocation.AssignStudents() once immediately. This takes place when the High School is either enabled in the settings, OR when the game starts/is loaded with High School already enabled. So, once per save start, KW will still auto assign all available teens as students. I did not want to interfere with that. It simply results in the requirement to manually check the registered student list once after each game start. The recurring 23:00 AddAlarmDay() registration is removed. Disabling High School continues to remove the existing assignment alarm and perform the normal school cleanup. No replacement alarm is added. The system will not automatically assign any students to the KW High School during a game sessions lifetime (until game restart/load, aka KW initialization). Leaving the initial AssignStudents intact gives you a good base line to check for new eligible students each play session, without having to manually dig through demographics. You simply wait a bit after KW has initialized and then check the registered students at your school. Unassign any newly added ones you do not want. That's it. The other way around appeared to be less reliable. The change therefore affects only the recurring automatic assignment. 1. SchoolLocation.PostLoadFixup() Remove the nightly alarm registration In PostLoadFixup(), the EnableHighSchool block originally registered the recurring assignment alarm: if (Main.Settings.EnableHighSchool) { AlarmManager global = AlarmManager.Global; float hourOfDay = 23f; DaysOfTheWeek daysToTrigger = DaysOfTheWeek.All; AlarmTimerCallback func; if ((func = SchoolLocation.<>O.<0>__AssignStudents) == null) { func = (SchoolLocation.<>O.<0>__AssignStudents = new AlarmTimerCallback(SchoolLocation.AssignStudents)); } SchoolLocation.__alarmAssign = global.AddAlarmDay( hourOfDay, daysToTrigger, func, "SchoolLocationAssignStudents", AlarmType.NeverPersisted, null); } Remove that entire alarm-registration block, leaving the EnableHighSchool condition empty if no other code is added there: if (Main.Settings.EnableHighSchool) { } The important point is that this removes only the alarm registration. It does not remove AssignStudents() itself. 2. SchoolLocation.EnableHighSchool(bool enable) There is a second, independent registration of the same nightly alarm. This occurs after the immediate assignment: if (enable) { if (Main.Settings.EnableHighSchoolAutoManagement) SchoolLocation.StartTasks(); else SchoolLocation.StopTasks(); KWPromSituation.Startup(); SchoolLocation.AssignStudents(); SchoolLocation.__alarmAssign = AlarmManager.Global.AddAlarmDay( 23f, DaysOfTheWeek.All, SchoolLocation.<>O.<0>__AssignStudents ?? (SchoolLocation.<>O.<0>__AssignStudents = new AlarmTimerCallback(SchoolLocation.AssignStudents)), "SchoolLocationAssignStudents", AlarmType.NeverPersisted, null); } The AddAlarmDay() registration must be removed, but the preceding AssignStudents() call must remain. Result: if (enable) { if (Main.Settings.EnableHighSchoolAutoManagement) SchoolLocation.StartTasks(); else SchoolLocation.StopTasks(); KWPromSituation.Startup(); SchoolLocation.AssignStudents(); } The rest of the enable == false branch remains unchanged, including: AlarmManager.Global.RemoveAlarm(SchoolLocation.__alarmAssign); and the subsequent KW promotion shutdown and school clearing. Why both locations must be changed There are two independent registrations of SchoolLocation.AssignStudents() as a daily 23:00 alarm. Removing only the registration in PostLoadFixup() is insufficient because EnableHighSchool(true) independently creates the same alarm. Both alarms are declared non persistent, but are seemingly recreated independently on game load. The runtime test confirmed this distinction: Only removing the first alarm assignment resulted in students still being automatically added at 23:00 after load of a save game with High School already enabled, which made removal of the second instance necessary. After load of the save game the High School enable path still performed its immediate AssignStudents() call, as intended. Two students were subsequently manually removed from the student list. The two manually removed students were not reassigned at 23:00. Therefore the recurring nightly assignment has successfully been disabled while the immediate assignment behavior remains intact. I am currently working on turning the alarm creation into a togglable settings item. This remains a pretty bruteforce workaround for the time being. Edited 7 hours ago by Aouregan
Aouregan Posted 11 hours ago Author Posted 11 hours ago (edited) What bugs me a bit about this, is that this is a functionality I would expect from the setting called "High School auto management", but for some reason the daily automatic student assignment was deliberately excluded (or the auto management system is simply entirely broken/legacy code). But the auto student assignment clearly sits outside of the auto management state. Also teacher assignment still happens automatically, if the school has less than two. Both make no sense to me. Either I have the school auto managed or not. Story Progression might be a culprit here, since KW careers are actively registered with EA's own career system, which in return is used for story progression mechanics. I did not follow that path deep enough to come to a conclusion. I would have succumbed to a stroke before that. The one randomly showing up teacher can be easily dismissed from service. It doesn't bother me enough, unlike the issue with the entire teen population knocking at my door each morning did. Let me assign my students manually and stay the fuck out of it, KW XD Getting force-fed every teen in town each day was rather obnoxious. Especially, if you try to run a girls only school. Another question is why the alarm is created twice under nearly the same conditions. It looks like one of them was some legacy implementation that was never cleaned up. Both SchoolLocation.PostLoadFixup() and SchoolLocation.EnableHighSchool(bool enable) seem to be called when a saved game with enabled high school is loaded, resulting in a duplicate/overwritten alarm. It seems very redundant on first glance, albeit they technically make sense: You want one alarm to be created once the school is actually enabled, and one created after each KW init (game start). Somehow they both were created on KW init, however. Edited 8 hours ago by Aouregan
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now