查看: 3311|回复: 8

[已经解决] 还是大地图问题

[复制链接]
梦石
2
星屑
34497
在线时间
614 小时
注册时间
2014-7-18
回帖
647

MZ评测员开拓者

发表于 2014-7-28 20:58:26 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
本帖最后由 VIPArcher 于 2014-7-28 21:11 编辑

我下了“WOR-MAPS V1.4.5 鼠标用户测试”来参考设置大地图,但把脚本复制到我的游戏上时,缺不能显示主角当前位置,这是为什么?以下是我改的脚本:
[pre lang="ruby" line="1"]#————————————————————————————————————————
# ●Wormaps By.Lyaci
#   *世界地图界面
#   *使用说明
#   -呼出界面 SceneManager.call(WMAPSET::Scene_WMAP)
#    界面快捷键默认 A 键
#   -每个地图对应在世界地图的坐标在“地图备注名称”里设置
#    格式 MAP001<MX100,100> 即该地图在MX这个图上显示的坐标 x100 y100
#   -更多请参考范例内容
#   -Ver:1.0 Date:2014.6.25
#   *地图传送
#   -选中后按确认键传送,可以设置总体开关和独立地图的开关
#    总体开关为偷懒用,即打开了 未设置独立开关的地图都可以传送
#    和显示说明一样,在地图备注内设置
#    格式<MOV:X,Y,D,WID> XY对应坐标,D对应朝向(2,4,6,8)->>(下,左,右,上)
#    WID对应独立传送的开关ID
#   -Ver:1.1 Date:2014.6.25PM
#   *重新定义全局传送开关概念
#    修正行走图错位问题
#   -Ver:1.2 Date:2014.6.26
#   *增加自动偏量范围与调试模式
#   -参考坐标变为锁标中心点(CX,CY)
#   -Ver:1.3 Date:2014.6.27
#   *修正参考坐标出现负数问题 & 数据接口优化
#   -Ver:1.3.1 & Ver:1.3.2 Date:2014.6.28
#   *1.4更新
#   -结构优化,文件夹统一化,主、偏量独立范围,增加蒙版响应图(可选)
#    -主量格式追加为:MAP001<MX,X,Y,F> MX=地图文件 XY=显示坐标 F=范围(响应区)
#    *蒙版可以为复杂的地方提供响应,F设置为0就可以不进行默认的范围描绘
#     -蒙版需要在OFLOCK_COLOR设置对应地图ID的范围色
#     -蒙版的文件名为 地图文件名 + _OF 找不到文件即不启用 *更多参考范例里“椰子”
#   -Ver:1.4 Date:2014.7.12
#   *实现无缝连接像素级分辨区域
#   -Ver:1.4.5 Date:2014.7.14
#————————————————————————————————————————
module WMAPSET
  #————————————————————————————————————————
  #●设置
  #————————————————————————————————————————
  MAP_KEY  = :C       #快捷键设置
  MAP_WSET = 1        #禁止/允许打开世界地图开关ID
  MAP_VSET = 100      #设置新的世界地图文件名的变量ID
  MAP_FILE = "世界地图"     #初始的地图文件名
  #————————————————————————————————————————
  ICON_FILE = "micon" #锁标的文件名
  ICON_XY_WIN = true  #辅助坐标窗口是否生成
  LOCKDIS = 5         #锁标每帧移动距离
  CAP_SPEED = 40      #队长行走图更新帧周期
  #Ver1.1—————————————————————————————————————
  MAP_WMOVSET = 100                           #公用地图传送开关ID
  MAP_AMOVSET = 99                            #全局传送开关ID(优先公用与独立开关)
  LOCK_RES = true                             #是否开启呼吸效果
  LOCK_FLASH = true                           #是否开启闪烁效果
  LOCK_FLASH_C1 = Color.new(100,200,255,168)  #闪烁色1
  LOCK_FLASH_C2 = Color.new(255,200,100,168)  #闪烁色2
  LOCK_FLASH_SPEED = 48                       #闪烁周期
  #Ver1.3—————————————————————————————————————
  OFLOCK = 80        #默认主、偏量范围(未手动设置范围即使用该值)
  DEBUG = true        #调试模式(蒙版、主量、偏量范围显示/关闭 F5按键取色)
  LOCKMOV_SOUND_SPEED = 6 #锁标移动声音间隔帧
  #Ver1.4—————————————————————————————————————
  WMAPS_FOLDER = "Graphics/WMAP/" #存放所有资源的文件夹
  #————————————————————————————————————————
  #锁定偏量增加 [地图文件名,X,Y,偏量范围] => 地图ID
  #偏量用于增加响应范围,按范围影响度自行调整
  OFLOCK_XY = {
  #第一张世界地图偏量(只是这个范例的)
  ["世界地图",170,80,20] => 19, #百元镇偏量
  ["世界地图",170,80,20] => 3, #百元大楼偏量
  ["世界地图",170,80,20] => 4, #百元镇偏量
  ["世界地图",170,80,20] => 5, #百元镇偏量
  ["世界地图",170,80,20] => 6, #百元镇偏量
  ["世界地图",170,80,20] => 7, #百元镇偏量
  ["世界地图",170,80,20] => 8, #百元镇偏量
  ["世界地图",170,80,20] => 9, #百元镇偏量
  ["世界地图",170,80,20] => 10, #百元镇偏量
  ["世界地图",170,80,20] => 17, #百元镇偏量
  ["世界地图",170,80,20] => 18, #百元镇偏量
  ["世界地图",170,110,20] => 20, #1号街道偏量
  ["世界地图",380,330] => 3, #神奇洞穴偏量
  ["世界地图",400,350] => 3, #神奇洞穴偏量
  }
  #Ver1.4.5————————————————————————————————————
  #自定义地图对应的范围色 地图ID => 颜色
  #*蒙版用到的范围颜色也在这添加,否则蒙版会不响应
  #*为了方便设置蒙版色,调试模式开启时F5键可以取得当前锁标中心范围色
  OFLOCK_COLOR = {
  19 => Color.new(255,0,0,84),  #百元镇的范围为红色
  }
#————————————————————————————————————————
# ●Scene_WMAP
#   *界面生成
#————————————————————————————————————————
class Scene_WMAP
  #———————————————————————————————————————
  #数据内容
  #———————————————————————————————————————
  def data
    #———————————————————————————————————————
    #常量
    @graphics_w = Graphics.width
    @graphics_h = Graphics.height
    #———————————————————————————————————————
    #生成背景
    map_back
    #———————————————————————————————————————
    #生成地图
    spr_map_ini
    #———————————————————————————————————————
    #生成锁标
    spr_lock_ini
    #———————————————————————————————————————
    #锁标地址数据
    LOCKCOM.com(@map)
    @comx,@comy,@comf,@comi = LOCKCOM.comdata(@map)
    @comofc = LOCKCOM.comofc(@map)
    @comide = LOCKCOM.comide(@map)
    #———————————————————————————————————————
    #生成范围
    spr_of_ini
    #———————————————————————————————————————
    #锁标初始坐标
    lock_xy_ini
    #———————————————————————————————————————
    #生成锁标坐标显示窗口
    win_lockxy_ini
    #生成地图信息显示窗口
    win_mapint_ini
    #———————————————————————————————————————
    #生成队长
    spr_cap_ini
    #———————————————————————————————————————
    update_map_int_yof
  end
  #———————————————————————————————————————
  #主循环
  #———————————————————————————————————————
  def main
    #准备数据
    data
    #执行过渡
    Graphics.transition
    #进行更新
    update until SceneManager.scene != self
    #准备过渡
    Graphics.freeze
    #释放全部
    dispose
  end
  #———————————————————————————————————————
  #主更新
  #———————————————————————————————————————
  def update
    update_GI
    update_input
    update_lock_flash if LOCK_FLASH
    update_lock_zoom if LOCK_RES
  end
  #———————————————————————————————————————
  #画面、输入更新
  #———————————————————————————————————————
  def update_GI
    Graphics.update
    Input.update
    update_cap
  end
  #———————————————————————————————————————
  #数据更新
  #———————————————————————————————————————
  def update_data
    update_lms
    update_oflock
    update_map_int_yof
    refresh_window_lock_xy
  end
  #———————————————————————————————————————
  #按键更新
  #———————————————————————————————————————
  def update_input
    if Input.press?(:DOWN)
      @lock_dy += LOCKDIS ; if @lock_dy <= @graphics_h-@lock_h
      @spr_lock.y += LOCKDIS
      @lock_dy = @lock_y = @spr_lock.y ; lock_mov = true ; end
    end
    if Input.press?(:UP)
      @lock_dy -= LOCKDIS ; if @lock_dy >= 0
      @spr_lock.y -= LOCKDIS
      @lock_dy = @lock_y = @spr_lock.y ; lock_mov = true ; end
    end
    if Input.press?(:LEFT)
      @lock_dx -= LOCKDIS ; if @lock_dx >= 0
      @spr_lock.x -= LOCKDIS
      @lock_dx = @lock_x = @spr_lock.x ; lock_mov = true ; end
    end
    if Input.press?(:RIGHT)
      @lock_dx += LOCKDIS ; if @lock_dx <= @graphics_w-@lock_w
      @spr_lock.x += LOCKDIS
      @lock_dx = @lock_x = @spr_lock.x ; lock_mov = true ; end
    end
    if Input.trigger?(:C)
      map_mov(lock_map_id)
    end
    if Input.trigger?(:B) or Input.trigger?(MAP_KEY)
      SceneManager.return
    end
    if Input.trigger?(:F5) && DEBUG
      p @bit_mapof.get_pixel(@lock_cx,@lock_cy)
    end
    if lock_mov
      update_data
      lock_mov = false
    end
  end
  #———————————————————————————————————————
  #范围更新
  #———————————————————————————————————————
  def update_oflock ; new_cxy
    if @bit_mapof.get_pixel(@lock_cx,@lock_cy).alpha != 0
      @new_map_id = lock_map_id
      if @new_map_id != @now_map_id
        @now_map_id = @new_map_id
        update_lock_xy(@now_map_id)
      end
    else
      @now_map_id = nil ; update_lock_xy(nil)
    end
  end
  #———————————————————————————————————————
  #更新锁标移动声音
  #———————————————————————————————————————
  def update_lms
    @lock_mov_dsc += 1
    if @lock_mov_dsc == LOCKMOV_SOUND_SPEED
    @lock_mov_dsc = 0 ; Sound.play_cursor ; end
  end
  #———————————————————————————————————————
  #锁标地址更新
  #———————————————————————————————————————
  def update_lock_xy(map_id)
    if map_id
      refresh_window_map_int(map_id)
      @wint_clear = false
    else
      unless @wint_clear
        @window_map_int.contents.clear
        @wint_clear = true
      end
    end
  end
  #———————————————————————————————————————
  #地图信息窗口坐标更新
  #———————————————————————————————————————
  def update_map_int_yof
    if @spr_lock.y >= @graphics_h - @lock_h - 96
    @window_map_int.y = 0 ; win_lock_y_set(100) ; else
    @window_map_int.y = @graphics_h - 96 ; win_lock_y_set(240) ; end
  end
  #———————————————————————————————————————
  #更新队长动作
  #———————————————————————————————————————
  def update_cap
    @cap_dsc += 1
    if @cap_dsc == CAP_SPEED ; @cap_index += 1 ; @cap_dsc = 0
    @cap_index = 0 if @cap_index >= 3
    @spr_cap.src_rect.x = @zx+@cw*@cap_index ; end
  end
  #———————————————————————————————————————
  #更新锁标“呼吸”
  #———————————————————————————————————————
  def update_lock_zoom
    if @lock_zoom_mr
      @spr_lock.zoom_x += 0.01 ; @spr_lock.zoom_y += 0.01
      @lock_zoom_mr = false if @spr_lock.zoom_x >= 1.1 ; else
      @spr_lock.zoom_x -= 0.01 ; @spr_lock.zoom_y -= 0.01
      @lock_zoom_mr = true if @spr_lock.zoom_x <= 0.9
    end
  end
  #———————————————————————————————————————
  #更新锁标闪烁
  #———————————————————————————————————————
  def update_lock_flash
    @spr_lock.update ; @lock_flash_dsc += 1
    if @lock_flash_dsc == LOCK_FLASH_SPEED
      @lock_flash_dsc = 0 ; @lock_flash_wb = !@lock_flash_wb
      color = @lock_flash_wb ? LOCK_FLASH_C1 : LOCK_FLASH_C2
      @spr_lock.flash(color,LOCK_FLASH_SPEED)
    end
  end
  #———————————————————————————————————————
  #地图精灵
  #———————————————————————————————————————
  def spr_map_ini
    @spr_map = Sprite.new
    @map = $game_variables[MAP_VSET] == 0 ? MAP_FILE :
    $game_variables[MAP_VSET]
    @map_id = $game_map.instance_variable_get(:@map_id)
    @spr_map.bitmap = Bitmap.new(WMAPS_FOLDER+@map)
  end
  #———————————————————————————————————————
  #锁标精灵
  #———————————————————————————————————————
  def spr_lock_ini
    @spr_lock = Sprite.new
    @spr_lock.bitmap = Bitmap.new(WMAPS_FOLDER+ICON_FILE)
    #锁标变量
    @lock_x = 0 ; @lock_y = 0 ; @lock_dx = 0 ; @lock_dy = 0
    @near_min = [] ; @lock_mov_dsc = 0
    @lock_w = @spr_lock.bitmap.width ; @lock_h = @spr_lock.bitmap.height
    @lock_mw = @lock_w*0.5 ; @lock_mh = @lock_h*0.5
    @lock_flash_dsc = 0 ; @lock_flash_wb = false ; @lock_zoom_mr = true
  end
  #———————————————————————————————————————
  #锁标初始坐标
  #———————————————————————————————————————
  def lock_xy_ini
    lock_xy = LOCKCOM.commxy(@map,@map_id)
    @near_x = lock_xy[0].to_i ; @near_y = lock_xy[1].to_i
    @spr_lock.x = @lock_x = @lock_dx = @near_x - @lock_mw
    @spr_lock.y = @lock_y = @lock_dy = @near_y - @lock_mh ; new_cxy
  end
  #———————————————————————————————————————
  #队长精灵
  #———————————————————————————————————————
  def spr_cap_ini
    #生成队长
    @spr_cap = Sprite.new
    cap = $game_party.members[0]
    cap_name =  cap ? cap.character_name : "雷鸣"
    cap_index = cap ? cap.character_index : 0
    @spr_cap.bitmap = Bitmap.new("Graphics/Characters/"+cap_name)
    cenx = @lock_x + @lock_w*0.16
    ceny = @lock_y + @lock_h*0.16
    @spr_cap.x,@spr_cap.y = cenx,ceny
    #捕捉位置
    @cw = @spr_cap.bitmap.width / 12 ; @ch = @spr_cap.bitmap.height / 8
    @zx = (cap_index%4*3)*@cw ; @zy = (cap_index/4*4)*@ch
    #位图矩形
    @spr_cap.src_rect = Rect.new(@zx, @zy, @cw, @ch)
    #更新数据
    @cap_dsc = 0 ; @cap_index = 0
  end
  #———————————————————————————————————————
  #锁标坐标窗口
  #———————————————————————————————————————
  def win_lockxy_ini
    return unless ICON_XY_WIN
    @window_lock_xy_false = Window_Base.new(0,240,260,78)
    @window_lock_xy_false.opacity = 0
    c1 = Color.new(255,255,255,128)
    c2 = Color.new(255,255,255,0)
    @window_lock_xy_false.contents.gradient_fill_rect(0, 0, 260, 24, c1, c2)
    @window_lock_xy_false.contents.gradient_fill_rect(0, 26, 260, 24, c1, c2)
    @window_lock_xy = Window_Base.new(0,240,260,78)
    @window_lock_xy.opacity = 0
    refresh_window_lock_xy
  end
  #———————————————————————————————————————
  #地图信息窗口
  #———————————————————————————————————————
  def win_mapint_ini
    @window_map_int = Window_Base.new(0,0,@graphics_w,96)
    #更新地图信息
    map_id = lock_map_id
    if map_id
      refresh_window_map_int(map_id)
      @now_map_id = map_id
    else
      @now_map_id = nil
    end
  end
  #———————————————————————————————————————
  #绘制地图信息
  #———————————————————————————————————————
  def refresh_window_map_int(map_id)
    note = LOCKCOM.comnote(map_id)
    /<INF:(.*?)>/ =~ note.gsub(/\n/){"\\n"}
    return unless $1
    Sound.play_recovery
    note = $1.gsub(/\\n/){"\n"}
    @window_map_int.contents.clear
    @window_map_int.draw_text_ex(4,0,note)
  end
  #———————————————————————————————————————
  #绘制锁标地址
  #———————————————————————————————————————
  def refresh_window_lock_xy
    return unless ICON_XY_WIN
    x,y = @lock_x,@lock_y ; cx = @lock_cx ; cy = @lock_cy
    @window_lock_xy.contents.clear
    @window_lock_xy.contents.draw_text(2,0,220,24,"X:#{x} Y:#{y}")
    @window_lock_xy.contents.draw_text(2,24,220,24,"CX:#{cx} CY:#{cy}")
  end
  #———————————————————————————————————————
  #设置坐标位置(Y)
  #———————————————————————————————————————
  def win_lock_y_set(y)
    return unless ICON_XY_WIN
    @window_lock_xy.y = y
    @window_lock_xy_false.y = y
  end
  #———————————————————————————————————————
  #生成背景
  #———————————————————————————————————————
  def map_back
    @map_back = Sprite.new
    @map_back.bitmap = SceneManager.background_bitmap
    @map_back.color.set(16, 16, 16, 128)
  end
  #———————————————————————————————————————
  #处理场景移动
  #———————————————————————————————————————
  def map_mov(map_id)
    return unless map_id
    mov_data = []
    note = LOCKCOM.comnote(map_id)
    /<MOV:(.*?)>/ =~ note
    return Sound.play_buzzer unless $1
    $1.scan(/\d+/) {|xy| mov_data << xy.to_i}
    x,y,d,swi = *mov_data
    swi = swi ? $game_switches[swi] : $game_switches[MAP_WMOVSET]
    if swi && $game_switches[MAP_AMOVSET]
    $game_player.reserve_transfer(map_id, x, y, d)
    $game_player.perform_transfer
    Sound.play_use_skill ; SceneManager.return ; else
    Sound.play_buzzer ; end
  end
  #———————————————————————————————————————
  #获取当前锁定的地图ID
  #———————————————————————————————————————
  def lock_map_id
    @comide[@bit_mapof.get_pixel(@lock_cx,@lock_cy).to_s]
  end
  #———————————————————————————————————————
  #更新锁标中心位置
  #———————————————————————————————————————
  def new_cxy
    @lock_cx = @lock_x + @lock_mw
    @lock_cy = @lock_y + @lock_mh
  end
  #———————————————————————————————————————
  #生成范围
  #———————————————————————————————————————
  def spr_of_ini
    @spr_mapof = Sprite.new
    @spr_mapof.bitmap = Bitmap.new(@graphics_w,@graphics_h)
    @bit_mapof = @spr_mapof.bitmap
    debug(DEBUG)
    of_file = WMAPS_FOLDER+@map+"_OF.png"
    if FileTest.file?(of_file)
      of_bitmap = Bitmap.new(of_file)
      @bit_mapof.blt(0,0,of_bitmap,Rect.new(0,0,@graphics_w,@graphics_h))
      of_bitmap.dispose
    end
    @comx.each_with_index {|x,i|
    f = @comf ; y = @comy ; id = @comi
    color = @comofc[id]
    @bit_mapof.fill_rect(x-f/2,y-f/2,f,f,color)
    if DEBUG
      color = Color.new(color.red,color.green,color.blue)
      @spr_debug.bitmap.fill_rect(x-f/2,y,f,1,color)
      @spr_debug.bitmap.fill_rect(x,y-f/2,1,f,color)
    end }
  end
  #———————————————————————————————————————
  #调试模式
  #———————————————————————————————————————
  def debug(tf)
    if tf
    @spr_debug = Sprite.new
    @spr_debug.bitmap = Bitmap.new(@graphics_w,@graphics_h)
    @spr_lock.bitmap.fill_rect(@lock_mw,@lock_mh,1,1,Color.new(0,0,0,255))
    else ; @spr_mapof.visible = false ; end
  end
  #———————————————————————————————————————
  #释放全部
  #———————————————————————————————————————
  def dispose
    @map_back.bitmap.dispose
    @spr_map.bitmap.dispose
    @spr_lock.bitmap.dispose
    @spr_cap.bitmap.dispose
    @spr_map.dispose ; @spr_lock.dispose
    @spr_cap.dispose ; @map_back.dispose
    @window_map_int.dispose
    @window_lock_xy.dispose if ICON_XY_WIN
    @window_lock_xy_false.dispose if ICON_XY_WIN
    @spr_debug.bitmap.dispose if DEBUG
    @spr_debug.dispose if DEBUG
    @spr_mapof.bitmap.dispose
    @spr_mapof.dispose
  end
