-- LUA Script - precede every function and global member with lowercase name of script + '_main' local decals = {} local random = math.random local rad = math.rad local deg = math.deg local modf = math.modf local Q = require "scriptbank\\quatlib" function balldropdecal_init(e) Include("quatlib.lua") Hide(e) decals[e] = nil CollisionOff(e) end local function rotateToPlayer(e) -- work out player quaternion local pq = Q.FromEuler(rad(g_PlayerAngX), rad(g_PlayerAngY), rad(g_PlayerAngZ)) local randAng = random(0,179) if random(1,2) == 2 then randAng = -randAng end -- get the new Euler angles local xr, yr, zr = Q.ToEuler(Q.Mul(pq, Q.FromEuler(0,0,rad(randAng)))) ResetRotation(e, deg(xr), deg(yr), deg(zr)) end function BD_ShowDecal(e, x, y, z) for k,v in pairs(decals) do if not v.used then decals[k].used = true local timer = random(600,1200) decals[k].timer = g_Time + timer decals[k].ent = e CollisionOff(k) ResetPosition(k, x, y, z) rotateToPlayer(k) CollisionOn(k) Show(k) return end end end function balldropdecal_main(e) local thisDecal = decals[e] if thisDecal == nil then decals[e] = {used = false, hide = false, timer = math.huge, scale = 20, maxScale = random(800,1200)} return elseif thisDecal.used then if g_Time > thisDecal.timer then if thisDecal.hide then if thisDecal.scale > 20 then thisDecal.scale = modf(thisDecal.scale * 0.9) Scale(e, thisDecal.scale) else Hide(e) thisDecal.hide = false thisDecal.used = false end else if thisDecal.scale < thisDecal.maxScale then thisDecal.scale = modf(thisDecal.scale * 1.05) Scale(e, thisDecal.scale) else DropBall(thisDecal.ent) thisDecal.hide = true thisDecal.timer = g_Time + random(100,200) end end end end end