-- LUA Script - precede every function and global member with lowercase name of script + '_main' -- Default script - does nothing. -- Add this to always active entity - only one is needed local deg = math.deg local rad = math.rad local sin = math.sin local cos = math.cos local atan = math.atan2 local tan = math.tan local pi = math.pi local abs = math.abs local modf = math.modf local sqrt = math.sqrt local random = math.random local rocketsCarried = {} local pickUppableEntity = {Ent = nil} function FP_AddRocket(e) for i = 1,4 do if rocketsCarried[i] == nil then rocketsCarried[i] = e return true end end end local function Rotate3D (x, y, z, xrot, yrot, zrot) function RotatePoint2D (x, y, Ang) -- Ang in radians local Sa, Ca = sin(Ang), cos(Ang) return x*Ca - y*Sa, x*Sa + y*Ca end local NX, NY, NZ = x, y, z -- X NZ, NY = RotatePoint2D (NZ, NY, -xrot) -- Y NX, NZ = RotatePoint2D (NX, NZ, -yrot) -- Z NY, NX = RotatePoint2D (NY, NX, -zrot) return NX, NY, NZ end function fp_rocket_main_init(e) end local function doRocket(e, x, y, z, xo, yo, zo, xA, yA, zA) local XO, YO, ZO = Rotate3D (xo, yo, zo, xA, yA, zA) CollisionOff(e) SetPosition(e, x + XO, y + YO, z + ZO) SetRotation(e, deg(xA), deg(yA), deg(zA)) Show(e) CollisionOn(e) end local function displayRockets(x, y, z, xA, yA, zA) if rocketsCarried[1] ~= nil then doRocket(rocketsCarried[1], x, y, z, -20, 10, 30, xA, yA, zA) end if rocketsCarried[2] ~= nil then doRocket(rocketsCarried[2], x, y, z, -20, -20, 30, xA, yA, zA) end if rocketsCarried[3] ~= nil then doRocket(rocketsCarried[3], x, y, z, 20, 10, 30, xA, yA, zA) end if rocketsCarried[4] ~= nil then doRocket(rocketsCarried[4], x, y, z, 20, -20, 30, xA, yA, zA) end end local fireDelay = 0 function fp_rocket_main_main(e) local x, y, z = g_PlayerPosX, g_PlayerPosY + 35, g_PlayerPosZ local paX, paY, paZ = rad(g_PlayerAngX), rad(g_PlayerAngY), rad(g_PlayerAngZ) displayRockets(x, y, z, paX, paY, paZ) if g_Time > fireDelay and g_MouseClick == 1 and FP_RocketFire ~= nil then local rckt = random (1,4) if rocketsCarried[rckt] ~= nil then FP_RocketFire(rocketsCarried[rckt], paX, paY, paZ) rocketsCarried[rckt] = nil fireDelay = g_Time + 500 end end end