Does anyone have a script that just makes an NPC aimlessly wander? thanks!
Random Walking Around
Débuté par
Leyf
, févr. 05 2011 05:47
#1
Posté 05 février 2011 - 05:47
#2
Guest_Chaos Wielder_*
Posté 05 février 2011 - 06:02
Guest_Chaos Wielder_*
Set this variable on them:
X2_L_SPAWN_USE_AMBIENT to 1
X2_L_SPAWN_USE_AMBIENT to 1
#3
Posté 05 février 2011 - 06:07
For villagers you probably want to use scripted waypoints. See the stickied thread.
Modifié par Kaldor Silverwand, 05 février 2011 - 06:08 .
#4
Posté 05 février 2011 - 06:07
There is an ActionRandomWalk function that can do this, but in practice truly random walking might not be what you want. For most ambient situations, like an NPC strolling through a city or town, it would be easier to use Scripted WalkWaypoints, where the NPC will randomly pick a new waypoint to walk to upon reaching a waypoint, or maybe stop for a few seconds to look around or do some sort of animation.
For things like grazing animals, you want them to mostly stay put, only occasionally moving on to other spot, and never far from the center of the herd. In a tavern, or some other crowded social place, you want the NPC to wander from person to person, instead of just randomly stumbling into walls. These kinds of tasks are easily done with a little bit of scripting on the heartbeat script. But you have to know what you want to do, and then be willing to customize a script to do exactly what you want it to.
For things like grazing animals, you want them to mostly stay put, only occasionally moving on to other spot, and never far from the center of the herd. In a tavern, or some other crowded social place, you want the NPC to wander from person to person, instead of just randomly stumbling into walls. These kinds of tasks are easily done with a little bit of scripting on the heartbeat script. But you have to know what you want to do, and then be willing to customize a script to do exactly what you want it to.
#5
Posté 07 février 2011 - 06:05
Here's an example of scripted waypoints. Any creature with any tag can wander randomly between the same set of waypoints you place in the area, if you give each creature a local variable called WP_TAG and set it to the name of the script below (in this example, "random_waypoints"). The waypoint names also have to contain the script name - eg. WP_[script name]_01. Rotate the waypoints in the toolset so that the arrow points in the direction you want the wandering creatures to face when they pause there.
// random_waypoints
//
// Create waypoints called WP_random_waypoints_**
// where ** are numbers starting at 01
//
// set variable on creatures as follows:
//
// WP_TAG = random_waypoints
#include "ginc_wp"
void main()
{
int iWP = GetCurrentWaypoint();
int MaxWPNo = GetNumWaypoints();
int iNextWP = Random(MaxWPNo) + 1;
SetNextWaypoint(iNextWP);
float fPauseTime = IntToFloat(Random(6)+5);// face waypoint direction and pause for 5-10 seconds
FaceAndPause(iWP, fPauseTime);
}
// random_waypoints
//
// Create waypoints called WP_random_waypoints_**
// where ** are numbers starting at 01
//
// set variable on creatures as follows:
//
// WP_TAG = random_waypoints
#include "ginc_wp"
void main()
{
int iWP = GetCurrentWaypoint();
int MaxWPNo = GetNumWaypoints();
int iNextWP = Random(MaxWPNo) + 1;
SetNextWaypoint(iNextWP);
float fPauseTime = IntToFloat(Random(6)+5);// face waypoint direction and pause for 5-10 seconds
FaceAndPause(iWP, fPauseTime);
}
Modifié par DannJ, 07 février 2011 - 06:15 .





Retour en haut






