lfnetwork.com mark read register faq members calendar

Thread: Making NPCs walk around a module
Thread Tools Display Modes
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Old 06-19-2009, 06:23 AM   #1
Demongo
Afro Skeleton
 
Demongo's Avatar
 
Join Date: Apr 2009
Posts: 963
Current Game: Street Fighter IV
Making NPCs walk around a module

I am currently working on a module and it is full with civillians and other NPCs so I want to ask: How can I make NPCs walk around a module? Like on Taris. The Sith and Citzens are walking around Taris. Thanks in advance.



Bink's Sake

"I've barely eaten anything for many decades now. It feels like my stomach shriveled into my back........though i don't have a stomach or back because i'm a skeleton! Yohohohoho! SKULL JOKE!"

"My eyes have never seen such a pretty woman! But i'm a skeleton so my eyes don't see much."
Demongo is offline   you may: quote & reply,
Old 06-19-2009, 09:45 AM   #2
disbeliever
Junior Member
 
disbeliever's Avatar
 
Join Date: Dec 2008
Location: Maryland
Posts: 335
Helpful! 
waypoints

edit: sorry not more specific but I do not know how myself, just how its done.
disbeliever is offline   you may: quote & reply,
Old 06-19-2009, 09:53 AM   #3
Prime
Am I a truck or robot?
 
Prime's Avatar
 
Status: Super Moderator
Join Date: Apr 2002
Location: Cybertron
Posts: 12,363
Current Game: Skyrim, Vector Thrust
10 year veteran! LF Jester Veteran Modder Helpful! 
Actually, there is a way for them to walk around randomly. I know I did it a long time ago for a mod I did for myself. Sorry that I can't remember the specifics.

Prime is offline   you may: quote & reply,
Old 06-19-2009, 10:03 AM   #4
DarthStoney
To bed. I'm old and tired
 
DarthStoney's Avatar
 
Join Date: Apr 2006
Posts: 506
Contest winner - Modding Veteran Modder Helpful! 
Here's a good link for how to do it http://www.lucasforums.com/showthread.php?t=142290

DarthStoney is offline   you may: quote & reply,
Old 06-19-2009, 10:04 AM   #5
Demongo
Afro Skeleton
 
Demongo's Avatar
 
Join Date: Apr 2009
Posts: 963
Current Game: Street Fighter IV
Well I need to know exactly the way how to do it. I am thinking of making waypoints, then create script to move to the waypoints or something like this.......

EDIT: I followed SithSpecter's tutorial but it didn't work. I don't really know what can be the problem. Any help?



Bink's Sake

"I've barely eaten anything for many decades now. It feels like my stomach shriveled into my back........though i don't have a stomach or back because i'm a skeleton! Yohohohoho! SKULL JOKE!"

"My eyes have never seen such a pretty woman! But i'm a skeleton so my eyes don't see much."

Last edited by Demongo; 06-19-2009 at 12:45 PM.
Demongo is offline   you may: quote & reply,
Old 06-19-2009, 07:55 PM   #6
logan23
Veteran
 
logan23's Avatar
 
Join Date: Aug 2007
Location: East Coast
Posts: 916
Current Game: Revenge of Revan
Veteran Modder Forum Veteran Contest winner - Modding Hot Topic Starter 
Hey,

Here is what you do to get the character to walk random.
Just remember the NPC will start walking in the direction you point them. So don't have them all facing same way or each other since it might lead to them bumping into each other.

Go to the utc's script area and locate k_def_spawn01

You will then open the script and go to the bottom and make one change-

//****** TURN ON WALKPOINTS ******
// The following line causes the object to follow waypoints
AssignCommand(OBJECT_SELF,ActionRandomWalk());

You place this line in and remove the old line, its in bold for you. Then compile and save the old k_def_spawn01 into another name....for example..... randwlk.nss

Should look like this:

Quote:
//:: k_def_spawn01
/*
v2.0
Default On Spawn In
*/
//:: Created By: Preston Watamaniuk
//:: Modified By: Anthony Davis
//:: Added treasure: Kevin Saunders
#include "k_inc_generic"
#include "k_inc_debug"
#include "k_inc_treas_k2"

