Jump to content

Home

Creating Puppets anyone?


Dak Vesser

Recommended Posts

There's allot of integers in Kotor2's nwscript (starting at line 840) that are used for creating Puppets which I believe belong in their own table out side of the npc partytable. These Puppets are made to follow the assigned NPC arround. Example: Puppet = Remote, and assigned Npc = BauDur

 

My problem is - I don't really know how to script all that good, but I was wondering if there is a way to create the right scripts so we can create and spawn are own Puppets and assign the to any character of our choosing. I just started looking into this last night, so there's allot for me to learn about this. These are some of the script comands for Puppet spawing and assigning:

 

[size=2][color=#33CCFF]// 840
// RWT-OEI 07/18/04
// This adds an existing puppet object to the party. The
// puppet object must already exist via SpawnAvailablePUP
// and must already be available via AddAvailablePUP*
// functions.
int AddPartyPuppet(int nPUP, object oidCreature);

// 841
// RWT-OEI 07/19/04
// This returns the object ID of the puppet's owner.
// The Puppet's owner must exist and must be in the party
// in order to be found.
// Returns invalid object Id if the owner cannot be found.
object GetPUPOwner(object oPUP = OBJECT_SELF);

// 842
// RWT-OEI 07/19/04
// Returns 1 if the creature is a Puppet in the party.
// Otherwise returns 0. It is possible for a 'party puppet'
// to exist without actually being in the party table.
// such as when SpawnAvailablePUP is used without subsequently
// using AddPartyPuppet to add the newly spawned puppet to
// the party table. A puppet in that in-between state would
// return 0 from this function
int GetIsPuppet(object oPUP = OBJECT_SELF );

// 843
// RWT-OEI 07/20/04
// Similiar to ActionFollowLeader() except the creature
// follows its owner
//nRange is how close it should follow. Note that once this
//action is queued, it will be the only thing this creature
//does until a ClearAllActions() is used.
void ActionFollowOwner(float fRange = 2.5);[/color][/size]

 

So if anyone has Ideas, questions, answers, or comments, this thread should be the place to talk about creating "Puppets".

Link to comment
Share on other sites

I share your curiosity here. Indeed, this is a brand new area of modding introduced by TSL!

 

I noticed that puppets are also preserved in savegames and AVAILPUPx where x is a number. I wasn't sure how editable they would be or what they even did, but perhaps KSE will be modified to support them soon. :)

Link to comment
Share on other sites

It would be kinda k0ol to spawn a "Mark1 Battle Droid" or another "HK-50 droid, or even a custom made .UTC" for example. Spawn it in the area as a Puppet and assign it to the Main Play character so it'll follow him/her around everywhere and also attack enemies when needed to. "Maybe give it some dialogue as well"

 

I think it's all about how we script, and if we make the right .nss scripts, and get "nwnnsscomp" to compile them without any problems? I think this type of mod would be in serious high demand!

 

Suggestion: We could make an Armband out of it or something. That could spawn, assign, replace, and delete puppets. It could also give us the ability to take any npc and turn it into a puppet.

 

It needs to be done :D

Link to comment
Share on other sites

That might be a good place to start. but the thing about a puppet is that the pupppet graphic model is not clipping, which means anyother character can walk right through it so that way it doesn't clutter and get in the way..

 

Comment: I think that the medical droid is not a true puppet. Its just a utc that's using a "followtheleader" script.

 

 

Any Ideas?

Link to comment
Share on other sites

Originally posted by Dak Vesser

Comment: I think that the medical droid is not a true puppet. Its just a utc that's using a "followtheleader" script.

 

Any Ideas?

 

Actually, I think you might be right.

 

Looks like there can be only 3 "available" puppets:

 

int PUP_SENSORBALL = 0;

int PUP_OTHER1 = 1;

int PUP_OTHER2 = 2;

 

 

First one is always the remote. 1 and 2 can be used. Using index above 2 makes AddAvailablePUPByObject fail...

 

Secondly, I haven't been able to assign a puppet to player (yet). Maybe it's because I was trying to get Hanharr to be a puppet :D , or maybe it's because it's not possible for main player to have one.. Not sure yet.

Link to comment
Share on other sites

It would be nice to know how these integers are put into script, like how are they written. But of course Obsidian did not put any source scripts about puppets in the game, and therefore it'll be second guessing and "trial'n'error" untill someone comes up with a working script.

 

 

Actually, I think you might be right.

 

Looks like there can be only 3 "available" puppets:

 

int PUP_SENSORBALL = 0;

int PUP_OTHER1 = 1;

int PUP_OTHER2 = 2

;

 

I guess int PUP_OTHER1 & int PUP_OTHER2 should equal the NPC you want to be the puppet. It looks like they're researved for whatever you want.. (I think)

Link to comment
Share on other sites

Originally posted by Dak Vesser

I guess int PUP_OTHER1 & int PUP_OTHER2 should equal the NPC you want to be the puppet. It looks like they're researved for whatever you want.. (I think)

 

Hmm, I don't know. Remote has puppet index 0, and has no NPC index as far as I can tell.

 

So far, I've managed to create a puppet (little Yoda guy) and have it follow Handmaiden. The problem now is that whenever my party gets into a fight, puppet stops following afterwards.

Link to comment
Share on other sites

Originally posted by Xcom

Hmm, I don't know. Remote has puppet index 0, and has no NPC index as far as I can tell.

 

So far, I've managed to create a puppet (little Yoda guy) and have it follow Handmaiden. The problem now is that whenever my party gets into a fight, puppet stops following afterwards.

 

 

I was wondering if you would be so kind as to share that script with us,

and I think that as far as your puppet not attacking the ememy or following after combat: check if the UTC has the k_hen_attacked01 script in OnAttacked and k_hen_percept01 in OnNotice, and also k_hen_combend01 in OnEndRound. that should make it fight back,and follow "In theory"

Link to comment
Share on other sites

Originally posted by Dak Vesser

I was wondering if you would be so kind as to share that script with us,

and I think that as far as your puppet not attacking the ememy or following after combat: check if the UTC has ..

 

I've almost entirely reproduced Remote's OnBlahBlah script section in the utc file. ;)

 

