ProjectsWhat's NewDownloadsCommunitySupportCompany
Forum Index » S.T.A.L.K.E.R.: Shadow of Chernobyl Forum » Mod discussion
How to tell if it is raining

1 2 3
Posted by/on
Question/AnswerMake Newest Up Sort by Descending
  00:38:30  24 May 2012
profilee-mailreply Message URLTo the Top
Daemonion
All About Audio
(Resident)

 

 
On forum: 09/27/2011
Messages: 567
How to tell if it is raining

For those who have been following my space restrictor thread, you know that I've used {=is_day} to trigger specific sounds in my restrictors.

Is there anything similar for rain? How can I ask the game if it is raining or not? My hope would be to trigger different audio when in a restrictor based on whether or not it is raining.


Thanks!
  02:28:07  24 May 2012
profilee-mailreply Message URLTo the Top
insanelazarez
Yeah, Good Luck With That...
(Resident)

 

 
On forum: 01/31/2009
Messages: 1070

---QUOTATION---
How to tell if it is raining

For those who have been following my space restrictor thread, you know that I've used {=is_day} to trigger specific sounds in my restrictors.

Is there anything similar for rain? How can I ask the game if it is raining or not? My hope would be to trigger different audio when in a restrictor based on whether or not it is raining.


Thanks!
---END QUOTATION---



Daemonion, instead of asking if it's raining... tell the game it's raining.
Create a weather file, with a 'default weather' structure and add the rain for the whole day. And use your space restrictor to call the new weather file.

Function in xr_effects


---QUOTATION---


function change_weather_now (actor, npc, p)
if p[1] then
level.set_weather (p[1])
end
end


---END QUOTATION---



Example in you space restrictor:


---QUOTATION---


[logic]
active = sr_idle@if_day_rain_otherwise_not_rain

[sr_idle@if_day_rain_otherwise_not_rain]
on_info = {=is_day} sr_idle@day_rain
on_info2 = {!is_day} sr_idle@night_not_rain

[sr_idle@day_rain]
on_timer = 3333 | sr_idle@whatever %=change_weather_now(name_of_weather_raining)%

[sr_idle@night_not_rain]
on_timer = 3333 | sr_idle@whatever %=change_weather_now(default)%

[sr_idle@whatever]
on_timer = 3333 | sr_idle@if_day_rain_otherwise_not_rain


---END QUOTATION---



But if you save the game and reload... the game needs time to call the new section like 6 seconds or something.

You dont need to check if is day. Call a info for example, right?

It was just an idea. The limitations are obvious. But the function works, cause i'm using it.

Something like this:


---QUOTATION---


%=change_weather_now(yantar)%


---END QUOTATION---



And voila... yantar weather. But again... if you save/reload... the new weather is gone. Because the game restores the normal weather section for that specific map.

We could add a function in bind stalker. But the result would be bad cause of the lag. Imagine the game checking/and changing the weather every 5 milisecs... lol. What a mess.

Well, a good scripter can use the bind stalker approach... i don't know... some timer right? But in this case you dont need space restrictors, right?
  03:32:25  24 May 2012
profilee-mailreply Message URLTo the Top
Daemonion
All About Audio
(Resident)

 

 
On forum: 09/27/2011
Messages: 567

---QUOTATION---
Daemonion, instead of asking if it's raining... tell the game it's raining.
---END QUOTATION---



lol, that sounds like something Morpheus would say

Well, I don't want to make it rain, actually.

It ties into what I was doing earlier with the space restrictors. Player walks into a house, and an "interior ambient" sound plays. Same idea, except, now, I was wondering if I could have two different "interior ambient" sounds - one for when it is raining, and one for when it is not raining.

Actor walks into space restrictor (say, some_house_in_cordon).
it is raining, so play interior_ambient_rain.ogg
or
it is not raining, so play interior_ambient_no_rain.ogg


Like that.
  11:33:08  24 May 2012
profilee-mailreply Message URLTo the Top
Meltac
messing with code
(Resident)

 

 
On forum: 01/21/2010
Messages: 1519
Cool idea you're having

I don't have any experience with space restrictors or other all.spawn related stuff because I consider it work of the devil

Just kidding. You can request whether it's raining and also how intensely by script. However I don't know of a simple function. What I did for my dynamic wet surfaces is parse the current weather to get the rain_density value. If you like I could send you an excerpt of my script (don't wanna make it public yet because it's not finished).
  11:47:00  24 May 2012