void main()
{
//BEGIN WALK WAYPOINT BEHAVIORS (Comment In or Out to Activate )
//****** WAYPOINT PATH STYLE ******
// Object will follow waypoints in order, and then start over at beginning.
// Example: WP_01, WP_02, WP_03, then return to WP_01 and continue...
//GN_SetSpawnInCondition(SW_FLAG_WAYPOINT_WALK_CIRCU LAR);
// Object will follow waypoints in order, and then follow the waypoints backwards.
// Example: WP_01, WP_02, WP_03, then WP_02, WP_01,
//GN_SetSpawnInCondition(SW_FLAG_WAYPOINT_WALK_PATH) ;
// Object will follow waypoints in a RANDOM order
// Example: WP_02, WP_03, WP_01
//GN_SetSpawnInCondition(SW_FLAG_WAYPOINT_WALK_RANDO M);
// Object will follow waypoints starting with NEAREST waypoint.
// THIS WILL EFFECT THE ORDER THE WAYPOINTS ARE FOLLOWED!
//GN_SetSpawnInCondition(SW_FLAG_WAYPOINT_START_AT_N EAREST);

//****** WAYPOINT FREQUENCY ******
// Object will follow waypoints ONLY ONCE.
// Leave commented out to have waypoints repeated forever.
//GN_SetSpawnInCondition(SW_FLAG_WAYPOINT_WALK_ONCE) ;

//****** WAYPOINT SPEED ******
// Object will RUN to waypoints.
//GN_SetSpawnInCondition(SW_FLAG_WAYPOINT_WALK_RUN);

//****** WAYPOINT PAUSING ******
// Object will PAUSE at each waypoints based on each option.
// CObjects will ONLY turn to face in the waypoint direction if
// the are pausing at the waypoint.
// The pause times are:
// Causes the Object to pause for 1 - 3 seconds at a waypoint
//GN_SetSpawnInCondition(SW_FLAG_WAYPOINT_PAUSE_SHOR T);
// Causes the Object to pause for 4 - 6 seconds at a waypoint
//GN_SetSpawnInCondition(SW_FLAG_WAYPOINT_PAUSE_LONG );
// Causes the Object to pause for 1 - 10 seconds at a waypoint
//GN_SetSpawnInCondition(SW_FLAG_WAYPOINT_PAUSE_RAND OM);

//****** WAYPOINT ANIMATIONS ******
// Object will play an animation that has been specified with
// SetLocalNumber(OBJECT_SELF, 29, <SOME ANIMATION NUMBER> )
// Local number 29 is reserved for animations.
// This may conflict with ambient animations (further down)
//GN_SetSpawnInCondition(SW_FLAG_USE_WAYPOINT_ANIMAT ION);
// If using an animation at a waypoint, uncomment and set the following lin:
//SetLocalNumber(OBJECT_SELF, 29, <SOME ANIMATION NUMBER> );


//****** WAYPOINT SERIES ******
// If this function is uncommented a number from 1 to 99 must be passed.
// This number represents a waypoint series that uses the string "01" through "99"
// instead of the creature's tag.
// eg. WP_22_01 through WP_22_05. 22 is the series number set with this function.
//GN_SetWalkWayPointsSeries( 1 );

//END WALK WAYPOINT BEHAVIORS

//****** AMBIENT ANIMATIONS ******
// This will play Ambient Animations until the NPC sees an enemy or is cleared.
// NOTE: that these animations will play automatically for Encounter Creatures.
//GN_SetSpawnInCondition(SW_FLAG_COMMONER_BEHAVIOR);
//GN_SetSpawnInCondition(SW_FLAG_FAST_BUFF);
//GN_SetSpawnInCondition(SW_FLAG_AMBIENT_ANIMATIONS) ;
//GN_SetSpawnInCondition(SW_FLAG_AMBIENT_ANIMATIONS_ MOBILE);

//****** COMPUTER DIALOG ******
//When a creature with this flag is talked to a computer dialogue will come up instead of the usual screens.
//GN_SetSpawnInCondition(SW_FLAG_ON_DIALOGUE_COMPUTE R);

//****** CUSTOM USER DEFINED EVENTS ******
// The following settings will allow the user to fire one of the blank
// user defined events in the NW_D2_DefaultD. Like the OnSpawnIn script,
// this script is meant to be customized by the end user to allow for unique
// behaviors. The user defined events user 1000 - 1010
//GN_SetSpawnInCondition(SW_FLAG_EVENT_ON_HEARTBEAT) ; //OPTIONAL BEHAVIOR - Fire User Defined Event 1001
//GN_SetSpawnInCondition(SW_FLAG_EVENT_ON_PERCEPTION ); //OPTIONAL BEHAVIOR - Fire User Defined Event 1002
//GN_SetSpawnInCondition(SW_FLAG_EVENT_ON_ATTACKED); //OPTIONAL BEHAVIOR - Fire User Defined Event 1005
//GN_SetSpawnInCondition(SW_FLAG_EVENT_ON_DAMAGED); //OPTIONAL BEHAVIOR - Fire User Defined Event 1006
//GN_SetSpawnInCondition(SW_FLAG_EVENT_ON_DISTURBED) ; //OPTIONAL BEHAVIOR - Fire User Defined Event 1008
//GN_SetSpawnInCondition(SW_FLAG_EVENT_ON_COMBAT_ROU ND_END); //OPTIONAL BEHAVIOR - Fire User Defined Event 1003
//GN_SetSpawnInCondition(SW_FLAG_EVENT_ON_DIALOGUE); //OPTIONAL BEHAVIOR - Fire User Defined Event 1004
//GN_SetSpawnInCondition(SW_FLAG_EVENT_ON_DEATH); //OPTIONAL BEHAVIOR - Fire User Defined Event 1007
//GN_SetSpawnInCondition(SW_FLAG_EVENT_ON_DISTURBED) ; //OPTIONAL BEHAVIOR - Fire User Defined Event 1008
//GN_SetSpawnInCondition(SW_FLAG_EVENT_ON_BLOCKED); //OPTIONAL BEHAVIOR - Fire User Defined Event 1009
//GN_SetSpawnInCondition(SW_FLAG_EVENT_ON_FORCE_AFFE CTED); //OPTIONAL BEHAVIOR - Fire User Defined Event 1010
//GN_SetSpawnInCondition(SW_FLAG_EVENT_ON_DIALOGUE_E ND); //OPTIONAL BEHAVIOR - Fire User Defined Event 1011

//****** BEGIN DEFAULT GENERIC BEHAVIOR (DO NOT TOUCH) ******
GN_SetDayNightPresence(AMBIENT_PRESENCE_ALWAYS_PRE SENT);
// This function although poorly named sets up the listening patterns and other
// important data for the creature it should never be removed.
GN_SetListeningPatterns();
SetLocalNumber(OBJECT_SELF, 11, 6);// FAK - OEI default turret cooldown
//****** END DEFAULT GENERIC BEHAVIOR (DO NOT TOUCH) ******

//****** TREASURE PLACEMENT
PlaceCritterTreasure(OBJECT_SELF, Random(4)-2);

//****** TURN ON WALKPOINTS ******
// The following line causes the object to follow waypoints
AssignCommand(OBJECT_SELF,ActionRandomWalk());

}
Logan

