Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- -- 1 2 3 4 5 6 7 8 9 10 11 12 13
- --modelData: { sceneID, x, y, z, o, scale, alpha, [{ enabled[,omni,dirX,dirY,dirZ,ambIntensity[,ambR,ambG,ambB[,dirIntensity[,dirR,dirG,dirB]]]] }], sequence, widthSquish, heightSquish, path, [referenceID] }
- --[[ DOCUMENTATION:
- sceneID: number - on which scene it's supposed to show up
- x: number - moves the model left and right \
- y: number - moves the model up and down | if the model doesn't show up at all try moving it around sometimes it will show up | blue white box: wrong path | no texture: texture is set through dbc, needs to be hardcoded | green texture: no texture
- z: number - moves the model back and forth /
- o: number - the orientation in which direction the model will face | number in radians | math.pi = 180° | math.pi * 2 = 360° | math.pi / 2 = 90°
- scale: number - used to scale the model | 1 = normal size | does not scale particles of flames for example on no camera models, use width/heightSquish for that
- alpha: number - opacity of the model | 1 = 100% , 0 = 0%
- light: table - table containing light data (look in light documentation for further explanation) | is optional
- sequence: number - the animation that should be played after the model is loaded
- widthSquish: number - squishes the model on the X axis | 1 = normal
- heightSquish: number - squishes the model on the Y axis | 1 = normal
- path: number - the path to the model ends with .mdx
- referenceID: number - mainly used for making changes while the scene is playing | example:
- local m = GetModel(1) <- GetModel(referenceID) the [1] to use the first model with this referenceID without it it would be a table with all models inside
- if m then
- m = m[1]
- local x,y,z = m:GetPosition()
- m:SetPosition(x-0.1,y,z) <- move the model -0.1 from it's current position on the x-axis
- end
- ]]
- --[[ LIGHT:
- enabled: number - appears to be 1 for lit and 0 for unlit
- omni: number - ?? (default of 0)
- dirX, dirY, dirZ: numbers - vector from the origin to where the light source should face
- ambIntensity: number - intensity of the ambient component of the light source
- ambR, ambG, ambB: numbers - color of the ambient component of the light source
- dirIntensity: number - intensity of the direct component of the light source
- dirR, dirG, dirB: numbers - color of the direct component of the light source
- ]]
- --[[ METHODS:
- GetModelData(referenceID / sceneID, (bool) get-all-scene-models) table - gets the model data table out of ModelList (returns a table with all model datas that have the same referenceID) or if bool is true from the scene
- GetModel(referenceID / sceneID, (bool) get-all-scene-models) table - gets all models with the same referenceID or the same sceneID (if bool is true)
- SetScene(sceneID) nil - sets the current scene to the sceneID given to the function
- GetScene() sceneID, sceneData, models, modeldatas - gets all information of the scene
- ]]
- --[[ CREDITS:
- Made by Mordred P.H.
- Thanks to:
- Soldan - helping me with all the model work
- Chase - finding a method to copy cameras on the fly
- Blizzard - for making it almost impossible to make it work properly
- ]]
- -------------------------------------------------------------------------
- -- 1 2
- --sceneData: {time_in_seconds, background_path} --> (index is scene id)
- local ModelList = {
- max_scenes = 5, -- number of scenes you use to shuffle through
- fade_duration = 1, -- fade animation duration in seconds (to next scene if more than 1 exists)
- sceneData = {
- {30,"Interface/LoginScreen/Background_1.blp"}, --30
- {20,"Interface/LoginScreen/Background_2.blp"}, --20
- {15,"Interface/LoginScreen/Background_3.blp"}, --15
- {20,"Interface/LoginScreen/Background_4.blp"}, --notdone
- {20,"Interface/LoginScreen/Background_5.blp"}, --20
- },
- {1, 0, 0, 0, -math.pi/2, 0.7, 1, _, 4, 1, 1, "Creature\\Icecrownfleshbeast\\icecrownfleshbeast.mdx", 1},
- {2, 0, 0, 0, 1.3+math.pi/2, 1, 1, _, 0, 1, 1, "Creature\\Boneguard\\boneguard.mdx", 2},
- {3, -20, 0.5, -0.35, -2.5+math.pi, 1, 1, _, 0, 1, 1, "Creature\\Madscientist\\madscientist.mdx", 3},
- {4, 0, 0, 0, 0, 1, 1, _, 0, 1, 1, "Creature\\Skeletonmage\\skeletonmage.mdx", 4},
- {4, 0, 0, 0, 0, 1, 1, _, 0, 1, 1, "Creature\\Skeletonmage\\skeletonmage.mdx", 6},
- {4, 0, 0, 0, 0, 1, 1, _, 0, 1, 1, "Creature\\Skeletonmage\\skeletonmage.mdx", 5},
- {4, 0, 0, 0, 0, 1, 1, _, 0, 1, 1, "Creature\\Skeletonmage\\skeletonmage.mdx", 6},
- {4, 0, 0, 0, 0, 1, 1, _, 0, 1, 1, "Creature\\Skeletonmage\\skeletonmage.mdx", 4},
- {5, 0, 0, 0, -0.6, 0.4, 1, _, 0, 1, 1, "Creature\\CryptLord\\CryptLordHardcoded.mdx", 7}
- }
- local use_random_starting_scene = false
- local shuffle_scenes_randomly = false
- local show_debug_button = true -- for testing events instead timed based by just pressing a button. also let's you use fprint(...) for printing on the button text
- local login_music_path = "Interface\\LoginScreen\\LoginMusic.wav" -- path to the music (should be always the same if not using a wow song)
- local login_music_time_in_seconds = 303 -- minutes * 60 + seconds
- ----------------------------------------------------------------------------- end of configuration part ----------------------------------------------------------------------------------------------
- local width, height = GlueParent:GetSize()
- local current = 1
- PlayMusic(login_music_path)
- function randomScene()
- return math.random(time()) % ModelList.max_scenes + 1
- end
- if use_random_starting_scene then
- current = randomScene()
- end
- -- main frame for displaying and positioning of the whole loginscreen
- LoginScene = CreateFrame("Frame",nil,AccountLogin)
- LoginScene:SetSize(width, (width/16)*9)
- LoginScene:SetPoint("CENTER", AccountLogin, "CENTER", 0,0)
- LoginScene:SetFrameStrata("LOW")
- -- main background that changes according to the scene
- LoginScreenBackground = LoginScene:CreateTexture(nil,"LOW")
- LoginScreenBackground:SetPoint("TOPRIGHT", LoginScene, "TOPRIGHT", 0, 125)
- LoginScreenBackground:SetPoint("BOTTOMLEFT", LoginScene, "BOTTOMLEFT", -1, -125)
- LoginScreenBlackBoarderTOP:SetPoint("BOTTOMLEFT", LoginScene, "TOPLEFT", 0,0)
- LoginScreenBlackBoarderTOP:SetPoint("BOTTOMRIGHT", LoginScene, "TOPRIGHT", 0,0)
- LoginScreenBlackBoarderBOTTOM:SetPoint("TOPLEFT", LoginScene, "BOTTOMLEFT", 0,0)
- LoginScreenBlackBoarderBOTTOM:SetPoint("TOPRIGHT", LoginScene, "BOTTOMRIGHT", 0,0)
- M = {}
- function newScene()
- local s = {parent = CreateFrame("Frame",nil,LoginScene),
- background = ModelList.sceneData[#M+1 or 1][2],
- duration = ModelList.sceneData[#M+1 or 1][1]}
- s.parent:SetSize(LoginScene:GetWidth(), LoginScene:GetHeight())
- s.parent:SetPoint("CENTER")
- s.parent:SetFrameStrata("MEDIUM")
- table.insert(M, s)
- return M[#M]
- end
- function newModel(parent,alpha,light,wSquish,hSquish,path)
- local mod = CreateFrame("Model",nil,parent)
- light = light or {1, 0, 0, -0.707, -0.707, 0.7, 1.0, 1.0, 1.0, 0.8, 1.0, 1.0, 0.8}
- mod:SetModel("Character\\Human\\Male\\HumanMale.mdx")
- mod:SetSize(LoginScene:GetWidth() / wSquish, LoginScene:GetHeight() / hSquish)
- mod:SetPoint("CENTER")
- mod:SetCamera(1)
- mod:SetLight(unpack(light))
- mod:SetAlpha(alpha)
- return mod
- end
- function Generate_M()
- ModelList.generate_scenes = #ModelList.sceneData
- for i=1, ModelList.generate_scenes do
- local s = newScene()
- for num, m in pairs(ModelList) do
- if type(m)=="table" and num ~= "sceneData" then
- if m[1] == i then
- table.insert(s, num, newModel(s.parent, m[7], m[8], m[10], m[11], m[12]))
- end
- end
- end
- if i ~= current then
- s.parent:Hide()
- else
- LoginScreenBackground:SetTexture(s.background)
- end
- end
- end
- Generate_M()
- if show_debug_button then
- testbutton:Show()
- end
- function fprint(dat)
- testbutton:SetText(width.." "..height)
- end
- ------- updating and methods
- local timed_update, nextC, nextCset
- local blend_timer, music_timer, blend_start = 0, 0, 0
- function LoginScreen_OnUpdate(self,dt)
- if music_timer > login_music_time_in_seconds then -- Music timer to loop the background music
- PlayMusic(login_music_path)
- else
- music_timer = music_timer + dt
- end
- if blend_start then -- Start blend after the loginscreen loaded to hide the setting up frame
- if blend_start < 0.5 then
- LoginScreenBlend:SetAlpha( 1 - blend_start*2 )
- blend_start = blend_start + dt
- else
- LoginScreenBlend:SetAlpha(0)
- blend_start = false
- end
- end
- if timed_update == true then -- 2 frames delayed update to hackfix some errors with blizzard masterrace code
- for num, m in pairs(ModelList) do
- if type(m)=="table" and num ~= "sceneData" and m[1] <= ModelList.max_scenes then
- local mod = M[m[1]][num]
- mod:SetModel(m[12])
- mod:SetPosition(m[4], m[2], m[3])
- mod:SetFacing(m[5])
- mod:SetModelScale(m[6])
- mod:SetSequence(m[9])
- end
- end
- blend_start = 0
- timed_update = false
- elseif timed_update == nil then
- timed_update = true
- end
- local cur = M[current]
- if cur.duration < blend_timer then -- Scene and blend timer for next scene and blends between the scenes
- if ModelList.max_scenes > 1 then
- local blend = blend_timer - cur.duration
- if blend < ModelList.fade_duration then
- LoginScreenBlend:SetAlpha( 1 - math.abs( 1 - (blend*2 / ModelList.fade_duration) ) )
- if blend*2 > ModelList.fade_duration and not nextCset then
- nextC = randomScene()
- if shuffle_scenes_randomly then
- if current == nextC then
- nextC = ((current+1 > ModelList.max_scenes) and 1) or current + 1
- end
- else
- nextC = ((current+1 > ModelList.max_scenes) and 1) or current + 1
- end
- nextCset = true
- local new = M[nextC]
- cur.parent:Hide()
- new.parent:Show()
- LoginScreenBackground:SetTexture(new.background)
- Scene_OnEnd(current)
- Scene_OnStart(nextC)
- end
- blend_timer = blend_timer + dt
- else
- current = nextC
- nextCset = false
- blend_timer = 0
- LoginScreenBlend:SetAlpha(0)
- end
- else
- blend_timer = 0
- Scene_OnEnd(current)
- Scene_OnStart(current)
- end
- else
- blend_timer = blend_timer + dt
- end
- SceneUpdate(dt, current, blend_timer, ModelList.sceneData[current][1])
- end
- function SetScene(sceneID)
- M[current].parent:Hide()
- M[sceneID].parent:Show()
- LoginScreenBackground:SetTexture(M[sceneID].background)
- Scene_OnEnd(current)
- Scene_OnStart(sceneID)
- current = sceneID
- end
- function GetScene()
- return current, ModelList.sceneData[current], GetModel(current, true), GetModelData(current, true)
- end
- function GetModelData(refID, allSceneModels)
- local data, count = {}, 0
- if allSceneModels then
- for num, m in pairs(ModelList) do
- if type(m)=="table" and num ~= "sceneData" then
- if m[1] == refID then
- table.insert(data, num, m)
- count = count + 1
- end
- end
- end
- return (count > 0 and data) or false
- else
- for num, m in pairs(ModelList) do
- if type(m)=="table" and num ~= "sceneData" then
- if m[13] == refID then
- table.insert(data, num, m)
- count = count + 1
- end
- end
- end
- return (count > 0 and data) or false
- end
- end
- function GetModel(refID, allSceneModels)
- local data, count = {} ,0
- if allSceneModels then
- for num, m in pairs(ModelList) do
- if type(m)=="table" and num ~= "sceneData" then
- if m[1] == refID then
- table.insert(data, M[m[1]][num])
- count = count + 1
- end
- end
- end
- return (count > 0 and data) or false
- else
- local mData = GetModelData(refID)
- if mData then
- for num, m in pairs(mData) do
- table.insert(data, M[m[1]][num])
- count = count + 1
- end
- return (count > 0 and data) or false
- else
- return false
- end
- end
- end
- -- test button for debugging
- function test_click()
- fprint(strlower(AccountLoginAccountEdit:GetText()))
- end
- ------------------------------------------------------------------------------------------------------
- ------ SCENE SCRIPTING PART ------
- ------------------------------------------------------------------------------------------------------
- -- update function that gets called each frame
- local anim = false
- function SceneUpdate(dt, sceneID, timer, sceneTime)
- if sceneID == 1 then
- local m = GetModel(1)
- if m then
- m = m[1]
- local way = 30/sceneTime
- local x,y,z = m:GetPosition()
- m:SetPosition(x,y - way*dt,z)
- end
- elseif sceneID == 2 then
- local m = GetModel(2)
- if m then
- m = m[1]
- if timer > 17.1 and timer < 17.6 then
- local turn = math.pi*((timer-17.1)*7)
- m:SetFacing(m:GetFacing() - turn*dt)
- end
- if timer > 17 and not anim then
- m:SetSequence(55)
- anim = true
- end
- end
- elseif sceneID == 3 then
- local m = GetModel(3)
- if m then
- m = m[1]
- if timer >= 12.7 and timer < 12.8 and strlower(AccountLoginAccountEdit:GetText()) ~= "moonwalk" then
- m:SetFacing(-2.6)
- end
- if timer > 12.8 and timer < 16 then
- local way = 0.7*dt
- local x,y,z = m:GetPosition()
- m:SetPosition(x-way/2,y-way,z+way/8)
- m:SetSequenceTime(4, (timer-12.8)*700)
- end
- end
- end
- end
- -- on end function that gets called when the scene ends
- function Scene_OnEnd(sceneID)
- if sceneID == 1 then
- local m = GetModel(1)
- if m then
- m = m[1]
- local mData = GetModelData(1)[1]
- m:SetPosition(mData[4], mData[2], mData[3])
- end
- end
- anim = false
- end
- -- on start function that gets called when the scene starts
- function Scene_OnStart(sceneID)
- anim = false
- if sceneID == 2 then
- local m = GetModel(2)
- if m then
- m = m[1]
- m:SetFacing(1.3+math.pi/2)
- m:SetSequence(0)
- end
- elseif sceneID == 3 then
- local m = GetModel(3)
- if m then
- m = m[1]
- m:SetFacing(-2.5+math.pi)
- m:SetSequence(0)
- m:SetPosition(-20, 0.5, -0.35)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement