Divergent/mods/Asnens and Groks Better Cig.../gamedata/scripts/ciga_effects.script

59 lines
1.6 KiB
Plaintext
Raw Normal View History

2024-03-17 20:18:03 -04:00
--[[
cigarettes smoke effect script
Author: Feel_Fried
--]]
local smoke = false
local ltx = ini_file("items\\items\\anims_cigga_smoke.ltx")
local function create_smoke()
if not smoke then
smoke = particles_object("vehiclefx\\exhaust_3")
local dir2 = device().cam_dir
smoke:set_direction(dir2)
smoke:play_at_pos(db.actor:bone_position("jaw_1"))
end
return true
end
local function move_smoke()
if smoke then
local dir2 = device().cam_dir
local pos = device().cam_pos
pos.y = pos.y - 0.35 + 0.3*dir2.y
pos.x = pos.x + 0.3*dir2.x
pos.z = pos.z + 0.3*dir2.z
smoke:set_direction(dir2)
smoke:move_to(pos, dir2)
return false
else
return true
end
end
local function destroy_smoke()
if smoke then
smoke:stop()
smoke = nil
end
return true
end
function ciga_start(used_item)
CreateTimeEvent("ea_cig_light","ea_cig_light",4.0,ea_light.light_on,1,0.9,0.2,1,0.1,0.15,0.25,0.2)
CreateTimeEvent("ea_cig_light2","ea_cig_light2",4.4,ea_light.light_on,0.8,0.5,0,3,0.5,1.3,0.7,0.1)
local t = {}
if not ltx:section_exist(used_item) then return end
local lines = ltx:line_count(used_item)
if lines % 2 ~= 0 then return end
local variable, value, result, i = "", "", "", ""
for current_line = 0, lines - 1 do
i = current_line+1
result, variable, value = ltx:r_line(used_item, current_line, "", "")
t[i] = value
if i % 2 == 0 then
CreateTimeEvent("ea_s_c".. i, "ea_s_c" .. i, t[current_line], create_smoke)
CreateTimeEvent("ea_s_m".. i, "ea_s_m".. i, t[current_line] + 0.050, move_smoke)
CreateTimeEvent("ea_s_d".. i, "ea_s_d".. i, t[i], destroy_smoke)
end
end
end