chaochao 发表于 2005-6-3 04:21:49

chaochao的地图加强ver1.1(6月16日更新)[rm xp rgss]

现在的功能:
1,地图事件保存,更换地图时保存现在地图上事件的数据(比如事件位置等等)。主要是为了方便游戏的制作。
举个例子:不需要在重新进入地图的时候用变量开关等等来设置此地图上事件的位置了。
重新进入地图的话事件的数据是从地图文件上取得的,所以如果想在进入地图的时候改变事件位置就需要一些很麻烦的设置。
2,按照地图坐标移动屏幕。事件里是按照距离和方向来来移动,我的是按照坐标来移动。
V1.0

V1.1
论坛上传出问题,就写出来吧,使用的时候请保留作者信息,谢谢咯。


#==============================================================================
# ■ chaochao的地图加强ver1.1
# 修改了Game_Temp、Game_Event、Game_Map、Scene_Map
# 功能:
# 1,地图事件保存,更换地图时保存现在地图上事件的数据(比如事件位置等等)。
# (特性:方便游戏制作。)
# 提醒:可能您会不习惯这种特性。
# 2,按照地图坐标移动屏幕。事件里是按照距离和方向来来移动,我的是按照坐标来移动。
# 使用方法:$game_map.chaochaoc(x,y,s)
# x,y是地图坐标,s是速度,1到6之间,越大移动越快。
#------------------------------------------------------------------------------
# 作者:chaochao
#http://zhuchao.go1.icpcn.com
#
#==============================================================================
class Game_Temp
attr_accessor :map_bgm
attr_accessor :message_text
attr_accessor :message_proc
attr_accessor :choice_start
attr_accessor :choice_max
attr_accessor :choice_cancel_type
attr_accessor :choice_proc
attr_accessor :num_input_start
attr_accessor :num_input_variable_id
attr_accessor :num_input_digits_max
attr_accessor :message_window_showing
attr_accessor :common_event_id
attr_accessor :in_battle
attr_accessor :battle_calling
attr_accessor :battle_troop_id
attr_accessor :battle_can_escape
attr_accessor :battle_can_lose
attr_accessor :battle_proc
attr_accessor :battle_turn
attr_accessor :battle_event_flags
attr_accessor :battle_abort
attr_accessor :battle_main_phase
attr_accessor :battleback_name
attr_accessor :forcing_battler
attr_accessor :shop_calling
attr_accessor :shop_goods
attr_accessor :name_calling
attr_accessor :name_actor_id
attr_accessor :name_max_char
attr_accessor :menu_calling
attr_accessor :menu_beep
attr_accessor :save_calling
attr_accessor :debug_calling
attr_accessor :player_transferring
attr_accessor :player_new_map_id
attr_accessor :player_new_x
attr_accessor :player_new_y
attr_accessor :player_new_direction
attr_accessor :transition_processing
attr_accessor :transition_name
attr_accessor :gameover
attr_accessor :to_title
attr_accessor :last_file_index
attr_accessor :debug_top_row
attr_accessor :debug_index
#下面是修改的部分
attr_accessor :chaochaoevents
#上面是修改的部分
def initialize
    @map_bgm = nil
    @message_text = nil
    @message_proc = nil
    @choice_start = 99
    @choice_max = 0
    @choice_cancel_type = 0
    @choice_proc = nil
    @num_input_start = 99
    @num_input_variable_id = 0
    @num_input_digits_max = 0
    @message_window_showing = false
    @common_event_id = 0
    @in_battle = false
    @battle_calling = false
    @battle_troop_id = 0
    @battle_can_escape = false
    @battle_can_lose = false
    @battle_proc = nil
    @battle_turn = 0
    @battle_event_flags = {}
    @battle_abort = false
    @battle_main_phase = false
    @battleback_name = ''
    @forcing_battler = nil
    @shop_calling = false
    @shop_id = 0
    @name_calling = false
    @name_actor_id = 0
    @name_max_char = 0
    @menu_calling = false
    @menu_beep = false
    @save_calling = false
    @debug_calling = false
    @player_transferring = false
    @player_new_map_id = 0
    @player_new_x = 0
    @player_new_y = 0
    @player_new_direction = 0
    @transition_processing = false
    @transition_name = ""
    @gameover = false
    @to_title = false
    @last_file_index = 0
    @debug_top_row = 0
    @debug_index = 0
    #下面是修改的部分
    @chaochaoevents = {}
    #上面是修改的部分
end
end
#=========================================================================
class Game_Event < Game_Character
#下面是修改的部分
def erase?
    return @erased
end
def unerase
    @erased = false
    refresh
end
#上面是修改的部分
end
#=========================================================================
class Game_Map
#下面是修改的部分
attr_accessor :chaochaox
attr_accessor :chaochaoy
attr_accessor :chaochaos
def initialize
    @map_id = 0
    @display_x = 0
    @display_y = 0
    @chaochaox = 0
    @chaochaoy = 0
    @chaochaos = 0
end
#移动屏幕用,x,y是地图坐标,s是速度,1到6之间,越大移动越快。
def chaochaoc(x,y,s)
    @chaochaox = x
    @chaochaoy = y
    case s
    when 1
      @chaochaos = 1
    when 2
      @chaochaos = 2
    when 3
      @chaochaos = 4
    when 4
      @chaochaos = 8
    when 5
      @chaochaos = 16
    when 6
      @chaochaos = 32
    end
end
#上面是修改的部分
def setup(map_id)
    @map_id = map_id
    @map = load_data(sprintf("Data/Map%03d.rxdata", @map_id))
    tileset = $data_tilesets[@map.tileset_id]
    @tileset_name = tileset.tileset_name
    @autotile_names = tileset.autotile_names
    @panorama_name = tileset.panorama_name
    @panorama_hue = tileset.panorama_hue
    @fog_name = tileset.fog_name
    @fog_hue = tileset.fog_hue
    @fog_opacity = tileset.fog_opacity
    @fog_blend_type = tileset.fog_blend_type
    @fog_zoom = tileset.fog_zoom
    @fog_sx = tileset.fog_sx
    @fog_sy = tileset.fog_sy
    @battleback_name = tileset.battleback_name
    @passages = tileset.passages
    @priorities = tileset.priorities
    @terrain_tags = tileset.terrain_tags
    @display_x = 0
    @display_y = 0
    @need_refresh = false
    #下面是修改的部分
    if $game_temp.chaochaoevents[@map_id] == nil
      @events = {}
      for i in @map.events.keys
      @events = Game_Event.new(@map_id, @map.events)
      end
    else
      @events = $game_temp.chaochaoevents[@map_id]
      for i in @events.keys
      if @events.erase?
          @events.unerase
      end
      end
    end
    #上面是修改的部分
    @common_events = {}
    for i in 1...$data_common_events.size
      @common_events = Game_CommonEvent.new(i)
    end
    @fog_ox = 0
    @fog_oy = 0
    @fog_tone = Tone.new(0, 0, 0, 0)
    @fog_tone_target = Tone.new(0, 0, 0, 0)
    @fog_tone_duration = 0
    @fog_opacity_duration = 0
    @fog_opacity_target = 0
    @scroll_direction = 2
    @scroll_rest = 0
    @scroll_speed = 4
end
def update
    if $game_map.need_refresh
      refresh
    end
    #下面是修改的部分
    if @scroll_rest > 0 and @chaochaos == 0
    #上面是修改的部分
      distance = 2 ** @scroll_speed
      case @scroll_direction
      when 2
      scroll_down(distance)
      when 4
      scroll_left(distance)
      when 6
      scroll_right(distance)
      when 8
      scroll_up(distance)
      end
      @scroll_rest -= distance
    end
   
    #下面是修改的部分
    if @chaochaos > 0 and @scroll_rest == 0
      max_x = ($game_map.width - 20) * 128
      max_y = ($game_map.height - 15) * 128
      cx = (320 - 16) * 4
      cy = (240 - 16) * 4
      if $game_map.display_x < .min].max
      $game_map.display_x += @chaochaos
      end
      if $game_map.display_x > .min].max
      $game_map.display_x -= @chaochaos
      end
      
      if $game_map.display_y < .min].max
      $game_map.display_y += @chaochaos
      end
      if $game_map.display_y > .min].max
      $game_map.display_y -= @chaochaos
      end
      if $game_map.display_x == .min].max and $game_map.display_y == .min].max
      @chaochaox = 0
      @chaochaoy = 0
      @chaochaos = 0
      end
    end
    #上面是修改的部分
    for event in @events.values
      event.update
    end
    for common_event in @common_events.values
      common_event.update
    end
    @fog_ox -= @fog_sx / 8.0
    @fog_oy -= @fog_sy / 8.0
    if @fog_tone_duration >= 1
      d = @fog_tone_duration
      target = @fog_tone_target
      @fog_tone.red = (@fog_tone.red * (d - 1) + target.red) / d
      @fog_tone.green = (@fog_tone.green * (d - 1) + target.green) / d
      @fog_tone.blue = (@fog_tone.blue * (d - 1) + target.blue) / d
      @fog_tone.gray = (@fog_tone.gray * (d - 1) + target.gray) / d
      @fog_tone_duration -= 1
    end
    if @fog_opacity_duration >= 1
      d = @fog_opacity_duration
      @fog_opacity = (@fog_opacity * (d - 1) + @fog_opacity_target) / d
      @fog_opacity_duration -= 1
    end
end
end
#=========================================================================
class Scene_Map
def transfer_player
    $game_temp.player_transferring = false
    if $game_map.map_id != $game_temp.player_new_map_id
      #下面是修改的部分
      #保存事件
      $game_temp.chaochaoevents[$game_map.map_id] = $game_map.events
      #上面是修改的部分
      $game_map.setup($game_temp.player_new_map_id)
    end
    $game_player.moveto($game_temp.player_new_x, $game_temp.player_new_y)
    case $game_temp.player_new_direction
    when 2
      $game_player.turn_down
    when 4
      $game_player.turn_left
    when 6
      $game_player.turn_right
    when 8
      $game_player.turn_up
    end
    $game_player.straighten
    $game_map.update
    @spriteset.dispose
    @spriteset = Spriteset_Map.new
    if $game_temp.transition_processing
      $game_temp.transition_processing = false
      Graphics.transition(20)
    end
    $game_map.autoplay
    Graphics.frame_reset
    Input.update
end
end
页: [1]
查看完整版本: chaochao的地图加强ver1.1(6月16日更新)[rm xp rgss]