Jump to content
Rpg²S Forum
  • 0

Modifica Script WorldMap


nickk.c
 Share

Question

Ciao a tutti, vorrei chiedere se è possibile modificare questo script in modo tale da poter cambiare durante il gioco sia l'immagine della mappa del mondo che il BGM. Grazie in anticipo :D

=begin
--------------------------------------------------------------------------------
 DNI IMAGE WORLD MAP SYSTEM
 Author: DaiNekoIchi (Dai Ichi)
 Site: http://dainekoichi.blogspot.com/
 Version: 1.0
 
 Please give credit if used~!
--------------------------------------------------------------------------------
 Updates:
  2015.10.13 - V1.0
  2015.10.11 - Started script
--------------------------------------------------------------------------------
 Introduction:
  This script recreates a world map system that uses an image file. Users can
  define locations(map points). This also features a 'fast travel' menu for
  those who feel that moving around with a cursor is dragging and boring.
--------------------------------------------------------------------------------
 Instructions:
  From RPG Maker VX Ace...
  1.) Press F11 or Tools -> Script Editor...
  2.) Copy/paste this script to an open slot blow ▼ Materials and above ▼ Main
  3.) Save.
--------------------------------------------------------------------------------
 Usage Ingame:
  - When the scene is called, press the directional keys to move around.
  - For fast travel (if enabled), press A (Shift)
--------------------------------------------------------------------------------
 Script Calls:
  - To call the World Map scene, use the following script:
    > call_worldmap('location_name')
    ...replace location_name with the actual location name (from the map points)
    
  - To unlock/enable/disable a location, use the following scripts:
    > unlock_location('location_name')
    > enable_location('location_name')
    > disable_location('location_name')
    Optionally, you can unlock a location in a disabled state:
    > unlock_location('location_name',false)

  - You can also check if a location is unlocked or enabled:
    > location_unlocked?('location_name')
    > location_enabled?('location_name')
    
  - To change the World Map picutre, use the following script:
    > change_world_map_image("picture")
--------------------------------------------------------------------------------
 Compatibility:
  This should be compatible with almost all other scripts. Contact me if there
  are any problems.
--------------------------------------------------------------------------------
 Terms and Conditions:
  This script cannot be reposted in other places without permission.
  Give credit if this script is used in your game.
  Free for non-commercial use. NOT YET AVAILABLE for commercial use.
--------------------------------------------------------------------------------
=end

$imported = {} if $imported.nil?
$imported["Dai-WorldMap"] = true

#===============================================================================
# [CONFIG START] LET THE CONFIGURATION BEGIN!
#===============================================================================
#$current_world_map_image = DAI::WORLDMAP::MAP_IMAGE
module DAI
  module WORLDMAP
    #---------------------------------------------------------------------------
    # CURSOR_IMAGE: The image file of the cursor
    # CURSOR_ORIGIN: The point of origin of your cursor image [x,y]
    # CURSOR_SPEED: Self-explanatory
    # CURSOR_MARGIN: Margin of the cursor so that it wouldn't reach the edge of
    #                the screen.
    #---------------------------------------------------------------------------
    CURSOR_IMAGE = 'WM_Cursor'
    CURSOR_ORIGIN = [0,23]
    CURSOR_SPEED = 5
    CURSOR_MARGIN = 0
    #---------------------------------------------------------------------------
    # LOCDISP_ENABLED: Show the name of the location when hovering into one?
    # LOCDISP_OFFSET: Offset of the location name when displayed [x,y]
    #---------------------------------------------------------------------------
    LOCDISP_ENABLED = true
    LOCDISP_OFFSET = [0,12]
    #---------------------------------------------------------------------------
    # GOTOLOC_TEXT: Text that will be shown when confirming entry to location.
    # GOTOLOC_YES: "Yes" command text
    # GOTOLOC_NO: "No" command text
    #---------------------------------------------------------------------------
    GOTOLOC_TEXT = '%s'
    GOTOLOC_YES = 'Go'
    GOTOLOC_NO = 'Cancel'
    #---------------------------------------------------------------------------
    # FT_ENABLED: Allow Fast Travel menu?
    # FT_LABEL: Fast Travel label text shown above the menu
    # FT_LABEL_ALIGNMENT: The alignment of the FT label
    # FT_OPTIONS_ALIGNMENT: The alignment of the FT options
    #---------------------------------------------------------------------------
    FT_ENABLED = true
    FT_LABEL = 'Fast Travel'
    FT_LABEL_ALIGNMENT = 0
    FT_OPTIONS_ALIGNMENT = 1
    #---------------------------------------------------------------------------
    # BGM_ENABLED: Play BGM while in the World Map?
    # BGM_PROPERTIES: Properties of the BGM [Filename,Volume,Pitch]
    #---------------------------------------------------------------------------
    BGM_ENABLED = true
    BGM_PROPERTIES = ['Theme1',70,100]
    #---------------------------------------------------------------------------
    # MAP_DEFAULT_X: Default X coordinate of a map when from an unknown location
    # MAP_DEFAULT_Y: Same as above but for Y coordinate
    # MAP_IMAGE: Image file of the map
    # MAP_SCROLL_SPEED: The scroll speed of the map when the cursor reaches
    #                   the margin.
    #---------------------------------------------------------------------------
    MAP_DEFAULT_X = Graphics.width / 2
    MAP_DEFAULT_Y = Graphics.height / 2
    MAP_IMAGE = "Picture"
    MAP_SCROLL_SPEED = 5
    #---------------------------------------------------------------------------
    # Here is where Map Points (locations) are configured.
    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    # :name => self-explanatory
    # :map_x => X coord of the location on the map
    # :map_y => Y coord of the location on the map
    # :map_icon_index => Index of the icon that will be shown in the map
    # :transfer_mapid => Map ID of where the player will be transfered to
    # :transfer_x => X coordinate of where the player will be transfered to
    # :transfer_y => Same as above but for Y coordinate
    # :transfer_f => Where the player will face when transfered
    #                (NumPad style, 2 for down, 4 for left, etc.)
    # :default => Is the location unlocked at the beginning?
    #---------------------------------------------------------------------------
    MAP_POINTS = [] # Do not delete!
    MAP_POINTS.push({:name=>'Name',
       :map_x => 439,
       :map_y => 224,
       :map_icon_index => 1508,
       :transfer_mapid => 1,
       :transfer_x => 8,
       :transfer_y => 6,
       :transfer_f => 2,
       :default => false});
