Advertisement
Guest User

Untitled

a guest
Apr 28th, 2013
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 16.86 KB | None | 0 0
  1. -- enable alerts, turn off for release version
  2. enableAlerts(0);
  3. -- disable all safe zones
  4. -- setSafeZones( 0 );
  5.  
  6. ----------------------------------------------------------------------------
  7.  
  8. function onInitialize()
  9.     -- Perform any initialization here, this is called right after the script is loaded
  10. end
  11.  
  12. ----------------------------------------------------------------------------
  13.  
  14. function onRelease()
  15.     -- Called before the script is release
  16. end
  17.  
  18. -------------------------------------------------------------------------------
  19. -- Server Side functions
  20.  
  21. function onSpawnScout1( cadetId )
  22.     if isNoun( "Weasel" ) then
  23.         detachNoun( "Weasel" );
  24.     end
  25.  
  26.     local fleetId = getFleetId( cadetId );
  27.     local shipId = spawnShip( "Ships\\ICC\\Scout\\M21 A\\SC_M21A.PRT", "Zoca", "Weasel", fleetId );
  28.     orderShip( shipId, cadetId, 2 );    -- follow cadet
  29.  
  30.         startTimer( 4, "activateECCMScanner( \"" .. shipId .. "\");" );
  31. end
  32.  
  33. function activateECCMScanner( shipId )
  34.     local count = useGadget( shipId, "P", nil, 0 );     -- activate ECCM
  35.     if count <= 0 then
  36.         scriptAlert( "Could not activate ECCM" );
  37.     end
  38.  
  39.     count = useGadget( shipId, "Y", nil, 0 );           -- activate Scanner
  40.     if count <= 0 then
  41.         scriptAlert( "Could not activate Scanner" );
  42.     end
  43. end
  44.  
  45. function getEnemyFleetId( notFleetId )
  46.     local maxFleet = fleetCount();
  47.     for i=0, maxFleet do
  48.         local checkFleetId = fleetId( i );
  49.         if not checkFleetid == notFleetId then
  50.             return checkFleetId;
  51.         end
  52.     end
  53. end
  54.  
  55. function onSpawnCombat1( cadetId )
  56.     local fleetId = getFleetId( cadetId );
  57.     local enemyFleetId = fleetId + 1; -- getEnemyFleetId( fleetId );
  58.  
  59.     local shipICC = spawnShip( "Ships\\ICC\\Destroyer\\M190 A\\SC_M190A.PRT", "Mycopia", "Schak'JaJ", fleetId );
  60.     local shipUGTO1 = spawnShip( "Ships\\UGTO\\Frigate\\ST-6 Interceptor\\SC_ST6.prt", "Mycopia", "Mephiblo", enemyFleetId );
  61.     local shipUGTO2 = spawnShip( "Ships\\UGTO\\Frigate\\ST-6 Interceptor\\SC_ST6.prt", "Mycopia", "Damion", enemyFleetId );
  62.  
  63.     orderShip( shipICC, "Mycopia", 2 );
  64.     orderShip( shipUGTO1, "Mycopia", 2 );  
  65.     orderShip( shipUGTO2, "Mycopia", 2 );  
  66.  
  67.     enablePointDefence( shipICC );
  68.     enablePointDefence( shipUGTO1 );
  69.     enablePointDefence( shipUGTO2 );
  70. end
  71.  
  72. function onSpawnCombat2( cadetId )
  73.     local fleetId = getFleetId( cadetId );
  74.     local shipICC1 = spawnShip( "Ships\\ICC\\Destroyer\\M190 A\\SC_M190A.PRT", "Zoca", "Faustus", fleetId );
  75.     local shipICC2 = spawnShip( "Ships\\ICC\\Destroyer\\M190 A\\SC_M190A.PRT", "Zoca", "Lemming", fleetId );
  76.  
  77.     -- order both ICC ships to defend Mycopia
  78.     orderShip( shipICC1, "Mycopia", 2 );
  79.     orderShip( shipICC2, "Mycopia", 2 );
  80.  
  81.     enablePointDefence( shipICC1 );
  82.     enablePointDefence( shipICC2 );
  83. end
  84.  
  85. function enablePointDefence( shipId )
  86.     local maxGadget = gadgetCount( shipId ) - 1;
  87.     for i = 0, maxGadget do
  88.         local gadgetId = getGadget( shipId, i );
  89.         if getGadgetType( gadgetId ) == 6 then  -- normal beam weapon
  90.             setBeamPointDefence( gadgetId, 1 );
  91.         end
  92.     end
  93. end
  94.  
  95. function doEJump( shipId )
  96.     if not isShipDestroyed( shipId ) then
  97.         useGadget( shipId, "J", nil, 1 );
  98.         startTimer( 5, "removeShip( \"" .. shipId .. "\" );" );
  99.     end
  100. end
  101.  
  102. function removeShip( shipId )
  103.     if not isShipDestroyed( shipId ) then
  104.         detachNoun( shipId );
  105.     end
  106. end
  107.  
  108. ----------------------------------------------------------------------------
  109.  
  110. -- The following callbacks are only called when running on the client
  111.  
  112. function onFleetSelect()
  113.     -- Called before the player selects a team
  114. end
  115.  
  116. function onFleetSelected( fleetId )
  117.     -- Called after the player selects a fleet, the fleet ID is passed
  118. end
  119.  
  120. function onSetFleet( fleetId )
  121.     -- called when the server assigns the players fleetId
  122. end
  123. //We wanna be nicer to the new player. Instead of throwing them into the fray.
  124. function onSpawnSelect()
  125. messageBox( "<b>Tutorial: Basic Trainingl</b>\n\nWelcome to the DarkSpace basic tutorial. This tutorial will teach you how to navigate your ship, engage in basic combat, and capture planets. You may press <b>F1</b> at any time to see additional help for that screen. Here you see only one option for a ship, \"\MT-261 Light Transport\". For now, this is your only option. Using the left mouse button click on the ship.\n\nClick on the <b>OK</b> button to continue, click on the <b>Cancel</b> button to abort this tutorial.", "onShipSelected()", "cancelTutorial()" );
  126.     -- called when the player enters the spawn selection screen
  127. end
  128.  
  129. function onSpawnSelected( spawnId )
  130.     -- called when the player selects a spawn point
  131. end
  132.  
  133. function onShipSelect()
  134.     -- Called before the player selects a ship
  135. end
  136. --Tell them that they did it right.
  137. function onShipSelected( shipName )
  138.     messageBox("Good, at the bottom right of the screen you will see a description of the ship, along with details about the ship and weapon systems. Go ahead and click \"Launch\".\n\nClick on the <b>OK</b> button to continue, click on the <b>Cancel</b> button to abort this tutorial.", "onTacticalView()", "cancelTutorial");
  139.     -- Called after the player selects a ship
  140. end
  141.  
  142. function onTactical()
  143.     startTutorial();
  144. end
  145.  
  146. function onShipAttached( shipId )
  147. end
  148.  
  149. function onShipDetached( shipId )
  150. end
  151.  
  152. function onDeath()
  153.     -- Called when the players ship is destroyed
  154.     messageBox("Ouch, don't worry! It's only a scratch we can get you back up and running in a pinch. Don't get discouraged, everyone dies once in a lifetime. But, we hear in Darkspace get to die an infinite amount of times.\n\nClick on the <b>OK</b> button to continue, click on the <b>Cancel</b> button to abort this tutorial.", "onWaitOrbit()", "cancelTutorial()" );
  155. end
  156.  
  157. function onCaptured()
  158.     -- Called when the players ship is captured
  159. end
  160.  
  161. function onDisconnected()
  162.     -- Called when connection to the server is lost
  163. end
  164.  
  165. function onEndGame()
  166.     -- Called when the scenerio or mission is completed
  167. end
  168.  
  169. function startTutorial()
  170.     onTacticalView();
  171. end
  172. --We really don't need startTutorial() anymore.
  173. function onTacticalView()
  174.     messageBox( "You are now in the <b>TACTICAL</b> view. Your ship is displayed in the center of the screen.<b>Right Click and Drag</b> in this view to change the view of your ship. The <b>Mouse Wheel</b> and the <b>X/Z</b> keys control zoom.\n\nTry rotating/zooming your view before clicking on the <b>OK</b> button...", "onShipStatus()", "cancelTutorial()" );
  175. end
  176.  
  177. function onShipStatus()
  178.     messageBox( "<con;HullBar>This is your <b>Ship Status</b> display.\n\nThe <b>Hull</b> bar shows the status of your ships hull, at 0% your hull is breached and your ship is destroyed.\n\nThe <b>Energy</b> bar shows the amount of energy you have available for weapons and other ship systems.\n\nThe <b>Signature</b> bar shows how much radiation your ship is emitting, the more higher your signature the easier your ship is detected. Your signature is affected by your ships velocity, energy usage, and ECM/ECCM in the area.", "onRepairQueue()", "cancelTutorial()" );
  179. end
  180.  
  181. function onRepairQueue()
  182.     messageBox( "<con;ButtonRepairQueue>This is your <b>Repair Queue</b>, as systems get damaged, ship system icons will appear listed here in order of repair, <b>Left click</b> on a button to move it to the top of the queue, <b>Right click</b> to move a system to the end of the repair queue. ", "onSystemsDisplay()", "cancelTutorial()" );
  183. end
  184.  
  185. function onSystemsDisplay()
  186.     messageBox( "<con;ButtonSystemDisplay>This is your <b>Systems Display</b>, all your ships systems/weapons/drives are displayed in this area. <b>Left Click</b> on a system to target that system. <b>Right Click</b> on a system button to activate that system or weapon if usable.\n\nIf the icon for a system is <b>white</b> then the system is currently active, <b>Green</b> icons indicate the system is ready to use/fire, and <b>grey</b> icons indicate they are currently unavailable (i.e. charging, out of range/arc).\n\nIf the device uses ammo or fuel, the amount of ammo/fuel available will be displayed in the upper right.\n\nThe <b>Hotkeys</b> for a device will be displayed in the lower right, pressing the hotkey will use the device immediately.", "onCargoDisplay()", "cancelTutorial()" );
  187. end
  188.  
  189. function onCargoDisplay()
  190.     messageBox( "<con;ButtonCargoDisplay>This is your <b>Cargo Display</b>. Any cargo your ship has in it's hold is displayed as buttons in this display. <b>Right click</b> on a button to unload it onto your current target. <b>Left click</b> on a button to target that cargo item.", "onHelmControls()", "cancelTutorial()" );
  191. end
  192.  
  193. function onHelmControls()
  194.     messageBox( "<con;ButtonHelmControls>This is your <b>Helm Display</b>. Your ships current velocity and heading are displayed in this area. You may left click on the velocity/heading bars to control your ship. However, usually you would use the <b>A/S/D</b> keys to control your heading and the <b>Q/W</b> keys to control your velocity. The <b>Arrow</b> keys may be used as well to control your heading and velocity.\n\nTry using the <b>A/S/D and Q/W</b> keys to control your heading and velocity, click on <b>OK</b> when you are ready to continue...", "onTargetDisplay()", "cancelTutorial()" );
  195. end
  196.  
  197. function onTargetDisplay()
  198.     -- go ahead and spawn the scout near zoca, it will jump to the players location
  199.     remoteCall( "Zoca", 5, "onSpawnScout1(\"" .. playersShip() .. "\");" );    -- get the ECCM cover here
  200.  
  201.     messageBox( "<con;TargetFrame>Your current target is displayed here. Depending on the type of target additional buttons will appear beside the target window. You set your current target by <b>Left Clicking</b> on a <b>target indicator</b>. (The target indicators are those colored arrows along the edge of your screen, red for enemy, green for friendly, and yellow for neutral.)\n\nA friendly scount is jumping to your location, you will see a green target indicator appear shortly, try left clicking on that indicator to set the scout as your current target...", "onNavigation()", "cancelTutorial()" );
  202. end
  203.  
  204. function onNavigation()
  205.     messageBox( "<con;ButtonNavigation>Press <b>F2</b> or click on this button to enter the navigation view." );
  206.     watchKey( 113, "onNavigationView()" );
  207. end
  208.  
  209. function onNavigationView()
  210.     watchKey( 113 );
  211.     messageBox( "This is the <b>Navigation view</b> which provides you with an overview of the current system. You rotate and zoom the camera in this view the same as in the tactical view. Hold down the <b>Right mouse button and drag</b> to rotate, use the <b>mouse wheel</b> or the <b>X/Z</b> keys to zoom.\n\nTIP: <b>SHIFT+Z</B> will zoom in the maximum distance, while <b>SHIFT+X</b> will zoom out the maximum distance.", "onNavigationFocus()", "cancelTutorial()" );
  212. end
  213.  
  214. function onNavigationFocus()
  215.     messageBox( "The navigation screen allows you to move around the focus of your view. Try holding down the <B>Left mouse button</b> over an empty part of the map and <b>DRAG</b>. If you target an object and press <b>Spacebar</b> that will center the map on that object. Also, <b>Double Left Click</b> will center the map on an object as well.\n\nTry looking around the system some, click the <b>OK</b> button to continue...", "onNavigationContacts()", "cancelTutorial()" );
  216. end
  217.  
  218. function onNavigationContacts()
  219.     messageBox( "<con;ButtonDisplayContacts> Displayed here are your navigation contacts. You can <b>LEFT CLICK</b> on an navigation contact to target that object, and press <b>SPACEBAR</b> to center the map on that object.", "onNavigationJump()", "cancelTutorial()" );
  220. end
  221.  
  222. function onNavigationJump()
  223.     messageBox( "If you have not already, select <color;00ffff>MYCOPIA</color> as your current target. Once selected you will notice a line appear between your current position and your target. The line will be either <b>WHITE</b> or <color;0000ff>RED</color> which indicates if any known objects are between you and your target.\n\nIf you press the <b>O</b> key, that will command your ship to orbit Mycopia. Your ship will automatically set course and jump to the target avoiding any collisions\n\nNOTE: You can press the <b>J</b> key to force a jump to your current target, however this will not avoid collisions or other hazards, so make sure the line is white.", "onNavigationOrbit()", "cancelTutorial()" );
  224. end
  225.  
  226. function onNavigationOrbit()
  227.     -- short combat scene to watch
  228.     remoteCall( "Mycopia", 5, "onSpawnCombat1(\"" .. playersShip() .. "\");" );  
  229.  
  230.     messageBox( "Press the <b>O</b> key to command your ship to orbit </b>Mycopia</b> then press <b>F2</b> to return to the tactical view.", "onWaitOrbit()", "cancelTutorial()" );
  231.     end
  232.  
  233. function onWaitOrbit()
  234.     messageBox( "You'll notice ships are already engaged in combat around Mycopia, do not engage or fire at any enemy ships yet, our mission is to orbit the planet and capture it...\nHowever, if you are destroyed, you'll be taken back to the ship selection screen and you'll be able to pick out a new ship.\n\nEnter orbit around Mycopia to continue...", "", "cancelTutorial()" );
  235.  
  236.     if isOrbiting( playersShip(), "Mycopia" ) then
  237.         onOrbit();
  238.     else
  239.         startTimer( 1, "onWaitOrbit()" );
  240.     end
  241. end
  242.  
  243. function onOrbit()
  244.     messageBox( "You are now in orbit around the primary planet of this system. Staying within 500 gu of a planet will affect the planets faction preference. The more allied ships in orbit of an enemy planet and the more allied troops on the ground, the faster the planet will capture, whereas enemy ships and infantry will do the opposite, and make the planet harder to capture. Target <b>Mycopia</b> again if needed, the <color;00ffff>yellow</color> markers on the planets surface are drop zones should you wish to drop infantry on the planet to engage in combat with enemy infantry and aid in capturing the planet.\n\nSelect a drop zone by <b>LEFT CLICKING</b>, then press the <b>U</b> key to unload your infantry on the planet.", "onInfantryUnloaded()", "cancelTutorial()" );
  245. end
  246.  
  247. function onInfantryUnloaded()
  248.     messageBox( "Once the infantry has landed on the surface it will seek out any enemy infantry on the surface to engage in combat with. If the RAZE order is given, they will seek out structure to destroy instead.\n\nEnemy infantry will make the planet less susceptible to capturing from ships in orbit, whilst allied infantry will aid in capturing enemy planets; Since there are no enemy infantry on this planet, the planet is not able to defend itself from your capture attempt.\n\nIf you run out of infantry, you can load more from a friendly planet with a Barracks or spawn a new transport ship.\n\nWhile we are waiting, lets help out the ICC destroyer, but first some basics on combat!\n\nRemember, if you stay within 500 gu of Mycopia you will aid your lone infantry in capturing planet.", "onCombat()", "cancelTutorial()" );
  249. end
  250.  
  251. function onCombat()
  252.     messageBox( "Look for a <b>RED</b> target indicator, this is the enemy ship. (NOTE: Pressing the <b>E</b> key will target the closest enemy ship, pressing the <b>R</b> key will target the closest friendly ship).\n\nOnce the ship is targeted, you may press the <B>F</b> key to automatically follow, or the <b>G</b> key to shadow the ship (Shadow is like follow, except you just match heading/velocity and doesn't close range as much).\n\nPress <b>SPACEBAR</b> to alpha strike, this fires all available weapons at your current target. NOTE: All weapons on your ship are limited by range and firing arc, when a weapon can fire will be indicated by it's icon turning green in the <b>Systems Display</b>. <con;GadgetLayout>", "onCombat2()", "cancelTutorial()" );
  253. end
  254.  
  255. function onCombat2()
  256.     messageBox( "Target the enemy by pressing the <b>E</b> key, and help the destroy the enemy..." );
  257.  
  258.     -- spawn 2 more destroyers to make sure the ship is destroyed
  259.     remoteCall( "Mycopia", 5, "onSpawnCombat2(\"" .. playersShip() .. "\");" );  
  260.     -- start waiting for Mycopia to be captured
  261.     onWaitCapture();
  262. end
  263.  
  264. function onWaitCapture()
  265.     local cadetId = playersShip();
  266.     if getFaction( cadetId ) == getFaction( "Mycopia" ) then
  267.         onPlanetCaptured();
  268.     else
  269.         startTimer( 15, "onWaitCapture()" );
  270.     end
  271. end
  272.  
  273. function onPlanetCaptured()
  274.     messageBox( "YAY! you've just captured your first planet. Your faction can now build structures on the planet, and use it's resources to take control of this star system.", "onLoadInfantry()", "cancelTutorial()" );
  275. end
  276.  
  277. function onLoadInfantry()
  278.     messageBox( "You may now load your infantry back onto your ship should you wish to use it to help you capture the other planets in this system, <b>Dawn</b> and <b>Lhzack</b>.\n\nTarget <b>Mycopia</b>, then you will your infantry appear on the surface at the location you unloaded them, target the infantry and press the <b>L</b> key to load the infantry back onto your ship.", "onInfantryLoaded()", "cancelTutorial()" );
  279. end
  280.  
  281. function onInfantryLoaded()
  282.     messageBox( "You may now capture <b>Dawn</b> and <b>Ihzack</b> to end this tutorial.", "endTutorial()", "cancelTutorial()" );
  283. end
  284.  
  285. function endTutorial()
  286.     pushChat( "Tutorial completed..." );
  287. end
  288.  
  289. function cancelTutorial()
  290.     pushChat( "Tutorial Cancelled..." );
  291. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement