本帖最后由 taroxd 于 2015-2-3 19:15 编辑
思路是这样,未测试
class Game_Interpreter def region_count(region_id, distance) x = $game_player.x y = $game_player.y (-distance..distance).inject(0) do |result, dx| dy_max = distance - dx.abs (-dy_max..dy_max).count { |dy| $game_map.region_id(x + dx, y + dy) == region_id } + result end end end
class Game_Interpreter
def region_count(region_id, distance)
x = $game_player.x
y = $game_player.y
(-distance..distance).inject(0) do |result, dx|
dy_max = distance - dx.abs
(-dy_max..dy_max).count { |dy|
$game_map.region_id(x + dx, y + dy) == region_id
} + result
end
end
end
在 变量操作 - 脚本 中输入 region_count(区域ID, 距离) 即可获取
再说一遍,未测试- - 结果不对不要怪我- - |