じ☆ve冰风 发表于 2026-7-10 21:22:28

Game Map Simple Addons

Those are two scripts that implement some additional configuration on the default map parts.
They can work independently and are compatible with most scripts.

Author: Wecoc
Release Date: April 2014
Last Version: July 2020

Terms of Use
- Giving credits (Wecoc) for using this script is optional, but appreciated.
- You can repost this code.
- You can edit this code freely, and distribute the edits as well.
- This code can be used on commercial games.

Code - Display and Zoom Addons

                Ruby:       
#==============================================================================# ** Game Map Simple Addons#------------------------------------------------------------------------------#Author: Wecoc (no credits required)#Version: 1.0 #==============================================================================#==============================================================================# ** Game_System#==============================================================================class Game_System#--------------------------------------------------------------------------attr_accessor :parallax_game#--------------------------------------------------------------------------# * Initialize#--------------------------------------------------------------------------alias parallax_game_initialize initialize unless $@def initialize    parallax_game_initialize    @parallax_game = falseendend#==============================================================================# ** Game_Map#==============================================================================class Game_Map#--------------------------------------------------------------------------attr_accessor :tilemap_display_x, :tilemap_display_yattr_accessor :weather_display_x, :weather_display_yattr_accessor :panorama_zoom_x, :panorama_zoom_yattr_accessor :panorama_display_x, :panorama_display_yattr_accessor :fog_zoom_x, :fog_zoom_yattr_accessor :fog_display_x, :fog_display_y#--------------------------------------------------------------------------# * Setup#--------------------------------------------------------------------------alias wecoc_addons_setup setup unless $@def setup(map_id)    wecoc_addons_setup(map_id)    if $game_system.parallax_game == true      set_parallax_display    else      set_default_display    end    @panorama_zoom_x = 100.0    @panorama_zoom_y = 100.0    @fog_zoom_x = @fog_zoom    @fog_zoom_y = @fog_zoomend#--------------------------------------------------------------------------# * Parameters without coordinate specificity#--------------------------------------------------------------------------def tilemap_display    return @tilemap_display_xend#--------------------------------------------------------------------------def tilemap_display=(value)    @tilemap_display_x = value    @tilemap_display_y = valueend#--------------------------------------------------------------------------def weather_display    return @weather_display_xend#--------------------------------------------------------------------------def weather_display=(value)    @weather_display_x = value    @weather_display_y = valueend#--------------------------------------------------------------------------def panorama_zoom    return @panorama_zoom_xend#--------------------------------------------------------------------------def panorama_zoom=(zoom)    @panorama_zoom_x = zoom    @panorama_zoom_y = zoomend#--------------------------------------------------------------------------def panorama_display    return @panorama_display_xend#--------------------------------------------------------------------------def panorama_display=(value)    @panorama_display_x = value    @panorama_display_y = valueend#--------------------------------------------------------------------------def fog_zoom=(zoom)    @fog_zoom = zoom    @fog_zoom_x = zoom    @fog_zoom_y = zoomend#--------------------------------------------------------------------------def fog_display    return @fog_display_xend#--------------------------------------------------------------------------def fog_display=(value)    @fog_display_x = value    @fog_display_y = valueend#--------------------------------------------------------------------------# * Set default display#--------------------------------------------------------------------------def set_default_display    @tilemap_display_x = 4    @tilemap_display_y = 4    @weather_display_x = 4    @weather_display_y = 4    @panorama_display_x = 8    @panorama_display_y = 8    @fog_display_x = 4    @fog_display_y = 4end#--------------------------------------------------------------------------# * Set parallax display#--------------------------------------------------------------------------def set_parallax_display    @tilemap_display_x = 4    @tilemap_display_y = 4    @weather_display_x = 4    @weather_display_y = 4    @panorama_display_x = 4    @panorama_display_y = 4    @fog_display_x = 4    @fog_display_y = 4endend#==============================================================================# ** Game_Picture#==============================================================================class Game_Picture#--------------------------------------------------------------------------attr_accessor :display_x, :display_y#--------------------------------------------------------------------------# * Initialize#--------------------------------------------------------------------------alias wecoc_display_ini initialize unless $@def initialize(number)    wecoc_display_ini(number)    @display_x = 0    @display_y = 0end#--------------------------------------------------------------------------# * Parameters without coordinate specificity#--------------------------------------------------------------------------def display    return @display_xend#--------------------------------------------------------------------------def display=(value)    @display_x = value    @display_y = valueend#--------------------------------------------------------------------------# * Erase#--------------------------------------------------------------------------def erase    @name = ""    self.display = 0endend#==============================================================================# ** Sprite_Picture#==============================================================================class Sprite_Picture#--------------------------------------------------------------------------# * Parameters without coordinate specificity#--------------------------------------------------------------------------def display    return @picture.displayend#--------------------------------------------------------------------------def display=(value)    @picture.display = valueend#--------------------------------------------------------------------------def display_x    return @picture.display_xend#--------------------------------------------------------------------------def display_y    return @picture.display_yend#--------------------------------------------------------------------------def display_x=(value)    @picture.display_x = valueend#--------------------------------------------------------------------------def display_y=(value)    @picture.display_y = valueendend#==============================================================================# ** Spriteset_Map#==============================================================================class Spriteset_Map#--------------------------------------------------------------------------# * Update#--------------------------------------------------------------------------def update    # Panorama Name & Hue    if @panorama_name != $game_map.panorama_name or       @panorama_hue != $game_map.panorama_hue      @panorama_name = $game_map.panorama_name      @panorama_hue = $game_map.panorama_hue      if @panorama.bitmap != nil      @panorama.bitmap.dispose      @panorama.bitmap = nil      end      if @panorama_name != ""      @panorama.bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue)      end      Graphics.frame_reset    end    # Fog Name & Hue    if @fog_name != $game_map.fog_name or @fog_hue != $game_map.fog_hue      @fog_name = $game_map.fog_name      @fog_hue = $game_map.fog_hue      if @fog.bitmap != nil      @fog.bitmap.dispose      @fog.bitmap = nil      end      if @fog_name != ""      @fog.bitmap = RPG::Cache.fog(@fog_name, @fog_hue)      end      Graphics.frame_reset    end    # Tilemap Parameters    @tilemap.ox = $game_map.display_x / $game_map.tilemap_display_x    @tilemap.oy = $game_map.display_y / $game_map.tilemap_display_y    @tilemap.update    # Panorama Parameters    @panorama.ox = $game_map.display_x / $game_map.panorama_display_x    @panorama.oy = $game_map.display_y / $game_map.panorama_display_y    @panorama.zoom_x = $game_map.panorama_zoom_x / 100.0    @panorama.zoom_y = $game_map.panorama_zoom_y / 100.0    # Fog Parameters    @fog.zoom_x = $game_map.fog_zoom_x / 100.0    @fog.zoom_y = $game_map.fog_zoom_y / 100.0    @fog.opacity = $game_map.fog_opacity    @fog.blend_type = $game_map.fog_blend_type    @fog.ox = $game_map.display_x / $game_map.fog_display_x + $game_map.fog_ox    @fog.oy = $game_map.display_y / $game_map.fog_display_y + $game_map.fog_oy    @fog.tone = $game_map.fog_tone    # Character Sprites    for sprite in @character_sprites      sprite.update    end    # Weather Parameters    @weather.type = $game_screen.weather_type    @weather.max = $game_screen.weather_max    @weather.ox = $game_map.display_x / $game_map.weather_display_x    @weather.oy = $game_map.display_y / $game_map.weather_display_y    @weather.update    # Picture Sprites    for sprite in @picture_sprites      sprite.update      if sprite.display_x != 0      sprite.x -= $game_map.display_x / sprite.display_x      sprite.y -= $game_map.display_y / sprite.display_y      end    end    # Timer Update    @timer_sprite.update    # Viewport Updates    @viewport1.tone = $game_screen.tone    @viewport1.ox = $game_screen.shake    @viewport3.color = $game_screen.flash_color    @viewport1.update    @viewport3.updateendend


