local dented = {} local exploded = {} local explode_decal = {} local smoke_decal = {} local oil_decal = {} local health = {} local state = {} local perc = {} local smoke_size = {} local explosion_size = {} local oil_size = {} --settings to adjust the decal starting and finishing sizes local min_smoke_size = 200 local max_smoke_size = 1300 local min_explosion_size = 700 local max_explosion_size = 710 local min_oil_size = 100 local max_oil_size = 600 function barrel_explode_custom_init_name(e,name) weapon_name[e] = tonumber(name) state[e] = "clean" smoke_size[e] = min_smoke_size explosion_size[e] = min_explosion_size oil_size[e] = min_oil_size --scale of the barrel (shouldnt be needed, just used to reset the barrel for testing) Scale(e,100) end function barrel_explode_custom_main(e) --Prompt(g_Entity[e]['health'] - 5000) if health[e] == nil then perc[e] = g_Entity[e]['health'] * (weapon_name[e] / 100) health[e] = 5000+g_Entity[e]['health'] SetEntityHealth(e,5000+g_Entity[e]['health']) else if dented[e] == nil then for a = 1,99999 do if g_Entity[a] ~= nil then if weapon_name[a] ~= nil then if weapon_name[a] == "dented barrel" then if GetDistance(e,a) < 55 then dented[e] = a end elseif weapon_name[a] == "barrel dead" then if GetDistance(e,a) < 55 then exploded[e] = a end end end end end else if explode_decal[e] == nil then for a = 1,99999 do if g_Entity[a] ~= nil then if weapon_name[a] ~= nil then if weapon_name[a] == "explosion decal" then if GetDistance(e,a) < 55 then explode_decal[e] = a end elseif weapon_name[a] == "smoke decal" then if GetDistance(e,a) < 55 then smoke_decal[e] = a end elseif weapon_name[a] == "oil decal" then if GetDistance(e,a) < 55 then oil_decal[e] = a end end end end end else if state[e] == "clean" then if g_Entity[e]['health'] - 5000 < perc[e] then --Hide(e) Scale(e,60) Show(dented[e]) state[e] = "dented" end elseif state[e] == "dented" then if g_Entity[e]['health'] < 5000 then StartTimer(e) SetEntityHealth(dented[e],0) Show(exploded[e]) Show(explode_decal[e]) Show(smoke_decal[e]) Show(oil_decal[e]) state[e] = "explode" end elseif state[e] == "explode" then Scale(smoke_decal[e],smoke_size[e]) Scale(explode_decal[e],explosion_size[e]) Scale(oil_decal[e],oil_size[e]) if GetTimer(e) > 1 then if smoke_size[e] < max_smoke_size then smoke_size[e] = smoke_size[e] + 1 end if oil_size[e] < max_oil_size then oil_size[e] = oil_size[e] + 1 end if explosion_size[e] < max_explosion_size then explosion_size[e] = explosion_size[e] + 1 else Hide(explode_decal[e]) end StartTimer(e) end if explosion_size[e] == max_explosion_size and smoke_size[e] == max_smoke_size and oil_size[e] == max_oil_size then Hide(e) Hide(exploded[e]) Hide(explode_decal[e]) Hide(oil_decal[e]) Hide(smoke_decal[e]) --PromptDuration("finished",2000) end end --state end --decals set end --other barrels set end --health set end --main function barrel_explode_custom_exit(e) end function GetDistance(e,v) if g_Entity[e] ~= nil and g_Entity[e] ~= 0 and g_Entity[v] ~= nil and g_Entity[v] ~= 0 then local disx = g_Entity[e]['x'] - g_Entity[v]['x'] local disz = g_Entity[e]['z'] - g_Entity[v]['z'] local disy = g_Entity[e]['y'] - g_Entity[v]['y'] return math.sqrt(disx^2 + disz^2 + disy^2) end end