ProjectsWhat's NewDownloadsCommunitySupportCompany
Forum Index » S.T.A.L.K.E.R.: Shadow of Chernobyl Forum » Mod discussion
Resetting the rain sound thru a script? (NatVac, bro, help!)

1 2 3
Posted by/on
Question/AnswerMake Newest Up Sort by Descending
  03:45:45  12 June 2012
profilee-mailreply Message URLTo the Top
Kocayine
Senior Resident
 

 
On forum: 07/15/2010
Messages: 918
Resetting the rain sound thru a script? (NatVac, bro, help!)

As we all know, there's a bug in stalker that causes the rain sound to disappear whenever you switch level. A fix is to save and reload the save, but to my experience that doesn't always work (Hardly ever, tbh). That is why I was wondering whether there was some sort of script I can add to the main menu and trigger via a binded key, that would somehow 'restart' whatever it is that does the rain sound. Just wondering if that is possible, as it would be sweet... The sad alternative would almost be to mute the rain sound and use an empty fx_rain.dds texture, which would suck .

Any help appreciate!
Thanks,
  18:51:32  13 June 2012
profilee-mailreply Message URLTo the Top
NatVac
Senior Resident
 

 
On forum: 06/15/2007
 

Message edited by:
NatVac
06/14/2012 3:00:29
Messages: 4302
Are you bucking for the "We now both rest in peace" secret, Kocayine? I had composed a few replies that will be posted later today in the ZRP thread, hopefully, including most of the following answer to your ZRP version of this question. Meanwhile here's some good news/bad news:

I have an active workaround I've been testing that uses the ZRP's _dev.queue_delayed_event() (in 1.07 R3) called from _z.on_first_update() (new), which was called from bind_stalker.script. Although a hack it acts like a fix, correcting the weather each time you load a save or change levels. I'm not yet sure how it will behave around weather transitions.

