Aller au contenu

Photo

Random wander script?


  • Veuillez vous connecter pour répondre
7 réponses à ce sujet

#1
Groove Widdit

Groove Widdit
  • Members
  • 378 messages
Hey guys. In the old NWN1 there was a heartbeat script to make an animal or whatever wander in a random direction. You didn't need waypoints. I found the 2 rw script with the waypoints, but isn't there a simpler one like the old one? Thankxs!

#2
Tchos

Tchos
  • Members
  • 5 042 messages

There's a function, ActionRandomWalk(), that can be given to a creature and it will wander with no need for waypoints.  It can be assigned automatically to a creature if you use the script x2_spn_rndwalk for its On Spawn In script.

 

It says it never ends and requires a ClearAllActions for the creature to do anything else, but I've used it on hostile creatures, and it doesn't prevent them from attacking.  Not sure what happens if you try to converse with one.  Would it start walking again afterward or not?  Or not allow you to converse?



#3
Dann-J

Dann-J
  • Members
  • 3 161 messages

Setting the following local string variable on a creature will cause it to wander randomly, although it will only begin to wander when a player comes within range.

 

Variable name: SpawnScript

String value: gb_wanderer_sp

 

Creatures spawned from an encounter trigger will wander by default, and will do so as soon as they spawn (regardless of whether there are any players nearby).



#4
Groove Widdit

Groove Widdit
  • Members
  • 378 messages
It worked! Eyrgh! Now I done got vermin sniffin all up and down my action!

#5
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 585 messages
I created fencing triggers and scripts to restrict wandering creatures to specific areas back in 2007. Those fencing scripts are in my Silverwand Sample campaign. There are other ways to do this using home waypoints though. A thread describing several options is here. Handy for keeping creatures from wandering too far from their point of origin.

Regards
  • GCoyote aime ceci

#6
kamal_

kamal_
  • Members
  • 5 240 messages

Things like this and the invisible fencing trigger thread scripts would be great to have in the scripts section of the Toolset Notes.



#7
Dann-J

Dann-J
  • Members
  • 3 161 messages

I created my own wandering animal scripts as well. They include a check for a home waypoint and a range value, so if they wander too far from home they turn and walk back. That keeps them within a certain radius of a specified point.

 

If they're within their specified home range (or they don't have a home waypoint), they wander randomly. I also have them randomly utter one of three animal cries, set on them as local string variables. That way pigs will occasionally grunt, horses will whinny, and chickens will cluck (or crow in the case of roosters).

 

I have an additional 'timid animal' system that gives them a custom aura, so that they run from anyone not of their own faction if the intruder gets too close. It's handy for flocks of chickens. Players can walk through them and watch them scatter in panic in all directions. Once the timid animal gets a certain distance from the intruder, they go back to their normal wandering (or head back to their home waypoint if they've run too far).

 

Here's the wander HB script. It requires the creature to be using the gb_wanderer_sp script as an OnSpawn script (either hardcoded, or via a local 'SpawnScript' string variable):

 

Spoiler

  • 4760 aime ceci

#8
Groove Widdit

Groove Widdit
  • Members
  • 378 messages
Ah, great resources, guys.