class 'DominionStatus' (State) function DominionStatus:__init( ) end function DominionStatus:onEnter( machine ) self.stateMachine = machine --This is necessary to ensure intro cinematics or avatar choices don't repeat when loading a saved game function checkCin( monitor, arg ) return EntityFinder( function(e) return e:isType(Entity.Type.GameObject) and e.odf == "rsensorarray.odf" and e.player.number == 7 end ):findOne() == nil end --Making the intro conditional is necessary to ensure intro cinematics or avatar choices don't repeat when loading a saved game function onCin( monitor, arg ) Cineractive.active = true Cineractive.skippable = true Entity.add( "romU_shields1.odf", 1, Vector(-1000, 0, -1000) ) Entity.add( "romU_shields2.odf", 1, Vector(-1000, 0, -1000) ) local allThings99 = EntityFinder( function(e) return e:isType(Entity.Type.Craft) and e.player.number == 1 end ):find() for _, v in pairs(allThings99) do v.shields = 1.0 end --Screen will fade in over two seconds Cineractive:fadeIn( 2.0 ) --Add the title at coordinates 50, 50. It will fade in, stay and fade out over ten seconds UI:addTitle( "The Raptor's Wrath", 50, 50, 10.0, true ) --Search for entities that have this class local firstship = EntityFinder( function(e) return e:isType(Entity.Type.GameObject) and e.odf == "rlbattleship.odf" end ):findOne() Cineractive:lookFrom( Path("path_1"), 0.15 ) --200, 100, 0 is slightly above and to the right of the target Cineractive:setCameraOffset( Vector( 200, 100, 0 ) ) Cineractive:lookAt( firstship ) --Play a sound bite Timer( "introsound", 3.0, Timer.State.Started ):hook( "introsound", nil, function() end, nil ) Media:playSound("TRW_Intro.mp3") Timer( "lookAtBase1", 40.0, Timer.State.Started ):hook( "lookAtBase1", nil, function() Cineractive:lookFrom( Path("path_3"), 0.25 ) --0, 100, 0 is slightly above the target Cineractive:setCameraOffset( Vector( 0, 100, 0 ) ) Cineractive:lookAt( Vector( 12500, 100, 1100 ) ) end, nil ) Timer( "lookAtBase2", 45.0, Timer.State.Started ):hook( "lookAtBase2", nil, function() Cineractive:lookFrom( Path("path_2"), 0.25 ) --0, 100, 0 is slightly above the target Cineractive:setCameraOffset( Vector( 0, 100, 0 ) ) Cineractive:lookAt( Vector( 12500, 100, 16400 ) ) end, nil ) --This timer will go off in 50 seconds local fadeTimer = Timer( "fadeTimer", 50, Timer.State.Started ) --Hook function will fade the screen out over two seconds fadeTimer:hook( "fadeOut", nil, function(timer, hook) Cineractive:fadeOut( 2.0 ) end, nil ) --This timer will go off in 49 seconds (this will be after the screen has faded --out) local endCineractiveTimer = Timer( "endTimer", 49, Timer.State.Started ) --Hook function will end the Cineractive endCineractiveTimer:hook( "endCineractive", nil, function(timer, hook) Media:stopSounds( ) Cineractive.active = false Objectives:load( "TRW_Objectives1.txt" ) Objectives.visible = true local visionsbeacons = EntityFinder( function(e) return e:isType(Entity.Type.Craft) and e.odf == "visionbeacon.odf" end ):find() for _, v in pairs(visionsbeacons) do Entity.remove( v ) end Player( 2 ):loadAIP( "dominion_mission_build_list_simple.aip" ) Player( 3 ):loadAIP( "dominion_mission_build_list_simple.aip" ) --Add the intro cinematic object for saved games Entity.add( "rsensorarray.odf", 7, Vector(-1300, 0, -1300) ) end, nil ) end --This is necessary to ensure intro cinematics or avatar choices don't repeat when loading a saved game Monitor( "checkCin", false, nil, checkCin, nil ):hook( "onCin", MonitorHook.Type.OnTrue, nil, onCin, nil ) --Complete a specific objective. The objective number to complete is stored --in the argument field of the hook. Also shows the Objectives screen. function completeObjective( objective_num ) Objectives.objectives[objective_num].state = true Objectives.visible = true end function checkNorthernDead( monitor, arg ) return EntityFinder( function(e) return e:isType(Entity.Type.Craft) and (e.crew > 0) and (e.odf ~= "dminer.odf") and (e.player.number == 3) end ):findOne() == nil end function checkSouthernDead( monitor, arg ) return EntityFinder( function(e) return e:isType(Entity.Type.Craft) and (e.crew > 0) and (e.odf ~= "dminer.odf") and (e.player.number == 2) end ):findOne() == nil end function checkPlayerDead( monitor, arg ) return EntityFinder( function(e) return e:isType(Entity.Type.Craft) and (e.crew > 0) and (e.player.number == 1) end ):findOne() == nil end function onSouthernDead( monitor, arg ) local northernBase = EntityFinder( function(e) return e:isType(Entity.Type.Craft) and (e.crew > 0) and (e.odf ~= "dminer.odf") and (e.player.number == 3) end ):findOne() if northernBase == nil then --Stop all existing monitors so they don't interfere. Monitor.stopAll() Cineractive.active = true Cineractive.skippable = false --Screen will fade in over one second Cineractive:fadeIn( 1.0 ) UI:addTitle( "Mission Completed", 50, 50, 5.0, true ) --Play a sound bite Timer( "completesound", 2.0, Timer.State.Started ):hook( "completesound", nil, function() Media:playSound("TRW_Victory.mp3") end, nil ) local fadeTimer4 = Timer( "fadeTimer4", 10, Timer.State.Started ) --Hook function will fade the screen out over two seconds fadeTimer4:hook( "fadeOut4", nil, function(timer, hook) Cineractive:fadeOut( 2.0 ) end, nil ) local endCineractiveTimer4 = Timer( "endTimer4", 12, Timer.State.Started ) --Hook function will end the Cineractive endCineractiveTimer4:hook( "endCineractive4", nil, function(timer, hook) Cineractive.active = false --End the mission (victory) Mission:finish( true, 0 ) end, nil ) end if northernBase ~= nil then --monitor:stop() --This is necessary for saved games with objectives that can be fulfilled before the final cinematic Objectives:load( "TRW_Objectives1.txt" ) local helpthing = EntityFinder( function(e) return e:isType(Entity.Type.GameObject) and e.odf == "rdefenseplatform.odf" and e.player.number == 7 end ):findOne() if helpthing == nil then Cineractive.active = true Cineractive.skippable = false --Screen will fade in over one second Cineractive:fadeIn( 1.0 ) UI:addTitle( "Southern Base Destroyed", 50, 50, 5.0, true ) --Play a sound bite Timer( "halfsound1", 1.0, Timer.State.Started ):hook( "halfsound1", nil, function() Media:playSound("TRW_OneDown.mp3") Cineractive:lookFrom( Path("path_2"), 0.25 ) --0, 100, 0 is slightly above the target Cineractive:setCameraOffset( Vector( 0, 100, 0 ) ) Cineractive:lookAt( Vector( 12500, 100, 16400 ) ) end, nil ) local fadeTimer = Timer( "fadeTimer2", 7, Timer.State.Started ) --Hook function will fade the screen out over two seconds fadeTimer:hook( "fadeOut", nil, function(timer, hook) Cineractive:fadeOut( 2.0 ) end, nil ) local endCineractiveTimer = Timer( "endTimer", 9, Timer.State.Started ) --Hook function will end the Cineractive endCineractiveTimer:hook( "endCineractive", nil, function(timer, hook) Media:stopSounds( ) Cineractive.active = false completeObjective( 2 ) --Add the intro cinematic object for saved games Entity.add( "rdefenseplatform.odf", 7, Vector(-1300, 0, -1000) ) end, nil ) end if helpthing ~= nil then --This is necessary for saved games with objectives that can be fulfilled before the final cinematic Objectives.objectives[1].state = true end end end function onNorthernDead( monitor, arg ) local southernBase = EntityFinder( function(e) return e:isType(Entity.Type.Craft) and (e.crew > 0) and (e.odf ~= "dminer.odf") and (e.player.number == 2) end ):findOne() if southernBase == nil then --Stop all existing monitors so they don't interfere. Monitor.stopAll() Cineractive.active = true Cineractive.skippable = false --Screen will fade in over one second Cineractive:fadeIn( 1.0 ) UI:addTitle( "Mission Completed", 50, 50, 5.0, true ) --Play a sound bite Timer( "completesound", 2.0, Timer.State.Started ):hook( "completesound", nil, function() Media:playSound("TRW_Victory.mp3") end, nil ) local fadeTimer4 = Timer( "fadeTimer4", 10, Timer.State.Started ) --Hook function will fade the screen out over two seconds fadeTimer4:hook( "fadeOut4", nil, function(timer, hook) Cineractive:fadeOut( 2.0 ) end, nil ) local endCineractiveTimer4 = Timer( "endTimer4", 12, Timer.State.Started ) --Hook function will end the Cineractive endCineractiveTimer4:hook( "endCineractive4", nil, function(timer, hook) Cineractive.active = false --End the mission (victory) Mission:finish( true, 0 ) end, nil ) end if southernBase ~= nil then --monitor:stop() --This is necessary for saved games with objectives that can be fulfilled before the final cinematic Objectives:load( "TRW_Objectives1.txt" ) local helpthing = EntityFinder( function(e) return e:isType(Entity.Type.GameObject) and e.odf == "rdefenseplatform.odf" and e.player.number == 7 end ):findOne() if helpthing == nil then Cineractive.active = true Cineractive.skippable = false --Screen will fade in over one second Cineractive:fadeIn( 1.0 ) UI:addTitle( "Northern Base Destroyed", 50, 50, 5.0, true ) --Play a sound bite Timer( "halfsound1", 1.0, Timer.State.Started ):hook( "halfsound1", nil, function() Media:playSound("TRW_OneDown.mp3") Cineractive:lookFrom( Path("path_3"), 0.25 ) --0, 100, 0 is slightly above the target Cineractive:setCameraOffset( Vector( 0, 100, 0 ) ) Cineractive:lookAt( Vector( 12500, 100, 1100 ) ) end, nil ) local fadeTimer = Timer( "fadeTimer2", 7, Timer.State.Started ) --Hook function will fade the screen out over two seconds fadeTimer:hook( "fadeOut", nil, function(timer, hook) Cineractive:fadeOut( 2.0 ) end, nil ) local endCineractiveTimer = Timer( "endTimer", 9, Timer.State.Started ) --Hook function will end the Cineractive endCineractiveTimer:hook( "endCineractive", nil, function(timer, hook) Media:stopSounds( ) Cineractive.active = false --monitor:stop() completeObjective( 2 ) --Add the intro cinematic object for saved games Entity.add( "rdefenseplatform.odf", 7, Vector(-1300, 0, -1000) ) end, nil ) end if helpthing ~= nil then --This is necessary for saved games with objectives that can be fulfilled before the final cinematic Objectives.objectives[2].state = true end end end function onPlayerDead( monitor, arg ) --Stop all existing monitors so they don't interfere. Monitor.stopAll() Cineractive.active = true Cineractive.skippable = false --Screen will fade in over one second Cineractive:fadeIn( 1.0 ) UI:addTitle( "Mission Failed", 50, 50, 5.0, true ) --Play a sound bite Timer( "failsound2", 2.0, Timer.State.Started ):hook( "failsound2", nil, function() Media:playSound("TRW_Defeat.mp3") end, nil ) local fadeTimer3 = Timer( "fadeTimer2", 8, Timer.State.Started ) --Hook function will fade the screen out over two seconds fadeTimer3:hook( "fadeOut3", nil, function(timer, hook) Cineractive:fadeOut( 2.0 ) end, nil ) local endCineractiveTimer3 = Timer( "endTimer3", 10, Timer.State.Started ) --Hook function will end the Cineractive endCineractiveTimer3:hook( "endCineractive3", nil, function(timer, hook) Cineractive.active = false --End the mission (defeat) Mission:finish( false, 0 ) end, nil ) end Monitor( "checkPlayerDead", false, nil, checkPlayerDead, nil ):hook( "onPlayerDead", MonitorHook.Type.OnTrue, nil, onPlayerDead, nil ) Monitor( "checkNorthernDead", false, nil, checkNorthernDead, nil ):hook( "onNorthernDead", MonitorHook.Type.OnTrue, nil, onNorthernDead, nil ) Monitor( "checkSouthernDead", false, nil, checkSouthernDead, nil ):hook( "onSouthernDead", MonitorHook.Type.OnTrue, nil, onSouthernDead, nil ) end function DominionStatus:onCineractiveEnd( forced ) --Cineractive may have been ended by the user, so we have to make sure that --the mission is in the right state. if( forced ) then --Stop all audio messages that may be playing, since the cineractive --was force ended. Media:stopSounds( ) --Stop all timers too since they would mess up things if we left them going. Timer.stopAll( ) Objectives:load( "TRW_Objectives1.txt" ) Objectives.visible = true local visionsbeacons = EntityFinder( function(e) return e:isType(Entity.Type.Craft) and e.odf == "visionbeacon.odf" end ):find() for _, v in pairs(visionsbeacons) do Entity.remove( v ) end Player( 2 ):loadAIP( "dominion_mission_build_list_simple.aip" ) Player( 3 ):loadAIP( "dominion_mission_build_list_simple.aip" ) --Add the intro cinematic object for saved games Entity.add( "rsensorarray.odf", 7, Vector(-1300, 0, -1300) ) end end