add game&rawdata
This commit is contained in:
parent
0133cd976c
commit
49b34b5546
45731 changed files with 709831 additions and 0 deletions
134
gamedata/scripts/xr_zones_sound.script
Normal file
134
gamedata/scripts/xr_zones_sound.script
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
--[[------------------------------------------------------------------------------------------------------------------
|
||||
Êëàññ zone_sound. Ïðîèãðîâêà çâóêîâ ïðè âõîäå â çîíó. Ðàçðåøåíèå ïðîèãðîâêè ðàíäîìíîé îçâó÷êè â çîíå.
|
||||
×óãàé Ñàøà
|
||||
--------------------------------------------------------------------------------------------------------------------]]
|
||||
|
||||
-- òèïû çâóêîâ äëÿ çîí
|
||||
local sound_types = {
|
||||
floor_wooden = {
|
||||
"ambient\\floor_creak1",
|
||||
"ambient\\floor_creak2",
|
||||
"ambient\\floor_creak3"
|
||||
},
|
||||
random = {
|
||||
"ambient\\random\\new_drone1",
|
||||
"ambient\\random\\new_drone2",
|
||||
"ambient\\random\\rnd_3dmbridge",
|
||||
"ambient\\random\\rnd_ak47_1",
|
||||
"ambient\\random\\rnd_ak47_2",
|
||||
"ambient\\random\\rnd_crow",
|
||||
"ambient\\random\\rnd_disgusting",
|
||||
"ambient\\random\\rnd_distantmortar3",
|
||||
"ambient\\random\\rnd_dog6",
|
||||
"ambient\\random\\rnd_drone1",
|
||||
"ambient\\random\\rnd_drone2",
|
||||
"ambient\\random\\rnd_fallscream",
|
||||
"ambient\\random\\rnd_horror3",
|
||||
"ambient\\random\\rnd_horror4",
|
||||
"ambient\\random\\rnd_m-16_3",
|
||||
"ambient\\random\\rnd_m-16_4",
|
||||
"ambient\\random\\rnd_m-249",
|
||||
"ambient\\random\\rnd_moan",
|
||||
"ambient\\random\\rnd_moan1",
|
||||
"ambient\\random\\rnd_moan2",
|
||||
"ambient\\random\\rnd_moan3",
|
||||
"ambient\\random\\rnd_moan4",
|
||||
"ambient\\random\\rnd_moan5",
|
||||
"ambient\\random\\rnd_scr1",
|
||||
"ambient\\random\\rnd_scr2",
|
||||
"ambient\\random\\rnd_scr3",
|
||||
"ambient\\random\\rnd_scr4",
|
||||
"ambient\\random\\rnd_scr5",
|
||||
"ambient\\random\\rnd_scr7",
|
||||
"ambient\\random\\rnd_scr8",
|
||||
"ambient\\random\\rnd_scr9",
|
||||
"ambient\\random\\rnd_scr10",
|
||||
"ambient\\random\\rnd_the_horror1",
|
||||
"ambient\\random\\rnd_the_horror2",
|
||||
"ambient\\random\\rnd_the_horror3",
|
||||
"ambient\\random\\rnd_the_horror4",
|
||||
"ambient\\random\\rnd_thunder",
|
||||
"ambient\\random\\rnd_wolfhowl01",
|
||||
"ambient\\random\\rnd_wolfhowl02",
|
||||
"ambient\\random\\rt_coo1-m",
|
||||
"ambient\\random\\rt_sickened1",
|
||||
"ambient\\random\\rt_sickened2",
|
||||
"ambient\\random\\rt_swamp_thing1"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-- âêëþ÷èòü â dest âñå ýëåìåíòû èç src. Òàáëèöû èíäåêñèðîâàíû
|
||||
function table_include( dest, src )
|
||||
if dest and src then
|
||||
for i, v in src do
|
||||
table.insert( dest, v )
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- ïðî÷èòàòü ÷èñëî èç ini
|
||||
function r_num( spawn_ini, section, line, default )
|
||||
if spawn_ini:line_exist( section, line ) then
|
||||
return spawn_ini:r_float( section, line )
|
||||
else
|
||||
return default
|
||||
end
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------------------------------------------------
|
||||
local pos, ang
|
||||
|
||||
class "zone_sound"
|
||||
|
||||
function zone_sound:__init( zone, binder, ini )
|
||||
self.zone = zone
|
||||
self.sound_names = {}
|
||||
|
||||
local sect = "sound"
|
||||
|
||||
if ini:line_exist( sect, "snd" ) then
|
||||
table_include( self.sound_names, parse_names( ini:r_string( sect, "snd" ) ) )
|
||||
end
|
||||
|
||||
if ini:line_exist( sect, "type" ) then
|
||||
local t = parse_names( ini:r_string( sect, "type" ) )
|
||||
|
||||
for i, v in t do
|
||||
if v == "random" then
|
||||
self.random_pos = true
|
||||
end
|
||||
|
||||
table_include( self.sound_names, sound_types[v] )
|
||||
end
|
||||
end
|
||||
|
||||
if #self.sound_names == 0 then
|
||||
utils.abort( "restrictor '%s': no sounds specified in section 'sound'", zone:name() )
|
||||
end
|
||||
|
||||
-- printf( table.concat( self.sound_names, " " ) )
|
||||
self.delay = r_num( ini, sect, "delay", 0 )
|
||||
self.idle = r_num( ini, sect, "idle", 0 ) * 1000 -- ñåêóíäû->ìñ
|
||||
self.rnd = r_num( ini, sect, "rnd", 100 )
|
||||
|
||||
self.idle_end = 0
|
||||
end
|
||||
|
||||
function zone_sound:on_enter( obj )
|
||||
if self.idle_end < game.time() then
|
||||
self.idle_end = game.time() + self.idle
|
||||
|
||||
if get_clsid( obj ) == clsid.actor and math.random( 100 ) <= self.rnd then
|
||||
pos = obj:position()
|
||||
|
||||
if self.random_pos then
|
||||
ang = math.pi / 180.0 * math.random( 0, 35900 ) * 0.01
|
||||
pos:add( vector():set( math.cos( ang ), 0, math.sin( ang ) ):mul( math.random( 1500, 5000 ) * 0.01 ) )
|
||||
-- printf( "%f", obj:position():distance_to( pos ) )
|
||||
end
|
||||
|
||||
sound_object( self.sound_names[math.random(1, #self.sound_names)] ):play_at_pos( obj, pos, self.delay )
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue