Advertisement
Guest User

Untitled

a guest
Apr 29th, 2013
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 17.32 KB | None | 0 0
  1. -- enable alerts, turn off for release version
  2. enableAlerts(1);
  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;
  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.  
  68.     enablePointDefence( shipICC );
  69.     enablePointDefence( shipUGTO1 );
  70.     enablePointDefence( shipUGTO2 );
  71. end
  72.  
  73. function onSpawnCombat2( cadetId )
  74.     local fleetId = getFleetId( cadetId );
  75.     local shipICC1 = spawnShip( "Ships\\ICC\\Destroyer\\M190 A\\SC_M190A.PRT", "Zoca", "Faustus", fleetId );
  76.     local shipICC2 = spawnShip( "Ships\\ICC\\Destroyer\\M190 A\\SC_M190A.PRT", "Zoca", "Lemming", fleetId );
  77.  
  78.     -- order both ICC ships to defend Mycopia
  79.     orderShip( shipICC1, "Mycopia", 2 );
  80.     orderShip( shipICC2, "Mycopia", 2 );
  81.  
  82.     enablePointDefence( shipICC1 );
  83.     enablePointDefence( shipICC2 );
  84. end
  85.  
  86. function enablePointDefence( shipId )
  87.     local maxGadget = gadgetCount( shipId ) - 1;
  88.     for i = 0, maxGadget do
  89.         local gadgetId = getGadget( shipId, i );
  90.         if getGadgetType( gadgetId ) == 6 then  -- normal beam weapon
  91.             setBeamPointDefence( gadgetId, 1 );
  92.         end
  93.     end
  94. end
  95.  
  96. function doEJump( shipId )
  97.     if not isShipDestroyed( shipId ) then
  98.         useGadget( shipId, "J", nil, 1 );
  99.         startTimer( 5, "removeShip( \"" .. shipId .. "\" );" );
  100.     end
  101. end
  102.  
  103. function removeShip( shipId )
  104.     if not isShipDestroyed( shipId ) then
  105.         detachNoun( shipId );
  106.     end
  107. end
  108.  
  109. ----------------------------------------------------------------------------
  110.  
  111. -- The following callbacks are only called when running on the client
  112.  
  113. function onFleetSelect()
  114.     -- Called before the player selects a team
  115. end
  116.  
  117. function onFleetSelected( fleetId )
  118.     -- Called after the player selects a fleet, the fleet ID is passed
  119. end
  120.  
  121. function onSetFleet( fleetId )
  122.     -- called when the server assigns the players fleetId
  123. end
  124.  
  125. function onSpawnSelect()
  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.     startTutorial();
  136. end
  137.  
  138. function onShipSelected( shipName )
  139.     -- Called after the player selects a ship
  140. end
  141.  
  142. function onTactical()
  143.     onTacticalView();
  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. end
  155.  
  156. function onCaptured()
  157.     -- Called when the players ship is captured
  158. end
  159.  
  160. function onDisconnected()
  161.     -- Called when connection to the server is lost
  162. end
  163.  
  164. function onEndGame()
  165.     -- Called when the scenerio or mission is completed
  166. end
  167.  
  168. function startTutorial()
  169.     messageBox( "<b>Tutorial: Basic Training!</b>\n\nWelcome to the DarkSpace basic tutorial. This tutorial will teach you how to spawn and 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.\n\nClick on the <b>OK</b> button to continue, click on the <b>Cancel</b> button to abort this tutorial.", "shipSpawnSelect()", "cancelTutorial()" );
  170. end
  171.  
  172. function shipSpawnSelect()
  173.     messageBox( "This is the spawn select screen where you can select a launch point for your selected ship below.\n\nFor tutorial purposes only the ICC Jump Gate is available to spawn from, but in normal play planets with <b>Shipyards</b> on them can function as remote spawn locations too.\n\nYou can rotate the camera to get a better view of the system(s) and possible spawn locations from here.", "shipSpawnSelect2()", "cancelTutorial()" );
  174. end
  175.  
  176. function shipSpawnSelect2()
  177.     messageBox( "<con;ShipButtons>This is the list of default ships for your selected faction. Ships in <color;00ffff>white</color> incidate they can be spawned, <color;0000ff>red</color> indicates you do not have sufficient rank and/or badges to use the ship, and <color;707070>grey</color> indicates that the ship cannot be launched due to lack of resources, technology, or shipyard.\n\nYou can toggle the filter buttons to the left of this list of ships to narrow down and find ships quicker, but for this tutorial only one ship is available. Go ahead and click on that ship.", "shipSpawnSelect3()", "cancelTutorial()" );
  178. end
  179.  
  180. function shipSpawnSelect3()
  181.     messageBox( "<con;ButtonOkay>You can now launch this ship as the spawn location has been selected by default for you. You may view the loadout of the ship in the ship viewer screen on the bottom right prior to launching if you desire to. Once you are ready, hit <b>Launch</b> to continue." );
  182. end
  183.  
  184. function onTacticalView()
  185.     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()" );
  186. end
  187.  
  188. function onShipStatus()
  189.     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 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()" );
  190. end
  191.  
  192. function onRepairQueue()
  193.     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()" );
  194. end
  195.  
  196. function onSystemsDisplay()
  197.     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 of the gadget icon.\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()" );
  198. end
  199.  
  200. function onCargoDisplay()
  201.     messageBox( "<con;ButtonCargoDisplay>This is your <b>Cargo Display</b>. Any cargo your ship has in it's hold is displayed as an icon 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()" );
  202. end
  203.  
  204. function onHelmControls()
  205.     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()" );
  206. end
  207.  
  208. function onTargetDisplay()
  209.     -- go ahead and spawn the scout near zoca, it will jump to the players location
  210.     remoteCall( "Zoca", 5, "onSpawnScout1(\"" .. playersShip() .. "\");" );    -- get the ECCM cover here
  211.  
  212.     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 scout 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()" );
  213. end
  214.  
  215. function onNavigation()
  216.    
  217.     messageBox( "<con;ButtonNavigation>Press <b>F2</b> or click on this button to enter the navigation view." );
  218.     watchKey( 113, "onNavigationView()" );
  219.  
  220. end
  221.  
  222. function onNavigationView()
  223.     watchKey( 113 );
  224.  
  225.     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()" );
  226.  
  227. end
  228.  
  229. function onNavigationFocus()
  230.     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()" );
  231. end
  232.  
  233. function onNavigationContacts()
  234.     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()" );
  235. end
  236.  
  237. function onNavigationJump()
  238.     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()" );
  239. end
  240.  
  241. function onNavigationOrbit()
  242.     -- short combat scene to watch
  243.     remoteCall( "Mycopia", 5, "onSpawnCombat1(\"" .. playersShip() .. "\");" );  
  244.  
  245.     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()" );
  246. end
  247.  
  248. function onWaitOrbit()
  249.     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()" );
  250.  
  251.     if isOrbiting( playersShip(), "Mycopia" ) then
  252.         onOrbit();
  253.     else
  254.         startTimer( 1, "onWaitOrbit()" );
  255.     end
  256. end
  257.  
  258. function onOrbit()
  259.     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()" );
  260. end
  261.  
  262. function onInfantryUnloaded()
  263.     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()" );
  264. end
  265.  
  266. function onCombat()
  267.     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()" );
  268. end
  269.  
  270. function onCombat2()
  271.     messageBox( "Target the enemy by pressing the <b>E</b> key, and help the destroy the enemy..." );
  272.  
  273.     -- spawn 2 more destroyers to make sure the ship is destroyed
  274.     remoteCall( "Mycopia", 5, "onSpawnCombat2(\"" .. playersShip() .. "\");" );  
  275.     -- start waiting for Mycopia to be captured
  276.     onWaitCapture();
  277. end
  278.  
  279. function onWaitCapture()
  280.     local cadetId = playersShip();
  281.     if getFaction( cadetId ) == getFaction( "Mycopia" ) then
  282.         onPlanetCaptured();
  283.     else
  284.         startTimer( 15, "onWaitCapture()" );
  285.     end
  286. end
  287.  
  288. function onPlanetCaptured()
  289.     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()" );
  290. end
  291.  
  292. function onLoadInfantry()  
  293.     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()" );
  294. end
  295.  
  296. function onInfantryLoaded()
  297.     messageBox( "You may now capture <b>Dawn</b> and <b>Ihzack</b> to end this tutorial.", "endTutorial()", "cancelTutorial()" );
  298. end
  299.  
  300. function endTutorial()
  301.     pushChat( "Tutorial completed..." );
  302. end
  303.  
  304. function cancelTutorial()
  305.     pushChat( "Tutorial Cancelled..." );
  306. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement