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

Project1

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

[转载] 【VA脚本】【已经汉化】地牢地图创造6

[复制链接]

Lv1.梦旅人

梦石
0
星屑
191
在线时间
835 小时
注册时间
2012-9-16
帖子
1811
跳转到指定楼层
1
发表于 2014-1-15 21:12:09 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 yangjunyin2002 于 2014-1-15 21:20 编辑

来自rpgmakerweb.com,注意请在使用时注明来自rpgmakerweb.com
本脚本由小y(yangjunyin2002)汉化,另外注释请不要删除(保留原日站和美站上的作者)。
  1. #==============================================================================
  2. # ■ 地牢创造 6
  3. #   版本: 0.14版   12/01/21 RGSS3
  4. #   作者: Saba Kan
  5. #   英文翻译: kirinelf
  6. #   汉化:yangjunyin2002(66RPG)
  7. #------------------------------------------------------------------------------
  8. #  
  9. #==============================================================================
  10. module Saba
  11.   module Dungeon
  12.     # 最小的图块的大小(很难解释,自己尝试一下)
  13.     # 默认: 7
  14.     MINIMUM_RECT_SIZE = 7

  15.     # 最小的房间地图大小
  16.     # 默认: 3
  17.     MINIMUM_ROOM_SIZE = 3

  18.     # 房间地图和图块的间距
  19.     # 默认: 2
  20.     MARGIN_BETWEEN_RECT_ROOM = 2

  21.     # 走廊的百分比(1/n)
  22.     # Works best with lower values.
  23.     # 默认: 35
  24.     MORE_COUPLE_RATE = 35

  25.     # 储存敌人的变量
  26.     ENEMY_COUNT_VARIABLE = 1

  27.     # 调试模式
  28.     # ・总是在小地图上显示敌人
  29.     DEBUG_MODE = false
  30.   end
  31. end

  32. #=========================================================================
  33. # Do not edit anything under this line unless you know what you're doing!
  34. #=========================================================================

  35. #==============================================================================
  36. # ■ Dungeon_Rect
  37. #------------------------------------------------------------------------------
  38. #  ダンジョンを区切った領域を表します。
  39. # 各 Dungeon_Rect に一つづつ Room が存在します。
  40. #==============================================================================
  41. class Dungeon_Rect
  42.   #--------------------------------------------------------------------------
  43.   # ● 公開インスタンス変数
  44.   #--------------------------------------------------------------------------
  45.   attr_accessor :lx
  46.   attr_accessor :ly
  47.   attr_accessor :hx
  48.   attr_accessor :hy
  49.   attr_accessor :room
  50.   attr_accessor :done_split_v
  51.   attr_accessor :done_split_h
  52.   #--------------------------------------------------------------------------
  53.   # ● オブジェクト初期化
  54.   #--------------------------------------------------------------------------
  55.   def initialize(lx, ly, hx, hy)
  56.     self.lx = lx
  57.     self.ly = ly
  58.     self.hx = hx
  59.     self.hy = hy
  60.     self.done_split_v = false
  61.     self.done_split_h = false
  62.   end
  63. end

  64. #==============================================================================
  65. # ■ Room
  66. #------------------------------------------------------------------------------
  67. #  部屋です。
  68. #==============================================================================
  69. class Room
  70.   #--------------------------------------------------------------------------
  71.   # ● 公開インスタンス変数
  72.   #--------------------------------------------------------------------------
  73.   attr_accessor :lx
  74.   attr_accessor :ly
  75.   attr_accessor :hx
  76.   attr_accessor :hy
  77.   attr_accessor :mapping
  78.   attr_reader :width
  79.   attr_reader :height
  80.   attr_reader :couple_areas  # 通路に面している[x, y]のリスト
  81.   #--------------------------------------------------------------------------
  82.   # ● オブジェクト初期化
  83.   #--------------------------------------------------------------------------
  84.   def initialize(lx, ly, hx, hy)
  85.     self.lx = lx
  86.     self.ly = ly
  87.     self.hx = hx
  88.     self.hy = hy
  89.     @width = hx - lx
  90.     [url=home.php?mod=space&uid=291977]@height[/url] = hy - ly
  91.     @events = {}
  92.     @couple_areas = []
  93.     @mapping = false
  94.   end
  95.   #--------------------------------------------------------------------------
  96.   # ● イベント配置可能数残りを取得
  97.   #--------------------------------------------------------------------------
  98.   def remain
  99.     return (hx - lx) * (hy - ly) -  @events.size - @couple_areas.size
  100.   end
  101.   #--------------------------------------------------------------------------
  102.   # ● 指定のイベントをこの部屋のランダムな場所に配置
  103.   #--------------------------------------------------------------------------
  104.   def put_to_random_place(event)
  105.     begin
  106.       key = [rand(hx - lx) + lx, rand(hy - ly) + ly]
  107.     end while @events[key] != nil || @couple_areas.include?(key)
  108.     @events[key] = event
  109.     event.moveto(key[0], key[1])
  110.   end
  111.   #--------------------------------------------------------------------------
  112.   # ● 指定の座標を含んでいるかを取得
  113.   #--------------------------------------------------------------------------
  114.   def contains(x, y)
  115.     return lx <= x && x < hx && ly <= y && y < hy
  116.   end
  117.   #--------------------------------------------------------------------------
  118.   # ● 指定の座標を明るくするかを取得
  119.   #--------------------------------------------------------------------------
  120.   def right_area?(x, y)
  121.     return lx-1 <= x && x < hx+1 && ly-1 <= y && y < hy+1
  122.   end
  123. end




  124. #==============================================================================
  125. # ■ Couple
  126. #------------------------------------------------------------------------------
  127. #  通路です。
  128. #==============================================================================
  129. class Couple
  130.   #--------------------------------------------------------------------------
  131.   # ● 公開インスタンス変数
  132.   #--------------------------------------------------------------------------
  133.   attr_accessor :rect0
  134.   attr_accessor :rect1
  135.   attr_accessor :direction
  136. end

  137. class Game_Map
  138.   attr_reader :map
  139.   attr_accessor :new_events
  140.   #--------------------------------------------------------------------------
  141.   # ● 定数
  142.   #--------------------------------------------------------------------------
  143.   COUPLE_VERTICAL = 0
  144.   COUPLE_HORIZONAL = 1
  145.   #--------------------------------------------------------------------------
  146.   # ● セットアップ
  147.   #     map_id : マップ ID
  148.   #--------------------------------------------------------------------------
  149.   alias saba_setup setup
  150.   def setup(map_id)
  151.     saba_setup(map_id)
  152.     @random_dungeon = nil
  153.     make_random_dungeon if dungeon?
  154.   end
  155.   #--------------------------------------------------------------------------
  156.   # ● ランダムダンジョンを作成
  157.   #--------------------------------------------------------------------------
  158.   def make_random_dungeon
  159.     @rect_list = []
  160.     @room_list = []
  161.     @couple_list = []
  162.     @map = load_data(sprintf("Data/Map%03d.rvdata2", @map_id))
  163.     @floor_chip_id = @map.data[0, 0, 0]
  164.     @floor_chip_id1 = @map.data[1, 0, 0]
  165.     @edge_chip_id = @map.data[0, 1, 0]
  166.     @wall_chip_id = @map.data[0, 2, 0]
  167.     @blank_chip_id = @map.data[0, 4, 0]
  168.     @object_chip_id0 = @map.data[0, 3, 0]
  169.     @object_chip_id1 = @map.data[0, 3, 1]
  170.     @object_chip_id2 = @map.data[0, 3, 2]
  171.     make_rect
  172.     make_room
  173.     make_couple_more

  174.     @init_phase = true

  175.     put_blank_tiles
  176.     put_couple_tiles
  177.     put_room_tiles
  178.     put_shadow
  179.     put_wall_tiles
  180.     put_edge_tiles

  181.     setup_dungeon_events
  182.     @random_data = @map.data
  183.     @last_moving = false

  184.   end
  185.   #--------------------------------------------------------------------------
  186.   # ● 区切りを作成
  187.   #--------------------------------------------------------------------------
  188.   def make_rect
  189.     split_rect(add_rect(0, 1, @map.width, @map.height))
  190.   end
  191.   #--------------------------------------------------------------------------
  192.   # ● 指定の DungeonRect を区切る
  193.   #--------------------------------------------------------------------------
  194.   def split_rect(parent)
  195.     if (parent.hy - parent.ly <= Saba::Dungeon::MINIMUM_RECT_SIZE * 2)
  196.       parent.done_split_v = true
  197.     end
  198.     if (parent.hx - parent.lx <= Saba::Dungeon::MINIMUM_RECT_SIZE * 2)
  199.       parent.done_split_h = true;
  200.     end
  201.     if ((parent.done_split_v) &&  (parent.done_split_h))
  202.       return
  203.     end
  204.     child = add_rect(parent.lx, parent.ly, parent.hx, parent.hy)
  205.     unless parent.done_split_v
  206.       split_coord_y = random_range(parent.ly + Saba::Dungeon::MINIMUM_RECT_SIZE, parent.hy - Saba::Dungeon::MINIMUM_RECT_SIZE)
  207.       parent.hy = split_coord_y
  208.       child.ly = split_coord_y
  209.       parent.done_split_v = true
  210.       child.done_split_v = true
  211.       add_couple(COUPLE_VERTICAL, parent, child)
  212.       split_rect(parent)
  213.       split_rect(child)
  214.     else
  215.       split_coord_x = random_range(parent.lx + Saba::Dungeon::MINIMUM_RECT_SIZE, parent.hx - Saba::Dungeon::MINIMUM_RECT_SIZE)
  216.       parent.hx = split_coord_x
  217.       child.lx = split_coord_x
  218.       parent.done_split_h = true
  219.       child.done_split_h = true
  220.       add_couple(COUPLE_HORIZONAL, parent, child)
  221.       split_rect(parent)
  222.       split_rect(child)
  223.     end
  224.   end
  225.   #--------------------------------------------------------------------------
  226.   # ● さらに道を作成
  227.   #--------------------------------------------------------------------------
  228.   def make_couple_more
  229.     rectmap = {}
  230.     for rect in @rect_list
  231.       for i in rect.lx...rect.hx
  232.         for j in rect.ly...rect.hy
  233.           rectmap[[i, j]] = rect
  234.         end
  235.       end
  236.     end

  237.     for i in 0..(@map.width-2)
  238.       for j in 1..(@map.height-2)
  239.         if rectmap[[i, j]] != rectmap[[i, j + 1]]
  240.           if rand(Saba::Dungeon::MORE_COUPLE_RATE) == 0
  241.             add_couple(COUPLE_VERTICAL, rectmap[[i,j]], rectmap[[i, j + 1]])
  242.           end
  243.         end
  244.         if rectmap[[i, j]] != rectmap[[i + 1, j]]
  245.           if rand(Saba::Dungeon::MORE_COUPLE_RATE) == 0
  246.             add_couple(COUPLE_HORIZONAL, rectmap[[i, j]], rectmap[[i + 1, j]])
  247.           end
  248.         end
  249.       end
  250.     end
  251.   end
  252.   #--------------------------------------------------------------------------
  253.   # ● ランダムダンジョンか?
  254.   #--------------------------------------------------------------------------
  255.   def dungeon?
  256.     if @random_dungeon != nil
  257.       return @random_dungeon
  258.     end
  259.     unless @map_infos
  260.       @map_infos = load_data("Data/MapInfos.rvdata2")
  261.     end
  262.     @random_dungeon = @map_infos[@map_id].name.include?("@")
  263.     return @random_dungeon
  264.   end
  265.   #--------------------------------------------------------------------------
  266.   # ● 指定の区間の中でランダムな値を取得
  267.   #--------------------------------------------------------------------------
  268.   def random_range(b, e)
  269.     return (rand(e - <img src='http://forums.rpgmakerweb.com/public/style_emoticons/<#EMO_DIR#>/cool.png' class='bbc_emoticon' alt='B)' /> + <img src='http://forums.rpgmakerweb.com/public/style_emoticons/<#EMO_DIR#>/cool.png' class='bbc_emoticon' alt='B)' />.to_i
  270.   end
  271.   #--------------------------------------------------------------------------
  272.   # ● DungeonRect を作成して追加
  273.   #--------------------------------------------------------------------------
  274.   def add_rect(lx, ly, hx, hy)
  275.     rect = Dungeon_Rect.new(lx, ly, hx, hy)
  276.     @rect_list.push(rect)
  277.     return rect
  278.   end
  279.   #--------------------------------------------------------------------------
  280.   # ● Room を作成して追加
  281.   #--------------------------------------------------------------------------
  282.   def add_room(lx, ly, hx, hy)
  283.     room = Room.new(lx, ly, hx, hy)
  284.     @room_list.push(room)
  285.     return room
  286.   end
  287.   #--------------------------------------------------------------------------
  288.   # ● 部屋を作成
  289.   #--------------------------------------------------------------------------
  290.   def make_room
  291.     for rect in @rect_list
  292.       w = random_range(Saba::Dungeon::MINIMUM_ROOM_SIZE, rect.hx - rect.lx - (Saba::Dungeon::MARGIN_BETWEEN_RECT_ROOM * 2) + 1);
  293.       h = random_range(Saba::Dungeon::MINIMUM_ROOM_SIZE, rect.hy - rect.ly - (Saba::Dungeon::MARGIN_BETWEEN_RECT_ROOM * 2) + 1);
  294.       x = random_range(rect.lx + Saba::Dungeon::MARGIN_BETWEEN_RECT_ROOM, rect.hx - Saba::Dungeon::MARGIN_BETWEEN_RECT_ROOM - w + 1);
  295.       y = random_range(rect.ly + Saba::Dungeon::MARGIN_BETWEEN_RECT_ROOM, rect.hy - Saba::Dungeon::MARGIN_BETWEEN_RECT_ROOM - h + 1);
  296.       rect.room = add_room(x, y, x + w, y + h);
  297.     end
  298.   end
  299.   #--------------------------------------------------------------------------
  300.   # ● 通路 を作成して追加
  301.   #--------------------------------------------------------------------------
  302.   def add_couple(direction, rect0, rect1)
  303.     @couple_list.each {|c|
  304.       if (c.rect0 == rect0 && c.rect1 == rect1) ||
  305.          (c.rect0 == rect1 && c.rect1 == rect0)
  306.         # 重複はつくらない
  307.         return
  308.       end
  309.     }
  310.     couple = Couple.new
  311.     couple.direction = direction
  312.     couple.rect0 = rect0
  313.     couple.rect1 = rect1
  314.     @couple_list.push(couple)
  315.     return couple
  316.   end
  317.   #--------------------------------------------------------------------------
  318.   # ● 空きチップを配置
  319.   #--------------------------------------------------------------------------
  320.   def put_blank_tiles
  321.     for x in [email protected]
  322.       for y in [email protected]
  323.         @map.data[x, y, 0] = @blank_chip_id
  324.         @map.data[x, y, 1] = 0
  325.         @map.data[x, y, 2] = 0
  326.       end
  327.     end
  328.   end
  329.   #--------------------------------------------------------------------------
  330.   # ● 床チップを配置
  331.   #--------------------------------------------------------------------------
  332.   def put_room_tiles
  333.     for rect in @rect_list
  334.       room = rect.room
  335.       (room.hx - room.lx).times do |x|
  336.         (room.hy - room.ly).times do |y|
  337.           put_floor_tile(x + room.lx, y + room.ly)
  338.         end
  339.       end
  340.     end
  341.   end
  342.   def put_floor_tile(x, y)
  343.     if @floor_chip_id1 > 0 && rand(10) == 0
  344.       @map.data[x, y, 0] = @floor_chip_id1
  345.     else
  346.       @map.data[x, y, 0] = @floor_chip_id
  347.     end
  348.   end
  349.   #--------------------------------------------------------------------------
  350.   # ● 通路チップを配置
  351.   #--------------------------------------------------------------------------
  352.   def put_couple_tiles
  353.     for couple in @couple_list
  354.       case couple.direction
  355.       when COUPLE_HORIZONAL then
  356.         unless couple.rect0.hx == couple.rect1.lx
  357.           p "Errorx:" + couple.rect0.hx.to_s + couple.rect1.lx .to_s
  358.           next
  359.         end
  360.         c0x = couple.rect0.hx
  361.         c0y = random_range(couple.rect0.room.ly + 1, couple.rect0.room.hy)
  362.         c1x = couple.rect1.lx
  363.         c1y = random_range(couple.rect1.room.ly + 1, couple.rect1.room.hy)
  364.         line(c0x, c0y, c1x, c1y);
  365.         line(couple.rect0.room.hx, c0y, c0x, c0y)
  366.         line(couple.rect1.room.lx, c1y, c1x, c1y)
  367.         couple.rect0.room.couple_areas.push([couple.rect0.room.hx-1, c0y])
  368.         couple.rect1.room.couple_areas.push([couple.rect1.room.lx, c1y])
  369.       when COUPLE_VERTICAL then
  370.         unless couple.rect0.hy == couple.rect1.ly
  371.           p "Errory:" + couple.rect0.hy.to_s + " " + couple.rect1.ly .to_s
  372.           next
  373.         end
  374.         c0x = random_range(couple.rect0.room.lx + 1, couple.rect0.room.hx)
  375.         c0y = couple.rect0.hy
  376.         c1x = random_range(couple.rect1.room.lx + 1, couple.rect1.room.hx)
  377.         c1y = couple.rect1.ly
  378.         line(c0x, c0y, c1x, c1y)
  379.         line(c0x, couple.rect0.room.hy, c0x, c0y)
  380.         line(c1x, couple.rect1.room.ly, c1x, c1y)
  381.         couple.rect0.room.couple_areas.push([c0x, couple.rect0.room.hy-1])
  382.         couple.rect1.room.couple_areas.push([c1x, couple.rect1.room.ly])
  383.       end
  384.     end
  385.   end
  386.   #--------------------------------------------------------------------------
  387.   # ● 指定の座標間で床を配置
  388.   #--------------------------------------------------------------------------
  389.   def line(x0, y0, x1, y1)
  390.     min_x = [x0, x1].min
  391.     max_x = [x0, x1].max
  392.     min_y = [y0, y1].min
  393.     max_y = [y0, y1].max
  394.     if ((x0 <= x1) && (y0 >= y1))
  395.       for i in min_x..max_x
  396.         put_floor_tile(i, max_y)
  397.       end
  398.       for j in min_y..max_y
  399.         put_floor_tile(max_x, j)
  400.       end
  401.     elsif ((x0 > x1) && (y0 > y1))
  402.       for i in min_x..max_x
  403.         put_floor_tile(i, min_y)
  404.       end
  405.       for j in min_y..max_y
  406.         put_floor_tile(max_x, j)
  407.       end
  408.     elsif ((x0 > x1) && (y0 <= y1))
  409.       for i in min_x..max_x
  410.         put_floor_tile(i, min_y)
  411.       end
  412.       for j in min_y..max_y
  413.         put_floor_tile(max_x, j)
  414.       end
  415.     elsif ((x0 <= x1) && (y0 < y1))
  416.       for i in min_x..max_x
  417.         put_floor_tile(i, max_y)
  418.       end
  419.       for j in min_y..max_y
  420.         put_floor_tile(min_x, j)
  421.       end
  422.     end
  423.   end
  424.   #--------------------------------------------------------------------------
  425.   # ● 壁チップを配置
  426.   #--------------------------------------------------------------------------
  427.   def put_wall_tiles
  428.     for y in ([email protected]).to_a.reverse
  429.       for x in [email protected]
  430.         next unless  floor?(x, y)
  431.         next if floor?(x, y-1)
  432.         @map.data[x, y-1, 0] = @wall_chip_id + 15
  433.       end
  434.     end

  435.     for y in ([email protected]).to_a.reverse
  436.       for x in [email protected]
  437.         tile = @map.data[x, y, 0]
  438.         next unless tile ==  @wall_chip_id + 15
  439.         if floor?(x, y-1)
  440.           put_object_tile(x, y)
  441.           next
  442.         end
  443.         if floor?(x-1, y) || blank?(x-1, y)
  444.           if floor?(x+1, y) || blank?(x+1, y)
  445.             @map.data[x, y, 0] = @wall_chip_id + 15
  446.           else
  447.             @map.data[x, y, 0] = @wall_chip_id + 11
  448.           end
  449.         else
  450.           if floor?(x+1, y) || blank?(x+1, y)
  451.             @map.data[x, y, 0] = @wall_chip_id + 14
  452.           else
  453.             @map.data[x, y, 0] = @wall_chip_id + 10
  454.           end
  455.         end
  456.       end
  457.     end
  458.   end
  459.   #--------------------------------------------------------------------------
  460.   # ● 障害物チップを配置
  461.   #--------------------------------------------------------------------------
  462.   def put_object_tile(x, y)
  463.     @map.data[x, y, 0] = @object_chip_id0
  464.     @map.data[x, y, 1] = @object_chip_id1
  465.     @map.data[x, y, 2] = @object_chip_id2
  466.   end
  467.   #--------------------------------------------------------------------------
  468.   # ● 境界チップを配置
  469.   #--------------------------------------------------------------------------
  470.   def put_edge_tiles
  471.     for y in ([email protected]).to_a.reverse
  472.       for x in [email protected]
  473.         tile = @map.data[x, y, 0]
  474.         next if inner?(x, y)
  475.         if inner?(x, y-1)
  476.           if inner?(x, y+1)
  477.             if inner?(x-1, y)
  478.               if inner?(x+1, y)
  479.                 @map.data[x, y, 0] = @edge_chip_id + 46
  480.               else
  481.                 @map.data[x, y, 0] = @edge_chip_id + 43
  482.               end
  483.             else
  484.               if inner?(x+1, y)
  485.                 @map.data[x, y, 0] = @edge_chip_id + 45
  486.               else
  487.                 @map.data[x, y, 0] = @edge_chip_id + 33
  488.               end
  489.             end
  490.           else
  491.             if inner?(x-1, y)
  492.               if inner?(x+1, y)
  493.                 @map.data[x, y, 0] = @edge_chip_id + 42
  494.               else
  495.                 @map.data[x, y, 0] = @edge_chip_id + 34
  496.               end
  497.             else
  498.               if inner?(x+1, y)
  499.                 @map.data[x, y, 0] = @edge_chip_id + 36
  500.               else
  501.                 @map.data[x, y, 0] = @edge_chip_id + 20
  502.               end
  503.             end
  504.           end
  505.         else
  506.           if inner?(x, y+1)
  507.             if inner?(x-1, y)
  508.               if inner?(x+1, y)
  509.                 @map.data[x, y, 0] = @edge_chip_id + 44
  510.               else
  511.                 @map.data[x, y, 0] = @edge_chip_id + 40
  512.               end
  513.             else
  514.               if inner?(x+1, y)
  515.                 @map.data[x, y, 0] = @edge_chip_id + 38
  516.               else
  517.                 @map.data[x, y, 0] = @edge_chip_id + 28
  518.               end
  519.             end
  520.           else
  521.             if inner?(x-1, y)
  522.               if inner?(x+1, y)
  523.                 @map.data[x, y, 0] = @edge_chip_id + 32
  524.               else
  525.                 @map.data[x, y, 0] = @edge_chip_id + 16
  526.               end
  527.             else
  528.               if inner?(x+1, y)
  529.                 @map.data[x, y, 0] = @edge_chip_id + 24
  530.               else
  531.                 if inner?(x+1, y+1) || inner?(x+1, y-1) ||
  532.                    inner?(x-1, y-1) || inner?(x-1, y+1)
  533.                   @map.data[x, y, 0] = @edge_chip_id
  534.                 else
  535.                   @map.data[x, y, 0] = @blank_chip_id
  536.                 end
  537.               end
  538.             end
  539.           end
  540.         end
  541.       end
  542.     end
  543.   end
  544.   #--------------------------------------------------------------------------
  545.   # ● 影タイルを置きます
  546.   #--------------------------------------------------------------------------
  547.   def put_shadow
  548.     for y in [email protected]
  549.       for x in [email protected]
  550.         next unless floor?(x, y)
  551.         next if floor?(x-1, y-1)
  552.         next unless blank?(x-1, y)
  553.         @map.data[x, y, 3] = 5
  554.       end
  555.     end
  556.   end
  557.   #--------------------------------------------------------------------------
  558.   # ● 指定の座標が境界の内側かどうか
  559.   #--------------------------------------------------------------------------
  560.   def inner?(x, y)
  561.     return floor?(x, y) || wall?(x, y) || object?(x, y)
  562.   end
  563.   #--------------------------------------------------------------------------
  564.   # ● 指定の座標が床かどうか
  565.   #--------------------------------------------------------------------------
  566.   def floor?(x, y)
  567.     return false if @map.data[x, y, 2] == @object_chip_id2
  568.     return true if @floor_chip_id1 && @map.data[x, y, 0] == @floor_chip_id1
  569.     return @map.data[x, y, 0] == @floor_chip_id
  570.   end
  571.   #--------------------------------------------------------------------------
  572.   # ● 指定の座標がカラかどうか
  573.   #--------------------------------------------------------------------------
  574.   def blank?(x, y)
  575.     return @map.data[x, y, 0] == @blank_chip_id
  576.   end
  577.   #--------------------------------------------------------------------------
  578.   # ● 指定の座標が障害物かどうか
  579.   #--------------------------------------------------------------------------
  580.   def object?(x, y)
  581.     return @map.data[x, y, 0] == @object_chip_id0
  582.   end
  583.   #--------------------------------------------------------------------------
  584.   # ● 指定の座標が壁かどうか
  585.   #--------------------------------------------------------------------------
  586.   def wall?(x, y)
  587.     tile = @map.data[x, y, 0]
  588.     return false if tile == nil || tile == 0
  589.     return tile >= @wall_chip_id && tile <= @wall_chip_id + 15
  590.   end
  591.   #--------------------------------------------------------------------------
  592.   # ● プレイヤーをランダムな位置に配置
  593.   #--------------------------------------------------------------------------
  594.   def setup_player_initial_position
  595.     put_to_random_place($game_player) unless floor?($game_player.x, $game_player.y)
  596.   end
  597.   #--------------------------------------------------------------------------
  598.   # ● ダンジョンの特殊なイベントをランダムな場所に配置する
  599.   #--------------------------------------------------------------------------
  600.   def setup_dungeon_events
  601.     @next_enemy_event_id = 10000
  602.     @enemy_events = []

  603.     for event in @events.values
  604.       if event.event.name.include?("*")
  605.         @enemy_events.push(event.event)
  606.         self.events[event.id].erase
  607.       else
  608.         put_to_random_place(event)
  609.       end
  610.     end
  611.     setup_enemy
  612.   end
  613.   #--------------------------------------------------------------------------
  614.   # ● 敵イベントの初期設定
  615.   #--------------------------------------------------------------------------
  616.   def setup_enemy
  617.     $game_variables[Saba::Dungeon::ENEMY_COUNT_VARIABLE] = 0
  618.     return if @enemy_events.count == 0
  619.     @map.encounter_step.times do |i|
  620.       add_random_enemy
  621.     end
  622.   end
  623.   #--------------------------------------------------------------------------
  624.   # ● ランダムな敵イベントをランダムな場所に配置する
  625.   #--------------------------------------------------------------------------
  626.   def add_random_enemy
  627.     add_enemy(rand(@enemy_events.count))
  628.   end
  629.   #--------------------------------------------------------------------------
  630.   # ● 指定の敵イベントを複製してランダムな場所に配置する
  631.   #--------------------------------------------------------------------------
  632.   def add_enemy(event_id)
  633.     enemy_event = @enemy_events[event_id]
  634.     event = Game_Event.new(@map_id, enemy_event)

  635.     # イベントのループ内では新しいイベントを追加できないので、
  636.     # 一旦別の場所に格納
  637.     @new_events = {} unless @new_events
  638.     @new_events[@next_enemy_event_id] = event

  639.     event.event_id = @next_enemy_event_id
  640.     @next_enemy_event_id += 1
  641.     $game_variables[Saba::Dungeon::ENEMY_COUNT_VARIABLE] += 1
  642.   end
  643.   alias saba_randomdungeon_update_events update_events
  644.   def update_events
  645.     saba_randomdungeon_update_events
  646.     if @new_events
  647.       for key in @new_events.keys
  648.         @events[key] = @new_events[key]
  649.         put_to_random_place(@events[key])
  650.         $game_minimap.add_event(@events[key]) if $game_minimap
  651.       end
  652.     end
  653.     @init_phase = false
  654.   end
  655.   #--------------------------------------------------------------------------
  656.   # ● 指定のイベントをランダムな場所に配置する
  657.   #--------------------------------------------------------------------------
  658.   def put_to_random_place(event)
  659.     if @init_phase
  660.       room_list = @room_list.select {|room| room.remain != 0 }
  661.     else
  662.       room_list = @room_list.select {|room| room.remain != 0 && room != $game_player.room }
  663.     end
  664.     room = room_list[rand(room_list.size)]
  665.     room.put_to_random_place(event)
  666.   end

  667.   #--------------------------------------------------------------------------
  668.   # ● 起動中のマップイベントを検出/セットアップ
  669.   #--------------------------------------------------------------------------
  670.   def setup_starting_map_event
  671.     event = @events.values.find {|event| event.starting }
  672.     event.clear_starting_flag if event
  673.     @interpreter.setup(event.list, event.event_id) if event
  674.     event
  675.   end
  676.   def room(x, y)
  677.     for rect in @rect_list
  678.       if rect.room.contains(x, y)
  679.         return rect.room
  680.       end
  681.     end
  682.     return nil
  683.   end

  684. end


  685. class Spriteset_Map
  686.   #--------------------------------------------------------------------------
  687.   # ● オブジェクト初期化
  688.   #--------------------------------------------------------------------------
  689.   alias saba_dungeon_initialize initialize
  690.   def initialize
  691.     saba_dungeon_initialize
  692.     @dark_sprite = Sprite_Dark.new(@viewport_dark)
  693.     update_dark_sprite_visible
  694.   end
  695.   #--------------------------------------------------------------------------
  696.   # ● ビューポートの作成
  697.   #--------------------------------------------------------------------------
  698.   alias saba_dungeon_create_viewports create_viewports
  699.   def create_viewports
  700.     saba_dungeon_create_viewports
  701.     @viewport_dark = Viewport.new
  702.   end
  703.   #--------------------------------------------------------------------------
  704.   # ● フレーム更新
  705.   #--------------------------------------------------------------------------
  706.   alias saba_dungeon_update update
  707.   def update
  708.     if $game_map.new_events
  709.       $game_map.new_events.values.each do |event|
  710.         @character_sprites.push(Sprite_Character.new(@viewport1, event))
  711.       end
  712.       $game_map.new_events = nil
  713.     end
  714.     saba_dungeon_update
  715.     update_dark_sprite_visible
  716.   end
  717.   #--------------------------------------------------------------------------
  718.   # ● 暗闇スプライトの表示更新
  719.   #--------------------------------------------------------------------------
  720.   def update_dark_sprite_visible
  721.     if @dark_sprite
  722.       if $game_map.dungeon?
  723.         @dark_sprite.visible = true
  724.         @dark_sprite.update
  725.       else
  726.         @dark_sprite.visible = false
  727.       end
  728.     end
  729.   end
  730.   #--------------------------------------------------------------------------
  731.   # ● 解放
  732.   #--------------------------------------------------------------------------
  733.   alias saba_dungeon_dispose dispose
  734.   def dispose
  735.     @dark_sprite.dispose if @dark_sprite
  736.     saba_dungeon_dispose
  737.   end
  738.   #--------------------------------------------------------------------------
  739.   # ● ビューポートの解放
  740.   #--------------------------------------------------------------------------
  741.   alias saba_dungeon_dispose_viewports dispose_viewports
  742.   def dispose_viewports
  743.     saba_dungeon_dispose_viewports
  744.     @viewport_dark.dispose
  745.   end
  746.   #--------------------------------------------------------------------------
  747.   # ● キャラクタースプライトの作成
  748.   #--------------------------------------------------------------------------
  749.   alias saba_dungeon_create_characters create_characters
  750.   def create_characters
  751.     saba_dungeon_create_characters
  752.     $game_map.new_events = nil
  753.   end
  754. end

  755. class Sprite_Character
  756.   alias saba_dangeon_update update
  757.   def update
  758.     saba_dangeon_update
  759.     return unless $game_map.dungeon?
  760.     if @character.is_a?(Game_Event)
  761. #~       if [url=home.php?mod=space&uid=33356]@Static[/url] == nil
  762. #~         @static = @character.name.to_i > 1000
  763. #~       end
  764. #~       if @static
  765. #~         self.visible = true
  766.         self.visible = false
  767.       if $game_player.room
  768.         self.visible = $game_player.room.contains(@character.x, @character.y)
  769.       end

  770.       case $game_player.distance(@character)
  771.         when 1;
  772.           self.visible = true
  773.           @last_visible = self.visible
  774.         when 2;
  775.           self.visible |= @last_visible
  776.           @last_visible = false
  777.       end

  778.     end
  779.   end
  780. end

  781. class Sprite_Dark < Sprite_Base
  782.   def initialize(viewport)
  783.     super(viewport)
  784.     self.bitmap = Bitmap.new(Graphics.width+32*32, Graphics.height+32*32)
  785.     refresh
  786.     update
  787.   end
  788.   def update
  789.     super

  790.     if @last_room != $game_player.room
  791.       refresh
  792.       @last_room = $game_player.room
  793.     end
  794.     if @last_room
  795.       self.viewport.ox = -@start_x + $game_map.display_x*32
  796.       self.viewport.oy = -@start_y + $game_map.display_y*32
  797.       if (self.viewport.ox - self.bitmap.width / 2 + Graphics.width / 2).abs > Graphics.width / 2 ||
  798.          (self.viewport.oy - self.bitmap.height / 2 + Graphics.height / 2).abs > Graphics.height / 2
  799.         refresh
  800.       end
  801.       self.viewport.ox = -@start_x + $game_map.display_x*32
  802.       self.viewport.oy = -@start_y + $game_map.display_y*32

  803.     else
  804.       self.viewport.ox = -$game_player.screen_x + self.bitmap.width / 2
  805.       self.viewport.oy = -$game_player.screen_y + self.bitmap.height / 2 + 16
  806.     end
  807.   end
  808.   def refresh
  809.     self.bitmap.clear
  810.     self.bitmap.fill_rect(0, 0, self.bitmap.width, self.bitmap.height, Color.new(0, 0, 0, 100))
  811.     room = $game_player.room
  812.     if room == nil
  813.       rect = Rect.new
  814.       rect.x = self.bitmap.width / 2 - 48
  815.       rect.y = self.bitmap.height / 2 - 45
  816.       rect.width = 96
  817.       rect.height = 96
  818.       self.bitmap.clear_rect(rect)

  819.       edge = Cache.system("dark_edge2")
  820.       self.bitmap.blt(rect.x, rect.y, edge, edge.rect)
  821.     else
  822.       rect = Rect.new
  823.       rect.x = self.bitmap.width / 2 - ($game_player.x - room.lx) * 32
  824.       rect.y = self.bitmap.height / 2 - ($game_player.y - room.ly) * 32
  825.       rect.width = (room.hx - room.lx+2) * 32
  826.       rect.height = (room.hy - room.ly+2) * 32
  827.       self.bitmap.clear_rect(rect)
  828.       @start_x = $game_map.display_x*32 - self.bitmap.width / 2 + ($game_player.x - $game_map.display_x - 1)*32
  829.       @start_y = $game_map.display_y*32 - self.bitmap.height / 2 + ($game_player.y - $game_map.display_y - 1)*32

  830.       edge = Cache.system("dark_edge")
  831.       self.bitmap.blt(rect.x, rect.y, edge, Rect.new(0, 0, 32, 32))
  832.       self.bitmap.blt(rect.x+rect.width-32, rect.y, edge, Rect.new(32, 0, 32, 32))
  833.       self.bitmap.blt(rect.x, rect.y+rect.height-32, edge, Rect.new(0, 32, 32, 32))
  834.       self.bitmap.blt(rect.x+rect.width-32, rect.y+rect.height-32, edge, Rect.new(32, 32, 32, 32))
  835.     end
  836.   end
  837. end
  838. class Game_Event
  839.   attr_reader :event
  840.   attr_accessor :event_id
  841.   attr_reader   :erased
  842.   def name
  843.     @event.name
  844.   end
  845.   alias saba_dungeon_erase erase
  846.   def erase
  847.     saba_dungeon_erase
  848.     return unless enemy?
  849.     $game_variables[Saba::Dungeon::ENEMY_COUNT_VARIABLE] -= 1
  850.   end
  851.   def enemy?
  852.     return name.include?("*")
  853.   end
  854. end

  855. class Game_Player
  856.   #--------------------------------------------------------------------------
  857.   # ● 指定位置に移動
  858.   #--------------------------------------------------------------------------
  859.   alias saba_dungeon_moveto moveto
  860.   def moveto(x, y)
  861.     saba_dungeon_moveto(x, y)
  862.     $game_map.setup_player_initial_position if $game_map.dungeon?
  863.   end
  864.   def distance(event)
  865.     min = $game_player.distance_xy_from(event.x, event.y)
  866.     return min unless $game_player.followers.visible
  867.     $game_player.followers.each do |character|
  868.       dist = character.distance_xy_from(event.x, event.y)
  869.       if dist < min
  870.         min = dist
  871.       end
  872.     end
  873.     return min
  874.   end
  875. end


  876. class Game_Character
  877.   #--------------------------------------------------------------------------
  878.   # ● 距離計算
  879.   #--------------------------------------------------------------------------
  880.   def distance_xy_from(x, y)
  881.     sx = distance_x_from(x)
  882.     sy = distance_y_from(y)
  883.     return [sx.abs, sy.abs].max
  884.   end
  885. end
复制代码

点评

脚本有错,不能使用,把脚本放在main上面后运行提示287行错误,无法解析<  发表于 2014-1-23 00:41

评分

参与人数 1星屑 +200 收起 理由
东来东去 + 200 塞糖

查看全部评分


——旧坑欢迎戳

Lv1.梦旅人

CODE GEASS

梦石
0
星屑
50
在线时间
619 小时
注册时间
2010-8-16
帖子
534
2
发表于 2014-1-16 19:12:29 | 只看该作者
脚本作用是什么...能给个截图看看嘛。

点评

很抱歉我不用VA了。。话说好像就是可以生成迷宫地图的说。那种牢房地图。  发表于 2014-1-16 19:19
江南何日?引人残,卷西风岁月,迷人倦。
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
540
在线时间
13 小时
注册时间
2014-1-20
帖子
3
3
发表于 2014-1-21 15:54:45 | 只看该作者
完全不懂,。。。。。。完全不懂。。。。
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
3228
在线时间
1120 小时
注册时间
2009-4-15
帖子
815
4
发表于 2014-1-22 18:24:55 | 只看该作者
一,这个脚本是干什么的?
二,这个脚本如何使用?(别跟我说什么放到main上面,这个我会,我的意思是,放到main上面了以后呢?还要不要设定其他的?比如备注栏里写注释之类的)

点评

饿,你换个网址就好了。默认的是外站,国内无法连接  发表于 2014-1-23 10:40
其实我也不太清楚,我不是VA党。这好像是生成地图的,可以放进去后自动联网并创建迷宫地牢地图,好像就在脚本里设置而已了。。。  发表于 2014-1-22 19:45
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
87 小时
注册时间
2014-1-14
帖子
74
5
发表于 2014-1-25 13:08:54 | 只看该作者
所有地图都会自动生成?还是个别的图会生成?生成条件是什么?
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-25 18:08

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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