ProjectsWhat's NewDownloadsCommunitySupportCompany
Forum Index » S.T.A.L.K.E.R.: Shadow of Chernobyl Forum » Mod discussion
Rain on Clothes Audio Script

1 2 | Next 10 events »| All Messages
Posted by/on
Question/AnswerMake Newest Up Sort by Descending
  00:26:17  18 February 2013
profilee-mailreply Message URLTo the Top
Daemonion
All About Audio
(Resident)

 

 
On forum: 09/27/2011
 

Message edited by:
Daemonion
02/18/2013 0:30:18
Messages: 567
Rain on Clothes Audio Script

I'm working on a script that will play audio (in stereo) around the player when it is raining. It will be the sound or rain hitting clothes. I added a call to it in actor_binder:update in bind_stalker.

Here is my script, but it doesn't work (crash when loading level: LUA error: ....r. - shadow of chernobyl\gamedata\scripts\_g.script:20: bad argument #2 to 'format' (string expected, got no value)).

What am I missing?

function rain_on_clothes()
	local rain_fps_l = sound_object ([[daemonion\misc\rain_test_l]],0)
	local rain_fps_r = sound_object ([[daemonion\misc\rain_test_r]],0)
	
	if level.rain_factor() > 0.07 then
		rain_fps_l:play_at_pos (actor, vector():set(-0.5,0.0,-0.3), d / 0000.1, sound_object.s2d)
		rain_fps_r:play_at_pos (actor, vector():set(0.5,0.0,0.3), d / 0000.1, sound_object.s2d)
	end
end

  09:37:45  18 February 2013
profilee-mailreply Message URLTo the Top
NatVac
Senior Resident
 

 
On forum: 06/15/2007
Messages: 4286
>> _g.script:20: bad argument #2 to 'format' (string expected, got no value)

You are probably using the vanilla _g.script or at least a version that doesn't change the first 20 lines, Daemonion. Line 20 in vanilla _g.script is this:

log(string.format(fmt,...))

So a printf() is being called with bad parameter data passed to it. The workaround is to comment out line 20 in _g.script. The fix is to find the printf() with the bad data and correct it or better, comment out all the printf()s. The printing/logging functionality was disabled in the release version of SoC, so the call is wasted at best, and because it processes the arguments passed in the printf() call, it wastes even more time and memory as well.

One source of such crashes is the abort() function in vanilla _g.script. It calls printf() on line 1116.

My recommendation is to use a modified version of _g.script. The ZRP one should work just fine. I strongly suggest modders to force abort() calls to crash their game so that they can know what is happening where and fix it. To do that, edit the ZRP _g.script file and change quit_on_abort from false to true.
  11:16:31  18 February 2013
profilee-mailreply Message URLTo the Top
Kocayine
Senior Resident
 

 
On forum: 07/15/2010
Messages: 918
I'm not of any help but I just wanted to say you're awesome Daemonion, for bringing a proper sound experience to SOC!
  22:22:53  18 February 2013
profilee-mailreply Message URLTo the Top
Daemonion
All About Audio
(Resident)

 

 
On forum: 09/27/2011
 

Message edited by:
Daemonion
02/18/2013 22:26:27
Messages: 567
Natvac
Thanks for the feedback. I actually tend to get this error anytime I write a script that isn't fully functional. I get it all the time. I'll try what you suggested, but that error usually tells me that something in the script isn't working as opposed to an external cause.

Kocayine
Thanks, man. I'm really trying hard to get this game up to snuff. It'd be best if I could just implement something like FMOD or wWise so that I could make everything procedural. As it is now, I just kind of have to hack everything together due to X-Ray being, well, X-Ray. Anyway, it is always nice to know folks are interested in what I'm doing. It is easy to just replace the sounds in the game, but that alone isn't going to create the experience that I'm looking to give players. I've gotta get down n' dirty.
  00:27:33  19 February 2013
profilee-mailreply Message URLTo the Top
Decane
Senior Resident
 

 
On forum: 04/04/2007
Messages: 1703
That looks like a syntax error, and no wonder, because your syntax is wrong.

Try this:

function rain_on_clothes()
local act = db.actor
local rain_fps_l = sound_object("daemonion\\misc\\rain_test_l")
local rain_fps_r = sound_object("daemonion\\misc\\rain_test_r")

if level.rain_factor() > 0.07 then
rain_fps_l:play_at_pos(act, vector():set(-0.5, 0, -0.3), 0, sound_object.s2d)
rain_fps_r:play_at_pos(act, vector():set(0.5, 0, 0.3), 0, sound_object.s2d)
end
end
  09:13:50  19 February 2013
profilee-mailreply Message URLTo the Top
Daemonion
All About Audio
(Resident)

 

 
On forum: 09/27/2011
 

Message edited by:
Daemonion
02/19/2013 9:16:09
Messages: 567
Here is what I have so far. The error I was getting was just due to bad syntax.

The info_portion is something I created (and it works) to see if the player is indoors. The debug stuff prints, but I hear no sound. My files are properly .ogg commented and what-not, of course.