end ; end
#———————————————————————————————————————
#●LOCKCOM
#  *处理全部地图锁标的模块
#———————————————————————————————————————
module LOCKCOM
  #———————————————————————————————————————
  #载入偏量地址源
  def self.com_set
    @com = {} ; @rof = {}
    WMAPSET::OFLOCK_XY.each {|key,id|
    com=key[0,3] ; f = key[3] ; rof = f.nil? ? WMAPSET::OFLOCK : f
    @com[com] = id ; @rof[com] = rof } ; @com
  end
  #读取全部主、偏量地址源
  def self.com(map)
    @com ||= LOCKCOM.com_set
    @map ||= Array.new
    unless @map.include?(map) ; @map << map
    $data_mapinfos.each {|id,v|
    /<#{map}(.*?)>/ =~ v.name ; if $1
    cof=[map] ; $1.scan(/\d+/) {|xy| cof << xy.to_i }
    com=cof[0,3] ; f = cof[3] ; rof = f.nil? ? WMAPSET::OFLOCK : f
    @com[com] = id ; @rof[com] = rof ; end } ; end
  end
  #———————————————————————————————————————
  #分析地址源为标准数据
  def self.comdata(map)
    @comxy ||= {}
    @comofc ||= {}
    @comide ||= {}
    unless @comxy.has_key?(map)
    x,y,f,i=[],[],[],[]
    @comofc[map] = {}
    @comide[map] = {}
    oc = WMAPSET::OFLOCK_COLOR
    @com.each {|key,map_id|
    if key[0] == map
      unless @comofc[map][map_id]
        if oc[map_id] ; LOCKCOM.comio_set(map,map_id,oc[map_id])
        else ; LOCKCOM.comio_rc(map,map_id) ; end
      end
      x<<key[1];y<<key[-1];f<<@rof[key];i<<map_id
    end }
    @comxy[map] = [x,y,f,i] ; end ; return *@comxy[map]
  end
  def self.comio_rc(map,map_id)
    loop { color = LOCKCOM.color
    unless @comofc[map].has_value?(color)
    LOCKCOM.comio_set(map,map_id,color) ; break ; end }
  end
  def self.comio_set(map,map_id,color)
    @comide[map][color.to_s] = map_id
    @comofc[map][map_id] = color
  end
  #———————————————————————————————————————
  #读取指定地图主量坐标
  def self.commxy(map,map_id)
    map_id = map_id ; until $1
    /<#{map}(.*?)>/ =~ $data_mapinfos[map_id].name
    map_id = $data_mapinfos[map_id].parent_id unless $1
    break if map_id == 0 ; end ; $1 ? $1.split(",") : 0
  end
  #———————————————————————————————————————
  #读取指定地图的备注
  def self.comnote(map_id)
    @comnote ||= {}
    unless @comnote.has_key?(map_id)
    note = load_data(sprintf("Data/Map%03d.rvdata2", map_id)).note
    @comnote[map_id] = note ; end ; @comnote[map_id]
  end
  #———————————————————————————————————————
  #取得范围色、范围色识别串
  def self.comofc(map)
    @comofc[map]
  end
  def self.comide(map)
    @comide[map]
  end
  def self.color
    Color.new(rand(255),rand(255),rand(255),84)
  end
