Conversation problem with controlled companion

I’ve noticed somewhat serious problem with my module. In a lot of my custom scripts, I need the first companion in the party to start a conversation with the PC (I have so many companions in this module that I often don’t know what companions the player will have in their party). I had a somewhat convoluted way of doing this at first. Everything works as long as you control the PC. If however, you run into the trigger when controlling a companion, then the first red node of the conversation, and in other cases the other red nodes too, will to belong to the PC, which creates a real weird conversation. So I changed one of the scripts to a simpler way of doing things, and I thought for sure this was going to work, but it didn’t work either.

My first convoluted way of doing things:

        object oPC1 = GetFirstPC();

		string sCompanion = GetFirstRosterMember();

		while(!GetIsRosterNameInParty(oPC1,sCompanion))
		{
		
			sCompanion = GetNextRosterMember();
		
		}
	
		object oCompanion = GetObjectByTag(sCompanion);	
		AssignCommand(oCompanion, ActionStartConversation(oPC1, "c_i5_partytalk2", FALSE, FALSE, TRUE, FALSE));

The new a simpler way of doing this:

object oPC1 = GetFirstPC();
object oFM = GetFirstFactionMember(oPC1, FALSE);

	if(oFM == oPC1)
	{

		oFM = GetNextFactionMember(oPC1, FALSE);

	}
			
DelayCommand(0.5,AssignCommand(oFM, ActionStartConversation(oPC1, "c_i5_partytalk1", FALSE, FALSE, TRUE, FALSE)));

Both of these will in some case produce the PC as the owner of the conversation instead of one of the companions, if you control the companion when moving into the trigger, which will result in the PC talking to himself.
I thought for sure the second way of doing things would work without problems, but it’s the same as before.
I have DLGPartySwap set to TRUE in the Campaign Editor, and I would really like to keep it that way. Is there any way to fix this?

Thanks for your time!

I found the solution to my problem. I remembered an old script that @Lance_Botelle helped me with for my third module. So the solution was to do it like this, by using the function SetOwnersControlledCompanion:

object oPC = GetEnteringObject();
object oPC1 = GetFirstPC();

oPC = SetOwnersControlledCompanion(oPC); 

object oFM1 = GetFirstFactionMember(oPC1, FALSE);

	if(oFM1 == oPC1)
	{

		oFM1 = GetNextFactionMember(oPC1, FALSE);

	}
			
DelayCommand(0.5,AssignCommand(oFM1, ActionStartConversation(oPC1, "c_groca_sacredstalk", FALSE, FALSE, TRUE, FALSE)));
1 Like