Specific Animations which are not shown under specific terrains

Started by Stray, December 09, 2011, 05:35:30 pm

Previous topic - Next topic

Stray

Hey hey~

Is there a script, that hides specific animations which are under specific terrains? For the areas where is nothing or walls.
I need this for lights. The part of the animation, which is under the terrain/the field should be hidden.


Stray~
I'm very grateful to you all for your great help.

Fantasist

I didn;t get you. What animations are you talking about? Event animations, autotile animations or battle animations?
Do you like ambient/electronic music? Then you should promote a talented artist! Help out here. (I'm serious. Just listen to his work at least!)


The best of freeware reviews: Gizmo's Freeware Reviews




LiTTleDRAgo

Quote from: Stray on December 09, 2011, 05:35:30 pm
Is there a script, that hides specific animations which are under specific terrains? For the areas where is nothing or walls.


from what I get, you want to make some animation didn't show at specific terrains?

Spoiler: ShowHide
Quote#==============================================================================
# ** Sprite_Character
#------------------------------------------------------------------------------
#  This sprite is used to display the character.It observes the Game_Character
#  class and automatically changes sprite conditions.
#==============================================================================

class Sprite_Character < RPG::Sprite
 
  ANIMATION_HIDE = [1,2,3]
  TERRAIN_HIDE = 1

  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    if @tile_id != @character.tile_id or
       @character_name != @character.character_name or
       @character_hue != @character.character_hue
      @tile_id = @character.tile_id
      @character_name = @character.character_name
      @character_hue = @character.character_hue
      if @tile_id >= 384
        self.bitmap = RPG::Cache.tile($game_map.tileset_name,
          @tile_id, @character.character_hue)
        self.src_rect.set(0, 0, 32, 32)
        self.ox = 16
        self.oy = 32
      else
        self.bitmap = RPG::Cache.character(@character.character_name,
          @character.character_hue)
        @cw = bitmap.width / 4
        @ch = bitmap.height / 4
        self.ox = @cw / 2
        self.oy = @ch
      end
    end
    self.visible = (not @character.transparent)
    if @tile_id == 0
      sx = @character.pattern * @cw
      sy = (@character.direction - 2) / 2 * @ch
      self.src_rect.set(sx, sy, @cw, @ch)
    end
    self.x = @character.screen_x
    self.y = @character.screen_y
    self.z = @character.screen_z(@ch)
    self.opacity = @character.opacity
    self.blend_type = @character.blend_type
    self.bush_depth = @character.bush_depth
    return if $game_map.terrain_tag(@character.x,@character.y) == TERRAIN_HIDE &&
        ANIMATION_HIDE.include?(@character.animation_id)

    if @character.animation_id != 0
      animation = $data_animations[@character.animation_id]
      animation(animation, true)
      @character.animation_id = 0
    end
  end
end



try inserting that line in Sprite_Character

Stray

Spoiler: ShowHide

That's how it looks normally...

Spoiler: ShowHide

That's how it should look like.
I'm very grateful to you all for your great help.

Stray

*bump*

There's no script, which can do something like that?
I'm very grateful to you all for your great help.

nathmatt

until now  :ninja:

edit: i think this is what you wanted

Spoiler: ShowHide
module RPG
 class Sprite < ::Sprite
   def animation_set_sprites(sprites, cell_data, position)
     for i in 0..15
       sprite = sprites[i]
       pattern = cell_data[i, 0]
       if sprite == nil or pattern == nil or pattern == -1
         sprite.visible = false if sprite != nil
         next
       end
       sprite.visible = true
       sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)
       if position == 3
         if self.viewport != nil
           sprite.x = self.viewport.rect.width / 2
           sprite.y = self.viewport.rect.height - 160
         else
           sprite.x = 320
           sprite.y = 240
         end
       else
         sprite.x = self.x - self.ox + self.src_rect.width / 2
         sprite.y = self.y - self.oy + self.src_rect.height / 2
         sprite.y -= self.src_rect.height / 4 if position == 0
         sprite.y += self.src_rect.height / 4 if position == 2
       end
       sprite.x += cell_data[i, 1]
       sprite.y += cell_data[i, 2]
       sprite.z = 100
       sprite.ox = 96
       sprite.oy = 96
       sprite.zoom_x = cell_data[i, 3] / 100.0
       sprite.zoom_y = cell_data[i, 3] / 100.0
       sprite.angle = cell_data[i, 4]
       sprite.mirror = (cell_data[i, 5] == 1)
       sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
       sprite.blend_type = cell_data[i, 7]
     end
   end
   
 end
 
end
Join Dead Frontier
Sorry, I will no longer be scripting for RMXP. I may or may not give support for my scripts. I don't have the will to script in RGSS anymore.
My script


Stray

Almost.
But unfortunately, the animations should be shown on the events too.
Only not on these tiles which are walls. It's important that I can use big light effects.

Spoiler: ShowHide
I'm very grateful to you all for your great help.

Blizzard

Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

nathmatt

try it now

Spoiler: ShowHide
module RPG
  class Sprite < ::Sprite
    def animation_set_sprites(sprites, cell_data, position)
      for i in 0..15
        sprite = sprites[i]
        pattern = cell_data[i, 0]
        if sprite == nil or pattern == nil or pattern == -1
          sprite.visible = false if sprite != nil
          next
        end
        sprite.visible = true
        sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)
        if position == 3
          if self.viewport != nil
            sprite.x = self.viewport.rect.width / 2
            sprite.y = self.viewport.rect.height - 160
          else
            sprite.x = 320
            sprite.y = 240
          end
        else
          sprite.x = self.x - self.ox + self.src_rect.width / 2
          sprite.y = self.y - self.oy + self.src_rect.height / 2
          sprite.y -= self.src_rect.height / 4 if position == 0
          sprite.y += self.src_rect.height / 4 if position == 2
        end
        sprite.x += cell_data[i, 1]
        sprite.y += cell_data[i, 2]
        sprite.z = 150
        sprite.ox = 96
        sprite.oy = 96
        sprite.zoom_x = cell_data[i, 3] / 100.0
        sprite.zoom_y = cell_data[i, 3] / 100.0
        sprite.angle = cell_data[i, 4]
        sprite.mirror = (cell_data[i, 5] == 1)
        sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
        sprite.blend_type = cell_data[i, 7]
      end
    end
   
  end
 
end
Join Dead Frontier
Sorry, I will no longer be scripting for RMXP. I may or may not give support for my scripts. I don't have the will to script in RGSS anymore.
My script


Stray

I'm so glad about your help and thank you, but the charsets are still above the animations... :ll
I'm very grateful to you all for your great help.

nathmatt

Quote from: nathmatt on December 29, 2011, 05:38:12 pm
sprite.z = 150



just keep messing with this line and see if you can come up with a number that works
Join Dead Frontier
Sorry, I will no longer be scripting for RMXP. I may or may not give support for my scripts. I don't have the will to script in RGSS anymore.
My script


Stray

This is the the line with sprite.z = 555
Spoiler: ShowHide


It's not important how high or low the value is.
If you try it with all priorities you'll see the effect. Anyway, it doesn't work very good.
I'm very grateful to you all for your great help.

nathmatt

Join Dead Frontier
Sorry, I will no longer be scripting for RMXP. I may or may not give support for my scripts. I don't have the will to script in RGSS anymore.
My script


KK20

I think you need to edit the z-values of the tilemap. Why? After studying the z-values of the tiles and characters, their values are almost identical and can clash into problems. For example, a character located at the VERY BOTTOM of the screen has a z-value of 511 while a tile with a priority of five can be less than that (like 160). My solution is to modify the z-value of tiles that have priority to something much bigger (like 1000 or more), thus the need to edit the Tilemap class.

Problem is, the Tilemap class is hidden. Users have made their own versions, so it's not that big of an issue. Whether you can program or not is essentially your biggest problem.

That said, I think I've found the solution, but I'm not ready to post it yet.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Stray

I'm not sure, what I have to change now. Also, I don't know much about scripting.

Do I need to change something in "Spriteset_Map", in the ".z"-Values?
I'm very grateful to you all for your great help.

KK20

