Jump to content

Home

Scripting TSL question


Recommended Posts

Do the scripts in TSL use the same format as they do in KOTOR?

 

I wasn't sure because I'm trying to spawn an NPC inside the Ebon Hawk, and then recruit them, but I'm confused about the "orientation" and "bearing" numbers found in the whereami armband. I don't remember having to place them in for KOTOR...

 

and also for some reason the format I've used for recruiting in KOTOR won't work on TSL, all it does is after the conversation is ended, it pops up the party selection screen but no changes have been made..... please help...:confused:

Link to comment
Share on other sites

Originally posted by Dark_lord_Cheez

and also for some reason the format I've used for recruiting in KOTOR won't work on TSL, all it does is after the conversation is ended, it pops up the party selection screen but no changes have been made

 

I get the same result. I use Darth333's script from the tutorial and the party selection screen pops up but the same NPC's are there.

Link to comment
Share on other sites

The scripting language is pretty much the same, though some new functions have been added.

 

Orientation is just the way you want the creature to face when spawned. Don't know what value the armband returns, but I'd guess you could use the orientation value when you define your spawn location in script.

 

This script should work to replace/recruit people in the party. Works fine as far as I've noticed so far at least. (It assumes that both the character being replaced and the one who should replace it has the same tag. This is recommended anyway since it will mess up the cutscenes otherwise.)

 

#include "k_inc_glob_party"

// ------------------------------------------------------
// Spawn the party member in its proper place on the Ebon 
// Hawk. Wrapper so it can be delayed.
// ------------------------------------------------------
void SpawnPartyMemberVoid(int nSlot) {
   SpawnIndividualPartyMember(nSlot, "WP_gspawn_");    
}

// ------------------------------------------------------
// Wrapper for letting the player execute the script 
// functionality instead of the original OBJECT_SELF.
// ------------------------------------------------------
void ReplaceAndAddToParty(int nSlot, object oCre) {
   // ST: Clear out whoever currently occupies this party slot.
   RemovePartyMember(nSlot);
   RemoveAvailableNPC(nSlot);

   // ST: Add the new creature to the party.
   AddAvailableNPCByObject(nSlot, oCre);

   // ST: If not on the ebon hawk, add to the active party if there
   //     is a free slot, otherwise show party selection screen.
   if (GetModuleName() != "003EBO") {
       if (GetPartyMemberCount() < 3)
           AddPartyMember(nSlot, oCre);
       else
           DelayCommand(0.5, ShowPartySelectionGUI());

   }

   // ST: Delete the old party member if present, and the new one if
   //     they haven't joined the party (thus essentially sending them
   //     back to the Ebon Hawk.)
   int nIdx = 0;
   object oNPC = GetObjectByTag(GetNPCTag(nSlot), nIdx);
   while (GetIsObjectValid(oNPC)) {
       if (!IsObjectPartyMember(oNPC)) {
           DestroyObject(oNPC, 0.0, TRUE);
       }
       oNPC = GetObjectByTag(GetNPCTag(nSlot), ++nIdx);
   }

   // ST: If we are already on the Ebon Hawk, spawn the new party member
   //     in its proper place, without joining the active party.
   if (GetModuleName() == "003EBO")
       DelayCommand(0.2, SpawnPartyMemberVoid(nSlot)); 
}

// ------------------------------------------------------
// Main function - runs when the script is triggered.
// ------------------------------------------------------
void main() {
   // ST: Get the party slot the new member should occupy.
   int nSlot = GetScriptParameter(1);

   // ST: Get the creature that should join the party.
   object oNPC = OBJECT_SELF;

// ST: This function does most of the work. It is run by the player
//     rather than the new party member to ensure that everything is
//     executed since the party member may be deleted halfway through
//     if they aren't joining the party immediately.
   AssignCommand(GetFirstPC(), ReplaceAndAddToParty(nSlot, oNPC));
}

 

It's written to be called from the conversation of the creature that should join. You set the first parameter on the dialog node for the script to the party slot you wish the creature to appear in:

 

0 = Atton

1 = Bao-Dur

2 = Mandalore

3 = G0T0

4 = The Handmaiden

5 = HK47

6 = Kreia

7 = Mira

8 = T3M4

9 = Visas

10 = Hanharr

11 = The Disciple

 

That script would only display the party selection GUI if you aren't on the Ebon Hawk (since you can't change around your party there anyway) and if there isn't a free slot in the active party already.

 

EDIT: Restructured the script a bit to make it more reliable.

Link to comment
Share on other sites

Originally posted by Dark_lord_Cheez

