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 | Next 10 events »| All Messages
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

 
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.