SOLVED:Timed collision object with character displaying text even if not collide

Started by barefoot, Tue 15/03/2011 07:49:21

Previous topic - Next topic

barefoot

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..

Code: ags


  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



I May Not Be Perfect but I Have A Big Heart ..

Dualnames

Code: ags
 
 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.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

barefoot

Cheers Dualnames

this seems to work ok

Code: ags

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

I May Not Be Perfect but I Have A Big Heart ..

Khris

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.

barefoot

I May Not Be Perfect but I Have A Big Heart ..

SMF spam blocked by CleanTalk