profilee-mailreply Message URLTo the Top
Daemonion
All About Audio
(Resident)

 

 
On forum: 09/27/2011
Messages: 567

---QUOTATION---
Cool idea you're having

I don't have any experience with space restrictors or other all.spawn related stuff because I consider it work of the devil

Just kidding. You can request whether it's raining and also how intensely by script. However I don't know of a simple function. What I did for my dynamic wet surfaces is parse the current weather to get the rain_density value. If you like I could send you an excerpt of my script (don't wanna make it public yet because it's not finished).
---END QUOTATION---


That would be great, please do!
  14:39:33  24 May 2012
profilee-mailreply Message URLTo the Top
{imperialreign}
Звуковой Шаман
(Resident)

 

 
On forum: 10/29/2008
Messages: 3075
Aside from earlier ideas . . . only thing I could think of is a little hack & slash . . .

That is, go through the weather config(s) and determine which weather hours are considered "rain" - then write a function that uses a shit-load of conditionals to check if it's a raining weather hour or not, based on the current weather config . . . from there, it could give or take a new i_p . . . which in turn you could use to change the sound being played in the logic controls . . . it's a little brute force, though, lol

If you're using nandersen's dynamic weather engine, it might be easier to create a new function within the control script that monitors the current weather config, and current game hour for the info portion.

I'm not 100% sure if there's a way to actually parse specific parameters of the current weather hour while the game is running, to look for specific values (i.e. if rain_density != 0). Especially considering that the weather config values are constantly changing between weather hours . . . You might want to consider searching key terms in the lua_help.txt to see if you turn up anything intersting.

BTW - I got your email, just haven't had a chance to get around to looking things over yet, I've been rather busy recently, lol
  15:22:15  24 May 2012
profilee-mailreply Message URLTo the Top
Meltac
messing with code
(Resident)

 

 
On forum: 01/21/2010
Messages: 1519

---QUOTATION---
I'm not 100% sure if there's a way to actually parse specific parameters of the current weather hour while the game is running, to look for specific values (i.e. if rain_density != 0). Especially considering that the weather config values are constantly changing between weather hours
---END QUOTATION---



It is possible to do that - as mentioned above I have written a script doing so.
  17:43:37  28 May 2012
profilee-mailreply Message URLTo the Top
FatalFunnel
(Senior)
 
On forum: 11/07/2011
Messages: 133
You know, it would be cool if we could come up with a system that has weather directly affect the actor, stuff like simulated temperature, and having individual suits tied into it. Things like some suits having waterproof properties, and having rain affect them less in a negative way, or some things being more insulated.

Basically I'm thinking of a system that adds simulated cold, something that makes weather more than just aesthetic.
  18:35:12  28 May 2012
profilee-mailreply Message URLTo the Top
Cromm Cruac
Сделано в Чернобыле
(Resident)

 

 
On forum: 11/19/2009
Messages: 1143
Can't you just use level.rain_factor() function?
It returns the current strength of rain in 0 to 1 value. You can even differentiate the sounds if it is heavy rain or the light one.
  20:22:40  28 May 2012
profilee-mailreply Message URLTo the Top
Daemonion
All About Audio
(Resident)

 

 
On forum: 09/27/2011
Messages: 567

---QUOTATION---
Can't you just use level.rain_factor() function?
It returns the current strength of rain in 0 to 1 value. You can even differentiate the sounds if it is heavy rain or the light one.
---END QUOTATION---


Hm, sounds interesting.

Can you tell me more about this?
  21:36:42  28 May 2012
profilee-mailreply Message URLTo the Top
Cromm Cruac
Сделано в Чернобыле
(Resident)

 

 
On forum: 11/19/2009
 

Message edited by:
Cromm Cruac
05/28/2012 21:41:52
Messages: 1143
There is nothing more to tell. It's pretty straight forward. This engine function tells if it currently rains and how hard. It returns 0 if it doesn't, 1 if it is full rain (as defined in weather config).

How it works? Let's say we have clear sky (no rain - rain_density= 0) defined at 10 o'clock and storm with full rain (rain_density=1) at 11 o'clock.
At 10:15 function will return 0.25, at 10:30 0.5 etc. No need to do other checks.

You could do smth like that:

If (actor indoor) then
  if (rain_factor()=0) then
   stop rain sound
  else if (rain_factor()>0 and rain_factor()<0.5) then
    play inside light rain sound
  else if (rain_factor()>=0.5 and rain_factor()<=1) then
    play inside pouring rain sound
  end
