Kain Nobel
Member
Map Auto Setup
Version: 2.5
By: Kain Nobel
Introduction
An alternative to using auto-start events to setup each map's special effects, allows you to setup each map through script. You've got a variety of options, such as each maps' menu/save access, switches/variables, etc... to what fog/tone each map uses.
Script
Instructions
Alot of the instructions are in the script, and the first few options are pre-setup as an example (using map 1 as an example, in the script).
Incase the instructions/example setup (in the script) are still too vauge, or you just need help on working a hash then please feel free to ask and I'll show you an example of how to do whatever you're trying to do with this.
Compatibility
Should be compatible with most anything, not sure if this script will work for VX.
Author's Notes
If I find time, I'll be adding some Interpreter commands so you can easily change AutoSetup settings via Call Script in events in your game, instead of being stuck trying to perfect settings through the RGSS Editor.
Terms and Conditions
Free to use in any commercial/non-commercial game, please credit me though if you use this.
Version: 2.5
By: Kain Nobel
Introduction
An alternative to using auto-start events to setup each map's special effects, allows you to setup each map through script. You've got a variety of options, such as each maps' menu/save access, switches/variables, etc... to what fog/tone each map uses.
Script
Code:
#===============================================================================
# ** Map : Auto Setup
#===============================================================================
Â
#-------------------------------------------------------------------------------
# * SDK Log
#-------------------------------------------------------------------------------
SDK.log('Map.AutoSetup', 'Kain Nobel ©', 2.5, '12.10.2008')
#-------------------------------------------------------------------------------
# * SDK Enabled Test : BEGIN
#-------------------------------------------------------------------------------
if SDK.enabled?('Map.AutoSetup')
Â
#===============================================================================
# ** Game_Map::AutoSetup
#===============================================================================
Â
module Game_Map::AutoSetup
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#
# ~** Â Â Â Â Â Â Â Â CUSTOMIZABLE INSTANCES - BEGIN Â Â Â Â Â Â Â Â Â Â Â **~ #
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#
 #-----------------------------------------------------------------------------
 # * @menu_disabled = {map_id => true/false}
 #-----------------------------------------------------------------------------
 @menu_disabled = {1 => true}
 #-----------------------------------------------------------------------------
 # * @save_disabled = {map_id => true/false}
 #-----------------------------------------------------------------------------
 @save_disabled = {1 => true}
 #-----------------------------------------------------------------------------
 # * @switches = {map_id => {switch_id => true/false}}
 #-----------------------------------------------------------------------------
 @switches  = {1 => {1 => true, 2 => false, 3 => true}}
 #-----------------------------------------------------------------------------
 # * @variables = {map_id => {variable_id => value}}
 #-----------------------------------------------------------------------------
 @variables  = {1 => {1 => 10, 2 => 20, 3 => 30}}
 #-----------------------------------------------------------------------------
 # * @self_switches = {map_id => {event_id => {event_key => value}}}
 #-----------------------------------------------------------------------------
 @self_switches = {1 => {1 => {"A" => true, "B" => false}}}
 #-----------------------------------------------------------------------------
 # * @screen_tones = {map_id => (Tone.new(r,g,b) || [r, g, b]), -fade}
 #-----------------------------------------------------------------------------
 @screen_tones = {1 => Tone.new(-68, -68, -68)}
 #-----------------------------------------------------------------------------
 # * @weather_effects = {map_id => [-weather, -power, -duration]}
 #-----------------------------------------------------------------------------
 @weather_effects = {1 => [1, 20, 40]}
 #-----------------------------------------------------------------------------
 # * @player_settings = {map_id => {'setting' => value}}
 #  - 'Speed'     => (Numeric)
 #  - 'Frequency'   => (Numeric)
 #  - 'Walk Anime'   => true/false
 #  - 'Step Anime'   => true/false
 #  - 'Direction Fix' => true/false
 #  - 'Through'    => true/false
 #  - 'Always On Top' => true/false
 #-----------------------------------------------------------------------------
 @player_settings = {}
 #-----------------------------------------------------------------------------
 # * @event_settings = {map_id => {event_id => {setting => value}}}
 #  - 'Speed'     => (Numeric)
 #  - 'Frequency'   => (Numeric)
 #  - 'Walk Anime'   => true/false
 #  - 'Step Anime'   => true/false
 #  - 'Direction Fix' => true/false
 #  - 'Through'    => true/false
 #  - 'Always On Top' => true/false
 #-----------------------------------------------------------------------------
 @event_settings = {}
 #-----------------------------------------------------------------------------
 # * @panorama_settings = {map_id => [filename (,hue)]}
 #-----------------------------------------------------------------------------
 @panorama_settings = {}
 #-----------------------------------------------------------------------------
 # * @fog_settings = {map_id => {'setting' => value, ...}}
 #  - 'Graphic' => (String)
 #  - 'Opacity' => (Numeric)
 #  - 'Tone'   => (Tone)
 #  - 'Zoom'   => (Numeric)
 #  - 'SX'    => (Numeric)
 #  - 'SY'    => (Numeric)
 #  - 'OX'    => (Numeric)
 #  - 'OY'    => (Numeric)
 #-----------------------------------------------------------------------------
 @fog_settings = {}
 #-----------------------------------------------------------------------------
 # * @fog_tones = {map_id => tone}
 #-----------------------------------------------------------------------------
 @fog_tones = {}
 #-----------------------------------------------------------------------------
 # * @fog_opacity = {map_id => [opacity (,fade)]}
 #-----------------------------------------------------------------------------
 @fog_opacity = {}
 #-----------------------------------------------------------------------------
 # * @battleback_settings = {map_id => [filename (,hue)]}
 #-----------------------------------------------------------------------------
 @battleback_settings = {}
 #-----------------------------------------------------------------------------
 # * @call_scripts = {map_id => "Call Script"}
 #-----------------------------------------------------------------------------
 @call_scripts = {}
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#
# ~** Â Â Â Â Â Â Â Â Â CUSTOMIZABLE INSTANCES - END Â Â Â Â Â Â Â Â Â Â Â Â **~ #
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#
 #-----------------------------------------------------------------------------
 # * Public Instance Variables
 #-----------------------------------------------------------------------------
 attr_accessor :menu_disabled
 attr_accessor :save_disabled
 attr_accessor :switches
 attr_accessor :variables
 attr_accessor :self_switches
 attr_accessor :screen_tones
 attr_accessor :weather_effects
 attr_accessor :player_settings
 attr_accessor :event_settings
 attr_accessor :fog_settings
 attr_accessor :fog_tones
 attr_accessor :battleback_settings
 #-----------------------------------------------------------------------------
 # * Game_Map::AutoSetup.pre_setup(map_id)
 #-----------------------------------------------------------------------------
 def self.pre_setup(map_id)
  instance_variables.each do |object|
   eval "#{object} = Hash.new unless #{object}.is_a?(Hash)"
  end
 end
 #-----------------------------------------------------------------------------
 # * Game_Map::AutoSetup.setup_menu_access
 #-----------------------------------------------------------------------------
 def self.setup_menu_access(map_id)
  if @menu_disabled.has_key?(map_id)
   $game_system.menu_disabled = @menu_disabled[map_id]
  end
 end
 #-----------------------------------------------------------------------------
 # * Game_Map::AutoSetup.setup_save_access
 #-----------------------------------------------------------------------------
 def self.setup_save_access(map_id)
  if @save_disabled.has_key?(map_id)
   $game_system.save_disabled = @save_disabled[map_id]
  end
 end
 #-----------------------------------------------------------------------------
 # * Game_Map::AutoSetup.setup_switches
 #-----------------------------------------------------------------------------
 def self.setup_switches(map_id)
  if @switches.has_key?(map_id)
   @switches[map_id].each_key do |key|
    $game_switches[key] = @switches[map_id][key] == true
   end
  end
 end
 #-----------------------------------------------------------------------------
 # * Game_Map::AutoSetup.setup_variables
 #-----------------------------------------------------------------------------
 def self.setup_variables(map_id)
  if @variables.has_key?(map_id)
   @variables[map_id].each_key do |key|
    unless @variables[map_id][key].nil?
     $game_variables[key] = @variables[map_id][key]
    else
     $game_variables[key] = 0
    end
   end
  end
 end
 #-----------------------------------------------------------------------------
 # * Game_Map::AutoSetup.setup_self_switches
 #-----------------------------------------------------------------------------
 def self.setup_self_switches(map_id)
  if @self_switches.has_key?(map_id)
   @self_switches[map_id].each_key do |event|
    if $game_map.events.include?(event)
     @self_switches[map_id][event].each_key do |key|
      if @self_switches[map_id][event].has_key?(key)
       $game_self_switches[[map_id, event, key]] =
       @self_switches[map_id][event][key] == true
      end
     end    Â
    end
   end
  end
 end
 #-----------------------------------------------------------------------------
 # * Game_Map::AutoSetup.setup_screen_tone
 #-----------------------------------------------------------------------------
 def self.setup_screen_tone(map_id)
  if @screen_tones.has_key?(map_id)
   if @screen_tones[map_id].is_a?(Tone)
    $game_screen.start_tone_change(@screen_tones[map_id].dup, 10)
    return
   elsif @screen_tones[map_id].is_a?(Array)
    if @screen_tones[map_id].size == 1
     if @screen_tones[map_id][0].is_a?(Tone)
      $game_screen.start_tone_change(@screen_tones[map_id][0].dup, 10)
      return
     end
    elsif @screen_tones[map_id].size == 2
     if @screen_tones[map_id][0].is_a?(Tone)
      if @screen_tones[map_id][1].is_a?(Numeric)
       $game_screen.start_tone_change(@screen_tones[map_id][0].dup,
       @screen_tones[map_id][1])
       return
      end
     end
    end
   end
  end
 end
 #-----------------------------------------------------------------------------
 # * Game_Map::AutoSetup.setup_weather_effects
 #-----------------------------------------------------------------------------
 def self.setup_weather_effects(map_id)
  if @weather_effects.has_key?(map_id)
   if @weather_effects[map_id].is_a?(Array)
    w = @weather_effects.dup
    case @weather_effects[map_id].size
    when 1 ; $game_screen.weather(w[map_id][0], 5, 0)
    when 2 ; $game_screen.weather(w[map_id][0], w[map_id][1], 0)
    when 3 ; $game_screen.weather(w[map_id][0], w[map_id][1], w[map_id][2])
    else  ; $game_screen.weather(0, 0, 0)
    end
   elsif @weather_effects[map_id].zero? || @weather_effects[map_id].nil?
    $game_screen.weather(0, 0, 0)
   end
  end
 end
 #-----------------------------------------------------------------------------
 # * Game_Map::AutoSetup.setup_player_settings
 #-----------------------------------------------------------------------------
 def self.setup_player_settings(map_id)
  if @player_settings.has_key?(map_id)
   @player_settings[map_id].each_key do |key|
    case key
    when "Speed"
     if @player_settings[map_id][key].is_a?(Numeric)
      $game_player.move_speed   = @player_settings[map_id][key]
     end
    when "Frequency"
     if @player_settings[map_id][key].is_a?(Numeric)
      $game_player.move_frequency = @player_settings[map_id][key]
     end
    when "Walk Anime"
     $game_player.walk_anime   = @player_settings[map_id][key] == true
    when "Step Anime"
     $game_player.step_anime   = @player_settings[map_id][key] == true
    when "Direction Fix"
     $game_player.direction_fix  = @player_settings[map_id][key] == true
    when "Through"
     $game_player.through     = @player_settings[map_id][key] == true
    when "Always On Top"
     $game_player.always_on_top  = @player_settings[map_id][key] == true
    end
   end
  end
 end
 #-----------------------------------------------------------------------------
 # * Game_Map::AutoSetup.setup_event_settings
 #-----------------------------------------------------------------------------
 def self.setup_event_settings(map_id)
  if @event_settings.has_key?(map_id)
   @event_settings[map_id].each_key do |i|
    if $game_map.events.include?(i)
     @event_settings[map_id][i].each_key do |key|
      event  = $game_map.events[i]
      setting = @event_settings[map_id][event.id][key]
      case key
      when "Speed"
       if setting.is_a?(Numeric)
        event.move_speed = setting
       end
      when "Frequency"
       if setting.is_a?(Numeric)
        event.move_frequency = setting
       end
      when "Walk Anime"
       event.walk_anime   = setting == true
      when "Step Anime"
       event.step_anime   = setting == true
      when "Direction Fix"
       event.direction_fix  = setting == true
      when "Through"
       event.through     = setting == true
      when "Always On Top"
       event.always_on_top  = setting == true
      end
     end
    end
   end
  end
 end
 #-----------------------------------------------------------------------------
 # * Game_Map::AutoSetup.setup_fog_settings
 #-----------------------------------------------------------------------------
 def self.setup_fog_settings(map_id)
  if @fog_settings.has_key?(map_id)
   @fog_settings[map_id].each_key do |key|
    case key
    when "Graphic"
     if @fog_settings[map_id][key].is_a?(String)
      begin
       $game_map.fog_name = @fog_settings[map_id][key]
      rescue
      end
     end
    when "Hue"
     if @fog_settings[map_id][key].is_a?(Numeric)
      if @fog_settings[map_id][key].between?(0, 360)
       $game_map.fog_hue = @fog_settings[map_id][key]
      end
     end
    when "SX"
     if @fog_settings[map_id][key].is_a?(Numeric)
      $game_map.fog_sx = @fog_settings[map_id][key]
     end
    when "OX"
     if @fog_settings[map_id][key].is_a?(Numeric)
      $game_map.fog_ox = @fog_settings[map_id][key]
     end
    when "SY"
     if @fog_settings[map_id][key].is_a?(Numeric)
      $game_map.fog_sy = @fog_settings[map_id][key]
     end
    when "OY"
     if @fog_settings[map_id][key].is_a?(Numeric)
      $game_map.fog_oy = @fog_settings[map_id][key]
     end
    when "Blend"
     if @fog_settings[map_id][key].is_a?(Numeric)
      if @fog_settings[map_id][key].between?(0, 2)
       $game_map.fog_blend_type = @fog_settings[map_id][key]
      end
     end
    when "Zoom"
     if @fog_settings[map_id][key].is_a?(Numeric)
      $game_map.fog_zoom = @fog_settings[map_id][key]
     end
    when "Opacity"
     if @fog_settings[map_id][key].is_a?(Numeric)
      if @fog_settings[map_id][key].between?(0, 255)
       $game_map.fog_opacity = @fog_settings[map_id][key]
      end
     end
    when "Tone"
     if @fog_settings[map_id][key].is_a?(Tone)
      $game_map.fog_tone = @fog_settings[map_id][key]
     end
    end
   end
  end
 end
 #-----------------------------------------------------------------------------
 # * Game_Map::AutoSetup.setup_fog_tone
 #-----------------------------------------------------------------------------
 def self.setup_fog_tone(map_id)
  if @fog_tones.has_key?(map_id)
   if @fog_tones[map_id].is_a?(Tone)
    $game_map.fog_tone = @fog_tones[map_id]
   elsif @fog_tones[map_id].is_a?(Array)
    if @fog_tones[map_id].length == 1
     if @fog_tones[map_id][0].is_a?(Tone)
      $game_map.start_fog_tone_change(@fog_tones[map_id][0], 20)
     end
    end
    if @fog_tones[map_id].length == 2
     if @fog_tones[map_id][0].is_a?(Tone)
      if @fog_tones[map_id][1].is_a?(Numeric)
       $game_map.start_fog_tone_change(@fog_tones[map_id][0],
       @fog_tones[map_id][1] * 2)
      end
     end
    end
   end
  end
 end
 #-----------------------------------------------------------------------------
 # * Game_Map::AutoSetup.setup_fog_opacity
 #-----------------------------------------------------------------------------
 def self.setup_fog_opacity(map_id)
  if @fog_opacity.has_key?(map_id)
   if @fog_opacity[map_id].is_a?(Numeric)
    $game_map.start_fog_opacity_change(@fog_opacity[map_id][0], 20)
   end
   if @fog_opacity[map_id].is_a?(Array)
    if @fog_opacity[map_id].length == 1
     if @fog_opacity[map_id][0].is_a?(Numeric)
      $game_map.start_fog_opacity_change(@fog_opacity[map_id][0], 20)
     end
    end
    if @fog_opacity[map_id].length == 2
     if @fog_opacity[map_id][0].is_a?(Numeric)
      if @fog_opacity[map_id][1].is_a?(Numeric)
       $game_map.start_fog_opacity_change(@fog_opacity[map_id][0],
       @fog_opacity[map_id][1] * 2)
      end
     end
    end
   end
  end
 end
 #-----------------------------------------------------------------------------
 # * Game_Map::AutoSetup.setup_panorama
 #-----------------------------------------------------------------------------
 def self.setup_panorama(map_id)
  if @panorama_settings.has_key?(map_id)
   if @panorama_settings[map_id].is_a?(String)
    $game_map.panorama_name = @panorama_settings[map_id]
   elsif @panorama_settings[map_id].is_a?(Array)
    if @panorama_settings[map_id].size >= 1 &&
    @panorama_settings[map_id].is_a?(String)
     $game_map.panorama_name = @panorama_settings[map_id][0]
     if @panorama_settings[map_id].size >= 2 &&
     @panorama_settings[map_id].is_a?(Numeric)
      $game_map.panorama_hue = @panorama_settings[map_id][1]
     end
    end
   end
  end
 end
 #-----------------------------------------------------------------------------
 # * Game_Map::AutoSetup.setup_battleback
 #-----------------------------------------------------------------------------
 def self.setup_battleback(map_id)
  if @battleback_settings.has_key?(map_id)
   if @battleback_settings[map_id].is_a?(String)
    $game_map.battleback_name = @battleback_settings[map_id]
    $game_temp.battleback_name = @battleback_settings[map_id]
   end
  end
 end
 #-----------------------------------------------------------------------------
 # * Game_Map::AutoSetup.setup_call_scripts
 #-----------------------------------------------------------------------------
 def self.setup_call_scripts(map_id)
  if @call_scripts.has_key?(map_id)
   if @call_scripts[map_id].is_a?(String)
    eval @call_scripts[map_id]
   elsif @call_scripts[map_id].is_a?(Array)
    @call_scripts[map_id].each do |script|
     eval script
    end
   end
  end
 end
