Ok.. i am running into a block and I cannot think of an easy way to get around it.
I am trying to re-write the movement section of GTBS to use tile movement restrictions. By this I mean that this tile may be -2 move and the next -1 and hence forth. So here is a situation.
You have an actor on a log, and they want to get to this other log just a stones throw away. The problem is that in order to cross to that log easily they must walk around, or go through the bushes separating them. So with this in mind.
The actor is the X... they are trying to get to the first 1 listed on the top row. To get there they could go through the 4(requiring 5 move) or around it(requiring 4 move). I want it to find the fastest route. The current path finding forces it to pass through the 4 tile while if they walked around it would require less overall move.
The code that is currently figuring this stuff out is this...
The above script allows it to find the fastest route to a tile, but doesnt consider the amount of move it requires to get there, other than it is less that the actors move amount. I would like this to also figure if it was the fastest way to get there, and thus uses the least move required.
Anyone want to help offer their skills? I was thinking of using the terrain_tag to figure this out. I am already using the terrain tag as part of def passable? for flying characters and other special abilities. Any help would be appreciated.
I am trying to re-write the movement section of GTBS to use tile movement restrictions. By this I mean that this tile may be -2 move and the next -1 and hence forth. So here is a situation.
You have an actor on a log, and they want to get to this other log just a stones throw away. The problem is that in order to cross to that log easily they must walk around, or go through the bushes separating them. So with this in mind.
Code:
1=Require 1 move to enter tile
2=Requires 2 move to enter tile
3=Requires 3 move to enter tile
4...
5...
-MAP -
1 1
4 1
X 1
The code that is currently figuring this stuff out is this...
Code:
case range_max
when 0
positions.push([actor.x, actor.y])
else
positions.push([actor.x, actor.y])
route = [[]]
more_step = [0]
for i in more_step
x = positions[i][0]
y = positions[i][1]
if !positions.include?([x, y + 1]) and actor.passable?(x, y, 2)
positions.push([x, y + 1])
route.push(route[i] + [2])
if route[i].size + 1 < range_max
more_step.push(route.index(route[i] + [2]))
end
end
if !positions.include?([x - 1, y]) and actor.passable?(x, y, 4)
positions.push([x - 1, y])
route.push(route[i] + [4])
if route[i].size + 1 < range_max
more_step.push(route.index(route[i] + [4]))
end
end
if !positions.include?([x + 1, y]) and actor.passable?(x, y, 6)
positions.push([x + 1, y])
route.push(route[i] + [6])
if route[i].size + 1 < range_max
more_step.push(route.index(route[i] + [6]))
end
end
if !positions.include?([x, y - 1]) and actor.passable?(x, y, 8)
positions.push([x, y - 1])
route.push(route[i] + [8])
if route[i].size + 1 < range_max
more_step.push(route.index(route[i] + [8]))
end
end
end
end
need_del = []
for pos in positions
if occupied?(pos[0], pos[1])
r = route[positions.index(pos)]
need_del.push([pos, r])
end
end
if need_del.size > 0
loop do
p = need_del[0][0]
r = need_del[0][1]
route.delete(r)
positions.delete(p)
need_del.delete([p,r])
if need_del.size == 0
break
end
end
end
@route = route
The above script allows it to find the fastest route to a tile, but doesnt consider the amount of move it requires to get there, other than it is less that the actors move amount. I would like this to also figure if it was the fastest way to get there, and thus uses the least move required.
Anyone want to help offer their skills? I was thinking of using the terrain_tag to figure this out. I am already using the terrain tag as part of def passable? for flying characters and other special abilities. Any help would be appreciated.