else 
  if (rain_factor()=0) then
   stop rain sound
  else if (rain_factor()>0 and rain_factor()<0.5) then
    play outside light rain sound
  else if (rain_factor()>=0.5 and rain_factor()<=1) then
    play outside pouring rain sound
  end
end


That's not an actual script just something like an algorythm.
  22:07:41  28 May 2012
profilee-mailreply Message URLTo the Top
Meltac
messing with code
(Resident)

 

 
On forum: 01/21/2010
Messages: 1519

---QUOTATION---
Can't you just use level.rain_factor() function?
It returns the current strength of rain in 0 to 1 value. You can even differentiate the sounds if it is heavy rain or the light one.
---END QUOTATION---



You've just made me become aware that I have wasted lots of hours of lifetime spending to implement a script function that obviously already existed

Never start coding without having checked lua_help!!!
  04:54:51  31 May 2012
profilee-mailreply Message URLTo the Top
Daemonion
All About Audio
(Resident)

 

 
On forum: 09/27/2011
 

Message edited by:
Daemonion
05/31/2012 4:59:22
Messages: 567
Thanks for the response, Cromm.

As you might be aware, I will be using this with my space restrictor ambient white noise stuff. A vid of that is here:
[link]https://www.youtube.com/watch?v=cob5Q4gtkYc[/link]

Here is the basic code used in each restrictor to make that work:
[link]http://pastebin.com/L6rrTRGL[/link]

As you'll see in that example, it is calling up the sr_sound_act@underground, which is used for being inside areas that are underground. If it was in, say, a house, it'd be sr_sound_act@indoors. This is shown working in the video.

The whole point of this thread is to help me figure out a way to change those sounds based on whether or not it is raining. If it is raining outside, I don't want the player to hear the regular "I'm outside and it is sunny and happy outside" audio. Likewise, when they are inside a particular restrictor, I want them to hear the rain hitting the roof and what not.


So, with that all in mind, the plan would be to create a function which pulls from level.rain_factor() function to enable an infoportion during rainy weather, and to disable it during non-rainy weather. We'll call this infoportion %its_raining_motherfucker%.
In otherwords, the function enables %its_raining_motherfucker% when rain_density=> 0, and disables %its_raining_motherfucker% when rain_density= 0.

The new space restrictor code would need to look something like this:
[link]http://pastebin.com/sSz2Mhy5[/link]


How does that look, gentlemen? Do-able? The big question is whether or not a function can enable an infoportion. Will that work?
  20:16:21  7 June 2012
profilee-mailreply Message URLTo the Top
Daemonion
All About Audio
(Resident)

 

 
On forum: 09/27/2011
 

Message edited by:
Daemonion
06/07/2012 21:00:18
Messages: 567
Ok, I just wrote this. How does it look?
function indoor_rain_check()
	if level.rain_factor() > .07 then
		db.actor:give_info_portion("its_raining")
	else
		db.actor:disable_info_portion("its_raining")
end


or [link]http://pastebin.com/u7GT0wM9[/link]


Where can I put this to make sure it is running at all times? Otherwise my space restrictor code won't work:
[link]http://pastebin.com/edit.php?i=sSz2Mhy5[/link]

Also, are there any console commands to make the game rain?
  22:20:41  7 June 2012
profilee-mailreply Message URLTo the Top
Meltac
messing with code
(Resident)

 

 
On forum: 01/21/2010
Messages: 1519

---QUOTATION---
Also, are there any console commands to make the game rain?
---END QUOTATION---



No - if there were such, then you wouldn't have needed that rain_factor function 'cause you just could query the respective console entry.

When it rains depends on current weather config and time. So best IMHO would be you install LUA console where you can either speed up the time until it rains (by entering level.set_time_factor(1000)) or set some other weather config (with level.set_weather(weathername)).
  02:05:34  8 June 2012
profilee-mailreply Message URLTo the Top
Daemonion
All About Audio
(Resident)

 

 
On forum: 09/27/2011
Messages: 567
I just set the rain density to 1.0 for ever hour of the day so there is perpetual rain. Actually, Holden did it because I am lazy sometimes.

About that function, though. If I put it in xr_effects will it be running constantly? Or do I need to put it at the beginning of my space restrictor code?

Maybe something like

[logic]
active = sr_idle

[sr_idle]
%indoor_rain_check_function%
blah blah all my other stuff
  03:04:28  8 June 2012