Tilemap_Class Rewrite: ShowHide
#==============================================================================
#
#   Yet another Tilemap Script (for any map size /w autotiles)
#   by Meâ €žÂ¢ / Derk-Jan Karrenbeld (me@solarsoft.nl)
#   version 1.0 released on 08 nov 08
#   version 1.2
#
#==============================================================================
# Slightly editted version created by KK20
#==============================================================================

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# C o n f i g u r e
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# The added Z-value the tile receives for every level of priority
#     i.e.
#         Base z value + (Tile's Priority * PRIORITY_MULT)
PRIORITY_MULT = 100
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# E n d     C o n f i g u r e
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#==============================================================================
# ** Tilemap (hidden class)
#------------------------------------------------------------------------------
#  This class handles the map data to screen processing
#==============================================================================
class Tilemap
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader :tileset
  attr_reader :autotiles
  attr_reader :flash_data
  attr_reader :priorities
  attr_reader :visible
  attr_reader :ox, :oy
  attr_writer :autotiles
 
  #--------------------------------------------------------------------------
  # * Constant Configuration
  #--------------------------------------------------------------------------
 
  # Window Rect - the visible Area of the Map (default: 640 x 480)
  # Bitmap Rect - the active drawing Area of the Map (window tiles + 2 tiles)
  # BitmapWindow offset - the invisible tile count on one side
  WindowRect = Rect.new(0,0,640,480)
  BitmapRect = Rect.new(0,0,640 + 64, 480 + 64) # Recommended
  BitmapWindowOffset = (BitmapRect.height-WindowRect.height)/2/32
 
  # Length in frames of one frame showing from autotile
  AutotileLength = 10
 
  # KillOutScreenSprite - Kills priority and autotile sprites out of screen
  # EnableFlashingData - If activated, enables updating flashing data
  KillOutScreenSprite   = true
  EnableFlashingData    = false
 
  # SingleFlashingSprite - Uses one Flashing sprite, instead of many
  # SinglePrioritySprite - Uses one Priority sprite, instead of many
  # SingleAutotileSprite - Uses one Autotile sprite, instead of many
  SingleFlashingSprite  = false
  SinglePrioritySprite  = false
  SingleAutotileSprite  = false
 
  # This is the Autotile animation graphical index array. It contains numbers
  # that point to the graphic part of an animating autotile.
  Autotiles = [
    [ [27, 28, 33, 34], [ 5, 28, 33, 34], [27,  6, 33, 34], [ 5,  6, 33, 34],
      [27, 28, 33, 12], [ 5, 28, 33, 12], [27,  6, 33, 12], [ 5,  6, 33, 12] ],
    [ [27, 28, 11, 34], [ 5, 28, 11, 34], [27,  6, 11, 34], [ 5,  6, 11, 34],
      [27, 28, 11, 12], [ 5, 28, 11, 12], [27,  6, 11, 12], [ 5,  6, 11, 12] ],
    [ [25, 26, 31, 32], [25,  6, 31, 32], [25, 26, 31, 12], [25,  6, 31, 12],
      [15, 16, 21, 22], [15, 16, 21, 12], [15, 16, 11, 22], [15, 16, 11, 12] ],
    [ [29, 30, 35, 36], [29, 30, 11, 36], [ 5, 30, 35, 36], [ 5, 30, 11, 36],
      [39, 40, 45, 46], [ 5, 40, 45, 46], [39,  6, 45, 46], [ 5,  6, 45, 46] ],
    [ [25, 30, 31, 36], [15, 16, 45, 46], [13, 14, 19, 20], [13, 14, 19, 12],
      [17, 18, 23, 24], [17, 18, 11, 24], [41, 42, 47, 48], [ 5, 42, 47, 48] ],
    [ [37, 38, 43, 44], [37,  6, 43, 44], [13, 18, 19, 24], [13, 14, 43, 44],
      [37, 42, 43, 48], [17, 18, 47, 48], [13, 18, 43, 48], [ 1,  2,  7,  8] ]
  ]
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     viewport : the drawing viewport
  #     rpgmap : the rpgmap object
  #--------------------------------------------------------------------------
  def initialize(viewport = nil, rpgmap = nil)
    # Autotiles Array
    @autotiles    = Array.new(6, nil)
    @oldautotiles = Array.new(6, nil)
    # Tilemap Viewport
    @viewport   = viewport ? viewport : Viewport.new(WindowRect)
    # Showing Region Rectangle
    @region     = Rect.new(0,0,BitmapRect.width/32, BitmapRect.height/32)
    # Old Region Rect
    @oldregion  = nil
    # Set TilemapSprite
    @sprite     = Sprite.new(@viewport)
    # Set Bitmap on Sprite
    @sprite.bitmap = Bitmap.new(BitmapRect.width, BitmapRect.height)
    # Set FlashingSprite and bitmap
    if SingleFlashingSprite
      @flashsprite = Sprite.new(@viewport)
      @flashsprite.bitmap = Bitmap.new(BitmapRect.width, BitmapRect.height)
    end
    # Set Informational Arrays/Hashes
    @priority_ids     = {}  # Priority ids
    @normal_tiles     = {}  # Non-auto tile bitmaps
    @auto_tiles       = {}  # Autotile bitmaps
    @priority_sprites = []  # Priority Sprites
    @autotile_sprites = []  # Autotile Sprites
    @flashing_sprites = []  # Flashing Sprites
    # Disposal Boolean
    @disposed   = false
    # Visibility Boolean
    @visible    = true
    # Flashing Boolean
    @flashing   = true
    # Disable Drawing Boolean
    @can_draw   = true
    # Set Coords
    @ox, @oy = 0, 0
    # Create TileMap if rpgmap is provided
    create_tilemap(rpgmap) if !rpgmap.nil?
  end
  #--------------------------------------------------------------------------
  # * Get Bitmap Sprite
  #--------------------------------------------------------------------------
  def sprite_bitmap
    return @sprite.bitmap
  end
  #--------------------------------------------------------------------------
  # * Data Tileset Referer - loads if needed
  #--------------------------------------------------------------------------
  def data_tilesets
    $data_tilesets ||= load_data("Data/Tilesets.rxdata")
  end
  #--------------------------------------------------------------------------
  # * Check: Disposed?
  #--------------------------------------------------------------------------
  def disposed?
    @disposed
  end
  #--------------------------------------------------------------------------
  # * Dispose
  #--------------------------------------------------------------------------
  def dispose
    # Dispose all sprites (and cached bitmaps for quick memory clearing)
    for sprite in [@sprite] + @normal_tiles.values + @auto_tiles.values + @priority_sprites + @autotile_sprites + (SingleFlashingSprite ? [@flashsprite] : @flashing_sprites)
      sprite = sprite[0] if sprite.is_a?(Array)
      sprite.dispose if sprite.is_a?(Bitmap)
    end
    # Set Informational Arrays/Hashes
    @priority_ids     = {}  # Priority ids
    @normal_tiles     = {}  # Non-auto tile bitmaps
    @priority_sprites = []  # Priority Sprites
    @autotile_sprites = []  # Autotile Sprites
    @flashing_sprites = []  # Flashing Sprites
    # I am disposed
    @disposed = true
  end
  #--------------------------------------------------------------------------
  # * Checking: Drawing Allowed
  #--------------------------------------------------------------------------
  def drawing?
    @can_draw
  end
  #--------------------------------------------------------------------------
  # * Enable Drawing
  #--------------------------------------------------------------------------
  def enable_drawing
    @can_draw = true
  end
  #--------------------------------------------------------------------------
  # * Disable Drawing
  #--------------------------------------------------------------------------
  def disable_drawing
    @can_draw = true
  end
  #--------------------------------------------------------------------------
  # * Enable Flashing
  #--------------------------------------------------------------------------
  def enable_flashing
    @flashing = true
  end
  #--------------------------------------------------------------------------
  # * Disable Flashing
  #--------------------------------------------------------------------------
  def disable_flashing
    @flashing = false
  end
  #--------------------------------------------------------------------------
  # * Check: Flashing
  #--------------------------------------------------------------------------
  def flashing?
    EnableFlashingData and @flashing and @flashing_sprites.size
  end
  #--------------------------------------------------------------------------
  # * Check: Visible
  #--------------------------------------------------------------------------
  def visible?
    @visible
  end
  #--------------------------------------------------------------------------
  # * Check: Autotiles Changed
  #--------------------------------------------------------------------------
  def autotiles_changed?
    @oldautotiles != @autotiles
  end
  #--------------------------------------------------------------------------
  # * Set Visibility
  #     value: new value
  #--------------------------------------------------------------------------
  def visible=(value)
    # Set Visibility value
    @visible = value
    # Update all sprites
    for sprite in [@sprite] + @priority_sprites + @autotile_sprites + (SingleFlashingSprite ? [@flashsprite] : @flashing_sprites)
      sprite = sprite[0] if sprite.is_a?(Array)
      sprite.visible = value
    end
  end
  #--------------------------------------------------------------------------
  # * Set Tileset
  #     value : new RPG::Tileset, String or Bitmap
  #--------------------------------------------------------------------------
  def tileset=(value)
    # Return on equal data
    return if @tileset == value
    # Set TilesetName
    value = value.tileset_name if value.is_a?(RPG::Tileset)
    # Cache Tileset
    @tileset = RPG::Cache.tileset(value) if value.is_a?(String)
    # Set Tileset
    @tileset = value if value.is_a?(Bitmap)
    # Draw Tileset
    redraw_tileset if @can_draw
  end
  #--------------------------------------------------------------------------
  # * Set Priorities
  #     value : new value
  #--------------------------------------------------------------------------
  def priorities=(value)
    # Return on equal data
    return if @priorities == value
    # Set Priorities
    @priorities = value
    # Draw Tileset
    redraw_priorities if @can_draw
  end
  #--------------------------------------------------------------------------
  # * Set flash data
  #     coord[0] : x
  #     coord[1] : y
  #     value    : Color or Hex
  #--------------------------------------------------------------------------
  def flash_data=(*coord, &value)
    # Return on equal data
    return if @flash_data[coord[0],coord[1]] == value
    # Already Flashing this tile?
    flashing = !@flash_data[x,y].nil?
    # Set Flash Data
    @flash_data[x,y] = value
    return if !EnableFlashingData
    # Take action and remove/change/add flash
    if value.nil?
      remove_flash(x,y)
    elsif flashing
      change_flash(x,y,value)
    else
      add_flash(x,y,value)
    end
  end
  #--------------------------------------------------------------------------
  # * Map Data referer
  #--------------------------------------------------------------------------
  def map_data
    @map_data
  end
  #--------------------------------------------------------------------------
  # * Set Map Data
  #     value : new Table value
  #--------------------------------------------------------------------------
  def map_data=(value)
    # Return on equal data
    return if @map_data == value
    # Set New Map Data
    @map_data = value
    # Flash Data Table
    @flash_data = Table.new(@map_data.xsize, @map_data.ysize)
    # Redraw Current Region
    draw_region if @can_draw and @priorities and @tileset
  end
  #--------------------------------------------------------------------------
  # * Get Map width (in tiles)
  #--------------------------------------------------------------------------
  def map_tile_width
    map_data.xsize
  end
  #--------------------------------------------------------------------------
  # * Get Map height (in tiles)
  #--------------------------------------------------------------------------
  def map_tile_height
    map_data.ysize
  end
  #--------------------------------------------------------------------------
  # * Create Tilemap
  #     rpgmap : base object
  #--------------------------------------------------------------------------
  def create_tilemap(rpgmap)
    # Return on invalid data
    return if rpgmap.is_a?(RPG::Map) == false
    # Restrict drawing
    @can_draw = false
    # Set Local Tileset Object (RPG::Tileset)
    _tileset = data_tilesets[rpgmap.tileset_id]
    # Return on invalid data
    return if _tileset.is_a?(RPG::Tileset) == false
    # Set Informational Arrays/Hashes
    @priority_ids     = {}  # Priority ids
    @normal_tiles     = {}  # Non-auto tile bitmaps
    @priority_sprites = []  # Priority Sprites
    @autotile_sprites = []  # Autotile Sprites
    @flashing_sprites = []  # Flashing Sprites
    # Set Tileset
    tileset = _tileset.tileset_name
    # Set AutoTiles
    (0..6).each { |i| autotiles[i] = _tileset.autotile_names[i] }
    # Set Priorities
    priorities = _tileset.priorities
    # Set Mapdata
    map_data = rpgmap.map_data
    # Reset drawing
    @can_draw = true
    # Reset disposed (need to reinit info variables)
    @disposed = false
    # Draw Region
    draw_region
  end
  #--------------------------------------------------------------------------
  # * Get Tile id
  #     x : x tile coord
  #     y : y tile coord
  #     z : z layer coord
  #--------------------------------------------------------------------------
  def tile_id(x, y, z)
    return map_data[x, y, z]
  end
  #--------------------------------------------------------------------------
  # * Get Priority
  #     args (1) : tile_id
  #     args (3) : x, y, z coord
  #--------------------------------------------------------------------------
  def priority(*args)
    return @priorities[args[0]] if args.size == 1
    return @priorities[tile_id(args[0], args[1], args[2])]
  end
  #--------------------------------------------------------------------------
  # * Redraw Tileset (on change)
  #--------------------------------------------------------------------------
  def redraw_tileset
    # Kill current bitmap
    sprite_bitmap.clear
    # Get rid of tile bitmaps
    @normal_tiles.clear
    # Get rid of autotile bitmaps
    @auto_tiles.clear
    # Dispose current tiles in screen
    (@autotile_sprites + @priority_sprites).each { |sprite| sprite[0].dispose if !sprite[0].disposed? }
    # Clear disposed graphics
    @autotile_sprites.clear; @priority_sprites.clear
    # Draw if allowed
    draw_region if @can_draw and @priorities and @tileset
  end
  #--------------------------------------------------------------------------
  # * Redraw Priorities (on change)
  #--------------------------------------------------------------------------
  def redraw_priorities
    # Dispose current tiles in screen
    (@autotile_sprites + @priority_sprites).each { |sprite| sprite[0].dispose if !sprite[0].disposed? }
    # Clear disposed graphics
    @priority_sprites.clear; @autotile_sprites.clear
    # Clear Priority id information
    @priority_ids.clear
    # Do a one time check for all priorities (can't do @tileset.priorities
    # because RPG::Tilemap is normally not passed trough, but if it were, you
    # can do the following - just uncomment this part and command the next for
    # loop:
    ## for tile_id in 0...@tileset.priorities.xsize
    ##  next if @tileset.priorities[tile_id] == 0
    ##  @priority_ids[tile_id] = @tileset.priorities[tile_id]
    ## end
    # But because we don't have that data, just iterate trough the map and
    # get seperate priority data for each tile, and save if there is one.
    for z in 0...3
      for y in 0...map_tile_height
        for x in 0...map_tile_width
          next if (id = tile_id(x, y, z)) == 0
          next if (p = priority(id)) == 0
          @priority_ids[id] = p
        end
      end
    end
    # Draw if allowed
    draw_region if @can_draw and @priorities and @tileset
  end
  #--------------------------------------------------------------------------
  # * Redraw autotiles (on change)
  #--------------------------------------------------------------------------
  def redraw_autotiles
    # Clear autotile bitmaps
    @auto_tiles.clear
    # Dispose current autotiles on screen
    @autotile_sprites.each { |sprite| sprite[0].dispose if !sprite[0].disposed? }
    # Get rid of disposed sprites
    @autotile_sprites.clear
    # Save changes aka don't call this method again
    @oldautotiles = @autotiles
    # Draw if allowed
    draw_region if @can_draw and @priorities and @tileset
  end
  #--------------------------------------------------------------------------
  # * Draw new Visible region
  #--------------------------------------------------------------------------
  def draw_current_region
    # Determine x and y coords for tile top left
    left_x = @ox / 32
    top_y = @oy / 32
    # Set origin for bitmap
    @sprite.ox = @ox % 32 + BitmapWindowOffset * 32
    @sprite.oy = @oy % 32 + BitmapWindowOffset * 32
    # Set New Region
    @region.x, @region.y = left_x, top_y
    # Set New Sprite Positions (pray for non disposed sprites: checking = cpu cost)
    (@priority_sprites + @autotile_sprites).each { |sprite| sprite[0].x = (sprite[1] - left_x) * 32 ;
      sprite[0].ox = @ox % 32; sprite[0].y = (sprite[2] - top_y) * 32; sprite[0].oy = @oy % 32;
      unless (priority = @priority_ids[tile_id(sprite[1], sprite[2], sprite[3])]).nil? then sprite[0].z = @viewport.z + sprite[0].y + priority * PRIORITY_MULT + 32 end}
    # Return on old data
    return if @oldregion == @region
    # Draw complete region if new?
    return draw_region if @oldregion.nil?
    # Determine missing rect
    first_drawing_x = [((left_x - @oldregion.x) >= 0 ? @region.width : 0) - (left_x - @oldregion.x)].max
    drawing_rect_x = Rect.new(first_drawing_x, 0, ((left_x - @oldregion.x).abs), @region.height)
    first_drawing_y = [((top_y - @oldregion.y) >= 0 ? @region.height : 0) - (top_y - @oldregion.y)].max
    drawing_rect_y = Rect.new(0, first_drawing_y, @region.width, ((top_y - @oldregion.y).abs))
    # Determine Rect that is still visible
    stay_rect = Rect.new([(left_x-@oldregion.x) * 32,0].max, [(top_y-@oldregion.y) * 32,0].max, (@region.width - (left_x-@oldregion.x).abs) * 32,(@region.height - (top_y-@oldregion.y).abs) * 32)
    # Dumplicate bitmap and clear Original
    dump_bitmap = sprite_bitmap.dup; sprite_bitmap.clear
    # Place Old bitmap on screen
    sprite_bitmap.blt([(@oldregion.x-left_x) * 32, 0].max, [(@oldregion.y-top_y) * 32, 0].max,dump_bitmap, stay_rect)
    # Remove Out of Range Sprites
    if KillOutScreenSprite
      _prio, _auto = @priority_sprites.dup, @autotile_sprites.dup; @priority_sprites, @autotile_sprites = [], []
      for sprite in _prio do if (sprite[1]) < @region.x - BitmapWindowOffset or (sprite[1] - BitmapWindowOffset) > @region.width + @region.x or sprite[2] < @region.y - BitmapWindowOffset or (sprite[2] - BitmapWindowOffset) > @region.height + @region.y  then sprite[0].dispose else @priority_sprites << sprite end end
      for sprite in _auto do if (sprite[1]) < @region.x - BitmapWindowOffset or (sprite[1] - BitmapWindowOffset) > @region.width + @region.x or sprite[2] < @region.y - BitmapWindowOffset or (sprite[2] - BitmapWindowOffset) > @region.height + @region.y  then sprite[0].dispose else @autotile_sprites << sprite end end
      # Remove nil elements (error prevention)
      @priority_sprites.compact!; @autotile_sprites.compact!;
    end
    # Draw New Columns
    for x in 0...drawing_rect_x.width
      for y in 0...drawing_rect_x.height
        for z in 0..2
          draw_tile(drawing_rect_x.x + x , drawing_rect_x.y + y, tile_id(left_x + drawing_rect_x.x + x - BitmapWindowOffset, top_y + y - BitmapWindowOffset, z), left_x + drawing_rect_x.x + x - BitmapWindowOffset, top_y + y - BitmapWindowOffset, z)
        end
      end
    end
    # Draw New Rows
    for x in 0...drawing_rect_y.width
      for y in 0...drawing_rect_y.height
        for z in 0..2
          draw_tile(drawing_rect_y.x + x , drawing_rect_y.y + y, tile_id(left_x + x - BitmapWindowOffset, top_y + drawing_rect_y.y + y - BitmapWindowOffset, z), left_x + x - BitmapWindowOffset, top_y + drawing_rect_y.y + y - BitmapWindowOffset, z)
        end
      end
    end
    # Set region sprite coords
    @oldregion = Rect.new(left_x, top_y, @region.width, @region.height)
  end
  #--------------------------------------------------------------------------
  # * Draw complete visible region
  #--------------------------------------------------------------------------
  def draw_region
    # Clear Sprites
    sprite_bitmap.clear
    (@priority_sprites + @autotile_sprites).each { |sprite| sprite[0].dispose }
    @priority_sprites.clear; @autotile_sprites.clear
    # Determine x and y coords for tile top left
    left_x = @ox / 32
    top_y = @oy / 32
    # Set Sprite ox/oy
    @sprite.ox = BitmapWindowOffset * 32
    @sprite.oy = BitmapWindowOffset * 32
    # Set New Region
    @region.x, @region.y = left_x, top_y
    # Iterate through new xses
    for x in 0...(@region.width)
      for y in 0...(@region.height)
        for z in 0..2
          # Draw new tiles
          draw_tile(x, y , tile_id(x + left_x - BitmapWindowOffset,y + top_y - BitmapWindowOffset,z), x + left_x - BitmapWindowOffset , y + top_y - BitmapWindowOffset, z)
        end
      end
    end
    # Set oldregion (sprite coords)
    @oldregion = Rect.new(left_x, top_y, @region.width, @region.height)
    # Update Sprite
    @sprite.update
    # Prevent Frame Skipping
    Graphics.frame_reset
  end
  #--------------------------------------------------------------------------
  # * Draw a tile
  #     x       : x coord in tiles on screen
  #     y       : y coord in tiles on screen
  #     tile_id : tile id
  #     tx      : x coord in tiles on map
  #     ty      : y coord in tiles on map
  #     tx      : z layer on map
  #     src_... : bitmap to draw on
  #--------------------------------------------------------------------------
  def draw_tile(x, y, tile_id, tx, ty, tz, src_bitmap = nil)
    # Return on invalid data
    #return if @region.x < x or @region.y < y
    #return if @region.width + @region.x > x or @region.height + @region.y > y
    return if x < 0 or y < 0
    return if tile_id == nil
    return draw_autotile(x, y, tile_id, tx, ty, tz, bitmap = bitmap) if tile_id < 384
    # First, Get Bitmap
    if (src_bitmap = @normal_tiles[tile_id]).nil?
      # Get Bitmap
      src_bitmap = Bitmap.new(32, 32)
      src_rect = Rect.new((tile_id - 384) % 8 * 32, (tile_id - 384) / 8 * 32,32,32)
      src_bitmap.blt(0, 0, @tileset, src_rect)
      # Save Bitmap
      @normal_tiles[tile_id] = src_bitmap
    end
    # Now, if tile is not a priority tile...
    if @priority_ids[tile_id].nil?
      sprite_bitmap.blt(x * 32, y * 32, src_bitmap, Rect.new(0,0,32,32))
    else
      # ... Set Sprite and bitmap
      sprite = Sprite.new(@viewport)
      sprite.visible = visible
      sprite.bitmap = src_bitmap
      sprite.x, sprite.y = (tx - (@ox/32)) * 32, (ty - (@oy/32)) * 32
      sprite.ox, sprite.oy = @ox % 32, @oy % 32
      # Priority matches 32 (above normal) + value * 32 (priority) + tile y * 32
      sprite.z = @viewport.z + y * 32 + @priority_ids[tile_id] * PRIORITY_MULT + 32
      # Add to sprites Array
      @priority_sprites << [sprite, tx, ty, tz]
    end
  end
  #--------------------------------------------------------------------------
  # * Draw an autotile
  #     x       : x coord in tiles on screen
  #     y       : y coord in tiles on screen
  #     tile_id : tile id
  #     tx      : x coord in tiles on map
  #     ty      : y coord in tiles on map
  #     tx      : z layer on map
  #     src_... : bitmap to draw on
  #--------------------------------------------------------------------------
  def draw_autotile(x, y, tile_id, tx, ty, tz, src_bitmap = nil)
    # Kill invalid calls
    return if x < 0 or y < 0
    return if tile_id == nil or tile_id >= 384
    return if tile_id == 0
    # Get AutotileGraphic
    autotile = @autotiles[tile_id/48-1]
    return if autotile.nil? or autotile.disposed?
    # Get Frame Data
    frames = (autotile.height == 32 ? autotile.width / 32 : autotile.width / 96)
    current_frame = (Graphics.frame_count/AutotileLength) % frames
    # First Get Bitmap
    if (src_bitmap_array = @auto_tiles[tile_id]).nil?
      @auto_tiles[tile_id] = []
      # If autotile is weird... :P
      if autotile.height == 32
        # Just iterate trough frames
        for i in 0...frames
          # Create a bitmap for this frame
          this_frame_bitmap = Bitmap.new(32,32)
          src_rect = Rect.new(i * 32, 0, 32, 32)
          this_frame_bitmap.blt(0, 0, autotile, src_rect)
          # Save this frame's bitmap
          @auto_tiles[tile_id] << this_frame_bitmap
        end
        # Set the bitmap array to the created one
        src_bitmap_array = @auto_tiles[tile_id]
      else
        # If autotile is normal, iterate
        for i in 0...frames
          # Create a new bitmap for this frame
          this_frame_bitmap = Bitmap.new(32,32)
          # Get the tiles from the Autotiles Array (tile_id corresponds
          # to the autotile graphic, so left_top is different to center
          tiles = Autotiles[(tile_id % 48)>>3][(tile_id % 48)&7]
          # Iterate trough 0, 1, 2 and 3
          for j in 0...4
            # Get tile_position (to get from the graphic)
            tile_position = tiles[j] - 1
            src_rect = Rect.new(tile_position % 6 * 16 + i * 96, tile_position / 6 * 16, 16, 16)
            this_frame_bitmap.blt(j % 2 * 16, j / 2 * 16 , autotile, src_rect)
          end
          @auto_tiles[tile_id][i] = this_frame_bitmap
        end
        src_bitmap_array = @auto_tiles[tile_id]
      end
    end
    # Now Get Frame Bitmap
    src_bitmap = src_bitmap_array[current_frame]
    return if src_bitmap.nil?
    # Now, if tile is not a priority tile...
    if @priority_ids[tile_id].nil? and autotile.width == 32
      sprite_bitmap.blt(x * 32, y * 32, src_bitmap, Rect.new(0,0,32,32))
    else
      priority = (@priority_ids[tile_id] or 0)
      # ... Set Sprite and bitmap
      sprite = Sprite.new(@viewport)
      sprite.visible = visible
      sprite.bitmap = src_bitmap
      sprite.x, sprite.y = (tx - (@ox/32)) * 32, (ty - (@oy/32)) * 32
      sprite.ox, sprite.oy = @ox % 32, @oy % 32
      # Priority matches 32 (above normal) + value * 32 (priority) + tile y * 32
      # Because this sprite is created later then the normal base sprite, it
      # has a higher internal z value. We fix this by setting the z value to
      # minus 2 + z value of this tile. This results in that a autotile is below
      # minus 2 + z value of this tile. This results in that a autotile is below
      # a normal sprite on the same priority
      sprite.z = @viewport.z - 2 + tz # Fix for ltr drwn.
      unless @priority_ids[tile_id].nil?
        sprite.z = @viewport.z + y * 32 + @priority_ids[tile_id] * PRIORITY_MULT + 32
      end
      # Add to sprites Array
      @autotile_sprites << [sprite, tx, ty, tz]
    end
  end
  #--------------------------------------------------------------------------
  # * Get new autotile Bitmap
  #     tile_id : tile id
  #--------------------------------------------------------------------------
  def get_update_autotile(tile_id)
    # Kill invalid Data
    return if tile_id == nil or tile_id >= 384
    return if tile_id == 0
    # Get AutotileGraphic
    autotile = @autotiles[tile_id/48-1]
    return if autotile.nil? or autotile.disposed?
    # Get Frame Data
    frames = (autotile.height == 32 ? autotile.width / 32 : autotile.width / 96)
    current_frame = (Graphics.frame_count/AutotileLength) % frames
    # Now Get Frame Bitmap
    src_bitmap = @auto_tiles[tile_id][current_frame]
    return src_bitmap   
  end
  #--------------------------------------------------------------------------
  # * Set x origin value
  #     value : new value
  #--------------------------------------------------------------------------
  def ox=(value)
    # Next line is needed if you want to do complex things if ox changes
    return unless @ox != value
    @ox = value
  end
  #--------------------------------------------------------------------------
  # * Set y origin value
  #     value : new value
  #--------------------------------------------------------------------------
  def oy=(value)
    # Next line is needed if you want to do complex things if oy changes
    return unless @oy != value
    @oy = value
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Redraw autotiles if changed
    redraw_autotiles if autotiles_changed?
    # Cancel updating if invisible
    return if not visible?
    # Flash Tiles
    update_flashing if flashing?
    # Update autotiles
    update_autotiles if (Graphics.frame_count % AutotileLength) == 0
    # Draw Region
    draw_current_region
  end
  #--------------------------------------------------------------------------
  # * Update (flashing)
  #--------------------------------------------------------------------------
  def update_flashing
    # To be released
  end
  #--------------------------------------------------------------------------
  # * Update (autotiles)
  #--------------------------------------------------------------------------
  def update_autotiles
    # Determine x and y coords for tile top left
    left_x = @ox / 32
    top_y = @oy / 32
    # Iterate trough sprites
    for sprite in @autotile_sprites
      # Get Data from Array
      real_sprite, tx, ty, tz = sprite
      tile_id = tile_id(tx, ty, tz)
      # Replace Bitmap (can't clear the bitmap, for some reason - don't try to)
      real_sprite.bitmap = get_update_autotile(tile_id)
      # We do not need to update the positions already, because it will be done
      # the next method call (below update_autotiles, there is draw_current_...)
      # so it will be 'fixed' there. No need to call something twice, right?
    end
  end
 
