NPC´s and regions

Started by JpSoft, Mon 05/05/2008 17:16:54

Previous topic - Next topic

JpSoft

Im trying to create a function to allow the NPC´s interact with room regions in the same way as the player character but i dont found an specific way so i just change the player character for any NPC is in the room and check if it is in any region.

Are there any other way? This solution slow down the game a lot  :(

jpsoft

Khris

You can use Region.GetAtRoomXY(cNpc.x, cNpc.y), check for it inside rep_ex.

JpSoft


m0ds

I'm having a similar problem with this and I don't really understand what to do.

When my NPC walks over a region I want them to say something in the background, but I don't know how to get AGS to check if the NPC is standing on the region.

QuoteYou can use Region.GetAtRoomXY(cNpc.x, cNpc.y), check for it inside rep_ex.

Is it possible to expand on this if it's the solution? I really don't get it, there doesn't seem to be anything telling AGS whether the NPC is on it or of it, or defining which of the regions I'm talking about... Any help?

:)

Khris

Code: ags
Overlay bgs;

// inside repeatedly execute

  if (cNpc.Room == player.Room) {  // skip over the following if NPC isn't in current room
    Region*R = Region.GetAtRoomXY(cNpc.x, cNpc.y); // get Region at NPC's feet
    int rid = R.ID;
    if (rid > 0) {   // skip if there's no region

      if (player.Room == 1) {  // room 1 events
        if (rid == 1) {
          if (bgs == null) bgs = cNpc.SayBackground("I'm on region 1!");
        }
        if (rid == 2) {
          if (bgs == null) bgs = cNpc.SayBackground("I'm on region 2!");
        }
      }

    }
  }

m0ds

Awesome, thanks for your kind help Khris!

Khris


SMF spam blocked by CleanTalk