logan23 is offline   you may: quote & reply,
Old 06-19-2009, 08:27 PM   #7
Demongo
Afro Skeleton
 
Demongo's Avatar
 
Join Date: Apr 2009
Posts: 963
Current Game: Street Fighter IV
I have the ist version of the script, but I included that line, and it worked. Only one problem: When I speak to the NPC he stops moving around. Is there a script to put in the OnEndDialog box?



Bink's Sake

"I've barely eaten anything for many decades now. It feels like my stomach shriveled into my back........though i don't have a stomach or back because i'm a skeleton! Yohohohoho! SKULL JOKE!"

"My eyes have never seen such a pretty woman! But i'm a skeleton so my eyes don't see much."
Demongo is offline   you may: quote & reply,
Old 06-20-2009, 06:37 AM   #8
ajlbibak
Rookie
 
ajlbibak's Avatar
 
Join Date: May 2007
Location: Caught somewhere in time.
Posts: 62
Current Game: X-Com: Terror from the deep
From Making NPCs walk waypoints tutorial

Quote:
#glovemaster 19/01/09:
A problem I found was that when you talked to them they stopped walking their waypoints, I had to add the following script to fire onEndDialog to fix it.
Code:
#include "k_inc_generic"
#include "k_inc_debug"
#include "k_inc_treas_k2"