As for the script, here it is. I am running it off a band.

void main()
{
vector vPos = GetPosition(GetPartyLeader());
float fPCFace = GetFacing(GetPartyLeader());
location lLoc = Location(vPos + AngleToVector(fPCFace) * 1.5f,fPCFace);
int PUP_TEST = 2;
object pupYoda= CreateObject(OBJECT_TYPE_CREATURE,"xc_yoda",lLoc, TRUE);
if (!AddAvailablePUPByObject(PUP_TEST, pupYoda ))
{
	SendMessageToPC (GetFirstPC(), "AddAvailablePUPByObject FAILED!");
	return;
}
if (!AddPartyPuppet(PUP_TEST, pupYoda ))
{
	SendMessageToPC (GetFirstPC(), "AddPartyPuppet FAILED!");
	return;
}	
if (!AssignPUP(PUP_TEST, NPC_HANDMAIDEN)) // !!! Handmaiden should be in your current party
{
	SendMessageToPC (GetFirstPC(), "AssignPUP FAILED!");
	return;
}
AssignCommand(pupYoda, ClearAllActions());	
AssignCommand(pupYoda, ActionFollowOwner());

//debug
if (GetIsPuppet(pupYoda)) {
	SendMessageToPC (GetFirstPC(), GetName(pupYoda) + " is puppet!");
	SendMessageToPC (GetFirstPC(), GetName(pupYoda) + " owner is " + GetName(GetPUPOwner(pupYoda)));
} else {
	SendMessageToPC (GetFirstPC(), GetName(pupYoda) + " is NOT A FREAKING puppet!");
}


}

Link to comment
Share on other sites

didn't tested any of this yet (no time to open the game :( ) but this is what remote uses to add him to the party:

// Adds baodur and remote to party
// JAB-OEI 9/14/04

void main()
{
   vector vPos = GetPosition(GetPartyLeader());
   float fPCFace = GetFacing(GetPartyLeader());

   location lLoc = Location(vPos + AngleToVector(fPCFace) * 1.5f,fPCFace);

   object oBaoDur = CreateObject(OBJECT_TYPE_CREATURE,"p_baodur",lLoc);
   object oRemote = CreateObject(OBJECT_TYPE_CREATURE,"p_remote",lLoc);

   AddAvailableNPCByObject(NPC_BAO_DUR,oBaoDur);
   AddAvailablePUPByObject(PUP_SENSORBALL,oRemote);
   AddPartyMember(NPC_BAO_DUR, oBaoDur);
   AssignPUP(PUP_SENSORBALL,NPC_BAO_DUR);

...
}

 