end
#———————————————————————————————————————
#●Scene_Map
#———————————————————————————————————————
class Scene_Map < Scene_Base
  alias :n_update :update
  def update
    n_update
    if Input.trigger?(WMAPSET::MAP_KEY) ; if $game_switches[WMAPSET::MAP_WSET]
      Sound.play_ok ; SceneManager.call(WMAPSET::Scene_WMAP)
      else ; Sound.play_buzzer ; end
    end
  end
end
[/pre]

点评

代码框使用失败,已编辑。VIPArcher留  发表于 2014-7-28 21:12

…あたしは天

梦石
0
星屑
2308
在线时间
4033 小时
注册时间
2010-10-4
回帖
10548

开拓者贵宾

发表于 2014-7-29 07:52:03 | 显示全部楼层
你是否使用了其他脚本?这种情况要么是少复制了东西,要么是脚本冲突导致的
回复

使用道具 举报

梦石
2
星屑
34497
在线时间
614 小时
注册时间
2014-7-18
回帖
647

MZ评测员开拓者

 楼主| 发表于 2014-7-29 15:13:23 | 显示全部楼层
taroxd 发表于 2014-7-29 07:52
你是否使用了其他脚本?这种情况要么是少复制了东西,要么是脚本冲突导致的 ...

绝对没有少复制,如果是脚本冲突的话,我只是弄了一个脸谱战斗的脚本,其它都是原样复制的,脸图战斗脚本如下:[pre lang="ruby" line="1"]$脸图战斗 = true
$imported = {} if $imported.nil?
module YEA
  module BATTLE
    SKIP_PARTY_COMMAND = true
    BATTLESTATUS_NAME_FONT_SIZE = 20
    BATTLESTATUS_TEXT_FONT_SIZE = 16
    BATTLESTATUS_NO_ACTION_ICON = 185
    BATTLESTATUS_HPGAUGE_Y_PLUS = 11
    BATTLESTATUS_CENTER_FACES   = false
    HELP_TEXT_ALL_FOES        = "全体敌人"
    HELP_TEXT_ONE_RANDOM_FOE  = "单个敌人"
    HELP_TEXT_MANY_RANDOM_FOE = "%d个随机敌人"
    HELP_TEXT_ALL_ALLIES      = "全体队友"
    HELP_TEXT_ALL_DEAD_ALLIES = "全体死亡队友"
    HELP_TEXT_ONE_RANDOM_ALLY = "单个随机队友"
    HELP_TEXT_RANDOM_ALLIES   = "%d个随机队友"
  end
