-- 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 then -- PromptLocal(e, dancer.name .. ", " .. xoff .. ", " .. zoff) -- end 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 -- local frame = GetAnimationFrame(e) -- if frame_number[e] ~= frame then -- frame_number[e] = frame -- time_last_frame[e] = time_this_frame[e] -- time_this_frame[e] = g_Time -- end -- -- Prompt((time_this_frame[e] - time_last_frame[e]) .. ", " .. frame) -- PromptLocal(e, frame) -- if sequence_num[e] == 1 then -- if sequence_timer[e] == 0 and frame == 1048 then -- sequence_timer[e] = g_Time + 35 -- sequence_num[e] = 2 -- end -- return -- end -- if sequence_num[e] == 2 then -- if g_Time >= sequence_timer[e] then -- StopAnimation(e) -- SendMessageI("collisionoff",e) -- dancer_location[e].z = dancer_location[e].z - 154 -- dancer_location[e].x = dancer_location[e].x - 3 -- SetAnimationFrame(e,1049) -- SetPosition(e, dancer_location[e].x, dancer_location[e].y, dancer_location[e].z) -- SendMessageI("collisionon",e) -- sequence_num[e] = 3 -- end -- end -- if sequence_num[e] == 3 then -- SetAnimationFrames(1049, 1614) -- PlayAnimation(e) -- sequence_num[e] = 4 -- sequence_timer[e] = 0 -- return -- end -- -- if sequence_num[e] == 4 then -- if sequence_timer[e] == 0 and frame == 1614 then -- sequence_timer[e] = g_Time + 35 -- sequence_num[e] = 5 -- end -- return -- end -- if sequence_num[e] == 5 then -- if g_Time >= sequence_timer[e] then -- StopAnimation(e) -- SendMessageI("collisionoff",e) -- dancer_location[e].z = dancer_location[e].z - 147 -- dancer_location[e].x = dancer_location[e].x + 20 -- SetAnimationFrame(e, 1615) -- SetPosition(e, dancer_location[e].x, dancer_location[e].y, dancer_location[e].z) -- SendMessageI("collisionon",e) -- sequence_num[e] = 6 -- end -- return -- end -- if sequence_num[e] == 6 then -- SetAnimationFrames(1615, 2382) -- PlayAnimation(e) -- sequence_num[e] = 7 -- sequence_timer[e] = 0 -- return -- end -- if sequence_num[e] == 7 then -- if sequence_timer[e] == 0 and frame == 2382 then -- sequence_timer[e] = g_Time + 35 -- sequence_num[e] = 8 -- end -- return -- end -- if sequence_num[e] == 8 then -- if g_Time >= sequence_timer[e] then -- StopAnimation(e) -- SendMessageI("collisionoff",e) -- dancer_location[e].z = dancer_location[e].z + 164 -- dancer_location[e].x = dancer_location[e].x - 40 -- SetAnimationFrame(e, 2383) -- SetPosition(e, dancer_location[e].x, dancer_location[e].y, dancer_location[e].z) -- SendMessageI("collisionon",e) -- sequence_num[e] = 9 -- end -- return -- end -- if sequence_num[e] == 9 then -- SetAnimationFrames(2383, 3495) -- PlayAnimation(e) -- sequence_num[e] = 10 -- sequence_timer[e] = 0 -- return -- end -- if sequence_num[e] == 10 then -- if frame == 3494 then -- StopAnimation(e) -- sequence_num[e] = 11 -- end -- end end