function rain_on_clothes()
	local actor = db.actor
	local rain_fps_l = sound_object ([[daemonion\\misc\\rain_test_l]],0)
	local rain_fps_r = sound_object ([[daemonion\\misc\\rain_test_r]],0)
	
	if not has_alife_info("interior_whitenoise_playing") and  level.rain_factor() > 0.07 then
		c_print("it is raining; player is outside restrictor")
		if rain_fps_l:playing() == false and rain_fps_r:playing() == false then
			c_print("playing sounds")
			rain_fps_l:play_at_pos (actor, vector():set(-0.5,0.0,0.0), 0, sound_object.s2d)
			rain_fps_r:play_at_pos (actor, vector():set(0.5,0.0,0.0), 0, sound_object.s2d)
		end
	elseif level.rain_factor == 0 then
		c_print("not raining; stopping")
		rain_fps_l:stop()
		rain_fps_r:stop()
		
	elseif has_alife_info("interior_whitenoise_playing") then
		c_print("player indoors; audio stopped")
		rain_fps_l:stop()
		rain_fps_r:stop()		
	end
end

  22:56:24  19 February 2013
profilee-mailreply Message URLTo the Top
Kocayine
Senior Resident
 

 
On forum: 07/15/2010
Messages: 918

---QUOTATION---
Kocayine
Thanks, man. I'm really trying hard to get this game up to snuff. It'd be best if I could just implement something like FMOD or wWise so that I could make everything procedural. As it is now, I just kind of have to hack everything together due to X-Ray being, well, X-Ray. Anyway, it is always nice to know folks are interested in what I'm doing. It is easy to just replace the sounds in the game, but that alone isn't going to create the experience that I'm looking to give players. I've gotta get down n' dirty.
---END QUOTATION---

Indeed! and SOC of all games are in dire need of it. Will your work be working with other SOC mods than LURK, with a bit of merging, maybe?
  23:50:37  19 February 2013
profilee-mailreply Message URLTo the Top
Daemonion
All About Audio
(Resident)

 

 
On forum: 09/27/2011
Messages: 567

---QUOTATION---
Kocayine
Thanks, man. I'm really trying hard to get this game up to snuff. It'd be best if I could just implement something like FMOD or wWise so that I could make everything procedural. As it is now, I just kind of have to hack everything together due to X-Ray being, well, X-Ray. Anyway, it is always nice to know folks are interested in what I'm doing. It is easy to just replace the sounds in the game, but that alone isn't going to create the experience that I'm looking to give players. I've gotta get down n' dirty.Indeed! and SOC of all games are in dire need of it. Will your work be working with other SOC mods than LURK, with a bit of merging, maybe?
---END QUOTATION---


It is difficult because many of my changes rely on changing the level.spawns for each level in the Level Editor.
  22:05:51  24 February 2013
profilee-mailreply Message URLTo the Top
Daemonion
All About Audio
(Resident)

 

 
On forum: 09/27/2011
Messages: 567

---QUOTATION---
Here is what I have so far. The error I was getting was just due to bad syntax.

The info_portion is something I created (and it works) to see if the player is indoors. The debug stuff prints, but I hear no sound. My files are properly .ogg commented and what-not, of course.

function rain_on_clothes()
	local actor = db.actor
	local rain_fps_l = sound_object ([[daemonion\\misc\\rain_test_l]],0)
	local rain_fps_r = sound_object ([[daemonion\\misc\\rain_test_r]],0)
	
	if not has_alife_info("interior_whitenoise_playing") and  level.rain_factor() > 0.07 then
		c_print("it is raining; player is outside restrictor")
		if rain_fps_l:playing() == false and rain_fps_r:playing() == false then
			c_print("playing sounds")
			rain_fps_l:play_at_pos (actor, vector():set(-0.5,0.0,0.0), 0, sound_object.s2d)
			rain_fps_r:play_at_pos (actor, vector():set(0.5,0.0,0.0), 0, sound_object.s2d)
		end
	elseif level.rain_factor == 0 then
		c_print("not raining; stopping")
		rain_fps_l:stop()
		rain_fps_r:stop()
		
	elseif has_alife_info("interior_whitenoise_playing") then
		c_print("player indoors; audio stopped")
		rain_fps_l:stop()
		rain_fps_r:stop()		
	end
end


---END QUOTATION---


This still isn't working, and I'm not sure what to do. If anyone has any feedback, that'd be great
  21:22:39  25 February 2013
profilee-mailreply Message URLTo the Top
chuppa
Senior Resident
 

 
On forum: 04/11/2008
Messages: 409
Total noob comment here - for which I apologise (my modding is limited to blending, config values tweaking and file replacement/shuffling) - but I'm a bit lost why you're trying to make a script function to detect whether the player is under cover etc. when the game already seems to have that function? - ie. local player environment sound clearly alters according to whether you're indoors or even under trees - tho only in volume I think...

I'm only jumping in on this because the idea is excellent - ie. I've puzzled from the first time I experienced rain in the game why we weren't getting that "rain on clothes" effect rather than just amplified generic environment rain volume - especially when the differentiation mechanics of being under cover was already there.
 
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-2020 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.