ProjectsWhat's NewDownloadsCommunitySupportCompany
Forum Index » S.T.A.L.K.E.R.: Clear Sky Forum » Mod discussion
Can't bypass default "use" sound

1 2 3
Posted by/on
Question/AnswerMake Newest Up Sort by Descending
  18:33:54  7 November 2012
profilee-mailreply Message URLTo the Top
soopytwist
Senior Resident
 

 
On forum: 03/30/2010
 

Message edited by:
soopytwist
11/07/2012 19:25:48
Messages: 447
Can't bypass default "use" sound

I'm trying to get a new item usage sound script to work. Basically I've got a script to play a different sound depending on what items you use in the inventory - for example the sound of eating when eating bread.

My script is called item_usage.script in gamedata\scripts. It's taken from the one I did for SoC so there shouldn't be any errors in it. And in sounds I've got a folder called item_usage and there are several .ogg files.

Using an item should look up the script which points to the sound effect but all I get is the default inv_slot sound. I tried commenting out the line
<snd_item_use>interface\inv_slot</snd_item_use> in gamedata\configs\ui\inventory_new.xml, but it still plays the old default sound for using everything.

I'm obviously missing something but can't figure it out.


local items =
{
  bread = "food",
  kolbasa = "food",
  conserva = "food",
  peanuts = "food",
  yantar = "food",
  energy_drink = "drink",
  nonstop_drink = "drink",
  vodka = "vodka",
  bandage = "bandaid",
  medkit = "medkit",
  medkit_army = "medkit",
  medkit_scientic = "medkit",
  antirad = "pills",
  repair_kit = "repair"
}

-- set proper path to sound files
local sounds =
{
  vodka = {"item_usage\\item_vodka_1", "item_usage\\item_vodka_2", "item_usage\\item_vodka_3"},
  drink = {"item_usage\\item_drink"},
  food = {"item_usage\\item_food"},
  pills = {"item_usage\\item_antirad"},
  bandaid = {"item_usage\\item_bandage"},  
  medkit = {"item_usage\\item_medkit"},
  repair = {"item_usage\\item_repair"}
}