Originally posted by Xcom

The problem now is that whenever my party gets into a fight, puppet stops following afterwards.

 

Make sure you have the correct OnHeartbeat script to make the Puppet follow you. (Remote uses k_hen_heartbt01 )

 

(For npcs other than puppets and party members, I got the sabers following my party leader after a fight in my lightsaber attack force power mod by modifying slightly a script made by Gameunlimited for Kotor 1 - source code is included in my mod)

Link to comment
Share on other sites

Originally posted by Dak Vesser

I was wondering if you would be so kind as to share that script with us,

and I think that as far as your puppet not attacking the ememy or following after combat: check if the UTC has the k_hen_attacked01 script in OnAttacked and k_hen_percept01 in OnNotice, and also k_hen_combend01 in OnEndRound. that should make it fight back,and follow "In theory"

 

Has anybody taken a close look at these AI scripts and the include files that are referenced in them. I don't have a chance to look at them at the moment but they may have puppet self tests within some of the include files. If there are self tests we may only need to adjust these scripts to test for 2 other puppets in addition to the remote. This may also prevent the puppet from not responding after combat.

 

I know I was getting ready to attack research into puppets when I saw this thread so already it is useful.

Link to comment
Share on other sites

Originally posted by Darkkender

Has anybody taken a close look at these AI scripts and the include files that are referenced in them.

 

Okay, apparently all party members use special spawn and UserDefined scripts which all include something else and it goes on and on. k_oei_hench_inc scrips is 54 kb! LOL.

 

So, I ended up writing custom spawn and userdef scripts for my lil Yoda, mostly basing it on Remote's (indeed, it sets its faction to puppet or something like that somewhere in those scripts). Anyways, it still "loses" its owner after the attack.. Damn. :mad: I need to inspect those scripts more closely. I did manage to equip him with attacking AI which is cool.

Link to comment
Share on other sites

Originally posted by Anach

Having those extra NPC follow, like Bao-Dur's droid, the repair droids or humanoid NPC is very annoying in TSL as it makes my party members bump into the back of me all the time.

 

I like the idea though.

 

 

Like I said, It would be great to create scripts for an armband that would allow you to add or delete a puppet at will. That way it doesn't get annoying. And they could also be holo-images too.. "Heh" why not!

Link to comment
Share on other sites

Originally posted by Xcom

Ah, yes. I think I got it working..

 

(ps. I'm a comlpete moron :o )

 

How did you get the puppet to follow? I can't seem to get mine moving at all - before, during, and after combat. I can get it to attack an enemy but it won't even follow BaoDur who it's assigned to in the first place. <---- :mad:

 

Have any tips on the ai scripts?

Link to comment
Share on other sites

I am not behind the PC that has the game right now.

 

Compare UTC files of remote and puppet you are using in GFFEdit. There is some stuff that doesn't show in Kotor Tool's Character Editor.

 

As to AI scripts, I practically ripped them from k_oie_hench_inc.nss Only changed it so that it doesn't loop computer noise or somesuch.

 

BTW.. my stupid mistake was that I made a typo in UTC script reference, so the thing didn't have HEARTBEAT behavior. It followed owner because of the command I used in the script above, but when attack ended (different event), it didn't do anything.

Link to comment
Share on other sites

Originally posted by Darth333

Make sure you have the correct OnHeartbeat script to make the Puppet follow you. (Remote uses k_hen_heartbt01 )

 

Although Remote's OnHearbeat points to k_hen_heartbt01, his actual heartbeat behavior seems to be user defined.

Link to comment
Share on other sites

All of the NPC AI scripts are going to be the same basically when you look in the gff file.

 

the k_hen_heartbt01 script is the same script for all henchmen. What you need to do is open up the script and see what include files are referenced in there. you will probably need to read through the script and it's includes to find the variable if statements that probably define the puppet ai working.

 

However has anybody on this thread tried Darth333's script above since she posted it?

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...