#===============================================================================
# [CONFIG END]
#-------------------------------------------------------------------------------
# [WARNING]
# Do NOT, and I repeat, do NOT edit anything below this part unless you know
# what you're doing. I won't be responsible if your computer blows up just
# because you tinkered with some code and made impossibly fatal errors.
#===============================================================================
  end
end

module Sound
  def self.play_bgm_worldmap
    props = DAI::WORLDMAP::BGM_PROPERTIES
    Audio.bgm_play('Audio/BGM/' + props[0],props[1],props[2])
  end
end

class Game_Temp
  
  attr_reader :iwm_location
  
  alias_method :dni_iwm_init, :initialize
  
  def initialize
    dni_iwm_init
    @iwm_location = ''
  end
  
  def set_iwm_location(locname)
    @iwm_location = locname
  end
  
  def get_iwm_location
    @iwm_location
  end
  
end

class Game_Party
  
  attr_accessor :locations
  
  alias_method :dni_iwm_init, :initialize
  def initialize
    dni_iwm_init
    @locations = Hash.new
    for loc in DAI::WORLDMAP::MAP_POINTS
      @locations[loc[:name]] = true if loc[:default] == true
    end
  end
  
end

class Game_Interpreter
  
  def fadeout_all(time = 1000)
    #RPG::BGM.fade(time)
    RPG::BGS.fade(time)
    RPG::ME.fade(time)
    Graphics.fadeout(time * Graphics.frame_rate / 1000)
    RPG::BGM.stop
    RPG::BGS.stop
    RPG::ME.stop
  end
  
  def call_worldmap(locname='')
    $game_temp.set_iwm_location(locname)
    fadeout_all
    SceneManager.call(Scene_WorldMap)
  end
  
  def unlock_location(locname,enabled=true)
    for loc in DAI::WORLDMAP::MAP_POINTS
      if loc[:name] == locname
        $game_party.locations[locname] = enabled
        return
      end
    end
  end
  
  def enable_location(locname)
    if $game_party.locations.keys.include?(locname)
      $game_party.locations[locname] = true
      
    end
  end
  
  def disable_location(locname)
    if $game_party.locations.keys.include?(locname)
      $game_party.locations[locname] = false
    end
  end
  
  def location_unlocked?(locname)
    $game_party.locations.keys.include?(locname)
  end
  
  def location_enabled?(locname)
    if $game_party.locations.keys.include?(locname)
      $game_party.locations[locname]
    end
    false
  end
  
end

class Window_WorldMapFTLabel < Window_Base
  def initialize
    x = Graphics.width - 250
    y = 0
    width = 250
    height = fitting_height(1)
    super(x,y,width,height)
    self.openness = 0
    refresh
  end
  
  def alignment
    DAI::WORLDMAP::FT_LABEL_ALIGNMENT
  end
  
  def refresh
    contents.clear
    draw_text(0,0,contents.width,line_height,DAI::WORLDMAP::FT_LABEL,alignment)
  end
  
end

class Window_WorldMapFTCmd < Window_Command
  
  def initialize(x,y)
    super
    deactivate
    self.openness = 0
  end
  
  def window_width
    250
  end
  
  def alignment
    DAI::WORLDMAP::FT_OPTIONS_ALIGNMENT
  end
  
  def window_height
    Graphics.height - fitting_height(1)
  end
  
  def make_command_list
    for location in $game_party.locations.keys.sort
      add_command(location,nil)
    end
  end
  
end


class Window_WorldMapConfirmCmd < Window_HorzCommand
  
  def initialize
    x = (Graphics.width - window_width)/2
    y = (Graphics.height - window_height)/2 + fitting_height(1)/2
    super(x,y)
    deactivate
    self.openness = 0
  end
  
  def window_width
     return Graphics.width * 2 / 3
  end
  
  def col_max
    return 2
  end
  
  def make_command_list
    add_command(DAI::WORLDMAP::GOTOLOC_YES,:enter)
    add_command(DAI::WORLDMAP::GOTOLOC_NO,:exit)
  end
  
end

class Window_WorldMapConfirmMsg < Window_Base
  
  def initialize
    width = Graphics.width * 2 / 3
    height = fitting_height(1)
    x = (Graphics.width - width) / 2
    y = (Graphics.height - height) / 2 - fitting_height(1)/2
    super(x,y,width,height)
    self.openness = 0
  end
  
  def open(locname='')
    super()
    @locname = locname
    refresh
  end
  
  def refresh
    contents.clear
    text = sprintf(DAI::WORLDMAP::GOTOLOC_TEXT,@locname)
    draw_text(0,0,contents.width,line_height,text,1)
  end
  
