Note: LucasForums Archive Project
The content here was reconstructed by scraping the Wayback Machine in an effort to restore some of what was lost when LF went down. The LucasForums Archive Project claims no ownership over the content or assets that were archived on archive.org.

This project is meant for research purposes only.

[K1] Scripting & creating new recruitable Party Member?

Page: 1 of 1
 Breger
11-13-2007, 4:32 PM
#1
Hello again, I return with questions once more.
This time, it's about scripting and recruitable party members.
I've read a few tutorials here (Darth333's 'How to recruit an npc in less than 10 steps' the one I've read the most), and have begun to crawl my way through these kind of things.
Now, I wish to replace T3-M4 with my own NPC, but I would also like to sell the droid off (I'm replacing him because of the non-existent role he plays in the story) to one of the shopkeepers on Dantooine. I guess that requires a script. But how would that script be written?
Oh, and please note that when you answer me, use small words. I'm not so into this with scripting, yet.

Also, I wish to add a custom voice to my NPC, and also want him to chime in with some comment from time to time, like all other NPCs, maybe even say something to one of them. The voice I almost have now, for all three of my recruitables (Yes, three of them. I want to give people a choice. Possibly also a choice of who's to be replaced), but from what I've understood, it is quite hard to change voices, if not impossible.
Is it possible to add a custom voice to an NPC, and force the NPC to use that voice and chime in like everyone else? I guess that it isn't so hard with T3, since he hasn't much to say. But if I were to replace, say, Carth, how would I replace his voice with my own, and make him talk to the others, or as I've said three times now, chime in when interacting with other NPCs that do nothing than giving quests?

*Whew!* Well, I have no more questions for now. :xp:
 stoffe
11-14-2007, 8:41 AM
#2
I wish to replace T3-M4 with my own NPC, but I would also like to sell the droid off (I'm replacing him because of the non-existent role he plays in the story) to one of the shopkeepers on Dantooine. I guess that requires a script. But how would that script be written?

If you want to do the trade via dialog with the shopkeeper you would need two scripts. One conditional script that checks if T3M4 is in the party with the player (to make the sale dialog branch available), and one action script that removes T3M4 from the party and gives the player the credits.

The conditional script you place on the trade dialog node might look something like:

int StartingConditional() {
return (IsNPCPartyMember(NPC_T3_M4)
&& (GetAppearanceType( GetObjectByTag("T3M4") ) == 2));
}


This script checks if the character in T3M4's party slot is in the active party with the player, and that his appearance is that of T3M4 (since you want to reuse that party slot for your own character who the player presumably shouldn't be able to sell as well :)).

The action script may look something like:

void main() {
RemovePartyMember(NPC_T3_M4);
RemoveAvailableNPC(NPC_T3_M4);
GiveGoldToCreature(GetFirstPC(), 4000);
}


This script removes the character in T3M4's party slot from the active party, from the party selection screen, and gives the player 4000 credits.

To compile the scripts, paste them into KotorTool's text/script editor and use it to compile them, and make sure the resulting .NCS files generated are in the game's override folder. Name the scripts something unique, and then put those names in the dialog file on the branches which deal with the trade in the DLG file of the merchant.
 Miles Edgeworth
11-15-2007, 12:58 PM
#3
The conditional script you place on the trade dialog node might look something like:

int StartingConditional() {
return (IsNPCPartyMember(NPC_T3_M4)
&& (GetAppearanceType( GetObjectByTag("T3M4") ) == 2));
}


Suppose my NPC could have this appearance, what would the script look like, then?
 stoffe
11-15-2007, 6:01 PM
#4
Suppose my NPC could have this appearance, what would the script look like, then?

You're replacing T3M4 with an identical-looking droid? :) If the tag and appearance are identical you could try checking for the name of the character with the GetName() function instead. Like:


int StartingConditional() {
return (IsNPCPartyMember(NPC_T3_M4)
&& (GetName(GetObjectByTag("T3M4")) == "T3-M4"));
}


Or you could add a global boolean variable that indicates whether your new party member has been recruited, and check if this has not been set instead.
 Breger
11-16-2007, 10:14 AM
#5
So, now that I've tried this, I guess that if I wanted to give the dialogue a Dark Sided option, I would have to make a new script, right? Oh, and don't give me any hints, I want to try it out for myself. ;)

Thank you for all help so far. I might have more questions soon.
 stoffe
11-16-2007, 12:59 PM
#6
So, now that I've tried this, I guess that if I wanted to give the dialogue a Dark Sided option, I would have to make a new script, right?

If you just want to give a normal Darkside alignment shift there are generic dialog action scripts for that already in the game you can use, so you won't have to make your own. You can find those in the scripts.bif data file.

Or you can just add the code for alignment shift to the script that "sells" T3. :)
 Breger
11-21-2007, 3:21 PM
#7
Ok, now let's see.
I've managed to get an NPC into the game, giving him dialogue, and also managed to edit the global.jrl to give a quest. Now I'm going to add the enemies to a certain location, but I'm not sure how? I want them to spawn when I enter the module, but I don't understand how to do that.
I've been searching around, but I can't seem to understand it. I'm at a loss for this with scripts.

Oh, and if I wanted to add a script that checks if the lead enemy is dead, how do I go about to do that?
I checked the "Talk - Fight - Talk" tutorial, thinking of modifying that script a bit, but I do not think it is possible, right?
Here's what I did:
void main()
{
int nCurrentHP;
int nUser = GetUserDefinedEventNumber();
if(nUser == 1006) // DAMAGED
{
nCurrentHP=GetCurrentHitPoints();
if (dead,thenameofthenpc) {


SetLocalBoolean(OBJECT_SELF,0,TRUE);
}

}

}

As you probably can tell, I know next to nothing about such things.
And how do I use the SetLocalBoolean part? I read that it helps the game remember what stage a quest is on, but how?
I'm really thankful for all help.
Page: 1 of 1