View Single Post
Old 03-11-2012, 09:20 PM   #148
Fallen Guardian
Wandering the Galaxy...
 
Fallen Guardian's Avatar
 
Join Date: Aug 2010
Location: Unknown Regions
Posts: 1,165
Current Game: Fallout: New Vegas
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?


The truly fallen cannot return to the light. If someone "falls" and "returns," they never really, truly fell.

Current Work in Progress: Dantooine Tension

Released Works
Blaster Pistol Ehancement
Ebon Hawk Texture Enhancement
Gaffi Stick Improvement
KotOR 1 Restoration Demo (Group collaboration with many team members)
Sunry Murder Recording Enhancement
VP's Hi Poly Tin Cans - KotOR 1 Version (Most of the work done by Varsity Puppet)

Last edited by Fallen Guardian; 03-13-2012 at 09:58 PM. Reason: Error
Fallen Guardian is offline   you may: quote & reply,