end

class Scene_WorldMap < Scene_Base
    
  def draw_icon(icon_index, x, y, enabled=true)
    sprite = Sprite.new
    sprite.bitmap = Bitmap.new(24,24)
    bitmap = Cache.system("Iconset")
    rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
    sprite.bitmap.blt(0, 0, bitmap, rect, enabled ? 255 : 160)
    sprite.ox = 11
    sprite.oy = 11
    sprite.x = x
    sprite.y = y
    sprite.viewport = @map_viewport
    return sprite
  end
  
  def start
    super
    Sound.play_bgm_worldmap if DAI::WORLDMAP::BGM_ENABLED
    @mode = 'map'
    make_map
    make_locations
    make_locdisp
    make_cursor
    make_confirm_windows
    make_ft_windows
    loc = get_location_item($game_temp.get_iwm_location)
    cursor_to_location(loc) if loc != nil
  end
  
  def update
    super
    bool1 = Input.dir8 != 0 && @mode == 'map'
    bool2 = get_cursor_hor_edge != 0 || get_cursor_ver_edge != 0
    update_input
    update_map if bool2
    update_cursor if bool1
    update_locdisp if bool1 || bool2
  end
  
  def terminate
    super
    @locdisp.dispose
  end
  
  def get_location_item(locname)
    for location in DAI::WORLDMAP::MAP_POINTS
      return location if location[:name] == locname
    end
    return nil
  end
  
  def cursor_to_location(loc)
    new_ox = loc[:map_x] - Graphics.width / 2
    new_oy = loc[:map_y] - Graphics.height / 2
    @map_viewport.ox = [[0,new_ox].max,@map.width - Graphics.width].min
    @map_viewport.oy = [[0,new_oy].max,@map.height - Graphics.height].min
    @cursor.x = loc[:map_x] - @map_viewport.ox
    @cursor.y = loc[:map_y] - @map_viewport.oy
    update_locdisp
  end
  
  def update_map_ft
    loc = get_location_item(@window_ftcmd.current_data[:name])
    cursor_to_location(loc)
  end
    
  alias_method :dni_iwm_return_scene, :return_scene
  def return_scene
    fadeout_all
    dni_iwm_return_scene
    $game_map.autoplay
  end
  
  def update_input
    if @mode == 'map'
      return_scene if Input.trigger?(:B)
      confirm_location if Input.trigger?(:C)
      ft_mode if Input.trigger?(:A) && DAI::WORLDMAP::FT_ENABLED
      #RPG::SE.new("INT_Ope", 100, 100).play
    elsif @mode == 'ft' && (Input.trigger?(:DOWN) || Input.trigger?(:UP))
      update_map_ft
    end
  end
  
  def ft_mode
    @mode = 'ft'
    @window_ftlab.open
    @window_ftcmd.open
    @window_ftcmd.activate
    update_map_ft
  end
  
  def confirm_location
    if @locname != ''
      if $game_party.locations[@locname] == true
        Sound.play_ok
        @mode = 'confirm'
        @window_confmsg.open(@locname)
        @window_confcmd.open
        @window_confcmd.activate
      else
        Sound.play_buzzer
      end
    end
  end
  
  def update_locdisp
    @locdisp.bitmap.clear
    for location in @map_locations.keys
      orig_x = @map_locations[location].x - @map_viewport.ox
      orig_y = @map_locations[location].y - @map_viewport.oy
      bool1 = (@cursor.x - orig_x).abs <= 12
      bool2 = (@cursor.y - orig_y).abs <= 12
      if bool1 && bool2
        @locname = location
        @locdisp.bitmap.draw_text(0,0,@locdisp.width,24,location,1)
        @locdisp.x = @cursor.x + DAI::WORLDMAP::LOCDISP_OFFSET[0]
        @locdisp.y = @cursor.y + DAI::WORLDMAP::LOCDISP_OFFSET[1]
        return
      end
    end
    @locname = ''
  end
  
  def on_confirmcmd_ok
    loc = get_location_item(@locname)
    $game_player.reserve_transfer(loc[:transfer_mapid], loc[:transfer_x],
    loc[:transfer_y], loc[:transfer_f])
    $game_player.perform_transfer
    return_scene
  end
  
  def on_confirmcmd_cancel
    @window_confmsg.close
    @window_confcmd.close
    @window_confcmd.deactivate
    @mode = 'map'
  end
  
  def on_ftcmd_exit
    @window_ftlab.close
    @window_ftcmd.close
    @window_ftcmd.deactivate
    @mode = 'map'
  end
  
  def update_cursor
    if Input.dir8 != 0
      case Input.dir8
      when 1,4,7
        @cursor.x -= DAI::WORLDMAP::CURSOR_SPEED
      when 3,6,9
        @cursor.x += DAI::WORLDMAP::CURSOR_SPEED
      end
      case Input.dir8
      when 7,8,9
        @cursor.y -= DAI::WORLDMAP::CURSOR_SPEED
      when 1,2,3
        @cursor.y += DAI::WORLDMAP::CURSOR_SPEED
      end
    end
    margin = DAI::WORLDMAP::CURSOR_MARGIN
    @cursor.x = [[margin,@cursor.x].max,Graphics.width - margin].min
    @cursor.y = [[margin,@cursor.y].max,Graphics.height - margin].min
  end
  
  def update_map
    scroll_spd = DAI::WORLDMAP::MAP_SCROLL_SPEED
    case get_cursor_hor_edge
    when -1
      @map_viewport.ox -= scroll_spd
    when 1
      @map_viewport.ox += scroll_spd
    end
    @map_viewport.ox = [[0,@map_viewport.ox].max,@map.width - Graphics.width].min
    case get_cursor_ver_edge
    when -1
      @map_viewport.oy -= scroll_spd
    when 1
      @map_viewport.oy += scroll_spd
    end
    @map_viewport.oy = [[0,@map_viewport.oy].max,@map.height - Graphics.height].min
  end
  
  def get_cursor_hor_edge
    margin = DAI::WORLDMAP::CURSOR_MARGIN
    return -1 if @cursor.x == margin
    return 1 if @cursor.x == Graphics.width - margin
    return 0
  end
  
  def get_cursor_ver_edge
    margin = DAI::WORLDMAP::CURSOR_MARGIN
    return -1 if @cursor.y == margin
    return 1 if @cursor.y == Graphics.height - margin
    return 0
  end
  
  def make_ft_windows
    @window_ftlab = Window_WorldMapFTLabel.new
    x = Graphics.width - 250
    y = @window_ftlab.height
    @window_ftcmd = Window_WorldMapFTCmd.new(x,y)
    @window_ftcmd.set_handler(:ok, method(:on_ftcmd_exit))
    @window_ftcmd.set_handler(:cancel, method(:on_ftcmd_exit))
  end
  
  def make_confirm_windows
    @window_confmsg = Window_WorldMapConfirmMsg.new
    @window_confcmd = Window_WorldMapConfirmCmd.new
    @window_confcmd.set_handler(:enter, method(:on_confirmcmd_ok))
    @window_confcmd.set_handler(:cancel, method(:on_confirmcmd_cancel))
    @window_confcmd.set_handler(:exit, method(:on_confirmcmd_cancel))
  end
  
  def make_locdisp
    @locname = ''
    @locdisp = Sprite.new
    @locdisp.bitmap = Bitmap.new(Graphics.width,24)
    @locdisp.ox = Graphics.width / 2
    @locdisp.oy = 11
    @locdisp.viewport = @interface_viewport
  end
  
  def make_map
    @map = Sprite.new
    @map.bitmap = Cache.picture(DAI::WORLDMAP::MAP_IMAGE)
    @map_viewport = Viewport.new(@map.src_rect)
    @map.viewport = @map_viewport
    @map.z = -2
  end
  
  def make_locations
    @map_locations = Hash.new
    for locname in $game_party.locations.keys
      enabled = $game_party.locations[locname]
      location = get_location_item(locname)
      index = location[:map_icon_index]
      sprite = draw_icon(index,location[:map_x],location[:map_y],enabled)
      @map_locations[location[:name]] = sprite
    end
  end
  
  def make_cursor
    @cursor = Sprite.new
    @cursor.bitmap = Cache.picture(DAI::WORLDMAP::CURSOR_IMAGE)
    @cursor.blend_type = 0
    @cursor.ox = DAI::WORLDMAP::CURSOR_ORIGIN[0]
    @cursor.oy = DAI::WORLDMAP::CURSOR_ORIGIN[1]
    @cursor.x = Graphics.width / 2
    @cursor.y = Graphics.height / 2
    @cursor.z = 0
    @interface_viewport = Viewport.new(0,0,Graphics.width, Graphics.height)
    @cursor.viewport = @interface_viewport
  end
  
