Ogłoszenie 

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


Administracja Forum


Poprzedni temat «» Następny temat
"Skrinszoty" Mapy!
Autor Wiadomość
Saskio 




Preferowany:
RPG Maker VXAce

Pomógł: 1 raz
Dołączył: 20 Sie 2012
Posty: 51
Skąd: Włocławek
Wysłany: Sro 29 Sie, 2012 10:46
"Skrinszoty" Mapy!
~ Tsuki Map Saver ~


Krótki opis:
Skrypt dodaje możliwość robienia skrinszotów oraz mapszotów (błędy specjalnie :D) Jakość jest całkiem dobra, co możecie zauważyć na screenie!

Autor:
Tsukihime

Tłumaczenie:
Nie tłumaczyłem, wydaje mi się, że skrypt jest zbyt prosty na tłumaczenie, zresztą... instrukcja poniżej.

Kompatybilność:
RPG Maker VX Ace

Skrypt:
Spoiler:

Kod:
=begin
==============================================================================
 ** Tsuki Map Saver
------------------------------------------------------------------------------
 Author: Tsukihime
 Date: Jul 27, 2012
------------------------------------------------------------------------------
    Map shows up in the game folder with the same name
 as the map, or the display name of the map if it exists.
 
 Two ways to export an image of the map:

 A - just hit F6 (can customize below)
 B - use script calls
   1. create an event on the map
   2. use the following script call
         Map_Saver.new(map_id).export
 
 You can also use the bitmap that it creates in-game as well
 with the following script call
    bitmap = Map_Saver.new(map_id).bitmap
 
 However currently there doesn't seem to be too many things you can
 do with a bitmap object. Maybe in the future.
------------------------------------------------------------------------------
 Credits to Cidiomar for drawing autotiles and shadows,
 as well as providing efficient bmp and png exporters
==============================================================================
=end
$imported = {} if $imported.nil?
$imported["Tsuki_MapSaver"] = true
#==============================================================================
# ** Configuration
# Some settings you can customize
#==============================================================================
module Tsuki
  module Map_Saver
   
    #Mapshot options. This takes an image of the entire map
    Mapshot_Scale = 1
    Mapshot_Button = Input::F7
   
    #Screenshot options. This takes an image of the visible map
    Screenshot_Button = Input::F6
    Screenshot_Scale = 1
   
    #Folder that the map will be exported to
    Mapshot_Directory = "Mapshots"
    Screenshot_Directory = "Screenshots"
   
    #format you want to export to
    #Options: [tga, bmp, png]
    Export_Format = "tga"
   
    #Should events be drawn in the image?
    Draw_Events = true
   
    #Should the game player be drawn in the image?
    Draw_Player = true
    Draw_Followers = true
   
    #Should shadows be drawn? What color?
    Draw_Shadow = true
    Shadow_Color = Color.new(0, 0, 0, 128)
   
    #Should damage tiles be highlighted? What color?
    Highlight_Damage = true
    Damage_Color = Color.new(128, 0, 0, 128)
   
    #Should regions be drawn?
    #And at what opacity (0 = transparent, 255 = opaque)
    Draw_Regions = false
    Region_Opacity = 160
   
    #Set this to true if your game crashes when trying to save image
    #Specify format to fallback to if your game crashes: choice of [bmp, png]
    Crashes = false
    Crash_Format = "png"
   
    ###Not implemented yet###
    Draw_Vehicles = true
  end
end

#==============================================================================
# ** Module: Map_Tiles
# Contains data and methods useful for working with maps and tiles
#==============================================================================

