Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: barefoot on Tue 15/03/2011 07:49:21

Title: SOLVED:Timed collision object with character displaying text even if not collide
Post by: barefoot on Tue 15/03/2011 07:49:21
Hi

I have a series of events that are set off by a Timer in Rep..

These events cause an object (bird) to fly around a scene.

I have 4 different Random options of where the bird fly's to.

This is ok and works as it should.

I have also incorporated a collide with character so should the bird touch the character during one of it's flights a series of events happen as below..

My problem at the moment is that the Display and Say happen even if the bird is not colliding with character.

I'm sure it's a script thing and possibly {}..  ::)

I will study the script again and all help appreciated..



 if (IsTimerExpired(1) == 1) {
   int ran=Random(2);
   
   if (ran == 0 ) {
   obird.Animate(0, 5, eRepeat, eNoBlock);
   object[4].Move(460, 662, 3, eBlock, eAnywhere);
 
   if (cwizard.IsCollidingWithObject(object[4]) == 1)
   
   Display("The bird's claws catch you on the neck!!");
   Wait(1);
   cwizard.Say("Ouch!!");
   object[4].Move(380, 502, 3, eBlock, eAnywhere);
   SetTimer(1, 100);


barefoot



Title: Re: Timed collision object with character displaying text even if not colliding..
Post by: Dualnames on Tue 15/03/2011 08:00:54
 
if (IsTimerExpired(1) == 1) {
    int ran=Random(2);
     if (ran == 0 ) {
    obird.Animate(0, 5, eRepeat, eNoBlock);
    object[4].Move(460, 662, 3, eBlock, eAnywhere);
 
  if (cwizard.IsCollidingWithObject(object[4]) == 1){   
    Display("The bird's claws catch you on the neck!!");
    Wait(1);
    cwizard.Say("Ouch!!");
    object[4].Move(380, 502, 3, eBlock, eAnywhere);
    SetTimer(1, 100);
}

}


I hate non-bracketed stuff much as anything. So that may be it as well.
Title: Re: Timed collision object with character displaying text even if not colliding..
Post by: barefoot on Tue 15/03/2011 08:26:26
Cheers Dualnames

this seems to work ok


if (IsTimerExpired(1) == 1) {
    int ran=Random(0);
     if (ran == 0 ) {
    obird.Animate(0, 5, eRepeat, eNoBlock);
    object[4].Move(460, 662, 3, eBlock, eAnywhere);
 
  if (cwizard.IsCollidingWithObject(object[4]) == 1){   
    Display("The bird's claws catch you on the neck!!");
    Wait(1);
    cwizard.Say("Ouch!!");
    object[4].Move(380, 502, 3, eBlock, eAnywhere);
  }
   
    else if (cwizard.IsCollidingWithObject(object[4]) == 0){   
   
    object[4].Move(380, 502, 3, eBlock, eAnywhere);
  }
    SetTimer(1, 100);
}
     }


Thank you

barefoot

Title: Re: SOLVED:Timed collision object with character displaying text even if not collide
Post by: Khris on Tue 15/03/2011 11:39:31
Shouldn't you test for the two conditions independently?

I imagine a flying bird can hit the player at any time, not just at the end of a timer.
Title: Re: SOLVED:Timed collision object with character displaying text even if not collide
Post by: barefoot on Tue 15/03/2011 12:16:38
Mmm good idea Khris...  it does make sense..   :=

cheers

barefoot