end

[/spoiler ]

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 1

 

On 11/3/2024 at 7:59 PM, nickk.c said:

Ciao a tutti, vorrei chiedere se è possibile modificare questo script in modo tale da poter cambiare durante il gioco sia l'immagine della mappa del mondo che il BGM. Grazie in anticipo :D

Ciao,

al momento non posso testare il codice, ma ho preparato una modifica che dovrebbe permetterti di cambiare sia l'immagine della mappa del mondo (World Map) che la musica di sottofondo (BGM) durante il gioco. Fammi sapere se funziona o se riscontri qualche errore.

Spoiler
=begin
--------------------------------------------------------------------------------
 DNI IMAGE WORLD MAP SYSTEM
 Author: DaiNekoIchi (Dai Ichi)
 Site: http://dainekoichi.blogspot.com/
 Version: 1.0
 
 Please give credit if used~!
--------------------------------------------------------------------------------
 Updates:
  2015.10.13 - V1.0
  2015.10.11 - Started script
--------------------------------------------------------------------------------
 Introduction:
  This script recreates a world map system that uses an image file. Users can
  define locations(map points). This also features a 'fast travel' menu for
  those who feel that moving around with a cursor is dragging and boring.
--------------------------------------------------------------------------------
 Instructions:
  From RPG Maker VX Ace...
  1.) Press F11 or Tools -> Script Editor...
  2.) Copy/paste this script to an open slot blow  Materials and above  Main
  3.) Save.
--------------------------------------------------------------------------------
 Usage Ingame:
  - When the scene is called, press the directional keys to move around.
  - For fast travel (if enabled), press A (Shift)
