Auto Lights Mod

SCREENSHOTS
5,136 Downloads 221 Thanks  Thanks 44 Favourited 15,284 Views
Uploaded: 15th Apr 2020 at 11:39 PM
Updated: 19th Aug 2021 at 2:02 PM - UPDATE 12
UPDATE 12: This update fixes the issues that I described in the previous update. It turns out it is possible to fix the diagonal window problem, and now auto-lights will be able to recognize diagonal windows, so you can have a room with only diagonal windows without any issues. In addition, I got rid of my basement check and added a new check to see if there is at least one window facing outside in a particular room. This new check allows rooms which only have windows facing another interior room to be considered as having no windows by the light code.

UPDATE 11: Fixed yet another oversight with the basement check, it should work properly now. However, you should keep in mind that this check only works for conventional basements. If you heavily elevate the regular terrain and build a house on that terrain, and then build a basement, it is likely that the basement won't be at a low enough point compared to the road to be properly checked by the mod. In such basements, I recommend not using any windows. There is also something you should know about windows in the Sims 2. Diagonal windows can only exist in one room, as opposed to straight windows having a tile on both sides. This is why rooms which only have diagonal windows are considered to have no windows by the game during gameplay checks. There is no way around this, so you may want to add at least one straight window to such rooms.

UPDATE 10: Fixed a small oversight from the previous update.

UPDATE 9: I have found a way to check if an object is in a basement, so this update makes basement lights always work as if it is night-time, and in the Advanced Version, basement lights won't consider windows.

UPDATE 8: The game now also checks to see if the TV is in the same room as the lamp, as part of the feature added to the Advanced Version in the previous update.

UPDATE 7: Lights in the Advanced Version will now work as if it is night-time if the sky clarity is cloudy during daytime. If you are playing with Maxis' default lighting, it may be a bit difficult to realize that the sky is cloudy, as the effect is a bit subtle. But, if you have lighting mods, then it gets visibly darker when the sky gets cloudy. In addition, in the Advanced Version, sims will not cause lights to turn on if their current interaction happens to be watching a TV and if the TV in question is showing a Freetime movie and there is at least one sim who is currently watching the TV. Finally, I have made it so that toddlers and babies will only be skipped if they are in a crib or Baby Dangle Master (Store item), so they won't be skipped any more if they are being held by a sim.

UPDATE 6: Lights in the Advanced Version will no longer consider sims who are currently routing to nap on a recliner/lounger. In addition, I realized that the Sleep interaction entry is a different number on single beds as opposed to double beds, which is why sims who were routing to sleep in a single bed still caused lights to turn on. This has also been fixed.

UPDATE 5: Magical assistants, the therapist and social bunny won't cause lights to turn on. I also added an extra check to the Advanced Version to see if the sim is currently routing.

UPDATE 4:
- There is now an Advanced Version of this mod. Scroll down to read the description for that version.
- Pool lights will now only be on from 18 to 6 just like outdoor lights. I forgot to enable this feature in the previous update.
- I found out that there is a Maxis feature which is supposed to tell a lamp to turn on/off whenever a sim enters/exits a room. This feature seems to be used only when there are sleeping sims in a room and an awake sim enters the room, so that the game immediately turns on the lights. This feature does not work well with this mod or any other mod that makes it so that lamps turn on/off at all times dependent on the sims inside the same room as the lamp, rather than daytime/nighttime checks. It can cause turned-on lights to turn off right when the sim is about to enter the room, for example, because the way the game handles this feature is through a message that is sent right before the sim enters the room, rather than after. Not only that, this feature has the potential to sometimes mess up the lighting of the lamp, causing lighting issues even in an unmodded game. This update disables this feature, because it is completely unnecessary, as the game constantly checks to see if there are sims in the room who should cause lights to turn on anyway.

UPDATE 3: The mod is now compatible with my new Utility Mod. Pool lights will now only be on from 18 to 6 just like outdoor lights.

UPDATE 2:
- If there is a party on the lot, then indoor lights will be on except if all the sims within the room are asleep.
- Whenever a light is supposed to turn off, the game will wait exactly 15 sim-minutes before turning off the light. This prevents lights from constantly turning on and off, especially if there are many people on the lot.

UPDATE 1: The mod now considers the presence of babies, toddlers, active werewolves and Servos.

ORIGINAL DESCRIPTION

I don't like the way automatic lights work in the Sims 2. This mod changes the rules the game uses to determine if a light which has been set to automatic (which is the default setting) should be on or off. Before I tell you what this mod changes, you should know how the unmodded game works:
- Outdoor lights are always on from 18 to 2.
- Indoor lights are always on at night unless all the sims in the same room are asleep.

That's basically it, and because the game has so few checks, there are many oversights in the auto-light code. When this mod checks to see if there are any awake sims in a particular room to determine whether the light should be on or off, the mod skips certain kinds of sims which I think should not cause lights to turn on. These kinds of sims are burglars who are on the job, pets, babies, toddlers, zombies, active werewolves, bigfoot and ungreeted visitors. Also, I found out that certain moving objects are considered as human NPCs by the game for as long as they are moving, and the unmodded light code considers these objects as awake sims which in turn cause lights to turn on. These are cage birds which are currently flying, remote-control cars/helicopters which are moving and so on. This mod makes it so that these objects won't affect lights in any way. In addition, when the game pushes two sims to spoon each other in bed, the game temporarily wakes the sims up for a few seconds which causes the lights to turn on, and this mod fixes this and makes the code skip spooning sims.

Here are the new rules added by the mod:
- Outdoor lights are always on from 18 to 6.
- Pool lights are always on.
- Indoor lights are always on even during the day on community lots, secret society lots, and secret hobby lots.
- On all other lots, indoor lights in a particular room will be on during the day only if there are no windows in the room, and there is at least one eligible, awake sim in the same room. If the lot has a currently open home business, then lights will always be on in such rooms except if there are sleeping sims and no eligible, awake sims in the room.
- On all other lots, indoor lights in a particular room will be on during the night only if there is at least one, awake sim in the same room. If the lot has a currently open home business, then lights will always be on in such rooms except if there are sleeping sims and no eligible, awake sims in the room.

Advanced Version: I've made this version for my personal use, but I decided to release it, because some players may like the extra additions of this version. The Advanced Version has a few additional rules to determine how lights act:
- Babies and toddlers who are in a crib or who are currently being held by a sim, and babies in the Baby Dangle Master (Store item) are now skipped, so they won't cause lights to turn on.
- When a sim is routing towards a bed or sofa to sleep, all lights will skip the sim, except those lights that are in a room with no windows. Communal areas in an apartment and non-liveable lots always consider all sims.
- When a sim is routing outside or if they are routing towards a vehicle, only those lights which are in the same room as the object that the sim is routing towards will consider the sim's presence, because the sim will be leaving the house. Lights which are in a room with no windows will still consider the sim's presence. Communal areas in an apartment and non-liveable lots always consider all sims.
- When a sim is routing towards an object that is inside, lights which are in the same room as the object will consider the sim's presence normally. Other lights will only consider the sim's presence if they are in a room with no windows, or if they are in a room with more than 20 tiles. Communal areas in an apartment and non-liveable lots always consider all sims.

You need the latest version of 7zip or WinRAR to get this mod.

Requirements: Apartment Life and/or M&G.

Resources:
Function - Main/0x7F60C397/0x00002007
Lamp - Global Tuning/0x7F60C397/0x00002002