Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: mport2004 on Thu 14/04/2005 01:28:19

Title: how to tell if an npc is in a room [SOLVED]
Post by: mport2004 on Thu 14/04/2005 01:28:19
i have a game thats almost finished but i came acrossed a problem in the game you have to guide some people to a village but i want them to stop when they get to the village.
Title: Re: how to tell if an npc is in a room
Post by: strazer on Thu 14/04/2005 01:47:30
Something like this?:

In the village room's repeatedly_execute interaction:


  // script for room: repeatedly execute

  if (GetGlobalInt(THEGLOBALINTNUMBER) == 0) { // if quest is not solved
    if ((character[PEOP1].room == character[GetPlayerCharacter()].room) &&
       (character[PEOP2].room == character[GetPlayerCharacter()].room) &&
       (character[PEOP3].room == character[GetPlayerCharacter()].room))
    { // if all people are in this room
      FollowCharacter(PEOP1, -1); // people don't follow you anymore
      FollowCharacter(PEOP2, -1);
      FollowCharacter(PEOP3, -1);
      DisplaySpeech(VILLAGER2, "Thank you!"); // people thank you
      SetGlobalInt(THEGLOBALINTNUMBER, 1); // set quest solved
    }
  }
Title: Re: how to tell if an npc is in a room
Post by: mport2004 on Thu 14/04/2005 17:05:25
thx im not to good a some parts of scripting yet.
Title: Re: how to tell if an npc is in a room [SOLVED]
Post by: mport2004 on Fri 15/04/2005 17:09:40
the code you gave me wont work i tryed it but it kept comming up w/ errors i changed it a bit

  if (GetGlobalInt(43) == 0) { // if quest is not solved
    if ((character[CPA].room == character[GetPlayerCharacter()].room) &&
       (character[CPB].room == character[GetPlayerCharacter()].room) &&
       (character[CPC].room == character[GetPlayerCharacter()].room))
       (character[CPD].room == character[GetPlayerCharacter()].room) &&
     { // if all people are in this room
      FollowCharacter(CPA, -1); // people don't follow you anymore
      FollowCharacter(CPB, -1);
      FollowCharacter(CPC, -1);
      FollowCharacter(CPD, -1);
      MoveCharacter(CPA,60,140);
      MoveCharacter(CPB,255,140);
      MoveCharacter(CPC,100,188);
      MoveCharacter(CPD,300,185);
      DisplaySpeech(CPA, "Guy wants to talk with you.");
      SetGlobalInt(43, 1); // set quest solved
    }
  }
Title: Re: how to tell if an npc is in a room [SOLVED]
Post by: Ashen on Fri 15/04/2005 17:20:50
Looks like there's an error with the lines:
(character[CPC].room == character[GetPlayerCharacter()].room))
(character[CPD].room == character[GetPlayerCharacter()].room) &&

I think it should be:
(character[CPC].room == character[GetPlayerCharacter()].room) &&
(character[CPD].room == character[GetPlayerCharacter()].room))

(Unless that's just how you typed it here, and not how it is in the script.)
Apart from that - what error messages are you getting?
Title: Re: how to tell if an npc is in a room [SOLVED]
Post by: mport2004 on Fri 15/04/2005 18:19:59
yay it finally worked thx for the help ;D