--------------------------------------------------------------------------------
 Script Calls:
  - To call the World Map scene, use the following script:
    > call_worldmap('location_name')
    ...replace location_name with the actual location name (from the map points)
    
  - To unlock/enable/disable a location, use the following scripts:
    > unlock_location('location_name')
    > enable_location('location_name')
    > disable_location('location_name')
    Optionally, you can unlock a location in a disabled state:
    > unlock_location('location_name',false)

  - You can also check if a location is unlocked or enabled:
    > location_unlocked?('location_name')
    > location_enabled?('location_name')
    
  - To change the World Map picutre, use the following script:
    > change_world_map_image("picture")
--------------------------------------------------------------------------------
 Compatibility:
  This should be compatible with almost all other scripts. Contact me if there
  are any problems.
--------------------------------------------------------------------------------
 Terms and Conditions:
  This script cannot be reposted in other places without permission.
  Give credit if this script is used in your game.
  Free for non-commercial use. NOT YET AVAILABLE for commercial use.
--------------------------------------------------------------------------------
=end
$current_world_map = 0
$imported = {} if $imported.nil?
$imported["Dai-WorldMap"] = true

#===============================================================================
# [CONFIG START] LET THE CONFIGURATION BEGIN!
#===============================================================================
module DAI
  module WORLDMAP
    #---------------------------------------------------------------------------
    # CURSOR_IMAGE: The image file of the cursor
    # CURSOR_ORIGIN: The point of origin of your cursor image [x,y]
    # CURSOR_SPEED: Self-explanatory
    # CURSOR_MARGIN: Margin of the cursor so that it wouldn't reach the edge of
    #                the screen.
    #---------------------------------------------------------------------------
    CURSOR_IMAGE = 'WM_Cursor'
    CURSOR_ORIGIN = [0,23]
    CURSOR_SPEED = 5
    CURSOR_MARGIN = 0
    #---------------------------------------------------------------------------
    # LOCDISP_ENABLED: Show the name of the location when hovering into one?
    # LOCDISP_OFFSET: Offset of the location name when displayed [x,y]
    #---------------------------------------------------------------------------
    LOCDISP_ENABLED = true
    LOCDISP_OFFSET = [0,12]
    #---------------------------------------------------------------------------
    # GOTOLOC_TEXT: Text that will be shown when confirming entry to location.
    # GOTOLOC_YES: "Yes" command text
    # GOTOLOC_NO: "No" command text
    #---------------------------------------------------------------------------
    GOTOLOC_TEXT = '%s'
    GOTOLOC_YES = 'Go'
    GOTOLOC_NO = 'Cancel'
    #---------------------------------------------------------------------------
    # FT_ENABLED: Allow Fast Travel menu?
    # FT_LABEL: Fast Travel label text shown above the menu
    # FT_LABEL_ALIGNMENT: The alignment of the FT label
    # FT_OPTIONS_ALIGNMENT: The alignment of the FT options
    #---------------------------------------------------------------------------
    FT_ENABLED = true
    FT_LABEL = 'Fast Travel'
    FT_LABEL_ALIGNMENT = 0
    FT_OPTIONS_ALIGNMENT = 1
    #---------------------------------------------------------------------------
    # MAP_DEFAULT_X: Default X coordinate of a map when from an unknown location
    # MAP_DEFAULT_Y: Same as above but for Y coordinate
    # MAP_SCROLL_SPEED: The scroll speed of the map when the cursor reaches
    #                   the margin.
    #---------------------------------------------------------------------------
    MAP_DEFAULT_X = Graphics.width / 2
    MAP_DEFAULT_Y = Graphics.height / 2
    MAP_SCROLL_SPEED = 5
    #---------------------------------------------------------------------------
    # Here is where Map Points (locations) are configured.
    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    # :name => self-explanatory
    # :map_x => X coord of the location on the map
    # :map_y => Y coord of the location on the map
    # :map_icon_index => Index of the icon that will be shown in the map
    # :transfer_mapid => Map ID of where the player will be transfered to
    # :transfer_x => X coordinate of where the player will be transfered to
    # :transfer_y => Same as above but for Y coordinate
    # :transfer_f => Where the player will face when transfered
    #                (NumPad style, 2 for down, 4 for left, etc.)
    # :default => Is the location unlocked at the beginning?
    #---------------------------------------------------------------------------
    MAPS = [
        # Map 0
        {:map_points => [], :map_image => 'Picture', :bgm_properties => ['Theme1',70,100], :bgm_enable => true},
        # Map 1
        {:map_points => [], :map_image => 'Picture', :bgm_properties => ['Theme1',70,100], :bgm_enable => true},
        # Map 2
        {:map_points => [], :map_image => 'Picture', :bgm_properties => ['Theme1',70,100], :bgm_enable => true},
    ]

    MAPS[0][:map_points].push({:name=>'Name',
        :map_x => 439,
        :map_y => 224,
        :map_icon_index => 1508,
        :transfer_mapid => 1,
        :transfer_x => 8,
        :transfer_y => 6,
        :transfer_f => 2,
        :default => false});
#===============================================================================
# [CONFIG END]
#-------------------------------------------------------------------------------
# [WARNING]
# Do NOT, and I repeat, do NOT edit anything below this part unless you know
# what you're doing. I won't be responsible if your computer blows up just
# because you tinkered with some code and made impossibly fatal errors.
#===============================================================================
  end
end

module Sound
  def self.play_bgm_worldmap
    props = DAI::WORLDMAP::MAPS[$current_world_map][:bgm_properties]
    Audio.bgm_play('Audio/BGM/' + props[0],props[1],props[2])
  end