end

Animation Edit: ShowHide
module RPG
  class Sprite < ::Sprite
    def animation_set_sprites(sprites, cell_data, position)
      # Run through each sprite window (16 is the maximum windows)
      for i in 0..15
        # Get sprite window
        sprite = sprites[i]
        # Find graphic
        pattern = cell_data[i, 0]
        if sprite == nil or pattern == nil or pattern == -1
          sprite.visible = false if sprite != nil
          next
        end
        sprite.visible = true
        sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)
        if position == 3
          if self.viewport != nil
            sprite.x = self.viewport.rect.width / 2
            sprite.y = self.viewport.rect.height - 160
          else
            sprite.x = 320
            sprite.y = 240
          end
        else
          sprite.x = self.x - self.ox + self.src_rect.width / 2
          sprite.y = self.y - self.oy + self.src_rect.height / 2
          sprite.y -= self.src_rect.height / 4 if position == 0
          sprite.y += self.src_rect.height / 4 if position == 2
        end
        sprite.x += cell_data[i, 1]
        sprite.y += cell_data[i, 2]
        sprite.z = 512
        sprite.ox = 96
        sprite.oy = 96
        sprite.zoom_x = cell_data[i, 3] / 100.0
        sprite.zoom_y = cell_data[i, 3] / 100.0
        sprite.angle = cell_data[i, 4]
        sprite.mirror = (cell_data[i, 5] == 1)
        sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
        sprite.blend_type = cell_data[i, 7]
      end
    end
   
  end
 
