Character's animations repeat when it shouldn't

Started by G, Sat 04/03/2006 11:29:22

Previous topic - Next topic

G

Well, this is something I can't solve.

I have a character roaming around the screen (an enemy)

When this character's y coordinate and player character's y coordinate are the same, the enemy character starts walking to the player character.

That works.

When the player character kicks the enemy character, a variable (player's strengt) y subtracted to another variable (enemy's health). When enemy's health reaches 0 or less, the enemy dies, playing an animation, and this is the problem. the enemy character stays running that animation once time and another. The problem is not that ive wrote wrong the parameters when implementing the character.Animate, because I wrote this:

  else if (pjs[1].evit <= 0) {
    if (cZombie.View != 19){
         cZombie.LockView(18);
         cZombie.Animate(cZombie.loop, 4, eOnce, eBlock, eForwards);
         cZombie.Solid = false; // this allows the player to walk through the enemy
         cZombie.FollowCharacter(null, 0, 0); //this makes the enemy stop following the player
         cZombie.UnlockView();
         cZombie.ChangeView(19); //Finally this makes the enemy change its view.
         }

But it looks like the script ignores UnlockView and ChangeView, because it never reaches View 19.

Can anyone explain me what happens, please?

monkey0506

I don't know if it would make a difference, but try changing "cZombie.FollowCharacter(null, 0, 0);" to "cZombie.FollowCharacter(null);"

If that doesn't fix it, then perhaps try putting a Display statement after the stop following statement to make sure the script is doing what it should...?  Maybe:

Code: ags
/* blah */
    cZombie.FollowCharacter(null);
    Display("cZombie.View: %d (1)", cZombie.View);
    cZombie.UnlockView();
    Display("cZombie.View: %d (2)", cZombie.View);
    cZombie.ChangeView(19);
    Display("cZombie.View: %d (3)", cZombie.View);
    }
  }


That way it would display the zombie's view when it is locked and stops following the player, after it is unlocked, and then after it is changed (the 1, 2, and 3 are there just to distinguish between the three statements).

Then if it doesn't look right, you could tell us what numbers it is displaying and we could try to help you some more?

Other than that I don't know what to tell you.

Scorpiorus

Also, try re-arranging lines as follows:

if (cZombie.View != 19) {

   // stop the enemy first
   cZombie.FollowCharacter(null); //this makes the enemy stop following the player

   // lock view, play animation, unlock
   cZombie.LockView(18);
   cZombie.Animate(cZombie.loop, 4, eOnce, eBlock, eForwards);
   cZombie.UnlockView();

   // do the rest
   cZombie.Solid = false; // this allows the player to walk through the enemy
   cZombie.ChangeView(19); //Finally this makes the enemy change its view.

}


But make sure to try what monkey_05_06 suggested if that won't work -- i.e. put Displays here and there to trace the script.

SMF spam blocked by CleanTalk