设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 732|回复: 3
打印 上一主题 下一主题

[已经过期] 求把xp的脚本转成va的

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
46 小时
注册时间
2014-1-11
帖子
49
跳转到指定楼层
1
发表于 2014-3-14 12:58:05 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
@Sion @喵呜喵5 @大神 ←(别告诉我真有叫大神的)现在我有三个xp版脚本,想转成va的,可是我对脚本一点都不懂,所以请大神们帮帮忙吧!
脚本范例:http://rpg.blue/forum.php?mod=viewthread&tid=344296
  1. #============================================================================
  2. #此脚本增加了一种深入的地图。
  3. #作者MGCaladtogel
  4. #中文版( 24/04/08 )
  5. #----------------------------------------------------------------------------
  6. #你必须添加到地图上的名字:
  7. # You must add to the map's name :
  8. #- [M7]  :激活Mode7
  9. #- [#xx] : xx是倾斜角(度) 。默认值为0 (正常地图)
  10. #- [Y]   : Y型地图循环
  11. #  [X]   :X地图的循环。此选项需要资源(较低的FPS )
  12. #- [A]   : 动画autotiles ( 4模式) 。此选项增加
  13. #          显着的加载时间,因此它可能会崩溃的大地图
  14. #          (SystemStackError)
  15. #- [C]   : 为中心的地图上的英雄(即使是小地图)
  16. #- [P]   : 有一个固定的全景
  17. #- [H]   : 有一个白色的地平线
  18. #- [OV]  : Overworld脚本调整(一Mewsterus的脚本功能)
  19. #
  20. # 或:
  21. # 看到“ $ mode7_maps_settings ”如下( L.48采取行动) ,以prapare设置
  22. #----------------------------------------------------------------------------
  23. #  其他命令(事件):
  24. #- $scene.spriteset.tilemap.mode7_set(new_angle)
  25. #  #重绘地图与new_angle
  26. #- $scene.spriteset.tilemap.mode7_set_p(new_angle)
  27. #  重绘地图逐步从目前的角度
  28. #- $scene.spriteset.tilemap.mode7_redraw
  29. #  重绘地图(有用下面的命令)
  30. #- $game_system.map_opacity = value
  31. #  界定不透明的Mode7地图(它需要重绘)
  32. #- $game_system.map_gradual_opacity = value
  33. #  要定义一个渐进的不透明的Mode7地图(它需要重绘)
  34. #  错误与横向循环
  35. #- $game_system.map_tone = Color.new(Red, Green, Blue)
  36. #  确定了基调Mode7地图(它需要重绘)
  37. #- $game_system.map_gradual_tone = Tone.new(Red, Green, Blue, Gray)
  38. #  要定义一个渐进的基调Mode7地图(它需要重绘)
  39. #- $game_system.horizon = value
  40. #  要定义视图的距离(默认是:960)(它需要重绘)
  41. #- $game_system.reset
  42. #  初始化前的选择
  43. #
  44. #- 如果要取得持平活动:
  45. #  刚刚添加评论的事件的命令清单: “平面”
  46. #
  47. #- 要处理的高度垂直事件:
  48. #  添加评论的事件的命令清单: “ Heigth X ”的,其中X是
  49. #============================================================================
  50. # 地图来自所有瓷砖的3层,不具有
  51. # terrain_tag的值为1或2 。
  52. # 其他瓷砖( terrain_tag = 1或2 )的形式要素,得出垂直,
  53. # 如第三层元素的旧版本。
  54. # 2地形编号用于垂直形式的内容
  55. $terrain_tags_vertical_tiles = [1,2] # You can modify these values
  56. # To access maps names
  57. $data_maps = load_data("Data/MapInfos.rxdata")
  58. $mode7_maps_settings = {}
  59. # Prepare your own settings for mode7 maps
  60. # Just put the first parameter in a map's name
  61. # For example :
  62. $mode7_maps_settings["Worldmap"] = ["#60", "X", "Y", "A", "H", "OV"]
  63. # -> will  be called  when "Worldmap" is included in the name
  64. $mode7_maps_settings["Smallslant"] = ["#20", "A", "S"]
  65. # Add any number of settings you want

  66. # enable/disable mode7 for mode7 maps (not on the fly, just when the map is loaded), enabled by default
  67. $enable_mode7_number = 5 # switch number : change this value !

  68. #============================================================================
  69. # ■ Game_System
  70. #----------------------------------------------------------------------------
  71. # Add attributes to this class
  72. #============================================================================

  73. class Game_System
  74.   attr_accessor :mode7 # false : normal map / true : mode 7
  75.   attr_accessor :loop_x # true : horizontal-looping map
  76.   attr_accessor :loop_y # true : vertical-looping map
  77.   attr_accessor :always_scroll # true : to center the camera around the hero
  78.   attr_accessor :map_tone # mode7 map's tone (Color)
  79.   attr_accessor :map_opacity # mode7 map's opacity (0..255)
  80.   attr_accessor :animated # true : animated autotiles for mode7 maps
  81.   attr_accessor :white_horizon # true : white line horizon for mode7 maps
  82.   attr_accessor :angle # mode7 map's slant angle (in degree)
  83.   attr_accessor :horizon # horizon's distance
  84.   attr_accessor :fixed_panorama # true : to fix the panorama (no scrolling any more)
  85.   attr_accessor :ov # true : Overworld Sprite Resize (smaller hero's sprite)
  86.   attr_accessor :ov_zoom # resize's value with ov
  87.   attr_accessor :map_gradual_opacity # mode7 map's gradual opacity (0..255)
  88.   attr_accessor :map_gradual_tone # mode7 map's gradual tone (Color)
  89.   #--------------------------------------------------------------------------
  90.   # * Object Initialization
  91.   #--------------------------------------------------------------------------
  92.   alias initialize_mode7_game_system initialize
  93.   def initialize
  94.     initialize_mode7_game_system
  95.     self.mode7 = false
  96.     self.loop_x = false
  97.     self.loop_y = false
  98.     self.always_scroll = false
  99.     self.animated = false
  100.     self.white_horizon = false
  101.     self.angle = 0
  102.     self.fixed_panorama = false
  103.     self.ov = false
  104.     self.ov_zoom = 0.6
  105.     reset
  106.   end
  107.   #--------------------------------------------------------------------------
  108.   # * Reset the values for opacity, tone and horizon's distance
  109.   #--------------------------------------------------------------------------
  110.   def reset
  111.     self.map_opacity = 255
  112.     self.map_tone = Color.new(0,0,0,0)
  113.     self.horizon = 960 # default value, equivalent to 30 tiles
  114.     self.map_gradual_opacity = 0
  115.     self.map_gradual_tone = Tone.new(0,0,0,0)
  116.   end
  117. end

  118. #============================================================================
  119. # ■ Tilemap_mode7
  120. #----------------------------------------------------------------------------
  121. # This new Tilemap class handles the drawing of a mode7 map
  122. #============================================================================

  123. class Tilemap_mode7
  124.   attr_accessor  :maps_list # contains map's graphics
  125.   attr_accessor  :map_ground # original map's graphic to handle flat events
  126.   attr_accessor  :tone_values # tone values for each line (Hash)
  127.   attr_accessor  :opacity_values # opacity values for each line (Hash)
  128.   attr_reader :spriteset
  129.   #--------------------------------------------------------------------------
  130.   # * Object Initialization
  131.   #     viewport  : viewport
  132.   #--------------------------------------------------------------------------
  133.   def initialize(viewport, spriteset)
  134.     @spriteset = spriteset
  135.     @id = $game_map.map_id # map's ID : to load or save the map in Cache
  136.     @maps_list = [] # contains map's drawings (Bitmap)
  137.     @disp_y = $game_map.display_y # @disp_y : tilemap's display_y
  138.     @disp_x = $game_map.display_x # @disp_x : tilemap's display_x
  139.     [url=home.php?mod=space&uid=291977]@height[/url] = 32 * $game_map.height # @height : map's height (in pixel)
  140.     @width = 32 * $game_map.width # @width : map's width (in pixel)
  141.     $game_temp.height = @height
  142.     # map's drawings are loaded if already in Cache
  143.     if RPG::Cache_Carte.in_cache(@id)
  144.       @map = RPG::Cache_Carte.load(@id)
  145.       @maps_list.push(@map)
  146.       @map_ground = RPG::Cache_Carte.load(@id, 4) # to handle flat events
  147.       if $game_system.animated
  148.         @map_2 = RPG::Cache_Carte.load(@id, 1)
  149.         @map_3 = RPG::Cache_Carte.load(@id, 2)
  150.         @map_4 = RPG::Cache_Carte.load(@id, 3)
  151.         @maps_list.push(@map_2)
  152.         @maps_list.push(@map_3)
  153.         @maps_list.push(@map_4)
  154.       end
  155.     else # draw the map and save it in the Cache
  156.       draw_map
  157.     end
  158.     # create vertical elements from tiles
  159.     data_V = Data_Vertical_Sprites.new(viewport)
  160.     # @sprites_V : list of vertical sprites (Sprite_V)
  161.     @sprites_V = data_V.list_sprites_V
  162.     # @sprites_V_animated : list of animated vertical sprites (Sprite_V)
  163.     @sprites_V_animated = data_V.list_sprites_V_animated
  164.     [url=home.php?mod=space&uid=124954]@Angle[/url] = $game_system.angle # map's slant angle (in degree)
  165.     @distance_h = 480 # distance between the map's center and the vanishing point
  166.     @pivot = 256 # screenline's number of the slant's pivot
  167.     @index_animated = 0 # 0..3 : index of animated tiles pattern
  168.     @viewport = viewport
  169.     @tone_values = {} # list of the tone values for each line
  170.     @opacity_values = {} # list of the opacity values for each line
  171.     init_sprites(@angle) # initialize screenlines sprites
  172.   end
  173.   #--------------------------------------------------------------------------
  174.   # * Dispose
  175.   #--------------------------------------------------------------------------
  176.   def dispose
  177.     # dispose of @sprites (scanlines), @sprites_V (vertical_sprites), and
  178.     # @sprites_loop_x (additional scanlines for horizontal looping)
  179.     for sprite in @sprites + @sprites_V + @sprites_loop_x
  180.       sprite.dispose
  181.     end
  182.     @sprites.clear
  183.     @sprites_loop_x.clear
  184.     @sprites_V.clear
  185.     @sprites_V_animated.clear
  186.     @maps_list.clear
  187.     $game_system.angle = @angle
  188.   end
  189.   #--------------------------------------------------------------------------
  190.   # * Increase slant's angle
  191.   #--------------------------------------------------------------------------
  192.   def increase_angle
  193.     return if @angle == 88
  194.     @angle = [@angle + 2, 88].min # angle's value between 0 and 88 degrees
  195.     @sprites.clear
  196.     @sprites_loop_x.clear
  197.     init_sprites(@angle) # reinitialize screenlines sprites
  198.   end
  199.   #--------------------------------------------------------------------------
  200.   # * Decrease slant's angle
  201.   #--------------------------------------------------------------------------
  202.   def decrease_angle
  203.     return if @angle == 0
  204.     @angle = [@angle - 2, 0].max # angle's value between 0 and 88 degrees
  205.     @sprites.clear
  206.     @sprites_loop_x.clear
  207.     init_sprites(@angle) # reinitialize screenlines sprites
  208.   end
  209.   #--------------------------------------------------------------------------
  210.   # * Slide from the current angle into the target value
  211.   #     value  : target angle's value (in degree)
  212.   #--------------------------------------------------------------------------
  213.   def mode7_set_p(value)
  214.     while value > @angle
  215.       increase_angle
  216.       spriteset.update
  217.       Graphics.update
  218.     end
  219.     while value < @angle
  220.       decrease_angle
  221.       spriteset.update
  222.       Graphics.update
  223.     end
  224.   end
  225.   #--------------------------------------------------------------------------
  226.   # * Redraw the map instantaneously with the new slant angle's value
  227.   #     value  : target angle's value (in degree)
  228.   #--------------------------------------------------------------------------
  229.   def mode7_set(value)
  230.     @angle = [[value, 0].max, 89].min
  231.     @sprites.clear
  232.     @sprites_loop_x.clear
  233.     init_sprites(@angle) # reinitialize screenlines sprites
  234.     update
  235.     Graphics.update
  236.   end
  237.   #--------------------------------------------------------------------------
  238.   # * Reinitialize screenlines sprites
  239.   #--------------------------------------------------------------------------
  240.   def mode7_redraw
  241.     @sprites.clear
  242.     @sprites_loop_x.clear
  243.     init_sprites(@angle) # reinitialize scanlines
  244.     update
  245.     Graphics.update
  246.   end
  247.   #--------------------------------------------------------------------------
  248.   # * Create sprites equivalent to scanlines
  249.   #     value  : target angle's value (in degree)
  250.   #--------------------------------------------------------------------------
  251.   def init_sprites(angle)
  252.     @horizon = $game_system.horizon
  253.     angle_rad = (Math::PI * angle) / 180 # angle in radian
  254.     @sprites = [] # list of the scanlines sprites (Sprite)
  255.     @sprites_loop_x = [] # list of the additionnal sprites (for X-looping)
  256.     cos_angle = Math.cos(angle_rad)
  257.     sin_angle = Math.sin(angle_rad)
  258.     # save values in $game_temp
  259.     $game_temp.distance_h = @distance_h
  260.     $game_temp.pivot = @pivot
  261.     $game_temp.cos_angle = cos_angle
  262.     $game_temp.sin_angle = sin_angle
  263.     # h0, z0 : intermediate values
  264.     h0 = (- @distance_h * @pivot * cos_angle).to_f /
  265.     (@distance_h + @pivot * sin_angle) + @pivot
  266.     z0 = @distance_h.to_f / (@distance_h + @pivot * sin_angle)
  267.     $game_temp.slope_value = (1.0 - z0) / (@pivot - h0)
  268.     $game_temp.corrective_value = 1.0 - @pivot * $game_temp.slope_value
  269.     last_line = - @pivot - @horizon # last_line : the highest line that is drawn
  270.     height_limit = (@distance_h * last_line * cos_angle).to_f /
  271.     (@distance_h - last_line * sin_angle) + @pivot # the line corresponding to
  272.     # the last_line in the warped reference = horizon's line
  273.     $game_temp.height_limit = height_limit
  274.     # constant to handle gradual opacity
  275.     k2lim = ((@distance_h * last_line).to_f /
  276.       (@distance_h * cos_angle + last_line * sin_angle)).to_i
  277.     # one sprite is created for each screenline
  278.     for j in 0..479
  279.       next if j < height_limit # if the line is further than the horizon's line,
  280.       # no sprite is created
  281.       i = j - @pivot # y-reference is the pivot's line
  282.       sprite = Sprite.new(@viewport)
  283.       sprite.x = 320 # x-reference is the vertical line in the middle of the screen
  284.       sprite.y = j
  285.       sprite.z = - 99999 # map must not mask vertical elements
  286.       sprite.y_origin_bitmap = (@distance_h * i).to_f /
  287.       (@distance_h * cos_angle + i * sin_angle) + @pivot
  288.       sprite.y_origin_bitmap_i = (sprite.y_origin_bitmap + 0.5).to_i
  289.       sprite.y_origin_bitmap_i %= @height if $game_system.loop_y
  290.       sprite.zoom_x = $game_temp.slope_value * j + $game_temp.corrective_value
  291.       sprite.length = 2 + (640.to_f / sprite.zoom_x).to_i
  292.       sprite.x_origin_bitmap_i = ((642 - sprite.length) / 2)
  293.       sprite.x_origin_bitmap_i %= @width if $game_system.loop_x
  294.       sprite.x_origin_bitmap = (sprite.x_origin_bitmap_i).to_f
  295.       sprite.ox = sprite.length / 2
  296.       sprite.bitmap = @map
  297.       # horizontal translation to center around the hero
  298.       if @disp_x != 0
  299.         sprite.x_origin_bitmap += @disp_x / 4
  300.         sprite.x_origin_bitmap_i = (sprite.x_origin_bitmap).to_i
  301.         sprite.x_origin_bitmap_i %= @width if $game_system.loop_x
  302.       end
  303.       # vertical translation to center around the hero
  304.       if @disp_y != 0
  305.         sprite.y_origin_bitmap += @disp_y / 4
  306.         sprite.y_origin_bitmap_i = (sprite.y_origin_bitmap + 0.5).to_i
  307.         sprite.y_origin_bitmap_i %= @height if $game_system.loop_y
  308.       end
  309.       # handle opacity and tone
  310.       k2 = ((@distance_h * i).to_f /
  311.       (@distance_h * cos_angle + i * sin_angle)).to_i
  312.       k2 = 0 if k2 > 0
  313.       k_red = (- k2.to_f/k2lim * $game_system.map_gradual_tone.red).to_i
  314.       k_green = (- k2.to_f/k2lim * $game_system.map_gradual_tone.green).to_i
  315.       k_blue = (- k2.to_f/k2lim * $game_system.map_gradual_tone.blue).to_i
  316.       k_gray = (- k2.to_f/k2lim * $game_system.map_gradual_tone.gray).to_i
  317.       k2 = (- k2.to_f/k2lim * $game_system.map_gradual_opacity).to_i
  318.       sprite.tone = Tone.new(k_red, k_green, k_blue, k_gray)
  319.       sprite.opacity = 255 - k2
  320.       sprite.opacity *= ($game_system.map_opacity).to_f / 255
  321.       sprite.color = $game_system.map_tone
  322.       # white horizon's line
  323.       k = j - height_limit
  324.       k = 500 / k
  325.       if $game_system.white_horizon
  326.         tone_red = sprite.tone.red + k
  327.         tone_green = sprite.tone.green + k
  328.         tone_blue = sprite.tone.blue + k
  329.         tone_gray = sprite.tone.gray + k
  330.         sprite.tone = Tone.new(tone_red, tone_green, tone_blue, tone_gray)
  331.       end
  332.       @tone_values[j] = sprite.tone
  333.       @opacity_values[j] = sprite.opacity
  334.       # set sprite's graphics
  335.       sprite.src_rect.set(sprite.x_origin_bitmap_i, sprite.y_origin_bitmap_i,
  336.       sprite.length, 1)
  337.       @sprites.push(sprite)
  338.       if $game_system.loop_x and j < @pivot
  339.         # additional sprite to handle horizontal looping
  340.         sprite2 = Sprite.new(@viewport)
  341.         sprite2.x = 320
  342.         sprite2.y = j
  343.         sprite2.z = - 99999
  344.         sprite2.y_origin_bitmap = sprite.y_origin_bitmap
  345.         sprite2.y_origin_bitmap_i = sprite.y_origin_bitmap_i
  346.         sprite2.zoom_x = sprite.zoom_x
  347.         sprite2.length = sprite.length
  348.         sprite2.x_origin_bitmap_i = sprite.x_origin_bitmap_i - @width
  349.         sprite2.x_origin_bitmap = sprite.x_origin_bitmap_i - @width
  350.         sprite2.ox = sprite.ox
  351.         sprite2.bitmap = @map
  352.         sprite2.opacity = sprite.opacity
  353.         sprite2.color = sprite.color
  354.         sprite2.tone = sprite.tone
  355.         sprite2.src_rect.set(sprite2.x_origin_bitmap_i, sprite2.y_origin_bitmap_i,
  356.         sprite2.length, 1)
  357.         @sprites_loop_x.push(sprite2)
  358.       end
  359.     end
  360.   end
  361.   #--------------------------------------------------------------------------
  362.   # * Update the screenlines sprites and the vertical sprites
  363.   #   compare tilemap's display with map's display
  364.   #--------------------------------------------------------------------------
  365.   def update
  366.     # update screenlines sprites
  367.     if @disp_y < $game_map.display_y
  368.       difference = $game_map.display_y - @disp_y
  369.       @disp_y += difference
  370.       for sprite in @sprites + @sprites_loop_x
  371.         sprite.y_origin_bitmap += difference.to_f / 4
  372.         sprite.y_origin_bitmap_i = (sprite.y_origin_bitmap+0.5).to_i
  373.         sprite.y_origin_bitmap_i %= @height if $game_system.loop_y
  374.         sprite.src_rect.set(sprite.x_origin_bitmap_i, sprite.y_origin_bitmap_i,
  375.         sprite.length, 1)
  376.       end
  377.     end
  378.     if @disp_y > $game_map.display_y
  379.       difference = @disp_y - $game_map.display_y
  380.       @disp_y -= difference
  381.       for sprite in @sprites + @sprites_loop_x
  382.         sprite.y_origin_bitmap -= difference.to_f / 4
  383.         sprite.y_origin_bitmap_i = (sprite.y_origin_bitmap+0.5).to_i
  384.         sprite.y_origin_bitmap_i %= @height if $game_system.loop_y
  385.         sprite.src_rect.set(sprite.x_origin_bitmap_i, sprite.y_origin_bitmap_i,
  386.         sprite.length, 1)
  387.       end
  388.     end
  389.     if @disp_x < $game_map.display_x
  390.       difference = $game_map.display_x - @disp_x
  391.       @disp_x += difference
  392.       for sprite in @sprites
  393.         sprite.x_origin_bitmap += difference.to_f / 4
  394.         sprite.x_origin_bitmap_i = (sprite.x_origin_bitmap).to_i
  395.         sprite.x_origin_bitmap_i %= @width if $game_system.loop_x
  396.         sprite.src_rect.set(sprite.x_origin_bitmap_i, sprite.y_origin_bitmap_i,
  397.         sprite.length, 1)
  398.       end
  399.       for sprite in @sprites_loop_x
  400.         sprite.x_origin_bitmap += difference.to_f / 4
  401.         sprite.x_origin_bitmap_i = (sprite.x_origin_bitmap).to_i
  402.         sprite.x_origin_bitmap_i %= @width
  403.         sprite.x_origin_bitmap_i -= @width
  404.         sprite.src_rect.set(sprite.x_origin_bitmap_i, sprite.y_origin_bitmap_i,
  405.         sprite.length, 1)
  406.       end
  407.     end
  408.     if @disp_x > $game_map.display_x
  409.       difference = @disp_x - $game_map.display_x
  410.       @disp_x -= difference
  411.       for sprite in @sprites
  412.         sprite.x_origin_bitmap -= difference.to_f / 4
  413.         sprite.x_origin_bitmap_i = (sprite.x_origin_bitmap).to_i
  414.         sprite.x_origin_bitmap_i %= @width if $game_system.loop_x
  415.         sprite.src_rect.set(sprite.x_origin_bitmap_i, sprite.y_origin_bitmap_i,
  416.         sprite.length, 1)
  417.       end
  418.       for sprite in @sprites_loop_x
  419.         sprite.x_origin_bitmap -= difference.to_f / 4
  420.         sprite.x_origin_bitmap_i = (sprite.x_origin_bitmap).to_i
  421.         sprite.x_origin_bitmap_i %= @width
  422.         sprite.x_origin_bitmap_i -= @width
  423.         sprite.src_rect.set(sprite.x_origin_bitmap_i, sprite.y_origin_bitmap_i,
  424.         sprite.length, 1)
  425.       end
  426.     end
  427.     # update vertical sprites
  428.     for sprite in @sprites_V
  429.       sprite.update
  430.     end
  431.   end
  432.   #--------------------------------------------------------------------------
  433.   # * Update animation for animated tiles
  434.   #--------------------------------------------------------------------------
  435.   def update_animated
  436.     @index_animated += 1
  437.     @index_animated %= 4
  438.     map = @maps_list[@index_animated]
  439.     # update screenlines sprites
  440.     for sprite in @sprites + @sprites_loop_x
  441.       sprite.bitmap = map
  442.       sprite.src_rect.set(sprite.x_origin_bitmap_i, sprite.y_origin_bitmap_i,
  443.       sprite.length, 1)
  444.     end
  445.     # update vertical sprites
  446.     for sprite in @sprites_V_animated
  447.       sprite.update_animated(@index_animated)
  448.     end
  449.   end
  450.   #--------------------------------------------------------------------------
  451.   # * Create bitmaps representing the map
  452.   #--------------------------------------------------------------------------
  453.   def draw_map
  454.     data = $game_map.data
  455.     # Table where animated tiles are flagged
  456.     data_animated = Table.new($game_map.width, $game_map.height)
  457.     # bigger maps to handle horizontal looping
  458.     offset = ($game_system.loop_x ? 640 : 0)
  459.     @map = Bitmap.new(@width + offset, @height)
  460.     @maps_list.push(@map)
  461.     rect = Rect.new(0, 0, 32, 32)
  462.     # create autotiles graphics
  463.     RPG::Cache.clear
  464.     @autotiles = []
  465.     for i in 0..6
  466.       autotile_name = $game_map.autotile_names[i]
  467.       fichier = RPG::Cache.autotile(autotile_name)
  468.       for l in 0..3
  469.         data_autotile = Data_Autotiles.new(fichier,l)
  470.         data_autotile.number = 4*i + l
  471.         RPG::Cache.save_autotile(data_autotile, data_autotile.number)
  472.         @autotiles.push(data_autotile)
  473.       end
  474.     end
  475.     # scan map's data to draw it
  476.     for i in 0...$game_map.height
  477.       for j in 0...$game_map.width
  478.         data_animated[j, i] = 0
  479.         # tile's ID for the first layer
  480.         value1 = data[j, i, 0].to_i
  481.         # prevent from drawing a vertical tile
  482.         value1 = ($terrain_tags_vertical_tiles.include?($game_map.terrain_tags[value1]) ?
  483.         0 : value1)
  484.         # value1 != 0
  485.         if value1 != 0
  486.           # tile's ID for the second layer
  487.           value2 = data[j, i, 1].to_i
  488.           # prevent from drawing a vertical tile
  489.           value2 = ($terrain_tags_vertical_tiles.include?($game_map.terrain_tags[value2]) ?
  490.           0 : value2)
  491.           # tile's ID for the third layer
  492.           value3 = data[j, i, 2].to_i
  493.           # prevent from drawing a vertical tile
  494.           value3 = ($terrain_tags_vertical_tiles.include?($game_map.terrain_tags[value3]) ?
  495.           0 : value3)
  496.           # value1 != 0, value2 = 0
  497.           if value2 == 0
  498.             # value1 != 0, value2 = 0, value3 = 0
  499.             if value3 == 0
  500.               # value1 associated with a normal autotile
  501.               if value1 > 383
  502.                 bitmap = RPG::Cache.tile($game_map.tileset_name, value1, 0)
  503.                 @map.blt(32*j, 32*i, bitmap, rect)
  504.                 if $game_system.loop_x and j.between?(0, 19)
  505.                   @map.blt(32*(j+$game_map.width), 32*i, bitmap, rect)
  506.                 end
  507.               # value1 associated with an autotile
  508.               else
  509.                 num = 4*((value1 / 48) - 1)
  510.                 bitmap = RPG::Cache.autotile_base(num, value1)
  511.                 if @autotiles[num].animated
  512.                   data_animated[j, i] = 1
  513.                 end
  514.                 @map.blt(32*j, 32*i, bitmap, rect)
  515.                 if $game_system.loop_x and j.between?(0, 19)
  516.                   @map.blt(32*(j+$game_map.width), 32*i, bitmap, rect)
  517.                 end
  518.               end
  519.             # value1 != 0, value2 = 0, value3 != 0
  520.             else
  521.               bitmap = RPG::Cache_Tile.load(value1, value3)
  522.               # value1 associated with an autotile
  523.               if value1 < 384
  524.                 num = 4*((value1 / 48) - 1)
  525.                 data_animated[j, i] = 1 if @autotiles[num].animated
  526.               end
  527.               # value3 associated with an autotile
  528.               if value3 < 384
  529.                 num = 4*((value3 / 48) - 1)
  530.                 data_animated[j, i] = 1 if @autotiles[num].animated
  531.               end
  532.               @map.blt(32*j, 32*i, bitmap, rect)
  533.               if $game_system.loop_x and j.between?(0, 19)
  534.                 @map.blt(32*(j+$game_map.width), 32*i, bitmap, rect)
  535.               end
  536.             end
  537.           # value1 != 0, value2 != 0
  538.           else
  539.             # value1 != 0, value2 != 0, value3 = 0
  540.             if value3 == 0
  541.               bitmap = RPG::Cache_Tile.load(value1, value2)
  542.               # value1 associated with an autotile
  543.               if value1 < 384
  544.                 num = 4*((value1 / 48) - 1)
  545.                 data_animated[j, i] = 1 if @autotiles[num].animated
  546.               end
  547.               # value2 associated with an autotile
  548.               if value2 < 384
  549.                 num = 4*((value2 / 48) - 1)
  550.                 data_animated[j, i] = 1 if @autotiles[num].animated
  551.               end
  552.               @map.blt(32*j, 32*i, bitmap, rect)
  553.               if $game_system.loop_x and j.between?(0, 19)
  554.                 @map.blt(32*(j+$game_map.width), 32*i, bitmap, rect)
  555.               end
  556.             # value1 != 0, value2 != 0, value3 != 0
  557.             else
  558.               bitmap = RPG::Cache_Tile.load2(value1, value2, value3)
  559.               # value1 associated with an autotile
  560.               if value1 < 384
  561.                 num = 4*((value1 / 48) - 1)
  562.                 data_animated[j, i] = 1 if @autotiles[num].animated
  563.               end
  564.               # value2 associated with an autotile
  565.               if value2 < 384
  566.                 num = 4*((value2 / 48) - 1)
  567.                 data_animated[j, i] = 1 if @autotiles[num].animated
  568.               end
  569.               # value3 associated with an autotile
  570.               if value3 < 384
  571.                 num = 4*((value3 / 48) - 1)
  572.                 data_animated[j, i] = 1 if @autotiles[num].animated
  573.               end
  574.               @map.blt(32*j, 32*i, bitmap, rect)
  575.               if $game_system.loop_x and j.between?(0, 19)
  576.                 @map.blt(32*(j+$game_map.width), 32*i, bitmap, rect)
  577.               end
  578.             end
  579.           end
  580.         # value1 = 0
  581.         else
  582.           value2 = data[j, i, 1].to_i
  583.           value2 = ($terrain_tags_vertical_tiles.include?($game_map.terrain_tags[value2]) ?
  584.           0 : value2)
  585.           value3 = data[j, i, 2].to_i
  586.           value3 = ($terrain_tags_vertical_tiles.include?($game_map.terrain_tags[value3]) ?
  587.           0 : value3)
  588.           # value1 = 0, value2 = 0
  589.           if value2 == 0
  590.             # value1 = 0, value2 = 0, value3 != 0
  591.             if value3 != 0
  592.               # value3 associated with a normal tile
  593.               if value3 > 383
  594.                 bitmap = RPG::Cache.tile($game_map.tileset_name, value3, 0)
  595.                 @map.blt(32*j, 32*i, bitmap, rect)
  596.                 if $game_system.loop_x and j.between?(0, 19)
  597.                   @map.blt(32*(j+$game_map.width), 32*i, bitmap, rect)
  598.                 end
  599.               # value3 associated with an autotile
  600.               else
  601.                 num = 4*((value3 / 48) - 1)
  602.                 bitmap = RPG::Cache.autotile_base(num, value3)
  603.                 if @autotiles[num].animated
  604.                   data_animated[j, i] = 1
  605.                 end
  606.                 @map.blt(32*j, 32*i, bitmap, rect)
  607.                 if $game_system.loop_x and j.between?(0, 19)
  608.                   @map.blt(32*(j+$game_map.width), 32*i, bitmap, rect)
  609.                 end
  610.               end
  611.             end
  612.           # value1 = 0, value2 != 0
  613.           else
  614.             # value1 = 0, value2 != 0, value3 = 0
  615.             if value3 == 0
  616.               # value2 associated with a normal tile
  617.               if value2 > 383
  618.                 bitmap = RPG::Cache.tile($game_map.tileset_name, value2, 0)
  619.                 @map.blt(32*j, 32*i, bitmap, rect)
  620.                 if $game_system.loop_x and j.between?(0, 19)
  621.                   @map.blt(32*(j+$game_map.width), 32*i, bitmap, rect)
  622.                 end
  623.               # value2 associated with an autotile
  624.               else
  625.                 num = 4*((value2 / 48) - 1)
  626.                 bitmap = RPG::Cache.autotile_base(num, value2)
  627.                 if @autotiles[num].animated
  628.                   data_animated[j, i] = 1
  629.                 end
  630.                 @map.blt(32*j, 32*i, bitmap, rect)
  631.                 if $game_system.loop_x and j.between?(0, 19)
  632.                   @map.blt(32*(j+$game_map.width), 32*i, bitmap, rect)
  633.                 end
  634.               end
  635.             # value1 = 0, value2 != 0, value3 != 0
  636.             else
  637.               bitmap = RPG::Cache_Tile.load(value2, value3)
  638.               # value2 associated with an autotile
  639.               if value2 < 384
  640.                 num = 4*((value2 / 48) - 1)
  641.                 data_animated[j, i] = 1 if @autotiles[num].animated
  642.               end
  643.               # value3 associated with an autotile
  644.               if value3 < 384
  645.                 num = 4*((value3 / 48) - 1)
  646.                 data_animated[j, i] = 1 if @autotiles[num].animated
  647.               end
  648.               @map.blt(32*j, 32*i, bitmap, rect)
  649.               if $game_system.loop_x and j.between?(0, 19)
  650.                 @map.blt(32*(j+$game_map.width), 32*i, bitmap, rect)
  651.               end
  652.             end
  653.           end
  654.         end
  655.       end
  656.     end
  657.     # save the map's drawing in the Cache
  658.     RPG::Cache_Carte.save(@id, @map)
  659.     @map_ground = @map.clone
  660.     # save a copy of the map to handle flat events
  661.     RPG::Cache_Carte.save(@id, @map_ground, 4)
  662.     return if !$game_system.animated
  663.     # create 3 other maps in case of animated tiles
  664.     @map_2 = @map.clone
  665.     @map_3 = @map.clone
  666.     @map_4 = @map.clone
  667.     @maps_list.push(@map_2)
  668.     @maps_list.push(@map_3)
  669.     @maps_list.push(@map_4)
  670.     for i in 0...$game_map.height
  671.       for j in 0...$game_map.width
  672.         next if data_animated[j, i].to_i == 0
  673.         # modify the tile if it is flagged as animated
  674.         value1 = data[j, i, 0].to_i
  675.         value2 = data[j, i, 1].to_i
  676.         value3 = data[j, i, 2].to_i
  677.         # prevent from drawing a vertical tile
  678.         value1 = ($terrain_tags_vertical_tiles.include?($game_map.terrain_tags[value1]) ?
  679.         0 : value1)
  680.         value2 = ($terrain_tags_vertical_tiles.include?($game_map.terrain_tags[value2]) ?
  681.         0 : value2)
  682.         value3 = ($terrain_tags_vertical_tiles.include?($game_map.terrain_tags[value3]) ?
  683.         0 : value3)
  684.         if value1 != 0
  685.           if value2 == 0
  686.             if value3 == 0
  687.               num = 4*((value1 / 48) - 1)
  688.               bitmap_2 = RPG::Cache.autotile_base(num+1, value1)
  689.               bitmap_3 = RPG::Cache.autotile_base(num+2, value1)
  690.               bitmap_4 = RPG::Cache.autotile_base(num+3, value1)
  691.               @map_2.blt(32*j, 32*i, bitmap_2, rect)
  692.               @map_3.blt(32*j, 32*i, bitmap_3, rect)
  693.               @map_4.blt(32*j, 32*i, bitmap_4, rect)
  694.               if $game_system.loop_x and j.between?(0, 19)
  695.                 @map_2.blt(32*(j+$game_map.width), 32*i, bitmap_2, rect)
  696.                 @map_3.blt(32*(j+$game_map.width), 32*i, bitmap_3, rect)
  697.                 @map_4.blt(32*(j+$game_map.width), 32*i, bitmap_4, rect)
  698.               end
  699.             else
  700.               bitmap_2 = RPG::Cache_Tile.load(value1, value3, 1)
  701.               bitmap_3 = RPG::Cache_Tile.load(value1, value3, 2)
  702.               bitmap_4 = RPG::Cache_Tile.load(value1, value3, 3)
  703.               @map_2.blt(32*j, 32*i, bitmap_2, rect)
  704.               @map_3.blt(32*j, 32*i, bitmap_3, rect)
  705.               @map_4.blt(32*j, 32*i, bitmap_4, rect)
  706.               if $game_system.loop_x and j.between?(0, 19)
  707.                 @map_2.blt(32*(j+$game_map.width), 32*i, bitmap_2, rect)
  708.                 @map_3.blt(32*(j+$game_map.width), 32*i, bitmap_3, rect)
  709.                 @map_4.blt(32*(j+$game_map.width), 32*i, bitmap_4, rect)
  710.               end
  711.             end
  712.           else
  713.             if value3 == 0
  714.               bitmap_2 = RPG::Cache_Tile.load(value1, value2, 1)
  715.               bitmap_3 = RPG::Cache_Tile.load(value1, value2, 2)
  716.               bitmap_4 = RPG::Cache_Tile.load(value1, value2, 3)
  717.               @map_2.blt(32*j, 32*i, bitmap_2, rect)
  718.               @map_3.blt(32*j, 32*i, bitmap_3, rect)
  719.               @map_4.blt(32*j, 32*i, bitmap_4, rect)
  720.               if $game_system.loop_x and j.between?(0, 19)
  721.                 @map_2.blt(32*(j+$game_map.width), 32*i, bitmap_2, rect)
  722.                 @map_3.blt(32*(j+$game_map.width), 32*i, bitmap_3, rect)
  723.                 @map_4.blt(32*(j+$game_map.width), 32*i, bitmap_4, rect)
  724.               end
  725.             else
  726.               bitmap_2 = RPG::Cache_Tile.load2(value1, value2, value3, 1)
  727.               bitmap_3 = RPG::Cache_Tile.load2(value1, value2, value3, 2)
  728.               bitmap_4 = RPG::Cache_Tile.load2(value1, value2, value3, 3)
  729.               @map_2.blt(32*j, 32*i, bitmap_2, rect)
  730.               @map_3.blt(32*j, 32*i, bitmap_3, rect)
  731.               @map_4.blt(32*j, 32*i, bitmap_4, rect)
  732.               if $game_system.loop_x and j.between?(0, 19)
  733.                 @map_2.blt(32*(j+$game_map.width), 32*i, bitmap_2, rect)
  734.                 @map_3.blt(32*(j+$game_map.width), 32*i, bitmap_3, rect)
  735.                 @map_4.blt(32*(j+$game_map.width), 32*i, bitmap_4, rect)
  736.               end
  737.             end
  738.           end
  739.         else
  740.           if value2 != 0
  741.             if value3 == 0
  742.               num = 4*((value2 / 48) - 1)
  743.               bitmap_2 = RPG::Cache.autotile_base(num+1, value2)
  744.               bitmap_3 = RPG::Cache.autotile_base(num+2, value2)
  745.               bitmap_4 = RPG::Cache.autotile_base(num+3, value2)
  746.               @map_2.blt(32*j, 32*i, bitmap_2, rect)
  747.               @map_3.blt(32*j, 32*i, bitmap_3, rect)
  748.               @map_4.blt(32*j, 32*i, bitmap_4, rect)
  749.               if $game_system.loop_x and j.between?(0, 19)
  750.                 @map_2.blt(32*(j+$game_map.width), 32*i, bitmap_2, rect)
  751.                 @map_3.blt(32*(j+$game_map.width), 32*i, bitmap_3, rect)
  752.                 @map_4.blt(32*(j+$game_map.width), 32*i, bitmap_4, rect)
  753.               end
  754.             else
  755.               bitmap_2 = RPG::Cache_Tile.load(value2, value3, 1)
  756.               bitmap_3 = RPG::Cache_Tile.load(value2, value3, 2)
  757.               bitmap_4 = RPG::Cache_Tile.load(value2, value3, 3)
  758.               @map_2.blt(32*j, 32*i, bitmap_2, rect)
  759.               @map_3.blt(32*j, 32*i, bitmap_3, rect)
  760.               @map_4.blt(32*j, 32*i, bitmap_4, rect)
  761.               if $game_system.loop_x and j.between?(0, 19)
  762.                 @map_2.blt(32*(j+$game_map.width), 32*i, bitmap_2, rect)
  763.                 @map_3.blt(32*(j+$game_map.width), 32*i, bitmap_3, rect)
  764.                 @map_4.blt(32*(j+$game_map.width), 32*i, bitmap_4, rect)
  765.               end
  766.             end
  767.           else
  768.             if value3 != 0
  769.               num = 4*((value3 / 48) - 1)
  770.               bitmap_2 = RPG::Cache.autotile_base(num+1, value3)
  771.               bitmap_3 = RPG::Cache.autotile_base(num+2, value3)
  772.               bitmap_4 = RPG::Cache.autotile_base(num+3, value3)
  773.               @map_2.blt(32*j, 32*i, bitmap_2, rect)
  774.               @map_3.blt(32*j, 32*i, bitmap_3, rect)
  775.               @map_4.blt(32*j, 32*i, bitmap_4, rect)
  776.               if $game_system.loop_x and j.between?(0, 19)
  777.                 @map_2.blt(32*(j+$game_map.width), 32*i, bitmap_2, rect)
  778.                 @map_3.blt(32*(j+$game_map.width), 32*i, bitmap_3, rect)
  779.                 @map_4.blt(32*(j+$game_map.width), 32*i, bitmap_4, rect)
  780.               end
  781.             end
  782.           end
  783.         end
  784.       end
  785.     end
  786.     # save the three additional maps in the Cache
  787.     RPG::Cache_Carte.save(@id, @map_2, 1)
  788.     RPG::Cache_Carte.save(@id, @map_3, 2)
  789.     RPG::Cache_Carte.save(@id, @map_4, 3)
  790.   end
  791.   #--------------------------------------------------------------------------
  792.   # * no tileset for mode7 maps
  793.   #--------------------------------------------------------------------------
  794.   def tileset
  795.     return nil
  796.   end
  797. end
