NewRoomEx problems(SOLVED)

Started by Pizzaman, Thu 03/02/2005 09:39:41

Previous topic - Next topic

Pizzaman

Hi,

I got this puzzle where its like a maze.Ã,  Each room looks identical, but depending on the sequence of paths EGO takes, he will end up victorious or dead.Ã,  Anyway, this problem is cosmetic, maybe you guys can help.

When I go off to any of th edge, I change EGO back to the same room, expect he will end up on the other side.Ã,  For example: If he walks off right edge, he will end up in the left edge of the "new" room.

But sometimes, randomly, he will not go to the opposite side of the room, the rest of the script works, like keeping track of the path history and all, its just sometimes he won't end up on the other side and would stay on the same side.

//here is an excerpt if he walks off to the right side of the screen
Ã,  // script for room: Walk off right screen edge
if (counter == 0)
{
Ã, 
Ã,  //keep track of path records
Ã,  ForestPathPuzzle[counter] = WEST;
Ã,  //increment counter
Ã,  counter++;
Ã,  NewRoomEx(4, 37,107); //start in same room, on the other side
}Ã, 

else if (counter < 4)
{
Ã,  //intermediate tracker
Ã,  ForestPathPuzzle[counter] = WEST;
Ã,  counter ++;
Ã,  NewRoomEx(4, 37, 107); //start in same room, on the other side
}

else if (counter == 4)
{
Ã,  int mismatch = 0;
Ã, 
Ã,  ForestPathPuzzle[counter] = WEST; //store the last path
Ã,  //check to see if correct configuration
Ã,  counter = 0; //reset counter
Ã,  while(counter < 5)
Ã,  {
Ã,  Ã,  if ( ForestPathPuzzle[counter] != ForestPathSolution[counter] ) //if there is a mismatch
Ã,  Ã,  {
Ã,  Ã,  Ã, mismatch = 1; //mark that there has been a mismatch
Ã,  Ã,  Ã, counter ++;Ã,  Ã,  Ã, 
Ã,  Ã,  }
Ã,  Ã,  else //else check next iteration
Ã,  Ã,  {
Ã,  Ã,  Ã, counter ++;
Ã,  Ã,  }
Ã,  } //end while(counter < 5)Ã, 
Ã, 
Ã,  //go to appropriate room depending on result
Ã,  if (mismatch == 0)
Ã,  {
Ã,  //success, puzzle solved!Ã, 
Ã,  Ã,  counter = 0;
Ã,  Ã,  SetGlobalInt(FORESTPUZZLE, 1);
Ã,  Ã,  NewRoomEx(8, 161, 89);
Ã,  }
Ã,  else
Ã,  {
Ã,  Ã,  counter = 0;
Ã,  Ã,  //go back to beginning!
Ã,  Ã,  NewRoomEx(5, 308,184);
Ã,  }

I checked to make sure that the new coordinates are far within the edge boundries.Ã,  I appreciate any input.Ã,  Thanks.

-Pizzaman

RickJ

#1
I would put "Display" statements in each brach of your if-else structure to see if that behaviour only happens at a particular point.  My guess is there is a flaw in the logic somewhere, but I wouldn't know for sure. 

*** Edit ***
Hmmm, well I guess my first suggestion won't be very helpful since you are using the same NewRoomEx() statement for both possibilities.  I gues the next thing I would wonder about is what code do you have for the "player enters room" events?  Maybe there is something there.  Also is there enough margin between where the player lands and the corresponding edge? 

strazer

#2
Quote
But sometimes, randomly, he will not go to the opposite side of the room

Hm, strange. Does the room change occur at all?

Btw, right is EAST, left is WEST. ;)

Edit:

You say this is an excerpt. NewRoomEx is a delayed-response function, meaning it doesn't get executed until the script finishes. Do you have any code after this that could affect it?

Pizzaman

#3
Quote from: RickJgues the next thing I would wonder about is what code do you have for the "player enters room" events?  Maybe there is something there.  Also is there enough margin between where the player lands and the corresponding edge?

No, there isn't any code in the "player enters room" event.  There is however, some simple if statements in "repeatedly execute" section in this room, but this bug occured before I had anything there in the first place.  As for the margin of landing, I believe I got enough.  It just sometimes does it randomly... I made a chart of counter vs. direction, and i did many trials.  It occurs at random times.

Quote from: strazerHm, strange. Does the room change occur at all?

Btw, right is EAST, left is WEST.

Edit:

You say this is an excerpt. NewRoomEx is a delayed-response function, meaning it doesn't get executed until the script finishes.

Yes the room changes.  It fades out and fades back in.  Ya this is an excerpt, however, this is the complete block of code for "walk off right edge."  Nothing afterwards.  I am sure that non of the other branches gets executed.

As for the direction, haha I knew someone would pick that up  Its actually part of the puzzle that the directions are wacked.

Quote from: Scorpiorus
QuoteYou say this is an excerpt. NewRoomEx is a delayed-response function, meaning it doesn't get executed until the script finishes. Do you have any code after this that could affect it?
To check strazer's supposition put the 'return' keyword just after each NewRoomEx function, i.e.:

if (counter == 0)
{
 
  //keep track of path records
  ForestPathPuzzle[counter] = WEST;
  //increment counter
  counter++;
  NewRoomEx(4, 37,107); //start in same room, on the other side
  return;
}

etc... after each NewRoomEx.

See if it works this way but be also sure to try the other suggestions.

Ya I did that too, but still does it randomly. 

Hmm, I got code in the global repeatedly execute... don't think that might cause the delays?  But even then... the room still changes.  I'm going to try setting the coordinates to the center of the room.

-Pizzaman

Nope that didn't work.  Is there a teleport character function and maybe a fade in fade out effects function?  I could fabricate the room change.

RickJ

Quote
Is there a teleport character function and maybe a fade in fade out effects function?
You could do something like this:
   FadeOut(1);                          // Fade out effect
   StopMoving(EGO);                //  Teleport character EGO
   character[EGO].x = xpos;
   character[EGO].y = ypos;
   FadeIn(1);                            // Fade in again 

Another thing you may be interested in is the continously loop room in DemoQuest.   If you used something similar you wouldn't need to do the fade in/out, it would seem to continously scroll left  or right. 

Pizzaman

alright, that did the trick.  Thanks for the code RickJ.  I had to put a Wait command right before the FadeIn(1), or else you can see him jump to the other side as it fades in.  Kinda like special effects gone wrong.

I still wonder why the NewRoomEx function gives me those problems.  Oh well, answers will arrive in the future.

-Pizzaman

SMF spam blocked by CleanTalk