profilee-mailreply Message URLTo the Top
Daemonion
All About Audio
(Resident)

 

 
On forum: 09/27/2011
 

Message edited by:
Daemonion
06/08/2012 3:07:51
Messages: 567
Got it working.

I just added these lines in sound_theme.script:
function weather_class(avail_types, npc)
	local type = "weather_good"
	if level.rain_factor() < 0.07 then
		type = "weather_good"
		db.actor:disable_info_portion("its_raining") -- added by Daemonion for LURK 1.2
	else
		type = "weather_bad"
		db.actor:give_info_portion("its_raining") -- added by Daemonion for LURK 1.2
	end
	return type
end


...and used my new space restrictor logic.
  17:56:29  13 June 2012
profilee-mailreply Message URLTo the Top
NatVac
Senior Resident
 

 
On forum: 06/15/2007
Messages: 4287
Just a heads-up, Daemonion: That weather_class() function is called to determine what remarks about the weather an NPC can make. If you are in an area with no online NPCs, the function won't be called.

You might want to put it in bind_stalker.script's update() loop, preferably in the part that only executes a few times a second.
  23:50:07  13 June 2012
profilee-mailreply Message URLTo the Top
Daemonion
All About Audio
(Resident)

 

 
On forum: 09/27/2011
Messages: 567

---QUOTATION---
Just a heads-up, Daemonion: That weather_class() function is called to determine what remarks about the weather an NPC can make. If you are in an area with no online NPCs, the function won't be called.

You might want to put it in bind_stalker.script's update() loop, preferably in the part that only executes a few times a second.
---END QUOTATION---


Oh, interesting. Thanks, NatVac! You are a gentlmen, a scholar, and probably quite handsome.
  16:05:10  17 June 2012
profilee-mailreply Message URLTo the Top
NatVac
Senior Resident
 

 
On forum: 06/15/2007
Messages: 4287
I was thinking that you might not even need to use an info_portion, Daemonion. Info_portions are nice because they are flags that survive save/reloads and level transitions, but they can be a bit "heavy". Your update() code can set a global boolean variable like is_raining, and that can be checked directly. Or the {+its_raining} could be replaced by {=is_raining} where is_raining() is an xr_conditions.script helper function that simply returns level.rain_factor() > 0.07.

While looking in xr_sound.script to check a hypothesis -- that the game's weather processing is occurring before the sound stuff, which might be executing a function like xr_sound.stop_all_sound_object() -- I checked on the lua_help.script sound stuff for sound_object. This class has a volume property. Object instances of this class are returned by xr_sound.get_safe_sound_object(path). If that property is a true property (that is, you can both get and set the volume), then you might have a way to control the fade on sounds.
  09:36:28  23 June 2012
profilee-mailreply Message URLTo the Top
Daemonion
All About Audio
(Resident)

 

 
On forum: 09/27/2011
Messages: 567

---QUOTATION---
I was thinking that you might not even need to use an info_portion, Daemonion. Info_portions are nice because they are flags that survive save/reloads and level transitions, but they can be a bit "heavy". Your update() code can set a global boolean variable like is_raining, and that can be checked directly. Or the {+its_raining} could be replaced by {=is_raining} where is_raining() is an xr_conditions.script helper function that simply returns level.rain_factor() > 0.07.

While looking in xr_sound.script to check a hypothesis -- that the game's weather processing is occurring before the sound stuff, which might be executing a function like xr_sound.stop_all_sound_object() -- I checked on the lua_help.script sound stuff for sound_object. This class has a volume property. Object instances of this class are returned by xr_sound.get_safe_sound_object(path). If that property is a true property (that is, you can both get and set the volume), then you might have a way to control the fade on sounds.
---END QUOTATION---


How did you know that class has a volume property?
  13:40:24  23 June 2012
profilee-mailreply Message URLTo the Top
mnn
Senior Resident
 

 
On forum: 06/12/2009
Messages: 2694
Daemonion: Hmm, he checked lua_help.script?
 
Each word should be at least 3 characters long.
Search:    
Search conditions:    - spaces as AND    - spaces as OR   
 
Forum Index » S.T.A.L.K.E.R.: Shadow of Chernobyl Forum » Mod discussion
 

All short dates are in Month-Day-Year format.


 

Copyright © 1995-2021 GSC Game World. All rights reserved.
This site is best viewed in Internet Explorer 4.xx and up and Javascript enabled. Webmaster.
Opera Software products are not supported.
If any problem concerning the site functioning under Opera Software appears apply
to Opera Software technical support service.