end

Game_Character Add-on: ShowHide
class Game_Character
  #--------------------------------------------------------------------------
  # * Get Screen Z-Coordinates
  #     height : character height
  #--------------------------------------------------------------------------
  def screen_z(height = 0)
    # If display flag on closest surface is ON
    if @always_on_top
      return PRIORITY_MULT * 100
    end
    # Get screen coordinates from real coordinates and map display position
    z = (@real_y - $game_map.display_y + 3) / 4 + 32
    # If tile
    if @tile_id > 0
      # Add tile priority * 32
      return z + $game_map.priorities[@tile_id] * 32
    # If character
    else
      # If height exceeds 32, then add 31
      return z + ((height > 32) ? 31 : 0)
    end
  end
end


In the Tilemap_Class, I added a constant that you may change. Find whatever value best fits your needs. I also suggest giving tiles the highest priority (a value of 5 in the database editor) if you want animations to play BEHIND the tile.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Stray

Oh god, it works! Thank you SO much!

Only one question now: Do you think it could make problems, if I used it with the blizz ABS?
I'm very grateful to you all for your great help.

KK20

Sadly, I cannot answer that question. I haven't studied Blizz ABS enough to notice any compatibility issues. Nor do I know how much changing the Z-values does to the graphics (like windows, fogs, screen transitions, HUDs, etc.).

