04:54:51 31 May 2012 |
|
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 |
|
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? |
02:05:34 8 June 2012 |
|
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 |
|
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 |
|
NatVac
Senior Resident
On forum: 06/15/2007
Messages: 4286
|
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 |
|
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 |
|
NatVac
Senior Resident
On forum: 06/15/2007
Messages: 4286
|
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. |
|