ProjectsWhat's NewDownloadsCommunitySupportCompany
Forum Index » S.T.A.L.K.E.R.: Shadow of Chernobyl Forum » Mod discussion
Need help with scripting ideas for audio!

« Previous 10 events | 1 2 3 4 | Next 10 events »| All Messages
Posted by/on
Question/AnswerMake Newest Up Sort by Descending
  08:29:24  24 October 2012
profilee-mailreply Message URLTo the Top
Daemonion
All About Audio
(Resident)

 

 
On forum: 09/27/2011
Messages: 567

---QUOTATION---
As for your particular problem; the solution that immediately comes to mind is to have a clone of each weapon with a different sound set. When the actor picks up the a weapon it is exchanged for the cloned version with the actor focused sound set.

ex.

[wpn_pm_actor]:wpn_pm
snd_draw      = darius\generic_draw, 0.1
...



just have a update that checks actor inventory and exchanges out weapons and does something similar to switch it back on drop or trade etc.
---END QUOTATION---


I am looking at Zhat's Progressive Weapons Mod for inspiration, as it does just that. I am having difficulty parsing it, though. But it does exactly what you described - clone and swap out .ltx files when the actor puts weapon into their inventory slots.

http://zhat.dk/stalker/

If anyone can help me parse that, I'd really appreciate it.
  23:14:00  25 October 2012
profilee-mailreply Message URLTo the Top
Nuor
Senior Resident
 

 
On forum: 03/10/2009
Messages: 735
I may take a look. Just a simplification of wpn_mod.script should suit your needs. He's doing some things with packet updates that differs slightly from my usual. I suspect the weapon switching function can be simplified for your use. But without playing with it the reasons for various design choices aren't obvious to me; Maybe they sidestep issues of which I'm unfamiliar.
  09:40:26  27 October 2012
profilee-mailreply Message URLTo the Top
Daemonion
All About Audio
(Resident)

 

 
On forum: 09/27/2011
 

Message edited by:
Daemonion
10/27/2012 9:45:13
Messages: 567
Got some updates:


---QUOTATION---
This should work for all weapons and will replace them with their "_actor" variant. I don't know if SOC has an isWeapon function defined in the _G.script, though.
---END QUOTATION---


SoC's _G.script has the following:

function isWeapon(object)
    local id = get_clsid(object)
    if id == nil then return false end

    if id == clsid.wpn_vintorez_s then return true
    elseif id == clsid.wpn_ak74_s then return true
    elseif id == clsid.wpn_lr300_s then return true
    elseif id == clsid.wpn_hpsa_s then return true
    elseif id == clsid.wpn_pm_s then return true
    elseif id == clsid.wpn_shotgun_s then return true
    elseif id == clsid.wpn_bm16_s then return true
    elseif id == clsid.wpn_svd_s then return true
    elseif id == clsid.wpn_svu_s then return true
    elseif id == clsid.wpn_rpg7_s then return true
    elseif id == clsid.wpn_val_s then return true
    elseif id == clsid.wpn_walther_s then return true
    elseif id == clsid.wpn_usp45_s then return true
    elseif id == clsid.wpn_groza_s then return true
    elseif id == clsid.wpn_knife_s then return true
    elseif id == clsid.wpn_grenade_launcher then return true
    elseif id == clsid.wpn_grenade_f1 then return true
    elseif id == clsid.wpn_grenade_rpg7 then return true
    elseif id == clsid.wpn_grenade_rgd5 then return true
    elseif id == clsid.wpn_grenade_fake then return true
    else return false end
end



Here is CoP, as far as I know, in _g.script:


local weapon_classes = {}

function isWeapon(object, class_id)
	local id = class_id or get_clsid(object)
	return weapon_classes[id] == true
end



Right now, my bind_stalker looks like this:

function actor_binder:on_item_take (obj)
	if (isWeapon(obj)) then
		local sec = obj:section()
		local ini = system_ini()
		-- Check system ini if section with the postfix "_actor" exists
		if (ini:section_exist(sec.."_actor")) then
			alife():release( alife():object(obj:id()),true )
			alife():create(sec.."_actor",db.actor:position(),0,0,0)
		end
	end
    if obj:clsid() ~= clsid.wpn_ammo then
		level_tasks.proceed(self.object)
	end
	if device().precache_frame >1 then return end
    --game_stats.update_take_item (obj, self.object)
	_z.on_item_take(obj, self.object)
