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 | Next 10 events »| All Messages
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: 6340
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: 6340
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: 6340
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?
 
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-2019 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.