Jump to content

Home

Creating Ebon Hawk Scripts


TheProphet

Recommended Posts

Hello everyone, as most of you know, I am making a storyline mod for Kotor2. Inevitably I am at the part of making my player transport (ex: Ebon Hawk). I have run into trouble as I am unsure what scripts to use and how to approach each one.

 

Here are my questions:

 

1. What is a script i can use to clear all of the party members of the pc on entry and have them go to their specific loacations in the ship.

 

2. How do I make it, so that when the player leaves the shp, he is promted with the character selection and party members are selectable again.

 

3. How do i use the galaxy map ( i am just using a computer with reply options) to change the exit location at the end of the ship.

 

4. Are there any other scripts I need to create when makeing an Ebon Hawk?

 

Help would be MUCH appreciated, thank you.

 

-Gsccc

Link to comment
Share on other sites

1. What is a script i can use to clear all of the party members of the pc on entry and have them go to their specific loacations in the ship.

 

You could create a custom OnEnter script for that I suppose. Something like this might work:

 

void main()
{
object oEntering = GetEnteringObject();
object oPC=GetFirstPC();
if (GetIsPC(oEntering)){

if (IsNPCPartyMember(0))// Checks to see if Atton is in the party
                       {
                        RemoveNPCFromPartyToBase(0); //If so, send him back into storage
                       }
if (IsNPCPartyMember(1))// Checks to see if Bao Dur is in the party
                       {
                        RemoveNPCFromPartyToBase(1); //If so, send him back into storage
                       }
//And so forth. Get your party numbers from NPC.2da
}}

 

As to having them move around... I don't know how the game does it but you could have it check to see if a current party member is available and then if so spawn him at a certain point - though I don't know if that would work.

 

 

2. How do I make it, so that when the player leaves the shp, he is promted with the character selection and party members are selectable again.

 

You can use a trigger and a simple script such as:

 

void main()
{
ShowPartySelectionGUI();
}

 

4. Are there any other scripts I need to create when makeing an Ebon Hawk?

 

I'd imagine there are quite a few such as NPC placement around the ship etc. and also variables for your little cutscenes. Have a look at the scripts for 003EBO.

Link to comment
Share on other sites

These are untested, but it should hopefully give some idea of how it works:

 

1. What is a script i can use to clear all of the party members of the pc on entry and have them go to their specific loacations in the ship.

 

This would probably be best to do in the OnEnter event-script of the area (not the module). A bare bones script for it could look something like:

#include "k_inc_hawk"

string GetPartyMemberTag(int iIndex) {
   string sTag = "ERROR";

   // Set the Tags of the party members to be stored in each 
   // Party Table Slot.
   switch (iIndex) {
       case NPC_ATTON:     sTag = "1stPartyMemberTag"; break;
       case NPC_BAO_DUR:   sTag = "2ndPartyMemberTag"; break;
       case NPC_CANDEROUS: sTag = "3rdPartyMemberTag"; break;
       case NPC_G0T0:      sTag = "4thPartyMemberTag"; break;
       case NPC_HANDMAIDEN:sTag = "5thPartyMemberTag"; break;
       case NPC_HK_47:     sTag = "6thPartyMemberTag"; break;
       case NPC_KREIA:     sTag = "7thPartyMemberTag"; break;
       case NPC_MIRA:      sTag = "8thPartyMemberTag"; break;
       case NPC_T3_M4:     sTag = "9thPartyMemberTag"; break;
       case NPC_VISAS:     sTag = "10thPartyMemberTag"; break;
       case NPC_HANHARR:   sTag = "11thPartyMemberTag"; break;
       case NPC_DISCIPLE:  sTag = "12thPartyMemberTag"; break;
   }   
   return sTag;
}