But if there are any issues you happen to come across, I'm here to help.  ;)

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Stray

Okay thank you.

My next question is, if this smooth scrolling script could be adjusted to these priorities.
I think it looks so pretty and makes a so much better effect... like a swinging camera.

So this script makes the scrolling while walking on a map more smooth.
Spoiler: ShowHide

#==============================================================================
# Listra Smooth Scroller Module by Bunga Tepi Jalan
# for RPG Maker
# Version 1.0
#==============================================================================
# Copyrighted by Bunga Tepi Jalan.
#  * Don't forget to credit me if you want to use this work
#  * You are free to Share - to copy, distribute and transmit the work
#  * You are free to Remix - to adapt the work
#  * You may not use this work for commercial purposes
#
#==============================================================================
# Information:
#  This script makes map scroll smoother.
#
# If you find any bugs or you have any suggestions, please report them via
# e-mail (listra92@gmail.com), or either my blog or these forums:
#  - http://bungatepijalan.wordpress.com
#  - http://www.rpgmakerid.com
#  - http://prodig.forumotion.net
#  - http://vixep.forumsrpg.net
#==============================================================================

module LSSM
  #--------------------------------------------------------------------------
  # * Listra Smooth Scroller Module Configuration
  #--------------------------------------------------------------------------
 
  # Config 1 -- Smooth scroll factor, higher value makes scroll slower
  SMOOTH = 16.0
  # Config 2 -- Custom horizontal & vertical map scroll border,
  #            don't exceed CENTER_X and CENTER_Y
  HBOR = 320 * 4
  VBOR = 240 * 4
  # Config 3 -- Use HBOR & VBOR?
  USECUSTOMBOR = false
