Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: barefoot on Mon 15/02/2010 20:59:19

Title: condition if all objects off (visible: false)
Post by: barefoot on Mon 15/02/2010 20:59:19
Hi

I am looking for a condition that when certain Objects are NOT visible a condition can be run such as change room... (Opposite condition of below code)

'After killing an Object it is switched off (visible true/false)..   I have 3 objects.'



if ((oMobster1Dead.Visible) && (oMobster2Dead.Visible) && (oMobster3Dead.Visible)) {
  Display("You have killed the 3 Mobsters and it's now safe to pass")
  player.ChangeRoom(23, 55, 371);
}


I have looked but not found the answer yet.

All help appreciated
barefoot
Title: Re: condition if all objects off (visible: false)
Post by: Khris on Mon 15/02/2010 21:00:49
  if (!oMobster1Dead.Visible && !oMobster2Dead.Visible && !oMobster3Dead.Visible) {
Title: Re: condition if all objects off (visible: false)
Post by: barefoot on Mon 15/02/2010 21:11:00
Thanks so much Khris

You helped me big time

cheers

barefoot
Title: Re: condition if all objects off (visible: false)
Post by: suicidal pencil on Tue 16/02/2010 17:42:14
There's another method that will let you use the same code over and over again for each room. Especially when you have too many objects in a room, and doing the if(!object[0].Visible && !object[1] && .......


function GetVisibility()
{
  int counter = 0;
  int false_count = 0;
  while(counter <= Room.ObjectCount)
  {
     if(!object[counter].Visible) false_count++;
  }
  if(false_count == Room.ObjectCount) return true;
  else return false;
}
Title: Re: condition if all objects off (visible: false)
Post by: Khris on Tue 16/02/2010 18:09:40
You have to stop the iteration at Room.ObjectCount - 1; object numbering starts at 0.
Title: Re: condition if all objects off (visible: false)
Post by: suicidal pencil on Wed 17/02/2010 01:52:18
Quote from: Khris on Tue 16/02/2010 18:09:40
You have to stop the iteration at Room.ObjectCount - 1; object numbering starts at 0.

yes, I know it starts at 0, and if you have all 40 objects in a room, that loop should stop when counter hits 39
Title: Re: condition if all objects off (visible: false)
Post by: Khris on Wed 17/02/2010 02:58:14
You have
while(counter <= Room.ObjectCount)

So at the last iteration, counter == Room.ObjectCount.

Plus - just saw that - you aren't incrementing counter.