end
Â
#===============================================================================
# ** Game_Map
#===============================================================================
Â
class Game_Map
 #-----------------------------------------------------------------------------
 # * Public Instance Variables
 #-----------------------------------------------------------------------------
 attr_accessor :fog_ox
 attr_accessor :fog_oy
 attr_accessor :fog_tone
 #-----------------------------------------------------------------------------
 # * Alias Listings
 #-----------------------------------------------------------------------------
 alias_method :auto_settings_game_map_setup, :setup
 #-----------------------------------------------------------------------------
 # * Setup
 #-----------------------------------------------------------------------------
 def setup(map_id)
  auto_settings_game_map_setup(map_id)
  AutoSetup.pre_setup(map_id)
  AutoSetup.setup_menu_access(map_id)
  AutoSetup.setup_save_access(map_id)
  AutoSetup.setup_switches(map_id)
  AutoSetup.setup_variables(map_id)
  AutoSetup.setup_self_switches(map_id)
  AutoSetup.setup_screen_tone(map_id)
  AutoSetup.setup_weather_effects(map_id)
  AutoSetup.setup_player_settings(map_id)
  AutoSetup.setup_event_settings(map_id)
  AutoSetup.setup_fog_settings(map_id)
  AutoSetup.setup_fog_tone(map_id)
  AutoSetup.setup_fog_opacity(map_id)
  AutoSetup.setup_battleback(map_id)
  AutoSetup.setup_call_scripts(map_id)
 end