end
----------------------------------------------------------------------------------------------------------------------
function actor_binder:on_item_drop (obj)
	if (isWeapon(obj) and string.find(obj:section(),"_actor")) then
		local sec = string.gsub(obj:section(),"_actor","")
		alife():release( alife():object(obj:id()),true )
		alife():create(sec,db.actor:position(),db.actor:level_vertex_id(),db.actor:game_vertex_id())
	end
    if obj:clsid() ~= clsid.wpn_ammo then
		level_tasks.proceed(self.object)
	end
    --game_stats.update_drop_item (obj, self.object)
	if _z.item_drop_is_intentional(obj, self.object) then
		if _z.on_item_drop(obj, self.object) then return end -- true = used item
		if use_sleeping_bag and abc_sleep and obj:section()=="sleep_bag" then
			if not has_alife_info("ui_inventory") then return end
			if _dev then
				_dev.queue_delayed_event({delay=1200,event="abc_sleep.show_sleep_dialog()"})
			else
				dbglog("sleep_bag needs valid _dev.script")
			end
		end
	end
end



I think I need a few tweaks to get this to work (the indentation is actually correct - the GSC forum formatting messed with it a little). Pastebin for those who want it: http://pastebin.com/efCcdqbk
  22:56:38  27 October 2012
profilee-mailreply Message URLTo the Top
Daemonion
All About Audio
(Resident)

 

 
On forum: 09/27/2011
 

Message edited by:
Daemonion
10/27/2012 22:57:22
Messages: 567
*******************
Update: Partial Success
*******************
I got some of this stuff working, thanks to Alundaio, Nuor, Malandrinus and Jketiynu - here is how.

1) Change function actor_binder: on_item_take (obj) and function actor_binder: on_item_drop (obj) in bind_stalker.script. Pastebin: http://pastebin.com/LtQjazQx

2) Create a unique weapons list in gamedata\config\misc\unique_items.ltx by adding the following lines for each gun:

[new weapon .ltx name]: original weapon .ltx name
parameter to change = new file

So, it looks like this for the makarov:

[wpn_pm_actor]:wpn_pm
snd_shoot = weapons\pm_actor


I have not tested this with weapons that have attachments yet. Next step is to see if there is some way to have the actor's weapon audio play in stereo (using _l and _r).
  04:08:28  20 November 2012
profilee-mailreply Message URLTo the Top
Daemonion
All About Audio
(Resident)

 

 
On forum: 09/27/2011
Messages: 567
Hi everyone, sorry for posting this in CoP, too, but I would love some more help on this. Currently, everything pretty much works. I have yet to test something like an AK that has attachments, though. I'll do that soon. As a reminder, here is the code:

function actor_binder:on_item_take (obj)
    level_tasks.proceed(self.object)
	if (isWeapon(obj)) then
		local sec = obj:section()
		local ini = system_ini()
		-- Check system ini if section with the postfix "_actor" exists
		if (ini:section_exist(sec.."_actor")) then
			alife():release( alife():object(obj:id()),true )
			alife():create(sec.."_actor",db.actor:position(),0,0,0)
		end
	end    
end

function actor_binder:on_item_drop (obj)
    level_tasks.proceed(self.object)
	if (isWeapon(obj) and string.find(obj:section(),"_actor")) then
		local sec = string.gsub(obj:section(),"_actor","")
		alife():release( alife():object(obj:id()),true )
		alife():create(sec,db.actor:position(),db.actor:level_vertex_id(),db.actor:game_vertex_id())
	end
	if _z.item_drop_is_intentional(obj, self.object) then
		if _z.on_item_drop(obj, self.object) then return end -- true = used item
		if use_sleeping_bag and abc_sleep and obj:section()=="sleep_bag" then
			if not has_alife_info("ui_inventory") then return end
			if _dev then
				_dev.queue_delayed_event({delay=1200,event="abc_sleep.show_sleep_dialog()"})
			else
				dbglog("sleep_bag needs valid _dev.script")
			end
		end
	end
end


Right now, the script checks to see if there is the postfix "_actor" in a weapon's ini file. What I've done is place this at the bottom of the relevant weapon's ltx file:

[wpn_pm_actor]:wpn_pm
snd_shoot = weapons\pm_actor