复制代码
第二段
  1. #============================================================================
  2. #此脚本增加了一种深入的地图。
  3. #作者MGCaladtogel
  4. #中文版(24/04/08)
  5. #============================================================================
  6. # ■ Game_Map
  7. #------------------------------------------------- ---------------------------
  8. # 方法处理地图变通循环
  9. #============================================================================

  10. class Game_Map
  11.   #--------------------------------------------------------------------------
  12.   # *向下滚动,
  13.   # 距离:滚动的距离
  14.   #--------------------------------------------------------------------------
  15.   alias scroll_down_mode7_game_map scroll_down
  16.   def scroll_down(distance)
  17.     if !$game_system.mode7
  18.       scroll_down_mode7_game_map(distance)
  19.       return
  20.     end
  21.     if $game_system.loop_y or $game_system.always_scroll
  22.       @display_y = @display_y + distance # always scroll
  23.     else
  24.       @display_y = [@display_y + distance, (self.height - 15) * 128].min
  25.     end
  26.   end
  27.     #--------------------------------------------------------------------------
  28.     #  *滚动左
  29.     #距离:滚动的距离
  30.     #--------------------------------------------------------------------------
  31.   alias scroll_left_mode7_game_map scroll_left
  32.   def scroll_left(distance)
  33.     if !$game_system.mode7
  34.       scroll_left_mode7_game_map(distance)
  35.       return
  36.     end
  37.     if $game_system.loop_x or $game_system.always_scroll
  38.       @display_x = @display_x - distance # always scroll
  39.     else
  40.       @display_x = [@display_x - distance, 0].max
  41.     end
  42.   end
  43.   #--------------------------------------------------------------------------
  44.   # *滚动权
  45.   # 距离:滚动的距离
  46.   #--------------------------------------------------------------------------
  47.   alias scroll_right_mode7_game_map scroll_right
  48.   def scroll_right(distance)
  49.     if !$game_system.mode7
  50.       scroll_right_mode7_game_map(distance)
  51.       return
  52.     end
  53.     if $game_system.loop_x or $game_system.always_scroll
  54.       @display_x = @display_x + distance # always scroll
  55.     else
  56.       @display_x = [@display_x + distance, (self.width - 20) * 128].min
  57.     end
  58.   end
  59.   #--------------------------------------------------------------------------
  60.   #  *向上滚动
  61.   #  距离:滚动的距离
  62.   #--------------------------------------------------------------------------
  63.   alias scroll_up_mode7_game_map scroll_up
  64.   def scroll_up(distance)
  65.     if !$game_system.mode7
  66.       scroll_up_mode7_game_map(distance)
  67.       return
  68.     end
  69.     if $game_system.loop_y or $game_system.always_scroll
  70.       @display_y = @display_y - distance # always scroll
  71.     else
  72.       @display_y = [@display_y - distance, 0].max
  73.     end
  74.   end
  75.   #--------------------------------------------------------------------------
  76.   #  *确定有效坐标
  77.   #  x: X的坐标
  78.   #  y: Y的坐标
  79.   #  允许英雄走出去的地图时,地图循
  80.   #--------------------------------------------------------------------------
  81.   alias valid_mode7_game_map? valid?
  82.   def valid?(x, y)
  83.     if !$game_system.mode7
  84.       return (valid_mode7_game_map?(x, y))
  85.     end
  86.     if $game_system.loop_x
  87.       if $game_system.loop_y
  88.         return true
  89.       else
  90.         return (y >= 0 and y < height)
  91.       end
  92.     elsif $game_system.loop_y
  93.       return (x >= 0 and x < width)
  94.     end
  95.     return (x >= 0 and x < width and y >= 0 and y < height)
  96.   end
  97.   #--------------------------------------------------------------------------
  98.   # * Determine if Passable
  99.   #     x          : x-coordinate
  100.   #     y          : y-coordinate
  101.   #     d          : direction (0,2,4,6,8,10)
  102.   #                  *  0,10 = determine if all directions are impassable
  103.   #     self_event : Self (If event is determined passable)
  104.   #--------------------------------------------------------------------------
  105.   alias passable_mode7_game_map? passable?
  106.   def passable?(x, y, d, self_event = nil)
  107.     if !$game_system.mode7
  108.       passable_mode7_game_map?(x, y, d, self_event)
  109.       return(passable_mode7_game_map?(x, y, d, self_event))
  110.     end
  111.     unless valid?(x, y)
  112.       return false
  113.     end
  114.     bit = (1 << (d / 2 - 1)) & 0x0f
  115.     for event in events.values
  116.       if event.tile_id >= 0 and event != self_event and
  117.          event.x == x and event.y == y and not event.through
  118.         if @passages[event.tile_id] & bit != 0
  119.           return false
  120.         elsif @passages[event.tile_id] & 0x0f == 0x0f
  121.           return false
  122.         elsif @priorities[event.tile_id] == 0
  123.           return true
  124.         end
  125.       end
  126.     end
  127.     for i in [2, 1, 0]
  128.       tile_id = data[x % width, y % height, i] # handle map looping
  129.       if tile_id == nil
  130.         return false
  131.       elsif @passages[tile_id] & bit != 0
  132.         return false
  133.       elsif @passages[tile_id] & 0x0f == 0x0f
  134.         return false
  135.       elsif @priorities[tile_id] == 0
  136.         return true
  137.       end
  138.     end
  139.     return true
  140.   end
  141.   #--------------------------------------------------------------------------
  142.   # * Setup
  143.   #     map_id : map ID
  144.   #--------------------------------------------------------------------------
  145.   alias old_setup_mode7 setup
  146.   def setup(map_id)
  147.     old_setup_mode7(map_id)
  148.     if !$game_switches[$enable_mode7_number]
  149.       $game_system.mode7 = false
  150.       $game_system.mode7 = false
  151.       $game_system.loop_x = false
  152.       $game_system.loop_y = false
  153.       $game_system.always_scroll = false
  154.       $game_system.animated = false
  155.       $game_system.white_horizon = false
  156.       $game_system.angle = 0
  157.       $game_system.fixed_panorama = false
  158.       $game_system.ov = false
  159.       $game_system.ov_zoom = 0.6
  160.       $game_system.reset
  161.       return
  162.     end
  163.     map_data = $data_maps[$game_map.map_id]
  164.     for keyword in $mode7_maps_settings.keys
  165.       if map_data.name2.include?(keyword)
  166.         command_list = $mode7_maps_settings[keyword]
  167.         $game_system.mode7 = true
  168.         $game_system.loop_x = command_list.include?("X")
  169.         $game_system.loop_y = command_list.include?("Y")
  170.         $game_system.always_scroll = command_list.include?("C")
  171.         $game_system.animated = command_list.include?("A")
  172.         $game_system.white_horizon = command_list.include?("H")
  173.         $game_system.fixed_panorama = command_list.include?("P")
  174.         $game_system.ov = command_list.include?("OV")
  175.         for command in command_list
  176.           if command.include?("#")
  177.             $game_system.angle = (command.slice(1, 2)).to_i
  178.             $game_system.angle = [[$game_system.angle, 0].max, 89].min
  179.             break
  180.           end
  181.         end
  182.         return
  183.       end
  184.     end
  185.     $game_system.mode7 = map_data.name2.include?("[M7]")
  186.     $game_system.loop_x = map_data.name2.include?("[X]")
  187.     $game_system.loop_y = map_data.name2.include?("[Y]")
  188.     $game_system.always_scroll = map_data.name2.include?("[C]")
  189.     $game_system.animated = map_data.name2.include?("[A]")
  190.     $game_system.white_horizon = map_data.name2.include?("[H]")
  191.     $game_system.fixed_panorama = map_data.name2.include?("[P]")
  192.     $game_system.ov = map_data.name2.include?("[OV]")
  193.     if $game_system.mode7
  194.       map_data.name2 =~ /\[#[ ]*([00-99]+)\]/i
  195.       $game_system.angle = $1.to_i
  196.       $game_system.angle = [[$game_system.angle, 0].max, 89].min
  197.     end
  198.   end
  199. end

  200. #============================================================================
  201. # ■ Game_Character
  202. #----------------------------------------------------------------------------
  203. # “更新”的方法变通处理地图循环
  204. #============================================================================

  205. class Game_Character
  206.   attr_accessor :x
  207.   attr_accessor :y
  208.   attr_accessor :real_x
  209.   attr_accessor :real_y
  210.   attr_reader   :flat
  211.   attr_reader   :height
  212.   #--------------------------------------------------------------------------
  213.   # * Object Initialization
  214.   #--------------------------------------------------------------------------
  215.   alias initialize_mode7_game_character initialize
  216.   def initialize
  217.     initialize_mode7_game_character
  218.     @flat = false
  219.     @height = 0.0
  220.   end
  221.   #--------------------------------------------------------------------------
  222.   # * Update
  223.   #--------------------------------------------------------------------------
  224.   alias update_mode7_game_character update
  225.   def update
  226.     if !$game_system.mode7
  227.       update_mode7_game_character
  228.       return
  229.     end
  230.     # if x-coordinate is out of the map
  231.     if !(x.between?(0, $game_map.width - 1))
  232.       difference = 128 * x - real_x
  233.       if self.is_a?(Game_Player)
  234.         # increase or decrease map's number
  235.         self.map_number_x += difference / (difference.abs)
  236.       end
  237.       # x-coordinate is equal to its equivalent in the map
  238.       self.x %= $game_map.width
  239.       self.real_x = 128 * x - difference
  240.     end
  241.     # if y-coordinate is out of the map
  242.     if !(y.between?(0, $game_map.height - 1))
  243.       difference = 128 * y - real_y
  244.       if self.is_a?(Game_Player)
  245.         # increase or decrease map's number
  246.         self.map_number_y += difference / (difference.abs)
  247.       end
  248.       # y-coordinate is equal to its equivalent in the map
  249.       self.y %= $game_map.height
  250.       self.real_y = 128 * y - difference
  251.     end
  252.     update_mode7_game_character
  253.   end
  254. end

  255. #==============================================================================
  256. # ■ Game_Event
  257. #----------------------------------------------------------------------------
  258. # Add methods to handle flat events and altitude for vertical event
  259. #============================================================================

  260. class Game_Event < Game_Character
  261.   #--------------------------------------------------------------------------
  262.   #    *扫描事件的命令列表
  263.   #页:扫描网页( RPG游戏::活动::页)
  264.   #--------------------------------------------------------------------------
  265.   def check_commands(page)
  266.     @height = 0.0
  267.     command_list = page.list
  268.     for k in 0..command_list.length - 2
  269.       command = command_list[k]
  270.       if (command.parameters[0].to_s).include?("Height")
  271.         @height = (command.parameters[0][7,command.parameters[0].length-1]).to_f
  272.       end
  273.       @flat = (command.parameters[0].to_s).include?("Flat")
  274.     end
  275.   end
  276.   #--------------------------------------------------------------------------
  277.   # * scan the event's commands list of the current page when refreshed
  278.   #--------------------------------------------------------------------------
  279.   alias refresh_mode7_game_character refresh
  280.   def refresh
  281.     refresh_mode7_game_character
  282.     check_commands(@page) if @page != nil
  283.   end
  284. end

  285. #============================================================================
  286. # ■ Game_Player
  287. #----------------------------------------------------------------------------
  288. # Add attributes to have a well-working panorama's scrolling
  289. #============================================================================

  290. class Game_Player < Game_Character
  291.   attr_accessor :map_number_x # map's number with X-looping
  292.   attr_accessor :map_number_y # map's number with Y-looping
  293.   #--------------------------------------------------------------------------
  294.   # * Object Initialization
  295.   #--------------------------------------------------------------------------
  296.   alias initialize_mode7_game_player initialize
  297.   def initialize
  298.     initialize_mode7_game_player
  299.     self.map_number_x = 0
  300.     self.map_number_y = 0
  301.   end
  302.   #--------------------------------------------------------------------------
  303.   # * Handle the option : center around the hero
  304.   #--------------------------------------------------------------------------
  305.   alias center_mode7_game_player center
  306.   def center(x, y)
  307.     if !$game_system.loop_y and !$game_system.always_scroll#!$game_system.mode7
  308.       center_mode7_game_player(x, y)
  309.       return
  310.     end
  311.     $game_map.display_x = x * 128 - CENTER_X
  312.     $game_map.display_y = y * 128 - CENTER_Y
  313.   end
  314. end

  315. #============================================================================
  316. # ■ Sprite
  317. #----------------------------------------------------------------------------
  318. # Add attributes to work efficiently with scanlines sprites
  319. #============================================================================

  320. class Sprite
  321.   attr_accessor :y_origin_bitmap # bitmap's y-coordinate for the "src_rect.set"
  322.   #method (float)
  323.   attr_accessor :x_origin_bitmap # bitmap's x-coordinate for the "src_rect.set"
  324.   #method (float)
  325.   attr_accessor :y_origin_bitmap_i # bitmap's y-coordinate for the
  326.   #"src_rect.set" method (integer)
  327.   attr_accessor :x_origin_bitmap_i # bitmap's x-coordinate for the
  328.   #"src_rect.set" method (integer)
  329.   attr_accessor :length # sprite's width
  330. end

  331. #============================================================================
  332. # ■ Sprite_Character
  333. #----------------------------------------------------------------------------
  334. # Calculate x-coordinate and y-coordinate for a mode7 map
  335. #============================================================================

  336. class Sprite_Character < RPG::Sprite
  337.   attr_reader   :flat_indicator # true if the event is flat-drawn
  338.   #--------------------------------------------------------------------------
  339.   # * Object Initialization
  340.   #--------------------------------------------------------------------------
  341.   alias initialize_mode7_sprite_character initialize
  342.   def initialize(viewport, character = nil)
  343.     @flat_indicator = false
  344.     initialize_mode7_sprite_character(viewport, character)
  345.   end
  346.   #--------------------------------------------------------------------------
  347.   # * Update
  348.   #--------------------------------------------------------------------------
  349.   alias update_mode7_sprite_character update
  350.   def update
  351.     if !$game_system.mode7
  352.       update_mode7_sprite_character
  353.       return
  354.     end
  355.     if @flat_indicator
  356.       if ([email protected] or @character.moving? or
  357.         @tile_id != @character.tile_id or
  358.         @character_name != @character.character_name or
  359.         @character_hue != @character.character_hue)
  360.         @flat_indicator = @character.flat
  361.         # redraw the original ground
  362.         maps_list = $scene.spriteset.tilemap.maps_list
  363.         map_ground = $scene.spriteset.tilemap.map_ground
  364.         rect = Rect.new(@flat_x_map, @flat_y_map, @flat_width, @flat_height)
  365.         for map in maps_list
  366.           map.blt(@flat_x_map, @flat_y_map, map_ground, rect)
  367.           if $game_system.loop_x and @flat_x_map.between?(0, 19 * 32)
  368.             map.blt(@flat_x_map + 32 * $game_map.width, @flat_y_map, map_ground,
  369.             rect)
  370.           end
  371.         end
  372.       else
  373.         return
  374.       end
  375.     end
  376.     super
  377.     if @tile_id != @character.tile_id or
  378.        @character_name != @character.character_name or
  379.        @character_hue != @character.character_hue
  380.       @tile_id = @character.tile_id
  381.       @character_name = @character.character_name
  382.       @character_hue = @character.character_hue
  383.       if @tile_id >= 384
  384.         self.bitmap = RPG::Cache.tile($game_map.tileset_name,
  385.           @tile_id, @character.character_hue)
  386.         self.src_rect.set(0, 0, 32, 32)
  387.         self.ox = 16
  388.         self.oy = 32
  389.       else
  390.         self.bitmap = RPG::Cache.character(@character.character_name,
  391.           @character.character_hue)
  392.         @cw = bitmap.width / 4
  393.         @ch = bitmap.height / 4
  394.         self.ox = @cw / 2
  395.         self.oy = @ch
  396.         # pivot correction (intersection between the map and this sprite)
  397.         self.oy -= 4
  398.       end
  399.     end
  400.     self.visible = (not @character.transparent)
  401.     if @tile_id == 0
  402.       sx = @character.pattern * @cw
  403.       sy = (@character.direction - 2) / 2 * @ch
  404.       self.src_rect.set(sx, sy, @cw, @ch)
  405.     end
  406.     if @character.flat # event must be flat drawn
  407.       return if $scene.spriteset == nil
  408.       if @tile_id == 0
  409.         @flat_x_map = @character.real_x / 4 - (@cw - 32) / 2
  410.         @flat_y_map = @character.real_y / 4 - @ch + 32
  411.         @flat_x0 = sx
  412.         @flat_y0 = sy
  413.         @flat_width = @cw
  414.         @flat_height = @ch
  415.       else
  416.         @flat_x_map = @character.real_x / 4
  417.         @flat_y_map = @character.real_y / 4
  418.         @flat_x0 = 0
  419.         @flat_y0 = 0
  420.         @flat_width = 32
  421.         @flat_height = 32
  422.       end
  423.       # modify the maps graphics
  424.       maps_list = $scene.spriteset.tilemap.maps_list
  425.       rect = Rect.new(@flat_x0, @flat_y0, @flat_width, @flat_height)
  426.       for map in maps_list
  427.         map.blt(@flat_x_map, @flat_y_map, bitmap, rect, @character.opacity)
  428.         if $game_system.loop_x and @flat_x_map.between?(0, 19 * 32)
  429.           map.blt(@flat_x_map + 32 * $game_map.width, @flat_y_map, bitmap, rect,
  430.           @character.opacity)
  431.         end
  432.       end
  433.       @flat_indicator = true
  434.       self.opacity = 0
  435.       return
  436.     end
  437.     x_intermediate = @character.screen_x
  438.     y_intermediate = @character.screen_y
  439.     y_intermediate -= $game_temp.pivot + 4 if $game_system.mode7
  440.     # if vertical looping
  441.     if $game_system.loop_y
  442.       h = 32 * $game_map.height
  443.       y_intermediate = (y_intermediate + h / 2) % h - h / 2
  444.     end
  445.     # coordinates in a mode7 map
  446.     self.y = (($game_temp.distance_h * y_intermediate *
  447.     $game_temp.cos_angle).to_f / ($game_temp.distance_h - y_intermediate *
  448.     $game_temp.sin_angle) + $game_temp.pivot)
  449.     self.zoom_x = $game_temp.slope_value * y + $game_temp.corrective_value
  450.     self.zoom_y = zoom_x
  451.     self.x = 320 + zoom_x * (x_intermediate - 320)
  452.     # if horizontal looping
  453.     if $game_system.loop_x
  454.       offset = ($game_map.width >= 24 ? 64 * zoom_x : 0)
  455.       l = 32 * $game_map.width * zoom_x
  456.       self.x = (x + offset) % l - offset
  457.     end
  458.     if @character.is_a?(Game_Player)
  459.       # Overworld Sprite Resize
  460.       if $game_system.ov
  461.         self.zoom_x *= $game_system.ov_zoom
  462.         self.zoom_y *= $game_system.ov_zoom
  463.       end
  464.     end   
  465.     self.z = @character.screen_z(@ch)
  466.     # hide the sprite if it is beyond the horizon's line
  467.     self.opacity = (y < $game_temp.height_limit ? 0 : @character.opacity)
  468.     self.y -= 32 * @character.height * zoom_y # height correction
  469.     self.blend_type = @character.blend_type
  470.     self.bush_depth = @character.bush_depth
  471.     if @character.animation_id != 0
  472.       animation = $data_animations[@character.animation_id]
  473.       animation(animation, true)
  474.       @character.animation_id = 0
  475.     end
  476.   end
  477. end

  478. #============================================================================
  479. # ■ Sprite_V (Vertical Sprites)
  480. #----------------------------------------------------------------------------
  481. #  Sprites corresponding to the vertical elements formed by tiles
  482. #============================================================================

  483. class Sprite_V < Sprite
  484.   attr_accessor :x_map # sprite's x_coordinates (in squares) (Float)
  485.   attr_accessor :y_map # sprite's y_coordinates (in squares) (Float)
  486.   attr_accessor :square_y # sprite's y_coordinates (in squares) (Integer)
  487.   attr_accessor :priority # sprite's priority
  488.   attr_accessor :animated # True if animated
  489.   attr_accessor :list_bitmap # list of sprite's bitmaps (Bitmap)
  490.   #--------------------------------------------------------------------------
  491.   # * Update
  492.   #--------------------------------------------------------------------------
  493.   def update
  494.     square_y_corrected = square_y
  495.     y_intermediate = 32 * y_map - $game_temp.pivot - $game_map.display_y / 4
  496.     y_intermediate_reference = y_intermediate
  497.     # if vertical looping
  498.     if $game_system.loop_y
  499.       y_intermediate = (y_intermediate + $game_temp.height / 2) %
  500.       $game_temp.height - $game_temp.height / 2
  501.       if y_intermediate_reference < y_intermediate
  502.         square_y_corrected = square_y + $game_map.height
  503.       elsif y_intermediate_reference > y_intermediate
  504.         square_y_corrected = square_y - $game_map.height
  505.       end
  506.     end
  507.     self.y = ($game_temp.distance_h * y_intermediate *
  508.     $game_temp.cos_angle).to_f / ($game_temp.distance_h - y_intermediate *
  509.     $game_temp.sin_angle) + $game_temp.pivot
  510.     if y < $game_temp.height_limit
  511.       # hide the sprite if it is beyond the horizon's line
  512.       self.opacity = 0
  513.       return
  514.     end
  515.     self.opacity = 255
  516.     if $scene.spriteset != nil and $scene.spriteset.tilemap.is_a?(Tilemap_mode7)
  517.       opacity_values = $scene.spriteset.tilemap.opacity_values
  518.       tone_values = $scene.spriteset.tilemap.tone_values
  519.       if opacity_values.has_key?(y)
  520.         self.opacity = opacity_values[y]
  521.         self.tone = tone_values[y]
  522.       end
  523.     end
  524.     self.zoom_x = $game_temp.slope_value * y + $game_temp.corrective_value
  525.     self.zoom_y = zoom_x
  526.     x_intermediate = 32 * x_map - $game_map.display_x / 4
  527.     self.x = 320 + (zoom_x * (x_intermediate - 320))
  528.     # if horizontal looping
  529.     if $game_system.loop_x
  530.       offset = ($game_map.width >= 24 ? 64 * zoom_x : 0)
  531.       l = 32 * $game_map.width * self.zoom_x
  532.       self.x = (self.x + offset) % l - offset
  533.     end
  534.     self.z = (128 * square_y_corrected - $game_map.display_y + 3) / 4 +
  535.     32 + 32 * priority
  536.     return
  537.   end
  538.   #--------------------------------------------------------------------------
  539.   # * Update bitmap for animation
  540.   #     index  : 0..3 : animation's index
  541.   #--------------------------------------------------------------------------
  542.   def update_animated(index)
  543.     self.bitmap = @list_bitmap[index]
  544.   end
  545. end

  546. #============================================================================
  547. # ■ Spriteset_Map
  548. #----------------------------------------------------------------------------
  549. #  Modifications to call a mode7 map
  550. #============================================================================

  551. class Spriteset_Map
  552.   attr_accessor :tilemap # just to be able to access the tilemap
  553.   #--------------------------------------------------------------------------
  554.   # * Initialize Object
  555.   #   Rewritten to call a map with mode7
  556.   #--------------------------------------------------------------------------
  557.   alias initialize_mode7_spriteset_map initialize
  558.   def initialize
  559.     if !$game_system.mode7
  560.       initialize_mode7_spriteset_map
  561.       return
  562.     end
  563.     @viewport1 = Viewport.new(0, 0, 640, 480)
  564.     @viewport2 = Viewport.new(0, 0, 640, 480)
  565.     @viewport3 = Viewport.new(0, 0, 640, 480)
  566.     @viewport2.z = 200
  567.     @viewport3.z = 5000
  568.     # mode7 map
  569.     @tilemap = Tilemap_mode7.new(@viewport1, self)
  570.     @panorama = Plane.new(@viewport1)
  571.     # sprites drawn at the horizon's level have a negative z, and with a z value
  572.     # of -100000 the panorama is still below
  573.     @panorama.z = ($game_system.mode7 ? -100000 : -1000)
  574.     @fog = Plane.new(@viewport1)
  575.     @fog.z = 3000
  576.     @character_sprites = []
  577.     for i in $game_map.events.keys.sort
  578.       sprite = Sprite_Character.new(@viewport1, $game_map.events[i])
  579.       @character_sprites.push(sprite)
  580.     end
  581.     @character_sprites.push(Sprite_Character.new(@viewport1, $game_player))
  582.     @weather = RPG::Weather.new(@viewport1)
  583.     @picture_sprites = []
  584.     for i in 1..50
  585.       @picture_sprites.push(Sprite_Picture.new(@viewport2,
  586.         $game_screen.pictures[i]))
  587.     end
  588.     @timer_sprite = Sprite_Timer.new
  589.     update
  590.   end
  591.   #--------------------------------------------------------------------------
  592.   # * Dispose
  593.   #--------------------------------------------------------------------------
  594.   def dispose
  595.     if @tilemap.tileset != nil
  596.       @tilemap.tileset.dispose
  597.       for i in 0..6
  598.         @tilemap.autotiles[i].dispose
  599.       end
  600.     end
  601.     @tilemap.dispose
  602.     @panorama.dispose
  603.     @fog.dispose
  604.     for sprite in @character_sprites
  605.       sprite.dispose
  606.     end
  607.     @weather.dispose
  608.     for sprite in @picture_sprites
  609.       sprite.dispose
  610.     end
  611.     @timer_sprite.dispose
  612.     @viewport1.dispose
  613.     @viewport2.dispose
  614.     @viewport3.dispose
  615.   end
  616.   #--------------------------------------------------------------------------
  617.   # * Update
  618.   #--------------------------------------------------------------------------
  619.   alias update_mode7_spriteset_map update
  620.   def update
  621.     if !$game_system.mode7
  622.       update_mode7_spriteset_map
  623.       return
  624.     end
  625.     if @panorama_name != $game_map.panorama_name or
  626.        @panorama_hue != $game_map.panorama_hue
  627.       @panorama_name = $game_map.panorama_name
  628.       @panorama_hue = $game_map.panorama_hue
  629.       if @panorama.bitmap != nil
  630.         @panorama.bitmap.dispose
  631.         @panorama.bitmap = nil
  632.       end
  633.       if @panorama_name != ""
  634.         @panorama.bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue)
  635.       end
  636.       Graphics.frame_reset
  637.     end
  638.     if @fog_name != $game_map.fog_name or @fog_hue != $game_map.fog_hue
  639.       @fog_name = $game_map.fog_name
  640.       @fog_hue = $game_map.fog_hue
  641.       if @fog.bitmap != nil
  642.         @fog.bitmap.dispose
  643.         @fog.bitmap = nil
  644.       end
  645.       if @fog_name != ""
  646.         @fog.bitmap = RPG::Cache.fog(@fog_name, @fog_hue)
  647.       end
  648.       Graphics.frame_reset
  649.     end
  650.     # update animated tiles each 20 frames
  651.     if Graphics.frame_count % 20 == 0 and $game_system.animated
  652.       @tilemap.update_animated
  653.     end
  654.     @tilemap.update
  655.     # if the panorama is fixed
  656.     if $game_system.fixed_panorama
  657.       @panorama.ox = 0
  658.       @panorama.oy = 0
  659.     # if it is a mode7 map
  660.     else
  661.       # to have a fluent panorama scrolling
  662.       @panorama.ox = (128 * $game_map.width * $game_player.map_number_x +
  663.       $game_player.real_x) / 8
  664.       @panorama.oy = - (128 * $game_map.height * $game_player.map_number_y +
  665.       $game_player.real_y) / 32
  666.     end
  667.     @fog.zoom_x = $game_map.fog_zoom / 100.0
  668.     @fog.zoom_y = $game_map.fog_zoom / 100.0
  669.     @fog.opacity = $game_map.fog_opacity
  670.     @fog.blend_type = $game_map.fog_blend_type
  671.     @fog.ox = $game_map.display_x / 4 + $game_map.fog_ox
  672.     @fog.oy = $game_map.display_y / 4 + $game_map.fog_oy
  673.     @fog.tone = $game_map.fog_tone
  674.     for sprite in @character_sprites
  675.       sprite.update
  676.     end
  677.     @weather.type = $game_screen.weather_type
  678.     @weather.max = $game_screen.weather_max
  679.     @weather.ox = $game_map.display_x / 4
  680.     @weather.oy = $game_map.display_y / 4
  681.     @weather.update
  682.     for sprite in @picture_sprites
  683.       sprite.update
  684.     end
  685.     @timer_sprite.update
  686.     @viewport1.tone = $game_screen.tone
  687.     @viewport1.ox = $game_screen.shake
  688.     @viewport3.color = $game_screen.flash_color
  689.     @viewport1.update
  690.     @viewport3.update
  691.   end
  692. end
