Heya!
I'm still not really getting it how I should add a function to the turn-based Board Game I'm making. It's a very geometrical issue I suppose.
I've got a board game playfield in the map. I indexed it (a littlebit funky) but it looks like the picture I added as an attachment. The fields inside with '...' are part of the playfield. The black parts aren't.
Currently I'm already too far to re-index the gamefield to, per example, flip the y so that it actually goes upwards. However... This shouldn't matter much for the outcome of this code.
The thing I'm having issues with is creating movement on the board while checking pathability after every step. I created something that marks the squares as 'pathable' around the unit based on his range. So let's say he can make 2 steps, the 4+8 squares around him will lighten up. However, if an enemy unit is standing in the way, I so far only could mark that single square as unpathable instead of the ones behind it aswell.
To make sure you get me I added 2 example pictures.
One of them shows the result of what I've got right now.
The other one shows what I really want.
(Yellow area is the unit that's going to move. Green areas are fields that are pathable. Red Areas are fields that are not pathable. The brown one's are out of range.)
So far some people have tried to help me, but they've shortly told me what to do and I barely understood what they were talking about. I was wondering if there's anyone that would like to make this for me, or patiently help me while I give it another shot.
Here's what I got right now (the code with the wrong result):
PS:
I was planning to start all over on this part of the code. So don't feel as if I want to keep what I got right now and edit it.
I think I have to go with a new approach anyway.
I'm still not really getting it how I should add a function to the turn-based Board Game I'm making. It's a very geometrical issue I suppose.
I've got a board game playfield in the map. I indexed it (a littlebit funky) but it looks like the picture I added as an attachment. The fields inside with '...' are part of the playfield. The black parts aren't.
Currently I'm already too far to re-index the gamefield to, per example, flip the y so that it actually goes upwards. However... This shouldn't matter much for the outcome of this code.
The thing I'm having issues with is creating movement on the board while checking pathability after every step. I created something that marks the squares as 'pathable' around the unit based on his range. So let's say he can make 2 steps, the 4+8 squares around him will lighten up. However, if an enemy unit is standing in the way, I so far only could mark that single square as unpathable instead of the ones behind it aswell.
To make sure you get me I added 2 example pictures.
One of them shows the result of what I've got right now.
The other one shows what I really want.
(Yellow area is the unit that's going to move. Green areas are fields that are pathable. Red Areas are fields that are not pathable. The brown one's are out of range.)
So far some people have tried to help me, but they've shortly told me what to do and I barely understood what they were talking about. I was wondering if there's anyone that would like to make this for me, or patiently help me while I give it another shot.
Here's what I got right now (the code with the wrong result):
JASS:
local integer X = Unit_X[GetUnitId(u)] ///This is the Field X value of the unit. It's something between 1 and 9
local integer Y = Unit_Y[GetUnitId(u)] ///This is the Field Y value of the unit. It's something between 0 and 17
local integer x = 0
local integer y = 0
local integer STEPS = RANGE ///So if the unit can max. move 2 steps this will be set to 2
loop
exitwhen x > RANGE
loop
exitwhen y > (RANGE - x)
if Field_Path[X+x][Y+y] == 0 then ///Field_Path checks how many units are on the selected field. 0 means its pathable unitwise
if IsRegAbleToMove(u, X+x, Y+y) then ///This one is not important now. (Checks if the field is water or cliff and checks if moving unit can climb or swim)
set Field_Pathable[X+x][Y+y] = true ///This turns the field to green
endif
endif
if Field_Path[X-x][Y+y] == 0 then
if IsRegAbleToMove(u, X-x, Y+y) then
set Field_Pathable[X-x][Y+y] = true
endif
endif
if Field_Path[X+x][Y-y] == 0 then
if IsRegAbleToMove(u, X+x, Y-y) then
set Field_Pathable[X+x][Y-y] = true
endif
endif
if Field_Path[X-x][Y-y] == 0 then
if IsRegAbleToMove(u, X-x, Y-y) then
set Field_Pathable[X-x][Y-y] = true
endif
endif
set y = y +1
set STEPS = STEPS - 1
endloop
set STEPS = RANGE - x
set y = 0
set x = x + 1
set STEPS = STEPS - 1
endloop
PS:
I was planning to start all over on this part of the code. So don't feel as if I want to keep what I got right now and edit it.
I think I have to go with a new approach anyway.