Jump to content

Home

Scripting Question - recruiting


Bunk

Recommended Posts

I've been fiddling with an idea here. Using an armband to pull recruited NPCs in and out of the party. (Big thanks to Darth333 for the armband using spells.2da to fire a dialog idea)

 

Unfortunately, I'm still really in the learning proccess here. Currently my dialog gives three options:

 

add npc1 to hk47s slot

add npc2 to gotos slot

put hk47 back in his slot

 

First two options work great, but the third one doesn't. The script is firing the third option, because it is going to the party selection screen, but it's not putting HK47 back in.

 

Here's the script:

 

void main() {

int nSwitch=GetScriptParameter(1);

object oPC=GetFirstPC();

switch (nSwitch) {

case 1:

RemoveAvailableNPC(5);

AddAvailableNPCByTemplate(5, "twinsun1");

DelayCommand(1.5,ShowPartySelectionGUI());

break;

case 2:

RemoveAvailableNPC(3);

AddAvailableNPCByTemplate(3, "morgan");

DelayCommand(1.5,ShowPartySelectionGUI());

break;

case 3:

RemoveAvailableNPC(5);

AddAvailableNPCByTemplate(5, "p_hk47");

DelayCommand(1.5,ShowPartySelectionGUI());

break;

}

 

}

 

Now as best I can tell "p_hk47" is HK's uti file. Any ideas why he isn't going back in? It doesn't give any errors, it just leaves my recruited NPC in his slot.

Link to comment
Share on other sites

Debugging with SendMessageToPC might help you shed light on the problem. Try this debug version and check your Feedback screen.

void main() {
int nSwitch=GetScriptParameter(1);
int nResult;
object oPC=GetFirstPC();
switch (nSwitch) {
case 1:
 SendMessageToPC(GetFirstPC(),"Switch 1 selected");
 nResult=RemoveAvailableNPC(5);
 if (nResult) {
  SendMessageToPC(GetFirstPC(),"RemoveAvailableNPC(5) was successful"); } 
 else { 
  SendMessageToPC(GetFirstPC(),"RemoveAvailableNPC(5) was not successful"); }
 nResult=AddAvailableNPCByTemplate(5, "twinsun1");
 if (nResult) { 
  SendMessageToPC(GetFirstPC(),"twinsun1 added successfully"); } 
 else { 
  SendMessageToPC(GetFirstPC(),"twinsun1 could not be added"); }
 break;
case 2:
 SendMessageToPC(GetFirstPC(),"Switch 2 selected");
 nResult=RemoveAvailableNPC(3);
 if (nResult) {
  SendMessageToPC(GetFirstPC(),"RemoveAvailableNPC(3) was successful"); } 
 else { 
  SendMessageToPC(GetFirstPC(),"RemoveAvailableNPC(3) was not successful"); }
 nResult=AddAvailableNPCByTemplate(3, "morgan");
 if (nResult) { 
  SendMessageToPC(GetFirstPC(),"morgan added successfully"); } 
 else { 
  SendMessageToPC(GetFirstPC(),"morgan could not be added"); }
 break;
case 3:
 SendMessageToPC(GetFirstPC(),"Switch 3 selected");
 nResult=RemoveAvailableNPC(5);
 if (nResult) {
  SendMessageToPC(GetFirstPC(),"RemoveAvailableNPC(5) was successful"); } 
 else { 
  SendMessageToPC(GetFirstPC(),"RemoveAvailableNPC(5) was not successful"); }
 nResult=AddAvailableNPCByTemplate(5, "p_hk47");
 if (nResult) { 
  SendMessageToPC(GetFirstPC(),"p_hk47 added successfully"); } 
 else { 
  SendMessageToPC(GetFirstPC(),"p_hk47 could not be added"); }
  break;
}
DelayCommand(1.5,ShowPartySelectionGUI());
}

Link to comment
Share on other sites

Thanks for the suggestions TK. Turns out the issue was my own fault. The game does not let you replace an NPC if someone is already in that slot. Once I removed the custom NPC from my active party, the script added HK back in just fine.

 

Tonight I'll be looking at the next step in this idea - will the game save the status of NPCs if you move them in and out of the same slot...

 

For example - Lets say I put a new recruit "Bob" in to HK47's slot. Then I level Bob up and do some things that modify his influence. Now I use my armband to switch him out and put HK back in. After using HK a while, I go back to Bob - will he still be leveled up with those changes to his influence?

 

What I really would like to do is be able to move recruits in and out of different charact slots, so that I can allow any combination of party members. Unfortunately, I can't currently see any way to make it work, since each character's .utc has to have a tag that matches the slot they go in to on the party selection screen. This would mean that if I made changes to "Bob" that was in slot one, those changes wouldn't be reflected on Bob in slot 2, since they would have to be two seperate .utc's.

Link to comment
Share on other sites

Tonight I'll be looking at the next step in this idea - will the game save the status of NPCs if you move them in and out of the same slot...

 

Only NPCs saved in the Party Table or the Puppet Table are saved globally (ie possible to retrieve anywhere in the game). Other NPCs are only saved with the area they exist in, and are only accessible within that area.

 

Thus, if you only allow the party member switching aboard the Ebon Hawk, and just remove the NPC from the party and not from the area, they should be saved in the Ebon Hawk area. (Provided that you modify the EHawk cleanup scripts so they aren't removed when re-entering the ship.) You'd then use AddAvailableNPCByObject() instead of AddAvailableNPCByTemplate() to add that creature instance back when you switch again.

 

However, if you want to allow switching everywhere you could probably use a bit of an ugly hack to allow the character to be retrieved anywhere. As I mentioned above, both the Party Table and Puppet Table save the creatures stored in them globally.

 

Since the party is already full, you could use the Puppet table to temporarily store the character you shift out of the party. Remove them from the active party (if necessary) and from the party table, use AddAvailablePUPByObject() to add the NPC to the puppet table, then remove the NPC from the area.

 

When you want to add them back to the party, you use SpawnAvailablePUP() to spawn them back into the area and then use AddAvailableNPCByObject() to add them back to the party.

 

At least I think that would work. :)

Link to comment
Share on other sites

Interesting idea, I wasn't even aware of the Puppet table. I'll have to play around with that. Is there a limit to the number of creatures stored in the puppet table?

 

Any scripts you might be able to point me to for examples of using the puppet table would help, as I'm still learning my way through this whole scripting thing, and I find looking at other peoples scripts the easiest way to learn.

Link to comment
Share on other sites

Sidenote: Keep in mind that puppets can have masters (as defined in AssignedPup field of the NPC). Bao Dur has this value set to 0 which points to Remote's puppet slot. If you wanted, you could use the AssignPup function to make this new NPC a follower or zombie of some other NPC in your party. I guess that's one workaround to having more NPCs in your party -- make some of them puppets!

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...