end
Â
#===============================================================================
# ** Game_Character
#===============================================================================
Â
class Game_Character
 #-----------------------------------------------------------------------------
 # * Public Instance @variables
 #-----------------------------------------------------------------------------
 attr_accessor :move_speed
 attr_accessor :move_frequency
 attr_accessor :walk_anime
 attr_accessor :step_anime
 attr_accessor :through
 attr_accessor :direction_fix
 attr_accessor :always_on_top
end
Â
#===============================================================================
# ** Interpreter
#===============================================================================
Â
class Interpreter
 #-----------------------------------------------------------------------------
 # * Included Modules
 #-----------------------------------------------------------------------------
 include Game_Map::AutoSetup
end
Â
#-------------------------------------------------------------------------------
# * SDK Enabled Test : END
#-------------------------------------------------------------------------------
end
Instructions
Alot of the instructions are in the script, and the first few options are pre-setup as an example (using map 1 as an example, in the script).
Incase the instructions/example setup (in the script) are still too vauge, or you just need help on working a hash then please feel free to ask and I'll show you an example of how to do whatever you're trying to do with this.
Compatibility
Should be compatible with most anything, not sure if this script will work for VX.
Author's Notes
If I find time, I'll be adding some Interpreter commands so you can easily change AutoSetup settings via Call Script in events in your game, instead of being stuck trying to perfect settings through the RGSS Editor.
Terms and Conditions
Free to use in any commercial/non-commercial game, please credit me though if you use this.