module Map_Tiles
 
  AUTOTILE_PARTS = [[18,17,14,13], [ 2,14,17,18], [13, 3,17,18], [ 2, 3,17,18],
                    [13,14,17, 7], [ 2,14,17, 7], [13, 3,17, 7], [ 2, 3,17, 7],
                    [13,14, 6,18], [ 2,14, 6,18], [13, 3, 6,18], [ 2, 3, 6,18],
                    [13,14, 6, 7], [ 2,14, 6, 7], [13, 3, 6, 7], [ 2, 3, 6, 7],
                    [16,17,12,13], [16, 3,12,13], [16,17,12, 7], [12, 3,16, 7],
                    [10, 9,14,13], [10, 9,14, 7], [10, 9, 6,13], [10, 9, 6, 7],
                    [18,19,14,15], [18,19, 6,15], [ 2,19,14,15], [ 2,19, 6,15],
                    [18,17,22,21], [ 2,17,22,21], [18, 3,22,21], [ 2, 3,21,22],
                    [16,19,12,15], [10, 9,22,21], [ 8, 9,12,13], [ 8, 9,12, 7],
                    [10,11,14,15], [10,11, 6,15], [18,19,22,23], [ 2,19,22,23],
                    [16,17,20,21], [16, 3,20,21], [ 8,11,12,15], [ 8, 9,20,21],
                    [16,19,20,23], [10,11,22,23], [ 8,11,20,23], [ 0, 1, 4, 5]]
  WATERFALL_PIECES = [[ 2, 1, 6, 5], [ 0, 1, 4, 5], [ 2, 3, 6, 7], [0, 3, 4, 7]]
  WALL_PIECES =  [[10, 9, 6, 5], [ 8, 9, 4, 5], [ 2, 1, 6, 5], [ 0, 1, 4, 5],
                  [10,11, 6, 7], [ 8,11, 4, 7], [ 2, 3, 6, 7], [ 0, 3, 4, 7],
                  [10, 9,14,13], [ 8, 9,12,13], [ 2, 1,14,13], [ 0, 1,12,13],
                  [10,11,14,15], [8, 11,12,15], [ 2, 3,14,15], [ 0, 3,12,15]]

  A1_TILES = [[0, 0], [0, 96], [192, 0], [192, 96],
               [256, 0], [448, 0], [256, 96], [448, 96],
               [0, 192], [192, 192], [0, 288], [192, 288],
               [256, 192], [448, 192], [256, 288], [448, 288]]
   
 
  #--------------------------------------------------------------------------
  # * Checks if a tile is a wall
  #--------------------------------------------------------------------------
  def is_wall?(data)
    return true if data.between?(2288, 2335)
    return true if data.between?(2384, 2431)
    return true if data.between?(2480, 2527)
    return true if data.between?(2576, 2623)
    return true if data.between?(2672, 2719)
    return true if data.between?(2768, 2815)
    return true if data.between?(4736, 5119)
    return true if data.between?(5504, 5887)
    return true if data.between?(6272, 6655)
    return true if data.between?(7040, 7423)
    return true if data > 7807
    false
  end
  #--------------------------------------------------------------------------
  # * Checks if a tile is roof
  #--------------------------------------------------------------------------
  def is_roof?(data)
    return true if data.between?(4352, 4735)
    return true if data.between?(5120, 5503)
    return true if data.between?(5888, 6271)
    return true if data.between?(6656, 7039)
    return true if data.between?(7424, 7807)
    false
  end 
  #--------------------------------------------------------------------------
  # * Checks if a tile is soil
  #--------------------------------------------------------------------------
  def is_soil?(data)
    return true if data.between?(2816, 4351) && !is_table?(data)
    return true if data > 1663 && !is_stair?(data)
    false
  end   
  #--------------------------------------------------------------------------
  # * Checks if a tile is a stair
  #--------------------------------------------------------------------------
  def is_stair?(data)
     return true if data.between?(1541, 1542)
     return true if data.between?(1549, 1550)
     return true if data.between?(1600, 1615)
     false
  end
  #--------------------------------------------------------------------------
  # * Checks if a tile is a table
  #--------------------------------------------------------------------------
  def is_table?(data)
    return true if data.between?(3152, 3199)
    return true if data.between?(3536, 3583)
    return true if data.between?(3920, 3967)
    return true if data.between?(4304, 4351)
    false
  end
 
  #--------------------------------------------------------------------------
  # * The tileset to be used
  #--------------------------------------------------------------------------
  def tileset
    $data_tilesets[@tileset_id]
  end
 
  #--------------------------------------------------------------------------
  # * Region ID
  #--------------------------------------------------------------------------
  def region_id(x, y)
    valid?(x, y) ? @map.data[x, y, 3] >> 8 : 0
  end
 
  #--------------------------------------------------------------------------
  # * Gets all of the tiles for each layer at position x,y
  #--------------------------------------------------------------------------
  def layered_tiles(x, y)
    [2, 1, 0].collect {|z| @map.data[x, y, z] }
  end
 
  def layered_tiles_flag?(x, y, bit)
    layered_tiles(x, y).any? {|tile_id| tileset.flags[tile_id] & bit != 0 }
  end
   
  def valid?(x, y)
    x >= 0 && x < width && y >= 0 && y < height
  end
 
  def damage_floor?(x, y)
    valid?(x, y) && layered_tiles_flag?(x, y, 0x100)
  end
 
  #--------------------------------------------------------------------------
  # * Specifies which type of autotile is used
  #--------------------------------------------------------------------------
  def auto_tile(id)
    id / 48
  end
 
  #--------------------------------------------------------------------------
  # * Specifies the specific arrangement of autotiles used
  #--------------------------------------------------------------------------
  def auto_index(id)
    id % 48
  end
 
  #--------------------------------------------------------------------------
  # * Put the auto-tile pieces together
  #--------------------------------------------------------------------------
  def make_autotile(rects, sx, sy)
    @tile.clear
    for i in 0...4
      @auto_rect.x = (rects[i] % 4) * 16 + sx
      @auto_rect.y = (rects[i] / 4) * 16 + sy
      @tile.blt((i % 2) * 16,(i / 2) * 16, @tilemap, @auto_rect)
    end
  end
     
  #--------------------------------------------------------------------------
  # * Get auto-tile A1 tiles
  #--------------------------------------------------------------------------
  def autotile_A1(tile_id)
    @tilemap = @bitmaps[0]
    autotile = tile_id / 48
    auto_id = tile_id % 48
    sx, sy = A1_TILES[autotile]
    if is_wall?(tile_id + 2048)
      rects = WATERFALL_PIECES[auto_id]
    else 
      rects = AUTOTILE_PARTS[auto_id]
    end
    make_autotile(rects, sx, sy)
  end
 
  #--------------------------------------------------------------------------
  # * Get auto-tile A2 tiles.
  # 64x96 tiles, 8 per row, 4 rows
  #--------------------------------------------------------------------------
  def autotile_A2(tile_id)
    autotile = tile_id / 48
    auto_id = tile_id % 48
    @tilemap = @bitmaps[1]
    sx = (autotile % 8) * 64
    sy = (autotile / 8 % 4) * 96
    rects = AUTOTILE_PARTS[auto_id]
    make_autotile(rects, sx, sy)
  end
 
  #--------------------------------------------------------------------------
  # * Get auto-tile A3 tiles.
  # 64x64 tiles, 8 per row, 4 rows
  #--------------------------------------------------------------------------
  def autotile_A3(tid)
    @tilemap = @bitmaps[2]
    sx = (auto_tile(tid) % 8) * 64
    sy = (auto_tile(tid) / 8 % 4) * 64
    rects = WALL_PIECES[auto_index(tid)]
    make_autotile(rects, sx, sy)
  end
 
  #--------------------------------------------------------------------------
  # * Get auto-tile A4 tiles (walls)
  #--------------------------------------------------------------------------
  def autotile_A4(tile_id)
    @tilemap = @bitmaps[3]
    autotile = tile_id / 48
    auto_id = tile_id % 48
    sx = (autotile % 8) * 64
    sy = (autotile / 16 * 160) + (autotile / 8 % 2) * 96
    if is_wall?(tile_id + 5888)
      rects = WALL_PIECES[auto_id]
    else
      rects = AUTOTILE_PARTS[auto_id]
    end
    make_autotile(rects, sx, sy)
  end
 
  #--------------------------------------------------------------------------
  # * Get auto-tile A5 tiles (normal)
  #--------------------------------------------------------------------------
  def autotile_A5(tile_id)
    @tilemap = @bitmaps[4]
    sx = (tile_id) % 8 * tilesize
    sy = (tile_id) / 8 * tilesize
    @src_rect.set(sx, sy, tilesize, tilesize)
    @tile.clear
    @tile.blt(0, 0, @tilemap, @src_rect)
  end
 
  #--------------------------------------------------------------------------
  # * Get normal tiles B, C, D, E
  #--------------------------------------------------------------------------
  def normal_tile(tile_id)
    @tilemap = @bitmaps[5 + tile_id / 256]
    sx = (tile_id / 128 % 2 * 8 + tile_id % 8) * tilesize;
    sy = (tile_id % 256 / 8 % 16) * tilesize;
    @src_rect.set(sx, sy, tilesize, tilesize)
    @tile.clear
    @tile.blt(0, 0, @tilemap, @src_rect)
  end
   
  #--------------------------------------------------------------------------
  # * Get bitmap for the specified tile id
  #--------------------------------------------------------------------------
  def get_bitmap(id)
    if id < 1024
      normal_tile(id)
    elsif id < 1664
      autotile_A5(id - 1536)
    elsif id < 2816
      autotile_A1(id - 2048)
    elsif id < 4352
      autotile_A2(id - 2816)
    elsif id < 5888
      autotile_A3(id - 4352)
    else
      autotile_A4(id - 5888)
    end
  end
end

#==============================================================================
# **
#==============================================================================

class Game_Player < Game_Character
 
  alias tsuki_mapsaver_update update
  def update
    tsuki_mapsaver_update
    if Input.trigger?(Tsuki::Map_Saver::Mapshot_Button)
      s = Map_Saver.new($game_map.map_id)
      s.set_scale(Tsuki::Map_Saver::Mapshot_Scale)
      s.mapshot
    end
    if Input.trigger?(Tsuki::Map_Saver::Screenshot_Button)
      s = Map_Saver.new($game_map.map_id)
      s.set_scale(Tsuki::Map_Saver::Screenshot_Scale)
      s.screenshot
    end
  end
end

class Game_Vehicle
  attr_reader :map_id
end

#==============================================================================
# **
#==============================================================================

class Map_Saver
  include Tsuki::Map_Saver
  include Map_Tiles
  #--------------------------------------------------------------------------
  # * Constants
  #--------------------------------------------------------------------------

  SHADOW_COLOR = Tsuki::Map_Saver::Shadow_Color
  DAMAGE_COLOR = Tsuki::Map_Saver::Damage_Color
  REGION_COLORS = { 0 => Color.new(0, 0, 0, 0),
                    1 => Color.new(183, 95, 95, Region_Opacity),
                    2 => Color.new(183, 139, 95, Region_Opacity),
                    3 => Color.new(183, 183, 95, Region_Opacity),
                    4 => Color.new(140, 183, 95, Region_Opacity),
                    5 => Color.new(95, 183, 95, Region_Opacity),
                    6 => Color.new(95, 183, 139, Region_Opacity),
                    7 => Color.new(95, 183, 182, Region_Opacity),
                    8 => Color.new(0, 0, 0, 0),
                    9 => Color.new(0, 0, 0, 0),
                    10 => Color.new(0, 0, 0, 0),
                    11 => Color.new(0, 0, 0, 0),
                    12 => Color.new(0, 0, 0, 0),
                    13 => Color.new(0, 0, 0, 0),
                    14 => Color.new(0, 0, 0, 0),
                    15 => Color.new(0, 0, 0, 0),
                    16 => Color.new(0, 0, 0, 0),
                    17 => Color.new(0, 0, 0, 0),
                    18 => Color.new(0, 0, 0, 0),
                    19 => Color.new(0, 0, 0, 0),
                    20 => Color.new(0, 0, 0, 0),
                    21 => Color.new(0, 0, 0, 0),
                    22 => Color.new(0, 0, 0, 0),
                    23 => Color.new(0, 0, 0, 0),
                    24 => Color.new(0, 0, 0, 0),
                    25 => Color.new(0, 0, 0, 0),
                    26 => Color.new(0, 0, 0, 0),
                    27 => Color.new(0, 0, 0, 0),
                    28 => Color.new(0, 0, 0, 0),
                    29 => Color.new(0, 0, 0, 0),
                    30 => Color.new(0, 0, 0, 0),
                    31 => Color.new(0, 0, 0, 0),
                    32 => Color.new(0, 0, 0, 0),
                    33 => Color.new(0, 0, 0, 0),
                    34 => Color.new(0, 0, 0, 0),
                    35 => Color.new(0, 0, 0, 0),
                    36 => Color.new(0, 0, 0, 0),
                    37 => Color.new(0, 0, 0, 0),
                    38 => Color.new(0, 0, 0, 0),
                    39 => Color.new(0, 0, 0, 0),
                    40 => Color.new(0, 0, 0, 0),
                    41 => Color.new(0, 0, 0, 0),
                    42 => Color.new(0, 0, 0, 0),
                    43 => Color.new(0, 0, 0, 0),
                    44 => Color.new(0, 0, 0, 0),
                    45 => Color.new(0, 0, 0, 0),
                    46 => Color.new(0, 0, 0, 0),
                    47 => Color.new(0, 0, 0, 0),
                    48 => Color.new(0, 0, 0, 0),
                    49 => Color.new(0, 0, 0, 0),
                    50 => Color.new(0, 0, 0, 0),
                    51 => Color.new(0, 0, 0, 0),
                    52 => Color.new(0, 0, 0, 0),
                    53 => Color.new(0, 0, 0, 0),
                    54 => Color.new(0, 0, 0, 0),
                    55 => Color.new(0, 0, 0, 0),
                    56 => Color.new(0, 0, 0, 0),
                    57 => Color.new(0, 0, 0, 0),
                    58 => Color.new(0, 0, 0, 0),
                    59 => Color.new(0, 0, 0, 0),
                    60 => Color.new(0, 0, 0, 0),
                    61 => Color.new(0, 0, 0, 0),
                    62 => Color.new(0, 0, 0, 0),
                    63 => Color.new(0, 0, 0, 0)
                   }

  #--------------------------------------------------------------------------
  # * Public instance variables
  #--------------------------------------------------------------------------
  attr_reader :map_image
  attr_accessor :screen_local
  attr_accessor :scale
  attr_accessor :draw_layer0
  attr_accessor :draw_layer1
  attr_accessor :draw_layer2
  attr_accessor :draw_shadow
  attr_accessor :draw_regions
  attr_accessor :draw_damage
  attr_accessor :draw_vehicles
  attr_accessor :draw_events
  attr_accessor :draw_player
 
  def initialize(map_id=$game_map.map_id, x=$game_player.x, y=$game_player.y)
    @scale = 1
    @local_x = x
    @local_y = y
    @screen_local = false
    @shadow_bitmap = Bitmap.new(128, 128)
    @draw_layer0 = true
    @draw_layer1 = true
    @draw_layer2 = true
    @draw_events = Draw_Events
    @draw_vehicles = Draw_Vehicles
    @draw_player = Draw_Player
    @draw_followers = Draw_Followers
    @draw_shadow = Draw_Shadow
    @draw_damage = Highlight_Damage
    @draw_regions = Draw_Regions
    @tile = Bitmap.new(32, 32) #stores the current tile to be drawn
    @tilemap = nil
    @src_rect = Rect.new
    @auto_rect = Rect.new(0, 0, tilesize / 2, tilesize/ 2) #constant
    @tile_rect = Rect.new(0, 0, tilesize, tilesize)        #constant
  end
 
  def load_tilesets
    bitmaps = []
    tileset.tileset_names.each_with_index do |name, i|
      bitmaps[i] = Cache.tileset(name)
    end
    return bitmaps
  end
 
  #--------------------------------------------------------------------------
  # * Refresh, possibly with a new map
  #--------------------------------------------------------------------------
  def redraw(map_id=$game_map.map_id, x=$game_player.x, y=$game_player.y)
    @map_image.dispose if @map_image
    @map_id = map_id
    @local_x = x
    @local_y = y
    @map = load_data(sprintf("Data/Map%03d.rvdata2", @map_id))
    @map_info = $data_mapinfos[map_id]
    @screen = $game_map.screen
    @tileset_id = @map.tileset_id
    @bitmaps = load_tilesets
   
    get_bounds
    @map_image = Bitmap.new(@width * tilesize, @height * tilesize)
    draw_map
    scale_map if @scale != 1
  end
 
  #--------------------------------------------------------------------------
  # * Pre-process. These will never change when drawing the map.
  #--------------------------------------------------------------------------
  def get_bounds
    @start_x = start_x
    @start_y = start_y
    @end_x = end_x
    @end_y = end_y
    @width = width
    @height = height
    @tilesize = tilesize
  end
 
  def screen_tile_x
    Graphics.width / 32
  end
 
  def screen_tile_y
    Graphics.height / 32
  end
 
  #--------------------------------------------------------------------------
  # * Sets the scale for the map
  #--------------------------------------------------------------------------
  def set_scale(scale)
    @scale = scale
  end
 
  #--------------------------------------------------------------------------
  # * Size of a tile
  #--------------------------------------------------------------------------
  def tilesize
    32
  end
 
  #--------------------------------------------------------------------------
  # * Width and height of the map, both locally and globally
  #--------------------------------------------------------------------------
  def width
    end_x - @start_x
  end
 
  def height
    end_y - @start_y
  end
 
  #--------------------------------------------------------------------------
  # * Starting and end positions, relative to the screen or map
  #--------------------------------------------------------------------------
  def start_x
    @screen_local ? [[$game_player.x - screen_tile_x / 2, @map.width - screen_tile_x].min, 0].max : 0
  end

  def start_y
    @screen_local ? [[$game_player.y - screen_tile_y / 2, @map.height - screen_tile_y].min, 0].max : 0
  end
 
  def end_x
    @screen_local ? [[screen_tile_x, @local_x + screen_tile_x / 2 + 1].max, @map.width].min : @map.width
  end
 
  def end_y
    @screen_local ? [[screen_tile_y, @local_y + screen_tile_y / 2 + 1].max, @map.height].min : @map.height
  end

  #--------------------------------------------------------------------------
  # * Draw tile onto image. x and y values are absolute coords. They should
  # be re-mapped based on the start_x and start_y values
  #--------------------------------------------------------------------------
  def draw_tile(x, y, tile, rect)
    ox = (x - @start_x) * tilesize
    oy = (y - @start_y) * tilesize
    @map_image.blt(ox, oy, tile, rect)
  end
 
  #--------------------------------------------------------------------------
  # * Get bitmap for the specified character
  #--------------------------------------------------------------------------
  def get_character_bitmap(name)
    charmap = Cache.character(name)
    sign = name[/^[\!\$]./]
    if sign && sign.include?('$')
      cw = charmap.width / 3
      ch = charmap.height / 4
    else
      cw = charmap.width / 12
      ch = charmap.height / 8
    end
    return charmap, cw, ch
  end
 
  #--------------------------------------------------------------------------
  # * Draw the character onto the tile
  #--------------------------------------------------------------------------
  def set_character_bitmap(character, x, y)
    charmap, cw, ch = get_character_bitmap(character.character_name)
    index = character.character_index
    pattern = character.pattern < 3 ? character.pattern : 1
    sx = (index % 4 * 3 + pattern) * cw
    sy = (index / 4 * 4 + (character.direction - 2) / 2) * ch
    @src_rect.set(sx, sy, cw, ch)
    x -= cw / (@tilesize * 2) if cw >= @tilesize
    y -= ch / (@tilesize * 2) if ch >= @tilesize 
    draw_tile(x, y, charmap, @src_rect)
  end
 
  #--------------------------------------------------------------------------
  # * create the shadow map
  #--------------------------------------------------------------------------
  def make_shadow_map
    for s in 0 ... 16
      x = s % 4
      y = s / 4
      if s & 0b1000 == 0b1000
        @shadow_bitmap.fill_rect(x*tilesize+16, y*@tilesize+16, 16, 16, SHADOW_COLOR)
      end
      if s & 0b0100 == 0b0100
        @shadow_bitmap.fill_rect(x*tilesize, y*@tilesize+16, 16, 16, SHADOW_COLOR)
      end
      if s & 0b0010 == 0b0010
        @shadow_bitmap.fill_rect(x*tilesize+16, y*@tilesize, 16, 16, SHADOW_COLOR)
      end
      if s & 0b0001 == 0b0001
        @shadow_bitmap.fill_rect(x*tilesize, y*@tilesize, 16, 16, SHADOW_COLOR)
      end
    end
  end
 
  def draw_parallax
    image = Cache.parallax(@map.parallax_name)
    @src_rect.set(0, 0, image.width, image.height)
    @map_image.blt(0, 0, image, @src_rect)
  end
 
  #--------------------------------------------------------------------------
  # * Draw the shadow map
  #--------------------------------------------------------------------------
  def draw_shadow_map
    for x in @start_x ... @end_x
      for y in @start_y ... @end_y
      _x, _y = x*@tilesize, y*@tilesize
        s = @map.data[x, y, 3]  & 0b1111
        if s != 0
          x_ = (s % 4) * @tilesize
          y_ = (s / 4) * @tilesize
          @src_rect.set(x_, y_, @tilesize, @tilesize)
          draw_tile(x, y, @shadow_bitmap, @src_rect)
        end
      end
    end
  end
 
  #--------------------------------------------------------------------------
  # * Draw the specified layer
  #--------------------------------------------------------------------------
  def draw_layer(layer)
    for x in @start_x ... @end_x
      for y in @start_y ... @end_y
        _x, _y = x*@tilesize, y*@tilesize
        tile_id = @map.data[x, y, layer]
        next if tile_id == 0
        get_bitmap(tile_id)
        draw_tile(x, y, @tile, @tile_rect)
      end
    end
  end

  #--------------------------------------------------------------------------
  # * Draw the game player
  #--------------------------------------------------------------------------
  def draw_player
    set_character_bitmap($game_player, $game_player.x, $game_player.y) if @map_id == $game_map.map_id
  end
 
  def draw_followers
  end
 
  #--------------------------------------------------------------------------
  # * Draw map events
  #--------------------------------------------------------------------------
  def draw_events
    @map.events.values.each do |event|
      id = event.pages[0].graphic.tile_id
      char_name = event.pages[0].graphic.character_name
      if id > 0
        normal_tile(id)
        draw_tile(event.x, event.y, @tilemap, @src_rect)
      elsif char_name != ""
        set_character_bitmap(event.pages[0].graphic, event.x, event.y)
      end
    end
  end
 
  #--------------------------------------------------------------------------
  # * Draw map vehicles
  #--------------------------------------------------------------------------
  def draw_vehicles
    $game_map.vehicles.each do |vehicle|
      set_character_bitmap(vehicle, vehicle.x, vehicle.y,) if @map_id == vehicle.map_id
    end
  end
 
  #--------------------------------------------------------------------------
  # * Draw map sprites
  #--------------------------------------------------------------------------
  def draw_sprites
    draw_events if @draw_events
    draw_vehicles if @draw_vehicles
    draw_player if @draw_player
    draw_followers if @draw_followers
  end
 
  #--------------------------------------------------------------------------
  # * Highlight damage tiles
  #--------------------------------------------------------------------------
  def draw_damage
    @tile.clear
    @tile.fill_rect(0, 0, @tilesize, @tilesize, DAMAGE_COLOR)
    @src_rect.set(0, 0, @tilesize, @tilesize)
    for x in @start_x ... @end_x
      for y in @start_y ... @end_y
        _x, _y = x*@tilesize, y*@tilesize
        if damage_floor?(x, y)
          draw_tile(x, y, @tile, @src_rect)
        end
      end
    end
  end
 
  #--------------------------------------------------------------------------
  # * Highlight regions
  #--------------------------------------------------------------------------
  def draw_regions
    for x in @start_x ... @end_x
      for y in @start_y ... @end_y
        _x, _y = x*@tilesize, y*@tilesize
        @tile.fill_rect(0, 0, @tilesize, @tilesize, REGION_COLORS[region_id(x,y)])
        draw_tile(x, y, @tile, @src_rect)
      end
    end
  end
 
  def draw_screen_effects
  end
  #--------------------------------------------------------------------------
  # * Draw the map
  #--------------------------------------------------------------------------
  def draw_map
    make_shadow_map if @draw_shadow
    draw_parallax
    draw_layer(0)
    draw_layer(1)
    draw_shadow_map
    draw_layer(2)
    draw_damage if @draw_damage
    draw_regions if @draw_regions
    draw_sprites
    draw_screen_effects
  end
 
  #--------------------------------------------------------------------------
  # * Scale the map
  #--------------------------------------------------------------------------
  def scale_map
    nw = @width * @scale
    nh = @height * @scale
    @src_rect.set(0, 0, @width, @height)
    scaled_map = Bitmap.new(nw, nh)
    scaled_rect = Rect.new(0, 0, nw, nh)
    scaled_map.stretch_blt(scaled_rect, @map_image, @src_rect)
    @map_image = scaled_map
  end
 
  #--------------------------------------------------------------------------
  # * Take a mapshot of the map
  #--------------------------------------------------------------------------
  def mapshot
    @screen_local = false
    redraw
    export(Tsuki::Map_Saver::Mapshot_Directory)
    $game_message.add("Mapshot taken")
  end
   
  #--------------------------------------------------------------------------
  # * Take a screenshot of the map
  #--------------------------------------------------------------------------
  def screenshot
    @screen_local = true
    redraw
    export(Tsuki::Map_Saver::Screenshot_Directory)
    $game_message.add("Screenshot taken")
  end
 
  #--------------------------------------------------------------------------
  # * Get the format to export to
  #--------------------------------------------------------------------------
  def get_format
    if Tsuki::Map_Saver::Crashes
      format = Tsuki::Map_Saver::Crash_Format
    else
      format = Tsuki::Map_Saver::Export_Format
    end
  end
 
  #--------------------------------------------------------------------------
  # * Export the map to a file
  #--------------------------------------------------------------------------
  def export(dirName="")
    format = get_format
    name = @map.display_name != "" ? @map.display_name : @map_info.name
    Dir.mkdir(dirName) unless File.directory?(dirName)
    filename = "%s\\%s.%s" %[dirName, name, format]
    t1 = Time.now
    @map_image.export(filename, format)
    t2 = Time.now
    $game_message.add("Exported in %f seconds" %[t2 - t1])
  end