Script calls
You can control the scroll speed ("display") of each part via script call.

Change the display of the tilemap (Default: 4)
$game_map.tilemap_display = value

Change the display of the weather effects (Default: 4)
$game_map.weather_display = value

Change the display of the panorama (Default: 8)
$game_map.panorama_display = value

Change the display of the fog (Default: 4)
$game_map.fog_display = value

Change the display of a picture (Default: 4)
$game_screen.pictures[id].display =value

Change the zoom of the panorama (Default: 100)
$game_map.panorama_zoom = value

Change the zoom of the fog (Default: 100)
$game_map.fog_zoom = value

Spoiler: Extra information about the methodsTo change the display of a sprite or plane you use a method with the format
$game_map.(sprite)_display = value

For each one you can control the X and Y coordinates separately using
$game_map.(sprite)_display_x = value
$game_map.(sprite)_display_y = value

The zoom methods work exactly the same way
$game_map.(sprite)_zoom_x = value
$game_map.(sprite)_zoom_y = value
Code - Height, Opacity and Tone Addons

                Ruby:       
#==============================================================================# ** Game Map Tone Addons#------------------------------------------------------------------------------#Author: Wecoc (no credits required)#Version: 1.0#==============================================================================#==============================================================================# ** Game_Map#==============================================================================class Game_Map#--------------------------------------------------------------------------attr_accessor :panorama_z, :fog_z, :weather_zattr_accessor :panorama_opacityattr_reader :panorama_toneattr_reader :weather_toneattr_reader :character_sprites_tone#--------------------------------------------------------------------------# * Setup#--------------------------------------------------------------------------alias wec_more_addons_setup setup unless $@def setup(*args)    wec_more_addons_setup(*args)    @panorama_z = -1000    @fog_z = 3000    @weather_z = 1000    @panorama_opacity = 255    @panorama_opacity_duration = 0    @panorama_opacity_target = 0    @panorama_tone = Tone.new(0, 0, 0, 0)    @panorama_tone_target = Tone.new(0, 0, 0, 0)    @panorama_tone_duration = 0    @weather_tone = Tone.new(0, 0, 0, 0)    @weather_tone_target = Tone.new(0, 0, 0, 0)    @weather_tone_duration = 0    @character_sprites_tone = {}end#--------------------------------------------------------------------------# * Start Panorama Tone Change#--------------------------------------------------------------------------def start_panorama_tone_change(tone, duration)    @panorama_tone_target = tone.clone    @panorama_tone_duration = duration    if @panorama_tone_duration == 0      @panorama_tone = @panorama_tone_target.clone    endend#--------------------------------------------------------------------------# * Start Panorama Opacity Change#--------------------------------------------------------------------------def start_panorama_opacity_change(opacity, duration)    @panorama_opacity_target = opacity * 1.0    @panorama_opacity_duration = duration    if @panorama_opacity_duration == 0      @panorama_opacity = @panorama_opacity_target    endend#--------------------------------------------------------------------------# * Start Weather Tone Change#--------------------------------------------------------------------------def start_weather_tone_change(tone, duration)    @weather_tone_target = tone.clone    @weather_tone_duration = duration    if @weather_tone_duration == 0      @weather_tone = @weather_tone_target.clone    endend#--------------------------------------------------------------------------# * Start Event Tone Change#--------------------------------------------------------------------------def start_event_tone_change(event_id, tone, duration)    if @character_sprites_tone.nil?      @character_sprites_tone = []      @character_sprites_tone = Tone.new(0, 0, 0, 0)    end    @character_sprites_tone = tone.clone    @character_sprites_tone = duration    if duration == 0      @character_sprites_tone = tone.clone    endend#--------------------------------------------------------------------------# * Apply tone change in all events#--------------------------------------------------------------------------def start_events_tone_change(tone, duration)    for event in events.values      start_event_tone_change(event.id, tone, duration)    endend#--------------------------------------------------------------------------# * Apply tone change in player#--------------------------------------------------------------------------def start_player_tone_change(tone, duration)    start_event_tone_change(-1, tone, duration)end#--------------------------------------------------------------------------# * Update#--------------------------------------------------------------------------alias wec_more_addons_upd update unless $@def update    wec_more_addons_upd    if @panorama_tone_duration >= 1      d = @panorama_tone_duration      target = @panorama_tone_target      @panorama_tone.red = (@panorama_tone.red * (d - 1) + target.red) / d      @panorama_tone.green = (@panorama_tone.green * (d - 1) + target.green) / d      @panorama_tone.blue = (@panorama_tone.blue * (d - 1) + target.blue) / d      @panorama_tone.gray = (@panorama_tone.gray * (d - 1) + target.gray) / d      @panorama_tone_duration -= 1    end    if @panorama_opacity_duration >= 1      d = @panorama_opacity_duration      @panorama_opacity = (@panorama_opacity * (d - 1) + @fog_opacity_target) / d      @panorama_opacity_duration -= 1    end    if @weather_tone_duration >= 1      d = @weather_tone_duration      target = @weather_tone_target      @weather_tone.red = (@weather_tone.red * (d - 1) + target.red) / d      @weather_tone.green = (@weather_tone.green * (d - 1) + target.green) / d      @weather_tone.blue = (@weather_tone.blue * (d - 1) + target.blue) / d      @weather_tone.gray = (@weather_tone.gray * (d - 1) + target.gray) / d      @weather_tone_duration -= 1    end    for k in @character_sprites_tone.keys      if @character_sprites_tone >= 1      d = @character_sprites_tone      current = @character_sprites_tone      target = @character_sprites_tone      current.red = (current.red * (d - 1) + target.red) / d      current.green = (current.green * (d - 1) + target.green) / d      current.blue = (current.blue * (d - 1) + target.blue) / d      current.gray = (current.gray * (d - 1) + target.gray) / d      @character_sprites_tone -= 1      end    endendend#==============================================================================# ** RPG::Weather#==============================================================================module RPGclass Weather    #------------------------------------------------------------------------    # * Update    #------------------------------------------------------------------------    alias wec_more_addons_upd update unless $@    def update      wec_more_addons_upd      if @sprites.z != $game_map.weather_z      @sprites.each{|sprite| sprite.z = $game_map.weather_z}      end      if @sprites.tone != $game_map.weather_tone      @sprites.each{|sprite| sprite.tone = $game_map.weather_tone.clone}      end    endendend#==============================================================================# ** Spriteset_Map#==============================================================================class Spriteset_Map#--------------------------------------------------------------------------# * Update#--------------------------------------------------------------------------alias wec_more_addons_upd updatedef update    wec_more_addons_upd    @panorama.z = $game_map.panorama_z    @fog.z = $game_map.fog_z    @panorama.tone = $game_map.panorama_tone    @panorama.opacity = $game_map.panorama_opacity    for sprite in @character_sprites      character = sprite.character      if character.is_a?(Game_Player)      if $game_map.character_sprites_tone.keys.include?(-1)          sprite.tone = $game_map.character_sprites_tone[-1]      end      else      if $game_map.character_sprites_tone.keys.include?(character.id)          sprite.tone = $game_map.character_sprites_tone      end      end    endendend