end
class Game_Battler
  def can_collapse?
    return false unless dead?
    unless actor?
      return false unless sprite.battler_visible
      array = [:collapse, :boss_collapse, :instant_collapse]
      return false if array.include?(sprite.effect_type)
    end
    return true
  end
  def draw_mp?
    return true
  end
  def draw_tp?
    return $data_system.opt_display_tp
  end
end
module Icon
  def self.no_action; return YEA::BATTLE::BATTLESTATUS_NO_ACTION_ICON; end
end
class Game_Temp
  attr_accessor :battle_aid
  attr_accessor :evaluating
end
class Game_Action
  alias evaluate_item_with_target_abe evaluate_item_with_target
  def evaluate_item_with_target(target)
    $game_temp.evaluating = true
    result = evaluate_item_with_target_abe(target)
    $game_temp.evaluating = false
    return result
  end
end
class Game_Actor < Game_Battler
  def draw_mp?
    return true unless draw_tp?
    for skill in skills
      next unless added_skill_types.include?(skill.stype_id)
      return true if skill.mp_cost > 0
    end
    return false
  end
  def draw_tp?
    return false unless $data_system.opt_display_tp
    for skill in skills
      next unless added_skill_types.include?(skill.stype_id)
      return true if skill.tp_cost > 0
    end
    return false
  end
end
class Window_BattleStatus < Window_Selectable
  def initialize
    super(0, 0, window_width, window_height)
    self.openness = 0
    @party = $game_party.battle_members.clone
  end
  def col_max; return $game_party.max_battle_members; end
  def battle_members; return $game_party.battle_members; end
  def actor; return battle_members[@index]; end
  def update
    super
    return if @party == $game_party.battle_members
    @party = $game_party.battle_members.clone
    refresh
  end
  def draw_item(index)
    return if index.nil?
    clear_item(index)
    actor = battle_members[index]
    rect = item_rect(index)
    return if actor.nil?
    draw_actor_face(actor, rect.x+2, rect.y+2, actor.alive?)
    draw_actor_name(actor, rect.x, rect.y, rect.width-8)
    draw_actor_action(actor, rect.x, rect.y)
    draw_actor_icons(actor, rect.x, line_height*1, rect.width)
    gx = YEA::BATTLE::BATTLESTATUS_HPGAUGE_Y_PLUS
    contents.font.size = YEA::BATTLE::BATTLESTATUS_TEXT_FONT_SIZE
    draw_actor_hp(actor, rect.x+2, line_height*2+gx, rect.width-4)
    if draw_tp?(actor) && draw_mp?(actor)
      dw = rect.width/2-2
      dw += 1 if $imported["YEA-CoreEngine"] && YEA::CORE::GAUGE_OUTLINE
      draw_actor_tp(actor, rect.x+2, line_height*3, dw)
      dw = rect.width - rect.width/2 - 2
      draw_actor_mp(actor, rect.x+rect.width/2, line_height*3, dw)
    elsif draw_tp?(actor) && !draw_mp?(actor)
      draw_actor_tp(actor, rect.x+2, line_height*3, rect.width-4)
    else
      draw_actor_mp(actor, rect.x+2, line_height*3, rect.width-4)
    end
  end
  def item_rect(index)
    rect = Rect.new
    rect.width = contents.width / $game_party.max_battle_members
    rect.height = contents.height
    rect.x = index * rect.width
    if YEA::BATTLE::BATTLESTATUS_CENTER_FACES
      rect.x += (contents.width - $game_party.members.size * rect.width) / 2
    end
    rect.y = 0
    return rect
  end
  def draw_face(face_name, face_index, dx, dy, enabled = true)
    bitmap = Cache.face(face_name)
    fx = [(96 - item_rect(0).width + 1) / 2, 0].max
    fy = face_index / 4 * 96 + 2
    fw = [item_rect(0).width - 4, 92].min
    rect = Rect.new(fx, fy, fw, 92)
    rect = Rect.new(face_index % 4 * 96 + fx, fy, fw, 92)
    contents.blt(dx, dy, bitmap, rect, enabled ? 255 : translucent_alpha)
    bitmap.dispose
  end
  def draw_actor_name(actor, dx, dy, dw = 112)
    reset_font_settings
    contents.font.size = YEA::BATTLE::BATTLESTATUS_NAME_FONT_SIZE
    change_color(hp_color(actor))
    draw_text(dx+24, dy, dw-24, line_height, actor.name)
  end
  def draw_actor_action(actor, dx, dy)
    draw_icon(action_icon(actor), dx, dy)
  end
  def action_icon(actor)
    return Icon.no_action if actor.current_action.nil?
    return Icon.no_action if actor.current_action.item.nil?
    return actor.current_action.item.icon_index
  end
  def draw_tp?(actor)
    return actor.draw_tp?
  end
  def draw_mp?(actor)
    return actor.draw_mp?
  end
  def draw_current_and_max_values(dx, dy, dw, current, max, color1, color2)
    change_color(color1)
    draw_text(dx, dy, dw, line_height, current.to_s, 2)
  end
  def draw_actor_hp(actor, dx, dy, width = 124)
    draw_gauge(dx, dy, width, actor.hp_rate, hp_gauge_color1, hp_gauge_color2)
    change_color(system_color)
    cy = (Font.default_size - contents.font.size) / 2 + 1
    draw_text(dx+2, dy+cy, 30, line_height, Vocab::hp_a)
    draw_current_and_max_values(dx, dy+cy, width, actor.hp, actor.mhp,
      hp_color(actor), normal_color)
    end
  def draw_actor_mp(actor, dx, dy, width = 124)
    draw_gauge(dx, dy, width, actor.mp_rate, mp_gauge_color1, mp_gauge_color2)
    change_color(system_color)
    cy = (Font.default_size - contents.font.size) / 2 + 1
    draw_text(dx+2, dy+cy, 30, line_height, Vocab::mp_a)
    draw_current_and_max_values(dx, dy+cy, width, actor.mp, actor.mmp,
      mp_color(actor), normal_color)
    end
  def draw_actor_tp(actor, dx, dy, width = 124)
    draw_gauge(dx, dy, width, actor.tp_rate, tp_gauge_color1, tp_gauge_color2)
    change_color(system_color)
    cy = (Font.default_size - contents.font.size) / 2 + 1
    draw_text(dx+2, dy+cy, 30, line_height, Vocab::tp_a)
    change_color(tp_color(actor))
    draw_text(dx + width - 42, dy+cy, 42, line_height, actor.tp.to_i, 2)
  end
