Alright, in KotOR 1, I've been attempting to make an NPC walk over to the PC and once the NPC is about 5 meters or so from the PC he initiates a conversation with the PC. This is the script I've been using:
Code:
void main()
{
object oPC=GetFirstPC();
object oNPC=GetObjectByTag("dt_comm");
int nCurrentDistance;
int nEvent = GetUserDefinedEventNumber();
nCurrentDistance = GetDistanceBetween(oNPC, oPC);
if(
(nEvent == 1002) &&
(nCurrentDistance<6) &&
GetGlobalBoolean("DT_CHECK1") == FALSE) {
ActionDoCommand(SetCommandable(TRUE, oNPC));
AssignCommand (oNPC, ActionMoveToObject(oPC));
AssignCommand (oNPC, ActionStartConversation(GetFirstPC()));
}
}
I get an error trying to compile it saying that the equal sign between nCurrentDistance and GetDistanceBetween is incorrect. This is most likely due to the fact I tried to copy of a script that would make something occur once an NPC reached a certain HP level. What should I change, or redo entirely, to make this work?
EDIT 1: Alright, while digging through source scripts searching for functions in my other modding projects, I found something that should work:
Code:
#include "k_inc_debug"
void main()
{
object oPC=GetFirstPC();
object oNPC=GetObjectByTag("dt_comm");
int nEvent = GetUserDefinedEventNumber();
if(
(nEvent == 1002) &&
GetGlobalBoolean("DT_CHECK1") == FALSE) &&
GetDistanceBetween(GetPCSpeaker(), GetFirstPC()) <= 6.00)){
ActionDoCommand(SetCommandable(TRUE, oNPC));
int bRun=TRUE;
AssignCommand (oNPC, ActionMoveToObject(oPC, bRun, fRange=1.0f));
AssignCommand (oNPC, ActionStartConversation(GetFirstPC()));
}
}
I'll get back if it works or not.
EDIT 2: Alright, now I get a syntax error at the && after GetGlobalBoolean. How would I fix this?