end

class Game_Temp
  
  attr_reader :iwm_location
  
  alias_method :dni_iwm_init, :initialize
  
  def initialize
    dni_iwm_init
    @iwm_location = ''
  end
  
  def set_iwm_location(locname)
    @iwm_location = locname
  end
  
  def get_iwm_location
    @iwm_location
  end
  
end

class Game_Party
  
  attr_accessor :locations
  
  alias_method :dni_iwm_init, :initialize
  def initialize
    dni_iwm_init
    @locations = Hash.new
    for loc in DAI::WORLDMAP::MAPS[$current_world_map][:map_points]
      @locations[loc[:name]] = true if loc[:default] == true
    end
  end
  
end

class Game_Interpreter
  
  def fadeout_all(time = 1000)
    #RPG::BGM.fade(time)
    RPG::BGS.fade(time)
    RPG::ME.fade(time)
    Graphics.fadeout(time * Graphics.frame_rate / 1000)
    RPG::BGM.stop
    RPG::BGS.stop
    RPG::ME.stop
  end
  
  def call_worldmap(locname='')
    $game_temp.set_iwm_location(locname)
    fadeout_all
    SceneManager.call(Scene_WorldMap)
  end
  
  def unlock_location(locname,enabled=true)
    for loc in DAI::WORLDMAP::MAPS[$current_world_map][:map_points]
      if loc[:name] == locname
        $game_party.locations[locname] = enabled
        return
      end
    end
  end
  
  def enable_location(locname)
    if $game_party.locations.keys.include?(locname)
      $game_party.locations[locname] = true
      
    end
  end
  
  def disable_location(locname)
    if $game_party.locations.keys.include?(locname)
      $game_party.locations[locname] = false
    end
  end
  
  def location_unlocked?(locname)
    $game_party.locations.keys.include?(locname)
  end
  
  def location_enabled?(locname)
    if $game_party.locations.keys.include?(locname)
      $game_party.locations[locname]
    end
    false
  end
  
end

class Window_WorldMapFTLabel < Window_Base
  def initialize
    x = Graphics.width - 250
    y = 0
    width = 250
    height = fitting_height(1)
    super(x,y,width,height)
    self.openness = 0
    refresh
  end
  
  def alignment
    DAI::WORLDMAP::FT_LABEL_ALIGNMENT
  end
  
  def refresh
    contents.clear
    draw_text(0,0,contents.width,line_height,DAI::WORLDMAP::FT_LABEL,alignment)
  end
  
end

class Window_WorldMapFTCmd < Window_Command
  
  def initialize(x,y)
    super
    deactivate
    self.openness = 0
  end
  
  def window_width
    250
  end
  
  def alignment
    DAI::WORLDMAP::FT_OPTIONS_ALIGNMENT
  end
  
  def window_height
    Graphics.height - fitting_height(1)
  end
  
  def make_command_list
    for location in $game_party.locations.keys.sort
      add_command(location,nil)
    end
  end
  
end


class Window_WorldMapConfirmCmd < Window_HorzCommand
  
  def initialize
    x = (Graphics.width - window_width)/2
    y = (Graphics.height - window_height)/2 + fitting_height(1)/2
    super(x,y)
    deactivate
    self.openness = 0
  end
  
  def window_width
     return Graphics.width * 2 / 3
  end
  
  def col_max
    return 2
  end
  
  def make_command_list
    add_command(DAI::WORLDMAP::GOTOLOC_YES,:enter)
    add_command(DAI::WORLDMAP::GOTOLOC_NO,:exit)
  end
  
end

class Window_WorldMapConfirmMsg < Window_Base
  
  def initialize
    width = Graphics.width * 2 / 3
    height = fitting_height(1)
    x = (Graphics.width - width) / 2
    y = (Graphics.height - height) / 2 - fitting_height(1)/2
    super(x,y,width,height)
    self.openness = 0
  end
  
  def open(locname='')
    super()
    @locname = locname
    refresh
  end
  
  def refresh
    contents.clear
    text = sprintf(DAI::WORLDMAP::GOTOLOC_TEXT,@locname)
    draw_text(0,0,contents.width,line_height,text,1)
  end
  
end