void main(){
	// Force them to continue walking waypoints.
	GN_WalkWayPoints();
}
ajlbibak is offline   you may: quote & reply,
Old 06-20-2009, 07:04 AM   #9
Demongo
Afro Skeleton
 
Demongo's Avatar
 
Join Date: Apr 2009
Posts: 963
Current Game: Street Fighter IV
That script doesn't work(at least for me), I tried it.



Bink's Sake

"I've barely eaten anything for many decades now. It feels like my stomach shriveled into my back........though i don't have a stomach or back because i'm a skeleton! Yohohohoho! SKULL JOKE!"

"My eyes have never seen such a pretty woman! But i'm a skeleton so my eyes don't see much."
Demongo is offline   you may: quote & reply,
Old 06-20-2009, 11:06 AM   #10
DarthStoney
To bed. I'm old and tired
 
DarthStoney's Avatar
 
Join Date: Apr 2006
Posts: 506
Contest winner - Modding Veteran Modder Helpful! 
If this is for K1 try attatching this script to the end of the actual dialog tree its actually k_act_walkways2.nss already in K1.

Code:
#include "k_inc_generic"
#include "k_inc_debug"

void main()
{
    GN_SetSpawnInCondition(SW_FLAG_WAYPOINT_DEACTIVATE, FALSE);
    ClearAllActions();
    DelayCommand(1.0, GN_WalkWayPoints());
}

DarthStoney is offline   you may: quote & reply,
Old 06-20-2009, 11:14 AM   #11
Robespierre
Junior Member
 
Robespierre's Avatar
 
Join Date: Aug 2007
Posts: 493
Isn't there also a certain script like walk random or something? I seem to remember it only working on modules which had .pth files though.



"We must use daring, daring and more daring." - Georges Jacques Danton
Robespierre is offline   you may: quote & reply,
Old 06-20-2009, 11:44 AM   #12
Demongo
Afro Skeleton
 
Demongo's Avatar
 
Join Date: Apr 2009
Posts: 963
Current Game: Street Fighter IV
Quote:
Originally Posted by Robespierre View Post
Isn't there also a certain script like walk random or something? I seem to remember it only working on modules which had .pth files though.
Well I tried that, and it actually worked but "random walk" means take two steps, then stop. Then take 3 steps, and stop. Take a few steps then stop...etc. I need a script which forces the NPCs to go to waypoints I created for them.


Quote:
Originally Posted by DSTONEY642000 View Post
If this is for K1 try attatching this script to the end of the actual dialog tree its actually k_act_walkways2.nss already in K1.

Code:
#include "k_inc_generic"
#include "k_inc_debug"

void main()
{
    GN_SetSpawnInCondition(SW_FLAG_WAYPOINT_DEACTIVATE, FALSE);
    ClearAllActions();
    DelayCommand(1.0, GN_WalkWayPoints());
}
Thanks, I will try this, and just to be sure, can you send the .nss version of the script that is supposed to force the NPC to follow waypoints?

EDIT: And spawn the NPC too ^



Bink's Sake

"I've barely eaten anything for many decades now. It feels like my stomach shriveled into my back........though i don't have a stomach or back because i'm a skeleton! Yohohohoho! SKULL JOKE!"

"My eyes have never seen such a pretty woman! But i'm a skeleton so my eyes don't see much."

Last edited by Demongo; 06-20-2009 at 11:51 AM.
Demongo is offline   you may: quote & reply,
Old 06-20-2009, 01:06 PM   #13
glovemaster
Now-a-days GroovyCarrot
 
Join Date: Jan 2007
Location: Liverpool, UK
Posts: 697
Current Game: No time for games, sadly
Helpful! 
That script I threw together above was a quick fix to make NPC's walk their waypoints after finishing a dialogue, since here we are using the random walk function then that won't work.

I think this script should make the NPC walk randomly again, personally I'd consider using waypoints for a few NPC's just to make it look more realistic - a few browsing markets or whatever the situation. This function I think was intended more for ambient creatures.
Code:
/*
    Resume random walk - onEndDialogue script.
*/
#include "k_inc_generic"
#include "k_inc_debug"
#include "k_inc_treas_k2"

void main() {
    AssignCommand(OBJECT_SELF,ActionRandomWalk());
}


If you're looking for any of the junk I did a few years ago; you can probably still find it all on filefront
glovemaster is offline   you may: quote & reply,
Old 06-20-2009, 01:12 PM   #14
Demongo
Afro Skeleton
 
