-- LUA Script - precede every function and global member with lowercase name of script + '_main' -- Default script - does nothing. local seqOffsets = {['Abigail'] = {xo = { -3, 20, -42}, zo = { -154, -139, 162}}, ['Bikini'] = {xo = { -3, 20, -42}, zo = { -154, -139, 162}}, ['Cagney'] = {xo = { -3, 20, -42}, zo = { -162, -139, 162}}, ['Doris'] = {xo = { -3, 20, -42}, zo = { -166, -147, 166}}, ['Freddy'] = {xo = { -3, 20, -42}, zo = { -162, -139, 162}}, ['Heath'] = {xo = { -3, 20, -42}, zo = { -154, -135, 157}}, ['Josie'] = {xo = { -3, 20, -42}, zo = { -156, -139, 162}}, ['Patrick'] = {xo = { -3, 20, -42}, zo = { -156, -139, 159}}, ['Robert'] = {xo = { -3, 20, -42}, zo = { -156, -139, 159}}, ['Stan'] = {xo = { -3, 20, -38}, zo = { -128, -110, 130}}, ['Susan'] = {xo = { -3, 20, -42}, zo = { -148, -130, 150}}, ['Workman'] = {xo = { -3, 20, -42}, zo = { -156, -139, 159}} } local frames = {[1] = {from = 155, to = 1048}, [2] = {from = 1049, to = 1614}, [3] = {from = 1615, to = 2382}, [4] = {from = 2383, to = 3494}} local animSpeed = 25 -- ms per frame local music_playing = false local dancers = {} local leadDancer = nil local xoff, zoff = 0, 0 -- debug function thriller_init_name(e, name) dancers[e] = {name = name, registered = false} SetAnimationFrames(22, 154) LoopAnimation(e) leadDancer = nil end local function moveDancer(e, dancer) local offsetx = seqOffsets[dancer.name].xo[dancer.sequenceN] local offsetz = seqOffsets[dancer.name].zo[dancer.sequenceN] local pos = dancer.pos xoff, zoff = offsetx, offsetz pos.x, pos.z = pos.x + offsetx, pos.z + offsetz SendMessageI("collisionoff",e) SetPosition(e, pos.x, pos.y, pos.z) SendMessageI("collisionon",e) end local function updateDancers() local timeNow = g_Time + 0 for k,_ in pairs(dancers) do local dancer = dancers[k] if timeNow > dancer.tActivate then dancer.tActivate = math.huge dancer.sequenceN = 1 dancer.currFrame = frames[dancer.sequenceN].from dancer.tgtFrame = frames[dancer.sequenceN].to dancer.tThisframe = timeNow + animSpeed dancer.active = true StopAnimation(k) end if dancer.active then if timeNow >= dancer.tThisframe then if dancer.currFrame == dancer.tgtFrame then if dancer.sequenceN < #frames then moveDancer(k, dancer) dancer.sequenceN = dancer.sequenceN + 1 dancer.currFrame = frames[dancer.sequenceN].from dancer.tgtFrame = frames[dancer.sequenceN].to SetAnimationFrame(k, dancer.currFrame) dancer.tThisframe = timeNow + animSpeed else StopAnimation(k) end else dancer.currFrame = dancer.currFrame + 1 SetAnimationFrame(k, dancer.currFrame) dancer.tThisframe = timeNow + animSpeed end end end end end function thriller_main(e) local dancer = dancers[e] if dancer ~= nil and dancer.registered and e ~= leadDancer then return end if leadDancer == nil then leadDancer = e end if not dancer.registered then local Ent = g_Entity[e] if Ent ~= nil then dancers[e].pos = {x = Ent.x, y = Ent.y, z = Ent.z} dancers[e].registered = true dancers[e].tActivate = g_Time + 20000 + math.random() * 60 dancers[e].active = false return end end if leadDancer == e then if not music_playing then -- LoadGlobalSound("audiobank\\music\\thriller.ogg", 1) -- PlayGlobalSound(1) music_playing = true end updateDancers() end end