class Scene_WorldMap < Scene_Base
    
  def draw_icon(icon_index, x, y, enabled=true)
    sprite = Sprite.new
    sprite.bitmap = Bitmap.new(24,24)
    bitmap = Cache.system("Iconset")
    rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
    sprite.bitmap.blt(0, 0, bitmap, rect, enabled ? 255 : 160)
    sprite.ox = 11
    sprite.oy = 11
    sprite.x = x
    sprite.y = y
    sprite.viewport = @map_viewport
    return sprite
  end
  
  def start
    super
    Sound.play_bgm_worldmap if DAI::WORLDMAP::MAPS[$current_world_map][:bgm_enabled]
    @mode = 'map'
    make_map
    make_locations
    make_locdisp
    make_cursor
    make_confirm_windows
    make_ft_windows
    loc = get_location_item($game_temp.get_iwm_location)
    cursor_to_location(loc) if loc != nil
  end
  
  def update
    super
    bool1 = Input.dir8 != 0 && @mode == 'map'
    bool2 = get_cursor_hor_edge != 0 || get_cursor_ver_edge != 0
    update_input
    update_map if bool2
    update_cursor if bool1
    update_locdisp if bool1 || bool2
  end
  
  def terminate
    super
    @locdisp.dispose
  end
  
  def get_location_item(locname)
    for location in DAI::WORLDMAP::MAPS[$current_world_map][:map_points]
      return location if location[:name] == locname
    end
    return nil
  end
  
  def cursor_to_location(loc)
    new_ox = loc[:map_x] - Graphics.width / 2
    new_oy = loc[:map_y] - Graphics.height / 2
    @map_viewport.ox = [[0,new_ox].max,@map.width - Graphics.width].min
    @map_viewport.oy = [[0,new_oy].max,@map.height - Graphics.height].min
    @cursor.x = loc[:map_x] - @map_viewport.ox
    @cursor.y = loc[:map_y] - @map_viewport.oy
    update_locdisp
  end
  
  def update_map_ft
    loc = get_location_item(@window_ftcmd.current_data[:name])
    cursor_to_location(loc)
  end
    
  alias_method :dni_iwm_return_scene, :return_scene
  def return_scene
    fadeout_all
    dni_iwm_return_scene
    $game_map.autoplay
  end
  
  def update_input
    if @mode == 'map'
      return_scene if Input.trigger?(:B)
      confirm_location if Input.trigger?(:C)
      ft_mode if Input.trigger?(:A) && DAI::WORLDMAP::FT_ENABLED
      #RPG::SE.new("INT_Ope", 100, 100).play
    elsif @mode == 'ft' && (Input.trigger?(:DOWN) || Input.trigger?(:UP))
      update_map_ft
    end
  end
  
  def ft_mode
    @mode = 'ft'
    @window_ftlab.open
    @window_ftcmd.open
    @window_ftcmd.activate
    update_map_ft
  end
  
  def confirm_location
    if @locname != ''
      if $game_party.locations[@locname] == true
        Sound.play_ok
        @mode = 'confirm'
        @window_confmsg.open(@locname)
        @window_confcmd.open
        @window_confcmd.activate
      else
        Sound.play_buzzer
      end
    end
  end
  
  def update_locdisp
    @locdisp.bitmap.clear
    for location in @map_locations.keys
      orig_x = @map_locations[location].x - @map_viewport.ox
      orig_y = @map_locations[location].y - @map_viewport.oy
      bool1 = (@cursor.x - orig_x).abs <= 12
      bool2 = (@cursor.y - orig_y).abs <= 12
      if bool1 && bool2
        @locname = location
        @locdisp.bitmap.draw_text(0,0,@locdisp.width,24,location,1)
        @locdisp.x = @cursor.x + DAI::WORLDMAP::LOCDISP_OFFSET[0]
        @locdisp.y = @cursor.y + DAI::WORLDMAP::LOCDISP_OFFSET[1]
        return
      end
    end
    @locname = ''
  end
  
  def on_confirmcmd_ok
    loc = get_location_item(@locname)
    $game_player.reserve_transfer(loc[:transfer_mapid], loc[:transfer_x],
    loc[:transfer_y], loc[:transfer_f])
    $game_player.perform_transfer
    return_scene
  end
  
  def on_confirmcmd_cancel
    @window_confmsg.close
    @window_confcmd.close
    @window_confcmd.deactivate
    @mode = 'map'
  end
  
  def on_ftcmd_exit
    @window_ftlab.close
    @window_ftcmd.close
    @window_ftcmd.deactivate
    @mode = 'map'
  end
  
  def update_cursor
    if Input.dir8 != 0
      case Input.dir8
      when 1,4,7
        @cursor.x -= DAI::WORLDMAP::CURSOR_SPEED
      when 3,6,9
        @cursor.x += DAI::WORLDMAP::CURSOR_SPEED
      end
      case Input.dir8
      when 7,8,9
        @cursor.y -= DAI::WORLDMAP::CURSOR_SPEED
      when 1,2,3
        @cursor.y += DAI::WORLDMAP::CURSOR_SPEED
      end
    end
    margin = DAI::WORLDMAP::CURSOR_MARGIN
    @cursor.x = [[margin,@cursor.x].max,Graphics.width - margin].min
    @cursor.y = [[margin,@cursor.y].max,Graphics.height - margin].min
  end
  
  def update_map
    scroll_spd = DAI::WORLDMAP::MAP_SCROLL_SPEED
    case get_cursor_hor_edge
    when -1
      @map_viewport.ox -= scroll_spd
    when 1
      @map_viewport.ox += scroll_spd
    end
    @map_viewport.ox = [[0,@map_viewport.ox].max,@map.width - Graphics.width].min
    case get_cursor_ver_edge
    when -1
      @map_viewport.oy -= scroll_spd
    when 1
      @map_viewport.oy += scroll_spd
    end
    @map_viewport.oy = [[0,@map_viewport.oy].max,@map.height - Graphics.height].min
  end
  
  def get_cursor_hor_edge
    margin = DAI::WORLDMAP::CURSOR_MARGIN
    return -1 if @cursor.x == margin
    return 1 if @cursor.x == Graphics.width - margin
    return 0
  end
  
  def get_cursor_ver_edge
    margin = DAI::WORLDMAP::CURSOR_MARGIN
    return -1 if @cursor.y == margin
    return 1 if @cursor.y == Graphics.height - margin
    return 0
  end
  
  def make_ft_windows
    @window_ftlab = Window_WorldMapFTLabel.new
    x = Graphics.width - 250
    y = @window_ftlab.height
    @window_ftcmd = Window_WorldMapFTCmd.new(x,y)
    @window_ftcmd.set_handler(:ok, method(:on_ftcmd_exit))
    @window_ftcmd.set_handler(:cancel, method(:on_ftcmd_exit))
  end
  
  def make_confirm_windows
    @window_confmsg = Window_WorldMapConfirmMsg.new
    @window_confcmd = Window_WorldMapConfirmCmd.new
    @window_confcmd.set_handler(:enter, method(:on_confirmcmd_ok))
    @window_confcmd.set_handler(:cancel, method(:on_confirmcmd_cancel))
    @window_confcmd.set_handler(:exit, method(:on_confirmcmd_cancel))
  end
  
  def make_locdisp
    @locname = ''
    @locdisp = Sprite.new
    @locdisp.bitmap = Bitmap.new(Graphics.width,24)
    @locdisp.ox = Graphics.width / 2
    @locdisp.oy = 11
    @locdisp.viewport = @interface_viewport
  end
  
  def make_map
    @map = Sprite.new
    @map.bitmap = Cache.picture(DAI::WORLDMAP::MAPS[$current_world_map][:map_image])
    @map_viewport = Viewport.new(@map.src_rect)
    @map.viewport = @map_viewport
    @map.z = -2
  end
  
  def make_locations
    @map_locations = Hash.new
    for locname in $game_party.locations.keys
      enabled = $game_party.locations[locname]
      location = get_location_item(locname)
      index = location[:map_icon_index]
      sprite = draw_icon(index,location[:map_x],location[:map_y],enabled)
      @map_locations[location[:name]] = sprite
    end
  end
  
  def make_cursor
    @cursor = Sprite.new
    @cursor.bitmap = Cache.picture(DAI::WORLDMAP::CURSOR_IMAGE)
    @cursor.blend_type = 0
    @cursor.ox = DAI::WORLDMAP::CURSOR_ORIGIN[0]
    @cursor.oy = DAI::WORLDMAP::CURSOR_ORIGIN[1]
    @cursor.x = Graphics.width / 2
    @cursor.y = Graphics.height / 2
    @cursor.z = 0
    @interface_viewport = Viewport.new(0,0,Graphics.width, Graphics.height)
    @cursor.viewport = @interface_viewport
  end
  