void main() {
   if (GetEnteringObject() != GetFirstPC()) 
       return;

   int iIdx;

   // Prevent player from adding party members...
   SetAreaUnescapable(TRUE);

   // Set main character back as controlled character
   SetPartyLeader(NPC_PLAYER);

   // Set the proper backdrop outside the cockpit window.
   SetBackground();

   // Set the correct hologram world in the main hold.
   SetHologramWorld();

   // Don't do cleanup when reloading a savegame on the ship.
   if (GetLoadFromSaveGame()) {
       DelayCommand(1.0, RebuildPartyTable());
       return;
   }    

   // Cleanup...
   for(iIdx = NPC_ATTON; iIdx <= NPC_DISCIPLE; iIdx++) {
       // Remove everyone else from the party.
       if(IsNPCPartyMember(iIdx)) {
           RemoveNPCFromPartyToBase(iIdx);
       }

       // And respawn everyone on the ship...
       object oNPC = GetObjectByTag(GetPartyMemberTag(iIdx));
       if (GetIsObjectValid(oNPC)) {
           DestroyObject(oNPC);    
       }

   }

   // Spawn the currently joined party members.
   for(iIdx = NPC_ATTON; iIdx <= NPC_DISCIPLE; iIdx++) {
       // Put everyone at a waypoint with tag "POST_" + Their Tag.
       if(GetNPCSelectability(iIdx) != -1) {
           object oNPC = GetObjectByTag(GetPartyMemberTag(iIdx));
           object oWP  = GetObjectByTag("POST_" + GetPartyMemberTag(iIdx));

           if (!GetIsObjectValid(oNPC)) {
                oNPC = SpawnAvailableNPC(iIdx, GetLocation(oWP));
           }

           if (GetIsObjectValid(oNPC)) {
               ChangeToStandardFaction(oNPC, STANDARD_FACTION_NEUTRAL);
               SetCreatureAILevel(oNPC, AI_LEVEL_HIGH);
           }
       }
   }
}

 

Set the tags of each party member that will be put in each party table slot in the first function in the script. It's important that this matches the value in the Tag field of their UTC, or bad things will happen. :)

 

NPC_* is the party table slot in question, where the constant (representing a value from 0-11) is named after the original game occupant of that slot. You can use the slot number instead of the constant if that's less confusing.

 

2. How do I make it, so that when the player leaves the shp, he is promted with the character selection and party members are selectable again.

 

Put a trigger or something where you wish the exit from the ship should be. Then put an OnEnter event script of the trigger to something like:

void main() {
   object oEnter = GetEnteringObject();

   if (GetIsPartyLeader(oEnter)) {
       int iOutside = GetGlobalNumber("003EBO_BACKGROUND");

       // Don't allow player to exit ship if it's in space or hyperspace.
       if ((iOutside != 8) && (iOutside != 10)) {
           SetGlobalFadeOut();
           SetFadeUntilScript();   
           ShowPartySelectionGUI("st_partyselect", -1, -1, TRUE);                  
       }       
   }
}

 

Then create the script that is fired by the party selection screen, which I called "st_partyselect" in the script above:

void main() {
   SetGlobalFadeIn();

   // Stop if player hit cancel on the party selection screen.
   if (!GetRunScriptVar())
       return;

   // Get the name of the module to load...
   int iModule = GetGlobalNumber("003EBO_RETURN_DEST");
   string sModule = "ERROR";

   // Add the names of the modules here, that each planet in
   // "planetary.2da" should correspond to.
   switch (iModule) {
       case 0:  sModule = "NameOf1stPlanetModule"; break;
       case 1:  sModule = "NameOf2ndPlanetModule"; break;
   }   

   // Set Tag of waypoint that you should arrive at when exiting ship.
   if (sModule != "ERROR") {
       StartNewModule(sModule, "TagOfWaypointToExitTo");   
   }
}

 

You'll have to set the name of your own modules which should correspond to where you arrive at each planet in the switch/case statement. The case is the row number in planetary.2da of the planet, the string is the name of the module itself. Set TagOfWaypointToExitTo to the Tag of the waypoint in the module you wish the player to be spawned at when they leave the ship.

 

3. How do i use the galaxy map ( i am just using a computer with reply options) to change the exit location at the end of the ship.

 

Create a placeable you wish to use as galaxy map, and make it selectable/usable. Then in the OnUsed event script slot, put a script like:

void main() {
   // Set all planets as unavailable to start, so we can determine
   // which ones should be shown below...
   // Planet numbers are from "planetary.2da".
   int iWorld;
   for (iWorld = 0; iWorld < 16; iWorld++) {
       SetPlanetAvailable(iWorld, FALSE);
       SetPlanetSelectable(iWorld, FALSE); 
   }   


   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
   // Then set which planets should be on the map and selectable.
   // Put any conditions here that determines when a planet should
   // show up on the galaxy map. For example:

   // Determines if the first planet shows on the map at all.
   SetPlanetAvailable(0, TRUE);  

   // Determines if the first planet is a valid travel target. If set
   // to FALSE, the string set in the "lockedoutreason" in "planetary.2da"
   // for this planet will be shown instead, and the "OK" button will 
   // be unclickable.
   SetPlanetSelectable(0, TRUE);

   // - - - - - - - - - - - - - - - - - - - - - - - - - - - -  


   // Get which world we are currently on.
   int iCurrent = GetGlobalNumber("003EBO_RETURN_DEST");

   // Don't allow travel to the planet you are currently on.
   SetPlanetSelectable(iCurrent, FALSE);       

   // Show galaxy map screen with the current planet selected.
   ShowGalaxyMap(iCurrent);
}

 

In this script you should put any conditions that determine when a planet becomes available and selectable/unselectable on the galaxy map. You can do this by setting globals in dialogue or whenever your plot advances and a new planet should become available. Then in this script you check if the global is set and switch on the planet on the map. See the part of the script within the dashed lines above. The script then activates the galaxy map screen.

 

The galaxy map screen itself fires a script that must be named "k_sup_galaxymap" when the player selects a planet on the map. This script should be used to set the value that determines which module the player exits the ship to (which was done in the trigger script above), to play any travel movies and to switch the view outside the ebon hawk cockpit window as necessary. It could look like:

// k_sup_galaxymap.nss
// This script is fired by the galaxy map screen when the player
// selects a planet and presses the "OK" button...
#include "k_inc_hawk"

void main() {
   // Row numbers from "planetary.2da"...
   int iSelected = GetSelectedPlanet();

   // Player pressed cancel, don't continue.
   if(iSelected == -1)
       return; 


   // Set selected planet as new currently visited planet.
   // This is used by the ship exit trigger to pick the correct module.
   SetGlobalNumber("003EBO_RETURN_DEST", iSelected);

   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
   // Put any travel movies and cockpit background changes here, 
   // for example:
   switch (iSelected) {
       case 0: 
           // Movie travelling to the first planet
           QueueMovie("TravelMovie1Name"); 

           // Backdrop seen outside the Ebon Hawk cockpit windows.
           SetGlobalNumber("003EBO_BACKGROUND", 1);
       break;

       case 1: 
           // Movie travelling to the second planet
           QueueMovie("TravelMovie2Name"); 

           // Backdrop seen outside the Ebon Hawk cockpit windows. 
           SetGlobalNumber("003EBO_BACKGROUND", 2);
       break;      
   }

   /* Set the 003EBO_BACKGROUND global value to get the cockpit view
      for:
      0 = peragus
      1 = citadel station
      2 = telos academy
      3 = nar shaddaa
      4 = dxun jungle
      5 = dantooine
      6 = korriban
      7 = droid planet
      8 = empty space
      9 = malachor
      10 = swirling purple hyperspace */
   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

   // Update cockpit window background.
   SetBackground();

   // Update planetary hologram in the main hold.
   SetHologramWorld();  

   SignalEvent(GetArea(GetFirstPC()), EventUserDefined(1));
   PlayMovieQueue();     
}

 

Add one case in the switch statement for each of your planets. The case number is the row number in planetary.2da of the planet the player selected as travel destination.

 

The 003EBO_BACKGROUND global variable determines what view is seen outside the cockpit windows, and what hologram is shown at the communicator in the main hold. See the comment in the script above what the numbers correspond to.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...