ID:138156
 
I just put a chicken into my game to test it, and the chicken goes around the border of the map and not only that, but it's always a rectangular pattern that they travel in. You really gotta make that feature better... chickens are the new fad you know...

Kevin
I just put a chicken into my game to test it, and the chicken goes around the border of the map and not only that, but it's always a rectangular pattern that they travel in.

Yeah, I forgot about that. Try this instead.

#define CHICKEN_SPEED 4
#define CHICKEN_CHANGE_DIR_PROB 30

mob/chicken
New()
. = ..()
spawn Wander()

proc/Wander()
while(src)
if((!step(src, dir)) || prob(CHICKEN_CHANGE_DIR_PROB))
var/turnAngle = 45
if(prob(50)) turnAngle *= -1
dir = turn(dir, turnAngle)

sleep(CHICKEN_SPEED)
In response to Guy T.
On 2/23/01 6:30 am Guy T. wrote:
I just put a chicken into my game to test it, and the chicken goes around the border of the map and not only that, but it's always a rectangular pattern that they travel in.

Yeah, I forgot about that. Try this instead.

#define CHICKEN_SPEED 4
#define CHICKEN_CHANGE_DIR_PROB 30

mob/chicken
New()
. = ..()
spawn Wander()

proc/Wander()
while(src)
if((!step(src, dir)) || prob(CHICKEN_CHANGE_DIR_PROB))
var/turnAngle = 45
if(prob(50)) turnAngle *= -1
dir = turn(dir, turnAngle)

sleep(CHICKEN_SPEED)

they move way too fast or something because they disappear and then com back in a new location... i raised the speed to 15 but that only helped a minimal amount...
In response to Spastic
they move way too fast or something because they disappear and then com back in a new location... i raised the speed to 15 but that only helped a minimal amount...

Odd! I'll try to look at it tonight and see if I did something wrong.
In response to Guy T.
On 2/23/01 6:30 am Guy T. wrote:
I just put a chicken into my game to test it, and the chicken goes around the border of the map and not only that, but it's always a rectangular pattern that they travel in.

Yeah, I forgot about that. Try this instead.


Let me save you a lot of hassle -- the Deadron library has a very flexible random walking function (because I had the same issue with walk_rand).

The important thing is that you can set the amount of randomness. You can read about dd_step_rand() here as well as download the library from the top of that page.
In response to Guy T.
Yay! I started the chicken fad! :)
lol
Someone should make a Chicken Hunter game!! :)
That would be cool :) And when you hit them there head falls off! lol
That would be funny :)
Thanx
Shane :)
On 2/23/01 5:47 am Spastic wrote:
I just put a chicken into my game to test it, and the chicken goes around the border of the map and not only that, but it's always a rectangular pattern that they travel in.

walk_rand actually follows a pattern which is called 'edge following'. That is, it'll move in a random direction until it reaches a wall, and then it'll pick a direction in a slight variation from its current path, picking greater and greater variations if the chosen variation is blocked.

You really gotta make that feature better... chickens are the new fad you know...

Well, walk_rand() suits its purpose fine... a quick, efficient, non-processor-intensive pseudo-random movement process. If you want more advanced control over pathing, I'd recommend downloading Deadron's library.