I have a situation where an NPC (who is about to be a companion, so therefore has the script set with all the gb scripts) is about to move towards the PC at the first node of a conversation. I use ga_move, but one thing that bothers me is that I feel the NPC ends up too far away from the PC. I have a waypoint that the NPC is supposed to move to, but she stops before reaching it (at least I’m fairly certain of that). Is there any way to remove the thing that makes her stop before reaching the wp?
This sounds like a ClearAllActions() is being called as the NPC makes their approach.
My guess (from your description) is that it is somewhere from a heartbeat script you have attached to them, perhaps?
As a test, remove their heartbeat script and test again. If it is this script (or whichever one you find it to be), add a custom script to that hook instead that only fires the actual script once the NPC is actually in the party. i.e. Stop any attached script firing that may be firing the offending call.
In my own campaign, I actually switch the entire script set from NPC to companion type upon becoming a member, so that this kind of thing does not happen. What I am recommending is a single script cut-down version of this.
I think I sort of managed to solve it. For one, in the toolset two waypoints seem a lot closer to each other than they actually are (I think). And: I had a trigger that fires the conversation where the NPC moves to a waypoint near the PC. However, once the PC enters the trigger that fires the conversation in the first place, and stops (because it’s a SpeakTrigger), I don’t think he’s exactly at the waypoint I pointed him to go to within the trigger. I think he instead is at the border of the trigger. What I did now was: during the NPCs walk towards the PC at the first node of the conversation, I do a ga_jump on the PC to the waypoint where he was supposed to be. I think that made things better. Another solution I tried was to just make the NPC move to the PC with ActionForceMoveToObject, but with that, the NPC gets almost a bit too close to the PC. So it was tricky to get the right distance for it to feel right. If they are too far apart it feels like they shout at each other, but if they’re too close (they’re strangers at this instance) it feels too “intimate” for lack of a better word. As said, it’s tricky.
I actually wish I could take this script here and just make the NPC go to the PC but stop when she’s not quite there, so that the distance between them is a tiny bit larger. I could probably do something with checking distance, but I’m not sure how to script that:
#include "ginc_param_const"
void main(string sCompaniontag, string sWaypoint)
{
object oPC = GetFirstPC();
object oWP = GetObjectByTag(sWaypoint);
object oCompanion = GetObjectByTag(sCompaniontag); //This is an NPC, but he/she will became a companion
AssignCommand(oCompanion, ActionForceMoveToObject(oPC));
}
EDIT: Hmmm, did another test now. I think it actually looks good. I placed the NPC waypoint pretty close to the PC waypoint and used AssignCommand(oCompanion, ActionForceMoveToObject(oWP));
.
Still, it would be cool to know how to script what I mentioned.
ActionForceMoveToObject
has a fRange
parameter that allows you to set the distance that the action subject will stop from the oMoveTo
target. Maybe use something like this - just change the fRange
float to maybe 2.0 or whatever range suits you:
#include "ginc_param_const"
void main(string sCompaniontag, int bRun=FALSE, float fRange=1.0f)
{
object oPC = GetFirstPC();
object oCompanion = GetObjectByTag(sCompaniontag);
AssignCommand(oCompanion, ActionForceMoveToObject(oPC, bRun, fRange));
}
How did I miss that in the function? Great to know. I’ll copy your version of the script then. Apparently, from the description of the function (I saw that just now), the default distance is 1.0f, so if I use your script as is and not add anything to float fRange in the node of the dialogue, it works just as before. Great solution! It’s actually easier than moving the waypoint around until satisfied.