Ogłoszenie 

Uwaga! To forum jest w trybie offline.
Wszelką pomoc uzyskasz pod adresem
forum.ultimateam.pl


Administracja Forum


Poprzedni temat «» Następny temat
Minimapa
Autor Wiadomość
The Big Master 




Preferowany:
RPG Maker XP

Pomógł: 6 razy
Dołączył: 19 Gru 2012
Posty: 81
Skąd: Masz taki nr. IQ ?
Wysłany: Nie 27 Sty, 2013 13:52
Minimapa
~ KMS_MiniMap ~


Krótki opis:
Skrypt tworzy niezbyt wyszukaną jednak w miarę dobrą minimape

Autor:
TOMY@Kamesoft///Nie jestem do końca pewny

Kompatybilność:
RPG Maker VX Ace

Skrypt:
Spoiler:

Kod:
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#_/    ◆ ミニマップ - KMS_MiniMap ◆ VX Ace ◆
#_/    ◇ Last update : 2012/02/12  (TOMY@Kamesoft) ◇
#_/----------------------------------------------------------------------------
#_/  ミニマップ表示機能を追加します。
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

#==============================================================================
# ★ 設定項目 - BEGIN Setting ★
#==============================================================================

module KMS_MiniMap
  # ◆ ミニマップ表示切替ボタン
  #  nil にするとボタン切り替え無効。
  SWITCH_BUTTON = :Z

  # ◆ ミニマップ表示位置・サイズ (X, Y, 幅, 高さ)
  MAP_RECT = Rect.new(364, 20, 160, 120)
  # ◆ ミニマップの Z 座標
  #  大きくしすぎると色々なものに被ります。
  MAP_Z = 0
  # ◆ 1マスのサイズ
  #  3 以上を推奨。
  GRID_SIZE = 5

  # ◆ Odcienie Kolorów są w (nawiasach) można je modyfikować)
  FOREGROUND_COLOR = Color.new(192, 192, 224, 160)  # Kolor forgrouda
  BACKGROUND_COLOR = Color.new(  0,   0, 160, 160)  # Kolor tła
  POSITION_COLOR   = Color.new(255,   0,   0, 192)  # Kolor pozycji
  MOVE_EVENT_COLOR = Color.new(255, 160,   0, 192)  # Kolor ruszającego się eventa
  VEHICLE_COLOR    = Color.new( 96, 128,   0, 192)  # Kolor Vechicle

  # ◆ オブジェクトの色
  #  要素の先頭から順に OBJ1, OBJ2, ... に対応。
  Kolor Objectów = [
    Color.new(  0, 128,   0, 192),  # OBJ 1
    Color.new(  0, 160, 160, 192),  # OBJ 2
    Color.new(160,   0, 160, 192),  # OBJ 3
  ]  # ← この ] は消さないこと!

  # ◆ アイコンの点滅の強さ
  #  5 ~ 8 あたりを推奨。
  BLINK_LEVEL = 7

  # ◆ マップのキャッシュ数
  #  この数を超えると、長期間参照していないものから削除。
  CACHE_NUM = 10
end

#==============================================================================
# ☆ 設定ここまで - END Setting ☆
#==============================================================================

$kms_imported = {} if $kms_imported == nil
$kms_imported["MiniMap"] = true

