#include "script/common.lua" #include "starthub.lua" DURATION = GetFloatParam("time", 10) LETTERBOX = GetBoolParam("letterbox", false) time = 0 hasCamera = false fontsInititated = false musicStarted = false function remap(value, x1, y1, x2, y2) local l = x2 - x1 local a = (clamp(value, x1, x2) - x1)/l return y1 + (y2 - y1) * a end pressedTimer = 0.0 function checkInputs() local key = InputLastPressedKey() if key ~= "" then return true else return InputPressed("interact") or InputPressed("usetool") or InputPressed("jump") or InputPressed("pause") end end function init() local locs = FindLocations() if #locs >= 2 then hasCamera = true camStart = GetLocationTransform(locs[1]) camEnd = GetLocationTransform(locs[2]) end end function tick(dt) pressedTimer = pressedTimer - dt if (pressedTimer > 0.0 and checkInputs()) or GetBool("savegame.mod.cinematic.complete") then exitSequence(); end if checkInputs() then pressedTimer = 4.0 end if fontsInititated and not musicStarted then -- Start music after loading fonts if not GetBool("savegame.mod.cinematic.complete") then PlayMusic("MOD/script/intro/intro.ogg") end musicStarted = true end if musicStarted then time = time + dt if hasCamera then local t = time/(DURATION-1.5) t = clamp(t, 0.0, 1.0) local cam = Transform(VecLerp(camStart.pos, camEnd.pos, t), QuatSlerp(camStart.rot, camEnd.rot, t)) SetCameraTransform(cam) end UiMute(1) if not done then if time > DURATION then exitSequence() end end end end function exitSequence() SetBool("savegame.mod.cinematic.complete",true) startHub() done = true end function draw() local black = math.max(remap(time, 0.0, 1.0, 2.0, 0.0), remap(time, DURATION - 3.0, 0.0, DURATION - 1.5, 1.0)) UiPush() UiColor(0,0,0, black) UiRect(UiWidth(), UiHeight()) UiPop() if not fontsInititated then --just to remove font load stutter UiColor(0,0,0) UiFont("bold.ttf", 30) UiText("Freya Woo in ART VANDALS") UiFont("bold.ttf", 24) UiText("Freya Woo in ART VANDALS") fontsInititated = true end if pressedTimer > 0.0 then UiPush() UiFont("bold.ttf", 24) local alpha = math.min(pressedTimer, 0.5) / 0.5 UiColor(1,1,1, alpha) UiTranslate(UiWidth()/2, UiHeight() - 110) UiAlign("center") UiText("Press again to skip") UiPop() end if LETTERBOX then UiPush() UiColor(0,0,0) UiRect(UiWidth(), 100) UiTranslate(0, UiHeight()-100) UiRect(UiWidth(), 100) UiPop() end if time > 4.2 then UiPush() UiAlign("center") local f0 = DURATION - 0.5 local f1 = DURATION - 0.3 local t = f1 - f0 local c = remap(time, DURATION-1.5, 1.0, DURATION-1.0, 0.0) UiColor(c,c,c) UiFont("bold.ttf", 30) UiTranslate(UiCenter(), UiMiddle()) UiTranslate(0,-40) UiText("Freya Woo in",true) UiTranslate(0, 50) if time > 6.3 then UiScale(3.3) UiText("ART VANDALS") end UiPop() end end