1-- Name: Science
2-- Description: [Station Tutorial]
3--- -------------------
4--- -Goes over science station.
5---
6--- [Station Info]
7--- -------------------
8--- Long-range Radar:
9--- -The Science station has a long-range radar that can locate ships and objects at a distance of up to 25U. The Science officer's most important task is to report the sector's status and any changes within it. On the edge of the radar are colored bands of signal interference that can vaguely suggest the presence of objects or space hazards even further from the ship, but it's up to the Science officer to interpret them.
10---
11--- Scanning:
12--- -You can scan ships to get more information about them. The Science officer must align two of the ship's scanning frequencies with a target to complete the scan. Most ships are unknown (gray) to your crew at the start of a scenario and must be scanned before they can be identified as a friend (green), foe (red), or neutral (blue). A scan also identifies the ship's type, which the Science officer can use to identify its capabilities in the station's database.
13---
14--- Deep Scans:
15--- -A second, more difficult scan yields more information about the ship, including its shield and beam frequencies. The Science officer must align both the frequency and modulation of each scan type to complete a deep scan. The helms and weapons screen can also see the firing arcs of deep-scanned ships, which help them guide your ship from being shot by their beams.
16---
17--- Nebulae:
18--- -Nebulae block the ship's long-range scanner. The Science officer cannot see what's inside or behind them, and while in a nebula the ship's radars cannot detect what's outside of it. These traits make nebulae ideal places to hide for repairs or stage an ambush. To avoid surprises around nebulae, relay information about where you can and cannot see objects to both the Captain and the Relay officer.
19---
20--- Probe View:
21--- -The Relay officer can launch probes and link one to the Science station. The Science officer can view the probe's short-range sensor data to scan ships within its range, even if the probe is far from the ship's long-range scanners or in a nebula.
22---
23--- Database:
24--- -The Science officer can access the ship's database of all known ships, as well as data about weapons and space hazards. This can be vital when assessing a ship's capabilities without a deep scan, or for help navigating a black hole, wormhole, or other anomaly.
25-- Type: Basic
26require("utils.lua")
27
28function init()
29    --Create the player ship
30    player = PlayerSpaceship():setFaction("Human Navy"):setTemplate("Phobos M3P")
31    tutorial:setPlayerShip(player)
32
33    tutorial:showMessage([[Welcome to the EmptyEpsilon tutorial.
34Note that this tutorial is designed to give you a quick overview of the basic options for the game, but does not cover every single aspect.
35
36Press next to continue...]], true)
37    tutorial_list = {
38        scienceTutorial
39    }
40    tutorial:onNext(function()
41        tutorial_list_index = 1
42        startSequence(tutorial_list[tutorial_list_index])
43    end)
44end
45
46-- TODO: Need to refactor this region into a utility (*Need help LUA hates me)
47--[[ Assist function in creating tutorial sequences --]]
48function startSequence(sequence)
49    current_sequence = sequence
50    current_index = 1
51    runNextSequenceStep()
52end
53
54function runNextSequenceStep()
55    local data = current_sequence[current_index]
56    current_index = current_index + 1
57    if data == nil then
58        tutorial_list_index = tutorial_list_index + 1
59        if tutorial_list[tutorial_list_index] ~= nil then
60            startSequence(tutorial_list[tutorial_list_index])
61        else
62            tutorial:finish()
63        end
64    elseif data["message"] ~= nil then
65        tutorial:showMessage(data["message"], data["finish_check_function"] == nil)
66        if data["finish_check_function"] == nil then
67            update = nil
68            tutorial:onNext(runNextSequenceStep)
69        else
70            update = function(delta)
71                if data["finish_check_function"]() then
72                    runNextSequenceStep()
73                end
74            end
75            tutorial:onNext(nil)
76        end
77    elseif data["run_function"] ~= nil then
78        local has_next_step = current_index <= #current_sequence
79        data["run_function"]()
80        if has_next_step then
81            runNextSequenceStep()
82        end
83    end
84end
85
86function createSequence()
87    return {}
88end
89
90function addToSequence(sequence, data, data2)
91    if type(data) == "string" then
92        if data2 == nil then
93            table.insert(sequence, {message = data})
94        else
95            table.insert(sequence, {message = data, finish_check_function = data2})
96        end
97    elseif type(data) == "function" then
98        table.insert(sequence, {run_function = data})
99    end
100end
101
102function resetPlayerShip()
103    player:setJumpDrive(false)
104    player:setWarpDrive(false)
105    player:setImpulseMaxSpeed(1)
106    player:setRotationMaxSpeed(1)
107    for _, system in ipairs({"reactor", "beamweapons", "missilesystem", "maneuver", "impulse", "warp", "jumpdrive", "frontshield", "rearshield"}) do
108        player:setSystemHealth(system, 1.0)
109        player:setSystemHeat(system, 0.0)
110        player:setSystemPower(system, 1.0)
111        player:commandSetSystemPowerRequest(system, 1.0)
112        player:setSystemCoolant(system, 0.0)
113        player:commandSetSystemCoolantRequest(system, 0.0)
114    end
115    player:setPosition(0, 0)
116    player:setRotation(0)
117    player:commandImpulse(0)
118    player:commandWarp(0)
119    player:commandTargetRotation(0)
120    player:commandSetShields(false)
121    player:setWeaponStorageMax("homing", 0)
122    player:setWeaponStorageMax("nuke", 0)
123    player:setWeaponStorageMax("mine", 0)
124    player:setWeaponStorageMax("emp", 0)
125    player:setWeaponStorageMax("hvli", 0)
126end
127--End Region Tut Utils
128
129
130scienceTutorial = createSequence()
131addToSequence(scienceTutorial, function()
132    tutorial:switchViewToScreen(3)
133    tutorial:setMessageToBottomPosition()
134    resetPlayerShip()
135end)
136addToSequence(scienceTutorial, [[Welcome, science officer.
137
138You are the eyes of the ship. Your job is to supply the captain with information. From your station, you can detect and scan objects at a range of up to 30u.]])
139addToSequence(scienceTutorial, function() prev_object = SpaceStation():setTemplate("Medium Station"):setFaction("Human Navy"):setPosition(3000, -15000) end)
140addToSequence(scienceTutorial, function() prev_object2 = CpuShip():setFaction("Human Navy"):setTemplate("Phobos T3"):setPosition(5000, -17000):orderIdle():setScanned(true) end)
141addToSequence(scienceTutorial, [[On this radar, you can select objects to get information about them.
142I've added a friendly ship and a station for you to examine. Select them and notice how much information you can observe.
143Heading and distance are of particular importance, as without these, the helms officer will be jumping in the dark.]])
144addToSequence(scienceTutorial, function() prev_object:destroy() end)
145addToSequence(scienceTutorial, function() prev_object = CpuShip():setFaction("Kraylor"):setTemplate("Phobos T3"):setPosition(3000, -15000):orderIdle() end)
146addToSequence(scienceTutorial, [[I've replaced the friendly station with an unknown ship. Once you select it, notice that you know nothing about this ship.
147To learn about it, you must scan it. Scanning requires you to match your scanner's frequency bands to your target's.
148Scan this ship now.]], function() return prev_object:isScannedBy(player) end)
149addToSequence(scienceTutorial, [[Good. Notice that you now know this ship is unfriendly. It might have been a friendly or neutral ship as well, but until you scanned it, you do not know.]])
150addToSequence(scienceTutorial, [[Note that you have less information about this ship than the friendly ship. You must perform a deep scan of this ship to acquire more information.
151A deep scan takes more effort and requires you to align 2 different frequency bands simultaneously.
152Deep scan the enemy now.]], function() return prev_object:isFullyScannedBy(player) end)
153addToSequence(scienceTutorial, [[Excellent. Notice that this took more time and concentration than the simple scan, so be careful to perform deep scans only when necessary or you could run out of time.]])
154addToSequence(scienceTutorial, function() prev_object:destroy() end)
155addToSequence(scienceTutorial, function() prev_object2:destroy() end)
156addToSequence(scienceTutorial, function() tutorial:setMessageToTopPosition() end)
157addToSequence(scienceTutorial, [[Next to the long-range radar, the science station can also access the science database.
158
159In this database, you can look up details on things like ship types, weapons, and other objects.]])
160addToSequence(scienceTutorial, [[Remember, your job is to supply information. Knowing the location and status of other ships is vital to your captain.
161
162Without your information, the crew is mostly blind.]])
163
164