View Single Post
Old 08-28-2006, 05:20 PM   #1
stoffe
Mostly dormant
 
stoffe's Avatar
 
Status: Administrator
Join Date: Apr 2002
Posts: 5,834
Helpful! 10 year veteran! Notable contributor 
Adding Planets To Galaxy Map in TSL

Taken from this thread here, please ask any and all questions about this Tutorial in that thread. -RH

(...quote and explanation snipped...)

To add a new working planet to the Ebon Hawk Galaxy Map you'd roughly follow these steps. The NSS files for scripts mentioned below exist either in scripts.bif, or can be found recreated here:
  1. Make a galaxy map icon for your planet. The easiest way is to extract one of the existing GAL_*_2.tpc files (where * is the planet name, for example GAL_M478_2.tpc), edit that one and then save it under a new name. In this example I'll call the new planet Gaia, so I'll save the modified icon as gal_gaia_2.tga. Put this in the override folder.

    Next, create a TXI file containing the texture information KotorTool likely had trouble extracting when you converted the TPC file to TGA. Create a new text file, name it the same as your TGA file but with a TXI extension instead (gal_gaia_2.txi), and as content of the file type in mipmap 0. Save this file along with the TGA file in the override folder.

  2. Open your dialog.tlk file with a TLK editor (TalkEd will do), and add two new entries. The first should contain the name of your new planet (Gaia in this example), the second should contain the specifics of the planet, laid out like:
    Climate: Terran
    Terrain: Mixed
    Docking: Gaia's Landing

    Write down the StrRef numbers these two entries were added as, you'll need those numbers soon.

  3. From gui.bif, extract the file named galaxymap_p.gui and save it in your override folder. Open this file with a GFF Editor, expand the CONTROLS list field and select the struct with listindex 11, copy it and paste it in under the CONTROLS field to add a new struct to the list while saving yourself some manual field creation. Open your newly pasted struct, find the BORDER struct inside it and expand that one too. There, find the FILL field and change its value to the name of the planet icon you created in step 1 above, gal_gaia_2 in this case.

    Next back up to your new struct again and expand the EXTENT struct (inside it) and change the LEFT and TOP fields to the X and Y coordinates on the galaxy map where you want your planet to appear. Check the coordinates for some of the other planets to get an idea of the scale, though some trial and error may be needed to find the desired location.

    Next back up to your new struct again and expand the HILIGHT struct (inside it) and change the value of the FILL field here to the name of the icon you created in step 1 above as well, gal_gaia_2 in this case.

    Back up to your new struct again and find the TAG field. Set this to something that has the name of your planet for simplicity, I use LBL_Planet_Gaia in this example, and write this down somewhere as you'll need this tag soon.

    Save changes to the modified galaxymap_p.gui file.

  4. Next, open the Planetary.2da file (2da.bif) and find line 12 (live planet 2):
    • Change the Label field here to the name of your planet (Gaia).
    • Change the name field to the StrRef number of the name of your planet from step 2 above.
    • Change the description field to the StrRef number of the description from step 2 above.
    • Change the icon field to the name of the icon you created in step 1 above (gal_gaia_2).
    • Change the model field to the name of the model (MDL/MDX) file of the model you want to use for the "spinning planet" 3D view when you select your planet on the galaxy map. Unless you've made a new unique model for your planet you can re-use one of the existing ones, as I do in this example. I set the value planet_06 here, borrowing the planetary view of Dantooine for my planet.
    • Change the guitag field to the Tag of the struct you added to the galaxymap_p.gui file in the previous step, LBL_Planet_Gaia in this example.
    Save your modified planetary.2da in the override folder.

  5. Extract the include file named k_inc_hawk.nss from scripts.bif and put where you compile your scripts. You'll need to make some changes to this include file and use this modified copy when recompiling the following scripts.
    • First, find the function named SetBackground(). This is responsible for setting what is seen outside the cockpit window in the Ebon Hawk when you have "arrived" at the planet. As far as I am aware it's currently not possible to add new room animations to an area model, so you'll have to use a view from one of the existing planets. Pick one that's close enough to resemble your new planet, I'll use the view for Dxun in this example.

      Scroll down to near the end of the long switch...case statement in this function, and before default: add a new case and set the room animation number you want to use here. In this example it looks like (the bolded part is what I added):
      Code:
      (...snip...)
      case 10://Hyperspace
      {
          nRoomAnimation = ANIMATION_ROOM_SCRIPTLOOP11;
      }break;
      case 12: //ST: Gaia....
      {
          nRoomAnimation = ANIMATION_ROOM_SCRIPTLOOP05;
      }break; 
      default://error
      {
          AurPostString("EBO ERROR: No background sepcified!",15,15,10.0);
      }
      (...snip...)
    • Next, scroll down to the function SetHologramWorld() and do the same. Before the default: case, add a new case for your planet, like (again, bolded part is what added, the other is just to show where to insert it):
      Code:
      (...snip...)
      case 10://Hyperspace
      {
          sResRef = "";
      }break;
      case 12: //ST: Gaia...
      {
          sResRef = "holo_tel";
      }break;      
      default://error
      {
          AurPostString("EBO ERROR: No background sepcified!",15,15,10.0);
      }
      (...snip...)
      This function set the name of the placeable UTP file for the holographic image of a planet that is shown in the main hold of the ebon hawk while "landed" on the planet. Pick one of the existing ones to re-use if you haven't made your own model, it doesn't matter which one since they are all completely identical as far as I can tell. I used holo_tel in this example.

    • Last, find the function GetCurrentPlanet(), which is used to tell the other scripts what planet you are currently landed/docked at. Again insert a new case near the end, like (bolded part is new, again...):
      Code:
      (...snip...)
      case 10://Hyperspace
      {
          return PLANET_EBON_HAWK;
      }break;
      case 12: //ST: Gaia...
      {
          return PLANET_LIVE_02;
      }break;    
      default://error
      {
          return PLANET_EBON_HAWK;
      }
      (...snip...)
    Save this modified k_inc_hawk.nss include file in a place where it will be used when you recompile the next batch of scripts below.

  6. Using the above modified k_inc_hawk.nss include file, recompile the scripts a_holoworld.nss and k_003ebo_enter.nss that is posted below. No changes to these scripts need to be done directly, they just need to be recompiled for the changes to the k_inc_hawk.nss include file to take effect.

  7. In the script a_galaxymap.nss (used to open the map screen), add...
    SetPlanetAvailable(PLANET_LIVE_02, TRUE);
    SetPlanetSelectable(PLANET_LIVE_02, TRUE);

    ...somewhere near the end to make sure the planet is always reachable. If you want the planet to only be reachable under certain conditions you may add additional checks here as well, but in this example the planet should always be there so the above is sufficient. Save the modified script, recompile it and put the resulting a_galaxymap.ncs file in the override folder.

  8. In the script k_sup_galaxymap.nss (used when you pick a destination at the map screen), find the switch statement near the start of the main() function that begins like switch(GetGlobalNumber("003EBO_BACKGROUND")). Add a new case at the end for your planet, like:
    Code:
    case 12: // ST: Gaia....
    {
    	QueueMovie("HypMov01");
    }break;
    This part plays the departure and hyperspace movies to give the impression of the ship travelling to its destination. If you've made a departure movie for your planet (or want to re-use an existing one) add another QueueMovie() call with the name of the BIK movie file as parameter. Otherwise you can do as the above example and skip the departure movie and go straight to the "jump to hyperspace" movie.

    Next scroll down to the next switch statement. This plays the arrival/landing movie for the destination planet, and sets which planet the Ebon Hawk is currently landed on. Add a new case at the end, like:
    Code:
    case PLANET_LIVE_02:
    {
        SetGlobalNumber("003EBO_RETURN_DEST",12);
        SetGlobalNumber("003EBO_BACKGROUND",12);
    }break;
    This sets which planet you are currently landed on. If you've made a new landing movie for your planet, or want to re-use an existing one you can add a QueueMovie() call with the name of the BIK movie file as parameter after the last of the SetGlobalNumber() function calls.

    Save and recompile the file, and put the resulting k_sup_galaxymap.ncs file in the override folder.

  9. If you want to restrict what NPCs may be brought along when exiting the Ebon Hawk on your new planet you can modify the script tr_leave_ehawk.nss to add these restrictions. This script is the OnEnter script of the exit ramp trigger inside the Ebon Hawk.

  10. Open the script check_party_gui.nss and scroll down to the ExitEbonHawk() function (it should be at the top of the script if you use the re-created script I made). In the switch statement inside this function, add a new case above the default case, like (bold text is new):
    Code:
    (..snip..)
    case 10: sDest = "IN_TRANSIT"; 	break;
    case 12: sDest = "ST_GAIA"; 	break;
    default: sDest = "ERROR";
    (..snip..)
    The text you assign at case 12 above (ST_GAIA) is the name of the MOD or RIM file containing your new module (st_gaia.mod in this example). This tells the game what module to load when you exit the Ebon Hawk. Save, recompile and put the resulting check_party_gui.ncs file in the override folder.

These steps will add a new planet to the galaxy map. When selected, a "jump to hyperspace" movie is played and the hawk is "landed" on that planet. When you exit the Ebon Hawk, the module for the new planet will load. With reservation for typos and poor memory, since I just wrote this thing it's only roughly proof-read.

The next posts in this thread contain the scripts mentioned above that have no NSS source code available in scripts.bif that you can use.

Last edited by stoffe; 09-16-2007 at 04:26 PM. Reason: Added some scripts mentioned that might not have source available in the game data
stoffe is offline   you may: quote & reply,