Character.Walk

Started by arj0n, Tue 29/09/2009 21:35:40

Previous topic - Next topic

arj0n

I want a NPC (a bird) go from the start position in the room to coordinate B and go back to coordinate A
33,163 is coordinate A, 190,163 is coordinate B
the bird should do this constantly
Somehow the character isn't moving at all.
What am I doing wrong?

Code:

function room_RepExec()
{
cBird.Walk(300,  163, eNoBlock);
cBird.Walk(190,  163, eNoBlock);
}

Crimson Wizard

#1
It does not move, because, since movement is not a blocking type, second line of script is executed right away, and since bird is already at the destination point, it does nothing.

You can do following:

Code: ags


function room_RepExec()
{

   if (!cBird.Moving)
   {
      if (cBird.x == 300)
      {
         cBird.Walk(190,  163, eNoBlock);
      }
      else
      {
         cBird.Walk(300,  163, eNoBlock);
      }
   }
}


This will only give Bird orders if it is not currently moving (that means - either it hasn't move yet, or just reached its destination).

Ethan D

Also, since you didn't specify whether it is walkableareas or Anywhere the editor will automatically choose WalkableAreas that also could be a problem.

arj0n

#3
Thanx Crimson & Ethan!

Crimson:
It didn't work, had to change the second line into this:
if (cBird.x == 190)

Than it still didn't work because of what Ethan said: The bird had to fly into an non-walkable area, so I had to make the whole area walkable in order to let the bird be able to fly.

But now the main character can also walk that way, and that's not what I want to.
I guess I have to let the editor know to use "anywhere" in stea of walkable are or something, but don't know how yet...

EDIT:
allrighty, found it, I should use:

cBird.Walk(400,  163, eNoBlock, eAnywhere);
cBird.Walk(190,  163, eNoBlock, eAnywhere);

SMF spam blocked by CleanTalk