Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: MoonDog on Fri 07/08/2015 16:55:14

Title: Creatures walk around. [solved]
Post by: MoonDog on Fri 07/08/2015 16:55:14
Ok so I managed to set it so that if I try pet something it shall walk away to a random stop. Only problem is that after it stops walking it doesn't animate. I tried putting animate code after the walk but it does nothing.
I then put a wait code for 120 then put animate, it works. Only problem now is that I can't move while in wait. How do I go about this? Also what's the best options for creatures to move around a single room without me having to interact with it?

This is what I got for the bunny1 movements:

Code (ags) Select


function cBunny1_Interact()
{
cBunny1.Walk(Random(999), Random(399), eNoBlock, eWalkableAreas);
Wait(120);
cBunny1.Animate(8,10,eRepeat,eNoBlock);

If (Region.GetAtRoomXY(cBunny1.x , cBunny1.y) == region[2] {
  CBunny1.Walk(Random(999), random(399), eNoBlock, eWalkableAreas);
Wait(120);
cBunny1.Animate(8,10,eRepeat, eNoBlock , eforwards);
}
}


The region part is just incase it stops behind a WalkBehind spot and unable to interact with it afterwards.
Title: Re: Creatures walk around.
Post by: MoonDog on Fri 07/08/2015 16:56:06
Code might not be 100% because I'm typing with a slow phone today.
Title: Re: Creatures walk around.
Post by: Grok on Sat 08/08/2015 07:44:12
For having the bunny walk around without interacting with it you could do something like this

on load you start a timer

SetTimer(1,1000);

In room_RepExec() you test if the timer has expired, If it has you walk the bunny and reset the timer. The bunny will then repeatedly walk to different spots in the room with periods of waiting between each walk (depending on what time you set the timer for).

if (IsTimerExpired(1))
{
  cBunny1.Walk(Random(999), Random(399), eNoBlock, eWalkableAreas);
  SetTimer(1,1000);
}


You could make the the intervals between walking more random if you want to.

SetTimer(1,1000 + Random(500));

For the animation between walks you could use the characters IdleView.

Title: Re: Creatures walk around.
Post by: MoonDog on Sat 08/08/2015 09:06:06
Will give that a try later today.
Title: Re: Creatures walk around.
Post by: MoonDog on Sun 09/08/2015 09:04:34
Tried it that it and it's walking around aimlessly perfectly, thanks :-D