end

module Zlib
  class Png_File < GzipWriter
   
    ARGB2BGRA = Win32API.new('System/argb2bgra.dll', 'ARGB2BGRA', 'PL', '')
    #--------------------------------------------------------------------------
    # &#9679; Main
    #--------------------------------------------------------------------------
    def make_png(bitmap_Fx,mode)
      @mode = mode
      @bitmap_Fx = bitmap_Fx
      self.write(make_header)
      self.write(make_ihdr)
      self.write(make_idat)
      self.write(make_iend)
    end
    #--------------------------------------------------------------------------
    # &#9679; PNG file header block
    #--------------------------------------------------------------------------
    def make_header
      return [0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a].pack("C*")
    end
    #--------------------------------------------------------------------------
    # &#9679; PNG file data block header information (IHDR)
    #--------------------------------------------------------------------------
    def make_ihdr
      ih_size = [13].pack("N")
      ih_sign = "IHDR"
      ih_width = [@bitmap_Fx.width].pack("N")
      ih_height = [@bitmap_Fx.height].pack("N")
      ih_bit_depth = [8].pack("C")
      ih_color_type = [6].pack("C")
      ih_compression_method = [0].pack("C")
      ih_filter_method = [0].pack("C")
      ih_interlace_method = [0].pack("C")
      string = ih_sign + ih_width + ih_height + ih_bit_depth + ih_color_type +
               ih_compression_method + ih_filter_method + ih_interlace_method
      ih_crc = [Zlib.crc32(string)].pack("N")
      return ih_size + string + ih_crc
    end
    #--------------------------------------------------------------------------
    # &#9679; Generated image data (IDAT)
    #--------------------------------------------------------------------------
    def make_idat
      header = "\x49\x44\x41\x54"
      case @mode # please 54 ~
      when 1
        data = make_bitmap_data # 1
      else
        data = make_bitmap_data
      end
      data = Zlib::Deflate.deflate(data, 8)
      crc = [Zlib.crc32(header + data)].pack("N")
      size = [data.length].pack("N")
      return size + header + data + crc
    end
    #--------------------------------------------------------------------------
    # &#9679; Requests from the Bitmap object 54 to generate image data in mode 1
    # (please 54 ~)
    #--------------------------------------------------------------------------
    def make_bitmap_data1
      w = @bitmap_Fx.width
      h = @bitmap_Fx.height
      data = []
      for y in 0...h
        data.push(0)
        for x in 0...w
          color = @bitmap_Fx.get_pixel(x, y)
          red = color.red
          green = color.green
          blue = color.blue
          alpha = color.alpha
          data.push(red)
          data.push(green)
          data.push(blue)
          data.push(alpha)
        end
      end
      return data.pack("C*")
    end
    #--------------------------------------------------------------------------
    # &#9679; Bitmap object from the image data generated in mode 0
    #--------------------------------------------------------------------------
    def make_bitmap_data
      w, h = @bitmap_Fx.width, @bitmap_Fx.height
      w_4  = w * 4
      #-----
      rdata_ptr   = DL::CPtr.new((@bitmap_Fx.object_id<<1)+16, 4)[0, 4].unpack('I')[0]
      bm_info_ptr = DL::CPtr.new(rdata_ptr+8, 4)[0, 4].unpack('I')[0]
      bm_data_ptr = DL::CPtr.new(bm_info_ptr+12, 4)[0, 4].unpack('I')[0]
      data        = DL::CPtr.new(bm_data_ptr)
      s           = "\0" * (w_4 * h)
      s.clear
      for i in 0 ... h
        s << "\0"
        t_data = data[0, w_4]
        if Tsuki::Map_Saver::Crashes
          for ix in 0 ... w
          x = ix * 4
          t_data[x+2], t_data[x] = t_data[x], t_data[x+2]
          end
        else
          ARGB2BGRA.call(t_data, w)
        end
        data = data - (w_4)
        s.concat(t_data)
      end
      return s
    end
   
    #--------------------------------------------------------------------------
    # &#9679; PNG end of the file data blocks (IEND)
    #--------------------------------------------------------------------------
    def make_iend
      ie_size = [0].pack("N")
      ie_sign = "IEND"
      ie_crc = [Zlib.crc32(ie_sign)].pack("N")
      return ie_size + ie_sign + ie_crc
    end
  end
