TUTORIAL: Map Editor - How to set the Time of Day in Scenarios?

Modding, Map Editor, IES Scripting and Other Tutorials
Post Reply
User avatar
Dr.MonaLisa
High Representative
Posts: 8697
Joined: 17 Jun 2010, 11:21
Location: Poland
Has thanked: 49 times
Been thanked: 108 times

TUTORIAL: Map Editor - How to set the Time of Day in Scenarios?

Post by Dr.MonaLisa »

Since Unofficial Patch 1.5.8.002 (released in November 2020), it's possible to set the custom Time of Day in scenarios created in the Map Editor.

Usage:

To use it, please simply add one of the following suffixes at the end of your scenario filename:

ToD_Dawn.scn
ToD_Afternoon.scn
ToD_Sunset.scn
ToD_Night.scn
ToD_Cycle2.scn
ToD_Cycle5.scn
ToD_Cycle10.scn
ToD_Cycle15.scn

Example:

EE2_ScreenShot_2020-11-22_09.48.17.522.jpg
EE2_ScreenShot_2020-11-22_09.48.17.522.jpg (332.69 KiB) Viewed 2126 times

Problems:

This method does not work when you click "Test Mission" in the Map Editor. It's because it uses a file named "testMission.scn" and UP1.5 is unable to determine time settings from it. However, it works flawlessly when loading a scenario from the Menu:

EE2_ScreenShot_2020-11-22_09.50.47.095.jpg
EE2_ScreenShot_2020-11-22_09.50.47.095.jpg (228.42 KiB) Viewed 2126 times

Unfortunately, option "Random" is not supported, as it's generated at a totally different layer.

Other details:

This method uses several workarounds in game process (applied by assembly). The filename checking function is called in UP15_GameHelper.dll.
The "ToD_" suffix is case-insensitive, so technically it will also work with "tod_cycle15.scn" or "tod_CYCLE15.scn".
It looks nice when it's at the end of the file name, but it's not required. The scenario file name might as well be: "Death of Hitler ToD_Night 1945.scn".

Source code in UP15_GameHelper.dll:

Code: Select all

