New account registration is temporarily disabled.

AJDERNIZ'S PROFILE

Search

Filter

Pathfinding

DAMN. Sucks to be this late to such an useful post.
Alright, the tutotial, I followed once, twice, thrice..., and I only know how to spell the '-ice' word up to three. Then I realized that this script works only for 10x10 maps, even after properly altering the variable count and the dimensions of such, whenever a 10 is present within the script. I even made it so that all the important variables are set up from only changing a 'dimension' variable on the initialize event; and yet, it ain't obvious to me what else there is to change so that the map works at any size other than 10x10.
I specifically need it to work at AT LEAST 11x11, or any other, higher, odd dimension.
If anyone ever reads this, and knows more or less what to do, I'll be... happy, yeah, happy. I suspect the problem is somewhere in the cheapest neighbour event. If I find out what to do, I'll update.

EDIT: OKAY, I DID IT. THE SCRIPT NOW WORKS FINE BY ADJUSTING ONLY ONE DIGIT
I don't want to make this overly long, so I'll try to be brief. The biggest pain in working with RPG Maker scripts is modifying variable locations, as it can take HOURS, where as coding with a text editor, it would just take at most 30 seconds. That, I'll cut out, but if you do a meticulous enough side-by-side script comparison with two tabs of RPG Maker open, one for your project and the other for the Demo, you'll get it right, eventualy...

Anyway, here's what I did

initialize game
dimension = the size of the square grid (I wanted 11x11, so I went with 11)
dimension-1 = dimension - 1, duh
tileStart = the location where the array of tile00 variables begins
tileEnd = the location where the array of tile00 variables ends
tempStart = tileEnd + 1 (you can skip this, if you want to set the location of the temp00 array further away from the tile00 array)
tileTempDif = tempStart - tileStart
horizontalBorder = (tileStart + dimension-1) % dimension
THIS LAST VARIABLE IS WHAT SAVED ME
Out of pure coincidence, the starting locations of the tile00 array in the Demo and on my project, were n hundred + 1. Now, further ahead on the script, there are several instances where, originally, the program would check for the current tile index % 10 to check the right neighbor, and do the same for the current index-1 for the left neighbor. If the result was 0, then that meant that it was located on either of the horizontal borders of the grid. On a 10x10 grid, this worked, because every row would start at XX1 and end at an XX0 number, and any number ending with 0.
When made to work with any other dimension, however (in this case, 11), each row would end at (a multiple of the dimension) + 1, since it is offset by 1 because of the location. If you set up that little equation at the start, then the problem I had, will be solved.

'build Dijkstra map' and 'cheapest neighbour' events
Every loop that checks if the counter variable has hit a number beyond the end of the tile00 array, has to be modified so that it checks the tileEnd variable.

Keep a lookout for any instance where there is a 10 involved, and change it for the dimension variable.

When the script checks if the left or right neighbor tiles are beyond the map (in other words, when it checks for a something % 10 = 0, change the 0 for the horizontalBorder variable.

And that's all I did.
I hope I'm not missing anything.
Pages: 1