include( "NameFinder.lua" ) include( "Stage2.lua" ) class 'Intro' (State) function Intro:__init( ) --Creating The Vars starbase = EntityFinder( function(e) return e:isType(Entity.Type.GameObject) and e.label == "starbase" end ):findOne() const = EntityFinder( function(e) return e:isType(Entity.Type.GameObject) and e.label == "const" end ):findOne() freight = EntityFinder( function(e) return e:isType(Entity.Type.GameObject) and e.label == "freight" end ):findOne() repair = EntityFinder( function(e) return e:isType(Entity.Type.GameObject) and e.label == "repair" end ):findOne() dil = EntityFinder( function(e) return e:isType(Entity.Type.GameObject) and e.label == "dil" end ):findOne() tri = EntityFinder( function(e) return e:isType(Entity.Type.GameObject) and e.label == "tri" end ):findOne() end function Intro:onEnter( machine ) self.stateMachine = machine Cineractive.active = true Cineractive.skippable = true Cineractive:fadeIn( 5.0 ) Objectives:load( "Tutorial1Stage1Objectives.txt" ) UI:addTitle( "Star Trek Armada II: Fleet Operations", 50, 50, 3.0, true ) UI:addSubtitle( "Tutorial I: Economy & Construction", 50, 100, 4.0, true ) Media:playMusic( "PremonitionsIntroMusic.ogg" ) function Cin0( hook, arg) if starbase.valid then Cineractive:fadeIn( 3.0 ) Cineractive:lookFrom( Path("path_1"), 0.525 ) Cineractive:lookAt( starbase ) UI:addTitle( "Federation Outpost", 700, 1000, 3.0, true ) end end function Cin1( hook, arg) if const.valid then Cineractive:fadeIn( 1.0 ) Cineractive:lookFrom( Path("path_2"), 0.25 ) Cineractive:lookAt( const ) UI:addTitle( "Mediterranean Class", 700, 1000, 3.0, true ) end end function Cin2( hook, arg) if freight.valid then Cineractive:fadeIn( 1.0 ) Cineractive:lookFrom( Path("path_3"), 0.25 ) Cineractive:lookAt( freight ) UI:addTitle( "Mandril Class", 700, 1000, 3.0, true ) end end function Cin3( hook, arg) if repair.valid then Cineractive:fadeIn( 1.0 ) Cineractive:lookFrom( Path("path_4"), 0.25 ) Cineractive:lookAt( repair ) UI:addTitle( "Newton Class", 700, 1000, 3.0, true ) end end function KillCin1() Cineractive.active = false Camera:center( starbase ) Objectives:load( "Tutorial1Stage1Objectives.txt" ) Objectives.visible = true --Mission:finish( true, 0 ) end function CinFade() Cineractive:fadeOut( 1.0 ) end --Where all the cinematic jazz happens... local Cin0Timer = Timer( "Cin0", 0, Timer.State.Started ):hook( "Cin0", self, Cin0, nil ) local fadeTimer = Timer( "fader", 14, Timer.State.Started ):hook( "fader", nil, CinFade, nil ) local Cin1Timer = Timer( "Cin1", 15, Timer.State.Started ):hook( "Cin1", self, Cin1, nil ) local fadeTimer = Timer( "fader", 29, Timer.State.Started ):hook( "fader", nil, CinFade, nil ) local Cin2Timer = Timer( "Cin2", 30, Timer.State.Started ):hook( "Cin2", self, Cin2, nil ) local fadeTimer = Timer( "fader", 44, Timer.State.Started ):hook( "fader", nil, CinFade, nil ) local Cin3Timer = Timer( "Cin3", 45, Timer.State.Started ):hook( "Cin3", self, Cin3, nil ) local fadeTimer = Timer( "fader", 59, Timer.State.Started ):hook( "fader", nil, CinFade, nil ) local KCinTimer = Timer( "KCin1", 60, Timer.State.Started ):hook( "KCin1", nil, KillCin1, nil ) --Down to buisness begin Stage 1... function checkDilithium( monitor, amount ) return Player( 1 ).resources.dilithium >= amount end function checkTritanium( monitor, amount ) return Player( 1 ).resources.latinum >= amount end function checkSupply( monitor, amount ) return Player( 1 ).resources.biomatter >= amount end function StorageDockDone( monitor, arg ) return EntityFinder( function(e) return e.odf == "fed_storage_dock.odf" and e.player.number == 1 end ):findOne() ~= nil end function completeObjective( monitor, hook ) Objectives.objectives[hook.argument].state = true Objectives.visible = true monitor:stop() end function checkStage1Done( monitor, arg ) return --Objectives.objectives[1].state and --Objectives.objectives[2].state and --Objectives.objectives[3].state and Objectives.objectives[4].state end function onStage1Done( monitor, hook ) Timer.stopAll( ) if starbase and starbase.valid then for _, h in pairs(starbase.hooks) do starbase:unhook(h) end end if const and const.valid then for _, h in pairs(const.hooks) do const:unhook(h) end end if freight and freight.valid then for _, h in pairs(freight.hooks) do freight:unhook(h) end end if repair and repair.valid then for _, h in pairs(repair.hooks) do repair:unhook(h) end end if dil and dil.valid then for _, h in pairs(dil.hooks) do dil:unhook(h) end end if tri and tri.valid then for _, h in pairs(tri.hooks) do tri:unhook(h) end end monitor:stop() machine:setState( Stage2() ) end function AntaresDone( monitor, arg ) return EntityFinder( function(e) return e.odf == "fed_antares_yardY.odf" and e.player.number == 1 end ):findOne() ~= nil end function PlatformDone( monitor, arg ) return EntityFinder( function(e) return e.odf == "fed_platformY.odf" and e.player.number == 1 end ):findOne() ~= nil end function completeObjective( monitor, hook ) Objectives.objectives[hook.argument].state = true Objectives.visible = true monitor:stop() end Monitor( "AntaresDone", false, nil, AntaresDone, nil ):hook( "completeObjective", MonitorHook.Type.OnTrue, nil, completeObjective, 1 ) Monitor( "PlatformDone", false, nil, PlatformDone, nil ):hook( "completeObjective", MonitorHook.Type.OnTrue, nil, completeObjective, 2 ) --Monitor( "StorageDockDone", false, nil, StorageDockDone, nil ):hook( "completeObjective", MonitorHook.Type.OnTrue, nil, completeObjective, 1 ) --Monitor( "checkDilithium", false, nil, checkDilithium, 1000 ):hook( "completeObjective", MonitorHook.Type.OnTrue, nil, completeObjective, 2 ) Monitor( "checkTritanium", false, nil, checkTritanium, 1000 ):hook( "completeObjective", MonitorHook.Type.OnTrue, nil, completeObjective, 3 ) Monitor( "checkSupply", false, nil, checkSupply, 150 ):hook( "completeObjective", MonitorHook.Type.OnTrue, nil, completeObjective, 4 ) Monitor( "checkStage1Done", false, nil, checkStage1Done, nil ):hook( "onStage1Done", MonitorHook.Type.OnTrue, nil, onStage1Done, nil ) end function Intro:onCineractiveEnd( forced ) if( forced ) then Media:stopSounds( ) Timer.stopAll( ) Cineractive.active = false Camera:center( starbase ) Objectives:load( "Tutorial1Stage1Objectives.txt" ) Objectives.visible = true end end