end
#==============================================================================
# &#9632; Bitmap
#------------------------------------------------------------------------------
# Related to the Bitmap.
#==============================================================================
class Bitmap
 
  #--------------------------------------------------------------------------
  # &#9679; Related
  #--------------------------------------------------------------------------
  def make_png(name="like", path="",mode=0)
    make_dir(path) if path != ""
    Zlib::Png_File.open("temp.gz") {|gz|
      gz.make_png(self,mode)
    }
    Zlib::GzipReader.open("temp.gz") {|gz|
      $read = gz.read
    }
    f = File.open(name,"wb")
    f.write($read)
    f.close
    File.delete('temp.gz')
    end
  #--------------------------------------------------------------------------
  # &#9679; Save the path generated
  #--------------------------------------------------------------------------
  def make_dir(path)
    dir = path.split("/")
    for i in 0...dir.size
      unless dir == "."
        add_dir = dir[0..i].join("/")
        begin
          Dir.mkdir(add_dir)
        rescue
        end
      end
    end
  end
 
  def write_pixels(file)
    pixels = []
    for y in (self.height - 1).downto(0)
      for x in 0..self.width - 1
        pix = self.get_pixel(x,y)
        pixels.concat([pix.blue, pix.green, pix.red])
      end
    end
    file.write(pixels.pack('C%d' %pixels.length))
  end
 
  def make_bmp(filename)
    file = File.open(filename, 'wb')
    size = width*height*3
    file.write(['BM',size+54,0,54,40,width,height,1,24,0,size,0,0,0,0].pack('a2L6S2L6'))
    write_pixels(file)
    file.close
  end
 
  def export(name, format="png")
    if format == "png"
      make_png(name)
    elsif format == "bmp"
      make_bmp(name)
    elsif format == "tga" && !Tsuki::Map_Saver::Crashes
      Win32API.new('System/bitmap2file.dll', 'Bitmap2File', 'LP', '').call(self.object_id, name)
    else
      $game_message.add("Unsupported format")
    end
  end