I am wondering if it is possible to take this to the next level. I saw in SoC there was some kind of function that measures the distance from an object to the player ...I think you know where I am going with this. Is it now feasible to keep the actor's weapon audio constant, and have the NPC's weapon audio change based on their distance from the player?

I was thinking three tiers for the sounds:
enemy is 0-15m from player = weapon_npc_0m
enemy is 15-50m from player = weapon_npc_15m
enemy is 50-inf from player = weapon_npc_50m



example of code in SoC that might help:
function fighting_dist_ge_20(actor, npc)
	return db.storage[npc:id()].enemy:position():distance_to ( npc:position() ) >= 400
end

  06:04:42  20 November 2012
profilee-mailreply Message URLTo the Top
Alundaio
Sad Clown
(Resident)

 

 
On forum: 04/05/2010
Messages: 2230
No. You would physically see NPCs switch guns as the player when they cross the distance checks. Also exponentially increases the amount of new weapon sections you need.
  08:53:13  20 November 2012
profilee-mailreply Message URLTo the Top
Daemonion
All About Audio
(Resident)

 

 
On forum: 09/27/2011
Messages: 567

---QUOTATION---
No. You would physically see NPCs switch guns as the player when they cross the distance checks. Also exponentially increases the amount of new weapon sections you need.
---END QUOTATION---


Hm, that makes sense.

That definitely takes anything less than 100m out of the question ...I would be curious to still put a single change in that covers anything over 100m. I think the weapon switching wouldn't matter so much there. So, I guess that'd require two - one for anything < 100m, and one for anything > 100m.
  21:47:43  13 December 2012
profilee-mailreply Message URLTo the Top
Daemonion
All About Audio
(Resident)

 

 
On forum: 09/27/2011
Messages: 567
Hey Alundaio, I would still love to try this for enemies that are at a distance greater than, say, 100m. I think the effect of seeing them switch weapons wouldn't matter much at that distance.

Well ...does the AI even shoot at distances past 100m?
  08:29:35  22 December 2012
profilee-mailreply Message URLTo the Top
Daemonion
All About Audio
(Resident)

 

 
On forum: 09/27/2011
Messages: 567
so, I found these functions that I think will do the trick:

function dist_to_actor_le(actor, npc, p)
    local d = p[1]
    return d and npc:position():distance_to_sqr(actor:position()) <= d * d
end

function dist_to_actor_ge(actor, npc, p)
    local d = p[1]
    return d and npc:position():distance_to_sqr(actor:position()) >= d * d
end


Not sure how to implement them, though. It'd be great to have the actor use audio affixed with _actor, and NPCs have audio for any shots less than 80m and any shots over 80m.

function wp_take()
	if (isWeapon(obj)) then
		local sec = obj:section()
		local ini = system_ini()
		-- Check system ini if section with the postfix "_actor" exists
		if (ini:section_exist(sec.."_actor")) then
			alife():release( alife():object(obj:id()),true )
			alife():create(sec.."_actor",db.actor:position(),0,0,0)
		end
	end
end

function wp_drop()
	if (isWeapon(obj) and string.find(obj:section(),"_actor")) then
		local sec = string.gsub(obj:section(),"_actor","")
		alife():release( alife():object(obj:id()),true )
		alife():create(sec,db.actor:position(),db.actor:level_vertex_id(),db.actor:game_vertex_id())
	end
end

  06:21:52  23 December 2012
profilee-mailreply Message URLTo the Top
NatVac
Senior Resident
 

 
On forum: 06/15/2007
Messages: 4302

---QUOTATION---
Is it now feasible to keep the actor's weapon audio constant, and have the NPC's weapon audio change based on their distance from the player?
---END QUOTATION---


I guess I'm seeing this from a different point of view. A shot made by an ally next to me firing the same kind of rifle would sound just like the shot I made.

I would let the engine do what it already does well to control the attenuation of the sound as a function of distance, and instead concentrate on using different sounds depending on environment.

Yes, I know that over a distance the sound is changed, but this is a lot of work to recreate that effect.

One possibility would be having two sounds, one loud one whose volume attenuates quickly over a very short distance, with the other a softer one that travels for a much greater distance. Let every corresponding sound source (e.g., gunfire) produce both sounds. While that doubles the number of sounds, it eliminates all the script-based overhead to manage and select the sounds in the first place.
 
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.