-- LUA Script - precede every function and global member with lowercase name of script + '_main' local U = require "scriptbank\\utillib" local rad = math.rad local velocity = 1.5 local barrel1 = { x = -20, y = -10, z = 20 } local barrel2 = { x = 20, y = -10, z = 20 } local namedEmitter = { imploder = { animSpd = 0.25, SR = 0, freq = -1, lifeMin = 3000, lifeMax = 3000, -- minX minY minZ maxX maxY maxZ offset = { 0, 0, 0, 0, 0, 0 }, speed = { 0, 0, 0, 0, 0, 0 }, rotate = { 0, 0 }, -- currently only Z rotate processed -- startMin startMax endMin endMax scale = { 6.5, 6.5, 6.5, 6.5 }, alpha = { 100, 100, 100, 100 } } } -- caller must load image local function PE_CreateNamedEmitter( name, image, frames, object ) 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 object == 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, 0, 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, object, 0, image, frames ) end return emitter end function particle_shooter_init( e ) Include( "utillib.lua" ) Hide( e ) CollisionOff( e ) end local mouseClicked = false local pe = nil local pe_image = pe_image or ParticlesLoadImage( "effectbank\\particles\\flare.dds" ) function particle_shooter_main( e ) if pe == nil then pe = PE_CreateNamedEmitter( 'imploder', pe_image, 64 ) end if g_MouseClick == 1 then if not mouseClicked then local pxp, pyp, pzp = g_PlayerPosX, g_PlayerPosY + 28, g_PlayerPosZ if GetGamePlayerStatePlayerDucking() == 1 then pyp = pyp - 18 end mouseClicked = true local paX, paY, paZ = rad( g_PlayerAngX ), rad( g_PlayerAngY ), rad( g_PlayerAngZ ); local vX, vY, vZ = U.Rotate3D ( 0, 0, velocity, paX, paY, paZ ) ParticlesSetSpeed( pe, vX, vY, vZ, vX, vY, vZ ) -- barrel 1 shot local xo, yo, zo = U.Rotate3D ( barrel1.x, barrel1.y, barrel1.z, paX, paY, paZ ) ParticlesSpawnParticle( pe, pxp + xo, pyp + yo, pzp + zo ) xo, yo, zo = U.Rotate3D ( barrel2.x, barrel2.y, barrel2.z, paX, paY, paZ ) ParticlesSpawnParticle( pe, pxp + xo, pyp + yo, pzp + zo ) end else mouseClicked = false end end