Jump to content

Home

Make npc walk to certain point


Seamhainn

Recommended Posts

Hello!

 

I have this script which makes a npc walk to a certain point and vanish. Unfortunately the npc does not walk away and vanishes without doing one stept. What did I do wrong?

 

void main () {

object oNPC=GetObjectByTag("kas25_lewbacca");

float x=24.01;
float y=237.55;
float z=11.08;

int bRun=FALSE;

vector vExit=Vector(x,y,z);
location lExit=Location(vExit,0.0f);
ActionDoCommand(SetCommandable(TRUE,oNPC));
AssignCommand (oNPC,ActionForceMoveToLocation(lExit,bRun));
AssignCommand (oNPC,ActionDoCommand(DestroyObject(oNPC)));

ActionDoCommand(SetCommandable(FALSE,oNPC));

}

Link to comment
Share on other sites

Check out the destination coordinates and that the path the NPC has to walk is not blocked by corners or objects, otherwise he/she will try to move but will not succeed :rolleyes: I think ... maybe defining 2 or 3 sets of coordinates will ensure an unblocked path to walk for him/her.

 

hope it helps bye :)

Link to comment
Share on other sites

Check out the destination coordinates and that the path the NPC has to walk is not blocked by corners or objects, otherwise he/she will try to move but will not succeed :rolleyes:

 

Indeed, MoveToLocation needs a clear and direct path to the target location without any obstacles in the way, while MoveToObject will try to pathfind around obstacles to the destination object, if I recall correctly.

 

Also make sure your destination coordinates are in a walkable area that can be reached (i.e. on the same walkmesh section and no locked doors in the way), or the move command might fail.

Link to comment
Share on other sites

Check out the destination coordinates and that the path the NPC has to walk is not blocked by corners or objects, otherwise he/she will try to move but will not succeed :rolleyes: I think ... maybe defining 2 or 3 sets of coordinates will ensure an unblocked path to walk for him/her.

 

hope it helps bye :)

 

I came to the same conclusion thinking about the problem, but I did nor have time to find try it out. I'll try it tonight...

 

EDIT: With an unobstructed path the npc leaves now properly. My question is how musth the script look like if the npc shall walk several locations?

 

Thanks and take care

Link to comment
Share on other sites

Okay, I have this script. kas25_secura shall go to the location defined in the script. But the way is obstructed. So I want to use MoveToObject, and in that case kas25_vos. How must the script look like?

 

void main () {

object oNPC=GetObjectByTag("kas25_secura");

object oTarget;
object oSpawn;
location lTarget;

oTarget = GetWaypointByTag("kas25_wp_sec01");

lTarget = GetLocation(oTarget);

oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "kas25_vos", lTarget);

float x=145.00;
float y=136.00;
float z=10.0;

int bRun=TRUE;

vector vExit=Vector(x,y,z);
location lExit=Location(vExit,0.0f);
ActionDoCommand(SetCommandable(TRUE,oNPC));
AssignCommand (oNPC,ActionForceMoveToLocation(lExit,bRun));

SetGlobalNumber("test_test", 2);

}

 

Thanks for any help!

Link to comment
Share on other sites

One of the problems with this area is the same problem I had with M4-78 there are no pathway files for this area. What that means is the npc will try to walk in a staight line to the waypoint specified. Don't know how but you may have to put a series of waypoints for your npc to walk to get there.

Link to comment
Share on other sites

If you don't care where the npc runs to, use the script I made for Secura;

 

void main () {


object oNPC = GetObjectByTag("NPC_TAG");
object oPC = GetFirstPC();

int bRun=TRUE;

AssignCommand(oNPC, ClearAllActions());
AssignCommand(oNPC, ClearAllActions());
AssignCommand(oNPC, ActionMoveAwayFromObject(oPC, bRun, 15.0f));
DelayCommand(8.5, DestroyObject(GetObjectByTag("NPC_TAG", 0), 0.0, 0, 0.0, 0);


}

I'm not sure if this will work but to make them limp try this script, it will set the NPC's maximum hit points to 5 which may make them limp;

 

void main () {


object oNPC = GetObjectByTag("NPC_TAG");
object oPC = GetFirstPC();
SetMaxHitPoints(oNPC, 5);

int bRun=TRUE;

AssignCommand(oNPC, ClearAllActions());
AssignCommand(oNPC, ClearAllActions());
AssignCommand(oNPC, ActionMoveAwayFromObject(oPC, bRun, 15.0f));
DelayCommand(8.5, DestroyObject(GetObjectByTag("NPC_TAG", 0), 0.0, 0, 0.0, 0);


}

--Stream

Link to comment
Share on other sites

Thanks for the maximum hit points tip, DS. It works great!

 

Unfortunately Secura must run to Vos, her Master, and he as in one of the caves. So she must run along a few Waypoints to reach him.

 

Thanks again!

 

EDIT: I can do that STONEY, but how must the SCRIPT look like. I can create as many Waypoints as necessary, no problem. But I am sucker at scripting!

Link to comment
Share on other sites

Have you tried stoffe's suggestion of MoveToObject, she should then find her own way. Also did you want her to disappear? if so once she's out of sight of the PC surely it doesn't matter where she's got to as the PC won't see her anyway.

 

--Stream

Link to comment
Share on other sites

Have you tried stoffe's suggestion of MoveToObject, she should then find her own way. Also did you want her to disappear? if so once she's out of sight of the PC surely it doesn't matter where she's got to as the PC won't see her anyway.

 

--Stream

 

She can't find her own way do to a lack of a .pth file for that module.

Link to comment
Share on other sites

Your script now should be OK by using the wp_NPCtag_## your npc should follow these waypoints.

 

Sorry, I am lost here. Do I understand it right that I can leave the script as it is, and that I just have to include some Waypoints into the .git file which have an unobstructed path to each other on the way to the desired location?

 

Thanks and take care

Link to comment
Share on other sites

read this thread hopefully it explains it better

http://www.lucasforums.com/showthread.php?t=142290 ,but yes because the waypoints have the npctag it should follow those waypoints. Normally there are .pth

files in a module which are genaric waypoints for npcs to follow to get around without running into walls or objects which work for all npcs this way it should only work for the specific npc.

Link to comment
Share on other sites

Just use your original script and add the waypoint in the .git the only thing you may have to do is check the npc spawn_ in script if it already uses below it should be OK

if not it will need to be changed as below.

 

(Your .utc's spawn-in script should be modeled after k_def_spawn01.nss inasmuch that you preserve the following lines:)

Code:

GN_SetDayNightPresence( AMBIENT_PRESENCE_ALWAYS_PRESENT);

GN_SetListeningPatterns();

GN_WalkWayPoints();

Link to comment
Share on other sites

Okay, I solved the problem with three scripts with different coordinates and Secura reached the desired destination. The script looks like this:

void main () {

object oNPC=GetObjectByTag("kas25_secura");

float x=121.00;
float y=134.00;
float z=10.0;

int bRun=FALSE;

vector vExit=Vector(x,y,z);
location lExit=Location(vExit,0.0f);
ActionDoCommand(SetCommandable(TRUE,oNPC));
AssignCommand (oNPC,ActionForceMoveToLocation(lExit,bRun));

ActionDoCommand(SetCommandable(FALSE,oNPC));

ExecuteScript("k_pkas_sec08", OBJECT_SELF, 1002);

}

 

Unfortunately if the pc initiates a conversation the npc stops and does not continue to walk on. How can I manage it that the npc walks on and ignores the conversation attempt?

 

Thanks again!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...