Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Whelandrew on Sat 14/08/2004 08:54:11

Title: Walking duck
Post by: Whelandrew on Sat 14/08/2004 08:54:11
I have a duck. I want this duck to walk around the screen. It has no real purpose but to add a bit more decor to the screen it's in. My problem is that my hours of battling scripting has left me without any idea how to get the Duck to walk around randomly on the screen.

How can I get it to just walk around the screen with no set direction?
Title: Re: Walking duck
Post by: Phemar on Sat 14/08/2004 09:08:03

short re=0;
while (re<1) { //will repeatedly execute
  MoveCharacter (DUCK, Random(320), Random(200));
  }

I haven't fully tested this out yet so there may be errors. The problem that might come here is you'll need a wait command somewhere, defeating the whole purpose... I dunno.
Title: Re: Walking duck
Post by: Darth Mandarb on Sat 14/08/2004 09:11:53
Sprinkle bread crumbs around the background.

I kid ...

You can get Scorpiorus' Character Control System (http://www.adventuregamestudio.co.uk/games.php?action=search&sterm=Scorpiorus&submit=Search%21) ... it might be what you're looking for.

Aside from that there's the, moveCharacterPath command you could look up the syntax in the help file ('cause I don't know it off hand!)
Title: Re: Walking duck
Post by: Mr Jake on Sat 14/08/2004 09:15:10
that will cause errors because its an infinate loop (wouldn't it?)

a way to do it might be:

If (walk == 0){
MoveCharacter (DUCK, Random(320), Random(200));
walk = 1;
}

if (Character[DUCK].walking == 0) {
walk = 0;
}

put this into the Rep_exe of the room, and make sure you define
int walk
at the start of the room script.
Title: Re: Walking duck
Post by: Ashen on Sat 14/08/2004 12:25:46
In the rooms rep_ex:

if (character[DUCK].walking  == 0) {
  MoveCharacterStraight (DUCK, Random (320), Random (240));
}

(Works for me, anyway)
The MoveCharacterStraight command means you can limit it to walkable areas (or, perhaps,  create a seperate area to be a pond). To have it wander the whole screen, replace it with MoveCharacterDirect.
Title: Re: Walking duck
Post by: Mr Jake on Sat 14/08/2004 12:27:04
duh, stupid me, those Ints were useless. :)

Ashens code does the same and mine but with less lines.
Title: Re: Walking duck
Post by: Scummbuddy on Sat 14/08/2004 18:07:59
you can make it so that it runs on a variable. and have it to have 4 "walk points". when it reaches one point, you add to the variable, which an if statement would cause it to find its way to the next point, and continue the procedure.
Title: Re: Walking duck
Post by: Whelandrew on Sat 14/08/2004 20:28:13
Yes! Ashens code did it! Thank you, Ashen! Now my duck is walking around and bouncing off the trees and buildings like a good little ignorant bird.
Title: Re: Walking duck
Post by: Phemar on Sun 15/08/2004 17:46:25

Bloody Favouritism :D
Title: Re: Walking duck
Post by: YOke on Mon 16/08/2004 14:25:51
I used an alternate solution in the soon to be released teamgame. There I had several child characters that were supposed to roam randomly around an object and, at one point, follow the character. For this i used an invisible character standing still that all the child-characters followed.
I used the FollowCharacterEx (CHARID, int chartofollow, int dist, int eagerness)

Adjusting dist to the distance they were allowed to roam from their parent, and eagerness to 0 to keep them wandering around randomly.
Might not be the best solution for a single character, but for a flock it worked like a charm.