Setting a character boundries to walk in and FollowCharacter problem...

Started by Snake, Fri 28/03/2008 11:47:30

Previous topic - Next topic

Snake

I am finding it very hard to find what I need in the manual (I've been looking/trying/experimenting since yesterday) and am sure I'm just over-looking it.

I'd like an NPC to walk within a small area randomly, follow the player character when he is within those boundries, then stop following/go back when the PC is back outside the bounds.

Walking randomly and following is no problem. Making the NPC walk within a 320,xxx box is no problem.

But how can I adjust the x? I don't want the NPC walking the full 320, just, let's say, for example, a width of 200 pixels in the center of the screen. How do I go about assigning the x coordinate?

FollowCharacter problem:
I tried using hotspots (as the boundry) to tell when to send the NPC back to inside the boundries. I used a local int, followme, set it to 1 when the PC was within the boundries and set back to 0 when outside.
This doesn't seem to work instantaniously.

When following the character, the NPC seems to ignore the command to go back (for what I could tell, until he stopped and stood still - waiting for the PC to move again) - resulting in following the PC way out of his boundries before going back - but he needs to stop and go back as soon as he's out of bounds.

A HUGE thanks in advance for any help,


--Snake
Grim: "You're making me want to quit smoking... stop it!;)"
miguel: "I second Grim, stop this nonsense! I love my cigarettes!"

Khris

If I understand you correctly, you're looking for x = Random(200) + 60;

About following: I've noticed that region events aren't always processed instantly.
It might be worth a try to do everything manually.

Code: ags
// rep ex

  if (Region.GetAtRoomXY(player.x, player.y) == 1) {
    if (!cGuy.Moving) cGuy.Walk(player.x, player.y);
  }
  else {
    if (!cGuy.Moving) cGuy.Walk(Random(200)+60, Random(50)+25);
  }

Snake

Thank you, Khris, I'll try both of them right away.

If I may ask, what is the +60? <-- So I know what I am adjusting...


--Snake
Grim: "You're making me want to quit smoking... stop it!;)"
miguel: "I second Grim, stop this nonsense! I love my cigarettes!"

Khris

I got that you wanted a random x coord in the range of 60 to 260 (200 in the middle of the 320-screen).
That's achieved by adding 60 to Random(200).

SMF spam blocked by CleanTalk