end

#==============================================================================
# * Compatibility add-ons
#==============================================================================
#Yami overlays
if $imported["YSE-OverlayMapping"]
  class Map_Saver
    def draw_overlay_map_ground
      filename = YSA::OVERLAY::GROUND
      filename += $game_map.map_id.to_s
      filename += "-" + $game_variables[YSA::OVERLAY::GROUND_VARIABLE].to_s
      p filename
      image = Cache.overlay(filename)
      @src_rect.set(@start_x*tilesize, @start_y*tilesize, image.width, image.height)
      @map_image.blt(0, 0, image, @src_rect)
    end
   
    def draw_overlay_map_parallax
      filename = YSA::OVERLAY::PARALLAX
      filename += $game_map.map_id.to_s
      filename += "-" + $game_variables[YSA::OVERLAY::PARALLAX_VARIABLE].to_s
      image = Cache.overlay(filename)
      @src_rect.set(@start_x*tilesize, @start_y*tilesize, image.width, image.height)
      @map_image.blt(0, 0, image, @src_rect)
    end
   
    def draw_overlay_map_light
      filename = YSA::OVERLAY::LIGHT
      filename += $game_map.map_id.to_s
      filename += "-" + $game_variables[YSA::OVERLAY::LIGHT_VARIABLE].to_s
      image = Cache.overlay(filename)
      @src_rect.set(@start_x*tilesize, @start_y*tilesize, image.width, image.height)
      @map_image.blt(0, 0, image, @src_rect, 10)
    end
   
    def draw_overlay_map_shadow
      filename = YSA::OVERLAY::SHADOW
      filename += $game_map.map_id.to_s
      filename += "-" + $game_variables[YSA::OVERLAY::SHADOW_VARIABLE].to_s
      image = Cache.overlay(filename)
      @src_rect.set(@start_x*tilesize, @start_y*tilesize, image.width, image.height)
      @map_image.blt(0, 0, image, @src_rect, 10)
    end
 
    alias :th_map_overlay_draw_map :draw_map
    def draw_map
      th_map_overlay_draw_map
      draw_overlay_map_ground if $game_switches[YSA::OVERLAY::GROUND_SWITCH]
      draw_overlay_map_parallax if $game_switches[YSA::OVERLAY::PARALLAX_SWITCH]
      draw_overlay_map_shadow if $game_switches[YSA::OVERLAY::SHADOW_SWITCH]
      draw_overlay_map_light if $game_switches[YSA::OVERLAY::LIGHT_SWITCH]
    end
  end
