My first move in the game is messing up the map

Hi again,

So I've got the map active, and have been adjusting the size and positions of the rooms so they look more like the layout of a house. Rather than stepping from one plain-looking square to another, you go from a narrow hallway into a larger room. Everything was fine, but somewhere along the way, something got mucked up.

When I start now, I'm in a narrow, 1x3 hallway. If I move east, I move into a 2x2 square 1 step north of the hallway. If I move west, I go into a 4x4 large room. If I go south, I go into another 4x4 large room. Everything was working fine, with lines marking the walls and such...

but for some reason now if I move west first, it seems that the large room to the west erases my 1x3 hallway. If I go back east, my little yellow marker dot is in a black, empty space rather than a white room (this is white on black). Every other room lines up correctly from this point on, but my starting hallway is essentially gone. This ONLY happens if my first move is west. If I move east, south, out, etc, the 1x3 room remains visible and the map builds up like it should. I can even go west and the 4x4 room does not screw up the rest of the map. This only happens if my first move is into the west room. I can look, search, so any sort of things I want, but the moment I move out of the room, if it's to the west, I lose the 1x3 starter room.

And I have no idea why.

I've checked the exits, there are no special scripts related to going west first. The fact that I can go in there after going anywhere else and it doesn't muck up has me utterly baffled.

Basically, THIS is what it's supposed to look like
VVVVVVVVVVVV

╔════╦■╦══╗
║                               ║
║              ║   ╠══╝
║              ║   ║
╠═       ═╣   ║

But what I get is THIS
VVVVVVVVVVVVVVVVV

╔════╗   ╔══╗
║              ║   ║       ║
║              ║   ╚══╝
║              ║   
╠═       ═╝ 


That's bizarre, and I can't think of any reason why it could happen.

Could you maybe share a link to the game, so someone else could take a look over the code and try to guess what could be causing this?


Sure, I've put the code up in my DropBox: https://www.dropbox.com/s/wif7dymyg3xitjb/Jack%20Monster.aslx?dl=0

Mind you, this is a work in progress, lots of experimentation, teaching myself how to use Quest, so you'll probably find a lot of "huh?" kind of stuff in there and missing room descriptions and such.


I've looked through it, and I can't see the issue. Completely stumped on this one.

If I get time later I might try creating a copy of the game so that I can take a look using the javascript debugger, but that's likely to be a very involved process. Hopefully there's someone else with the desktop version of Quest who might take a look at it.


I see something, but someone else will need to explain it...
When you move west first, the room is offset to the left by 1.
When you go other directions, it is lined up with the room to the south.
Does this help?
I don't have much experience with maps, but something is moving the room.

Actually, if you start the player to _NE, then the room is offset to the left by 1.
Where is the info that set the X and Y location for the room?
This could be what is causing the problem.

OK, what ever room you start in is offset left by 1 when you move west.
But NOT when you move other directions first.
Does this help?


If you resize room_NE (to the west), you can see how the first room is hidden under the west room.
Why??? I don't know.


Sounds like any starting room is moved 1 to the west, rather than the player?


Thank you to you all for taking a look!


So... I found a workaround. It's not a solution, because it doesn't explain what's causing the first room to end up under the second room if you move west, but it makes it so it won't happen:

I made my player's starting room the front porch.

Now, the only option for first movement is to go in. And because of this, no matter which way you go after, the map does not screw up anymore.

I should note that I tried adjust the exit to the NW room to have a grid_length of 1, and this fixed the initial problem, but caused a larger one where every subsequent entry into the room from the east caused it to misalign 1 grid space further west with each try. Still baffling.


Could it be that since the player "jumps" to the first room, Quest doesn't know which way the player moved?
How about just opening a 1 way door to the first room?

Also, a general map question, How does Quest know where each room is, relative to the other rooms?
Mainly regarding rooms that are not the classic same-size, grid aligned rooms.


Also, a general map question, How does Quest know where each room is, relative to the other rooms?