Script calls

Change the Z of the panorama (Default: -1000)
$game_map.panorama_z = value

Change the Z of the fog (Default: 3000)
$game_map.fog_z = value

Change the Z of the weather (Default: 1000)
$game_map.weather_z = value

Change the opacity of the panorama
$game_map.panorama_opacity = value
$game_map.start_panorama_opacity_change(opacity,duration)

Change the tone of the panorama
$game_map.start_panorama_tone_change(tone,duration)

Change the tone of the weather
$game_map.start_weather_tone_change(tone,duration)

Change the tone of an event
$game_map.start_event_tone_change(event ID,tone,duration)
Use @event_id to change the tone of the current event.

Change the tone of all the events (it doesn't include the player)
$game_map.start_events_tone_change(tone, duration)

Change the tone of the player
$game_map.start_player_tone_change(tone, duration)

Spoiler: Extra information about the methodsSome script calls are long so you will have to use multiple lines, like this
                Code:       
t = Tone.new(-64, -80, -32, 32)d = 40$game_map.start_panorama_tone_change(t, d)


If the duration is 0, it changes directly.
Related scripts
By default the Viewport changes the tone of everything at once, with this script you can also change it independently.
The only part that doesn't have the tone integrated is the Tilemap. To do so, you have to use a Tilemap rewrite. My recommendation is the script Tilemap Tone Changer.


本贴来自国际rpgmaker官方论坛作者:Wecoc处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/game-map-simple-addons.138222/
页: [1]
查看完整版本: Game Map Simple Addons