end
class Window_BattleActor < Window_BattleStatus
  def show
    create_flags
    super
  end
  def create_flags
    set_select_flag(:any)
    select(0)
    return if $game_temp.battle_aid.nil?
    if $game_temp.battle_aid.need_selection?
      select(0)
      set_select_flag(:dead) if $game_temp.battle_aid.for_dead_friend?
    elsif $game_temp.battle_aid.for_user?
      battler = BattleManager.actor
      id = battler.nil? ? 0 : $game_party.battle_members.index(battler)
      select(id)
      set_select_flag(:user)
    elsif $game_temp.battle_aid.for_all?
      select(0)
      set_select_flag(:all)
      set_select_flag(:all_dead) if $game_temp.battle_aid.for_dead_friend?
    elsif $game_temp.battle_aid.for_random?
      select(0)
      set_select_flag(:random) if $game_temp.battle_aid.for_random?
    end
  end
  def set_select_flag(flag)
    @select_flag = flag
    case @select_flag
    when :all, :all_dead, :random
      @cursor_all = true
    else
      @cursor_all = false
    end
  end
  def update_cursor
    if @cursor_all
      cursor_rect.set(0, 0, contents.width, contents.height)
      self.top_row = 0
    elsif @index < 0
      cursor_rect.empty
    else
      ensure_cursor_visible
      cursor_rect.set(item_rect(@index))
    end
  end
  def cursor_movable?
    return false if @select_flag == :user
    return super
  end
  def current_item_enabled?
    return true if $game_temp.battle_aid.nil?
    if $game_temp.battle_aid.need_selection?
      member = $game_party.battle_members[@index]
      return member.dead? if $game_temp.battle_aid.for_dead_friend?
    elsif $game_temp.battle_aid.for_dead_friend?
      for member in $game_party.battle_members
        return true if member.dead?
      end
      return false
    end
    return true
  end
end
class Window_BattleStatusAid < Window_BattleStatus
  attr_accessor :status_window
  def initialize
    super
    self.visible = false
    self.openness = 255
  end
  def window_width; return 128; end
  def show
    super
    refresh
  end
  def refresh
    contents.clear
    return if @status_window.nil?
    draw_item(@status_window.index)
  end
  def item_rect(index)
    return Rect.new(0, 0, contents.width, contents.height)
  end
end
class Window_BattleEnemy < Window_Selectable
  def initialize(info_viewport)
    super(0, Graphics.height, window_width, fitting_height(1))
    refresh
    self.visible = false
    @info_viewport = info_viewport
  end
  def col_max; return item_max; end
  def show
    create_flags
    super
  end
  def create_flags
    set_select_flag(:any)
    select(0)
    return if $game_temp.battle_aid.nil?
    if $game_temp.battle_aid.need_selection?
      select(0)
    elsif $game_temp.battle_aid.for_all?
      select(0)
      set_select_flag(:all)
    elsif $game_temp.battle_aid.for_random?
      select(0)
      set_select_flag(:random)
    end
  end
  def set_select_flag(flag)
    @select_flag = flag
    case @select_flag
    when :all, :random
      @cursor_all = true
    else
      @cursor_all = false
    end
  end
  def select_all?
    return true if @select_flag == :all
    return true if @select_flag == :random
    return false
  end
  def update_cursor
    if @cursor_all
      cursor_rect.set(0, 0, contents.width, contents.height)
      self.top_row = 0
    elsif @index < 0
      cursor_rect.empty
    else
      ensure_cursor_visible
      cursor_rect.set(item_rect(@index))
    end
  end
  def cursor_movable?
    return false if @select_flag == :user
    return super
  end
  def current_item_enabled?
    return true if $game_temp.battle_aid.nil?
    if $game_temp.battle_aid.need_selection?
      member = $game_party.battle_members[@index]
      return member.dead? if $game_temp.battle_aid.for_dead_friend?
    elsif $game_temp.battle_aid.for_dead_friend?
      for member in $game_party.battle_members
        return true if member.dead?
      end
      return false
    end
    return true
  end
  def enemy; @data[index]; end
  def refresh
    make_item_list
    create_contents
    draw_all_items
  end
  def make_item_list
    @data = $game_troop.alive_members
    @data.sort! { |a,b| a.screen_x <=> b.screen_x }
  end
  def draw_item(index); return; end
  def update
    super
    return unless active
    enemy.sprite_effect_type = :whiten
    return unless select_all?
    for enemy in $game_troop.alive_members
      enemy.sprite_effect_type = :whiten
    end
  end
end
class Window_BattleHelp < Window_Help
  attr_accessor :actor_window
  attr_accessor :enemy_window
  def update
    super
    if !self.visible and @text != ""
      @text = ""
      return refresh
    end
    update_battler_name
  end
  def update_battler_name
    return unless @actor_window.active || @enemy_window.active
    if @actor_window.active
      battler = $game_party.battle_members[@actor_window.index]
    elsif @enemy_window.active
      battler = @enemy_window.enemy
    end
    if special_display?
      refresh_special_case(battler)
    else
      refresh_battler_name(battler) if battler_name(battler) != @text
    end
  end
  def battler_name(battler)
    text = battler.name.clone
    return text
  end
  def refresh_battler_name(battler)
    contents.clear
    reset_font_settings
    change_color(normal_color)
    @text = battler_name(battler)
    icons = battler.state_icons + battler.buff_icons
    dy = icons.size <= 0 ? line_height / 2 : 0
    draw_text(0, dy, contents.width, line_height, @text, 1)
    dx = (contents.width - (icons.size * 24)) / 2
    draw_actor_icons(battler, dx, line_height, contents.width)
  end
  def special_display?
    return false if $game_temp.battle_aid.nil?
    return false if $game_temp.battle_aid.for_user?
    return !$game_temp.battle_aid.need_selection?
  end
  def refresh_special_case(battler)
    if $game_temp.battle_aid.for_opponent?
      if $game_temp.battle_aid.for_all?
        text = YEA::BATTLE::HELP_TEXT_ALL_FOES
      else
        case $game_temp.battle_aid.number_of_targets
        when 1
          text = YEA::BATTLE::HELP_TEXT_ONE_RANDOM_FOE
        else
          number = $game_temp.battle_aid.number_of_targets
          text = sprintf(YEA::BATTLE::HELP_TEXT_MANY_RANDOM_FOE, number)
        end
      end
    else
      if $game_temp.battle_aid.for_dead_friend?
        text = YEA::BATTLE::HELP_TEXT_ALL_DEAD_ALLIES
      elsif $game_temp.battle_aid.for_random?
        case $game_temp.battle_aid.number_of_targets
        when 1
          text = YEA::BATTLE::HELP_TEXT_ONE_RANDOM_ALLY
        else
          number = $game_temp.battle_aid.number_of_targets
          text = sprintf(YEA::BATTLE::HELP_TEXT_RANDOM_ALLIES, number)
        end
      else
        text = YEA::BATTLE::HELP_TEXT_ALL_ALLIES
      end
    end
    return if text == @text
    @text = text
    contents.clear
    reset_font_settings
    draw_text(0, 0, contents.width, line_height*2, @text, 1)
  end
end
class Window_SkillList < Window_Selectable
  def spacing
    return 8 if $game_party.in_battle
    return super
  end
end
class Window_ItemList < Window_Selectable
  def spacing
    return 8 if $game_party.in_battle
    return super
  end
end
class Scene_Battle < Scene_Base
  attr_accessor :enemy_window
  attr_accessor :info_viewport
  attr_accessor :spriteset
  attr_accessor :status_window
  attr_accessor :status_aid_window
  attr_accessor :subject
  alias scene_battle_create_all_windows_abe create_all_windows
  def create_all_windows
    scene_battle_create_all_windows_abe
    create_battle_status_aid_window
    set_help_window
  end
  alias scene_battle_create_info_viewport_abe create_info_viewport
  def create_info_viewport
    scene_battle_create_info_viewport_abe
    @status_window.refresh
  end
  def create_battle_status_aid_window
    @status_aid_window = Window_BattleStatusAid.new
    @status_aid_window.status_window = @status_window
    @status_aid_window.x = Graphics.width - @status_aid_window.width
    @status_aid_window.y = Graphics.height - @status_aid_window.height
  end
  def create_help_window
    @help_window = Window_BattleHelp.new
    @help_window.hide
  end
  def set_help_window
    @help_window.actor_window = @actor_window
    @help_window.enemy_window = @enemy_window
  end
  alias scene_battle_create_skill_window_abe create_skill_window
  def create_skill_window
    scene_battle_create_skill_window_abe
    @skill_window.height = @info_viewport.rect.height
    @skill_window.width = Graphics.width - @actor_command_window.width
    @skill_window.y = Graphics.height - @skill_window.height
  end
  alias scene_battle_create_item_window_abe create_item_window
  def create_item_window
    scene_battle_create_item_window_abe
    @item_window.height = @skill_window.height
    @item_window.width = @skill_window.width
    @item_window.y = Graphics.height - @item_window.height
  end
  alias scene_battle_next_command_abe next_command
  def next_command
    @status_window.show
    redraw_current_status
    @actor_command_window.show
    @status_aid_window.hide
    scene_battle_next_command_abe
  end
  alias scene_battle_prior_command_abe prior_command
  def prior_command
    redraw_current_status
    scene_battle_prior_command_abe
  end
  def redraw_current_status
    return if @status_window.index < 0
    @status_window.draw_item(@status_window.index)
  end
  alias scene_battle_command_attack_abe command_attack
  def command_attack
    $game_temp.battle_aid = $data_skills[BattleManager.actor.attack_skill_id]
    scene_battle_command_attack_abe
  end
  alias scene_battle_command_skill_abe command_skill
  def command_skill
    scene_battle_command_skill_abe
    @status_window.hide
    @actor_command_window.hide
    @status_aid_window.show
  end
  alias scene_battle_command_item_abe command_item
  def command_item
    scene_battle_command_item_abe
    @status_window.hide
    @actor_command_window.hide
    @status_aid_window.show
  end
  def on_skill_ok
    @skill = @skill_window.item
    $game_temp.battle_aid = @skill
    BattleManager.actor.input.set_skill(@skill.id)
    BattleManager.actor.last_skill.object = @skill
    if @skill.for_opponent?
      select_enemy_selection
    elsif @skill.for_friend?
      select_actor_selection
    else
      @skill_window.hide
      next_command
      $game_temp.battle_aid = nil
    end
  end
  alias scene_battle_on_skill_cancel_abe on_skill_cancel
  def on_skill_cancel
    scene_battle_on_skill_cancel_abe
    @status_window.show
    @actor_command_window.show
    @status_aid_window.hide
  end
  def on_item_ok
    @item = @item_window.item
    $game_temp.battle_aid = @item
    BattleManager.actor.input.set_item(@item.id)
    if @item.for_opponent?
      select_enemy_selection
    elsif @item.for_friend?
      select_actor_selection
    else
      @item_window.hide
      next_command
      $game_temp.battle_aid = nil
    end
    $game_party.last_item.object = @item
  end
  alias scene_battle_on_item_cancel_abe on_item_cancel
  def on_item_cancel
    scene_battle_on_item_cancel_abe
    @status_window.show
    @actor_command_window.show
    @status_aid_window.hide
  end
  alias scene_battle_select_actor_selection_abe select_actor_selection
  def select_actor_selection
    @status_aid_window.refresh
    scene_battle_select_actor_selection_abe
    @status_window.hide
    @skill_window.hide
    @item_window.hide
    @help_window.show
  end
  alias scene_battle_on_actor_ok_abe on_actor_ok
  def on_actor_ok
    $game_temp.battle_aid = nil
    scene_battle_on_actor_ok_abe
    @status_window.show
    if $imported["YEA-BattleCommandList"] && !@confirm_command_window.nil?
      @actor_command_window.visible = !@confirm_command_window.visible
    else
      @actor_command_window.show
    end
    @status_aid_window.hide
  end
  alias scene_battle_on_actor_cancel_abe on_actor_cancel
  def on_actor_cancel
    BattleManager.actor.input.clear
    @status_aid_window.refresh
    $game_temp.battle_aid = nil
    scene_battle_on_actor_cancel_abe
    case @actor_command_window.current_symbol
    when :skill
      @skill_window.show
    when :item
      @item_window.show
    end
  end
  alias scene_battle_select_enemy_selection_abe select_enemy_selection
  def select_enemy_selection
    @status_aid_window.refresh
    scene_battle_select_enemy_selection_abe
    @help_window.show
  end
  alias scene_battle_on_enemy_ok_abe on_enemy_ok
  def on_enemy_ok
    $game_temp.battle_aid = nil
    scene_battle_on_enemy_ok_abe
  end
  alias scene_battle_on_enemy_cancel_abe on_enemy_cancel
  def on_enemy_cancel
    BattleManager.actor.input.clear
    @status_aid_window.refresh
    $game_temp.battle_aid = nil
    scene_battle_on_enemy_cancel_abe
    if @skill_window.visible || @item_window.visible
      @help_window.show
    else
      @help_window.hide
    end
  end
  def end_battle_conditions?
    return true if $game_party.members.empty?
    return true if $game_party.all_dead?
    return true if $game_troop.all_dead?
    return true if BattleManager.aborting?
    return false
  end
  def refresh_status
    #如果你是程序员,请顺手帮忙优化下这里,谢谢。
    @status_window.refresh
    for i in $game_party.battle_members
      @status_window.draw_item($game_party.battle_members.index(i))
    end
  end
end
[/pre]
回复

使用道具 举报

…あたしは天

梦石
0
星屑
2308
在线时间
4033 小时
注册时间
2010-10-4
回帖
10548

开拓者贵宾

发表于 2014-7-29 15:18:23 | 显示全部楼层
xjzsq 发表于 2014-7-29 15:13
绝对没有少复制,如果是脚本冲突的话,我只是弄了一个脸谱战斗的脚本,其它都是原样复制的,脸图战斗脚本 ...

那么把脸图战斗的脚本去掉,还有这个问题吗?
回复

使用道具 举报

梦石
2
星屑
34497
在线时间
614 小时
注册时间
2014-7-18
回帖
647

MZ评测员开拓者

 楼主| 发表于 2014-7-29 20:17:10 | 显示全部楼层
仍然如此,是不是我改的大地图脚本不完全(有的地方漏下了没改导致的)希望您帮忙改过来,如果这样没法改,我可以把工程发给你。十分感谢!求求您了,大神啊!!!

点评

那我就不知道了= = 范例能用的话你就从范例上改吧= =  发表于 2014-7-29 20:23
回复

使用道具 举报

梦石
2
星屑
34497
在线时间
614 小时
注册时间
2014-7-18
回帖
647

MZ评测员开拓者

 楼主| 发表于 2014-7-29 20:53:48 | 显示全部楼层
我把我的游戏发给你,你帮忙看看脚本上有木有漏改的地方?谢谢,求求taroxd这位大神了!!!
回复

使用道具 举报

梦石
0
星屑
50
在线时间
186 小时
注册时间
2014-6-14
回帖
184
发表于 2014-7-31 11:04:36 | 显示全部楼层
范例吗?
也许是对原始脚本进行改动的吧……
用一下范例吧……反正也可以显示主角现在位置。
回复

使用道具 举报

梦石
2
星屑
34497
在线时间
614 小时
注册时间
2014-7-18
回帖
647

MZ评测员开拓者

 楼主| 发表于 2014-7-31 15:10:07 | 显示全部楼层
本帖最后由 xjzsq 于 2014-7-31 15:18 编辑
qq19750508 发表于 2014-7-31 11:04
范例吗?
也许是对原始脚本进行改动的吧……
用一下范例吧……反正也可以显示主角现在位置。 ...


我已经发现问题了。
回复

使用道具 举报

梦石
2
星屑
34497
在线时间
614 小时
注册时间
2014-7-18
回帖
647

MZ评测员开拓者

 楼主| 发表于 2014-7-31 15:21:34 | 显示全部楼层
对不起,各位大神们,因为我没有把范例研究清楚,只设置了一半,so...太对不起了!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部