end

#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
#  This class handles the player. Its functions include event starting
#  determinants and map scrolling. Refer to "$game_player" for the one
#  instance of this class.
#==============================================================================

class Game_Player < Game_Character
  #--------------------------------------------------------------------------
  # * Invariables (changed)
  #--------------------------------------------------------------------------
  CENTER_X = 320 * 4  # Center screen x-coordinate * 4
  CENTER_Y = 240 * 4  # Center screen y-coordinate * 4
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Remember whether or not moving in local variables
    last_moving = moving?
    # If moving, event running, move route forcing, and message window
    # display are all not occurring
    unless moving? or $game_system.map_interpreter.running? or
          @move_route_forcing or $game_temp.message_window_showing
      # Move player in the direction the directional button is being pressed
      case Input.dir4
      when 2
        move_down
      when 4
        move_left
      when 6
        move_right
      when 8
        move_up
      end
    end
    # Remember coordinates in local variables
    last_real_x = @real_x
    last_real_y = @real_y
    super
    # Player position as the real target coordinate (times 4)
    # Disable this if you want to use another position at certain event
    target_x = @real_x
    target_y = @real_y
    # Horizontal & vertical scroll border
    if LSSM::USECUSTOMBOR
      hbor = LSSM::HBOR
      vbor = LSSM::VBOR
    else
      hbor = CENTER_X
      vbor = CENTER_Y
    end
    # If character is positioned lower than the center of the screen
    if target_y - $game_map.display_y > 15*128 - vbor
      # Scroll map down
      if target_y > $game_map.height*128 - vbor
        $game_map.scroll_down((($game_map.height - 15)*128 - $game_map.display_y)/LSSM::SMOOTH)
      else
        $game_map.scroll_down((target_y - $game_map.display_y - 15*128 + vbor)/LSSM::SMOOTH)
      end
    end
    # If character is positioned more left on-screen than center
    if target_x - $game_map.display_x < hbor
      # Scroll map left
      if target_x < hbor
        $game_map.scroll_left($game_map.display_x/LSSM::SMOOTH)
      else
        $game_map.scroll_left(($game_map.display_x + hbor - target_x)/LSSM::SMOOTH)
      end
    end
    # If character is positioned more right on-screen than center
    if target_x - $game_map.display_x > 20*128 - hbor
      # Scroll map right
      if target_x > $game_map.width*128 - hbor
        $game_map.scroll_right((($game_map.width - 20)*128 - $game_map.display_x)/LSSM::SMOOTH)
      else
        $game_map.scroll_right((target_x - $game_map.display_x - 20*128 + hbor)/LSSM::SMOOTH)
      end
    end
    # If character is positioned higher than the center of the screen
    if target_y - $game_map.display_y < vbor
      # Scroll map up
      if target_y < vbor
        $game_map.scroll_up($game_map.display_y/LSSM::SMOOTH)
      else
        $game_map.scroll_up(($game_map.display_y + vbor - target_y)/LSSM::SMOOTH)
      end
    end
    # If not moving
    unless moving?
      # If player was moving last time
      if last_moving
        # Event determinant is via touch of same position event
        result = check_event_trigger_here([1,2])
        # If event which started does not exist
        if result == false
          # Disregard if debug mode is ON and ctrl key was pressed
          unless $DEBUG and Input.press?(Input::CTRL)
            # Encounter countdown
            if @encounter_count > 0
              @encounter_count -= 1
            end
          end
        end
      end
      # If C button was pressed
      if Input.trigger?(Input::C)
        # Same position and front event determinant
        check_event_trigger_here([0])
        check_event_trigger_there([0,1,2])
      end
    end
  end
end




The script can't work with the new scripts that we have here.
As example:
The hero walks 1 field up -> smooth scrolling for the hero sprite (and the lowest layer).
But the layers we have edited or added aren't mentioned in the "smooth scrolling"-script, so these layers
just move normal so that the map is collapsing.

Maybe I'm a bit insane to require this, but if there is a solution to it I could die happily. :^_^':
I'm very grateful to you all for your great help.

Stray

Is it that impossible?
I'm very grateful to you all for your great help.

KK20

I tried looking into it, but I was going into it blind. There are a ton of variables and numbers to keep track of to understand what is the issue. I don't think I can figure it out anytime soon. :\

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Stray

Too bad, the effect was so cool... I am just lucky your help was there.
I'm very grateful to you all for your great help.