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

72 lines
2.7 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 Chimeras, 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 Chimeras every 60 seconds.
--All growl sounds made me using the existing Chimera sound files.
local tb_angry_check = 0
local tb_recount_chims = 0
local lastchim = 0
local tb_growl_snd = sound_object("tb_growls\\tb_growl_1")
tb_chimeras = {}
function actor_on_first_update()
collect_all_chimeras()
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_chimeras ~= 0 then
checkangrychimeras()
end
end
if (tg > tb_recount_chims) then
tb_recount_chims = tg + 60000
collect_all_chimeras()
end
end
function checkangrychimeras()
local randchim = tb_chimeras[math.random(#tb_chimeras)][2]
local objpos = randchim:position()
if randchim:get_enemy() then
tb_growl_snd = sound_object("tb_growls\\tb_growl_" .. 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_chimeras()
tb_chimeras = {}
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,"chimera") then
if se_obj:is_monster() then
table.insert(tb_chimeras,{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