end

 

Non ho scritto commenti ma per creare le mappe devi agire qui:

MAPS = [
        # Map 0
        {:map_points => [], :map_image => 'Picture', :bgm_properties => ['Theme1',70,100], :bgm_enable => true},
        # Map 1
        {:map_points => [], :map_image => 'Picture', :bgm_properties => ['Theme1',70,100], :bgm_enable => true},
        # Map 2
        {:map_points => [], :map_image => 'Picture', :bgm_properties => ['Theme1',70,100], :bgm_enable => true},
    ]

    MAPS[0][:map_points].push({:name=>'Name',
        :map_x => 439,
        :map_y => 224,
        :map_icon_index => 1508,
        :transfer_mapid => 1,
        :transfer_x => 8,
        :transfer_y => 6,
        :transfer_f => 2,
        :default => false});

Nel blocco chiamato MAPS, inserisci le informazioni relative alla tue mappa, come ad esempio l'immagine della mappa o la musica di sottofondo. Lascia vuoto map_points. Se vuoi aggiungere nuovi punti alla mappa, basta copiare e modificare la seconda riga di codice, cambiando i dettagli in base a quello che ti serve. Ricorda che il numero che vedi davanti a ogni mappa (ad esempio MAPS[0], MAPS[1], ecc.) indica quale mappa stai modificando.

Per scegliere quale mappa visualizzare crea uno script in un evento e scrivi:

$current_world_map = INDICE_DELLA_MAPPA

Ad esempio $current_world_map = 0 se vuoi impostare la mappa 0.

 

 

http://wwwdonnemanagernapoli.files.wordpress.com/2013/03/napoli-calcio.jpg

 

Link to comment
Share on other sites

  • 1

Mmm... Ho dato un'occhiata allo script ma al momento non riesco a vedere l'errore. Ti do una bella checklist di controlli che puoi fare:

  • Controlla che il file abbia estensione .ogg (scaricare un file bgm.mp3 e rinominarlo in bgm.ogg non è una conversione)
  • Controlla se RPG Maker riproduce in modo corretto l'audio dalla GUI. Prova ad esempio a mettere quel bgm che vuoi suonare nel menù in una mappa
  • Controlla se hai scritto bene il nome del file (ma credo di sì perché sono abbastanza sicuro che altrimenti crasherebbe)

Se nessuno dei metodi funziona prova a cerca questa linea:

Sound.play_bgm_worldmap if DAI::WORLDMAP::BGM_ENABLED

E sostituiscila con

Sound.play_bgm_worldmap

EDIT: Se ancora non dovesse funzionare cerchiamo di debuggare insieme

Edited by raffy2010
misspell

 

 

http://wwwdonnemanagernapoli.files.wordpress.com/2013/03/napoli-calcio.jpg

 

Link to comment
Share on other sites

  • 1

Con la modifica che ho fatto i bgm sono sempre abilitati, quindi puoi anche evitare di di scrivere ad ogni riga

:bgm_enable => true
Edited by raffy2010

 

 

http://wwwdonnemanagernapoli.files.wordpress.com/2013/03/napoli-calcio.jpg

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...