177 lines
5.3 KiB
Plaintext
177 lines
5.3 KiB
Plaintext
-- @ Version: SCREEN SPACE SHADERS - UPDATE 17
|
|
-- @ Description: Rain - Footsteps
|
|
-- @ Author: https://www.moddb.com/members/ascii1457
|
|
-- @ Mod: https://www.moddb.com/mods/stalker-anomaly/addons/screen-space-shaders
|
|
|
|
-- Settings
|
|
local ssfx_rf_vol = 0
|
|
local ssfx_rf_vol_variation = 0
|
|
|
|
local ssfx_rf_vol_multi_without_rain = 0
|
|
local ssfx_rf_vol_multi_walk = 0
|
|
local ssfx_rf_vol_multi_run = 0
|
|
|
|
local ssfx_rf_jump_vol = 0
|
|
local ssfx_rf_land_vol = 0
|
|
|
|
-- Internal vars
|
|
module_installed = true
|
|
|
|
local Rain_Hemi = 0
|
|
local Rain_Factor = 0
|
|
|
|
local Footstep_Snd = {}
|
|
local Footstep_Jump_Snd = {}
|
|
local Footstep_Land_Snd = {}
|
|
|
|
local Weapon_Aiming = 0
|
|
|
|
local Last_Snd = -1
|
|
local JL_Counter = { ["jump"] = 0, ["land"] = 0 }
|
|
|
|
function actor_on_first_update()
|
|
|
|
Rain_Hemi = 0
|
|
Rain_Factor = 0
|
|
|
|
end
|
|
|
|
function on_game_load()
|
|
|
|
-- Preload all the sounds
|
|
Footstep_Snd[0] = sound_object([[material\human\step\rain_01]])
|
|
Footstep_Snd[1] = sound_object([[material\human\step\rain_02]])
|
|
Footstep_Snd[2] = sound_object([[material\human\step\rain_03]])
|
|
Footstep_Snd[3] = sound_object([[material\human\step\rain_04]])
|
|
Footstep_Snd[4] = sound_object([[material\human\step\rain_05]])
|
|
Footstep_Snd[5] = sound_object([[material\human\step\rain_06]])
|
|
Footstep_Snd[6] = sound_object([[material\human\step\rain_07]])
|
|
Footstep_Snd[7] = sound_object([[material\human\step\rain_08]])
|
|
|
|
Footstep_Jump_Snd[0] = sound_object([[material\human\step\rain_jump_01]])
|
|
Footstep_Jump_Snd[1] = sound_object([[material\human\step\rain_jump_02]])
|
|
Footstep_Jump_Snd[2] = sound_object([[material\human\step\rain_jump_03]])
|
|
|
|
Footstep_Land_Snd[0] = sound_object([[material\human\step\rain_land_01]])
|
|
Footstep_Land_Snd[1] = sound_object([[material\human\step\rain_land_02]])
|
|
Footstep_Land_Snd[2] = sound_object([[material\human\step\rain_land_03]])
|
|
end
|
|
local TestValue = 0
|
|
function actor_on_footstep()
|
|
|
|
local Base_Vol = clamp(level.rain_wetness() * 2.0, 0.0, 1.0) -- Base sound volume
|
|
|
|
if Base_Vol > 0 then
|
|
|
|
Rain_Hemi = level.rain_hemi() -- Use rain hemi to detect cover
|
|
Rain_Factor = clamp(level.rain_factor(), ssfx_rf_vol_multi_without_rain, 1.0) -- Lower volume when rain stop
|
|
|
|
Base_Vol = Base_Vol * Rain_Hemi * Rain_Factor
|
|
|
|
if (Base_Vol < 0.05) then return end -- Just skip
|
|
|
|
local Actor_State = level.actor_moving_state()
|
|
|
|
-- Slower
|
|
Actor_Crouch = ssfx_rf_vol_multi_walk * (bit_and(Actor_State, 16) ~= 0 and 1 or 0)
|
|
Actor_Walk = ssfx_rf_vol_multi_walk * (bit_and(Actor_State, 32) ~= 0 and 1 or 0)
|
|
Actor_Aiming = ssfx_rf_vol_multi_walk * Weapon_Aiming
|
|
|
|
-- Faster
|
|
Actor_Sprint = bit_and(Actor_State, 4096) ~= 0
|
|
|
|
-- Adjust volume
|
|
Vol_Mod = 1.0 - (Actor_Crouch + Actor_Walk + Actor_Aiming)
|
|
Vol_Mod = Actor_Sprint and ssfx_rf_vol_multi_run or Vol_Mod
|
|
|
|
local rand = math.random(0, 7) -- Random Sound
|
|
|
|
-- Avoid repeat
|
|
if rand == Last_Snd then
|
|
rand = (Last_Snd + 1) % 8
|
|
end
|
|
|
|
-- Play Sound and set volume
|
|
variation = math.random(0.0, ssfx_rf_vol_variation * 100) / 100
|
|
|
|
Footstep_Snd[rand]:play(db.actor,0,sound_object.s2d)
|
|
Footstep_Snd[rand].volume = clamp(Base_Vol * (ssfx_rf_vol + variation) * Vol_Mod, 0.0, 1.0);
|
|
|
|
--printdbg("* RAIN - FOOTSTEP : [%s] vol:%s base:%s", rand, Footstep_Snd[rand].volume, Base_Vol)
|
|
|
|
Last_Snd = rand
|
|
end
|
|
end
|
|
|
|
local function actor_on_jump()
|
|
|
|
if ssfx_rf_jump_vol > 0 then
|
|
ssfx_JumpLand_Snd(Footstep_Jump_Snd, ssfx_rf_jump_vol, "jump")
|
|
end
|
|
|
|
end
|
|
|
|
local function actor_on_land()
|
|
|
|
if ssfx_rf_land_vol > 0 then
|
|
ssfx_JumpLand_Snd(Footstep_Land_Snd, ssfx_rf_land_vol, "land")
|
|
end
|
|
|
|
end
|
|
|
|
function ssfx_JumpLand_Snd(SndDB, Vol, CntStr)
|
|
|
|
-- Check last Rain_Hemi
|
|
if (Rain_Hemi > 0.1) then
|
|
|
|
-- Play Sound and set volume
|
|
SndDB[JL_Counter[CntStr]]:play(db.actor,0,sound_object.s2d)
|
|
SndDB[JL_Counter[CntStr]].volume = Vol * Rain_Factor
|
|
|
|
-- Next Sound
|
|
JL_Counter[CntStr] = (JL_Counter[CntStr] + 1) % 3
|
|
end
|
|
end
|
|
|
|
|
|
local function ssfx_aim_in()
|
|
Weapon_Aiming = 1
|
|
end
|
|
|
|
local function ssfx_aim_out()
|
|
Weapon_Aiming = 0
|
|
end
|
|
|
|
function on_option_change()
|
|
|
|
-- Get settings
|
|
local module_id = "ssfx_rain_module/ssfx_rain_footsteps"
|
|
ssfx_rf_vol = ssfx_001_mcm.ssfx_get_setting(module_id, "main_vol", ssfx_rain_footsteps_settings)
|
|
ssfx_rf_vol_variation = ssfx_001_mcm.ssfx_get_setting(module_id, "vol_rnd", ssfx_rain_footsteps_settings)
|
|
|
|
ssfx_rf_vol_multi_without_rain = ssfx_001_mcm.ssfx_get_setting(module_id, "multi_no_rain", ssfx_rain_footsteps_settings)
|
|
ssfx_rf_vol_multi_walk = ssfx_001_mcm.ssfx_get_setting(module_id, "multi_walk", ssfx_rain_footsteps_settings)
|
|
ssfx_rf_vol_multi_run = ssfx_001_mcm.ssfx_get_setting(module_id, "multi_run", ssfx_rain_footsteps_settings)
|
|
|
|
ssfx_rf_jump_vol = ssfx_001_mcm.ssfx_get_setting(module_id, "jump_vol", ssfx_rain_footsteps_settings)
|
|
ssfx_rf_land_vol = ssfx_001_mcm.ssfx_get_setting(module_id, "land_vol", ssfx_rain_footsteps_settings)
|
|
|
|
end
|
|
|
|
function on_game_start()
|
|
|
|
-- General Functions
|
|
RegisterScriptCallback("actor_on_first_update", actor_on_first_update)
|
|
RegisterScriptCallback("on_option_change", on_option_change)
|
|
RegisterScriptCallback("on_game_load", on_game_load)
|
|
|
|
-- Actor Actions
|
|
RegisterScriptCallback("actor_on_weapon_zoom_in", ssfx_aim_in)
|
|
RegisterScriptCallback("actor_on_weapon_zoom_out", ssfx_aim_out)
|
|
RegisterScriptCallback("actor_on_jump", actor_on_jump)
|
|
RegisterScriptCallback("actor_on_land", actor_on_land)
|
|
RegisterScriptCallback("actor_on_footstep",actor_on_footstep)
|
|
|
|
-- Read and apply settigns
|
|
on_option_change()
|
|
end |