module SLG_Module
Node = Struct.new(:x,:y,:mp)
def self.get_movable_area(event,maxp)
cutflag=0
offx = [-1, 0, 1, 0]
offy = [0, 1, 0, -1]
pMap = Table.new($game_map.width,$game_map.height)
temp = Node.new(event.x,event.y,maxp)
rets = []
retable = Table.new($game_map.width,$game_map.height)
retable[temp.x,temp.y] = 1
allpath = [temp.clone]
while cutflag<allpath.size
n=allpath.size
i = cutflag
while i < allpath.size
for j in 0...4
temp.x=allpath[i].x+offx[j]
temp.y=allpath[i].y+offy[j]
temp.mp=allpath[i].mp-1
next if temp.mp<0
next unless event.passable?(temp.x,temp.y,0)
next if pMap[temp.x,temp.y]>0
allpath << temp.clone
rets << Point.new(temp.x,temp.y)
retable[temp.x,temp.y] = 1
end
pMap[allpath[i].x,allpath[i].y] = 1
i+=1
end
cutflag=n
end
bit = SLG_Area.new
bit.set_data(rets)
return [bit,retable]
end
end
module SLG_Module
Node = Struct.new(:x,:y,:mp)
def self.get_movable_area(event,maxp)
cutflag=0
offx = [-1, 0, 1, 0]
offy = [0, 1, 0, -1]
pMap = Table.new($game_map.width,$game_map.height)
temp = Node.new(event.x,event.y,maxp)
rets = []
retable = Table.new($game_map.width,$game_map.height)
retable[temp.x,temp.y] = 1
allpath = [temp.clone]
while cutflag<allpath.size
n=allpath.size
i = cutflag
while i < allpath.size
for j in 0...4
temp.x=allpath[i].x+offx[j]
temp.y=allpath[i].y+offy[j]
temp.mp=allpath[i].mp-1
next if temp.mp<0
next unless event.passable?(temp.x,temp.y,0)
next if pMap[temp.x,temp.y]>0
allpath << temp.clone
rets << Point.new(temp.x,temp.y)
retable[temp.x,temp.y] = 1
end
pMap[allpath[i].x,allpath[i].y] = 1
i+=1
end
cutflag=n
end
bit = SLG_Area.new
bit.set_data(rets)
return [bit,retable]
end
end