Note: LucasForums Archive Project
The content here was reconstructed by scraping the Wayback Machine in an effort to restore some of what was lost when LF went down. The LucasForums Archive Project claims no ownership over the content or assets that were archived on archive.org.

This project is meant for research purposes only.

Make npc walk to certain point

Page: 1 of 1
 Seamhainn
01-28-2008, 4:20 PM
#1
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));

}
 DarthStoney
01-28-2008, 4:40 PM
#2
Is your object tag correct?
 Seamhainn
01-28-2008, 4:49 PM
#3
Yes!
 GeorgNihilus
01-29-2008, 12:47 AM
#4
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 :)
 CrisG
01-29-2008, 1:07 AM
#5
ah that is how the NPCs we meet like in Taris can walk around us, depending on when we block their path and where, very interesting.
 stoffe
01-29-2008, 6:05 AM
#6
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.
 Seamhainn
01-29-2008, 2:09 PM
#7
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
 Seamhainn
01-30-2008, 2:02 AM
#8
Any takers here, please?! Also: a npc can walk or run. But is there a possbility to make the npc limping away, looking injured?

Thanks and take care
 Seamhainn
01-31-2008, 3:15 PM
#9
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!
 DarthStoney
01-31-2008, 3:40 PM
#10
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.
 Seamhainn
01-31-2008, 3:51 PM
#11
No problem there. How must the script look like if kas25_secura has to walk along two or three Waypoints.

Thanks for the help!
 Stream
01-31-2008, 3:59 PM
#12
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
 DarthStoney
01-31-2008, 4:10 PM
#13
Don"t now if this will work but you may be able to put a few waypoints in the .git file
naming them wp_NPCtag_## where ## is a two digit number starting with 01. The NPCtag portion should match the .utc tag exactly. leading up to your exit point.
 Seamhainn
01-31-2008, 4:13 PM
#14
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!
 DarthStoney
01-31-2008, 4:23 PM
#15
Your script now should be OK by using the wp_NPCtag_## your npc should follow these waypoints.
 Stream
01-31-2008, 4:29 PM
#16
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
 DarthStoney
01-31-2008, 4:38 PM
#17
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.
 Seamhainn
02-01-2008, 12:45 AM
#18
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
 DarthStoney
02-01-2008, 7:44 AM
#19
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.
 Seamhainn
02-01-2008, 9:46 AM
#20
That does not clear it up totally for me unfortunately. Must I just add some Waypoints into the .git file and can use the original script? Or must I change the script using something like

GN_WalkWayPoints();

or somesuch?

Thanks
 DarthStoney
02-01-2008, 10:00 AM
#21
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();
 Seamhainn
02-01-2008, 11:39 AM
#22
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!
Page: 1 of 1