复制代码
第三段
  1. #============================================================================
  2. #此脚本增加了一种深入的地图。
  3. #作者MGCaladtogel
  4. #中文版( 24/04/08 )
  5. #==============================================================================
  6. # ■ Game_Switches
  7. #==============================================================================
  8. class Game_Switches
  9.   #--------------------------------------------------------------------------
  10.   # *对象初始化
  11.   #--------------------------------------------------------------------------
  12.   alias initialize_mode7_game_player initialize
  13.   def initialize
  14.     initialize_mode7_game_player
  15.     self[$enable_mode7_number] = true
  16.   end
  17. end

  18. #============================================================================
  19. # ■ Scene_Map
  20. #============================================================================
  21. class Scene_Map
  22.   attr_accessor :spriteset #只需要访问spriteset
  23. end

  24. #============================================================================
  25. # ■ Data_Autotiles
  26. #----------------------------------------------------------------------------
  27. # Creates the set of tiles from an autotile's file
  28. #============================================================================

  29. class Data_Autotiles < Bitmap
  30.   # data list to form tiles from an atotiles file
  31.   Data_creation = [[27,28,33,34],[5,28,33,34],[27,6,33,34],[5,6,33,34],
  32.   [27,28,33,12],[5,28,33,12],[27,6,33,12],[5,6,33,12],[27,28,11,34],
  33.   [5,28,11,34],[27,6,11,34],[5,6,11,34],[27,28,11,12],[5,28,11,12],
  34.   [27,6,11,12],[5,6,11,12],[25,26,31,32],[25,6,31,32],[25,26,31,12],
  35.   [25,6,31,12],[15,16,21,22],[15,16,21,12],[15,16,11,22],[15,16,11,12],
  36.   [29,30,35,36],[29,30,11,36],[5,30,35,36],[5,30,11,36],[39,40,45,46],
  37.   [5,40,45,46],[39,6,45,46],[5,6,45,46],[25,30,31,36],[15,16,45,46],
  38.   [13,14,19,20],[13,14,19,12],[17,18,23,24],[17,18,11,24],[41,42,47,48],
  39.   [5,42,47,48],[37,38,43,44],[37,6,43,44],[13,18,19,24],[13,14,43,44],
  40.   [37,42,43,48],[17,18,47,48],[13,18,43,48],[13,18,43,48]]
  41.   attr_accessor :number # autotile's number to identify it
  42.   attr_accessor :animated # TRUE if the autotile is animated
  43.   #--------------------------------------------------------------------------
  44.   # * Initialize Object
  45.   #     file   : autotiles file's bitmap (Bitmap)
  46.   #     l      : 0..3 : pattern's number for animated autotiles
  47.   #--------------------------------------------------------------------------
  48.   def initialize(file, l)
  49.     super(8*32, 6*32)
  50.     create(file, l)
  51.   end
  52.   #--------------------------------------------------------------------------
  53.   # * Create the tiles set
  54.   #     file   : autotiles file's bitmap (Bitmap)
  55.   #     l      : 0..3 : pattern's number for animated autotiles
  56.   #--------------------------------------------------------------------------
  57.   def create(file, l)
  58.     l = (file.width > 96 ? l : 0)
  59.     self.animated = (file.width > 96)
  60.     for i in 0..5
  61.       for j in 0..7
  62.         data = Data_creation[8 * i + j]
  63.         for number in data
  64.           number -= 1
  65.           m = 16 * (number % 6)
  66.           n = 16 * (number / 6)
  67.           blt(32 * j + m % 32, 32 * i + n % 32, file,
  68.           Rect.new(m + 96 * l, n, 16, 16))
  69.         end
  70.       end
  71.     end
  72.   end
  73. end

  74. #============================================================================
  75. # ■ Data_Vertical_Sprites
  76. #----------------------------------------------------------------------------
  77. # Create a list of vertical sprites for the three layers of a map
  78. # "V" for "Vertical" in the script
  79. # "num" for "number"
  80. #============================================================================

  81. class Data_Vertical_Sprites
  82.   attr_accessor  :list_sprites_V # list of vertical sprites
  83.   attr_accessor  :list_sprites_V_animated # list of animated vertical sprites
  84.   #--------------------------------------------------------------------------
  85.   # * A little method to compare terrain_tags
  86.   #     value  : tile's ID
  87.   #     num    : reference terrain_tag's value
  88.   #--------------------------------------------------------------------------
  89.   def suitable?(value, num)
  90.     return ($game_map.terrain_tags[value] == num)
  91.   end
  92.   #--------------------------------------------------------------------------
  93.   # * This algorithm scans each layer and create a sprites formed by tiles
  94.   #   in contact
  95.   #     viewport : Viewport
  96.   #--------------------------------------------------------------------------
  97.   def initialize(viewport)
  98.     @viewport = viewport
  99.     # lists initialization
  100.     self.list_sprites_V = []
  101.     self.list_sprites_V_animated = []
  102.     # @num_tiles : list of tiles coordinates that form a vertical sprite
  103.     @num_tiles = []
  104.     # create copy of map's data
  105.     @dataV = ($game_map.data).clone
  106.     # scan each layer
  107.     for h in 0..2
  108.       # scan each row
  109.       for i in 0..$game_map.height
  110.         # scan each column
  111.         for j in 0..$game_map.width
  112.           value = @dataV[j, i, h].to_i
  113.           # if tile's terrain tag is declared to give vertical sprites
  114.           if $terrain_tags_vertical_tiles.include?($game_map.terrain_tags[value])
  115.             @reference_terrain_tag = $game_map.terrain_tags[value]
  116.             @num_tiles.push([j, i])
  117.             # the following algorithm is so complex that I really don't know how
  118.             # it works exactly
  119.             list_end = 0
  120.             length = 0
  121.             while j + length + 1 < $game_map.width and
  122.               suitable?(@dataV[j +length+ 1, i, h].to_i, @reference_terrain_tag)
  123.               @num_tiles.push([j + length+ 1,i])
  124.               length += 1
  125.             end
  126.             list_start = j
  127.             list_end = length + j
  128.             indicator = true
  129.             row = 0
  130.             j2 = j
  131.             while indicator
  132.               row += 1
  133.               break if (i + row) == $game_map.height
  134.               list_start2 = j2
  135.               length2 = 0
  136.               indicator = false
  137.               if length >= 2
  138.                 for k in (j2 + 1)..(j2 + length -1)
  139.                   if suitable?(@dataV[k, i + row, h].to_i,
  140.                     @reference_terrain_tag)
  141.                     if !indicator
  142.                       list_start2 = k
  143.                     else
  144.                       length2 = k - list_start2
  145.                     end
  146.                     indicator = true
  147.                     @num_tiles.push([k, i + row])
  148.                   elsif !indicator
  149.                     length2 -= 1
  150.                   end
  151.                 end
  152.               end
  153.               if suitable?(@dataV[j2 + length, i + row, h].to_i,
  154.                 @reference_terrain_tag)
  155.                 length2 = j2 + length - list_start2
  156.                 indicator = true
  157.                 @num_tiles.push([j2 + length, i + row])
  158.                 length3 = 1
  159.                 while j2 + length + length3 < $game_map.width and
  160.                   suitable?(@dataV[j2 + length + length3, i + row, h].to_i,
  161.                   @reference_terrain_tag)
  162.                   @num_tiles.push([j2 + length + length3, i + row])
  163.                   length3 += 1
  164.                   length2 += 1
  165.                   if j2 + length + length3 > list_end
  166.                     list_end = j2 + length + length3
  167.                   end
  168.                 end
  169.               end
  170.               if suitable?(@dataV[j2, i + row, h].to_i, @reference_terrain_tag)
  171.                 list_start3 = list_start2 - j2
  172.                 length2 = length2 + list_start3
  173.                 list_start2 = j2
  174.                 indicator = true
  175.                 @num_tiles.push([j2, i + row])
  176.                 length3 = 1
  177.                 while j2 - length3 >= 0 and
  178.                   suitable?(@dataV[j2 - length3, i + row, h].to_i,
  179.                   @reference_terrain_tag)
  180.                   @num_tiles.push([j2 - length3, i + row])
  181.                   length3 += 1
  182.                   length2 += 1
  183.                   list_start2 -= 1
  184.                   if list_start2 < list_start
  185.                     list_start = list_start2
  186.                   end
  187.                 end
  188.               end
  189.               length = length2
  190.               j2 = list_start2
  191.             end
  192.             row -= 1
  193.             # create a bitmap and a sprite from the tiles listed in @num_tiles
  194.             create_bitmap(i, list_start, row, list_end - list_start, h)
  195.             # clear the used tiles
  196.             clear_data(h)
  197.             # reinitialize the list of tiles
  198.             @num_tiles = []
  199.           end
  200.         end
  201.       end
  202.     end
  203.   end
  204.   #--------------------------------------------------------------------------
  205.   # * Clear the used data to prevent from reusing them
  206.   #     layer  : current scanned layer
  207.   #--------------------------------------------------------------------------
  208.   def clear_data(layer)
  209.     for num in @num_tiles
  210.       @dataV[num[0], num[1], layer] = 0
  211.     end
  212.   end
  213.   #--------------------------------------------------------------------------
  214.   # * Create a Bitmap from the listed tiles in @num_tiles and its associated
  215.   #   sprite (Sprite_V)
  216.   #     row     : start row's value
  217.   #     column  : start column's value
  218.   #     height  : sprite's height (in tiles)
  219.   #     width   : sprite's width (in tiles)
  220.   #     layer   : current scanned layer
  221.   #--------------------------------------------------------------------------
  222.   def create_bitmap(row, column, height, width, layer)
  223.     bmp = Bitmap.new(32*(1+width), 32*(1+height))
  224.     rect = Rect.new(0, 0, 32, 32)
  225.     @num_tiles.sort! {|a, b|  -(a[1] - b[1])}
  226.     sprite = Sprite_V.new(@viewport)
  227.     # initialize sprite's attributes
  228.     sprite.animated = false
  229.     sprite.list_bitmap = []
  230.     # draw the bitmap
  231.     for tile_coordinates in @num_tiles
  232.       value = @dataV[tile_coordinates[0], tile_coordinates[1], layer].to_i
  233.       # if tile is a normal tile
  234.       if value > 383
  235.         bitmap = RPG::Cache.tile($game_map.tileset_name, value, 0)
  236.       else # tile is an autotile
  237.         file = (value / 48) - 1
  238.         num_file = 4 * file
  239.         if !sprite.animated
  240.           autotile_name = $game_map.autotile_names[file]
  241.           fichier = RPG::Cache.autotile(autotile_name)
  242.           sprite.animated = (fichier.width > 96 ? true : false)
  243.         end
  244.         bitmap = RPG::Cache.autotile_base(num_file, value)
  245.       end
  246.       bmp.blt(32 * (tile_coordinates[0] - column),
  247.       32 * (tile_coordinates[1] - row), bitmap, rect)
  248.     end
  249.     sprite.list_bitmap.push(bmp)
  250.     # create 3 additionnal bitmaps for animated sprites
  251.     if sprite.animated
  252.       for j in 1..3
  253.         bmp = Bitmap.new(32 * (1 + width), 32 * (1 + height))
  254.         for tile_coordinates in @num_tiles
  255.           value = @dataV[tile_coordinates[0], tile_coordinates[1], layer].to_i
  256.           if value > 383
  257.             bitmap = RPG::Cache.tile($game_map.tileset_name, value, 0)
  258.           else
  259.             num_file = 4 * ((value / 48) - 1)
  260.             bitmap = RPG::Cache.autotile_base(num_file + j, value)
  261.           end
  262.           bmp.blt(32 * (tile_coordinates[0] - column),
  263.           32 * (tile_coordinates[1] - row), bitmap, rect)
  264.         end
  265.         sprite.list_bitmap.push(bmp)
  266.       end
  267.     end
  268.     value = @dataV[@num_tiles[0][0], @num_tiles[0][1], layer].to_i
  269.     # set sprite's priority
  270.     sprite.priority = $game_map.priorities[value]
  271.     # set sprite's coordinates (in squares (32 * 32 pixels))
  272.     sprite.x_map = (column.to_f) + bmp.width / 64
  273.     sprite.x_map += 0.5 if width % 2 == 0
  274.     sprite.y_map = (row + height).to_f + 0.5
  275.     sprite.square_y = sprite.y_map.to_i # Integer
  276.     # set the y_pivot (intersection between the map and the sprite)
  277.     sprite.oy = bmp.height - 16
  278.     sprite.ox = bmp.width / 2
  279.     sprite.bitmap = sprite.list_bitmap[0]
  280.     self.list_sprites_V.push(sprite)
  281.     self.list_sprites_V_animated.push(sprite) if sprite.animated
  282.   end
  283. end

  284. #============================================================================
  285. # ■ RPG::Cache_Tile
  286. #----------------------------------------------------------------------------
  287. # The tiles resulting in a superimposing of several tiles are kept in memory
  288. # for a faster call
  289. # valueX : tile's ID
  290. #============================================================================

  291. module RPG
  292.   module Cache_Tile
  293.     @cache = {}
  294.     #------------------------------------------------------------------------
  295.     # * Superimposing of two tiles, offset = pattern's number for animated
  296.     # autotiles
  297.     #------------------------------------------------------------------------
  298.     def self.load(value1, value2, offset=0)
  299.       if not @cache.include?([value1, value2, offset])
  300.         bitmap = Bitmap.new(32, 32)
  301.         rect = Rect.new(0, 0, 32, 32)
  302.         if value1 > 383 # normal tile
  303.           bitmap.blt(0, 0, RPG::Cache.tile($game_map.tileset_name, value1, 0),
  304.           rect)
  305.         else # autotile
  306.           num = 4*((value1 / 48) - 1) + offset
  307.           bitmap.blt(0, 0, RPG::Cache.autotile_base(num, value1), rect)
  308.         end
  309.         if value2 > 383 # normal tile
  310.           bitmap.blt(0, 0, RPG::Cache.tile($game_map.tileset_name, value2, 0),
  311.           rect)
  312.         else # autotile
  313.           num = 4*((value2 / 48) - 1) + offset
  314.           bitmap.blt(0, 0, RPG::Cache.autotile_base(num, value2), rect)
  315.         end
  316.         @cache[[value1, value2, offset]] = bitmap
  317.       end
  318.       @cache[[value1, value2, offset]]
  319.     end
  320.     #------------------------------------------------------------------------
  321.     # * Superimposing of three tiles
  322.     #------------------------------------------------------------------------
  323.     def self.load2(value1, value2, value3, offset = 0)
  324.       if not @cache.include?([value1, value2, value3, offset])
  325.         bitmap = Bitmap.new(32, 32)
  326.         rect = Rect.new(0, 0, 32, 32)
  327.         if value1 > 383 # normal tile
  328.           bitmap.blt(0, 0, RPG::Cache.tile($game_map.tileset_name, value1, 0),
  329.           rect)
  330.         else # autotile
  331.           num = 4*((value1 / 48) - 1) + offset
  332.           bitmap.blt(0, 0, RPG::Cache.autotile_base(num, value1), rect)
  333.         end
  334.         if value2 > 383 # normal tile
  335.           bitmap.blt(0, 0, RPG::Cache.tile($game_map.tileset_name, value2, 0),
  336.           rect)
  337.         else # autotile
  338.           num = 4*((value2 / 48) - 1) + offset
  339.           bitmap.blt(0, 0, RPG::Cache.autotile_base(num, value2), rect)
  340.         end
  341.         if value3 > 383 # normal tile
  342.           bitmap.blt(0, 0, RPG::Cache.tile($game_map.tileset_name, value3, 0),
  343.           rect)
  344.         else # autotile
  345.           num = 4*((value3 / 48) - 1) + offset
  346.           bitmap.blt(0, 0, RPG::Cache.autotile_base(num, value3), rect)
  347.         end
  348.         @cache[[value1, value2, value3, offset]] = bitmap
  349.       end
  350.       @cache[[value1, value2, value3, offset]]
  351.     end
  352.     #------------------------------------------------------------------------
  353.     # * Clear the Cache
  354.     #------------------------------------------------------------------------
  355.     def self.clear
  356.       @cache = {}
  357.       GC.start
  358.     end
  359.   end
  360. end

  361. #============================================================================
  362. # ■ RPG::Cache_Carte
  363. #----------------------------------------------------------------------------
  364. # Maps drawn with mode7 are kept in memory to have a faster call the next
  365. # times they need to be drawn
  366. #============================================================================

  367. module RPG
  368.   module Cache_Carte
  369.     @cache = {}
  370.     #------------------------------------------------------------------------
  371.     # * Check if the map is in the Cache
  372.     #   map_id : map's ID
  373.     #------------------------------------------------------------------------
  374.     def self.in_cache(map_id)
  375.       return @cache.include?(map_id)
  376.     end
  377.     #------------------------------------------------------------------------
  378.     # * Return the map's drawing (Bitmap)
  379.     #   map_id : map's ID
  380.     #   num    : pattern's number for animated autotiles
  381.     #------------------------------------------------------------------------
  382.     def self.load(map_id, num = 0)
  383.       return @cache[map_id][num]
  384.     end
  385.     #------------------------------------------------------------------------
  386.     # * Save the map's drawing in the Cache
  387.     #   map_id : map's ID
  388.     #   bitmap    : map's drawing (Bitmap)
  389.     #   num    : pattern's number for animated autotiles
  390.     #------------------------------------------------------------------------
  391.     def self.save(map_id, bitmap, num = 0)
  392.       @cache[map_id] = [] if !self.in_cache(map_id)
  393.       @cache[map_id][num] = bitmap
  394.     end
  395.     #------------------------------------------------------------------------
  396.     # * Clear the Cache
  397.     #------------------------------------------------------------------------
  398.     def self.clear
  399.       @cache = {}
  400.       GC.start
  401.     end
  402.   end
  403. end

  404. #============================================================================
  405. # ■ RPG::Cache
  406. #----------------------------------------------------------------------------
  407. # The tiles from autotiles files are kept in memory for a faster call
  408. #============================================================================

  409. module RPG
  410.   module Cache
  411.     #------------------------------------------------------------------------
  412.     # * Check if the map is in the Cache
  413.     #   num    : autotiles file's ID
  414.     #   value    : tile's ID
  415.     #------------------------------------------------------------------------
  416.     def self.autotile_base(num, value)
  417.       key = [num, value]
  418.       if not @cache.include?(key) or @cache[key].disposed?
  419.         @cache[key] = Bitmap.new(32, 32)
  420.         num_tile = value % 48
  421.         sx = 32 * (num_tile % 8)
  422.         sy = 32 * (num_tile / 8)
  423.         rect = Rect.new(sx, sy, 32, 32)
  424.         @cache[key].blt(0, 0, self.load_autotile(num), rect)
  425.       end
  426.         @cache[key]
  427.     end
  428.     #------------------------------------------------------------------------
  429.     # * Save the tile's drawing in the Cache
  430.     #   bitmap : tile's drawing (Bitmap)
  431.     #   key    : tile's ID
  432.     #------------------------------------------------------------------------
  433.     def self.save_autotile(bitmap, key)
  434.       @cache[key] = bitmap
  435.     end
  436.     #------------------------------------------------------------------------
  437.     # * Return the tile's drawing (Bitmap)
  438.     #   key    : tile's ID
  439.     #------------------------------------------------------------------------
  440.     def self.load_autotile(key)
  441.       @cache[key]
  442.     end
  443.   end
  444. end

  445. #============================================================================
  446. # ■ RPG::MapInfo
  447. #============================================================================

  448. class RPG::MapInfo
  449.   # defines the map's name as the name without anything within brackets,
  450.   # including brackets
  451.   def name
  452.     return @name.gsub(/\[.*\]/) {""}
  453.   end
  454.   #--------------------------------------------------------------------------
  455.   # the original name with the codes
  456.   def name2
  457.     return @name
  458.   end
  459. end

  460. #============================================================================
  461. # ■ Game_Temp
  462. #----------------------------------------------------------------------------
  463. # Add attributes to this class / Avoid using too many global variables
  464. #============================================================================

  465. class Game_Temp
  466.   attr_accessor :pivot # screenline's number of the slant's pivot
  467.   attr_accessor :cos_angle # cosinus of the slant's angle
  468.   attr_accessor :sin_angle # sinus of the slant's angle
  469.   attr_accessor :height_limit # horizon's line
  470.   attr_accessor :distance_h # distance between the map's center and the vanishing point
  471.   attr_accessor :slope_value # intermediate value
  472.   attr_accessor :corrective_value # intermediate value
  473.   attr_accessor :height # map's height (in pixel)
  474.   #--------------------------------------------------------------------------
  475.   # * Object Initialization
  476.   #--------------------------------------------------------------------------
  477.   alias initialize_mode7_game_temp initialize
  478.   def initialize
  479.     initialize_mode7_game_temp
  480.     self.pivot = 0
  481.     self.cos_angle = 0.0
  482.     self.sin_angle = 0.0
  483.     self.height_limit = 0
  484.     self.distance_h = 0
  485.     self.slope_value = 0.0
  486.     self.corrective_value = 0.0
  487.     self.height = 0
  488.   end
  489. end
复制代码

Lv3.寻梦者

梦石
0
星屑
3278
在线时间
1120 小时
注册时间
2009-4-15
帖子
815
2
发表于 2014-3-14 14:56:20 | 只看该作者
VA有自己的伪3D地图

点评

我估计他和我一样觉得va伪3d的地是扁的不好看吧。  发表于 2014-3-14 19:46
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
600
在线时间
1118 小时
注册时间
2012-12-24
帖子
831
3
发表于 2014-3-14 18:46:50 | 只看该作者

点击签名档去一个神奇的地方
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
46 小时
注册时间
2014-1-11
帖子
49
4
 楼主| 发表于 2014-3-18 20:38:01 | 只看该作者
江户川洛奇 发表于 2014-3-14 18:46
VA伪3D:http://rpg.blue/thread-282052-1-1.html

不喜欢这个3d....,想要可以立起来的。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-9-25 07:25

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表