Project Zomboid

Project Zomboid

Working Air Conditioners
Slayer  [developer] 13 Nov, 2023 @ 7:09am
Cooling
Cooling option will not be available in multiplayer. I tried, but it is impossible. If you are a modder and are interested in the details here is what I can read from the decompiled java code

There is a function in that calculates a temperature for a given square on the map. That function takes into account many variables, for example global temperature, sunlight depending on the season, indoors/outdoors, also if that square is a ground floor or not. It was kinda interesting how many small details game developers took into account, really nice work. After calculation, there is check if there is an extra source of heat. If that heat is greater than the previously calculated temperature, it becomes the actual temperature for the square. So if the heat source value is smaller than the normal temperature for the square, it is discarded. That is why cooling never works. The exception is when player is in a vehicle, then temperature is taken from the passenger compartment and has nothing to do with anything else. I tried creating a virtual vehicle that player would be in all the time, but it doesn't work, player freezes in car seating position without a car :) So the only option was to manipulate the global temperature for the world. In single player, when player is inside a room and a heat source is detected, I lower the global temperature of the whole world so it matches the ac setting. Since it is a single player game, there is no way other players standing outside would report the kinda cheat that I'm doing. But there is a risk that something may break, for example there are mods that would kill your harvest when temperature is too low, but that is below 5C, so 10C+ should be ok. In multiplier only server can control climate, that means I can change temperature locally for a player temperature, but it will be overwritten by the server synchronization packet every 10 game minutes.
< >
Showing 1-4 of 4 comments
Thank you for the details and your hard work! This mod is great and I can tell you put a lot of effort into it, so I'd like to see it work fully and help if I can. This is one of those cases where overriding the vanilla functions makes sense. We can add an additional check to the climate system to see if the additional heat source is negative (thanks to AC unit) and if it is, override the tile temperature. I'll throw it together sometime today probably.
Wow you were definitely right. I see only one viable option to getting it working on in multiplayer, which is a pretty significant trade-off but it would work.

Primarily, we can recompile the zombie.iso.weather.ClimateManager class for the SERVER and optionally change the frequency of the climate packets. This way players wouldn't be required to replace a .class file to even join the server. But this would make digital watches go insane though so either they would need to be removed (functionally replaced with standard watches), or alternatively their display can be modified to work correctly with the aircon mod. Same goes for body temp and temp moodlets.

Its also MAYBE possible that we can use the `OnClimateTick` event to override the watch temperature without having to do anything hacky. Just depends on the UI rendering

How does that sound to you? I'm happy to work on it
Last edited by Maeve 牛子精灵; 22 Nov, 2023 @ 5:50pm
Slayer  [developer] 23 Nov, 2023 @ 5:50am 
Hey. Thanks for helping and appreciation.

It's tricky because we dont want for example a fireplace with heat of 30 degrees work as a cooler when it's 40 inside. Some heatsources should heat only, not cool.

Introducing negative heatsources would generate negative temperature with current implementation. This is not the solution either.

The solution would be maybe to introduce extra parameter for heatsources that would allow lowering the temperatures. Fireplaces would have that flag false, by default. For AC i could set if true. The flag would simply bypass the if statement at the end of the function (just before the check if player is in vehicle).

Or you can make an explicit mode cooling or heating. If heating, lower heatsources than temperature are ignored, just like it is now. If cooling, higher heatsource temperatures than temperature are ignored.
Last edited by Slayer; 23 Nov, 2023 @ 10:33am
Slayer  [developer] 23 Nov, 2023 @ 5:57am 
Also I love this game and my work is super fun.
< >
Showing 1-4 of 4 comments
Per page: 1530 50