Skip to content

Posts from Day and night cycle.

No ratings yet — be the first to rate!
User Avatar
Auto-translated
I remember in the last mission for Arantir, when he was passing through a garrison, the lighting on the map changed, or the file responsible for it was replaced with another. Could we do the same, but when a new day begins? For example, after some turns, both the player and the AI have had their turns, and then a new day begins, and the lighting changes to nighttime, and so on for each new "day-night" and "day-day" cycle.
User Avatar
Auto-translated
footman
I remember in the last mission for Arantir, when he was passing through a garrison, the lighting on the map changed, or the file responsible for it was replaced with another. Could we do the same, but when a new day arrives? For example, I move, the AI moves, a new day arrives, and the lighting changes to night, and so on for each new "day-night" and "day-day" cycle.

Yes, yes, this is changed with scripts... in the maps of respected comrades Dyrman, RedHeavenHero, Ment, or other mapmakers - I seem to remember something like that... the lighting changed from day to night! :smile04:
С уважением, Psatkha (Псатха)

---------------------------------------------

Неудачное планирование ведёт к неудаче ...

NCF - мод, добавляющий дополнительных существ в HeroesV 3.1
User Avatar
Auto-translated
Yes, this is done through a new day trigger, which is automatically called at the beginning of each turn, except for the first one. Regarding lighting specifically: first, all lighting resources that will be used in the map must be added to it in these tabs -

Next, each lighting element needs to have a script name added to its settings (it should be in one of them, but I don't remember exactly, so I'm writing it in both). -

And then you need to write a script using the SetAmbientLight() function. It has 4 parameters:
-script name of the lighting
-level at which the lighting changes (GROUND/UNDERGROUND)
-use a delay when changing the lighting (nil - no, 1 - yes)
-delay duration in seconds

In the end, if, for example, your goal is to change the lighting every day, the code will be approximately like this (using a 5-second change as an example):
curr_light = 'day'

function NewDay()
if curr_light == 'day' then
SetAmbientLight('night_lighting_name', GROUND, 1, 5.0)
curr_light = 'night'
else
SetAmbientLight('day_lighting_name', GROUND, 1, 5.0)
curr_light = 'day'
end
end

Trigger(NEW_DAY_TRIGGER, 'NewDay')
Нет войне.
User Avatar
Auto-translated
I created a random map to test it out; there's an error in the command line.
User Avatar
Auto-translated
yeah, I wrote something silly, first the map level, then the lighting name is specified.
SetAmbientLight(GROUND, 'night_lighting_name', 1, 5.0) and so on.
Нет войне.
User Avatar
Auto-translated
It worked, thank you.
User Avatar
Auto-translated
Hi Gerter! I've also been testing the lighting changes and exploring the scenarios in your map, but it's not working! I want to create something very simple so that each day of the week has different lighting. Testing a single-day change would be sufficient... I think this code is the most correct (I've tried a thousand possible changes). Greetings!
Trigger(NEW_DAY_TRIGGER, 'Days')

function Days()
local Day_W = GetDate(DAY_OF_WEEK)
if Day_W == 1 then
SetAmbientLight(GROUND, 'PreLight', not nil, 1);
end
end
User Avatar
Excuse me, but does ambient light in MapPropertiesTree=>Resurces=>Ground/UnderGroundAmbientLights have such in;ternale name? As function SetAmbientLight(GROUND, "Name", not nil, 1) works correctly itself... Also, 1st day of week is Tuesday (and 0 - Monday). Have you checked only for the first day?
С уважением, }{0TT@6bI4
_________________
Группа картостроителей
Там ответы на вопросы, руководства, гайды и прочее
Discord-сервер "Герои 5: S.T.A.L.K.E.R"
Сервер по модификации "Герои 5: S.T.A.L.K.E.R"
_________________
User Avatar
yes, I added the light in the MapPropertiesTree, it is an existing light in the game, not created by me. and I have tried with 0,1,2 .... nothing.
In reply to xuxo
User Avatar
xuxo
yes, I added the light in the MapPropertiesTree, it is an existing light in the game, not created by me. and I have tried with 0,1,2 .... nothing.

Gm... Ok, to add light it's needed:
Go to Map Properties Tree => Ground/Underground Ambient Lights => Add element with Internal Name in properties.
Than write in script SetAmbientLight(floor, name, fade, time).

Could you try to write only string with SetAmbLight function in console and tell results?
С уважением, }{0TT@6bI4
_________________
Группа картостроителей
Там ответы на вопросы, руководства, гайды и прочее
Discord-сервер "Герои 5: S.T.A.L.K.E.R"
Сервер по модификации "Герои 5: S.T.A.L.K.E.R"
_________________
User Avatar
solved! I'm useless! I hadn't understood the "internal name" thing, I was using the filename haha. Thank you very much, also to Footman, he helped me for discord !!
Auto-translated
Since the topic is relatively new, I wanted to ask – is there a mod that dynamically changes the lighting, just like in the third mission for the Necromancer in Tribes of the East? I really liked how the day gradually turned into night.
User Avatar
Auto-translated
The lighting changes via scripts. This means a mod is needed that will specify in some advmap-startup.lua file the execution of our script, which is subordinate to it, to change the time of day.
However, this will only work on maps that specify MapScript.lua (otherwise, the advmap-startup.lua files themselves will not run), which means it won't work on generated maps. Or, a map handler is needed that adds an empty MapScript to them.

In general, there is no such mod (yet), correct me if I'm wrong.
С уважением, }{0TT@6bI4
_________________
Группа картостроителей
Там ответы на вопросы, руководства, гайды и прочее
Discord-сервер "Герои 5: S.T.A.L.K.E.R"
Сервер по модификации "Герои 5: S.T.A.L.K.E.R"
_________________

Statistics

Welcome our newest member: Emil