extern "C" void UP15_Fixes_Based_on_File_Name(int CallType, char* currentEAX) {
	//Setting up
	if(CallType == 0){
		if (currentEAX != NULL) {
			//Reset
			Set_Time_of_Day_from_File_Name_Now = false;
			Set_Time_of_Day_from_File_Name_Short = -1;

			std::string StringFromEax = currentEAX;
			if (StringFromEax.length() > 0) {
				std::string StringFromEaxLowerCase = BoostStringToLowerCase(StringFromEax);
				std::size_t TodDefined1 = StringFromEaxLowerCase.find("tod_");
				if (TodDefined1 != std::string::npos) {
					std::string TempStringAfterTod = StringFromEaxLowerCase.substr(TodDefined1 + 4);
					TodDefined1 = TempStringAfterTod.find(".");

					short SelectedTimeOfDayMode = -1;

					if (TodDefined1 != std::string::npos) {
						TempStringAfterTod = TempStringAfterTod.substr(0, TodDefined1);
					}
					if (TempStringAfterTod.find("dawn") != std::string::npos) {
						SelectedTimeOfDayMode = 0;
					}
					else if (TempStringAfterTod.find("afternoon") != std::string::npos) {
						SelectedTimeOfDayMode = 1;
					}
					else if (TempStringAfterTod.find("sunset") != std::string::npos) {
						SelectedTimeOfDayMode = 2;
					}
					else if (TempStringAfterTod.find("night") != std::string::npos) {
						SelectedTimeOfDayMode = 3;
					}
					else if (TempStringAfterTod.find("cycle2") != std::string::npos) {
						SelectedTimeOfDayMode = 4;
					}
					else if (TempStringAfterTod.find("cycle5") != std::string::npos) {
						SelectedTimeOfDayMode = 5;
					}
					else if (TempStringAfterTod.find("cycle10") != std::string::npos) {
						SelectedTimeOfDayMode = 6;
					}
					else if (TempStringAfterTod.find("cycle15") != std::string::npos) {
						SelectedTimeOfDayMode = 7;
					}

					if (SelectedTimeOfDayMode > -1) {
						Set_Time_of_Day_from_File_Name_Now = true;
						Set_Time_of_Day_from_File_Name_Short = SelectedTimeOfDayMode;
						//MessageBoxA(NULL, to_string(SelectedTimeOfDayMode).c_str(), "Selected Time of Day in File Name, ID:", MB_OK);
					}

				}

			}
		}
	}
	//This is right after time of day is set
	else if (CallType == 1) {
		//158002, tmp time of day fix:
		if (Set_Time_of_Day_from_File_Name_Now) {
			DWORD ReturnValue = -1;
			if (Current_Game_EE2_Zero_AOS_One == 1) {
				__asm
				{
					mov EAX, DWORD PTR DS : [0x0DA9A10] // setting EAX to 42 here
					CMP EAX, 0
					JE BadBadA1
					MOV EAX, DWORD PTR DS : [EAX + 28]
					MOV ReturnValue, EAX
					BadBadA1 :
				}
			}
			else {
				__asm
				{
					mov EAX, DWORD PTR DS : [0x0CF8568] // setting EAX to 42 here
					CMP EAX, 0
					JE BadBad1
					MOV EAX, DWORD PTR DS : [EAX + 28]
					MOV ReturnValue, EAX
					BadBad1 :
				}
			}

			//MessageBoxA(NULL, to_string(ReturnValue).c_str(), "Current Detected Time of Day:", MB_OK | MB_ICONINFORMATION);

				if (ReturnValue >= 0 && ReturnValue <= 7) {

					if (Current_Game_EE2_Zero_AOS_One == 1) {
						__asm
						{
							mov EAX, DWORD PTR DS : [0x0DA9A10] // setting EAX to 42 here
							CMP EAX, 0
							JE BadBadA2
							MOV CX, Set_Time_of_Day_from_File_Name_Short
							MOV WORD PTR DS : [EAX + 28] , CX
							BadBadA2 :
						}
					}
					else {
						__asm
						{
							mov EAX, DWORD PTR DS : [0x0CF8568] // setting EAX to 42 here
							CMP EAX, 0
							JE BadBad2
							MOV CX, Set_Time_of_Day_from_File_Name_Short
							MOV WORD PTR DS : [EAX + 28] , CX
							BadBad2 :
						}
					}

				}
			Set_Time_of_Day_from_File_Name_Now = false;
			Set_Time_of_Day_from_File_Name_Short = -1;
		}
	}
}
Contribution:

Special thanks to player "Sat42" for contribution in making this feature possible in such a short time.
Best regards,
Dr.MonaLisa
Ministry of Game Affairs
Department of Control and Complains
These users thanked the author Dr.MonaLisa for the post:
PaulStretch

Sat42
Posts: 129
Joined: 03 Dec 2018, 18:01
Has thanked: 6 times
Been thanked: 1 time

Re: TUTORIAL: Map Editor - How to set the Time of Day in Scenarios?

Post by Sat42 »

Awesome stuff! :D

P.S.: "How to eat a banana" should totally become an actual scenario! :P
User avatar
Dr.MonaLisa
High Representative
Posts: 8697
Joined: 17 Jun 2010, 11:21
Location: Poland
Has thanked: 49 times
Been thanked: 108 times

Re: TUTORIAL: Map Editor - How to set the Time of Day in Scenarios?

Post by Dr.MonaLisa »

Sat42 wrote: 23 Nov 2020, 10:12 Awesome stuff! :D

P.S.: "How to eat a banana" should totally become an actual scenario! :P
FYI I'm implementing the new "Unofficial Patch IES" system. It will generally be possible to control the time of day (the static as well as cycle) with the IES command in next versions of UP1.6. It's generally already working, so let me know if you would like to test it before the official release.

viewtopic.php?p=28164#p28164
Best regards,
Dr.MonaLisa
Ministry of Game Affairs
Department of Control and Complains
Sat42
Posts: 129
Joined: 03 Dec 2018, 18:01
Has thanked: 6 times
Been thanked: 1 time

Re: TUTORIAL: Map Editor - How to set the Time of Day in Scenarios?