function get_item_sound(i_type)
  return sounds[i_type][math.random(1, #sounds[i_type])]
end

function on_use_item(obj)
  local i_type = items[obj:section()]
  if i_type ~= nil then
    local snd = get_item_sound(i_type)
    snd = sound_object(snd)
    snd:play_no_feedback(db.actor, sound_object.s2d, 0, vector(), 1.0)
  end
end

  18:42:26  7 November 2012
profilee-mailreply Message URLTo the Top
soopytwist
Senior Resident
 

 
On forum: 03/30/2010
 

Message edited by:
soopytwist
11/07/2012 19:29:31
Messages: 447
Oh, and this in bind_stalker.script:


function actor_binder:on_use_item(obj)
  item_usage.on_use_item(obj)
end



EDIT

Opps! I missed this line:


self.object:set_callback(callback.use_object, self.on_use_item, self)



from under actor_binder:reinit()

Now I hear mostly the default inv_slot sound effect and only occasionally the new sound. Or I get both sounds at the same time or I hear the default sound and the new sound quieter and in one channel! Bust mostly I just hear the old sounds.

What's going on?
  19:37:31  7 November 2012
profilee-mailreply Message URLTo the Top
soopytwist
Senior Resident
 

 
On forum: 03/30/2010
Messages: 447
I blanked out the inv_slot sound (made it silent) now I hear my new sounds only very very quite or not at all only very occasionally at proper volume and a couple of times at a very high volume.

I'm beginning to suspect CS doesn't like .ogg files from SoC.
  01:23:44  8 November 2012
profilee-mailreply Message URLTo the Top
SetaKat
Ex modder, Zones only ferret and will someday release a game
(Resident)

 

 
On forum: 02/20/2010
Messages: 6342
SoC uses mono sound files, whereas CS/CoP uses stereo. Might pay to grab the sound files from CoP and try them, or use some other CS sounds to debug.
Also, look for the SAVandT tool here for recommenting sound files, might be helpful.
  16:34:47  8 November 2012
profilee-mailreply Message URLTo the Top
soopytwist
Senior Resident
 

 
On forum: 03/30/2010
 

Message edited by:
soopytwist
11/08/2012 16:39:47
Messages: 447
Thanks SetaKat. I actually installed the level editor again just to try recommenting the ogg's but can't get the editor to work (missing dll's - think I had that problem last year). SAVandT will be better though and I should still have the unpacked gamedata from CoP knocking about somewhere.

EDIT

All the ogg's for CS are mono, apart from music.
  17:03:40  8 November 2012
profilee-mailreply Message URLTo the Top
soopytwist
Senior Resident
 

 
On forum: 03/30/2010
Messages: 447
Hmm. I got the original item use sounds from CoP, commented them using SAVandT and now, in the game, I hear one sound then none after that. Doesn't matter what item I use there are no sounds.
  00:14:12  9 November 2012
profilee-mailreply Message URLTo the Top
SetaKat
Ex modder, Zones only ferret and will someday release a game
(Resident)

 

 
On forum: 02/20/2010
Messages: 6342
CoP sound files shouldn't require recommenting. SoC would.
SoC also does sound differently to CS/CoP, due to the fact it uses Mono sound files most of the time. Did you try checking how CS plays sounds in comparision to CS?
  17:35:06  9 November 2012
profilee-mailreply Message URLTo the Top
soopytwist
Senior Resident
 

 
On forum: 03/30/2010
Messages: 447
I opened vanilla CS sounds that do work, such as weapon add-ons, opening and closing the inventory etc in SAVandT and checked the "comment" settings that were already set and just made the new sounds (in item_usage) the same. So I would expect them to work but the output I get when using items is either:

- sound plays once whichever item you use then never again
- volume of the sound is very very quiet
- sound plays in one channel only (left or right ear/speaker)
- no sounds at all using any items

All vanilla game sounds are fine.

As CS has no vanilla sounds for using items in the inventory I suspect it was never designed to, which is why the new sounds are not working (the SoC script is not compatible?) - though it is just an engine update of SoC really.

I haven't been able to find any ready-made mods that play sounds when items are used, to check if I'm making an error some place. I can only find that sort of mod for SoC and CoP. Same with the repair kit mod, though I have been able to get my repair kit mod to work - it would be nice to have a sound play when the repair kits are used though, before I upload it to FileFront.
  00:35:51  10 November 2012
profilee-mailreply Message URLTo the Top
SetaKat
Ex modder, Zones only ferret and will someday release a game
(Resident)

 

 
On forum: 02/20/2010
 

Message edited by:
SetaKat
11/10/2012 0:37:02
Messages: 6342
Try using "xr_sound.set_sound_play(db.actor:id(), sound)" instead of "snd: play_no_feedback(db.actor, sound_object.s2d, 0, vector(), 1.0)", so the script looks like this:

function on_use_item(obj)
  local i_type = items[obj:section()]
  if i_type ~= nil then
    local snd = get_item_sound(i_type)
    xr_sound.set_sound_play(db.actor:id(), snd)
  end
end


With this approach, you'll need to define the sounds in the sound ltx in configs/misc, which is probably a better solution that defining them in a script, since it offers a few more options. I've used xr_sound.set_sound_play(...) in a custom script, and it plays sounds fine. Your original sound approach was valid in SoC, but not in CS/CoP.
  17:54:10  10 November 2012
profilee-mailreply Message URLTo the Top
soopytwist
Senior Resident
 

 
On forum: 03/30/2010
Messages: 447
Do you mean script_sound.ltx in misc\config?
  00:11:30  11 November 2012
profilee-mailreply Message URLTo the Top
SetaKat
Ex modder, Zones only ferret and will someday release a game
(Resident)

 

 
On forum: 02/20/2010
Messages: 6342
Yep.
  02:06:30  11 November 2012
profilee-mailreply Message URLTo the Top
soopytwist
Senior Resident
 

 
On forum: 03/30/2010
Messages: 447
Think I must be missing something

This is in script_sound.ltx:

item_antirad
item_bandage
item_drink
item_food
item_medkit
item_repair
item_vodka_1
item_vodka_2
item_vodka_3

[item_antirad]
type = actor
path = item_usage\item_antirad

[item_bandage]
type = actor
path = item_usage\item_bandage

[item_drink]
type = actor
path = item_usage\item_drink

[item_food]
type = actor
path = item_usage\item_food

[item_medkit]
type = actor
path = item_usage\item_medkit

[item_repair]
type = actor
path = item_usage\item_repair

[item_vodka_1]
type = actor
path = item_usage\item_vodka_1

[item_vodka_2]
type = actor
path = item_usage\item_vodka_2

[item_vodka_3]
type = actor
path = item_usage\item_vodka_3



And this in item_usage.script:

function on_use_item(obj)
  local i_type = items[obj:section()]
  if i_type ~= nil then
    local snd = get_item_sound(i_type)
    xr_sound.set_sound_play(db.actor:id(), snd)
  end
end



And this in bind_stalker.script:

function actor_binder:on_use_item(obj)
  item_usage.on_use_item(obj)
end



Also in bind_stalker.script under function actor_binder:reinit():

self.object:set_callback(callback.use_object, self.on_use_item, self)



What I get now is a crash whit this error:

[error]Expression    : fatal error
[error]Function      : CScriptEngine::lua_error
[error]File          : E:\priquel\sources\engine\xrServerEntities\script_engine.cpp
[error]Line          : 180
[error]Description   : <no expression>
[error]Arguments     : LUA error: ....t.a.l.k.e.r. - clear sky\gamedata\scripts\_g.script:975: bad argument #2 to 'format' (string expected, got nil)

  02:22:27  11 November 2012
profilee-mailreply Message URLTo the Top
SetaKat
Ex modder, Zones only ferret and will someday release a game
(Resident)

 

 
On forum: 02/20/2010
Messages: 6342
Whats the line above the crash? _g.script line 975 is abort, so there will be a [LUA][ERROR] line in the log right above the crash section.
  16:20:48  11 November 2012
profilee-mailreply Message URLTo the Top
soopytwist
Senior Resident
 

 
On forum: 03/30/2010
Messages: 447

---QUOTATION---
Whats the line above the crash? _g.script line 975 is abort, so there will be a [LUA][ERROR] line in the log right above the crash section.
---END QUOTATION---



Ah sorry, I didn't see that bit:

! [LUA][ERROR] ERROR: INCORRECT LOAD [_sound_actor_save].[0][47706]

Maybe doesn't like type = actor then?
  23:22:25  11 November 2012
profilee-mailreply Message URLTo the Top
SetaKat
Ex modder, Zones only ferret and will someday release a game
(Resident)

 

 
On forum: 02/20/2010
Messages: 6342
Your missing addition variables for type = actor. If you use type = 3d, it should work fine. Hopefully.
  17:06:24  12 November 2012
profilee-mailreply Message URLTo the Top
soopytwist
Senior Resident
 

 
On forum: 03/30/2010
 

Message edited by:
soopytwist
11/12/2012 17:10:33
Messages: 447

---QUOTATION---
Your missing addition variables for type = actor. If you use type = 3d, it should work fine. Hopefully.
---END QUOTATION---



Nope, already tried type = 3d, same error.

I've been going through how CoP handles item sounds, as I am in effect trying to replicate that in CS. Works a little differently and is not using a script, like you suggested I try for CS. The bind_stalker entry though is more complex as that ties in with the use of anabiotics, which of course CS doesn't have.

Definitely not the .ogg files at fault that's for sure as I pointed my previously sort-of-working script to some vanilla .oggs and the same audio problems occur.

Maybe CS can't have on-item-use sounds?
  00:14:25  13 November 2012
profilee-mailreply Message URLTo the Top
SetaKat
Ex modder, Zones only ferret and will someday release a game
(Resident)

 

 
On forum: 02/20/2010
Messages: 6342
Are you testing these on an existing game? I double checked the crash, and its save related, so it might be that the game doesn't like script sounds being added part way through a game.
  17:02:04  13 November 2012
profilee-mailreply Message URLTo the Top
soopytwist
Senior Resident
 

 
On forum: 03/30/2010
Messages: 447

---QUOTATION---
Are you testing these on an existing game? I double checked the crash, and its save related, so it might be that the game doesn't like script sounds being added part way through a game.
---END QUOTATION---



You're absolutely right, it was the save crashing the game. So I started a new game, everything fine until I actually use an item (from the start I can only afford some food or one antirad)

Error is:


[error]Expression    : fatal error
[error]Function      : CScriptEngine::lua_error
[error]File          : E:\priquel\sources\engine\xrServerEntities\script_engine.cpp
[error]Line          : 180
[error]Description   : <no expression>
[error]Arguments     : LUA error: ....e.r. - clear sky\gamedata\scripts\item_usage.script:2: attempt to index global 'items' (a nil value)



So something in item_usage.script it don't like.


function on_use_item(obj)
  local i_type = items[obj:section()]
  if i_type ~= nil then
    local snd = get_item_sound(i_type)
    xr_sound.set_sound_play(db.actor:id(), snd)
  end
end



Or am I missing something out of this? I got rid of all the other stuff, as we're calling up script.sound.ltx to handle the ogg's.
  00:55:20  14 November 2012
profilee-mailreply Message URLTo the Top
SetaKat
Ex modder, Zones only ferret and will someday release a game
(Resident)

 

 
On forum: 02/20/2010
Messages: 6342
script_sound.ltx

item_antirad
item_bandage
item_drink
item_food
item_medkit
item_repair
item_vodka

[item_antirad]
type = actor
path = item_usage\item_antirad

[item_bandage]
type = actor
path = item_usage\item_bandage

[item_drink]
type = actor
path = item_usage\item_drink

[item_food]
type = actor
path = item_usage\item_food

[item_medkit]
type = actor
path = item_usage\item_medkit

[item_repair]
type = actor
path = item_usage\item_repair

[item_vodka]
type = actor
path = item_usage\item_vodka_
shuffle = rnd


item_usage.script

local items =
{
  bread = "item_food",
  kolbasa = "item_food",
  conserva = "item_food",
  peanuts = "item_food",
  yantar = "item_food",
  energy_drink = "item_drink",
  nonstop_drink = "item_drink",
  vodka = "item_vodka",
  bandage = "item_bandaid",
  medkit = "item_medkit",
  medkit_army = "item_medkit",
  medkit_scientic = "item_medkit",
  antirad = "item_pills",
  repair_kit = "item_repair"
}

function on_use_item(obj)
    local snd = items[obj:section()]
    xr_sound.set_sound_play(db.actor:id(), snd)
end


This should fix it.
In sound_script.ltx, the sound path for item_vodka has a '_' on the end. This tells the game to search for files with a number at the end of them. The shuffle line will tell it to pick a sound at random.
  19:03:45  14 November 2012
profilee-mailreply Message URLTo the Top
soopytwist
Senior Resident
 

 
On forum: 03/30/2010
Messages: 447
You're not going to believe this SetaKat.

After all that - while the game no longer crashes using this new script method, I have the exact same sound issue as before with my original scripts. Using items either play the correct sound or not at all, or they're too quiet to hear clearly or play back in one ear.

I just don't get it. I've already discounted the .ogg's themselves being the issue because if I reference existing vanilla .ogg's the same sound issues occur.

I'm at a loss.
  23:25:25  14 November 2012
profilee-mailreply Message URLTo the Top
SetaKat
Ex modder, Zones only ferret and will someday release a game
(Resident)

 

 
On forum: 02/20/2010
Messages: 6342
Well, thats odd.
Did you check the sound commenting against other sounds in script_sound.ltx that also have type = actor.
The only thing I can think of is that the base sound level is too low. Try increasing it in SAVandT.
  01:18:24  15 November 2012
profilee-mailreply Message URLTo the Top
soopytwist
Senior Resident
 

 
On forum: 03/30/2010
Messages: 447
It's the same.

I changed them all to:

Game Sound Type = NPC_talking
Base Sound Volume = 1.0
Minimum Distance = 2.5
Maximum Distance = 75.0
Maximum AI Distance = 2.0

Which is the same as other type = actor sounds.

Just checked Sound File Info in SAVandT. All my new sounds have a Nominal Bitrate of 96000 and the Comment CRC is 99007F4F.

Original vanilla Ogg's in CS for Interface for example have a Nominal Bitrate of 48000 and the Comment CRC is A59F6130. I don't know what these "Comment CRC" are but the bitrate could be the cause...?
  02:09:21  15 November 2012
profilee-mailreply Message URLTo the Top
SetaKat
Ex modder, Zones only ferret and will someday release a game
(Resident)

 

 
On forum: 02/20/2010
Messages: 6342
Ignore the comment CRC.
You'll need to reconvert the sounds to 128Kbps, 44100Hz bitrate, and then redo the comments.
I use Freemake Audio converter (http://www.freemake.com/free_audio_converter/) because of its ease of use, speed, and options. It can join files in addition to converting them as well. Its also 99% idiot proof. One of its OGG presets is the required settings for Stalker sounds, so its as easy as loading all the sounds in, hitting OGG, selecting the correct preset, and then hitting convert.
  19:05:35  15 November 2012
profilee-mailreply Message URLTo the Top
soopytwist
Senior Resident
 

 
On forum: 03/30/2010
Messages: 447
Freemake is complete arse. Apart from it's (failed) valiant attempts to install other crap on my PC and boot me over to ad sites it does not have a setting to convert for Stalker games. All it has is the option to convert to 128kbps ogg, which are all stereo (which sounds in CS are not) and no comments.

Either way, the sounds still don't play properly as before. I use Goldwave for editing sounds (have done for many years), though it does not have the ability to save to 128kbps, it does have a number of other bitrates etc...and I've tried them all.

My conclusion after all this lengthy malarkey is that item use sounds are not possible in Clear Sky. If it were, someone would have done it already - well I just confirmed, in a roundabout way, that it can't be done.
  00:56:29  16 November 2012
profilee-mailreply Message URLTo the Top
SetaKat
Ex modder, Zones only ferret and will someday release a game
(Resident)

 

 
On forum: 02/20/2010
Messages: 6342

---QUOTATION---
Freemake is complete arse. Apart from it's (failed) valiant attempts to install other crap on my PC and boot me over to ad sites it does not have a setting to convert for Stalker games. All it has is the option to convert to 128kbps ogg, which are all stereo (which sounds in CS are not) and no comments.
---END QUOTATION---


Comments are essentially extra metadata, which is discarded during conversion. Freemake has never tried to install other crap on my PC, or boot me over to ad sites. If you didn't get it from the link I provided, I suspect you didn't get the genuine product. And restoring comment data is easy if you copy it from an existing sound, and paste it into the new sound.
For it to convert to Mono, you need to create a custom preset. The default 128kbps is a Stereo preset. Just select "Add your preset", select Mono instead of Stereo, and make sure bitrate=128kbps, and sample rate=44100Hz, and give it a new name. Then convert with it.


---QUOTATION---
My conclusion after all this lengthy malarkey is that item use sounds are not possible in Clear Sky. If it were, someone would have done it already - well I just confirmed, in a roundabout way, that it can't be done.
---END QUOTATION---


The only reason it has already not been done is the lack of CS modders who could potentially come up with such an idea. There is only a handful of us. Now I'm going to grab the CoP sounds, and test this for myself.
  09:50:49  16 November 2012
profilee-mailreply Message URLTo the Top
SetaKat
Ex modder, Zones only ferret and will someday release a game
(Resident)

 

 
On forum: 02/20/2010
Messages: 6342
Grabbed the CoP sounds, added the code, sounds play at full volume fine, only issue is if I use multiple items in quick succession the sounds might not play, but otherwise, no problems.
  19:03:31  16 November 2012
profilee-mailreply Message URLTo the Top
soopytwist
Senior Resident
 

 
On forum: 03/30/2010
 

Message edited by:
soopytwist
11/16/2012 19:08:22
Messages: 447

---QUOTATION---
Grabbed the CoP sounds, added the code, sounds play at full volume fine, only issue is if I use multiple items in quick succession the sounds might not play, but otherwise, no problems.
---END QUOTATION---



That's interesting. This could be a hardware issue then. I have a Creative X-Fi Fatality Pro sound card. I use Daniel K's drivers rather than Creative's own because they have never worked so well with Windows 7, especially concerning 5.1 and 7.1 surround and EAX.

I did notice using items in quick succession don't play but for me just using any other item after using a different one doesn't always play either, even if I wait a few moments. Or the sound plays quietly or in one channel. I saved them all as 128kbps mono 44100Hz OGG.

I downloaded Freemake from the link you supplied, perhaps they changed how it installs since you installed it last? I had to opt out of installing at least three internet tool bars and it opened an add site when it installed and when I ran the program it tried to access my browser again but I'd already killed my connection.

EDIT

I should also point out I did have Clear Sky Complete v1.1.2 installed when making and testing this mod. Also, do we know if Clear Sky uses DirectSound3D or OpenAL?
  20:22:03  16 November 2012
profilee-mailreply Message URLTo the Top
soopytwist
Senior Resident
 

 
On forum: 03/30/2010
Messages: 447
RESOLVED!

Got it fixed!

I went and deleted everything and started again. First I started with an empty gamedata to test the vanilla game, re-wrote the scripts, copied over the CoP sounds and kept them in the interface folder this time. Tested the game and the sounds play fine.

Next I deleted the gamedata folder and reinstalled Clear Sky Complete, then re-merged, by hand, all my scripts and copied the rest over from my vanilla version. Tested the game again and they work!

Difficult to pin down exactly what the problem was before, maybe the game just didn't like playing the sounds from a new folder (item_usage). All the sounds are now in the interface folder with the other sounds.

Well, anyway it's all sorted - thanks Setakat you've been a massive help, have credited you in the documentation for my mod. I've already got version 1.0 without sounds pending on FileFront, once it gets approved I'll upload this new 1.1 version with the working sounds to replace it.

Thanks again.
  01:19:29  17 November 2012
profilee-mailreply Message URLTo the Top
SetaKat
Ex modder, Zones only ferret and will someday release a game
(Resident)

 

 
On forum: 02/20/2010
 

Message edited by:
SetaKat
11/17/2012 1:22:46
Messages: 6342

---QUOTATION---
I downloaded Freemake from the link you supplied, perhaps they changed how it installs since you installed it last? I had to opt out of installing at least three internet tool bars and it opened an add site when it installed and when I ran the program it tried to access my browser again but I'd already killed my connection.
---END QUOTATION---


Yeah, I remember that. Freemake is freeware, so they probably have sponsors from the companies that make those internet toolbars. That sort of stuff is a common occurrence when using freeware programs.
I reran my installer, and they must have changed the installer, since it ran off and redownloaded it. The opening of the browser just opened a "Thank you for installing Freemake" page.

Actually, it must have updated at some point, since originally I couldn't set 128kbps 44100Hz Mono in the OGG conversion format, and now I can. Just remembered that.

Also, this is probably a safer bit of code.

function on_use_item(obj)
    local snd = items[obj:section()]
    if snd ~= nil then
        xr_sound.set_sound_play(db.actor:id(), snd)
    end
end

If the mod adds an item that isn't in the list, it won't crash. Dunno if it is necessary, but given some of GSC's code, it wouldn't hurt.
 
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.: Clear Sky 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.