MoveCharacter problems

Started by Scummbuddy, Thu 02/12/2004 04:58:40

Previous topic - Next topic

Scummbuddy

I followed the script for making NPC's walk in the bg from the tech archive.

basically, this in the room rep. ex.:
Code: ags

if (character[ZOMBA].walking != 1)
{
Ã,  Ã,  MoveCharacter(ZOMBA, Random(1600),Random(1200));
}


this causes ZOMBA to walk veeeeeeery slow. so slow that its almost impossible to Alt-x out of the game. Its taking all the computer power, essentially. What you see is basically one frame of the walking animation like every 4 seconds, as it attempts to walk to a new point. Because of this, I can't really walk around (using the arrow keys) unless I hold them down, and the code eventually gets to my (if key pressed down). but then i only move one frame of animation again very sluggishly, and I barely move from my original spot, if at all, and neither does ZOMBA.

quite odd.

If I simply change the code to this:
Code: ags

if (character[ZOMBA].walking == 0)
{
Ã,  Ã,  MoveCharacter(ZOMBA, Random(1600),Random(1200));
}


it works just fine. Is this a possible bug?
- Oh great, I'm stuck in colonial times, tentacles are taking over the world, and now the toilets backing up.
- No, I mean it's really STUCK. Like adventure-game stuck.
-Hoagie from DOTT

Gilbert

No, I don't think it is a bug.

It's just because that variable returns SOME non-zero value for true and 0 for false.
Normally it won't cause any problem, if you adapt the common convension that a nonzero value means true, and zero means false.
So
if (character[EGO].walking) {... to check if it's true
if (character[EGO].walking==0) {... to check if it's false

When something in the manual that only reads something like "...tells you whether..." you have to be careful, it never says it MUST return 1 when true (unless it's clearly stated in the sentence).

Pumaman

Yeah, the documentation's a bit weak on this I concede. The "walking" is 0 when not moving, or non-zero when moving. It's not gauranteed to be 1.

I'll be replacing it with a Property for the new version though, which will ensure it returns 1.

SMF spam blocked by CleanTalk