Divergent/mods/TBs Angry Chimera Growls/gamedata/scripts/TB_Angry_Lurker_Growls.script

72 lines
2.6 KiB
Plaintext
Raw Permalink Normal View History

2024-03-17 20:18:03 -04:00
--Tweaki_Breeki's
----_____-------------------_-_-------------------------------------------------_----------------_-------------------
---/-____|-----------------|-(_)-----------------/\----------------------------|-|--------------|-|------------------
--|-|--__-_-__-_____------_|-|_-_-__---__-_-----/--\---_-__---__-_-_-__-_---_--|-|----_---_-_-__|-|-_____-_-__-___---
--|-|-|_-|-'__/-_-\-\-/\-/-/-|-|-'_-\-/-_`-|---/-/\-\-|-'_-\-/-_`-|-'__|-|-|-|-|-|---|-|-|-|-'__|-|/-/-_-\-'__/-__|--
--|-|__|-|-|-|-(_)-\-V--V-/|-|-|-|-|-|-(_|-|--/-____-\|-|-|-|-(_|-|-|--|-|_|-|-|-|___|-|_|-|-|--|---<--__/-|--\__-\--
---\_____|_|--\___/-\_/\_/-|_|_|_|-|_|\__,-|-/_/----\_\_|-|_|\__,-|_|---\__,-|-|______\__,_|_|--|_|\_\___|_|--|___/--
---------------------------------------__/-|------------------__/-|------__/-|---------------------------------------
--------------------------------------|___/------------------|___/------|___/----------------------------------------
--Version 1.1
--05/08/2021
--This file should be in gamedata\scripts\
--Checks the level for Lurkers, adds them to a table, randomly iterates through them every 2.5 - 5.0 seconds, if they are alive and angry at something then play a random growl sound at their position!
--Rechecks level for any newly spawned Lurkers every 60 seconds.
--All growl sounds made me using the existing Lurker sound files.
local tb_angry_check = 0
local tb_recount_lurks = 0
local lastlurk = 0
local tb_growl_snd = sound_object("tb_growls\\tb_lurk_1")
tb_lurkers = {}
function actor_on_first_update()
collect_all_lurkers()
end
function actor_on_update()
local tg = time_global()
if (tg > tb_angry_check) then
tb_angry_check = tg + math.random(2500,5000)
if #tb_lurkers ~= 0 then
checkangrylurkers()
end
end
if (tg > tb_recount_lurks) then
tb_recount_lurks = tg + 60000
collect_all_lurkers()
end
end
function checkangrylurkers()
local randlurk = tb_lurkers[math.random(#tb_lurkers)][2]
local objpos = randlurk:position()
if randlurk:get_enemy() then
tb_growl_snd = sound_object("tb_growls\\tb_lurk_" .. tostring(math.random(1,8)))
if tb_growl_snd:playing() then
tb_growl_snd:stop()
end
tb_growl_snd:play_at_pos(se_obj,objpos,0,sound_object.s3d)
end
end
function collect_all_lurkers()
tb_lurkers = {}
for i=1, 65534 do
local se_obj = level.object_by_id(i)
if se_obj then
local objsec = se_obj:section()
if string.find(objsec,"lurker") then
if se_obj:is_monster() then
table.insert(tb_lurkers,{i,se_obj})
end
end
end
end
end
function on_game_start()
RegisterScriptCallback("actor_on_first_update",actor_on_first_update)
RegisterScriptCallback("actor_on_update", actor_on_update)
end