for i in more_step
x = @position[0]
y = @position[1]
@move = @position[2]
# 下
if @battler.passable?(x, y, 2) and !(@move < battler.need_mov[$game_map.terrain_tag(x,y + 1)])
@move1 = @move - battler.need_mov[$game_map.terrain_tag(x,y + 1)]
@position.push([x, y + 1,@move1])
@position0.push([x, y + 1]) if [email protected]?([x, y + 1])
@route.push(@route + [2])
more_step.push(@route.index(@route + [2]))
end
if @battler.passable?(x, y, 4) and !(@move < battler.need_mov[$game_map.terrain_tag(x - 1,y)])
@move2 = @move - battler.need_mov[$game_map.terrain_tag(x - 1,y)]
@position.push([x - 1, y, @move2])
@position0.push([x - 1, y]) if [email protected]?([x - 1, y])
@route.push(@route + [4])
more_step.push(@route.index(@route + [4]))
end
if @battler.passable?(x, y, 6) and !(@move < battler.need_mov[$game_map.terrain_tag(x + 1,y)])
@move3 = @move - battler.need_mov[$game_map.terrain_tag(x + 1,y)]
@position.push([x + 1, y, @move3])
@position0.push([x + 1, y]) if [email protected]?([x + 1, y])
@route.push(@route + [6])
more_step.push(@route.index(@route + [6]))
end
if @battler.passable?(x, y, 8) and !(@move < battler.need_mov[$game_map.terrain_tag(x,y - 1)])
@move4 = @move - battler.need_mov[$game_map.terrain_tag(x,y - 1)]
@position.push([x, y - 1,@move4])
@position0.push([x, y - 1]) if [email protected]?([x, y - 1])
@route.push(@route + [8])
more_step.push(@route.index(@route + [8]))
end
end
for i in [email protected]
x0 = @position0[0]
y0 = @position0[1]
area = Sprite_Area.new(@spriteset.viewport1, x0, y0)
@spriteset.area_sprites.push(area)
end
for i in more_step
x = @areas[0]
y = @areas[1]
@move = @areas[2]
if @battler.passable?(x, y, 2) and
(@move - battler.need_mov[$game_map.terrain_tag(x,y + 1)]) > @position[x,y + 1]
@move2 = @move - battler.need_mov[$game_map.terrain_tag(x,y + 1)]
@areas.push([x,y + 1,@move2])
@position[x,y + 1] = @move2 - 1
@route.push(@route + [2])
more_step.push(@route.index(@route + [2]))
end
if @battler.passable?(x, y, 4) and
(@move - battler.need_mov[$game_map.terrain_tag(x - 1,y)]) > @position[x - 1,y]
@move4 = @move - battler.need_mov[$game_map.terrain_tag(x - 1,y)]
@areas.push([x - 1,y,@move4])
@position[x - 1,y] = @move4 - 1
@route.push(@route + [4])
more_step.push(@route.index(@route + [4]))
end
if @battler.passable?(x, y, 6) and
(@move - battler.need_mov[$game_map.terrain_tag(x + 1,y)]) > @position[x + 1,y]
@move4 = @move - battler.need_mov[$game_map.terrain_tag(x + 1,y)]
@areas.push([x + 1,y,@move4])
@position[x + 1,y] = @move4 - 1
@route.push(@route + [6])
more_step.push(@route.index(@route + [6]))
end
if @battler.passable?(x, y, 8) and
(@move - battler.need_mov[$game_map.terrain_tag(x,y - 1)]) > @position[x,y - 1]
@move2 = @move - battler.need_mov[$game_map.terrain_tag(x,y - 1)]
@areas.push([x,y - 1,@move2])
@position[x,y - 1] = @move2 - 1
@route.push(@route + [8])
more_step.push(@route.index(@route + [8]))
end
end
@areas2 = []
for j in @areas
a = j[0]
b = j[1]
c = [[a,b]]
@areas2 = @areas2 | c
end
for area in @areas2
x = area[0]
y = area[1]
@area = Sprite_Area.new(@spriteset.viewport1, x, y)
@spriteset.area_sprites.push(@area)
end作者: 禾西 时间: 2008-5-15 07:25
稍微放出個工程給禾西一同測試吧。對於這個稍微有點興趣。
發現眞正的問題所在....
[LINE]1,#dddddd[/LINE]
def passable?(x, y, d)
# 求得新的坐标
new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
# 坐标在地图外的情况下
unless $game_map.valid?(new_x, new_y)
# 不能通行
return false
end
# 调试模式为 ON 并且 按下 CTRL 键的情况下
if $DEBUG and Input.press?(Input::CTRL)
# 可以通行
return true
end
super
end
def passable?(x, y, d)
# 求得新的坐标
new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
# 坐标在地图以外的情况
unless $game_map.valid?(new_x, new_y)
# 不能通行
return false
end
# 穿透是 ON 的情况下
if @through
# 可以通行
return true
end
# 移动者的元件无法来到指定方向的情况下
unless $game_map.passable?(x, y, d, self)
# 通行不可
return false
end
# 从指定方向不能进入到移动处的元件的情况下
unless $game_map.passable?(new_x, new_y, 10 - d)
# 不能通行
return false
end
# 循环全部事件
for event in $game_map.events.values
# 事件坐标于移动目标坐标一致的情况下
if event.x == new_x and event.y == new_y
# 穿透为 ON
unless event.through
# 自己就是事件的情况下
if self != $game_player
# 不能通行
return false
end
# 自己是主角、对方的图形是角色的情况下
if event.character_name != ""
# 不能通行
return false
end
end
end
end
# 主角的坐标与移动目标坐标一致的情况下
if $game_player.x == new_x and $game_player.y == new_y
# 穿透为 ON
unless $game_player.through
# 自己的图形是角色的情况下
if @character_name != ""
# 不能通行
return false
end
end
end
# 可以通行
return true
end作者: aiyuzui 时间: 2008-5-16 05:53
不是这个原因
实际上,我根据FE系统,把所有的脚本都重新写过了,所有与FE无关的函数全都删除了
现在的通行判断,只判断地图范围。图块没有通行判定,只要把经过消耗的移动力设为很高就是了
def passable?(x, y, d)
new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
unless $game_map.valid?(new_x, new_y)
return false
end
return true
end
@move_ability_remain = Table.new($game_map.data.xsize,$game_map.data.ysize)
@move_ability_remain[@battler.x, @battler.y] = battler.mov
@movable_flag = Table.new($game_map.data.xsize,$game_map.data.ysize)
for a in 0..battler.mov
for b in 0..battler.mov
for x in [@battler.x + a,@battler.x - a]
for y in [@battler.y + b,@battler.y - b]
if a + b <= battler.mov and @move_ability_remain[x, y] != nil and @move_ability_remain[x, y] > 0
@move = @move_ability_remain[x,y]
if @move >= battler.need_mov[$game_map.terrain_tag(x + 1,y)] and @battler.passable?(x, y, 6)
@move_ability_remain[x + 1, y] = @move - battler.need_mov[$game_map.terrain_tag(x + 1,y)]
@movable_flag[x + 1, y] = 1
end
if @move >= battler.need_mov[$game_map.terrain_tag(x - 1,y)] and @battler.passable?(x, y, 4)
@move_ability_remain[x - 1, y] = @move - battler.need_mov[$game_map.terrain_tag(x - 1,y)]
@movable_flag[x - 1, y] = 1
end
if @move >= battler.need_mov[$game_map.terrain_tag(x,y + 1)] and @battler.passable?(x, y, 2)
@move_ability_remain[x, y + 1] = @move - battler.need_mov[$game_map.terrain_tag(x,y + 1)]
@movable_flag[x, y + 1] = 1
end
if @move >= battler.need_mov[$game_map.terrain_tag(x,y - 1)] and @battler.passable?(x, y, 8)
@move_ability_remain[x, y - 1] = @move - battler.need_mov[$game_map.terrain_tag(x,y - 1)]
@movable_flag[x, y - 1] = 1
end
end
end
end
end
end
for i in 0..@movable_flag.xsize
for j in 0..@movable_flag.ysize
if @movable_flag[i,j] == 1
@area = Sprite_Area.new(@spriteset.viewport1, i, j)
@spriteset.area_sprites.push(@area)
end
end
end
延迟为0。。。orz