Post by Sat42 »

Dr.MonaLisa wrote: 12 Mar 2024, 08:10
Sat42 wrote: 23 Nov 2020, 10:12 Awesome stuff! :D

P.S.: "How to eat a banana" should totally become an actual scenario! :P
FYI I'm implementing the new "Unofficial Patch IES" system. It will generally be possible to control the time of day (the static as well as cycle) with the IES command in next versions of UP1.6. It's generally already working, so let me know if you would like to test it before the official release.

viewtopic.php?p=28164#p28164
Thank you for the heads up Mona! This whole new "Unofficial Patch IES" sounds extremely interesting, and indeed can open up a whole new range of options for scenario design. Now, currently I am too busy to test this (what with lots of travelling) but, I will definitely look into it in due time (so by all means go ahead with the official release, as the period is not good for me).
There is 1 thing I can say for now in terms of a "bug" that I would like to see corrected if possible: the way we set the custom Time of Day in scenarios so far works both in Normal 1.5 (or 1.6 is it now? I need to update :P) and Developers version of course, and I aim for the Developers version primarily since the "full version" once ready will require modding (a "lighter" version will also be available for the Normal version). BUT, for the sky itself this is a different matter: setting the time of day only affects accordingly the sky in Normal 1.5 and not in the Devs version, meaning even if it's nighttime (the lighting on the map is nighttime), the Dev version shows a bright blue sky like noon. Would it be possible for you to look into correcting this? I hope it's not too complicated! (again, the sky changes depending on the time of day in the Normal version, it's just the Developers version which retains a noon sky regardless)

Cheers
User avatar
Dr.MonaLisa
High Representative
Posts: 8697
Joined: 17 Jun 2010, 11:21
Location: Poland
Has thanked: 49 times
Been thanked: 108 times

Re: TUTORIAL: Map Editor - How to set the Time of Day in Scenarios?

Post by Dr.MonaLisa »

Generally, the sky was always the same in all times of days in EE2. In the normal version of 1.6, I modded some of game files to use different cloud setts. For developers version I can't do this as it would overwrite some of the file(s) frequently modified by other mods. So the only solution is to modify the files that decide about the cloud sets yourself (I think it was something with "climate' in name), and put changes based on the normal version of 1.6.
Best regards,
Dr.MonaLisa
Ministry of Game Affairs
Department of Control and Complains
These users thanked the author Dr.MonaLisa for the post:
Sat42
Sat42
Posts: 129
Joined: 03 Dec 2018, 18:01
Has thanked: 6 times
Been thanked: 1 time

Re: TUTORIAL: Map Editor - How to set the Time of Day in Scenarios?

Post by Sat42 »

Thanks for the quick reply! OK so if I understand correctly, the game files that decide the cloud sets (with "climate" in the name) are typically also modified by other mods, hence I'd have to make the change myself as part of my "mod" for my scenario(s). Normal version 1.6 should help with making the relevant changes (essentially copying the code over). If you can give more pointers later I'd be grateful - but duly noted for now and I'll get back to you if necessary, of course.
P.S.: love that you're still maintaining this game after all these years!
User avatar
Dr.MonaLisa
High Representative
Posts: 8697
Joined: 17 Jun 2010, 11:21
Location: Poland
Has thanked: 49 times
Been thanked: 108 times

Re: TUTORIAL: Map Editor - How to set the Time of Day in Scenarios?

Post by Dr.MonaLisa »

Yes, exactly. You could import clouds from the other mods. The ones in UP1.6 use the textures that were available in game files already (except the Night that I changed myself because was unacceptable). The other mods, such as EE4 have a way better sky textures, so I would recommend importing from them. I planned to replace the current UP1.6 sky boxes to something self-made, but I never had time to focus on this idea. Maybe one day it will be just simpler to buy existing sky boxes textures, and make their format EE2 compatible.

For the files to modify, I'm sure it's something in zips/db.zip and has climate.csv or maybe climate name in filename. So as soon as you find these files, it's simple to understand where they put skyboxes texture names.
Best regards,
Dr.MonaLisa
Ministry of Game Affairs
Department of Control and Complains
Post Reply

Return to “Tutorials”