Visual error - Map Screenshot + Pixel Offset

This issue has bugged me for months but I can't figure it out.

This is how I think the map screenshot script places events on a full mapshot or screenshot:
upload_2019-1-13_12-18-7.png


The Offset script uses comments to determine if there should be any X or Y offsets to the character sprite). I've been trying to add something like "event.x/event.y + ( self.x or self.y tweaks the offset script made)" but that's failed so far.

Example: Event placed has an offset comment so that it appears on the red tile. (comment: MOVE 32, 0)
upload_2019-1-13_12-24-35.png
upload_2019-1-13_12-25-10.png


But when taking a screenshot/mapshot, the offset is ignored:
upload_2019-1-13_12-26-0.png


I've attached a demo with the scripts below.
Bump..
Here you go:
Spoiler
Code:
class Map_Saver
 
  def draw_events
    @map.events.each do |eid,event|
      canDraw = event.pages[0].list.any? do |cmd|
        cmd.code == 108 && cmd.parameters[0] =~ /<screenshot:\s*tile\s*>/i
      end
      next unless @draw_events || canDraw
      id = event.pages[0].graphic.tile_id
      char_name = event.pages[0].graphic.character_name
      ev = @game_map.events[eid]
      ex = ev.imp1_pixel_offset[0]
      ey = ev.imp1_pixel_offset[1]
      if id > 0
        normal_tile(id)
        draw_tile(event.x, event.y, @tilemap, @src_rect, ex, ey)
      elsif char_name != ""
        set_character_bitmap(event.pages[0].graphic, event.x, event.y, ex, ey)
      end
    end
  end
 
  def set_character_bitmap(character, x, y, ex = 0, ey = 0)
    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)
    draw_character(x, y, cw, ch, charmap, @src_rect, ex, ey)
  end

  def draw_tile(x, y, tile, rect, ex = 0, ey = 0)
    ox = (x - @start_x) * tilesize + ex
    oy = (y - @start_y) * tilesize + ey
    @map_image.blt(ox, oy, tile, rect)
  end
 
  def draw_character(x, y, width, height, bmp, rect, ex = 0, ey = 0)
    ox = (x - @start_x) * tilesize
    oy = (y - @start_y) * tilesize
    ox = ox - width / 4 if width > 32
    oy = oy - height / 2 if height > 32
    @map_image.blt(ox + ex, oy + ey, bmp, rect)
  end

end
Drop this right below Tsukihime's Map Screenshot script. I only tested it for one map screenshot, but I guess it shouldn't have issues.
Here you go:
Spoiler
Code:
class Map_Saver
 
  def draw_events
    @map.events.each do |eid,event|
      canDraw = event.pages[0].list.any? do |cmd|
        cmd.code == 108 && cmd.parameters[0] =~ /<screenshot:\s*tile\s*>/i
      end
      next unless @draw_events || canDraw
      id = event.pages[0].graphic.tile_id
      char_name = event.pages[0].graphic.character_name
      ev = @game_map.events[eid]
      ex = ev.imp1_pixel_offset[0]
      ey = ev.imp1_pixel_offset[1]
      if id > 0
        normal_tile(id)
        draw_tile(event.x, event.y, @tilemap, @src_rect, ex, ey)
      elsif char_name != ""
        set_character_bitmap(event.pages[0].graphic, event.x, event.y, ex, ey)
      end
    end
  end
 
  def set_character_bitmap(character, x, y, ex = 0, ey = 0)
    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)
    draw_character(x, y, cw, ch, charmap, @src_rect, ex, ey)
  end

  def draw_tile(x, y, tile, rect, ex = 0, ey = 0)
    ox = (x - @start_x) * tilesize + ex
    oy = (y - @start_y) * tilesize + ey
    @map_image.blt(ox, oy, tile, rect)
  end
 
  def draw_character(x, y, width, height, bmp, rect, ex = 0, ey = 0)
    ox = (x - @start_x) * tilesize
    oy = (y - @start_y) * tilesize
    ox = ox - width / 4 if width > 32
    oy = oy - height / 2 if height > 32
    @map_image.blt(ox + ex, oy + ey, bmp, rect)
  end

end
Drop this right below Tsukihime's Map Screenshot script. I only tested it for one map screenshot, but I guess it shouldn't have issues.
I've tested it a bunch as well, no issues found. 🙂 Thank you.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/visual-error-map-screenshot-pixel-offset.104405/