end


Screeny:
Spoiler:



Dodatkowe informacje:
Instrukcja:
1.Skrypt wkleić nad 'Main' w Edytorze Skryptów.
2. Pobrać ten plik i wrzucić go do folderu 'System' w naszej grze.
3.Aby zrobić "skrina", w trakcie gry trzeba kliknąć 'F6'
4.Aby zrobić 'mapshota' należy w trakcie gry kliknąć F7
________________________
Praca uszlachetnia, lenistwo uszczęśliwia.
 
 
aragorn7015 




Preferowany:
RPG Maker VXAce

Pomógł: 15 razy
Dołączył: 20 Kwi 2012
Posty: 186
Skąd: się biorą dzieci?
Wysłany: Pią 12 Paź, 2012 17:01
Wrzuć jeszcze raz plik ten który trzeba wrzucic do folderu System najlepiej na mediafire...
________________________
Jeśli pomogłem, daj
Spoiler:

POMÓGŁ



Uwielbiam się bawić na zdarzeniach w VX-ie... Więc jeśli masz jakieś pytanie jak coś zrobić na zdarzeniach to napisz. Jeśli będę wiedział to odpowiem
 
 
 
HPfan880 



Preferowany:
RPG Maker VX

Pomógł: 1 raz
Dołączył: 13 Lis 2012
Posty: 32
Skąd: Wołów
Wysłany: Wto 11 Gru, 2012 17:45
Bez tego skryptu też można zrobić.
Oto instrukcja:
Wejdź w mapę (daj najlepiej warstwę zdarzeniową)
kliknij "print screen"
Obrób w paiincie.
Ale skrypcik fajny :-)
________________________
Uwielbiam batcha :-)
Więc jak ktoś potrzebuje np. Pilota do gry to śmiało pisać do mnie :)
-----------------------------------------------------------Jak mnie obrazisz to:
$scene_GameOver :-)

