I’m fiddling around with an idea for a new module. Don’t know if anything will come of it but…
As the first scene in the module I have a trigger where the starting point of the module is. In front of the PC there’s an NPC that starts talking when you enter.
Here’s the problem: 50 % of the time the NPC stands and walks on his spot, not moving forward just walking or moving his legs without going anywhere. I thought this would have to do with the distance of the character to the PC. Maybe he wants to get a bit closer, even though he’s pretty close already. There are quite a few placeables around so the area is a bit crowded. However, all the placeables are converted to environment objects so there should be no problems.
I made a script (well, I modified one of kevL_s’ scripts) and put on the NPC’s OnConversation slots to prevent the walking from happening, but it doesn’t seem to solve anything:
/*
OnConversation script. Original script by kevL_s. Slightly modified by andgalf.
*/
const string TAG_WAYPOINT = "d_inkwp";
const float DEFAULT_DIST_DIALOG = 0.f;
void BeginDialog(object oSpeaker);
// OBJECT_SELF is innkeeper
void main()
{
object oSpeaker = OBJECT_SELF;
object oPc = GetLastSpeaker();
if (GetDistanceToObject(oPc) > DEFAULT_DIST_DIALOG)
{
AssignCommand(oSpeaker, ClearAllActions());
AssignCommand(oPc, ActionDoCommand(BeginDialog(oSpeaker)));
}
else // standard start conversation ->
{
ClearAllActions();
BeginConversation();
}
}
// OBJECT_SELF is pc here
void BeginDialog(object oSpeaker)
{
ClearAllActions();
SetFacingPoint(GetPosition(oSpeaker));
object oPc = GetFirstPC(); //OBJECT_SELF; // req'd - do not put OBJECT_SELF directly into the next calls
AssignCommand(oSpeaker, ClearAllActions());
AssignCommand(oSpeaker, SetFacingPoint(GetPosition(oPc)));
AssignCommand(oSpeaker, ActionStartConversation(oPc));
}
I even tried with a ga_move on the first node of the conversation where the character moves a few cm to the right, just to try get him to stand still, but that does nothing.
Anyone knows a solution to this? I just looks lame that he stands walking on a spot when talking.
If he’s an innkeeper as the script says he might be trying to get to you through the bar.
I’ve had this happen and what I do is make a bar out of the placeable bar pieces and surround the innkeeper, leave a gap for reality and put a collision box in the hole or use a walkmesh cutter.
This way the area isn’t totally shut in with placeables and will bake and no landlord ever tries to jump over the bar or get to you because they’re trapped. If you want to kill him later just destroy the collision block in a conversation and he’s all yours ( walkmesh cutter wont work of course ). You can also make part of the bar usable that keeps him trapped too and you can smash it up on your way to kill him for watering down the beer !
No, he’s not an innkeeper. It’s a script originally made for an innkeeper in my previous module. Sorry, I should have taken that stuff out to not confuse people.
Edit: There…Now I’ve taken that out from the script above.
It certainly sounds like the NPC is trying to get to you for that convo, but can’t, because he’s stuck on something. Although the convo did start, and now he’s in perpetual movement animation through the convo? Another weird one!
Anyways, lets try to start the convo without making the NPC move to you. Try this:
/*
This will start a convo regardless of the distance between actors.
Place on the trigger's OnEnter event.
You may have to give the convo a few second delay if it is supposed fire when the mod loads.
*/
void main()
{
object oEnter = GetEnteringObject();
object oNPC = GetNearestObjectByTag("c_halforc"); // speaker tag
string sConvo = ""; // dialog name if not using the speaker's assigned convo
if (!GetIsPC(oEnter)) return;
AssignCommand(oEnter, ClearAllActions());
AssignCommand(oNPC, ClearAllActions());
DelayCommand(0.0f, AssignCommand(oNPC, ActionStartConversation(oEnter, sConvo, FALSE, FALSE, TRUE)));
}
OK. I’ll try it. I also believe it is as you say, that he really is trying to get close to the PC. Also, it is a bit hard to test since it only happens 50 % of the time.
Comparing your script now @travus with my own trigger OnEnter script, it’s almost identical. The only difference being you do a ClearAllActions, so I’m not sure how much difference it’s going to make, but I’ll give it a go.
And, I have no delay on the start of the conversation I see now. Maybe that will help. I’ll test with a delay of 2 seconds.
Alright, since I have a tga image at the beginning of the module, it looked bad when I did a delay of 2 seconds. I adjusted this to 0.5 seconds and now it looks good. I’ve tested this intro scene 10 times now and there has been no problems. I don’t trust NWN2 fully though, but at the moment it seems that your script @travus did the trick! So, thank you!
The big difference is that I have the bIgnoreStartDistance set to TRUE. That means the convo will fire regardless of how far away the actors are (i.e. the speaker won’t move to the listener). Otherwise, if you use the default setting of FALSE, the speaker will try to move to within 3 meters of the listener for the convo.
FYI, if you swap the oNPC and oEnter so it looks like this :
Ah, I see. That was what I was trying to do in modified the OnConversation script from kevL_s. It’s been a while since I checked all the different things in ActionStartConversation. Then that makes total sense. I can try to set the delay to 0.0. and see what happens.