-- LUA Script - precede every function and global member with lowercase name of script + '_main' local U = require "scriptbank\\utillib" local namedEmitter = { rain = { animSpd = 1, SR = 1, freq = 20, lifeMin = 1000, lifeMax = 1000, -- minX minY minZ maxX maxY maxZ offset = { -250, 200, -250, 250, 200, 250 }, speed = { 0, -4, 0, 0, -6, 0 }, rotate = { 0, 0 },-- currently only Z rotate processed -- startMin startMax endMin endMax scale = { 2, 10, 5, 15 }, alpha = { 40, 40, 20, 20 } } } -- caller must load image local function PE_CreateNamedEmitter( name, image, frames, entity ) image = image or 1 -- default to smoke frames = frames or 64 local et = namedEmitter[ name ] if et == nil then return end local emitter = ParticlesGetFreeEmitter() if emitter == -1 then return end local pos, spd, scl = et.offset, et.speed, et.scale if entity == nil then ParticlesAddEmitterEx( emitter, et.animSpd, et.SR, pos[1], pos[2], pos[3], pos[4], pos[5], pos[6], scl[1], scl[2], scl[3], scl[4], spd[1], spd[2], spd[3], spd[4], spd[5], spd[6], et.rotate[1], et.rotate[2], et.lifeMin, et.lifeMax, et.alpha[1], et.alpha[2], et.alpha[3], et.alpha[4], et.freq, -1, 0, image, frames ) else ParticlesAddEmitterEx( emitter, et.animSpd, et.SR, pos[1], pos[2], pos[3], pos[4], pos[5], pos[6], scl[1], scl[2], scl[3], scl[4], spd[1], spd[2], spd[3], spd[4], spd[5], spd[6], et.rotate[1], et.rotate[2], et.lifeMin, et.lifeMax, et.alpha[1], et.alpha[2], et.alpha[3], et.alpha[4], et.freq, entity, 0, image, frames ) end return emitter end function radiation_zone_init(e) end local radZones = {} local testImg = nil local emitter = nil local closest = { dist = math.huge, ent = 0 } local maxParticles = 800 function radiation_zone_main(e) if emitter == nil then if testImg == nil then testImg = ParticlesLoadImage( "entitybank\\decals\\Green Flare.dds", 4 ) end emitter = PE_CreateNamedEmitter( 'rain', testImg, 16 ) ParticlesSetWindVector( 0, 0 ) return end if radZones[ e ] == nil then radZones[ e ] = { nextCheck = 0 } end local timeNow = g_Time if timeNow > radZones[ e ].nextCheck then radZones[ e ].nextCheck = timeNow + 200 local dist = GetPlayerDistance( e ) if closest.ent == e then closest.dist = dist end if closest.dist > dist then closest.ent = e closest.dist = dist end if closest.ent == e then local numParticles = maxParticles - closest.dist / 2 if numParticles < 0 then numParticles = 0 end Prompt(numParticles) ParticlesSetLife( emitter, 10, 1000, 2000, numParticles , 0 ) end end end