I wasn't sure because I'm trying to spawn an NPC inside the Ebon Hawk, and then recruit them, but I'm confused about the "orientation" and "bearing" numbers found in the whereami armband. I don't remember having to place them in for KOTOR...

In Kotor one, when you use the whereami cheat it only gives you the x,y,z coordinates of your object.

 

However, I added orientation (degrees): this is practical if you want your npcs/placeables to face a certain direction when you spawn them. Example:

void main() 
{ 
// xyz coordinates:
float x=0.00f;  
float y=0.00f;
float z=0.00f;
//orientation goes here:
float r=0.0f;
vector vecNPC=Vector(x,y,z);
location locNPC=Location(vecNPC, r);
CreateObject(OBJECT_TYPE_CREATURE,"npc_tag",locNPC);
}

 

Bearing: the script attached to the armband also converts degrees into radians. This is used for placeables and doors in the .git files . It was added to save trouble to module makers so they don't have to calculate it manually :)

Link to comment
Share on other sites

Originally posted by Dark_lord_Cheez

but I'm confused about the "orientation" and "bearing" numbers found in the whereami armband. I don't remember having to place them in for KOTOR...

 

Bearing is only needed for situated objects, and only if you if you want to create them in the GIT file. Otherwise you can ignore it.

 

Orientation obtained in whereami is not technically the orientation - it's the facing angle in degrees. It works fine if you are spawning your NPCs via a script, using CreateObject. However, if you are inputting them in the GIT file, you need two values for orientation: X_Orientation and Y_Orientation.

Link to comment
Share on other sites

#include "k_inc_glob_party"

void SpawnPartyMemberVoid(int nSlot) {
   SpawnIndividualPartyMember(nSlot, "WP_gspawn_");    
}

void ReplaceAndAddToParty(int nSlot, object oCre) {
   RemovePartyMember(nSlot);
   RemoveAvailableNPC(nSlot);
   AddAvailableNPCByObject(nSlot, oCre);

   if (GetModuleName() != "003EBO") {
       if (GetPartyMemberCount() < 3)
           AddPartyMember(nSlot, oCre);
       else
           DelayCommand(0.5, ShowPartySelectionGUI());

   }

   int nIdx = 0;
   object oNPC = GetObjectByTag(GetNPCTag(nSlot), nIdx);
   while (GetIsObjectValid(oNPC)) {
       if (!IsObjectPartyMember(oNPC)) {
           DestroyObject(oNPC, 0.0, TRUE);
       }
       oNPC = GetObjectByTag(GetNPCTag(nSlot), ++nIdx);
   }

   if (GetModuleName() == "003EBO")
       DelayCommand(0.2, SpawnPartyMemberVoid(nSlot)); 
}

void main() {
   int nSlot = GetScriptParameter(1);
   object oNPC = OBJECT_SELF;

   AssignCommand(GetFirstPC(), ReplaceAndAddToParty(nSlot, oNPC));
}

 

not to be a bother or anything, but I'm still fairly new to scripting... is it possible if you could show which fields exactly I have to adjust to get this to work...

 

again, I don't want to seem like a bother, I just don't understand most of the scripts unless I know which fields to adjust with what information..

Link to comment
Share on other sites

Originally posted by Dark_lord_Cheez

not to be a bother or anything, but I'm still fairly new to scripting... is it possible if you could show which fields exactly I have to adjust to get this to work...

 

again, I don't want to seem like a bother, I just don't understand most of the scripts unless I know which fields to adjust with what information..

 

You shouldn't have to adjust anything in the script as long as it is attached to the conversation of the creature that is supposed to join you. It's made to be fairly generic.

 

What you need to do is specify which party slot the creature should appear in (and replace its current occupant if the original NPC has already joined your party). You do this in your dialog file. If you use the DLG Editor, you attach the compiled script to one of the "Script #" fields. To the right of those are a number of boxes where you specify parameters to the scripts. In the box labeled "P1" to the right of the script box, specify the party slot.

 

In my above post I posted what numbers corresponds to which slot. Use the number for the original party NPC you wish to replace with your own. Remember that Disciple/Handmaiden and Hanharr/Mira are mutually exclusive, since they share the same spot on the party selection screen even if they have different slot numbers in the party table.

 

Also make sure your new NPC has the same TAG set in its (UTC) blueprint as the party member you intend to replace. Otherwise you'll run into trouble, not only with this script but the game in general. :)

 

 

At any rate, I edited my post above and added lots of comments in the script code, hopefully it should help you understand what it does a bit better if you need to modify anything.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...