It gets the weather via level.get_weather(), saves that in a local variable, then it resets the weather to "test". (The "pripyat" weather has worked also and would probably be better for your situation as you'll see.) Then I queue up a set_weather() call with a delay of 10 ms. to allow the engine to breathe and let all the weather changes propagate. After a bit the weather is reset.

The good news is that the ZRP player won't notice anything. The bad news is you will need to find out how to queue up a timer event to get this to work for you, or you will have to execute two script commands via Esc keystroke, Esc keystroke.

The first one would be something like this:

cur_weather = level.get_weather()
level.set_weather("pripyat", true)


And the second would be this:

if cur_weather then level.set_weather(cur_weather, true) end

If you get the timer figured out, then you can put those in bind_stalker.script's update() function, inside the if self.bCheckStart conditional check so that it only executes once per level change or load:

local w = level.get_weather()
level.set_weather("pripyat", true)
-- then queue up the next -- put your own timer call here
_dev.queue_delayed_event({delay=10, event="level.set_weather("\"..w.."\",true)"})


The reason for using "pripyat" is that it is close to the other weathers so that it isn't too jarring if you see it briefly before you apply the second set_weather() call. "Test" is all bright and sunny, even at night.

Edit: Brain-dead spell-checker don't know grammar from mom's mom.
  01:46:23  14 June 2012
profilee-mailreply Message URLTo the Top
insanelazarez
Yeah, Good Luck With That...
(Resident)

 

 
On forum: 01/31/2009
Messages: 1070

---QUOTATION---
The reason for using "pripyat" is that it is close to the other weathers so that it isn't too jarring if you see it briefly before you apply the second set_weather() call. "Test" is all bright and sunny, even at night.
---END QUOTATION---



Lol, now we just need a 'Nightvision Umbrella'. Aha, sorry NatVac... i just needed to say something lol.
  01:52:53  14 June 2012
profilee-mailreply Message URLTo the Top
Kocayine
Senior Resident
 

 
On forum: 07/15/2010
Messages: 918
Hehe, I thought you someone missed that post so I decided to make a thread . Anyway, thanks for answering!

Yeah, I had previously been doing some pathetic attempts at using the get weather to something like you are talking about (failed ofcourse).

I'm almost sure I know what to do and I'm gonna try out right away, and let you know of my result!

Thanks!
  02:13:10  14 June 2012
profilee-mailreply Message URLTo the Top
Kocayine
Senior Resident
 

 
On forum: 07/15/2010
Messages: 918
Okay I gotta admit I'm pretty confused. What if I wanted to apply this to a non-ZRP mod? Then I can't make the delay, right? or am I missing something ...
  14:42:58  14 June 2012
profilee-mailreply Message URLTo the Top
{imperialreign}
Звуковой Шаман
(Resident)

 

 
On forum: 10/29/2008
Messages: 3075

---QUOTATION---
Okay I gotta admit I'm pretty confused. What if I wanted to apply this to a non-ZRP mod? Then I can't make the delay, right? or am I missing something ...
---END QUOTATION---



I was actually wondering the same, after reading Nat's response - again, though NatVac, you come up with some brilliant work arounds to problems . . . lord only knows where this modding community would be without your input, lol

But, yes, if I interpret his post correctly, I do not believe such a solution would work well with any mod using dynamic weathers or re-worked weathers (for that matter) . . . thankfully, though, there aren't mmany dynamic weather solutions. OL2.2 would probably be the easiest to apply such a *fix* method to, but I think it would almost fail completely with nandersen's dynamic weather engine . . . especially if you're in the middle of one of the hundreds of transitional weather hours. I'll try and shoot him an email and see if he ever figured a work around for this issue to use with his work . . .

Another idea, similiar, right off the top of my head would be to check the level weather on player exiting a map, and compare it to the current weather on the new level . . . if same or similiar, applye a weather_fx with just a rain variable change (i.e. 0) for 1 or 2 in-game minutes . . . when the weather_fx runs out, the engine defaults back to current weather values. So . . . not sure if it will work, as I just thought of this and haven't fully worked out the nuances, but . . . maybe . . .
  14:59:29  17 June 2012
profilee-mailreply Message URLTo the Top
NatVac
Senior Resident
 

 
On forum: 06/15/2007
Messages: 4302
insanelazarez, it could be a reason to wear one's sunglasses at night.
__________

---QUOTATION---
Okay I gotta admit I'm pretty confused. What if I wanted to apply this to a non-ZRP mod? Then I can't make the delay, right? or am I missing something ...
---END QUOTATION---


Okay, I gave you a way to fix it with two key sequences, so you have that as a fallback if you can't figure out how to use whatever timer support is in the AMK-derived mod. In OL I see some references to amk.g_start_timer() -- you could look up instances of that function is used to see how to get a ten millisecond delay and then if the timer "kicks off" (the time delay has elapsed) you could check to see if the name string is "weather" or whatever you used, then execute the level.set_weather(cur_weather,true) code statement inside the do_timer_action() function or whatever is used.

Please don't ask me how to use that stuff -- I just looked at it briefly and it has probably changed for the mod you are using.

¯¯¯¯¯¯¯¯¯¯
>> if I interpret his post correctly, I do not believe such a solution would
>> work well with any mod using dynamic weathers or re-worked weathers

{imperialreign}, the hack fix is executed after the weather for the level has been set, so the current weather is properly set.

The same concern with transitions I had for vanilla would apply to dynamic weather. It is just a bit more likely that the transition could occur in the 10-ms window between the check and the reset. It might be very easily avoided by just not performing the hack if the time is within, say, half a second of the minute change, so the fix is not applied in 1 of 120 times on average. Or use the initial delay to then grab the new weather and resubmit another queue_delayed_event() call. Or just live with the briefly out-of-sync weather.

You just made me realize that the only time in vanilla that the weather is changed is at level change, so the vanilla version doesn't need a check. Yes, the weather changes all the time, but the "weather" passed in set_weather() doesn't -- it's set by the weathers assignment in game_maps_single.ltx and that only changes with the level.
  14:41:43  8 September 2012
profilee-mailreply Message URLTo the Top
Kocayine
Senior Resident
 

 
On forum: 07/15/2010
Messages: 918
NatVac

I gotta be honest, my script capabilities, especially in this game, can't even pull this off. I'd really appreciate it if you could help me thru this, NatVac.

If we were to try this without the delay between the commands, what would the actual code be? .. I was thinking of just sticking to executing it thru the main menu (hotkey), like I do with the fix-doors and fix-megaphone ZRP scripts.
  04:37:06  16 September 2012
profilee-mailreply Message URLTo the Top
Kocayine
Senior Resident
 

 
On forum: 07/15/2010
Messages: 918
I've spent quite an amount of hours today trying to put together some script that would reset the weather. I've made a script that I can execute in mainmenu:


function main()
get_console():execute("main_menu off"
cur_weather = level.get_weather()
level.set_weather("pripyat",true)
if cur_weather then level.set_weather(cur_weather, true)

end


If I dont have the last line as part of the script then it changes to "pripyat" weather but if I keep it then nothing happens. I assume it is because of the missing delay? It happens to fast to let the engine actually change weather and therefore cannot fix the missing rain bug. So yeah, I've tried with amk.g_start_timer() which is used to run a script inside amk.script, or something, so I assume I cannot just put "if cur_weather then level.set_weather(cur_weather, true)" into a different script file. Is there a way to maybe implement the delay function of ZRP into my AMK based mod? I really think it's the only thing keeping me away from getting this.

Please remember, I'm really new to scripting and all that.
  13:30:56  16 October 2012
profilee-mailreply Message URLTo the Top
NatVac
Senior Resident
 

 
On forum: 06/15/2007
Messages: 4302
Even though you already have this sorted, Kocayine, for completeness I'm including the ui_main_menu.script key processing to fix the rain sound by executing the same keystroke pair twice (here, Esc W):

   if dik == DIK_keys.DIK_W then --use an available key
       get_console():execute("main_menu off")
       if cur_weather then
           level.set_weather(cur_weather, true)
           cur_weather = nil
       else -- cur_weather was nil; start of level or save loaded
           cur_weather = level.get_weather()
           level.set_weather("pripyat",true)
       end
   end

  18:09:38  16 October 2012
profilee-mailreply Message URLTo the Top
Kocayine
Senior Resident
 

 
On forum: 07/15/2010
Messages: 918
Ah! neat, man! Thanks a lot
  16:49:33  29 December 2012
profilee-mailreply Message URLTo the Top
lowenz
Augmented Technician
(Resident)

 

 
On forum: 04/15/2007
 

Message edited by:
lowenz
12/29/2012 16:49:43
Messages: 332
Problem is in CS too.
Maybe in CoP (never noticed).

A way to fix it there?
  04:33:15  5 January 2013
profilee-mailreply Message URLTo the Top
NatVac
Senior Resident
 

 
On forum: 06/15/2007
Messages: 4302
The same problem could use the same manual workaround. This could be put into the corresponding ui_main_menu.script file in CS (and CoP if needed), lowenz.

The active (programmed) workaround involving a delay timer would require knowledge of the other two games, neither of which I have, so you might want to post this in the CS and/or CoP sections.

Ideally, you'd want the engine programmer to fix the silly bug, not use a workaround. At least the later games give scripters more control and debugging abilities.
  01:24:01  16 July 2013
profilee-mailreply Message URLTo the Top
KreoShoc
(Novice)
 
On forum: 07/15/2013
Messages: 2
Here I have a solution of the problem. You need to add a few functions in level_weathers.script like this:


function WeatherManager:update()

...

   self:rain_sound_fix()
end

--  rain sound fix
local wthr = nil

function WeatherManager:rain_sound_fix()
	if wthr == nil then
		wthr = level.get_weather()
		level.set_weather("test", true)
		game.start_tutorial("rain_sound_fix")
    	end
end

function rain_sound_fix()
    	    level.set_weather(wthr, true)
end
-- rain sound fix



Also need to add a tutorial in game_tutorials.xml:


<rain_sound_fix>
<global_wnd/>
  <item type="video">
   <length_sec>1</length_sec>
   <pause_state>on</pause_state>
   <function_on_stop>level_weathers.rain_sound_fix</function_on_stop>
   <video_wnd x="0" y="0" width="1024" height="768" stretch="1">
    <texture x="0" y="0" width="1024" height="768">intro\intro_back</texture>
   </video_wnd>
  </item>
</rain_sound_fix>



This method works correctly with SWO v3.
  02:13:27  18 July 2013
profilee-mailreply Message URLTo the Top
Kocayine
Senior Resident
 

 
On forum: 07/15/2010
Messages: 918
Great job, man.
  22:19:09  18 July 2013
profilee-mailreply Message URLTo the Top
bamah
Senior Resident
 

 
On forum: 02/10/2008
 

Message edited by:
bamah
07/18/2013 23:13:24
Messages: 911
something similar works with any mod

In main_menu.script (zrp)

elseif dik == DIK_keys.DIK_W then
--if level.present() and (db.actor ~= nil) and db.actor:alive() then
get_console():execute("main_menu off"
if cur_weather then
level.set_weather(cur_weather, true)
cur_weather = nil
else -- cur_weather was nil; start of level or save loaded
cur_weather = level.get_weather()
level.set_weather("pripyat",true)--or rain section from a weather mod
--level.set_weather("storm",true)
end

in z_weather_temp_reset.script
function main()
--level.set_weather("test", true)
level.set_weather("rain_fix", true)
_z.show_small_msg("Weather preset 'Cloudy Dark Rain section' applied."
end

Tomatoes tomaatoes...same thing.
I like yours better
  21:06:08  24 July 2013
profilee-mailreply Message URLTo the Top
NatVac
Senior Resident
 

 
On forum: 06/15/2007
Messages: 4302
That's a clever use of the tutorial functionality, KreoShoc!

I've not tried it, but why did you use the "test" weather setting? That's sunny daylight even at night in vanilla. Does that mean that the tutorial locks the screen on the main menu for an extra second until the weather is properly fixed?

If not, I'd suggest using the "pripyat" weather setting for something closer to the default to avoid the possible flashing.

Thanks for going through the trouble to register just to post this!

¯¯¯¯¯¯¯¯¯¯
bamah, "rain_fix" is a custom weather setting of yours, right? It might be better than "pripyat". The z_weather_temp_reset.script function wouldn't be needed for your main menu function, though. Are you using it to fix the flashing-triangles problem?
  15:52:51  26 July 2013
profilee-mailreply Message URLTo the Top
KreoShoc
(Novice)
 
On forum: 07/15/2013
Messages: 2
NatVac, usage of this tutorial returns the correct weather before you see it, so you can use any weather setting, that you prefer...
  21:06:50  26 July 2013
profilee-mailreply Message URLTo the Top
Daemonion
All About Audio
(Resident)

 

 
On forum: 09/27/2011
Messages: 567

---QUOTATION---
Here I have a solution of the problem. You need to add a few functions in level_weathers.script like this:


function WeatherManager:update()

...

   self:rain_sound_fix()
end

--  rain sound fix
local wthr = nil

function WeatherManager:rain_sound_fix()
	if wthr == nil then
		wthr = level.get_weather()
		level.set_weather("test", true)
		game.start_tutorial("rain_sound_fix")
    	end
end

function rain_sound_fix()
    	    level.set_weather(wthr, true)
end
-- rain sound fix



Also need to add a tutorial in game_tutorials.xml:


<rain_sound_fix>
<global_wnd/>
  <item type="video">
   <length_sec>1</length_sec>
   <pause_state>on</pause_state>
   <function_on_stop>level_weathers.rain_sound_fix</function_on_stop>
   <video_wnd x="0" y="0" width="1024" height="768" stretch="1">
    <texture x="0" y="0" width="1024" height="768">intro\intro_back</texture>
   </video_wnd>
  </item>
</rain_sound_fix>



This method works correctly with SWO v3.
---END QUOTATION---


This gives me so many ideas with the tutorial function. Great work, and many thanks
  23:11:28  26 July 2013
profilee-mailreply Message URLTo the Top
ERForman
Senior Resident
 

 
On forum: 04/12/2007
Messages: 224
fyi

I've been using the Weather Overhaul mod with ZRP for years. It works
perfectly. Excellent sounds, dark nights, sun, moon, stars, storms, wind, lightning, etc., etc.
  21:09:30  7 December 2013
profilee-mailreply Message URLTo the Top
Darkh4
Senior Resident
 

 
On forum: 04/01/2007
 

Message edited by:
Darkh4
12/07/2013 21:12:53
Messages: 1177
Is there a chance of the solution posted by KreoShoc causing a problem with _g.script?

After adding it I've been running into some corrupted saves in Agroprom, with the error log saying that _g.script was expecting a string and got nothing. I was able to repeat the issue with new quick saves made after entering the level.

I was able to get around it by going back to the autosave from entering the level and replacing the altered level_weathers file with the one I was originally using, but now I've put it back in and I'm not getting a corrupted save any more.

Could it just be coincidence? I'm not even sure what _g.script does, but I vaguely remember something about it causing corrupted saves in Pripyat in the unmodded game. So maybe my game is just getting unstable after almost two and half months in the Zone.
 
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-2022 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.