Demongo's Avatar
 
Join Date: Apr 2009
Posts: 963
Current Game: Street Fighter IV
Quote:
Originally Posted by glovemaster View Post
That script I threw together above was a quick fix to make NPC's walk their waypoints after finishing a dialogue, since here we are using the random walk function then that won't work.

I think this script should make the NPC walk randomly again, personally I'd consider using waypoints for a few NPC's just to make it look more realistic - a few browsing markets or whatever the situation. This function I think was intended more for ambient creatures.
Code:
/*
    Resume random walk - onEndDialogue script.
*/
#include "k_inc_generic"
#include "k_inc_debug"
#include "k_inc_treas_k2"

void main() {
    AssignCommand(OBJECT_SELF,ActionRandomWalk());
}
Sorry if I said something wrong, but the best will be to tell everything what I have now. I've got an NPC(civil1.utc) with 4 waypoints(wp_civil1_01,wp_civil1_02,wp_civil1_03,w p_civil1_04). When I go in-game he just stands and he doesn't do anything, but when I talk to him, he begins following the waypoints. So I guess I need an Onspawn script.



Bink's Sake

"I've barely eaten anything for many decades now. It feels like my stomach shriveled into my back........though i don't have a stomach or back because i'm a skeleton! Yohohohoho! SKULL JOKE!"

"My eyes have never seen such a pretty woman! But i'm a skeleton so my eyes don't see much."
Demongo is offline   you may: quote & reply,
Old 06-20-2009, 02:25 PM   #15
glovemaster
Now-a-days GroovyCarrot
 
Join Date: Jan 2007
Location: Liverpool, UK
Posts: 697
Current Game: No time for games, sadly
Helpful! 
Ah then you can try this script for onSpawn:
Code:
/*
	Walk waypoints on spawn - onSpawn script, of course =]
*/
#include "k_inc_generic"
#include "k_inc_debug"
#include "k_inc_treas_k2"

void main()
{
    // SW_FLAG_WAYPOINT_WALK_PATH - Walks waypoints in order and then walks them in reverse. 1 - 2 - 3 - 2 - 1...
    // SW_FLAG_WAYPOINT_WALK_RANDOM - Self explanatory
    // SW_FLAG_WAYPOINT_START_AT_NEAREST - Object will follow waypoints starting with NEAREST waypoint.
    GN_SetSpawnInCondition(SW_FLAG_WAYPOINT_WALK_CIRCULAR); // Walks waypoints in a circle 1 - 2 - 3 - 1 -2 - 3...

    GN_SetDayNightPresence(AMBIENT_PRESENCE_ALWAYS_PRESENT);
    GN_SetListeningPatterns();
    SetLocalNumber(OBJECT_SELF, 11, 6);

    PlaceCritterTreasure(OBJECT_SELF, Random(4)-2);

    GN_WalkWayPoints();
}
The bit with commented SW_FLAG_WAYPOINT_* 's are different settings you can use with an explanation by them. You just need to replace the line GN_SetSpawnInCondition(SW_FLAG_WAYPOINT_WALK_CIRCU LAR); with GN_SetSpawnInCondition(SW_FLAG_WAYPOINT_WALK_HOWEVER_YOU_WANT);

Hope that helps
-Glove


If you're looking for any of the junk I did a few years ago; you can probably still find it all on filefront
glovemaster is offline   you may: quote & reply,
Old 06-20-2009, 02:40 PM   #16
Demongo
Afro Skeleton
 
Demongo's Avatar
 
Join Date: Apr 2009
Posts: 963
Current Game: Street Fighter IV
Ah thank you so much!(I had to modify the script a little but it works) Now he starts walking when I enter the module



Bink's Sake

"I've barely eaten anything for many decades now. It feels like my stomach shriveled into my back........though i don't have a stomach or back because i'm a skeleton! Yohohohoho! SKULL JOKE!"

"My eyes have never seen such a pretty woman! But i'm a skeleton so my eyes don't see much."
Demongo is offline   you may: quote & reply,
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Go Back   LucasForums > Network > Knights of the Old Republic > Editing / Modding > Holowan Laboratories > Making NPCs walk around a module

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:02 PM.

LFNetwork, LLC ©2002-2011 - All rights reserved.
Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.