赞 | 204 |
VIP | 13 |
好人卡 | 7 |
积分 | 122 |
经验 | 52899 |
最后登录 | 2021-6-29 |
在线时间 | 4435 小时 |
Lv4.逐梦者
- 梦石
- 0
- 星屑
- 12157
- 在线时间
- 4435 小时
- 注册时间
- 2014-4-11
- 帖子
- 5955
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
AUTO_MAP_SAVE = true依旧没效果啊。还是没有保存ID9999的地图。已经厌烦了画地图了,这要是能使用,可以节省很多时间。
# # 随机地图生成脚本 v0.80 by tonbi # # 汉化修改 66RPG bbschat(2006.1.2) # # 随机地图自动生成脚本。 # # ●使用方法 # # 首先,设定随机地图名称 # # 地图名称请按照「XXXXX,随机,YYY,ZZZ」的样式来命名。 # XXXXX 地图名,随便起自己喜欢的名字。 # YYY 随机类型编号,参考样例。 # ZZZ 障碍物数量,参考样例。 # # 接下来,参考样例在地图上按照一定的规则画上地图元件 # 画的时候注意一下层。参考样例把地图元件画在对应的层上。 # # 最后设定以下事件 # # 中继点设定方法: # 事件名称为「XXXXX,中继点」或事件执行内容的第一行加上「◆注释 : 中继点」。 # # 随机地图将按照中继点事件产生随机道路,并按照事件ID顺序依次通过数个中继点 # (当然肯定不是直线通过) # 一般请在地图的两端设定中继点事件。 # 两个中继点之间请保留适当空间,少于5个地图元件的话就没有墙壁了。 # 不过就算没有中继点,也能生成随机地图。 # 增加中继点会减少墙壁的数量,所以不要太多,有几个中继点就可以了。 # 通常按照三角形的方位来设置3个中继点。 # # 中继点以外的事件如果没有特别指定将随机放置在地图的道路上。 # # 固定事件设定方法: # 事件名称为「XXXXX,固定」或事件执行内容的第一行加上「◆注释 : 固定」。 # # 该事件将被放置在离该事件位置最近的道路上。 # # 完全固定事件设定方法: # 事件名称为「XXXXX,完全固定」或事件执行内容的第一行加上「◆注释 : 完全固定」 # # 该事件位置将保持不变。 # 自动执行和并行处理的事件或者希望放在地图边缘方便查找的事件可以使用完全固定。 # # 墙壁事件设定方法: # 事件执行内容的第一行为「◆注释 : 壁设置」 # 该事件将随机出现在地图的墙壁上。 # 门,火把之类的事件专用。注释形式类似「壁设置,1」这样,后面要跟一个数字, # 数字为了保证可以添加类似于[横幅]这样的事件。(横幅1元件为0,3个元件为1。) # 这样的话就可以使用一些较大的事件了。 # # 墙壁固定事件设定方法: # 事件页第一行为「◆注释 : 壁设置固定」 # 这是同时具有上述固定事件和墙壁事件两个性质的事件。 # 也就是放置在离该事件位置最近的墙壁上的事件。 # 如果使用「壁设置固定,1」这种形式,也可以使用较大的事件。 # # 还有使用之前请按照自己的需要设定下面的参数。 #======================================================================== #======================================================================== #★Clipping距离指定(搞不懂什么意思的话就不要改。) class Game_Character DRAWRANGEX = 1920 # 地图角色的Sprite更新距离 DRAWRANGEY = 1664 # 使用较大CharChip?时请适当增加。 # 指定的是X:15 Y:13乘128的数值。 # 上面是X坐标(横)下面是Y坐标(纵)。 end #======================================================================== #======================================================================== #★是否保存。(并不准备使用随机地图、只是为了节约制作时间。) # 保存下来的地图可以复制到其他地方以节省制作时间。 class Game_Map AUTO_MAP_SAVE = true # 是否保存为地图ID:999。 # true 保存 false 不保存 # 游戏做完发布后请设定为false。 end #------------------------------------------------------------------- # ●Game_Temp #-------------------------------------------------------------------- class Game_Temp alias initialize_tonbi1 initialize def initialize initialize_tonbi1 $onscreen = [] # Sprite是否画面内标志 end end #-------------------------------------------------------------------------- # ● Game_Character #-------------------------------------------------------------------------- class Game_Character #-------------------------------------------------------------------------- # ● 更新 #-------------------------------------------------------------------------- alias update_tonbi1 update def update # 画面上的位置 sx = @real_x - $game_map.display_x - 1280 sy = @real_y - $game_map.display_y - 960 # 画面位置的绝对值 abs_sx = sx > 0 ? sx : -sx abs_sy = sy > 0 ? sy-3 : -sy # 纵横坐标超出 DRAWRANGE 元件的情况下 if abs_sx > DRAWRANGEX or abs_sy > DRAWRANGEY # Sprite不更新 $onscreen[@id]=false else # Sprite更新 $onscreen[@id]=true end update_tonbi1 end end class Spriteset_Map #-------------------------------------------------------------------------- # ● 初始化对像 #-------------------------------------------------------------------------- attr_accessor :character_sprites def initialize $onscreen = [] # 生成显示端口 @viewport1 = Viewport.new(0, 0, 640, 480) @viewport2 = Viewport.new(0, 0, 640, 480) @viewport3 = Viewport.new(0, 0, 640, 480) @viewport2.z = 200 @viewport3.z = 5000 # 生成元件地图 @tilemap = Tilemap.new(@viewport1) @tilemap.tileset = RPG::Cache.tileset($game_map.tileset_name) for i in 0..6 autotile_name = $game_map.autotile_names[i] @tilemap.autotiles[i] = RPG::Cache.autotile(autotile_name) end @tilemap.map_data = $game_map.data @tilemap.priorities = $game_map.priorities # 生成远景平面 @panorama = Plane.new(@viewport1) @panorama.z = -1000 # 生成雾平面 @fog = Plane.new(@viewport1) @fog.z = 3000 #########################################################★改变 # 角色活动块 # 将Party和Event区分开。 @character_sprites = [] @party_sprites = [] for i in $game_map.events.keys.sort sprite = Sprite_Character.new(@viewport1, $game_map.events[i]) @character_sprites[i]=sprite $onscreen[i] = true end @party_sprites.push(Sprite_Character.new(@viewport1, $game_player)) ######################################################### # 生成天气 @weather = RPG::Weather.new(@viewport1) # 生成图片 @picture_sprites = [] for i in 1..50 @picture_sprites.push(Sprite_Picture.new(@viewport2, $game_screen.pictures[i])) end # 生成计时器块 @timer_sprite = Sprite_Timer.new # 刷新画面 update end #-------------------------------------------------------------------------- # ● 释放 #-------------------------------------------------------------------------- def dispose # 释放元件地图 @tilemap.tileset.dispose for i in 0..6 @tilemap.autotiles[i].dispose end @tilemap.dispose # 释放远景平面 @panorama.dispose # 释放雾平面 @fog.dispose ############################################################★改变 # 释放角色活动块 # nil 的话不释放 for i in @character_sprites if i != nil i.dispose end end for i in @party_sprites if i != nil i.dispose end end ############################################################ # 释放天候 @weather.dispose # 释放图片 for sprite in @picture_sprites sprite.dispose end # 释放计时器块 @timer_sprite.dispose # 释放显示端口 @viewport1.dispose @viewport2.dispose @viewport3.dispose end #-------------------------------------------------------------------------- # ● 刷新画面 #-------------------------------------------------------------------------- def update # 远景与现在的情况有差异发情况下 if @panorama_name != $game_map.panorama_name or @panorama_hue != $game_map.panorama_hue @panorama_name = $game_map.panorama_name @panorama_hue = $game_map.panorama_hue if @panorama.bitmap != nil @panorama.bitmap.dispose @panorama.bitmap = nil end if @panorama_name != "" @panorama.bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue) end Graphics.frame_reset end # 雾与现在的情况有差异的情况下 if @fog_name != $game_map.fog_name or @fog_hue != $game_map.fog_hue @fog_name = $game_map.fog_name @fog_hue = $game_map.fog_hue if @fog.bitmap != nil @fog.bitmap.dispose @fog.bitmap = nil end if @fog_name != "" @fog.bitmap = RPG::Cache.fog(@fog_name, @fog_hue) end Graphics.frame_reset end # 刷新元件地图 @tilemap.ox = $game_map.display_x / 4 @tilemap.oy = $game_map.display_y / 4 @tilemap.update # 刷新远景平面 @panorama.ox = $game_map.display_x / 8 @panorama.oy = $game_map.display_y / 8 # 刷新雾平面 @fog.zoom_x = $game_map.fog_zoom / 100.0 @fog.zoom_y = $game_map.fog_zoom / 100.0 @fog.opacity = $game_map.fog_opacity @fog.blend_type = $game_map.fog_blend_type @fog.ox = $game_map.display_x / 4 + $game_map.fog_ox @fog.oy = $game_map.display_y / 4 + $game_map.fog_oy @fog.tone = $game_map.fog_tone #####################################################★改变 # 刷新角色活动块 # 画面外的角色活动块不更新 for i in $game_map.events.keys if $onscreen[i] @character_sprites[i].update end end # 玩家角色更新 for i in @party_sprites i.update end ##################################################### # 刷新天候图形 @weather.type = $game_screen.weather_type @weather.max = $game_screen.weather_max @weather.ox = $game_map.display_x / 4 @weather.oy = $game_map.display_y / 4 @weather.update # 刷新图片 for sprite in @picture_sprites sprite.update end # 刷新计时器块 @timer_sprite.update # 设置画面的色调与震动位置 @viewport1.tone = $game_screen.tone @viewport1.ox = $game_screen.shake # 设置画面的闪烁色 @viewport3.color = $game_screen.flash_color # 刷新显示端口 @viewport1.update @viewport3.update end end #============================================================================== # ■ Game_Map #============================================================================== class Game_Map #-------------------------------------------------------------------------- # ● 设置 # map_id : 地图 ID #-------------------------------------------------------------------------- def setup(map_id) # 地图 ID 记录到 @map_id @map_id = map_id # 地图文件装载后、设置到 @map @map = load_data(sprintf("Data/Map%03d.rxdata", @map_id)) # 定义实例变量设置地图元件信息 tileset = $data_tilesets[@map.tileset_id] @tileset_name = tileset.tileset_name @autotile_names = tileset.autotile_names @panorama_name = tileset.panorama_name @panorama_hue = tileset.panorama_hue @fog_name = tileset.fog_name @fog_hue = tileset.fog_hue @fog_opacity = tileset.fog_opacity @fog_blend_type = tileset.fog_blend_type @fog_zoom = tileset.fog_zoom @fog_sx = tileset.fog_sx @fog_sy = tileset.fog_sy @battleback_name = tileset.battleback_name @passages = tileset.passages @priorities = tileset.priorities @terrain_tags = tileset.terrain_tags # 初始化显示坐标 @display_x = 0 @display_y = 0 check_special_map #★检查随机地图 # 清除刷新要求标志 @need_refresh = false # 设置地图事件数据 @events = {} for i in @map.events.keys @events[i] = Game_Event.new(@map_id, @map.events[i]) end # 设置公共事件数据 @common_events = {} for i in 1...$data_common_events.size @common_events[i] = Game_CommonEvent.new(i) end # 初始化雾的各种信息 @fog_ox = 0 @fog_oy = 0 @fog_tone = Tone.new(0, 0, 0, 0) @fog_tone_target = Tone.new(0, 0, 0, 0) @fog_tone_duration = 0 @fog_opacity_duration = 0 @fog_opacity_target = 0 # 初始化滚动信息 @scroll_direction = 2 @scroll_rest = 0 @scroll_speed = 4 end #-------------------------------------------------------------------------- # ● 紧接读入地图之后的处理 #-------------------------------------------------------------------------- def check_special_map # 取得地图名称 mapinfo = load_data("Data/MapInfos.rxdata") # 地图名称包含“随机”的场合 if mapinfo[@map_id].subname == "随机" if mapinfo[@map_id].subname(3)=="" or mapinfo[@map_id].subname(3) == nil p3 = 0 else p3 = mapinfo[@map_id].subname(3).to_i end if mapinfo[@map_id].subname(4)=="false" p4 = false end make_random_map(2,mapinfo[@map_id].subname(2).to_i,p3,p4) end end #-------------------------------------------------------------------------- # ● 生成随机地图 # wall = 墙壁的高 >> 现在无效 # type = 墙壁制作类型 >> 0以外没制作(汗 指定方法也未定) (<-- bbschat注:汗~原来日本人也会用汗) # thoughplayer = 玩家在中继点中包含吗? # connect = 中继点的连接方法 >> true=连续 false=2个各自独立 # # ※所有参数全部省略 可以使用下面的例子 # ex. make_random_map(2,0,,true) #-------------------------------------------------------------------------- def make_random_map(wall = 2, type = 0, objcnt = 0, connect = true) # 非法参数处理 wall = 0 if wall == nil type = 0 if type == nil objcnt = 0 if objcnt == nil unless objcnt.is_a?(Numeric) objcnt = 0 end if objcnt < 0 objcnt = 0 end connect = true if connect != false # 高度数据表 @heightdata = Table.new(@map.width,@map.height) # 地形数据表 @maskdata = Table.new(@map.width,@map.height) # 事件数据表 @oneventdata = Table.new(@map.width,@map.height) # 遮照设定数组 @masksetting = [] # 制作方法数组 @makedata = [] # 演算方法初始化 @targettype=0 @chgtype=0 time = -1 # 数据初始化 for i in [email]0...@map.width[/email] for j in [email]0...@map.height[/email] time += 1 if time%2000 == 0 Graphics.update end @heightdata[i,j] = 0 @maskdata[i,j] = 0 end end for i in 0...100 @masksetting[i] = true end # 取得中继点情报 needposx = [] needposy = [] # 增加中继点事件 for i in @map.events.keys.sort time += 1 if time%200 == 0 Graphics.update end if event_settype(i) == 1 if connect == true needposx.push(@map.events[i].x) needposy.push(@map.events[i].y) needposx.push(@map.events[i].x) needposy.push(@map.events[i].y) else needposx.push(@map.events[i].x) needposy.push(@map.events[i].y) end end end if connect == true needposx.shift needposy.shift end loop do if needposx.size <= 2 needposx.push(rand(@map.width)) needposy.push(rand(@map.height)) else break end end # 这里设定制作方法数组 case type when 0 # 类型0 >> 2层自然类型 @makedata.push([0,1,0]) @makedata.push([5,1]) for i in 0...(needposx.size/2) @makedata.push([1,needposx[i*2],needposy[i*2],needposx[i*2+1],needposy[i*2+1]]) @makedata.push([3,0,-15,4,0]) @makedata.push([1,1,1,1,1]) @makedata.push([6,0,needposx[i*2],needposy[i*2]]) @makedata.push([6,0,needposx[i*2+1],needposy[i*2+1]]) end @makedata.push([4,0,1,1,1]) @makedata.push([4,0,1,1,1]) @makedata.push([4,1,1,1,1]) @makedata.push([0,0,0]) @makedata.push([2,0,2]) @makedata.push([5,0]) @makedata.push([2,1,2]) @makedata.push([5,1]) when 1 # 类型1 >> 2层人工类型 @makedata.push([0,1,0]) @makedata.push([5,1]) for i in 0...(needposx.size/2) @makedata.push([1,needposx[i*2],needposy[i*2],needposx[i*2+1],needposy[i*2+1]]) @makedata.push([3,0,-6,4,1,10]) @makedata.push([1,1,1,1,1]) @makedata.push([6,0,needposx[i*2],needposy[i*2]]) @makedata.push([6,0,needposx[i*2+1],needposy[i*2+1]]) end @makedata.push([4,0,2,3,1]) @makedata.push([4,1,2,2,1]) @makedata.push([4,0,1,1,1]) @makedata.push([0,0,0]) @makedata.push([2,0,2]) @makedata.push([5,0]) @makedata.push([2,1,2]) @makedata.push([5,1]) when 2 # 类型2 >> 2层自然凸类型 @makedata.push([0,1,0]) @makedata.push([5,1]) for i in 0...(needposx.size/2) @makedata.push([1,needposx[i*2],needposy[i*2],needposx[i*2+1],needposy[i*2+1]]) @makedata.push([3,0,-15,4,0]) @makedata.push([1,1,1,1,1]) @makedata.push([6,0,needposx[i*2],needposy[i*2]]) @makedata.push([6,0,needposx[i*2+1],needposy[i*2+1]]) end @makedata.push([4,0,2,2,1]) @makedata.push([4,1,1,1,1]) @makedata.push([0,0,0]) @makedata.push([2,0,2]) @makedata.push([5,0]) @makedata.push([2,1,2]) @makedata.push([5,-1]) when 3 # 类型3 >> 2层人工凸类型 @makedata.push([0,1,0]) @makedata.push([5,1]) for i in 0...(needposx.size/2) @makedata.push([1,needposx[i*2],needposy[i*2],needposx[i*2+1],needposy[i*2+1]]) @makedata.push([3,0,-15,4,1,10]) @makedata.push([1,1,1,1,1]) @makedata.push([6,0,needposx[i*2],needposy[i*2]]) @makedata.push([6,0,needposx[i*2+1],needposy[i*2+1]]) end @makedata.push([4,0,2,2,1]) @makedata.push([4,1,1,1,1]) @makedata.push([0,0,0]) @makedata.push([2,0,2]) @makedata.push([5,0]) @makedata.push([2,1,2]) @makedata.push([5,-1]) when 4 # 类型4 >> 2层自然类型 之一 # 地形[0:洞 1:地面 2:墙壁] # 基本设定 @makedata.push([0,1,0]) @makedata.push([5,0]) # 放置墙 @makedata.push([1,0,0,-1,0]) @makedata.push([3,2,-6,1,0]) @makedata.push([1,-1,0,-1,-1]) @makedata.push([3,2,-6,1,0]) @makedata.push([1,-1,-1,0,-1]) @makedata.push([3,2,-6,1,0]) @makedata.push([1,0,-1,0,0]) @makedata.push([3,2,-6,1,0]) @makedata.push([4,2,2,2,1]) # 随机放置洞 for i in 0...(rand(12*@map.width*@map.height/40/40)+(5*@map.width*@map.height/40/40)) @makedata.push([1,3,3,8,8]) @makedata.push([6,0,rand(@map.width-10)+5,rand(@map.height-10)+5]) end # 生成周围的墙 @makedata.push([7,2]) @makedata.push([4,2,1,1,1]) # 生成道路 for i in 0...(needposx.size/2) @makedata.push([1,needposx[i*2],needposy[i*2],needposx[i*2+1],needposy[i*2+1]]) @makedata.push([3,1,-8,4,0,5]) @makedata.push([1,1,1,1,1]) @makedata.push([6,1,needposx[i*2],needposy[i*2]]) @makedata.push([6,1,needposx[i*2+1],needposy[i*2+1]]) end # 扩张处理 @makedata.push([4,1,1,1,1]) @makedata.push([4,1,0,1,1]) @makedata.push([2,0,0]) @makedata.push([4,1,1,0,1]) @makedata.push([2,-1,1]) @makedata.push([4,2,1,1,1]) # 高度设定 @makedata.push([0,0,0]) @makedata.push([2,0,2]) @makedata.push([5,-1]) @makedata.push([2,1,2]) @makedata.push([5,0]) @makedata.push([2,2,2]) @makedata.push([5,1]) when 5 # 类型5 >> 2层人工类型 之一 # 地形[0:洞 1:地面 2:墙壁] # 基本设定 @makedata.push([0,1,0]) @makedata.push([5,0]) # 放置墙 @makedata.push([1,0,0,-1,0]) @makedata.push([3,2,-6,1,0]) @makedata.push([1,-1,0,-1,-1]) @makedata.push([3,2,-6,1,0]) @makedata.push([1,-1,-1,0,-1]) @makedata.push([3,2,-6,1,0]) @makedata.push([1,0,-1,0,0]) @makedata.push([3,2,-6,1,0]) @makedata.push([4,2,2,2,1]) # 随机放置洞 for i in 0...(rand(12*@map.width*@map.height/40/40)+(5*@map.width*@map.height/40/40)) @makedata.push([1,3,3,8,8]) @makedata.push([6,0,rand(@map.width-10)+5,rand(@map.height-10)+5]) end # 生成周围的墙 @makedata.push([7,2]) @makedata.push([4,2,1,1,1]) # 生成道路 for i in 0...(needposx.size/2) @makedata.push([1,needposx[i*2],needposy[i*2],needposx[i*2+1],needposy[i*2+1]]) @makedata.push([3,1,-8,4,1,5]) @makedata.push([1,1,1,1,1]) @makedata.push([6,1,needposx[i*2],needposy[i*2]]) @makedata.push([6,1,needposx[i*2+1],needposy[i*2+1]]) end # 扩张处理 @makedata.push([4,1,1,1,1]) @makedata.push([4,1,0,1,1]) @makedata.push([2,0,0]) @makedata.push([4,1,1,0,1]) @makedata.push([2,-1,1]) @makedata.push([4,2,1,1,1]) # 高度设定 @makedata.push([0,0,0]) @makedata.push([2,0,2]) @makedata.push([5,-1]) @makedata.push([2,1,2]) @makedata.push([5,0]) @makedata.push([2,2,2]) @makedata.push([5,1]) when 6 # 类型6 >> 2层自然类型 之二 # 地形[0:洞 1:地面 2:墙壁] # 基本设定 @makedata.push([0,1,0]) @makedata.push([5,0]) # 放置墙 @makedata.push([1,0,0,-1,0]) @makedata.push([3,2,-6,1,0]) @makedata.push([1,-1,0,-1,-1]) @makedata.push([3,2,-6,1,0]) @makedata.push([1,-1,-1,0,-1]) @makedata.push([3,2,-6,1,0]) @makedata.push([1,0,-1,0,0]) @makedata.push([3,2,-6,1,0]) @makedata.push([4,2,2,2,1]) # 随机放置洞 for i in 0...(rand(12*@map.width*@map.height/40/40)+(5*@map.width*@map.height/40/40)) @makedata.push([1,1,1,3,3]) @makedata.push([6,0,rand(@map.width-10)+5,rand(@map.height-10)+5]) end # 洞扩大 @makedata.push([4,0,2,2,0]) @makedata.push([4,0,1,2,1]) # 生成周围的墙 @makedata.push([7,2]) @makedata.push([4,2,1,1,1]) # 生成道路 for i in 0...(needposx.size/2) @makedata.push([1,needposx[i*2],needposy[i*2],needposx[i*2+1],needposy[i*2+1]]) @makedata.push([3,1,-15,4,0,5]) @makedata.push([1,1,1,1,1]) @makedata.push([6,1,needposx[i*2],needposy[i*2]]) @makedata.push([6,1,needposx[i*2+1],needposy[i*2+1]]) end # 扩张处理 @makedata.push([4,1,1,1,1]) @makedata.push([4,1,0,1,1]) @makedata.push([2,0,0]) @makedata.push([4,1,1,0,1]) @makedata.push([2,-1,1]) @makedata.push([4,2,1,1,1]) # 高度设定 @makedata.push([0,0,0]) @makedata.push([2,0,2]) @makedata.push([5,-1]) @makedata.push([2,1,2]) @makedata.push([5,0]) @makedata.push([2,2,2]) @makedata.push([5,1]) when 7 # 类型7 >> 2层人工类型 之二 # 地形[0:洞 1:地面 2:墙壁] # 基本设定 @makedata.push([0,1,0]) @makedata.push([5,0]) # 放置墙 @makedata.push([1,0,0,-1,0]) @makedata.push([3,2,-6,1,0]) @makedata.push([1,-1,0,-1,-1]) @makedata.push([3,2,-6,1,0]) @makedata.push([1,-1,-1,0,-1]) @makedata.push([3,2,-6,1,0]) @makedata.push([1,0,-1,0,0]) @makedata.push([3,2,-6,1,0]) @makedata.push([4,2,2,2,1]) # 随机放置洞 for i in 0...(rand(12*@map.width*@map.height/40/40)+(5*@map.width*@map.height/40/40)) @makedata.push([1,1,1,3,3]) @makedata.push([6,0,rand(@map.width-10)+5,rand(@map.height-10)+5]) end # 洞扩大 @makedata.push([4,0,2,2,0]) @makedata.push([4,0,1,2,1]) # 生成周围的墙 @makedata.push([7,2]) @makedata.push([4,2,1,1,1]) # 生成道路 for i in 0...(needposx.size/2) @makedata.push([1,needposx[i*2],needposy[i*2],needposx[i*2+1],needposy[i*2+1]]) @makedata.push([3,1,-15,4,1,5]) @makedata.push([1,1,1,1,1]) @makedata.push([6,1,needposx[i*2],needposy[i*2]]) @makedata.push([6,1,needposx[i*2+1],needposy[i*2+1]]) end # 扩张处理 @makedata.push([4,1,1,1,1]) @makedata.push([4,1,0,1,1]) @makedata.push([2,0,0]) @makedata.push([4,1,1,0,1]) @makedata.push([2,-1,1]) @makedata.push([4,2,1,1,1]) # 高度设定 @makedata.push([0,0,0]) @makedata.push([2,0,2]) @makedata.push([5,-1]) @makedata.push([2,1,2]) @makedata.push([5,0]) @makedata.push([2,2,2]) @makedata.push([5,1]) end # 实际制作 for make_stat in @makedata time += 1 if time%2 == 0 Graphics.update end case make_stat[0] when 0 # 对象变化 (p1[0=高度 1=地形], p2[0=代入 1=加算]) rndmap_chtarget(make_stat[1],make_stat[2]) when 1 # 参数设定 (minx, miny, maxz, maxy) rndmap_setstat(make_stat[1],make_stat[2],make_stat[3],make_stat[4]) when 2 # 遮照变化 (p1[-1:全部], p2[ 0=false 1=true 2=onlytrue]) rndmap_chmask(make_stat[1],make_stat[2]) when 3 # 生成道路 (值,中继点数,边缘确保,类型) rndmap_mkroad(make_stat[1],make_stat[2],make_stat[3],make_stat[4],make_stat[5]) when 4 # 扩张 (对象,纵幅,横幅,类型) rndmap_plus(make_stat[1],make_stat[2],make_stat[3],make_stat[4]) when 5 # 全变化 (值) rndmap_allchg(make_stat[1]) when 6 # 指定点 (值,位置X,位置Y) rndmap_putpos(make_stat[1],make_stat[2],make_stat[3]) when 7 # 周围 (值) rndmap_edge(make_stat[1]) end end # 取得使用地图元件 @tilesetting = Table.new(3,40,3) for i in [0,1,2] for k in 0...40 for j in [0,1,2] @tilesetting[j,k,i] = @map.data[j,k,i] end end end # 补正 time = 0 for k in [email]0...@map.height[/email] for j in [email]0...@map.width[/email] time += 1 # 定期画面更新 if time%500 == 0 Graphics.update end # 墙下的地图元件要是洞的话,地面变更 if @heightdata[j,k] == 1 if @heightdata[j,k+1]==-1 @heightdata[j,k+1] = 0 if @heightdata[j,k+2]==-1 and @heightdata[j,k+3] == 0 @heightdata[j,k+2] = 0 end end end end end # 生成地面 之一 >> 暂且全面铺上 time = 0 for k in [email]0...@map.height[/email] for j in [email]0...@map.width[/email] time += 1 # 定期画面更新 if time%500 == 0 Graphics.update end if @heightdata[j,k] == 0 if @heightdata[j,k+1] == -1 or @heightdata[j,k-1] == -1 or @heightdata[j+1,k] == -1 or @heightdata[j-1,k] == -1 set_mapdata2(j,k,0,8) else set_mapdata2(j,k,0,0) end elsif @heightdata[j,k] == 1 if @heightdata[j,k+1] == -1 or @heightdata[j,k-1] == -1 or @heightdata[j+1,k] == -1 or @heightdata[j-1,k] == -1 set_mapdata2(j,k,0,8) elsif @heightdata[j,k+1] == 0 or @heightdata[j,k-1] == 0 or @heightdata[j+1,k] == 0 or @heightdata[j-1,k] == 0 set_mapdata2(j,k,0,0) else set_mapdata2(j,k,1,4) end else set_mapdata2(j,k,0,8) end end end # 生成地面 之二 >> 生成洞 time = 0 for k in [email]0...@map.height[/email] for j in [email]0...@map.width[/email] time += 1 # 定期画面更新 if time%500 == 0 Graphics.update end if @heightdata[j,k] == 0 if @heightdata[j,k+1] == -1 # 下面是洞------------------ if @heightdata[j-1,k] == -1 # 左边也是洞 for i in [0,1,2] set_mapdata(j,k+i,0,13+i,1) end elsif @heightdata[j+1,k] == -1 # 右边也是洞 for i in [0,1,2] set_mapdata(j,k+i,2,13+i,1) end else # 两边是地面 for i in [0,1,2] set_mapdata(j,k+i,1,13+i,1) end end elsif @heightdata[j,k-1] == -1 # 上面是洞------------------ if @heightdata[j-1,k] == -1 or (@heightdata[j-1,k] == 1 and @heightdata[j-1,k-1] == -1) # 左边也是洞 set_mapdata(j,k,0,11,2) elsif @heightdata[j+1,k] == -1 or (@heightdata[j+1,k] == 1 and @heightdata[j+1,k-1] == -1) # 右边也是洞 set_mapdata(j,k,2,11,2) else # 两边是地面 set_mapdata(j,k,1,11,2) end elsif @heightdata[j-1,k] == -1 or (@heightdata[j-1,k] == 1 and @heightdata[j-1,k-1] == -1) # 左边是洞------------------ set_mapdata(j,k,0,12,1) elsif @heightdata[j+1,k] == -1 or (@heightdata[j+1,k] == 1 and @heightdata[j+1,k-1] == -1) # 右边是洞------------------ set_mapdata(j,k,2,12,1) elsif @heightdata[j-1,k-1] == -1 # 左上面是洞------------------ set_mapdata(j,k,0,9,1) elsif @heightdata[j-1,k+1] == -1 # 左下面是洞------------------ set_mapdata(j,k,0,10,1) elsif @heightdata[j+1,k-1] == -1 # 右上面是洞------------------ set_mapdata(j,k,1,9,1) elsif @heightdata[j+1,k+1] == -1 # 右下面是洞------------------ set_mapdata(j,k,1,10,1) end end if @heightdata[j,k] == 1 and @heightdata[j,k-1] != -1 if @heightdata[j,k+1] == -1 # 下面是洞------------------ if @heightdata[j-1,k] == -1 # 左边也是洞 for i in [0,1,2] # set_mapdata(j,k+i,0,13+i,1) end elsif @heightdata[j+1,k] == -1 # 右边也是洞 for i in [0,1,2] # set_mapdata(j,k+i,2,13+i,1) end else # 两边是地面 for i in [0,1,2] # set_mapdata(j,k+i,1,13+i,1) end end elsif @heightdata[j,k-1] == -1 # 上面是洞------------------ if @heightdata[j-1,k] == -1 # 左边也是洞 set_mapdata(j,k,0,11,2) elsif @heightdata[j+1,k] == -1 # 右边也是洞 set_mapdata(j,k,2,11,2) else # 两边是地面 set_mapdata(j,k,1,11,2) end elsif @heightdata[j-1,k] == -1 # 左边是洞------------------ set_mapdata(j,k,0,12,1) elsif @heightdata[j+1,k] == -1 # 右边是洞------------------ set_mapdata(j,k,2,12,1) elsif @heightdata[j-1,k-1] == -1 # 左上面是洞------------------ set_mapdata(j,k,0,9,1) elsif @heightdata[j-1,k+1] == -1 # 左下面是洞------------------ set_mapdata(j,k,0,10,1) elsif @heightdata[j+1,k-1] == -1 # 右上面是洞------------------ set_mapdata(j,k,1,9,1) elsif @heightdata[j+1,k+1] == -1 # 右下面是洞------------------ set_mapdata(j,k,1,10,1) end end end end # 生成地面 之三 >> 生成墙壁 time = 0 for k in [email]0...@map.height[/email] for j in [email]0...@map.width[/email] time += 1 # 定期画面更新 if time%500 == 0 Graphics.update end if @heightdata[j,k] == 1 if @heightdata[j,k+1] == 0 or @heightdata[j,k+1] == -1 # 下面是洞------------------ if @heightdata[j-1,k] == 0 or @heightdata[j-1,k] == -1 # 左边也是洞 set_mapdata(j,k+0,0,5+0,5) set_mapdata(j,k+1,0,5+1,5) set_mapdata(j,k+2,0,5+2,4) if @heightdata[j,k+3] != 0 and @heightdata[j,k+2] != 1 and (@heightdata[j,k+2] != 0 or @heightdata[j-1,k+2] != 0) set_mapdata(j,k+2,0,16,5) for i in [0,1] set_mapdata(j,k+3+i,0,14+i,1) if @heightdata[j,k+3+i] != -1 break end end end elsif @heightdata[j+1,k] == 0 or @heightdata[j+1,k] == -1 # 右边也是洞 set_mapdata(j,k+0,2,5+0,5) set_mapdata(j,k+1,2,5+1,5) set_mapdata(j,k+2,2,5+2,4) if @heightdata[j,k+3] != 0 and @heightdata[j,k+2] != 1 and (@heightdata[j,k+2] != 0 or @heightdata[j+1,k+2] != 0) set_mapdata(j,k+2,2,16,5) for i in [0,1] set_mapdata(j,k+3+i,2,14+i,1) if @heightdata[j,k+3+i] != -1 break end end end else # 两边是地面 set_mapdata(j,k+0,1,5+0,5) set_mapdata(j,k+1,1,5+1,5) set_mapdata(j,k+2,1,5+2,4) if @heightdata[j,k+3] != 0 and @heightdata[j,k+2] != 1 set_mapdata(j,k+2,1,16,5) for i in [0,1] set_mapdata(j,k+3+i,1,14+i,1) if @heightdata[j,k+3+i] != -1 break end end end end elsif @heightdata[j,k-1] == 0 or @heightdata[j,k-1] == -1 # 上面是洞------------------ if @heightdata[j-1,k] == 0 or @heightdata[j-1,k] == -1 # 左边也是洞 set_mapdata(j,k,0,3,4) elsif @heightdata[j+1,k] == 0 or @heightdata[j+1,k] == -1 # 右边也是洞 set_mapdata(j,k,2,3,4) else # 两边是地面 set_mapdata(j,k,1,3,4) end elsif @heightdata[j-1,k] == 0 or @heightdata[j-1,k] == -1 # 左边是洞------------------ set_mapdata(j,k,0,4,4) elsif @heightdata[j+1,k] == 0 or @heightdata[j+1,k] == -1 # 右边是洞------------------ set_mapdata(j,k,2,4,4) elsif @heightdata[j-1,k-1] == 0 or @heightdata[j-1,k-1] == -1 # 左上面是洞------------------ set_mapdata(j,k,0,1,4) elsif @heightdata[j-1,k+1] == 0 or @heightdata[j-1,k+1] == -1 # 左下面是洞------------------ set_mapdata(j,k,0,2,4) elsif @heightdata[j+1,k-1] == 0 or @heightdata[j+1,k-1] == -1 # 右上面是洞------------------ set_mapdata(j,k,1,1,4) elsif @heightdata[j+1,k+1] == 0 or @heightdata[j+1,k+1] == -1 # 右下面是洞------------------ set_mapdata(j,k,1,2,4) end end end end # 调整玩家位置 playerpos_reset($game_temp.player_new_x,$game_temp.player_new_y) @oneventdata[$game_temp.player_new_x,$game_temp.player_new_y] = 1 time = 0 for i in @map.events.keys.sort time += 1 if time%100 == 0 Graphics.update end # 事件设置类型>>完全固定(最优先) case event_settype(i) when 3 @oneventdata[@map.events[i].x,@map.events[i].y] = 1 end end for i in @map.events.keys.sort time += 1 if time%100 == 0 Graphics.update end # 事件设置类型>>中继点 case event_settype(i) when 1 set_defeventpos(i,@map.events[i].x,@map.events[i].y) @oneventdata[@map.events[i].x,@map.events[i].y] = 1 end end # 调整事件位置 for i in @map.events.keys.sort time += 1 if time%100 == 0 Graphics.update end j = event_settype(i) case j when 0 # 随机 set_defeventpos(i,rand(@map.width-4)+2,rand(@map.width-4)+2) @oneventdata[@map.events[i].x,@map.events[i].y] = 1 when 2 # 固定 set_defeventpos(i,@map.events[i].x,@map.events[i].y) @oneventdata[@map.events[i].x,@map.events[i].y] = 1 when 100..199 # 壁设置 set_defeventpos_wall(i,rand(@map.width-4)+2,rand(@map.width-4)+2,j-100) @oneventdata[@map.events[i].x,@map.events[i].y] = 1 @oneventdata[@map.events[i].x,@map.events[i].y-1] = 1 for k in 1..(j-100) @oneventdata[@map.events[i].x+k,@map.events[i].y] = 1 @oneventdata[@map.events[i].x+k,@map.events[i].y-1] = 1 @oneventdata[@map.events[i].x-k,@map.events[i].y] = 1 @oneventdata[@map.events[i].x-k,@map.events[i].y-1] = 1 end when 200..299 # 壁设置固定 set_defeventpos_wall(i,@map.events[i].x,@map.events[i].y,j-200) @oneventdata[@map.events[i].x,@map.events[i].y] = 1 @oneventdata[@map.events[i].x,@map.events[i].y-1] = 1 for k in 1..(j-200) @oneventdata[@map.events[i].x+k,@map.events[i].y] = 1 @oneventdata[@map.events[i].x+k,@map.events[i].y-1] = 1 @oneventdata[@map.events[i].x-k,@map.events[i].y] = 1 @oneventdata[@map.events[i].x-k,@map.events[i].y-1] = 1 end end end # 放置障碍 for i in 0...(rand(objcnt)+objcnt/2) time += 1 if time%500 == 0 Graphics.update end j = rand(@map.width) k = rand(@map.width) case rand(10) when 0..4 if standable_newtile?(1,0) if standable?(j,k) set_mapdata(j,k,1,0,6) end else if standable2?(j,k) set_mapdata(j,k,1,0,6) end end when 5..7 if standable_newtile?(2,0) if standable?(j,k) set_mapdata(j,k,2,0,6) end else if standable2?(j,k) set_mapdata(j,k,2,0,6) end end when 8..9 if standable2?(j,k) if @map.data[j,k-1,2]==0 and (@map.data[j,k,1]==0 or @map.data[j,k,2]==0) set_mapdata(j,k,2,2,4) # 4>6? set_mapdata(j,k-1,2,1,4) # 4>2? end end end end # 释放变量的内容 @heightdata.resize(0,0) @maskdata.resize(0,0) @oneventdata.resize(0,0) @masksetting.clear @makedata.clear @tilesetting.resize(0,0,0) if AUTO_MAP_SAVE # 保存机能 save_data(@map,sprintf("Data/Map%03d.rxdata", 999)) maplist = load_data("Data/MapInfos.rxdata") mapinfo = RPG::MapInfo.new mapinfo.name = sprintf("随机自动保存(%s)", maplist[@map_id].name) mapinfo.parent_id = 0 mapinfo.order = 999 mapinfo.expanded = true mapinfo.scroll_x = 0 mapinfo.scroll_y = 0 maplist[999]=mapinfo save_data(maplist,"Data/MapInfos.rxdata") end end #-------------------------------------------------------------------------- # ● 获得事件的位置类型 #-------------------------------------------------------------------------- def event_settype(i) if @map.events[i].subname == "中继点" return 1 end if @map.events[i].subname == "固定" return 2 end if @map.events[i].subname == "完全固定" return 3 end for j in 0..1000 if @map.events[i].pages[0].list[j].code != 108 break end # 注释中有中继点 if @map.events[i].pages[0].list[j].parameters[0].split(/,/)[0] == "中继点" return 1 end # 注释中有完全固定 if @map.events[i].pages[0].list[j].parameters[0].split(/,/)[0] == "完全固定" return 3 end # 注释中有固定 if @map.events[i].pages[0].list[j].parameters[0].split(/,/)[0] == "固定" return 2 end # 注释中有壁设置 if @map.events[i].pages[0].list[j].parameters[0].split(/,/)[0] == "壁设置" if @map.events[i].pages[0].list[j].parameters[0].split(/,/)[1] == nil return 100 else k = @map.events[i].pages[0].list[j].parameters[0].split(/,/)[1] k = k.to_i return 100+k end end # 注释中有壁设置固定 if @map.events[i].pages[0].list[j].parameters[0].split(/,/)[0] == "壁设置固定" if @map.events[i].pages[0].list[j].parameters[0].split(/,/)[1] == nil return 200 else k = @map.events[i].pages[0].list[j].parameters[0].split(/,/)[1] k = k.to_i return 200+k end end end return 0 end #-------------------------------------------------------------------------- # ● 指定位置附近设置事件 #-------------------------------------------------------------------------- def set_defeventpos(id,x,y) if standable2?(x,y) @map.events[id].x=x @map.events[id].y=y return end for i in 1..([@map.width,@map.height].max) if standable2?(x,y+i) @map.events[id].x=x @map.events[id].y=y+i return end for j in 1..i if standable2?(x-j,y+i) @map.events[id].x=x-j @map.events[id].y=y+i return end if standable2?(x+j,y+i) @map.events[id].x=x+j @map.events[id].y=y+i return end if standable2?(x-j,y-i) @map.events[id].x=x-j @map.events[id].y=y-i return end if standable2?(x+j,y-i) @map.events[id].x=x+j @map.events[id].y=y-i return end end end end #-------------------------------------------------------------------------- # ● 指定位置附近的墙壁上设置事件 # p4 幅度 #-------------------------------------------------------------------------- def set_defeventpos_wall(id,x,y,p4) if standable3?(x,y,p4) @map.events[id].x=x @map.events[id].y=y return end for i in 1..([@map.width,@map.height].max) if standable3?(x,y+i,p4) @map.events[id].x=x @map.events[id].y=y+i return end for j in 1..i if standable3?(x-j,y+i,p4) @map.events[id].x=x-j @map.events[id].y=y+i return end if standable3?(x+j,y+i,p4) @map.events[id].x=x+j @map.events[id].y=y+i return end if standable3?(x-j,y-i,p4) @map.events[id].x=x-j @map.events[id].y=y-i return end if standable3?(x+j,y-i,p4) @map.events[id].x=x+j @map.events[id].y=y-i return end end end end #-------------------------------------------------------------------------- # ● 指定位置附近设置玩家 #-------------------------------------------------------------------------- def playerpos_reset(x,y) if standable?(x,y) $game_temp.player_new_x=x $game_temp.player_new_y=y return end for i in 1..([@map.width,@map.height].max) if standable?(x,y+i) $game_temp.player_new_x=x $game_temp.player_new_y=y+i return end for j in 0..i if standable?(x-j,y+i) $game_temp.player_new_x=x-j $game_temp.player_new_y=y+i return end if standable?(x+j,y+i) $game_temp.player_new_x=x+j $game_temp.player_new_y=y+i return end if standable?(x-j,y-i) $game_temp.player_new_x=x-j $game_temp.player_new_y=y-i return end if standable?(x+j,y-i) $game_temp.player_new_x=x+j $game_temp.player_new_y=y-i return end end end end #-------------------------------------------------------------------------- # ● 自己能通过吗?(障碍物元件) # p1,p2 位置X,Y #-------------------------------------------------------------------------- def standable_newtile?(p1,p2) for i in [2, 1, 0] tile_id = @tilesetting[p1, p2, i] if tile_id == nil return false elsif @passages[tile_id] & 0x0f == 0x0f return false elsif @priorities[tile_id] == 0 return true end end return true end #-------------------------------------------------------------------------- # ● 在指定位置站立吗? # p1,p2 位置X,Y #-------------------------------------------------------------------------- def standable?(p1,p2) if @heightdata[p1,p2] != 0 return false end if @oneventdata[p1,p2] ==1 return false end for i in [2, 1, 0] tile_id = @map.data[p1, p2, i] if tile_id == nil return false elsif @passages[tile_id] & 0x0f == 0x0f return false elsif @priorities[tile_id] == 0 return true end end return true end #-------------------------------------------------------------------------- # ● 放置在指定位置没问题吗?(考虑周围的事件) # p1,p2 位置X,Y #-------------------------------------------------------------------------- def standable2?(p1,p2) # 站立位置判断 unless standable?(p1,p2) return false end # 周围事件检查(能否前往尽头?) # 去掉能到纵吗 if standable?(p1+1,p2-1) == false or standable?(p1+1,p2) == false or standable?(p1+1,p2+1) == false if standable?(p1-1,p2-1) == false or standable?(p1-1,p2) == false or standable?(p1-1,p2+1) == false # 去掉根本不能到纵的时候忽视 if standable?(p1,p2-1) == true and standable?(p1,p2+1) == true return false end end end # 去掉能到横吗 if standable?(p1+1,p2+1) == false or standable?(p1,p2+1) == false or standable?(p1-1,p2+1) == false if standable?(p1+1,p2-1) == false or standable?(p1,p2-1) == false or standable?(p1-1,p2-1) == false # 去掉根本不能到横的时候忽视 if standable?(p1-1,p2) == true and standable?(p1+1,p2) == true return false end end end if standable?(p1,p2-1) == false and (standable?(p1-1,p2+1) == false or standable?(p1,p2+1) == false or standable?(p1+1,p2+1) == false) return false end if standable?(p1,p2+1) == false and (standable?(p1-1,p2-1) == false or standable?(p1+1,p2-1) == false or standable?(p1+1,p2-1) == false) return false end if standable?(p1-1,p2) == false and (standable?(p1+1,p2-1) == false or standable?(p1+1,p2) == false or standable?(p1+1,p2+1) == false) return false end if standable?(p1+1,p2) == false and (standable?(p1-1,p2-1) == false or standable?(p1-1,p2) == false or standable?(p1-1,p2+1) == false) return false end return true end #-------------------------------------------------------------------------- # ● 放置在指定位置没问题吗?(墙壁版) # p1,p2 位置X,Y # p3 幅度 #-------------------------------------------------------------------------- def standable3?(p1,p2,p3) # 站立位置判断 unless standable?(p1,p2+1) return false end # 位置判断 if @oneventdata[p1,p2] == 1 or @oneventdata[p1,p2-1] == 1 or @heightdata[p1,p2-2] != 1 or @heightdata[p1,p2-1] == 1 or @heightdata[p1,p2+1] != 0 return false end for i in 1...p3+1 if@heightdata[p1+i,p2-2] != 1 or @heightdata[p1+i,p2-1] == 1 or @heightdata[p1+i,p2+1] != 0 return false end if@heightdata[p1-i,p2-2] != 1 or @heightdata[p1-i,p2-1] == 1 or @heightdata[p1-i,p2+1] != 0 return false end end for i in 1...p3+1 if @oneventdata[p1+i,p2] == 1 or @oneventdata[p1+i,p2-1] == 1 return false end if @oneventdata[p1-i,p2] == 1 or @oneventdata[p1-i,p2-1] == 1 return false end end return true end #-------------------------------------------------------------------------- # ● 地图元件信息变化 # p1,p2 起首处位置X,Y # p3,p4 原参照位置X,Y # p5 插入方法 0:通常 1:下一层 2:上一层 3:从下面 4:从上面 5:两边 #-------------------------------------------------------------------------- def set_mapdata(p1,p2,p3,p4,p5 = 0) unless self.valid?(p1, p2) return end if @tilesetting[p3,p4,0] != 0 # 0层普通放置 @map.data[p1,p2,0] = @tilesetting[p3,p4,0] end case p5 when 0 # 通常 if @tilesetting[p3,p4,1] != 0 @map.data[p1,p2,1] = @tilesetting[p3,p4,1] end if @tilesetting[p3,p4,2] != 0 @map.data[p1,p2,2] = @tilesetting[p3,p4,2] end when 1 # 放在下面 if @tilesetting[p3,p4,1] != 0 @map.data[p1,p2,1] = @tilesetting[p3,p4,1] end when 2 # 放在上面 if @tilesetting[p3,p4,1] != 0 @map.data[p1,p2,2] = @tilesetting[p3,p4,1] end when 3 # 从下面放置 if @tilesetting[p3,p4,1] != 0 if @map.data[p1,p2,1] != 0 @map.data[p1,p2,2] = @map.data[p1,p2,1] end @map.data[p1,p2,1] = @tilesetting[p3,p4,1] end when 4 # 从上面放置 if @tilesetting[p3,p4,1] != 0 if @map.data[p1,p2,2] != 0 @map.data[p1,p2,1] = @map.data[p1,p2,2] end @map.data[p1,p2,2] = @tilesetting[p3,p4,1] end when 5 # 从两边放置 if @tilesetting[p3,p4,1] != 0 @map.data[p1,p2,1] = @tilesetting[p3,p4,1] end if @tilesetting[p3,p4,1] != 0 @map.data[p1,p2,2] = @tilesetting[p3,p4,1] end when 6 # 能放置就放置 if @map.data[p1,p2,1] == 0 @map.data[p1,p2,1] = @tilesetting[p3,p4,1] elsif @map.data[p1,p2,2] == 0 @map.data[p1,p2,2] = @tilesetting[p3,p4,1] end end end #-------------------------------------------------------------------------- # ● 地图元件信息变化2 >>没有范围外判断等 # p1,p2 起首处位置X,Y # p3,p4 原参照位置X,Y #-------------------------------------------------------------------------- def set_mapdata2(p1,p2,p3,p4) @map.data[p1,p2,0] = @tilesetting[p3,p4,0] @map.data[p1,p2,1] = @tilesetting[p3,p4,1] @map.data[p1,p2,2] = @tilesetting[p3,p4,2] end #-------------------------------------------------------------------------- # ● 指定位置信息变化 # p1,p2 位置X,Y # p3 值 #-------------------------------------------------------------------------- def set_height(p1,p2,p3) return if p1<0 return if p1>=@map.width return if p2<0 return if p2>=@map.height @heightdata[p1,p2]=p3 end #-------------------------------------------------------------------------- # ● 指定位置信息变化 # p1,p2 位置X,Y # p3 值 #-------------------------------------------------------------------------- def set_grounddata(p1,p2,p3) return if p1<0 return if p1>=@map.width return if p2<0 return if p2>=@map.height if @masksetting[@maskdata[p1,p2]] == true if @targettype==0 if @chgtype==0 @heightdata[p1,p2]=p3 elsif @chgtype==1 @heightdata[p1,p2]+=p3 end elsif @targettype==1 if @chgtype==0 @maskdata[p1,p2]=p3 elsif @chgtype==1 @maskdata[p1,p2]+=p3 end end end end #-------------------------------------------------------------------------- # ● 指定计算方法 # p1 对象 >> =0:高度 =1:地形 (現在、高度0=地面 1=墙壁 # p2 方法 >> =0:代入 =1:加算 地形只是遮照判断使用 #-------------------------------------------------------------------------- def rndmap_chtarget(p1,p2) @targettype=p1 @chgtype=p2 end #-------------------------------------------------------------------------- # ● 设定其他注释使用的值 # p1,p2 最小 X,Y # p3,p4 最大 X,Y 设定制作道路的开始点,结束点等的时候使用 #-------------------------------------------------------------------------- def rndmap_setstat(p1,p2,p3,p4) @minx=p1 @miny=p2 @maxx=p3 @maxy=p4 end #-------------------------------------------------------------------------- # ● 设定地形遮照 # p1 = 对象地形 (-1= 全部) # p2 = 变更值 (0= 禁止改写 1= 可以改写 2= 只有那个地形可以) #-------------------------------------------------------------------------- def rndmap_chmask(p1,p2) if p1>=0 if p2==0 @masksetting[p1]=false elsif p2 == 1 @masksetting[p1]=true elsif p2 == 2 for i in 0...100 @masksetting[i]=false end @masksetting[p1]=true end end if p1==-1 if p2==0 for i in 0...100 @masksetting[i]=false end else for i in 0...100 @masksetting[i]=true end end end end #-------------------------------------------------------------------------- # ● 2点之间生成道路 # 起点、终点在rndmap_setstat里设定 # p1 = 改写值 # p2 = 途中点数(减的话以地图大小40*40为基准相对变化) # p3 = 确保边缘的宽度 # p4 = 途中点连接方法 (0=直线连接 1=直角线(?)连接) # p5 = 无视中继点的距离 #-------------------------------------------------------------------------- def rndmap_mkroad(p1,p2,p3,p4,p5 = 5) p5 = 5 if p5 == nil localdata = Table.new(@map.width,@map.height) aposx = [] aposy = [] aflag = [] for i in [email]0...@map.width[/email] for j in [email]0...@map.height[/email] localdata[i,j] = 0 end end if p2<0 p2=(p2*-1)*@map.width*@map.height/40/40 end aposx[0]=@minx aposy[0]=@miny aposx[1]=@maxx aposy[1]=@maxy if aposx[0]<0 aposx[0]=@map.width+aposx[0] end if (aposx[0]>=1000) and (aposx[0]<=1100) aposx[0]=@map.width*(aposx[0]-1000)/100 end if aposy[0]<0 aposy[0]=@map.height+aposy[0] end if (aposy[0]>=1000) and (aposy[0]<=1100) aposy[0]=@map.height*(aposy[0]-1000)/100 end if aposx[1]<0 aposx[1]=@map.width+aposx[1] end if (aposx[1]>=1000) and (aposx[1]<=1100) aposx[1]=@map.width*(aposx[1]-1000)/100 end if aposy[1]<0 aposy[1]=@map.height+aposy[1] end if (aposy[1]>=1000) and (aposy[1]<=1100) aposy[1]=@map.height*(aposy[1]-1000)/100 end if p4==0 or p4==1 or p4==2 if p4 == 2 i4 = rand(2) end aflag[0] = true aflag[1] = false for i in 2...(p2+2) aposx[i] = rand(@map.width-p3*2) + p3 aposy[i] = rand(@map.height-p3*2) + p3 aflag[i] = false end i3=0 i1=aposx[i3] i2=aposy[i3] localdata[i1,i2] = 1 for i in 0...p2+2 i7=5000000 for j in 0...p2+2 if aflag[j] == false i4 = aposx[j]-i1 i4=i4*-1 if i4 < 0 i5 = aposy[j]-i2 i5=i5*-1 if i5 < 0 if (i4**2+i5**2) <=(p5**2) and j != 1 aflag[j] = true elsif i7 > (i4**2+i5**2) i7=(i4**2+i5**2) i6=j end end end # 起点ID:i3 终点ID:i6 if p4==0 if aposx[i3] > aposx[i6] i8 = aposx[i3] i9 = aposy[i3] i10 = aposx[i6] i11 = aposy[i6] else i8 = aposx[i6] i9 = aposy[i6] i10 = aposx[i3] i11 = aposy[i3] end if i8!=i10 for i in 0..(i8-i10) localdata[i+i10,(i9-i11)*i/(i8-i10)+i11] = 1 end end if aposy[i3] > aposy[i6] i8 = aposx[i3] i9 = aposy[i3] i10 = aposx[i6] i11 = aposy[i6] else i8 = aposx[i6] i9 = aposy[i6] i10 = aposx[i3] i11 = aposy[i3] end if i9!=i11 for i in 0..(i9-i11) localdata[(i8-i10)*i/(i9-i11)+i10,i+i11] = 1 end end end if p4==1 i4 = rand(2) if i4==0 for i in 0..([aposx[i3]-aposx[i6],aposx[i6]-aposx[i3]].max) localdata[i+[aposx[i3],aposx[i6]].min,aposy[i3]] = 1 end for i in 0..([aposy[i3]-aposy[i6],aposy[i6]-aposy[i3]].max) localdata[aposx[i6],i+[aposy[i3],aposy[i6]].min] = 1 end else for i in 0..([aposx[i3]-aposx[i6],aposx[i6]-aposx[i3]].max) localdata[i+[aposx[i3],aposx[i6]].min,aposy[i6]] = 1 end for i in 0..([aposy[i3]-aposy[i6],aposy[i6]-aposy[i3]].max) localdata[aposx[i3],i+[aposy[i3],aposy[i6]].min] = 1 end end end i3=i6 i1=aposx[i3] i2=aposy[i3] aflag[i3]=true if i3==1 break end end end for i in [email]0...@map.width[/email] for j in [email]0...@map.height[/email] if localdata[i,j] == 1 set_grounddata(i,j,p1) end end end end #-------------------------------------------------------------------------- # ● 对象扩张 # p1 对象 # p2,p3 扩张幅度X,Y # p4 扩张方法 (0=十字 1=四角) #-------------------------------------------------------------------------- def rndmap_plus(p1,p2,p3,p4) localdata = Table.new(@map.width,@map.height) for i in [email]0...@map.width[/email] for j in [email]0...@map.height[/email] if @targettype==0 localdata[i,j] = @heightdata[i,j] elsif @targettype==1 localdata[i,j] = @maskdata[i,j] end end end if p4 == 0 for i in [email]0...@map.width[/email] for j in [email]0...@map.height[/email] if p1==localdata[i,j] for k in 1..p2 set_grounddata(i+k,j,p1) set_grounddata(i-k,j,p1) end for k in 1..p3 set_grounddata(i,j+k,p1) set_grounddata(i,j-k,p1) end end end end elsif p4 == 1 for i in [email]0...@map.width[/email] for j in [email]0...@map.height[/email] if p1==localdata[i,j] for k in (i-p2)..(i+p2) for l in (j-p3)..(j+p3) set_grounddata(k,l,p1) end end end end end end end #-------------------------------------------------------------------------- # ● 全部设定 # p1 值 #-------------------------------------------------------------------------- def rndmap_allchg(p1) for i in [email]0...@map.width[/email] for j in [email]0...@map.height[/email] set_grounddata(i,j,p1) end end end #-------------------------------------------------------------------------- # ● 指定点 # p1 值 # p2,p3 位置X,Y #-------------------------------------------------------------------------- def rndmap_putpos(p1,p2,p3) i = rand(@maxx-@minx+1)+@minx j = rand(@maxy-@miny+1)+@miny for k in (p2-i)..(p2+i) for l in (p3-j)..(p3+j) set_grounddata(k,l,p1) end end end #-------------------------------------------------------------------------- # ● 周围 # p1 值 #-------------------------------------------------------------------------- def rndmap_edge(p1) for i in [email]0...@map.width[/email] set_grounddata(i,0,p1) set_grounddata(i,@map.height-1,p1) end for i in [email]0...@map.height[/email] set_grounddata(0,i,p1) set_grounddata(@map.width-1,i,p1) end end end #============================================================================== # □ RPG::MapInfo >>用subname取得 “,”后面的文字 #============================================================================== module RPG class MapInfo def name name = @name.split(/,/)[0] return name != nil ? name : '' end def name=(str) str2 = @name[/^[^,]*(,.*)/, 1] @name = str2 != nil ? str + str2 : str end def subname(i = 1) name = @name.split(/,/)[i] return name != nil ? name : "" end end end #============================================================================== # □ RPG::Event >>用subname取得 “,”后面的文字 #============================================================================== module RPG class Event def name name = @name.split(/,/)[0] return name != nil ? name : '' end def name=(str) str2 = @name[/^[^,]*(,.*)/, 1] @name = str2 != nil ? str + str2 : str end def subname(i = 1) name = @name.split(/,/)[i] return name != nil ? name : "" end end end
#
# 随机地图生成脚本 v0.80 by tonbi
#
# 汉化修改 66RPG bbschat(2006.1.2)
#
# 随机地图自动生成脚本。
#
# ●使用方法
#
# 首先,设定随机地图名称
#
# 地图名称请按照「XXXXX,随机,YYY,ZZZ」的样式来命名。
# XXXXX 地图名,随便起自己喜欢的名字。
# YYY 随机类型编号,参考样例。
# ZZZ 障碍物数量,参考样例。
#
# 接下来,参考样例在地图上按照一定的规则画上地图元件
# 画的时候注意一下层。参考样例把地图元件画在对应的层上。
#
# 最后设定以下事件
#
# 中继点设定方法:
# 事件名称为「XXXXX,中继点」或事件执行内容的第一行加上「◆注释 : 中继点」。
#
# 随机地图将按照中继点事件产生随机道路,并按照事件ID顺序依次通过数个中继点
# (当然肯定不是直线通过)
# 一般请在地图的两端设定中继点事件。
# 两个中继点之间请保留适当空间,少于5个地图元件的话就没有墙壁了。
# 不过就算没有中继点,也能生成随机地图。
# 增加中继点会减少墙壁的数量,所以不要太多,有几个中继点就可以了。
# 通常按照三角形的方位来设置3个中继点。
#
# 中继点以外的事件如果没有特别指定将随机放置在地图的道路上。
#
# 固定事件设定方法:
# 事件名称为「XXXXX,固定」或事件执行内容的第一行加上「◆注释 : 固定」。
#
# 该事件将被放置在离该事件位置最近的道路上。
#
# 完全固定事件设定方法:
# 事件名称为「XXXXX,完全固定」或事件执行内容的第一行加上「◆注释 : 完全固定」
#
# 该事件位置将保持不变。
# 自动执行和并行处理的事件或者希望放在地图边缘方便查找的事件可以使用完全固定。
#
# 墙壁事件设定方法:
# 事件执行内容的第一行为「◆注释 : 壁设置」
# 该事件将随机出现在地图的墙壁上。
# 门,火把之类的事件专用。注释形式类似「壁设置,1」这样,后面要跟一个数字,
# 数字为了保证可以添加类似于[横幅]这样的事件。(横幅1元件为0,3个元件为1。)
# 这样的话就可以使用一些较大的事件了。
#
# 墙壁固定事件设定方法:
# 事件页第一行为「◆注释 : 壁设置固定」
# 这是同时具有上述固定事件和墙壁事件两个性质的事件。
# 也就是放置在离该事件位置最近的墙壁上的事件。
# 如果使用「壁设置固定,1」这种形式,也可以使用较大的事件。
#
# 还有使用之前请按照自己的需要设定下面的参数。
#========================================================================
#========================================================================
#★Clipping距离指定(搞不懂什么意思的话就不要改。)
class Game_Character
DRAWRANGEX = 1920 # 地图角色的Sprite更新距离
DRAWRANGEY = 1664 # 使用较大CharChip?时请适当增加。
# 指定的是X:15 Y:13乘128的数值。
# 上面是X坐标(横)下面是Y坐标(纵)。
end
#========================================================================
#========================================================================
#★是否保存。(并不准备使用随机地图、只是为了节约制作时间。)
# 保存下来的地图可以复制到其他地方以节省制作时间。
class Game_Map
AUTO_MAP_SAVE = true # 是否保存为地图ID:999。
# true 保存 false 不保存
# 游戏做完发布后请设定为false。
end
#-------------------------------------------------------------------
# ●Game_Temp
#--------------------------------------------------------------------
class Game_Temp
alias initialize_tonbi1 initialize
def initialize
initialize_tonbi1
$onscreen = [] # Sprite是否画面内标志
end
end
#--------------------------------------------------------------------------
# ● Game_Character
#--------------------------------------------------------------------------
class Game_Character
#--------------------------------------------------------------------------
# ● 更新
#--------------------------------------------------------------------------
alias update_tonbi1 update
def update
# 画面上的位置
sx = @real_x - $game_map.display_x - 1280
sy = @real_y - $game_map.display_y - 960
# 画面位置的绝对值
abs_sx = sx > 0 ? sx : -sx
abs_sy = sy > 0 ? sy-3 : -sy
# 纵横坐标超出 DRAWRANGE 元件的情况下
if abs_sx > DRAWRANGEX or abs_sy > DRAWRANGEY
# Sprite不更新
$onscreen[@id]=false
else
# Sprite更新
$onscreen[@id]=true
end
update_tonbi1
end
end
class Spriteset_Map
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
attr_accessor :character_sprites
def initialize
$onscreen = []
# 生成显示端口
@viewport1 = Viewport.new(0, 0, 640, 480)
@viewport2 = Viewport.new(0, 0, 640, 480)
@viewport3 = Viewport.new(0, 0, 640, 480)
@viewport2.z = 200
@viewport3.z = 5000
# 生成元件地图
@tilemap = Tilemap.new(@viewport1)
@tilemap.tileset = RPG::Cache.tileset($game_map.tileset_name)
for i in 0..6
autotile_name = $game_map.autotile_names[i]
@tilemap.autotiles[i] = RPG::Cache.autotile(autotile_name)
end
@tilemap.map_data = $game_map.data
@tilemap.priorities = $game_map.priorities
# 生成远景平面
@panorama = Plane.new(@viewport1)
@panorama.z = -1000
# 生成雾平面
@fog = Plane.new(@viewport1)
@fog.z = 3000
#########################################################★改变
# 角色活动块
# 将Party和Event区分开。
@character_sprites = []
@party_sprites = []
for i in $game_map.events.keys.sort
sprite = Sprite_Character.new(@viewport1, $game_map.events[i])
@character_sprites[i]=sprite
$onscreen[i] = true
end
@party_sprites.push(Sprite_Character.new(@viewport1, $game_player))
#########################################################
# 生成天气
@weather = RPG::Weather.new(@viewport1)
# 生成图片
@picture_sprites = []
for i in 1..50
@picture_sprites.push(Sprite_Picture.new(@viewport2,
$game_screen.pictures[i]))
end
# 生成计时器块
@timer_sprite = Sprite_Timer.new
# 刷新画面
update
end
#--------------------------------------------------------------------------
# ● 释放
#--------------------------------------------------------------------------
def dispose
# 释放元件地图
@tilemap.tileset.dispose
for i in 0..6
@tilemap.autotiles[i].dispose
end
@tilemap.dispose
# 释放远景平面
@panorama.dispose
# 释放雾平面
@fog.dispose
############################################################★改变
# 释放角色活动块
# nil 的话不释放
for i in @character_sprites
if i != nil
i.dispose
end
end
for i in @party_sprites
if i != nil
i.dispose
end
end
############################################################
# 释放天候
@weather.dispose
# 释放图片
for sprite in @picture_sprites
sprite.dispose
end
# 释放计时器块
@timer_sprite.dispose
# 释放显示端口
@viewport1.dispose
@viewport2.dispose
@viewport3.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 远景与现在的情况有差异发情况下
if @panorama_name != $game_map.panorama_name or
@panorama_hue != $game_map.panorama_hue
@panorama_name = $game_map.panorama_name
@panorama_hue = $game_map.panorama_hue
if @panorama.bitmap != nil
@panorama.bitmap.dispose
@panorama.bitmap = nil
end
if @panorama_name != ""
@panorama.bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue)
end
Graphics.frame_reset
end
# 雾与现在的情况有差异的情况下
if @fog_name != $game_map.fog_name or @fog_hue != $game_map.fog_hue
@fog_name = $game_map.fog_name
@fog_hue = $game_map.fog_hue
if @fog.bitmap != nil
@fog.bitmap.dispose
@fog.bitmap = nil
end
if @fog_name != ""
@fog.bitmap = RPG::Cache.fog(@fog_name, @fog_hue)
end
Graphics.frame_reset
end
# 刷新元件地图
@tilemap.ox = $game_map.display_x / 4
@tilemap.oy = $game_map.display_y / 4
@tilemap.update
# 刷新远景平面
@panorama.ox = $game_map.display_x / 8
@panorama.oy = $game_map.display_y / 8
# 刷新雾平面
@fog.zoom_x = $game_map.fog_zoom / 100.0
@fog.zoom_y = $game_map.fog_zoom / 100.0
@fog.opacity = $game_map.fog_opacity
@fog.blend_type = $game_map.fog_blend_type
@fog.ox = $game_map.display_x / 4 + $game_map.fog_ox
@fog.oy = $game_map.display_y / 4 + $game_map.fog_oy
@fog.tone = $game_map.fog_tone
#####################################################★改变
# 刷新角色活动块
# 画面外的角色活动块不更新
for i in $game_map.events.keys
if $onscreen[i]
@character_sprites[i].update
end
end
# 玩家角色更新
for i in @party_sprites
i.update
end
#####################################################
# 刷新天候图形
@weather.type = $game_screen.weather_type
@weather.max = $game_screen.weather_max
@weather.ox = $game_map.display_x / 4
@weather.oy = $game_map.display_y / 4
@weather.update
# 刷新图片
for sprite in @picture_sprites
sprite.update
end
# 刷新计时器块
@timer_sprite.update
# 设置画面的色调与震动位置
@viewport1.tone = $game_screen.tone
@viewport1.ox = $game_screen.shake
# 设置画面的闪烁色
@viewport3.color = $game_screen.flash_color
# 刷新显示端口
@viewport1.update
@viewport3.update
end
end
#==============================================================================
# ■ Game_Map
#==============================================================================
class Game_Map
#--------------------------------------------------------------------------
# ● 设置
# map_id : 地图 ID
#--------------------------------------------------------------------------
def setup(map_id)
# 地图 ID 记录到 @map_id
@map_id = map_id
# 地图文件装载后、设置到 @map
@map = load_data(sprintf("Data/Map%03d.rxdata", @map_id))
# 定义实例变量设置地图元件信息
tileset = $data_tilesets[@map.tileset_id]
@tileset_name = tileset.tileset_name
@autotile_names = tileset.autotile_names
@panorama_name = tileset.panorama_name
@panorama_hue = tileset.panorama_hue
@fog_name = tileset.fog_name
@fog_hue = tileset.fog_hue
@fog_opacity = tileset.fog_opacity
@fog_blend_type = tileset.fog_blend_type
@fog_zoom = tileset.fog_zoom
@fog_sx = tileset.fog_sx
@fog_sy = tileset.fog_sy
@battleback_name = tileset.battleback_name
@passages = tileset.passages
@priorities = tileset.priorities
@terrain_tags = tileset.terrain_tags
# 初始化显示坐标
@display_x = 0
@display_y = 0
check_special_map #★检查随机地图
# 清除刷新要求标志
@need_refresh = false
# 设置地图事件数据
@events = {}
for i in @map.events.keys
@events[i] = Game_Event.new(@map_id, @map.events[i])
end
# 设置公共事件数据
@common_events = {}
for i in 1...$data_common_events.size
@common_events[i] = Game_CommonEvent.new(i)
end
# 初始化雾的各种信息
@fog_ox = 0
@fog_oy = 0
@fog_tone = Tone.new(0, 0, 0, 0)
@fog_tone_target = Tone.new(0, 0, 0, 0)
@fog_tone_duration = 0
@fog_opacity_duration = 0
@fog_opacity_target = 0
# 初始化滚动信息
@scroll_direction = 2
@scroll_rest = 0
@scroll_speed = 4
end
#--------------------------------------------------------------------------
# ● 紧接读入地图之后的处理
#--------------------------------------------------------------------------
def check_special_map
# 取得地图名称
mapinfo = load_data("Data/MapInfos.rxdata")
# 地图名称包含“随机”的场合
if mapinfo[@map_id].subname == "随机"
if mapinfo[@map_id].subname(3)=="" or mapinfo[@map_id].subname(3) == nil
p3 = 0
else
p3 = mapinfo[@map_id].subname(3).to_i
end
if mapinfo[@map_id].subname(4)=="false"
p4 = false
end
make_random_map(2,mapinfo[@map_id].subname(2).to_i,p3,p4)
end
end
#--------------------------------------------------------------------------
# ● 生成随机地图
# wall = 墙壁的高 >> 现在无效
# type = 墙壁制作类型 >> 0以外没制作(汗 指定方法也未定) (<-- bbschat注:汗~原来日本人也会用汗)
# thoughplayer = 玩家在中继点中包含吗?
# connect = 中继点的连接方法 >> true=连续 false=2个各自独立
#
# ※所有参数全部省略 可以使用下面的例子
# ex. make_random_map(2,0,,true)
#--------------------------------------------------------------------------
def make_random_map(wall = 2, type = 0, objcnt = 0, connect = true)
# 非法参数处理
wall = 0 if wall == nil
type = 0 if type == nil
objcnt = 0 if objcnt == nil
unless objcnt.is_a?(Numeric)
objcnt = 0
end
if objcnt < 0
objcnt = 0
end
connect = true if connect != false
# 高度数据表
@heightdata = Table.new(@map.width,@map.height)
# 地形数据表
@maskdata = Table.new(@map.width,@map.height)
# 事件数据表
@oneventdata = Table.new(@map.width,@map.height)
# 遮照设定数组
@masksetting = []
# 制作方法数组
@makedata = []
# 演算方法初始化
@targettype=0
@chgtype=0
time = -1
# 数据初始化
for i in [email]0...@map.width[/email]
for j in [email]0...@map.height[/email]
time += 1
if time%2000 == 0
Graphics.update
end
@heightdata[i,j] = 0
@maskdata[i,j] = 0
end
end
for i in 0...100
@masksetting[i] = true
end
# 取得中继点情报
needposx = []
needposy = []
# 增加中继点事件
for i in @map.events.keys.sort
time += 1
if time%200 == 0
Graphics.update
end
if event_settype(i) == 1
if connect == true
needposx.push(@map.events[i].x)
needposy.push(@map.events[i].y)
needposx.push(@map.events[i].x)
needposy.push(@map.events[i].y)
else
needposx.push(@map.events[i].x)
needposy.push(@map.events[i].y)
end
end
end
if connect == true
needposx.shift
needposy.shift
end
loop do
if needposx.size <= 2
needposx.push(rand(@map.width))
needposy.push(rand(@map.height))
else
break
end
end
# 这里设定制作方法数组
case type
when 0
# 类型0 >> 2层自然类型
@makedata.push([0,1,0])
@makedata.push([5,1])
for i in 0...(needposx.size/2)
@makedata.push([1,needposx[i*2],needposy[i*2],needposx[i*2+1],needposy[i*2+1]])
@makedata.push([3,0,-15,4,0])
@makedata.push([1,1,1,1,1])
@makedata.push([6,0,needposx[i*2],needposy[i*2]])
@makedata.push([6,0,needposx[i*2+1],needposy[i*2+1]])
end
@makedata.push([4,0,1,1,1])
@makedata.push([4,0,1,1,1])
@makedata.push([4,1,1,1,1])
@makedata.push([0,0,0])
@makedata.push([2,0,2])
@makedata.push([5,0])
@makedata.push([2,1,2])
@makedata.push([5,1])
when 1
# 类型1 >> 2层人工类型
@makedata.push([0,1,0])
@makedata.push([5,1])
for i in 0...(needposx.size/2)
@makedata.push([1,needposx[i*2],needposy[i*2],needposx[i*2+1],needposy[i*2+1]])
@makedata.push([3,0,-6,4,1,10])
@makedata.push([1,1,1,1,1])
@makedata.push([6,0,needposx[i*2],needposy[i*2]])
@makedata.push([6,0,needposx[i*2+1],needposy[i*2+1]])
end
@makedata.push([4,0,2,3,1])
@makedata.push([4,1,2,2,1])
@makedata.push([4,0,1,1,1])
@makedata.push([0,0,0])
@makedata.push([2,0,2])
@makedata.push([5,0])
@makedata.push([2,1,2])
@makedata.push([5,1])
when 2
# 类型2 >> 2层自然凸类型
@makedata.push([0,1,0])
@makedata.push([5,1])
for i in 0...(needposx.size/2)
@makedata.push([1,needposx[i*2],needposy[i*2],needposx[i*2+1],needposy[i*2+1]])
@makedata.push([3,0,-15,4,0])
@makedata.push([1,1,1,1,1])
@makedata.push([6,0,needposx[i*2],needposy[i*2]])
@makedata.push([6,0,needposx[i*2+1],needposy[i*2+1]])
end
@makedata.push([4,0,2,2,1])
@makedata.push([4,1,1,1,1])
@makedata.push([0,0,0])
@makedata.push([2,0,2])
@makedata.push([5,0])
@makedata.push([2,1,2])
@makedata.push([5,-1])
when 3
# 类型3 >> 2层人工凸类型
@makedata.push([0,1,0])
@makedata.push([5,1])
for i in 0...(needposx.size/2)
@makedata.push([1,needposx[i*2],needposy[i*2],needposx[i*2+1],needposy[i*2+1]])
@makedata.push([3,0,-15,4,1,10])
@makedata.push([1,1,1,1,1])
@makedata.push([6,0,needposx[i*2],needposy[i*2]])
@makedata.push([6,0,needposx[i*2+1],needposy[i*2+1]])
end
@makedata.push([4,0,2,2,1])
@makedata.push([4,1,1,1,1])
@makedata.push([0,0,0])
@makedata.push([2,0,2])
@makedata.push([5,0])
@makedata.push([2,1,2])
@makedata.push([5,-1])
when 4
# 类型4 >> 2层自然类型 之一
# 地形[0:洞 1:地面 2:墙壁]
# 基本设定
@makedata.push([0,1,0])
@makedata.push([5,0])
# 放置墙
@makedata.push([1,0,0,-1,0])
@makedata.push([3,2,-6,1,0])
@makedata.push([1,-1,0,-1,-1])
@makedata.push([3,2,-6,1,0])
@makedata.push([1,-1,-1,0,-1])
@makedata.push([3,2,-6,1,0])
@makedata.push([1,0,-1,0,0])
@makedata.push([3,2,-6,1,0])
@makedata.push([4,2,2,2,1])
# 随机放置洞
for i in 0...(rand(12*@map.width*@map.height/40/40)+(5*@map.width*@map.height/40/40))
@makedata.push([1,3,3,8,8])
@makedata.push([6,0,rand(@map.width-10)+5,rand(@map.height-10)+5])
end
# 生成周围的墙
@makedata.push([7,2])
@makedata.push([4,2,1,1,1])
# 生成道路
for i in 0...(needposx.size/2)
@makedata.push([1,needposx[i*2],needposy[i*2],needposx[i*2+1],needposy[i*2+1]])
@makedata.push([3,1,-8,4,0,5])
@makedata.push([1,1,1,1,1])
@makedata.push([6,1,needposx[i*2],needposy[i*2]])
@makedata.push([6,1,needposx[i*2+1],needposy[i*2+1]])
end
# 扩张处理
@makedata.push([4,1,1,1,1])
@makedata.push([4,1,0,1,1])
@makedata.push([2,0,0])
@makedata.push([4,1,1,0,1])
@makedata.push([2,-1,1])
@makedata.push([4,2,1,1,1])
# 高度设定
@makedata.push([0,0,0])
@makedata.push([2,0,2])
@makedata.push([5,-1])
@makedata.push([2,1,2])
@makedata.push([5,0])
@makedata.push([2,2,2])
@makedata.push([5,1])
when 5
# 类型5 >> 2层人工类型 之一
# 地形[0:洞 1:地面 2:墙壁]
# 基本设定
@makedata.push([0,1,0])
@makedata.push([5,0])
# 放置墙
@makedata.push([1,0,0,-1,0])
@makedata.push([3,2,-6,1,0])
@makedata.push([1,-1,0,-1,-1])
@makedata.push([3,2,-6,1,0])
@makedata.push([1,-1,-1,0,-1])
@makedata.push([3,2,-6,1,0])
@makedata.push([1,0,-1,0,0])
@makedata.push([3,2,-6,1,0])
@makedata.push([4,2,2,2,1])
# 随机放置洞
for i in 0...(rand(12*@map.width*@map.height/40/40)+(5*@map.width*@map.height/40/40))
@makedata.push([1,3,3,8,8])
@makedata.push([6,0,rand(@map.width-10)+5,rand(@map.height-10)+5])
end
# 生成周围的墙
@makedata.push([7,2])
@makedata.push([4,2,1,1,1])
# 生成道路
for i in 0...(needposx.size/2)
@makedata.push([1,needposx[i*2],needposy[i*2],needposx[i*2+1],needposy[i*2+1]])
@makedata.push([3,1,-8,4,1,5])
@makedata.push([1,1,1,1,1])
@makedata.push([6,1,needposx[i*2],needposy[i*2]])
@makedata.push([6,1,needposx[i*2+1],needposy[i*2+1]])
end
# 扩张处理
@makedata.push([4,1,1,1,1])
@makedata.push([4,1,0,1,1])
@makedata.push([2,0,0])
@makedata.push([4,1,1,0,1])
@makedata.push([2,-1,1])
@makedata.push([4,2,1,1,1])
# 高度设定
@makedata.push([0,0,0])
@makedata.push([2,0,2])
@makedata.push([5,-1])
@makedata.push([2,1,2])
@makedata.push([5,0])
@makedata.push([2,2,2])
@makedata.push([5,1])
when 6
# 类型6 >> 2层自然类型 之二
# 地形[0:洞 1:地面 2:墙壁]
# 基本设定
@makedata.push([0,1,0])
@makedata.push([5,0])
# 放置墙
@makedata.push([1,0,0,-1,0])
@makedata.push([3,2,-6,1,0])
@makedata.push([1,-1,0,-1,-1])
@makedata.push([3,2,-6,1,0])
@makedata.push([1,-1,-1,0,-1])
@makedata.push([3,2,-6,1,0])
@makedata.push([1,0,-1,0,0])
@makedata.push([3,2,-6,1,0])
@makedata.push([4,2,2,2,1])
# 随机放置洞
for i in 0...(rand(12*@map.width*@map.height/40/40)+(5*@map.width*@map.height/40/40))
@makedata.push([1,1,1,3,3])
@makedata.push([6,0,rand(@map.width-10)+5,rand(@map.height-10)+5])
end
# 洞扩大
@makedata.push([4,0,2,2,0])
@makedata.push([4,0,1,2,1])
# 生成周围的墙
@makedata.push([7,2])
@makedata.push([4,2,1,1,1])
# 生成道路
for i in 0...(needposx.size/2)
@makedata.push([1,needposx[i*2],needposy[i*2],needposx[i*2+1],needposy[i*2+1]])
@makedata.push([3,1,-15,4,0,5])
@makedata.push([1,1,1,1,1])
@makedata.push([6,1,needposx[i*2],needposy[i*2]])
@makedata.push([6,1,needposx[i*2+1],needposy[i*2+1]])
end
# 扩张处理
@makedata.push([4,1,1,1,1])
@makedata.push([4,1,0,1,1])
@makedata.push([2,0,0])
@makedata.push([4,1,1,0,1])
@makedata.push([2,-1,1])
@makedata.push([4,2,1,1,1])
# 高度设定
@makedata.push([0,0,0])
@makedata.push([2,0,2])
@makedata.push([5,-1])
@makedata.push([2,1,2])
@makedata.push([5,0])
@makedata.push([2,2,2])
@makedata.push([5,1])
when 7
# 类型7 >> 2层人工类型 之二
# 地形[0:洞 1:地面 2:墙壁]
# 基本设定
@makedata.push([0,1,0])
@makedata.push([5,0])
# 放置墙
@makedata.push([1,0,0,-1,0])
@makedata.push([3,2,-6,1,0])
@makedata.push([1,-1,0,-1,-1])
@makedata.push([3,2,-6,1,0])
@makedata.push([1,-1,-1,0,-1])
@makedata.push([3,2,-6,1,0])
@makedata.push([1,0,-1,0,0])
@makedata.push([3,2,-6,1,0])
@makedata.push([4,2,2,2,1])
# 随机放置洞
for i in 0...(rand(12*@map.width*@map.height/40/40)+(5*@map.width*@map.height/40/40))
@makedata.push([1,1,1,3,3])
@makedata.push([6,0,rand(@map.width-10)+5,rand(@map.height-10)+5])
end
# 洞扩大
@makedata.push([4,0,2,2,0])
@makedata.push([4,0,1,2,1])
# 生成周围的墙
@makedata.push([7,2])
@makedata.push([4,2,1,1,1])
# 生成道路
for i in 0...(needposx.size/2)
@makedata.push([1,needposx[i*2],needposy[i*2],needposx[i*2+1],needposy[i*2+1]])
@makedata.push([3,1,-15,4,1,5])
@makedata.push([1,1,1,1,1])
@makedata.push([6,1,needposx[i*2],needposy[i*2]])
@makedata.push([6,1,needposx[i*2+1],needposy[i*2+1]])
end
# 扩张处理
@makedata.push([4,1,1,1,1])
@makedata.push([4,1,0,1,1])
@makedata.push([2,0,0])
@makedata.push([4,1,1,0,1])
@makedata.push([2,-1,1])
@makedata.push([4,2,1,1,1])
# 高度设定
@makedata.push([0,0,0])
@makedata.push([2,0,2])
@makedata.push([5,-1])
@makedata.push([2,1,2])
@makedata.push([5,0])
@makedata.push([2,2,2])
@makedata.push([5,1])
end
# 实际制作
for make_stat in @makedata
time += 1
if time%2 == 0
Graphics.update
end
case make_stat[0]
when 0 # 对象变化 (p1[0=高度 1=地形], p2[0=代入 1=加算])
rndmap_chtarget(make_stat[1],make_stat[2])
when 1 # 参数设定 (minx, miny, maxz, maxy)
rndmap_setstat(make_stat[1],make_stat[2],make_stat[3],make_stat[4])
when 2 # 遮照变化 (p1[-1:全部], p2[ 0=false 1=true 2=onlytrue])
rndmap_chmask(make_stat[1],make_stat[2])
when 3 # 生成道路 (值,中继点数,边缘确保,类型)
rndmap_mkroad(make_stat[1],make_stat[2],make_stat[3],make_stat[4],make_stat[5])
when 4 # 扩张 (对象,纵幅,横幅,类型)
rndmap_plus(make_stat[1],make_stat[2],make_stat[3],make_stat[4])
when 5 # 全变化 (值)
rndmap_allchg(make_stat[1])
when 6 # 指定点 (值,位置X,位置Y)
rndmap_putpos(make_stat[1],make_stat[2],make_stat[3])
when 7 # 周围 (值)
rndmap_edge(make_stat[1])
end
end
# 取得使用地图元件
@tilesetting = Table.new(3,40,3)
for i in [0,1,2]
for k in 0...40
for j in [0,1,2]
@tilesetting[j,k,i] = @map.data[j,k,i]
end
end
end
# 补正
time = 0
for k in [email]0...@map.height[/email]
for j in [email]0...@map.width[/email]
time += 1
# 定期画面更新
if time%500 == 0
Graphics.update
end
# 墙下的地图元件要是洞的话,地面变更
if @heightdata[j,k] == 1
if @heightdata[j,k+1]==-1
@heightdata[j,k+1] = 0
if @heightdata[j,k+2]==-1 and
@heightdata[j,k+3] == 0
@heightdata[j,k+2] = 0
end
end
end
end
end
# 生成地面 之一 >> 暂且全面铺上
time = 0
for k in [email]0...@map.height[/email]
for j in [email]0...@map.width[/email]
time += 1
# 定期画面更新
if time%500 == 0
Graphics.update
end
if @heightdata[j,k] == 0
if @heightdata[j,k+1] == -1 or
@heightdata[j,k-1] == -1 or
@heightdata[j+1,k] == -1 or
@heightdata[j-1,k] == -1
set_mapdata2(j,k,0,8)
else
set_mapdata2(j,k,0,0)
end
elsif @heightdata[j,k] == 1
if @heightdata[j,k+1] == -1 or
@heightdata[j,k-1] == -1 or
@heightdata[j+1,k] == -1 or
@heightdata[j-1,k] == -1
set_mapdata2(j,k,0,8)
elsif @heightdata[j,k+1] == 0 or
@heightdata[j,k-1] == 0 or
@heightdata[j+1,k] == 0 or
@heightdata[j-1,k] == 0
set_mapdata2(j,k,0,0)
else
set_mapdata2(j,k,1,4)
end
else
set_mapdata2(j,k,0,8)
end
end
end
# 生成地面 之二 >> 生成洞
time = 0
for k in [email]0...@map.height[/email]
for j in [email]0...@map.width[/email]
time += 1
# 定期画面更新
if time%500 == 0
Graphics.update
end
if @heightdata[j,k] == 0
if @heightdata[j,k+1] == -1
# 下面是洞------------------
if @heightdata[j-1,k] == -1
# 左边也是洞
for i in [0,1,2]
set_mapdata(j,k+i,0,13+i,1)
end
elsif @heightdata[j+1,k] == -1
# 右边也是洞
for i in [0,1,2]
set_mapdata(j,k+i,2,13+i,1)
end
else
# 两边是地面
for i in [0,1,2]
set_mapdata(j,k+i,1,13+i,1)
end
end
elsif @heightdata[j,k-1] == -1
# 上面是洞------------------
if @heightdata[j-1,k] == -1 or
(@heightdata[j-1,k] == 1 and
@heightdata[j-1,k-1] == -1)
# 左边也是洞
set_mapdata(j,k,0,11,2)
elsif @heightdata[j+1,k] == -1 or
(@heightdata[j+1,k] == 1 and
@heightdata[j+1,k-1] == -1)
# 右边也是洞
set_mapdata(j,k,2,11,2)
else
# 两边是地面
set_mapdata(j,k,1,11,2)
end
elsif @heightdata[j-1,k] == -1 or
(@heightdata[j-1,k] == 1 and
@heightdata[j-1,k-1] == -1)
# 左边是洞------------------
set_mapdata(j,k,0,12,1)
elsif @heightdata[j+1,k] == -1 or
(@heightdata[j+1,k] == 1 and
@heightdata[j+1,k-1] == -1)
# 右边是洞------------------
set_mapdata(j,k,2,12,1)
elsif @heightdata[j-1,k-1] == -1
# 左上面是洞------------------
set_mapdata(j,k,0,9,1)
elsif @heightdata[j-1,k+1] == -1
# 左下面是洞------------------
set_mapdata(j,k,0,10,1)
elsif @heightdata[j+1,k-1] == -1
# 右上面是洞------------------
set_mapdata(j,k,1,9,1)
elsif @heightdata[j+1,k+1] == -1
# 右下面是洞------------------
set_mapdata(j,k,1,10,1)
end
end
if @heightdata[j,k] == 1 and
@heightdata[j,k-1] != -1
if @heightdata[j,k+1] == -1
# 下面是洞------------------
if @heightdata[j-1,k] == -1
# 左边也是洞
for i in [0,1,2]
# set_mapdata(j,k+i,0,13+i,1)
end
elsif @heightdata[j+1,k] == -1
# 右边也是洞
for i in [0,1,2]
# set_mapdata(j,k+i,2,13+i,1)
end
else
# 两边是地面
for i in [0,1,2]
# set_mapdata(j,k+i,1,13+i,1)
end
end
elsif @heightdata[j,k-1] == -1
# 上面是洞------------------
if @heightdata[j-1,k] == -1
# 左边也是洞
set_mapdata(j,k,0,11,2)
elsif @heightdata[j+1,k] == -1
# 右边也是洞
set_mapdata(j,k,2,11,2)
else
# 两边是地面
set_mapdata(j,k,1,11,2)
end
elsif @heightdata[j-1,k] == -1
# 左边是洞------------------
set_mapdata(j,k,0,12,1)
elsif @heightdata[j+1,k] == -1
# 右边是洞------------------
set_mapdata(j,k,2,12,1)
elsif @heightdata[j-1,k-1] == -1
# 左上面是洞------------------
set_mapdata(j,k,0,9,1)
elsif @heightdata[j-1,k+1] == -1
# 左下面是洞------------------
set_mapdata(j,k,0,10,1)
elsif @heightdata[j+1,k-1] == -1
# 右上面是洞------------------
set_mapdata(j,k,1,9,1)
elsif @heightdata[j+1,k+1] == -1
# 右下面是洞------------------
set_mapdata(j,k,1,10,1)
end
end
end
end
# 生成地面 之三 >> 生成墙壁
time = 0
for k in [email]0...@map.height[/email]
for j in [email]0...@map.width[/email]
time += 1
# 定期画面更新
if time%500 == 0
Graphics.update
end
if @heightdata[j,k] == 1
if @heightdata[j,k+1] == 0 or
@heightdata[j,k+1] == -1
# 下面是洞------------------
if @heightdata[j-1,k] == 0 or
@heightdata[j-1,k] == -1
# 左边也是洞
set_mapdata(j,k+0,0,5+0,5)
set_mapdata(j,k+1,0,5+1,5)
set_mapdata(j,k+2,0,5+2,4)
if @heightdata[j,k+3] != 0 and
@heightdata[j,k+2] != 1 and
(@heightdata[j,k+2] != 0 or @heightdata[j-1,k+2] != 0)
set_mapdata(j,k+2,0,16,5)
for i in [0,1]
set_mapdata(j,k+3+i,0,14+i,1)
if @heightdata[j,k+3+i] != -1
break
end
end
end
elsif @heightdata[j+1,k] == 0 or
@heightdata[j+1,k] == -1
# 右边也是洞
set_mapdata(j,k+0,2,5+0,5)
set_mapdata(j,k+1,2,5+1,5)
set_mapdata(j,k+2,2,5+2,4)
if @heightdata[j,k+3] != 0 and
@heightdata[j,k+2] != 1 and
(@heightdata[j,k+2] != 0 or @heightdata[j+1,k+2] != 0)
set_mapdata(j,k+2,2,16,5)
for i in [0,1]
set_mapdata(j,k+3+i,2,14+i,1)
if @heightdata[j,k+3+i] != -1
break
end
end
end
else
# 两边是地面
set_mapdata(j,k+0,1,5+0,5)
set_mapdata(j,k+1,1,5+1,5)
set_mapdata(j,k+2,1,5+2,4)
if @heightdata[j,k+3] != 0 and
@heightdata[j,k+2] != 1
set_mapdata(j,k+2,1,16,5)
for i in [0,1]
set_mapdata(j,k+3+i,1,14+i,1)
if @heightdata[j,k+3+i] != -1
break
end
end
end
end
elsif @heightdata[j,k-1] == 0 or
@heightdata[j,k-1] == -1
# 上面是洞------------------
if @heightdata[j-1,k] == 0 or
@heightdata[j-1,k] == -1
# 左边也是洞
set_mapdata(j,k,0,3,4)
elsif @heightdata[j+1,k] == 0 or
@heightdata[j+1,k] == -1
# 右边也是洞
set_mapdata(j,k,2,3,4)
else
# 两边是地面
set_mapdata(j,k,1,3,4)
end
elsif @heightdata[j-1,k] == 0 or
@heightdata[j-1,k] == -1
# 左边是洞------------------
set_mapdata(j,k,0,4,4)
elsif @heightdata[j+1,k] == 0 or
@heightdata[j+1,k] == -1
# 右边是洞------------------
set_mapdata(j,k,2,4,4)
elsif @heightdata[j-1,k-1] == 0 or
@heightdata[j-1,k-1] == -1
# 左上面是洞------------------
set_mapdata(j,k,0,1,4)
elsif @heightdata[j-1,k+1] == 0 or
@heightdata[j-1,k+1] == -1
# 左下面是洞------------------
set_mapdata(j,k,0,2,4)
elsif @heightdata[j+1,k-1] == 0 or
@heightdata[j+1,k-1] == -1
# 右上面是洞------------------
set_mapdata(j,k,1,1,4)
elsif @heightdata[j+1,k+1] == 0 or
@heightdata[j+1,k+1] == -1
# 右下面是洞------------------
set_mapdata(j,k,1,2,4)
end
end
end
end
# 调整玩家位置
playerpos_reset($game_temp.player_new_x,$game_temp.player_new_y)
@oneventdata[$game_temp.player_new_x,$game_temp.player_new_y] = 1
time = 0
for i in @map.events.keys.sort
time += 1
if time%100 == 0
Graphics.update
end
# 事件设置类型>>完全固定(最优先)
case event_settype(i)
when 3
@oneventdata[@map.events[i].x,@map.events[i].y] = 1
end
end
for i in @map.events.keys.sort
time += 1
if time%100 == 0
Graphics.update
end
# 事件设置类型>>中继点
case event_settype(i)
when 1
set_defeventpos(i,@map.events[i].x,@map.events[i].y)
@oneventdata[@map.events[i].x,@map.events[i].y] = 1
end
end
# 调整事件位置
for i in @map.events.keys.sort
time += 1
if time%100 == 0
Graphics.update
end
j = event_settype(i)
case j
when 0 # 随机
set_defeventpos(i,rand(@map.width-4)+2,rand(@map.width-4)+2)
@oneventdata[@map.events[i].x,@map.events[i].y] = 1
when 2 # 固定
set_defeventpos(i,@map.events[i].x,@map.events[i].y)
@oneventdata[@map.events[i].x,@map.events[i].y] = 1
when 100..199 # 壁设置
set_defeventpos_wall(i,rand(@map.width-4)+2,rand(@map.width-4)+2,j-100)
@oneventdata[@map.events[i].x,@map.events[i].y] = 1
@oneventdata[@map.events[i].x,@map.events[i].y-1] = 1
for k in 1..(j-100)
@oneventdata[@map.events[i].x+k,@map.events[i].y] = 1
@oneventdata[@map.events[i].x+k,@map.events[i].y-1] = 1
@oneventdata[@map.events[i].x-k,@map.events[i].y] = 1
@oneventdata[@map.events[i].x-k,@map.events[i].y-1] = 1
end
when 200..299 # 壁设置固定
set_defeventpos_wall(i,@map.events[i].x,@map.events[i].y,j-200)
@oneventdata[@map.events[i].x,@map.events[i].y] = 1
@oneventdata[@map.events[i].x,@map.events[i].y-1] = 1
for k in 1..(j-200)
@oneventdata[@map.events[i].x+k,@map.events[i].y] = 1
@oneventdata[@map.events[i].x+k,@map.events[i].y-1] = 1
@oneventdata[@map.events[i].x-k,@map.events[i].y] = 1
@oneventdata[@map.events[i].x-k,@map.events[i].y-1] = 1
end
end
end
# 放置障碍
for i in 0...(rand(objcnt)+objcnt/2)
time += 1
if time%500 == 0
Graphics.update
end
j = rand(@map.width)
k = rand(@map.width)
case rand(10)
when 0..4
if standable_newtile?(1,0)
if standable?(j,k)
set_mapdata(j,k,1,0,6)
end
else
if standable2?(j,k)
set_mapdata(j,k,1,0,6)
end
end
when 5..7
if standable_newtile?(2,0)
if standable?(j,k)
set_mapdata(j,k,2,0,6)
end
else
if standable2?(j,k)
set_mapdata(j,k,2,0,6)
end
end
when 8..9
if standable2?(j,k)
if @map.data[j,k-1,2]==0 and
(@map.data[j,k,1]==0 or @map.data[j,k,2]==0)
set_mapdata(j,k,2,2,4) # 4>6?
set_mapdata(j,k-1,2,1,4) # 4>2?
end
end
end
end
# 释放变量的内容
@heightdata.resize(0,0)
@maskdata.resize(0,0)
@oneventdata.resize(0,0)
@masksetting.clear
@makedata.clear
@tilesetting.resize(0,0,0)
if AUTO_MAP_SAVE
# 保存机能
save_data(@map,sprintf("Data/Map%03d.rxdata", 999))
maplist = load_data("Data/MapInfos.rxdata")
mapinfo = RPG::MapInfo.new
mapinfo.name = sprintf("随机自动保存(%s)", maplist[@map_id].name)
mapinfo.parent_id = 0
mapinfo.order = 999
mapinfo.expanded = true
mapinfo.scroll_x = 0
mapinfo.scroll_y = 0
maplist[999]=mapinfo
save_data(maplist,"Data/MapInfos.rxdata")
end
end
#--------------------------------------------------------------------------
# ● 获得事件的位置类型
#--------------------------------------------------------------------------
def event_settype(i)
if @map.events[i].subname == "中继点"
return 1
end
if @map.events[i].subname == "固定"
return 2
end
if @map.events[i].subname == "完全固定"
return 3
end
for j in 0..1000
if @map.events[i].pages[0].list[j].code != 108
break
end
# 注释中有中继点
if @map.events[i].pages[0].list[j].parameters[0].split(/,/)[0] == "中继点"
return 1
end
# 注释中有完全固定
if @map.events[i].pages[0].list[j].parameters[0].split(/,/)[0] == "完全固定"
return 3
end
# 注释中有固定
if @map.events[i].pages[0].list[j].parameters[0].split(/,/)[0] == "固定"
return 2
end
# 注释中有壁设置
if @map.events[i].pages[0].list[j].parameters[0].split(/,/)[0] == "壁设置"
if @map.events[i].pages[0].list[j].parameters[0].split(/,/)[1] == nil
return 100
else
k = @map.events[i].pages[0].list[j].parameters[0].split(/,/)[1]
k = k.to_i
return 100+k
end
end
# 注释中有壁设置固定
if @map.events[i].pages[0].list[j].parameters[0].split(/,/)[0] == "壁设置固定"
if @map.events[i].pages[0].list[j].parameters[0].split(/,/)[1] == nil
return 200
else
k = @map.events[i].pages[0].list[j].parameters[0].split(/,/)[1]
k = k.to_i
return 200+k
end
end
end
return 0
end
#--------------------------------------------------------------------------
# ● 指定位置附近设置事件
#--------------------------------------------------------------------------
def set_defeventpos(id,x,y)
if standable2?(x,y)
@map.events[id].x=x
@map.events[id].y=y
return
end
for i in 1..([@map.width,@map.height].max)
if standable2?(x,y+i)
@map.events[id].x=x
@map.events[id].y=y+i
return
end
for j in 1..i
if standable2?(x-j,y+i)
@map.events[id].x=x-j
@map.events[id].y=y+i
return
end
if standable2?(x+j,y+i)
@map.events[id].x=x+j
@map.events[id].y=y+i
return
end
if standable2?(x-j,y-i)
@map.events[id].x=x-j
@map.events[id].y=y-i
return
end
if standable2?(x+j,y-i)
@map.events[id].x=x+j
@map.events[id].y=y-i
return
end
end
end
end
#--------------------------------------------------------------------------
# ● 指定位置附近的墙壁上设置事件
# p4 幅度
#--------------------------------------------------------------------------
def set_defeventpos_wall(id,x,y,p4)
if standable3?(x,y,p4)
@map.events[id].x=x
@map.events[id].y=y
return
end
for i in 1..([@map.width,@map.height].max)
if standable3?(x,y+i,p4)
@map.events[id].x=x
@map.events[id].y=y+i
return
end
for j in 1..i
if standable3?(x-j,y+i,p4)
@map.events[id].x=x-j
@map.events[id].y=y+i
return
end
if standable3?(x+j,y+i,p4)
@map.events[id].x=x+j
@map.events[id].y=y+i
return
end
if standable3?(x-j,y-i,p4)
@map.events[id].x=x-j
@map.events[id].y=y-i
return
end
if standable3?(x+j,y-i,p4)
@map.events[id].x=x+j
@map.events[id].y=y-i
return
end
end
end
end
#--------------------------------------------------------------------------
# ● 指定位置附近设置玩家
#--------------------------------------------------------------------------
def playerpos_reset(x,y)
if standable?(x,y)
$game_temp.player_new_x=x
$game_temp.player_new_y=y
return
end
for i in 1..([@map.width,@map.height].max)
if standable?(x,y+i)
$game_temp.player_new_x=x
$game_temp.player_new_y=y+i
return
end
for j in 0..i
if standable?(x-j,y+i)
$game_temp.player_new_x=x-j
$game_temp.player_new_y=y+i
return
end
if standable?(x+j,y+i)
$game_temp.player_new_x=x+j
$game_temp.player_new_y=y+i
return
end
if standable?(x-j,y-i)
$game_temp.player_new_x=x-j
$game_temp.player_new_y=y-i
return
end
if standable?(x+j,y-i)
$game_temp.player_new_x=x+j
$game_temp.player_new_y=y-i
return
end
end
end
end
#--------------------------------------------------------------------------
# ● 自己能通过吗?(障碍物元件)
# p1,p2 位置X,Y
#--------------------------------------------------------------------------
def standable_newtile?(p1,p2)
for i in [2, 1, 0]
tile_id = @tilesetting[p1, p2, i]
if tile_id == nil
return false
elsif @passages[tile_id] & 0x0f == 0x0f
return false
elsif @priorities[tile_id] == 0
return true
end
end
return true
end
#--------------------------------------------------------------------------
# ● 在指定位置站立吗?
# p1,p2 位置X,Y
#--------------------------------------------------------------------------
def standable?(p1,p2)
if @heightdata[p1,p2] != 0
return false
end
if @oneventdata[p1,p2] ==1
return false
end
for i in [2, 1, 0]
tile_id = @map.data[p1, p2, i]
if tile_id == nil
return false
elsif @passages[tile_id] & 0x0f == 0x0f
return false
elsif @priorities[tile_id] == 0
return true
end
end
return true
end
#--------------------------------------------------------------------------
# ● 放置在指定位置没问题吗?(考虑周围的事件)
# p1,p2 位置X,Y
#--------------------------------------------------------------------------
def standable2?(p1,p2)
# 站立位置判断
unless standable?(p1,p2)
return false
end
# 周围事件检查(能否前往尽头?)
# 去掉能到纵吗
if standable?(p1+1,p2-1) == false or
standable?(p1+1,p2) == false or
standable?(p1+1,p2+1) == false
if standable?(p1-1,p2-1) == false or
standable?(p1-1,p2) == false or
standable?(p1-1,p2+1) == false
# 去掉根本不能到纵的时候忽视
if standable?(p1,p2-1) == true and
standable?(p1,p2+1) == true
return false
end
end
end
# 去掉能到横吗
if standable?(p1+1,p2+1) == false or
standable?(p1,p2+1) == false or
standable?(p1-1,p2+1) == false
if standable?(p1+1,p2-1) == false or
standable?(p1,p2-1) == false or
standable?(p1-1,p2-1) == false
# 去掉根本不能到横的时候忽视
if standable?(p1-1,p2) == true and
standable?(p1+1,p2) == true
return false
end
end
end
if standable?(p1,p2-1) == false and
(standable?(p1-1,p2+1) == false or
standable?(p1,p2+1) == false or
standable?(p1+1,p2+1) == false)
return false
end
if standable?(p1,p2+1) == false and
(standable?(p1-1,p2-1) == false or
standable?(p1+1,p2-1) == false or
standable?(p1+1,p2-1) == false)
return false
end
if standable?(p1-1,p2) == false and
(standable?(p1+1,p2-1) == false or
standable?(p1+1,p2) == false or
standable?(p1+1,p2+1) == false)
return false
end
if standable?(p1+1,p2) == false and
(standable?(p1-1,p2-1) == false or
standable?(p1-1,p2) == false or
standable?(p1-1,p2+1) == false)
return false
end
return true
end
#--------------------------------------------------------------------------
# ● 放置在指定位置没问题吗?(墙壁版)
# p1,p2 位置X,Y
# p3 幅度
#--------------------------------------------------------------------------
def standable3?(p1,p2,p3)
# 站立位置判断
unless standable?(p1,p2+1)
return false
end
# 位置判断
if @oneventdata[p1,p2] == 1 or
@oneventdata[p1,p2-1] == 1 or
@heightdata[p1,p2-2] != 1 or
@heightdata[p1,p2-1] == 1 or
@heightdata[p1,p2+1] != 0
return false
end
for i in 1...p3+1
if@heightdata[p1+i,p2-2] != 1 or
@heightdata[p1+i,p2-1] == 1 or
@heightdata[p1+i,p2+1] != 0
return false
end
if@heightdata[p1-i,p2-2] != 1 or
@heightdata[p1-i,p2-1] == 1 or
@heightdata[p1-i,p2+1] != 0
return false
end
end
for i in 1...p3+1
if @oneventdata[p1+i,p2] == 1 or
@oneventdata[p1+i,p2-1] == 1
return false
end
if @oneventdata[p1-i,p2] == 1 or
@oneventdata[p1-i,p2-1] == 1
return false
end
end
return true
end
#--------------------------------------------------------------------------
# ● 地图元件信息变化
# p1,p2 起首处位置X,Y
# p3,p4 原参照位置X,Y
# p5 插入方法 0:通常 1:下一层 2:上一层 3:从下面 4:从上面 5:两边
#--------------------------------------------------------------------------
def set_mapdata(p1,p2,p3,p4,p5 = 0)
unless self.valid?(p1, p2)
return
end
if @tilesetting[p3,p4,0] != 0 # 0层普通放置
@map.data[p1,p2,0] = @tilesetting[p3,p4,0]
end
case p5
when 0 # 通常
if @tilesetting[p3,p4,1] != 0
@map.data[p1,p2,1] = @tilesetting[p3,p4,1]
end
if @tilesetting[p3,p4,2] != 0
@map.data[p1,p2,2] = @tilesetting[p3,p4,2]
end
when 1 # 放在下面
if @tilesetting[p3,p4,1] != 0
@map.data[p1,p2,1] = @tilesetting[p3,p4,1]
end
when 2 # 放在上面
if @tilesetting[p3,p4,1] != 0
@map.data[p1,p2,2] = @tilesetting[p3,p4,1]
end
when 3 # 从下面放置
if @tilesetting[p3,p4,1] != 0
if @map.data[p1,p2,1] != 0
@map.data[p1,p2,2] = @map.data[p1,p2,1]
end
@map.data[p1,p2,1] = @tilesetting[p3,p4,1]
end
when 4 # 从上面放置
if @tilesetting[p3,p4,1] != 0
if @map.data[p1,p2,2] != 0
@map.data[p1,p2,1] = @map.data[p1,p2,2]
end
@map.data[p1,p2,2] = @tilesetting[p3,p4,1]
end
when 5 # 从两边放置
if @tilesetting[p3,p4,1] != 0
@map.data[p1,p2,1] = @tilesetting[p3,p4,1]
end
if @tilesetting[p3,p4,1] != 0
@map.data[p1,p2,2] = @tilesetting[p3,p4,1]
end
when 6 # 能放置就放置
if @map.data[p1,p2,1] == 0
@map.data[p1,p2,1] = @tilesetting[p3,p4,1]
elsif @map.data[p1,p2,2] == 0
@map.data[p1,p2,2] = @tilesetting[p3,p4,1]
end
end
end
#--------------------------------------------------------------------------
# ● 地图元件信息变化2 >>没有范围外判断等
# p1,p2 起首处位置X,Y
# p3,p4 原参照位置X,Y
#--------------------------------------------------------------------------
def set_mapdata2(p1,p2,p3,p4)
@map.data[p1,p2,0] = @tilesetting[p3,p4,0]
@map.data[p1,p2,1] = @tilesetting[p3,p4,1]
@map.data[p1,p2,2] = @tilesetting[p3,p4,2]
end
#--------------------------------------------------------------------------
# ● 指定位置信息变化
# p1,p2 位置X,Y
# p3 值
#--------------------------------------------------------------------------
def set_height(p1,p2,p3)
return if p1<0
return if p1>=@map.width
return if p2<0
return if p2>=@map.height
@heightdata[p1,p2]=p3
end
#--------------------------------------------------------------------------
# ● 指定位置信息变化
# p1,p2 位置X,Y
# p3 值
#--------------------------------------------------------------------------
def set_grounddata(p1,p2,p3)
return if p1<0
return if p1>=@map.width
return if p2<0
return if p2>=@map.height
if @masksetting[@maskdata[p1,p2]] == true
if @targettype==0
if @chgtype==0
@heightdata[p1,p2]=p3
elsif @chgtype==1
@heightdata[p1,p2]+=p3
end
elsif @targettype==1
if @chgtype==0
@maskdata[p1,p2]=p3
elsif @chgtype==1
@maskdata[p1,p2]+=p3
end
end
end
end
#--------------------------------------------------------------------------
# ● 指定计算方法
# p1 对象 >> =0:高度 =1:地形 (現在、高度0=地面 1=墙壁
# p2 方法 >> =0:代入 =1:加算 地形只是遮照判断使用
#--------------------------------------------------------------------------
def rndmap_chtarget(p1,p2)
@targettype=p1
@chgtype=p2
end
#--------------------------------------------------------------------------
# ● 设定其他注释使用的值
# p1,p2 最小 X,Y
# p3,p4 最大 X,Y 设定制作道路的开始点,结束点等的时候使用
#--------------------------------------------------------------------------
def rndmap_setstat(p1,p2,p3,p4)
@minx=p1
@miny=p2
@maxx=p3
@maxy=p4
end
#--------------------------------------------------------------------------
# ● 设定地形遮照
# p1 = 对象地形 (-1= 全部)
# p2 = 变更值 (0= 禁止改写 1= 可以改写 2= 只有那个地形可以)
#--------------------------------------------------------------------------
def rndmap_chmask(p1,p2)
if p1>=0
if p2==0
@masksetting[p1]=false
elsif p2 == 1
@masksetting[p1]=true
elsif p2 == 2
for i in 0...100
@masksetting[i]=false
end
@masksetting[p1]=true
end
end
if p1==-1
if p2==0
for i in 0...100
@masksetting[i]=false
end
else
for i in 0...100
@masksetting[i]=true
end
end
end
end
#--------------------------------------------------------------------------
# ● 2点之间生成道路
# 起点、终点在rndmap_setstat里设定
# p1 = 改写值
# p2 = 途中点数(减的话以地图大小40*40为基准相对变化)
# p3 = 确保边缘的宽度
# p4 = 途中点连接方法 (0=直线连接 1=直角线(?)连接)
# p5 = 无视中继点的距离
#--------------------------------------------------------------------------
def rndmap_mkroad(p1,p2,p3,p4,p5 = 5)
p5 = 5 if p5 == nil
localdata = Table.new(@map.width,@map.height)
aposx = []
aposy = []
aflag = []
for i in [email]0...@map.width[/email]
for j in [email]0...@map.height[/email]
localdata[i,j] = 0
end
end
if p2<0
p2=(p2*-1)*@map.width*@map.height/40/40
end
aposx[0]=@minx
aposy[0]=@miny
aposx[1]=@maxx
aposy[1]=@maxy
if aposx[0]<0
aposx[0]=@map.width+aposx[0]
end
if (aposx[0]>=1000) and (aposx[0]<=1100)
aposx[0]=@map.width*(aposx[0]-1000)/100
end
if aposy[0]<0
aposy[0]=@map.height+aposy[0]
end
if (aposy[0]>=1000) and (aposy[0]<=1100)
aposy[0]=@map.height*(aposy[0]-1000)/100
end
if aposx[1]<0
aposx[1]=@map.width+aposx[1]
end
if (aposx[1]>=1000) and (aposx[1]<=1100)
aposx[1]=@map.width*(aposx[1]-1000)/100
end
if aposy[1]<0
aposy[1]=@map.height+aposy[1]
end
if (aposy[1]>=1000) and (aposy[1]<=1100)
aposy[1]=@map.height*(aposy[1]-1000)/100
end
if p4==0 or p4==1 or p4==2
if p4 == 2
i4 = rand(2)
end
aflag[0] = true
aflag[1] = false
for i in 2...(p2+2)
aposx[i] = rand(@map.width-p3*2) + p3
aposy[i] = rand(@map.height-p3*2) + p3
aflag[i] = false
end
i3=0
i1=aposx[i3]
i2=aposy[i3]
localdata[i1,i2] = 1
for i in 0...p2+2
i7=5000000
for j in 0...p2+2
if aflag[j] == false
i4 = aposx[j]-i1
i4=i4*-1 if i4 < 0
i5 = aposy[j]-i2
i5=i5*-1 if i5 < 0
if (i4**2+i5**2) <=(p5**2) and j != 1
aflag[j] = true
elsif i7 > (i4**2+i5**2)
i7=(i4**2+i5**2)
i6=j
end
end
end
# 起点ID:i3 终点ID:i6
if p4==0
if aposx[i3] > aposx[i6]
i8 = aposx[i3]
i9 = aposy[i3]
i10 = aposx[i6]
i11 = aposy[i6]
else
i8 = aposx[i6]
i9 = aposy[i6]
i10 = aposx[i3]
i11 = aposy[i3]
end
if i8!=i10
for i in 0..(i8-i10)
localdata[i+i10,(i9-i11)*i/(i8-i10)+i11] = 1
end
end
if aposy[i3] > aposy[i6]
i8 = aposx[i3]
i9 = aposy[i3]
i10 = aposx[i6]
i11 = aposy[i6]
else
i8 = aposx[i6]
i9 = aposy[i6]
i10 = aposx[i3]
i11 = aposy[i3]
end
if i9!=i11
for i in 0..(i9-i11)
localdata[(i8-i10)*i/(i9-i11)+i10,i+i11] = 1
end
end
end
if p4==1
i4 = rand(2)
if i4==0
for i in 0..([aposx[i3]-aposx[i6],aposx[i6]-aposx[i3]].max)
localdata[i+[aposx[i3],aposx[i6]].min,aposy[i3]] = 1
end
for i in 0..([aposy[i3]-aposy[i6],aposy[i6]-aposy[i3]].max)
localdata[aposx[i6],i+[aposy[i3],aposy[i6]].min] = 1
end
else
for i in 0..([aposx[i3]-aposx[i6],aposx[i6]-aposx[i3]].max)
localdata[i+[aposx[i3],aposx[i6]].min,aposy[i6]] = 1
end
for i in 0..([aposy[i3]-aposy[i6],aposy[i6]-aposy[i3]].max)
localdata[aposx[i3],i+[aposy[i3],aposy[i6]].min] = 1
end
end
end
i3=i6
i1=aposx[i3]
i2=aposy[i3]
aflag[i3]=true
if i3==1
break
end
end
end
for i in [email]0...@map.width[/email]
for j in [email]0...@map.height[/email]
if localdata[i,j] == 1
set_grounddata(i,j,p1)
end
end
end
end
#--------------------------------------------------------------------------
# ● 对象扩张
# p1 对象
# p2,p3 扩张幅度X,Y
# p4 扩张方法 (0=十字 1=四角)
#--------------------------------------------------------------------------
def rndmap_plus(p1,p2,p3,p4)
localdata = Table.new(@map.width,@map.height)
for i in [email]0...@map.width[/email]
for j in [email]0...@map.height[/email]
if @targettype==0
localdata[i,j] = @heightdata[i,j]
elsif @targettype==1
localdata[i,j] = @maskdata[i,j]
end
end
end
if p4 == 0
for i in [email]0...@map.width[/email]
for j in [email]0...@map.height[/email]
if p1==localdata[i,j]
for k in 1..p2
set_grounddata(i+k,j,p1)
set_grounddata(i-k,j,p1)
end
for k in 1..p3
set_grounddata(i,j+k,p1)
set_grounddata(i,j-k,p1)
end
end
end
end
elsif p4 == 1
for i in [email]0...@map.width[/email]
for j in [email]0...@map.height[/email]
if p1==localdata[i,j]
for k in (i-p2)..(i+p2)
for l in (j-p3)..(j+p3)
set_grounddata(k,l,p1)
end
end
end
end
end
end
end
#--------------------------------------------------------------------------
# ● 全部设定
# p1 值
#--------------------------------------------------------------------------
def rndmap_allchg(p1)
for i in [email]0...@map.width[/email]
for j in [email]0...@map.height[/email]
set_grounddata(i,j,p1)
end
end
end
#--------------------------------------------------------------------------
# ● 指定点
# p1 值
# p2,p3 位置X,Y
#--------------------------------------------------------------------------
def rndmap_putpos(p1,p2,p3)
i = rand(@maxx-@minx+1)+@minx
j = rand(@maxy-@miny+1)+@miny
for k in (p2-i)..(p2+i)
for l in (p3-j)..(p3+j)
set_grounddata(k,l,p1)
end
end
end
#--------------------------------------------------------------------------
# ● 周围
# p1 值
#--------------------------------------------------------------------------
def rndmap_edge(p1)
for i in [email]0...@map.width[/email]
set_grounddata(i,0,p1)
set_grounddata(i,@map.height-1,p1)
end
for i in [email]0...@map.height[/email]
set_grounddata(0,i,p1)
set_grounddata(@map.width-1,i,p1)
end
end
end
#==============================================================================
# □ RPG::MapInfo >>用subname取得 “,”后面的文字
#==============================================================================
module RPG
class MapInfo
def name
name = @name.split(/,/)[0]
return name != nil ? name : ''
end
def name=(str)
str2 = @name[/^[^,]*(,.*)/, 1]
@name = str2 != nil ? str + str2 : str
end
def subname(i = 1)
name = @name.split(/,/)[i]
return name != nil ? name : ""
end
end
end
#==============================================================================
# □ RPG::Event >>用subname取得 “,”后面的文字
#==============================================================================
module RPG
class Event
def name
name = @name.split(/,/)[0]
return name != nil ? name : ''
end
def name=(str)
str2 = @name[/^[^,]*(,.*)/, 1]
@name = str2 != nil ? str + str2 : str
end
def subname(i = 1)
name = @name.split(/,/)[i]
return name != nil ? name : ""
end
end
end
|
|