how to turn off folowcharacter ex and other questions?

Started by hawanja, Tue 25/05/2004 21:46:28

Previous topic - Next topic

hawanja

I have a scene where a player walks into a room and is attacked by a zombie. I've got it so the player takes damage and can kill the zombie by clicking on him, so far it works fine. However I've got a few problems:

the zombie attacks with FollowCharacterEX with eagerness set to 0, (which is under "first time player enters screen)which works fine, however after your kill it and the zombie goes to the death animation, it continues to follow you out of the room. Is there a way to turn FollowCharacterEX off? I tried this:

if (GetGlobalInt(16)==0){
   SetCharacterView (ZOMBIE, 9);
   StopMoving (ZOMBIE);
   character[ZOMBIE].room=-1;
      }
Where 9 is the dead zombie frame, and globalint 16 is the zombie's health, of course. But it doesn't work. The zombie stops moving in the room with the fight, but when you leave the room it's dead corpse follows you.


2nd question:

The zombie damages the player when two conditions are met, when characters are colliding and when the attack variable is zero. Here's my pathetic noobie code:

// script for room: Repeatedly execute
if ((AreCharactersColliding (2,3)==1)&& (GetGlobalInt(15)==0)){
  StopMoving(ZOMBIE);
  SetGlobalInt(10,GetGlobalInt(10)-10);
  AnimateCharacter (3,5,5,0);
  MoveCharacter(ZOMBIE,189,146);
  } 

It works okay, however the zombie's attack animation does not play. The hero takes damage (rather too quickly, need to fix that too) Globalint 15 is the attack variable, 2 and 3 are the hero and zombie charIDs respectively, globalint 10 is the hero's health. The idea is that the zombie will "collide" with the hero, take a swipe, do 10 points of damage, and then move away. Everything works except for the zombie's attack animation. Any pointers?

strazer

1st question:

FollowCharacter(ZOMBIE, -1); // stop following anyone

2nd question:

AnimateCharacter is a non-blocking function, meaning the command
  MoveCharacter(ZOMBIE,189,146);
is executed immediately afterwards before the animation had a chance to play.
Use
  AnimateCharacterEx (3,5,5,0,0,1); // animate blocking
instead.

hawanja

Worked like a charm! Fabulous.

One more thing, the zombie dies and just disappears, I'd like it if he leaved a body behind, so I figure that I could have a room turn on an object (the dead zombie) at the exact place where the zombie eats it. Any ideas how to do this? I have it turn on the object, but it appears where I place it in the room.

Thanks for your help above.

strazer

Cool.

Btw, the name holds the character value, so to be on the safe side, use
AnimateCharacterEx (ZOMBIE,5,5,0,0,1); // animate blocking

As for making a zombie corpse, I would draw it directly onto the background. This way, it doesn't slow down the game. However, it is erased once you leave the room.

Try this:

#define CORPSESPRITE 777

int corpsewidth = GetGameParameter(GP_SPRITEWIDTH, CORPSESPRITE, 0, 0);
int corpseheight = GetGameParameter(GP_SPRITEHEIGHT, CORPSESPRITE, 0, 0);
RawDrawImage (character[ZOMBIE].x-(corpsewidth/2), character[ZOMBIE].y-corpseheight, CORPSESPRITE);

where 777 is the number of the zombie corpse sprite in the sprite manager.

You can combine the above three lines into one, but that makes it less readable:

RawDrawImage (character[ZOMBIE].x-(GetGameParameter(GP_SPRITEWIDTH, CORPSESPRITE, 0, 0)/2), character[ZOMBIE].y-GetGameParameter(GP_SPRITEHEIGHT, CORPSESPRITE, 0, 0), CORPSESPRITE);

You decide.

Edit:
Of course, if you do it this way, you can't interact with the corpse afterwards.
The good thing is, however, that you can have the same character come at you as another zombie. Zombie hordes! :)

If you just don't want him to disappear, erase this line:
character[ZOMBIE].room=-1;

To have him be a corpse, just play a death animation with the last frame being the corpse.

SMF spam blocked by CleanTalk