module KMS_MiniMap
  # ミニマップ非表示
  REGEX_NO_MINIMAP_NOTE = /<(?:&#12511;&#12491;&#12510;&#12483;&#12503;|MINIMAP)\s*(?:&#38750;&#34920;&#31034;|HIDE)>/i
  REGEX_NO_MINIMAP_NAME = /\[NOMAP\]/i

  # &#38556;&#23475;&#29289;
  REGEX_WALL_EVENT = /<(?:&#12511;&#12491;&#12510;&#12483;&#12503;|MINIMAP)\s*(?:&#22721;|&#38556;&#23475;&#29289;|WALL)>/i

  # &#31227;&#21205;&#12452;&#12505;&#12531;&#12488;
  REGEX_MOVE_EVENT = /<(?:&#12511;&#12491;&#12510;&#12483;&#12503;|MINIMAP)\s*(?:&#31227;&#21205;|MOVE)>/i

  # &#12458;&#12502;&#12472;&#12455;&#12463;&#12488;
  REGEX_OBJECT = /<(?:&#12511;&#12491;&#12510;&#12483;&#12503;|MINIMAP)\s+OBJ(?:ECT)?\s*(\d+)>/i
end

# *****************************************************************************

#==============================================================================
# &#9633; KMS_Commands
#==============================================================================

module KMS_Commands
  module_function
  #--------------------------------------------------------------------------
  # &#9675; &#12511;&#12491;&#12510;&#12483;&#12503;&#12434;&#34920;&#31034;
  #--------------------------------------------------------------------------
  def show_minimap
    $game_temp.minimap_manual_visible = true
    $game_system.minimap_show         = true
  end
  #--------------------------------------------------------------------------
  # &#9675; &#12511;&#12491;&#12510;&#12483;&#12503;&#12434;&#38560;&#12377;
  #--------------------------------------------------------------------------
  def hide_minimap
    $game_system.minimap_show = false
  end
  #--------------------------------------------------------------------------
  # &#9675; &#12511;&#12491;&#12510;&#12483;&#12503;&#34920;&#31034;&#29366;&#24907;&#12398;&#21462;&#24471;
  #--------------------------------------------------------------------------
  def minimap_showing?
    return $game_system.minimap_show
  end
  #--------------------------------------------------------------------------
  # &#9675; &#12511;&#12491;&#12510;&#12483;&#12503;&#12434;&#12522;&#12501;&#12524;&#12483;&#12471;&#12517;
  #--------------------------------------------------------------------------
  def refresh_minimap
    return unless SceneManager.scene_is?(Scene_Map)

    $game_map.refresh if $game_map.need_refresh
    SceneManager.scene.refresh_minimap
  end
  #--------------------------------------------------------------------------
  # &#9675; &#12511;&#12491;&#12510;&#12483;&#12503;&#12398;&#12458;&#12502;&#12472;&#12455;&#12463;&#12488;&#12434;&#26356;&#26032;
  #--------------------------------------------------------------------------
  def update_minimap_object
    return unless SceneManager.scene_is?(Scene_Map)

    $game_map.refresh if $game_map.need_refresh
    SceneManager.scene.update_minimap_object
  end
end

#==============================================================================
# &#9632; Game_Interpreter
#==============================================================================

class Game_Interpreter
  # &#12452;&#12505;&#12531;&#12488;&#12467;&#12510;&#12531;&#12489;&#12363;&#12425;&#30452;&#25509;&#12467;&#12510;&#12531;&#12489;&#12434;&#21481;&#12369;&#12427;&#12424;&#12358;&#12395;&#12377;&#12427;
  include KMS_Commands
end

#==============================================================================
# &#9632; RPG::Map
#==============================================================================

class RPG::Map
  #--------------------------------------------------------------------------
  # &#9675; &#12511;&#12491;&#12510;&#12483;&#12503;&#12398;&#12461;&#12515;&#12483;&#12471;&#12517;&#29983;&#25104;
  #--------------------------------------------------------------------------
  def create_minimap_cache
    @__minimap_show = true

    note.each_line { |line|
      if line =~ KMS_MiniMap::REGEX_NO_MINIMAP_NOTE  # &#12510;&#12483;&#12503;&#38750;&#34920;&#31034;
        @__minimap_show = false
      end
    }
  end
  #--------------------------------------------------------------------------
  # &#9675; &#12511;&#12491;&#12510;&#12483;&#12503;&#34920;&#31034;
  #--------------------------------------------------------------------------
  def minimap_show?
    create_minimap_cache if @__minimap_show.nil?
    return @__minimap_show
  end
end

#==============================================================================
# &#9632; RPG::MapInfo
#==============================================================================

class RPG::MapInfo
  #--------------------------------------------------------------------------
  # &#9679; &#12510;&#12483;&#12503;&#21517;&#21462;&#24471;
  #--------------------------------------------------------------------------
  def name
    return @name.gsub(/\[.*\]/) { "" }
  end
  #--------------------------------------------------------------------------
  # &#9675; &#12458;&#12522;&#12472;&#12490;&#12523;&#12510;&#12483;&#12503;&#21517;&#21462;&#24471;
  #--------------------------------------------------------------------------
  def original_name
    return @name
  end
  #--------------------------------------------------------------------------
  # &#9675; &#12511;&#12491;&#12510;&#12483;&#12503;&#12398;&#12461;&#12515;&#12483;&#12471;&#12517;&#29983;&#25104;
  #--------------------------------------------------------------------------
  def create_minimap_cache
    @__minimap_show = !(@name =~ KMS_MiniMap::REGEX_NO_MINIMAP_NAME)
  end
  #--------------------------------------------------------------------------
  # &#9675; &#12511;&#12491;&#12510;&#12483;&#12503;&#34920;&#31034;
  #--------------------------------------------------------------------------
  def minimap_show?
    create_minimap_cache if @__minimap_show == nil
    return @__minimap_show
  end
end

#==============================================================================
# &#9632; Game_Temp
#==============================================================================

class Game_Temp
  #--------------------------------------------------------------------------
  # &#9675; &#20844;&#38283;&#12452;&#12531;&#12473;&#12479;&#12531;&#12473;&#22793;&#25968;
  #--------------------------------------------------------------------------
  attr_accessor :minimap_manual_visible  # &#12511;&#12491;&#12510;&#12483;&#12503;&#25163;&#21205;&#34920;&#31034;&#20999;&#12426;&#26367;&#12360;&#12501;&#12521;&#12464;
  #--------------------------------------------------------------------------
  # &#9675; &#12458;&#12502;&#12472;&#12455;&#12463;&#12488;&#21021;&#26399;&#21270;
  #--------------------------------------------------------------------------
  alias initialize_KMS_MiniMap initialize
  def initialize
    initialize_KMS_MiniMap

    @minimap_manual_visible = true
  end
end

#==============================================================================
# &#9632; Game_System
#==============================================================================

class Game_System
  #--------------------------------------------------------------------------
  # &#9675; &#20844;&#38283;&#12452;&#12531;&#12473;&#12479;&#12531;&#12473;&#22793;&#25968;
  #--------------------------------------------------------------------------
  attr_accessor :minimap_show  # &#12511;&#12491;&#12510;&#12483;&#12503;&#34920;&#31034;&#12501;&#12521;&#12464;
  #--------------------------------------------------------------------------
  # &#9675; &#12458;&#12502;&#12472;&#12455;&#12463;&#12488;&#21021;&#26399;&#21270;
  #--------------------------------------------------------------------------
  alias initialize_KMS_MiniMap initialize
  def initialize
    initialize_KMS_MiniMap

    @minimap_show = true
  end
end

#==============================================================================
# &#9632; Game_Map
#==============================================================================

class Game_Map
  #--------------------------------------------------------------------------
  # &#9675; &#23450;&#25968;
  #--------------------------------------------------------------------------
  MINIMAP_FADE_NONE = 0  # &#12511;&#12491;&#12510;&#12483;&#12503; &#12501;&#12455;&#12540;&#12489;&#12394;&#12375;
  MINIMAP_FADE_IN   = 1  # &#12511;&#12491;&#12510;&#12483;&#12503; &#12501;&#12455;&#12540;&#12489;&#12452;&#12531;
  MINIMAP_FADE_OUT  = 2  # &#12511;&#12491;&#12510;&#12483;&#12503; &#12501;&#12455;&#12540;&#12489;&#12450;&#12454;&#12488;
  #--------------------------------------------------------------------------
  # &#9675; &#20844;&#38283;&#12452;&#12531;&#12473;&#12479;&#12531;&#12473;&#22793;&#25968;
  #--------------------------------------------------------------------------
  attr_accessor :minimap_fade
  #--------------------------------------------------------------------------
  # &#9675; &#12511;&#12491;&#12510;&#12483;&#12503;&#12434;&#34920;&#31034;&#12377;&#12427;&#12363;
  #--------------------------------------------------------------------------
  def minimap_show?
    return $data_mapinfos[map_id].minimap_show? && @map.minimap_show?
  end
  #--------------------------------------------------------------------------
  # &#9675; &#12511;&#12491;&#12510;&#12483;&#12503;&#12434;&#12501;&#12455;&#12540;&#12489;&#12452;&#12531;
  #--------------------------------------------------------------------------
  def fadein_minimap
    @minimap_fade = MINIMAP_FADE_IN
  end
  #--------------------------------------------------------------------------
  # &#9675; &#12511;&#12491;&#12510;&#12483;&#12503;&#12434;&#12501;&#12455;&#12540;&#12489;&#12450;&#12454;&#12488;
  #--------------------------------------------------------------------------
  def fadeout_minimap
    @minimap_fade = MINIMAP_FADE_OUT
  end
  #--------------------------------------------------------------------------
  # &#9679; &#12522;&#12501;&#12524;&#12483;&#12471;&#12517;
  #--------------------------------------------------------------------------
  alias refresh_KMS_MiniMap refresh
  def refresh
    refresh_KMS_MiniMap

    SceneManager.scene.refresh_minimap if SceneManager.scene_is?(Scene_Map)
  end
end

#==============================================================================
# &#9632; Game_Event
#==============================================================================

class Game_Event < Game_Character
  #--------------------------------------------------------------------------
  # &#9675; &#12511;&#12491;&#12510;&#12483;&#12503;&#29992;&#12398;&#12461;&#12515;&#12483;&#12471;&#12517;&#12434;&#20316;&#25104;
  #--------------------------------------------------------------------------
  def __create_minimap_cache
    @__last_page = @page
    @__minimap_wall_event  = false
    @__minimap_move_event  = false
    @__minimap_object_type = -1

    return if @page.nil?

    @page.list.each { |cmd|
      # &#27880;&#37320;&#20197;&#22806;&#12395;&#21040;&#36948;&#12375;&#12383;&#12425;&#38626;&#33073;
      break unless [108, 408].include?(cmd.code)

      # &#27491;&#35215;&#34920;&#29694;&#21028;&#23450;
      case cmd.parameters[0]
      when KMS_MiniMap::REGEX_WALL_EVENT
        @__minimap_wall_event = true
      when KMS_MiniMap::REGEX_MOVE_EVENT
        @__minimap_move_event = true
      when KMS_MiniMap::REGEX_OBJECT
        @__minimap_object_type = $1.to_i
      end
    }
  end
  private :__create_minimap_cache
  #--------------------------------------------------------------------------
  # &#9675; &#12464;&#12521;&#12501;&#12451;&#12483;&#12463;&#12364;&#12354;&#12427;&#12363;
  #--------------------------------------------------------------------------
  def graphic_exist?
    return (character_name != "" || tile_id > 0)
  end
  #--------------------------------------------------------------------------
  # &#9675; &#38556;&#23475;&#29289;&#12363;
  #--------------------------------------------------------------------------
  def is_minimap_wall_event?
    if @__minimap_wall_event.nil? || @__last_page != @page
      __create_minimap_cache
    end

    return @__minimap_wall_event
  end
  #--------------------------------------------------------------------------
  # &#9675; &#31227;&#21205;&#12452;&#12505;&#12531;&#12488;&#12363;
  #--------------------------------------------------------------------------
  def is_minimap_move_event?
    if @__minimap_move_event.nil? || @__last_page != @page
      __create_minimap_cache
    end

    return @__minimap_move_event
  end
  #--------------------------------------------------------------------------
  # &#9675; &#12511;&#12491;&#12510;&#12483;&#12503;&#12458;&#12502;&#12472;&#12455;&#12463;&#12488;&#12363;
  #--------------------------------------------------------------------------
  def is_minimap_object?
    if @__minimap_object_type.nil? || @__last_page != @page
      __create_minimap_cache
    end

    return @__minimap_object_type > 0
  end
  #--------------------------------------------------------------------------
  # &#9675; &#12511;&#12491;&#12510;&#12483;&#12503;&#12458;&#12502;&#12472;&#12455;&#12463;&#12488;&#12479;&#12452;&#12503;
  #--------------------------------------------------------------------------
  def minimap_object_type
    if @__minimap_object_type.nil? || @__last_page != @page
      __create_minimap_cache
    end

    return @__minimap_object_type
  end
end

#==============================================================================
# &#9633; Game_MiniMap
#------------------------------------------------------------------------------
#   &#12511;&#12491;&#12510;&#12483;&#12503;&#12434;&#25201;&#12358;&#12463;&#12521;&#12473;&#12391;&#12377;&#12290;
#==============================================================================

class Game_MiniMap
  #--------------------------------------------------------------------------
  # &#9675; &#27083;&#36896;&#20307;
  #--------------------------------------------------------------------------
  Point = Struct.new(:x, :y)
  Size  = Struct.new(:width, :height)
  PassageCache = Struct.new(:map_id, :table, :scan_table)
  #--------------------------------------------------------------------------
  # &#9675; &#12463;&#12521;&#12473;&#22793;&#25968;
  #--------------------------------------------------------------------------
  @@passage_cache = []  # &#36890;&#34892;&#12501;&#12521;&#12464;&#12486;&#12540;&#12502;&#12523;&#12461;&#12515;&#12483;&#12471;&#12517;
  #--------------------------------------------------------------------------
  # &#9679; &#12458;&#12502;&#12472;&#12455;&#12463;&#12488;&#21021;&#26399;&#21270;
  #--------------------------------------------------------------------------
  def initialize(tilemap)
    @map_rect  = KMS_MiniMap::MAP_RECT
    @grid_size = [KMS_MiniMap::GRID_SIZE, 1].max

    @x = 0
    @y = 0
    @grid_num = Point.new(
      (@map_rect.width  + @grid_size - 1) / @grid_size,
      (@map_rect.height + @grid_size - 1) / @grid_size
    )
    @draw_grid_num    = Point.new(@grid_num.x + 2, @grid_num.y + 2)
    @draw_range_begin = Point.new(0, 0)
    @draw_range_end   = Point.new(0, 0)
    @tilemap = tilemap

    @last_x = $game_player.x
    @last_y = $game_player.y

    @showing = false
    @hiding  = false

    create_sprites
    refresh

    unless $game_temp.minimap_manual_visible
      self.opacity = 0
    end
  end
  #--------------------------------------------------------------------------
  # &#9675; &#12473;&#12503;&#12521;&#12452;&#12488;&#20316;&#25104;
  #--------------------------------------------------------------------------
  def create_sprites
    @viewport   = Viewport.new(@map_rect)
    @viewport.z = KMS_MiniMap::MAP_Z

    # &#12499;&#12483;&#12488;&#12510;&#12483;&#12503;&#12469;&#12452;&#12474;&#35336;&#31639;
    @bmp_size = Size.new(
      (@grid_num.x + 2) * @grid_size,
      (@grid_num.y + 2) * @grid_size
    )
    @buf_bitmap = Bitmap.new(@bmp_size.width, @bmp_size.height)

    # &#12510;&#12483;&#12503;&#29992;&#12473;&#12503;&#12521;&#12452;&#12488;&#20316;&#25104;
    @map_sprite   = Sprite.new(@viewport)
    @map_sprite.x = -@grid_size
    @map_sprite.y = -@grid_size
    @map_sprite.z = 0
    @map_sprite.bitmap = Bitmap.new(@bmp_size.width, @bmp_size.height)

    # &#12458;&#12502;&#12472;&#12455;&#12463;&#12488;&#29992;&#12473;&#12503;&#12521;&#12452;&#12488;&#20316;&#25104;
    @object_sprite   = Sprite_MiniMapIcon.new(@viewport)
    @object_sprite.x = -@grid_size
    @object_sprite.y = -@grid_size
    @object_sprite.z = 1
    @object_sprite.bitmap = Bitmap.new(@bmp_size.width, @bmp_size.height)

    # &#29694;&#22312;&#20301;&#32622;&#12473;&#12503;&#12521;&#12452;&#12488;&#20316;&#25104;
    @position_sprite   = Sprite_MiniMapIcon.new
    @position_sprite.x = @map_rect.x + @grid_num.x / 2 * @grid_size
    @position_sprite.y = @map_rect.y + @grid_num.y / 2 * @grid_size
    @position_sprite.z = @viewport.z + 2
    bitmap = Bitmap.new(@grid_size, @grid_size)
    bitmap.fill_rect(bitmap.rect, KMS_MiniMap::POSITION_COLOR)
    @position_sprite.bitmap = bitmap
  end
  #--------------------------------------------------------------------------
  # &#9679; &#35299;&#25918;
  #--------------------------------------------------------------------------
  def dispose
    @buf_bitmap.dispose
    @map_sprite.bitmap.dispose
    @map_sprite.dispose
    @object_sprite.bitmap.dispose
    @object_sprite.dispose
    @position_sprite.bitmap.dispose
    @position_sprite.dispose
    @viewport.dispose
  end
  #--------------------------------------------------------------------------
  # &#9675; &#21487;&#35222;&#29366;&#24907;&#21462;&#24471;
  #--------------------------------------------------------------------------
  def visible
    return @map_sprite.visible
  end
  #--------------------------------------------------------------------------
  # &#9675; &#21487;&#35222;&#29366;&#24907;&#35373;&#23450;
  #--------------------------------------------------------------------------
  def visible=(value)
    @viewport.visible        = value
    @map_sprite.visible      = value
    @object_sprite.visible   = value
    @position_sprite.visible = value
  end
  #--------------------------------------------------------------------------
  # &#9675; &#19981;&#36879;&#26126;&#24230;&#21462;&#24471;
  #--------------------------------------------------------------------------
  def opacity
    return @map_sprite.opacity
  end
  #--------------------------------------------------------------------------
  # &#9675; &#19981;&#36879;&#26126;&#24230;&#35373;&#23450;
  #--------------------------------------------------------------------------
  def opacity=(value)
    @map_sprite.opacity      = value
    @object_sprite.opacity   = value
    @position_sprite.opacity = value
  end
  #--------------------------------------------------------------------------
  # &#9675; &#12522;&#12501;&#12524;&#12483;&#12471;&#12517;
  #--------------------------------------------------------------------------
  def refresh
    update_draw_range
    update_passage_table
    update_object_list
    update_position
    draw_map
    draw_object
    Graphics.frame_reset
  end
  #--------------------------------------------------------------------------
  # &#9675; &#12501;&#12455;&#12540;&#12489;&#12452;&#12531;
  #--------------------------------------------------------------------------
  def fadein
    @showing = true
    @hiding  = false
  end
  #--------------------------------------------------------------------------
  # &#9675; &#12501;&#12455;&#12540;&#12489;&#12450;&#12454;&#12488;
  #--------------------------------------------------------------------------
  def fadeout
    @showing = false
    @hiding  = true
  end
  #--------------------------------------------------------------------------
  # &#9675; &#12461;&#12540;&#20837;&#21147;&#26356;&#26032;
  #--------------------------------------------------------------------------
  def update_input
    return if KMS_MiniMap::SWITCH_BUTTON.nil?

    if Input.trigger?(KMS_MiniMap::SWITCH_BUTTON)
      if opacity < 255 && !@showing
        $game_temp.minimap_manual_visible = true
        fadein
      elsif opacity > 0 && !@hiding
        $game_temp.minimap_manual_visible = false
        fadeout
      end
    end
  end
  #--------------------------------------------------------------------------
  # &#9675; &#25551;&#30011;&#31684;&#22258;&#26356;&#26032;
  #--------------------------------------------------------------------------
  def update_draw_range
    range = []
    (2).times { |i| range[i] = @draw_grid_num[i] / 2 }

    @draw_range_begin.x = $game_player.x - range[0]
    @draw_range_begin.y = $game_player.y - range[1]
    @draw_range_end.x   = $game_player.x + range[0]
    @draw_range_end.y   = $game_player.y + range[1]
  end
  #--------------------------------------------------------------------------
  # &#9675; &#36890;&#34892;&#21487;&#21542;&#12486;&#12540;&#12502;&#12523;&#26356;&#26032;
  #--------------------------------------------------------------------------
  def update_passage_table
    cache = get_passage_table_cache
    @passage_table      = cache.table
    @passage_scan_table = cache.scan_table

    update_around_passage_table
  end
  #--------------------------------------------------------------------------
  # &#9675; &#36890;&#34892;&#21487;&#21542;&#12486;&#12540;&#12502;&#12523;&#12398;&#12461;&#12515;&#12483;&#12471;&#12517;&#12434;&#21462;&#24471;
  #--------------------------------------------------------------------------
  def get_passage_table_cache
    map_id = $game_map.map_id
    cache  = @@passage_cache.find { |c| c.map_id == map_id }

    # &#12461;&#12515;&#12483;&#12471;&#12517;&#12511;&#12473;&#12375;&#12383;&#12425;&#26032;&#35215;&#20316;&#25104;
    if cache == nil
      cache = PassageCache.new(map_id)
      cache.table      = Table.new($game_map.width, $game_map.height)
      cache.scan_table = Table.new(
        ($game_map.width  + @draw_grid_num.x - 1) / @draw_grid_num.x,
        ($game_map.height + @draw_grid_num.y - 1) / @draw_grid_num.y
      )
    end

    # &#30452;&#36817;&#12398;&#12461;&#12515;&#12483;&#12471;&#12517;&#12399;&#20808;&#38957;&#12395;&#31227;&#21205;&#12375;&#12289;&#21476;&#12356;&#12461;&#12515;&#12483;&#12471;&#12517;&#12399;&#21066;&#38500;
    @@passage_cache.unshift(cache)
    @@passage_cache.delete_at(KMS_MiniMap::CACHE_NUM)

    return cache
  end
  #--------------------------------------------------------------------------
  # &#9675; &#36890;&#34892;&#21487;&#21542;&#12486;&#12540;&#12502;&#12523;&#12398;&#12461;&#12515;&#12483;&#12471;&#12517;&#12434;&#12463;&#12522;&#12450;
  #--------------------------------------------------------------------------
  def clear_passage_table_cache
    return if @passage_scan_table == nil

    table = @passage_scan_table
    @passage_scan_table = Table.new(table.xsize, table.ysize)
  end
  #--------------------------------------------------------------------------
  # &#9675; &#36890;&#34892;&#21487;&#21542;&#12486;&#12540;&#12502;&#12523;&#12398;&#25506;&#32034;
  #     x, y : &#25506;&#32034;&#20301;&#32622;
  #--------------------------------------------------------------------------
  def scan_passage(x, y)
    dx = x / @draw_grid_num.x
    dy = y / @draw_grid_num.y

    # &#25506;&#32034;&#28168;&#12415;
    return if @passage_scan_table[dx, dy] == 1

    # &#12510;&#12483;&#12503;&#31684;&#22258;&#22806;
    return unless dx.between?(0, @passage_scan_table.xsize - 1)
    return unless dy.between?(0, @passage_scan_table.ysize - 1)

    rx = (dx * @draw_grid_num.x)...((dx + 1) * @draw_grid_num.x)
    ry = (dy * @draw_grid_num.y)...((dy + 1) * @draw_grid_num.y)
    mw = $game_map.width  - 1
    mh = $game_map.height - 1

    # &#25506;&#32034;&#31684;&#22258;&#20869;&#12398;&#36890;&#34892;&#12486;&#12540;&#12502;&#12523;&#12434;&#29983;&#25104;
    rx.each { |x|
      next unless x.between?(0, mw)
      ry.each { |y|
        next unless y.between?(0, mh)

        # &#36890;&#34892;&#26041;&#21521;&#12501;&#12521;&#12464;&#20316;&#25104;
        # (&#8595;&#12289;&#8592;&#12289;&#8594;&#12289;&#8593; &#12398;&#38918;&#12395; 1, 2, 4, 8 &#12364;&#23550;&#24540;)
        flag = 0
        [2, 4, 6, 8].each{ |d|
          flag |= 1 << (d / 2 - 1) if $game_map.passable?(x, y, d)
        }
        @passage_table[x, y] = flag
      }
    }
    @passage_scan_table[dx, dy] = 1
  end
  #--------------------------------------------------------------------------
  # &#9675; &#21608;&#36794;&#12398;&#36890;&#34892;&#21487;&#21542;&#12486;&#12540;&#12502;&#12523;&#26356;&#26032;
  #--------------------------------------------------------------------------
  def update_around_passage_table
    gx = @draw_grid_num.x
    gy = @draw_grid_num.y
    dx = $game_player.x - gx / 2
    dy = $game_player.y - gy / 2
    scan_passage(dx,      dy)
    scan_passage(dx + gx, dy)
    scan_passage(dx,      dy + gy)
    scan_passage(dx + gx, dy + gy)
  end
  #--------------------------------------------------------------------------
  # &#9675; &#12458;&#12502;&#12472;&#12455;&#12463;&#12488;&#19968;&#35239;&#26356;&#26032;
  #--------------------------------------------------------------------------
  def update_object_list
    events = $game_map.events.values

    # WALL
    @wall_events = events.find_all { |e| e.is_minimap_wall_event? }

    # MOVE
    @move_events = events.find_all { |e| e.is_minimap_move_event? }

    # OBJ
    @object_list = events.find_all { |e| e.is_minimap_object? }
  end
  #--------------------------------------------------------------------------
  # &#9675; &#20301;&#32622;&#26356;&#26032;
  #--------------------------------------------------------------------------
  def update_position
    # &#31227;&#21205;&#37327;&#31639;&#20986;
    pt = Point.new($game_player.x, $game_player.y)
    ox = ($game_player.real_x - pt.x) * @grid_size
    oy = ($game_player.real_y - pt.y) * @grid_size

    @viewport.ox = ox
    @viewport.oy = oy

    # &#31227;&#21205;&#12375;&#12390;&#12356;&#12383;&#12425;&#12510;&#12483;&#12503;&#20877;&#25551;&#30011;
    if pt.x != @last_x || pt.y != @last_y
      draw_map
      @last_x = pt.x
      @last_y = pt.y
    end
  end
  #--------------------------------------------------------------------------
  # &#9675; &#25551;&#30011;&#31684;&#22258;&#20869;&#21028;&#23450;
  #--------------------------------------------------------------------------
  def in_draw_range?(x, y)
    rb = @draw_range_begin
    re = @draw_range_end
    return (x.between?(rb.x, re.x) && y.between?(rb.y, re.y))
  end
  #--------------------------------------------------------------------------
  # &#9675; &#12510;&#12483;&#12503;&#31684;&#22258;&#20869;&#21028;&#23450;
  #--------------------------------------------------------------------------
  def in_map_range?(x, y)
    mw = $game_map.width
    mh = $game_map.height
    return (x.between?(0, mw - 1) && y.between?(0, mh - 1))
  end
  #--------------------------------------------------------------------------
  # &#9675; &#12510;&#12483;&#12503;&#25551;&#30011;
  #--------------------------------------------------------------------------
  def draw_map
    update_around_passage_table

    bitmap  = @map_sprite.bitmap
    bitmap.fill_rect(bitmap.rect, KMS_MiniMap::BACKGROUND_COLOR)

    draw_map_foreground(bitmap)
    draw_map_move_event(bitmap)
  end
  #--------------------------------------------------------------------------
  # &#9675; &#36890;&#34892;&#21487;&#33021;&#38936;&#22495;&#12398;&#25551;&#30011;
  #--------------------------------------------------------------------------
  def draw_map_foreground(bitmap)
    range_x = (@draw_range_begin.x)..(@draw_range_end.x)
    range_y = (@draw_range_begin.y)..(@draw_range_end.y)
    map_w   = $game_map.width  - 1
    map_h   = $game_map.height - 1
    rect    = Rect.new(0, 0, @grid_size, @grid_size)

    range_x.each { |x|
      next unless x.between?(0, map_w)
      range_y.each { |y|
        next unless y.between?(0, map_h)
        next if @passage_table[x, y] == 0
        next if @wall_events.find { |e| e.x == x && e.y == y }  # &#22721;

        # &#12464;&#12522;&#12483;&#12489;&#25551;&#30011;&#12469;&#12452;&#12474;&#31639;&#20986;
        rect.set(0, 0, @grid_size, @grid_size)
        rect.x = (x - @draw_range_begin.x) * @grid_size
        rect.y = (y - @draw_range_begin.y) * @grid_size
        flag = @passage_table[x, y]
        if flag & 0x01 == 0  # &#19979;&#36890;&#34892;&#19981;&#33021;
          rect.height -= 1
        end
        if flag & 0x02 == 0  # &#24038;&#36890;&#34892;&#19981;&#33021;
          rect.x     += 1
          rect.width -= 1
        end
        if flag & 0x04 == 0  # &#21491;&#36890;&#34892;&#19981;&#33021;
          rect.width -= 1
        end
        if flag & 0x08 == 0  # &#19978;&#36890;&#34892;&#19981;&#33021;
          rect.y      += 1
          rect.height -= 1
        end
        bitmap.fill_rect(rect, KMS_MiniMap::FOREGROUND_COLOR)
      }
    }
  end
  #--------------------------------------------------------------------------
  # &#9675; &#31227;&#21205;&#12452;&#12505;&#12531;&#12488;&#12398;&#25551;&#30011;
  #--------------------------------------------------------------------------
  def draw_map_move_event(bitmap)
    rect = Rect.new(0, 0, @grid_size, @grid_size)
    @move_events.each { |e|
      rect.x = (e.x - @draw_range_begin.x) * @grid_size
      rect.y = (e.y - @draw_range_begin.y) * @grid_size
      bitmap.fill_rect(rect, KMS_MiniMap::MOVE_EVENT_COLOR)
    }
  end
  #--------------------------------------------------------------------------
  # &#9675; &#12450;&#12491;&#12513;&#12540;&#12471;&#12519;&#12531;&#26356;&#26032;
  #--------------------------------------------------------------------------
  def update_animation
    if @showing
      # &#12501;&#12455;&#12540;&#12489;&#12452;&#12531;
      self.opacity += 16
      if opacity == 255
        @showing = false
      end
    elsif @hiding
      # &#12501;&#12455;&#12540;&#12489;&#12450;&#12454;&#12488;
      self.opacity -= 16
      if opacity == 0
        @hiding = false
      end
    end
  end
  #--------------------------------------------------------------------------
  # &#9675; &#12458;&#12502;&#12472;&#12455;&#12463;&#12488;&#25551;&#30011;
  #--------------------------------------------------------------------------
  def draw_object
    # &#19979;&#28310;&#20633;
    bitmap = @object_sprite.bitmap
    bitmap.clear
    rect = Rect.new(0, 0, @grid_size, @grid_size)

    # &#12458;&#12502;&#12472;&#12455;&#12463;&#12488;&#25551;&#30011;
    @object_list.each { |obj|
      next unless in_draw_range?(obj.x, obj.y)

      color = KMS_MiniMap::OBJECT_COLOR[obj.minimap_object_type - 1]
      next if color.nil?

      rect.x = (obj.real_x - @draw_range_begin.x) * @grid_size
      rect.y = (obj.real_y - @draw_range_begin.y) * @grid_size
      bitmap.fill_rect(rect, color)
    }

    # &#20055;&#12426;&#29289;&#25551;&#30011;
    $game_map.vehicles.each { |vehicle|
      next if vehicle.transparent

      rect.x = (vehicle.real_x - @draw_range_begin.x) * @grid_size
      rect.y = (vehicle.real_y - @draw_range_begin.y) * @grid_size
      bitmap.fill_rect(rect, KMS_MiniMap::VEHICLE_COLOR)
    }
  end
  #--------------------------------------------------------------------------
  # &#9675; &#26356;&#26032;
  #--------------------------------------------------------------------------
  def update
    update_input

    return unless need_update?

    update_draw_range
    update_position
    update_animation
    draw_object

    @map_sprite.update
    @object_sprite.update
    @position_sprite.update
  end
  #--------------------------------------------------------------------------
  # &#9675; &#26356;&#26032;&#21028;&#23450;
  #--------------------------------------------------------------------------
  def need_update?
    return (visible && opacity > 0) || @showing || @hiding
  end
end

#==============================================================================
# &#9633; Sprite_MiniMapIcon
#------------------------------------------------------------------------------
#   &#12511;&#12491;&#12510;&#12483;&#12503;&#29992;&#12450;&#12452;&#12467;&#12531;&#12398;&#12463;&#12521;&#12473;&#12391;&#12377;&#12290;
#==============================================================================

class Sprite_MiniMapIcon < Sprite
  DURATION_MAX = 60
  #--------------------------------------------------------------------------
  # &#9679; &#12458;&#12502;&#12472;&#12455;&#12463;&#12488;&#21021;&#26399;&#21270;
  #     viewport : &#12499;&#12517;&#12540;&#12509;&#12540;&#12488;
  #--------------------------------------------------------------------------
  def initialize(viewport = nil)
    super(viewport)
    @duration = DURATION_MAX / 2
  end
  #--------------------------------------------------------------------------
  # &#9679; &#12501;&#12524;&#12540;&#12512;&#26356;&#26032;
  #--------------------------------------------------------------------------
  def update
    super
    @duration += 1
    if @duration == DURATION_MAX
      @duration = 0
    end
    update_effect
  end
  #--------------------------------------------------------------------------
  # &#9675; &#12456;&#12501;&#12455;&#12463;&#12488;&#12398;&#26356;&#26032;
  #--------------------------------------------------------------------------
  def update_effect
    self.color.set(255, 255, 255,
      (@duration - DURATION_MAX / 2).abs * KMS_MiniMap::BLINK_LEVEL
    )
  end
end

#==============================================================================
# &#9632; Spriteset_Map
#==============================================================================

class Spriteset_Map
  attr_reader :minimap
  #--------------------------------------------------------------------------
  # &#9679; &#12458;&#12502;&#12472;&#12455;&#12463;&#12488;&#21021;&#26399;&#21270;
  #--------------------------------------------------------------------------
  alias initialize_KMS_MiniMap initialize
  def initialize
    initialize_KMS_MiniMap

    create_minimap
  end
  #--------------------------------------------------------------------------
  # &#9675; &#12511;&#12491;&#12510;&#12483;&#12503;&#12398;&#20316;&#25104;
  #--------------------------------------------------------------------------
  def create_minimap
    @minimap = Game_MiniMap.new(@tilemap)
    @minimap.visible = $game_system.minimap_show && $game_map.minimap_show?
  end
  #--------------------------------------------------------------------------
  # &#9679; &#35299;&#25918;
  #--------------------------------------------------------------------------
  alias dispose_KMS_MiniMap dispose
  def dispose
    dispose_KMS_MiniMap

    dispose_minimap
  end
  #--------------------------------------------------------------------------
  # &#9675; &#12511;&#12491;&#12510;&#12483;&#12503;&#12398;&#35299;&#25918;
  #--------------------------------------------------------------------------
  def dispose_minimap
    @minimap.dispose
    @minimap = nil
  end
  #--------------------------------------------------------------------------
  # &#9679; &#12501;&#12524;&#12540;&#12512;&#26356;&#26032;
  #--------------------------------------------------------------------------
  alias update_KMS_MiniMap update
  def update
    update_KMS_MiniMap

    update_minimap
  end
  #--------------------------------------------------------------------------
  # &#9675; &#12511;&#12491;&#12510;&#12483;&#12503;&#26356;&#26032;
  #--------------------------------------------------------------------------
  def minimap_show?
    return $game_map.minimap_show? && $game_system.minimap_show
  end
  #--------------------------------------------------------------------------
  # &#9675; &#12511;&#12491;&#12510;&#12483;&#12503;&#26356;&#26032;
  #--------------------------------------------------------------------------
  def update_minimap
    return if @minimap.nil?

    # &#34920;&#31034;&#20999;&#26367;
    if minimap_show?
      @minimap.visible = true
    else
      @minimap.visible = false
      return
    end

    # &#12501;&#12455;&#12540;&#12489;&#21028;&#23450;
    case $game_map.minimap_fade
    when Game_Map::MINIMAP_FADE_IN
      @minimap.fadein
      $game_map.minimap_fade = Game_Map::MINIMAP_FADE_NONE
    when Game_Map::MINIMAP_FADE_OUT
      @minimap.fadeout
      $game_map.minimap_fade = Game_Map::MINIMAP_FADE_NONE
    end

    @minimap.update
  end
  #--------------------------------------------------------------------------
  # &#9675; &#12511;&#12491;&#12510;&#12483;&#12503;&#20840;&#20307;&#12434;&#12522;&#12501;&#12524;&#12483;&#12471;&#12517;
  #--------------------------------------------------------------------------
  def refresh_minimap
    return if @minimap.nil?

    @minimap.clear_passage_table_cache
    @minimap.refresh
  end
  #--------------------------------------------------------------------------
  # &#9675; &#12511;&#12491;&#12510;&#12483;&#12503;&#12398;&#12458;&#12502;&#12472;&#12455;&#12463;&#12488;&#12434;&#26356;&#26032;
  #--------------------------------------------------------------------------
  def update_minimap_object
    @minimap.update_object_list unless @minimap.nil?
  end
end

#==============================================================================
# &#9632; Scene_Map
#==============================================================================

class Scene_Map
  #--------------------------------------------------------------------------
  # &#9679; &#22580;&#25152;&#31227;&#21205;&#24460;&#12398;&#20966;&#29702;
  #--------------------------------------------------------------------------
  alias post_transfer_KMS_MiniMap post_transfer
  def post_transfer
    refresh_minimap

    post_transfer_KMS_MiniMap
  end
  #--------------------------------------------------------------------------
  # &#9675; &#12511;&#12491;&#12510;&#12483;&#12503;&#20840;&#20307;&#12434;&#12522;&#12501;&#12524;&#12483;&#12471;&#12517;
  #--------------------------------------------------------------------------
  def refresh_minimap
    @spriteset.refresh_minimap unless @spriteset.nil?
  end
  #--------------------------------------------------------------------------
  # &#9675; &#12511;&#12491;&#12510;&#12483;&#12503;&#12398;&#12458;&#12502;&#12472;&#12455;&#12463;&#12488;&#12434;&#26356;&#26032;
  #--------------------------------------------------------------------------
  def update_minimap_object
    @spriteset.update_minimap_object unless @spriteset.nil?
  end
end


Screeny:
Spoiler:



Dodatkowe informacje:
Aby wywołać mapkę trzeba chyba kliknąć klawisz "Z", ale nie jestem pewien ponieważ znalazłem go w necie +Nie ponoszę odpowiedzialności za niego, i nie pomoge z nim, a no i też sory za te "Krzaczki"
________________________
Siema

Gość, Jeżeli ci Pomogłem, możesz mi dać .
_______________________________________________________________
Niestety, padł mi komp z Projektami, więc przez pewien czas niestety nici z Projektów :C
 
 
 
cj2 




Preferowany:
RPG Maker VXAce

Ranga RM:
1 gra

Pomógł: 6 razy
Dołączył: 07 Mar 2010
Posty: 261
Skąd: Gliwice
Wysłany: Nie 27 Sty, 2013 20:02
Wrzucasz tyle skryptów, że nawet nie sprawdzasz :roll:
________________________
Porady dla twórców gier
Nie ma śniegu, a zgubiłem normalny avatar :I
 
 
The Big Master 




Preferowany:
RPG Maker XP

Pomógł: 6 razy
Dołączył: 19 Gru 2012
Posty: 81
Skąd: Masz taki nr. IQ ?
Wysłany: Nie 27 Sty, 2013 20:37
Nie tylko chodzi o to że teraz nie mam kompa i wale z Lapka siorki który jest słabiakiem, i żadnego RM'a u niej nie zainstaluje z tych nowszych. Dodatkowo pragnę nadmienić iż Preferuję RMXP'ka a nie VXAce więc i tak go nie miałem na kompie bo z niego nie korzystam skrypty zamieszczam aby ułatwić <przynajmniej miałbym taką ochotę> wam tworzenie gier, więc jeżeli się coś nie podoba to mogę się już tu nie udzielać <Dział o skryptach VXAce> i bd po kłopocie :)
________________________
Siema

Gość, Jeżeli ci Pomogłem, możesz mi dać .
_______________________________________________________________
Niestety, padł mi komp z Projektami, więc przez pewien czas niestety nici z Projektów :C
 
 
 
Viuu 

Project-Ayus




Preferowany:
RPG Maker VXAce

Pomógł: 15 razy
Dołączył: 21 Maj 2010
Posty: 106
Skąd: Gdańsk
Wysłany: Nie 27 Sty, 2013 21:31
Mr. Bubble przetłumaczył ten skrypt na angielski.
W tej wersji przynajmniej jest instrukcja, której u ciebie nie ma...
________________________



Spoiler:



 
 
 
Wyświetl posty z ostatnich:   
Odpowiedz do tematu
Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Nie możesz załączać plików na tym forum
Możesz ściągać załączniki na tym forum
Dodaj temat do Ulubionych
Wersja do druku

Skocz do:  

Powered by phpBB modified by Przemo © 2003 phpBB Group | Template Klam by Ayene