PDA

View Full Version : Adding Party Members with Scripts


ABCoLD
07-17-2006, 10:18 PM
I'm trying to do a new, snazzy and generally righteous version of Bypass Peragus. The only problem is my scripting skills aren't exactly up to snuff. I can get most things to work properly. But for the life of me I can't figure out how to spawn the party members I want and add another to the available party members. I can't seem to get AddNPCbyTemplate or AddNPCbyObject to work properly for me. AddPartyMember also seems to be a bust.
AddAvailableNPCByObject(NPC_ATTON,GetObjectByTag("atton"));

AddPartyMember(NPC_ATTON,GetObjectByTag("atton"));
The above isn't working for me, I have it set in a bit of script tucked away in the middle of a conversation. Afterwards I fire another string of script that adds a bunch of variables including
SetGlobalNumber("101PER_Atton_Joined", 1);
(Not that it should matter I think, strictly speaking for the function of the first code to work.) Then I have the second script whisk me off to a magical new land with StartNewModule. So, any ideas what I'm doing wrong? I really don't need any fancy multi-function can be used for any party member code involving int. I just need something straightforward and clean that's designed to do one thing. The rest of the scripting seems to work and function perfectly, except for that darn party member adding and such on and so forth. Making me scratch my head.

Princess Artemis
07-17-2006, 10:56 PM
I think the problem is you're not actually spawning Atton before adding him to the party. Assuming the dialogue you're tucking the script into isn't with Atton.

This, or a variation thereof, might work. I've only used it on an on enter script, but it might work from a dialogue. My mistake, it will work in a script attached to a dialogue, a_carth.ncs uses a version of this for Bastila toward the end of K2.
CreateObject(1, "p_atton", Location(Vector(X, Y, Z), Orientation));
The x, y, z and orientation you'd need to get from Darth333's Whereami band or from Kotor Tool's module editor if the module in question is available.

Once Atton exists, then your script can grab him by his tag and shove him into the party. You could go this way...
object oAtton = GetObjectByTag("Atton");
if (GetIsObjectValid(oAtton)) {
AddAvailableNPCByObject(NPC_ATTON, oAtton);
AddPartyMember(NPC_ATTON, oAtton);
}

That's pretty much how I'm getting Dustil to take over NPC_HK_47, so I'd guess it would work for Atton.

stoffe
07-18-2006, 08:02 AM
I think the problem is you're not actually spawning Atton before adding him to the party. Assuming the dialogue you're tucking the script into isn't with Atton.

This, or a variation thereof, might work.(...snip...)
Once Atton exists, then your script can grab him by his tag and shove him into the party. You could go this way...

CreateObject(1, "p_atton", Location(Vector(X, Y, Z), Orientation);
object oAtton = GetObjectByTag("Atton");
if (GetIsObjectValid(oAtton)) {
AddAvailableNPCByObject(NPC_ATTON, oAtton);
AddPartyMember(NPC_ATTON, oAtton);
}



For "some variation", if you want to add a party member that doesn't exist in the game world yet you can use AddAvailableNPCByTemplate() instead, which would create the NPC and then add them to the party table. If you want to add them into the active party at the same time you can spawn them from the party table add add them. Something like:

AddAvailableNPCByTemplate(NPC_ATTON, "p_atton");
AddPartyMember(NPC_ATTON, SpawnAvailableNPC(NPC_ATTON, GetLocation(OBJECT_SELF)));


...which would work pretty much the same as your variant, so you can do it either way depending on personal taste. :)


Though if the active party is already full this won't add him to the active party, just the party table, allowing you to use the party selection screen to add him (if the area permits it).