Aktualny Projekt: End Adventure
Program: Notatnik :-)
 
 
aragorn7015 




Preferowany:
RPG Maker VXAce

Pomógł: 15 razy
Dołączył: 20 Kwi 2012
Posty: 186
Skąd: się biorą dzieci?
Wysłany: Wto 11 Gru, 2012 21:55
UP:
Myślisz że nie wiem?
Cytat:
Wejdź w mapę (daj najlepiej warstwę zdarzeniową)

Co? Przecież to beznadziejnie wygląda! Lepiej dodać screena z gry...
________________________
Jeśli pomogłem, daj
Spoiler:

POMÓGŁ



Uwielbiam się bawić na zdarzeniach w VX-ie... Więc jeśli masz jakieś pytanie jak coś zrobić na zdarzeniach to napisz. Jeśli będę wiedział to odpowiem
 
 
 
Amelanduil 




Preferowany:
RPG Maker VXAce

Pomógł: 3 razy
Dołączył: 28 Wrz 2011
Posty: 464
Wysłany: Sro 12 Gru, 2012 13:14
Nie, nie da się zrobić bez skryptu, głupoty gadasz, HP. Powodzenia w robieniu tego na mapie o wymiarach conajmniej 50x50. Skrypt jest po to, żebyś nie musiał biegać po mapie i sklejać 20 screenów...
A z edytora screenów się nie robi, tak robią tylko baki :I

Dobry skrypt, takich się do parallaxa używa tak nawiasem.
________________________
(╯°□°)╯︵ ┻━┻
"A jeśli... Boga nie ma, to co z ciebie za szatan?"
 
 
 
Nex 




Preferowany:
RPG Maker XP

Pomógł: 15 razy
Dołączył: 27 Paź 2012
Posty: 145
Wysłany: Sro 12 Gru, 2012 15:10
Teraz może będzie wiadomo o co chodzi gdy ktoś będzie miał problem z mapą :mrgreen:
 
 
MrBoomGood 




Preferowany:
RPG Maker VX

Pomógł: 3 razy
Dołączył: 07 Kwi 2011
Posty: 292
Skąd: Katowice
Wysłany: Pon 07 Sty, 2013 16:36
Można nowy link do tego pliku co trzeba wrzucić do system?
 
 
 
Saskio 




Preferowany:
RPG Maker VXAce

Pomógł: 1 raz
Dołączył: 20 Sie 2012
Posty: 51
Skąd: Włocławek
Wysłany: Pon 07 Sty, 2013 16:42
Niestety nie mam go już na dysku bo zmieniałem kompa, a ten plugin już nie istnieje :-(
________________________
Praca uszlachetnia, lenistwo uszczęśliwia.
 
 
MrBoomGood 




Preferowany:
RPG Maker VX

Pomógł: 3 razy
Dołączył: 07 Kwi 2011
Posty: 292
Skąd: Katowice
Wysłany: Pon 07 Sty, 2013 16:53
To bardzo szkoda, bo skrypt zapowiadał się świetnie ;c

@edit - Jakby ktoś potrzebował to tutaj coś znalazłem: http://www.rpgmakervxace....map-screenshot/
Jeszcze nie testowałem.
@edit2 - Sprawdziłem i wszystko działa jak powinno.
 
 
 
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