When the player enters a room, Quest looks at all exits from that room.

  • Exit's x coordinate is:
    • north/south: room x plus half of room width (to put it in the middle of the side)
    • west: room's x coordinate
    • east: room's y coordinate
  • Destination room's x coordinate is:
    • north/south: exit's xcoordinate, minus half the width of the destination room (so the exit is in the centre of the N/S wall)
    • west: exit's x coord, minus exit's grid_length, minus width of the destination room
    • east: exit's x coord plus exit's grid_length
      The same is done for the y coords

I've manually looked through the code in that game, and tried to work out the numbers in my head. I can't see how it's messing up the positions.
If I had the game in the editor, I'd try making a function to display the coordinates, and see what it shows before and after visiting different rooms. Something like:

coords = NewObjectList()
list add (coords, Floor_1_N)
list add (coords, Floor_1_NW)
list add (coords, GetObject(GetExitByLink(Floor_1_N, Floor_1_NW)))
list add (coords, GetObject(GetExitByLink(Floor_1_NW, Floor_1_N)))
foreach (room, coords) {
  dict = Grid_GetPlayerCoordinatesForRoom(player, room)
  result = "Coordinates for "+room.name+" ("+GetDisplayAlias(room)+")<ul>"
  foreach (key, dict) {
    result = result + "<li>"+key+": "+DictionaryItem(dict, key)+"</li>"
  }
  msg (result+"</ul>")
}

Running that before entering the hallway, after entering the hallway, and after entering the room would give a little more information, maybe giving us a clue why it's going wrong.

If the room appears correctly if it's not the first one you enter, perhaps it would be worth looking at the coordinates in that case too.


I'll try this code out today and post what results I get. Thanks for your continued research, folks!


Well this just got weirder.

I put the code in the "Before entering" for the north hallway. I put the code in "After entering" the north hallway. I put the code in "After entering" the living room.

And the map no longer broke. It showed me the coordinates, but more importantly, the map worked. Here's what it gave me:

Coordinates for Floor_1_N (North Hallway)
x: 0
y: 0
z: 0
grid_isdrawn: True

Coordinates for Floor_1_NW (Living Room)
x: -4
y: 0
z: 0

Coordinates for exit3 (west)
x: 0
y: 2
end_x: 0
end_y: 2

Coordinates for exit1 (east)

Note that the living room is adjusted -4 in the x direction, and the west exit's x coordinate is 0.

The map looked fine.

So I took the code out, and the map went back to being broken again. At this point I said to myself, "so something in the code is affecting the outcome." and I put the code in bit by bit. Apparently, something about the code in the "Before entering" the north hallway is affecting how the map works, because here are the coordinates I get when it's gone:

Coordinates for Floor_1_N (North Hallway)
x: 0
y: 0
z: 0
grid_isdrawn: True

Coordinates for Floor_1_NW (Living Room)
x: -3
y: 0
z: 0

Coordinates for exit3 (west)
x: 1
y: 2
end_x: 1
end_y: 2

Coordinates for exit1 (east)

Now the living room is offset by -3, which is causing it to overlap the hallway, and the exit to it is offset by 1.

I took out the After entering code for both rooms, left the Before entering code in, but removed the part where it posts the results in a message, and somehow simply gathering the information is enough to fix the problem, but I don't know why. I tried removing the foreach loop and it broke. I stripped the code down until I found a single line that fixes everything:

dict = Grid_GetPlayerCoordinatesForRoom(player, room)

With just this line in the Before entering script, the map functions properly.


That's strange. I wonder if the code that generates the initial coordinates for the first room (well, the hallway you're teleporting them into, which isn't connected to the actual start room by an exit) behaves differently depending if the room already has a coordinate dictionary.

I'll have to look into that later.

(Does creating an invisible exit leading from "room" to "Floor_1_N" in any compass direction also fix the issue?)


I actually stopped starting the player out in the "intro" room and just plopped them right down in the north hallway and it still did this. I can't say when this began unfortunately because the idea of a shaped map that fits with the expected dimensions of the individual rooms was something new I was just toying with when I discovered the problem.


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums