Creatures walk around. [solved]

Started by MoonDog, Fri 07/08/2015 16:55:14

Previous topic - Next topic

MoonDog

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


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.

MoonDog

Code might not be 100% because I'm typing with a slow phone today.

Grok

For having the bunny walk around without interacting with it you could do something like this

on load you start a timer

Code: ags
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).
Code: ags

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.

Code: ags
 SetTimer(1,1000 + Random(500));


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


MoonDog

Will give that a try later today.

MoonDog

Tried it that it and it's walking around aimlessly perfectly, thanks :-D

SMF spam blocked by CleanTalk