| 
 
| 赞 | 0 |  
| VIP | 0 |  
| 好人卡 | 0 |  
| 积分 | 1 |  
| 经验 | 8533 |  
| 最后登录 | 2017-7-6 |  
| 在线时间 | 125 小时 |  
 Lv1.梦旅人 
	梦石0 星屑50 在线时间125 小时注册时间2006-7-19帖子336 | 
3楼
 
 
 楼主|
发表于 2011-9-26 19:35:09
|
只看该作者 
| 用公共事件,会与这条发生冲突。 这是某某整合的用行走图做战斗图的那个整合横版战斗脚本。具体是那个版本,我倒是给忘了。复制代码$CP可见 = true
$敌人血条显示 = true
class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # ● 开始技能选择
  #--------------------------------------------------------------------------
  def start_skill_selection
    @help_window = Window_Help.new
    @skill_window = Window_Skill.new(0, 56, 544, 208, @active_battler)
    @skill_window.z = 520
    @help_window.z = 520
    @skill_window.help_window = @help_window
    @actor_command_window.active = false
  end  
  #--------------------------------------------------------------------------
  # ● 生成资讯显示端口
  #--------------------------------------------------------------------------
  def create_info_viewport
    @info_viewport = Viewport.new(0, 256, 544, 160)
    @info_viewport.z = 100
    @status_window = Window_BattleStatus.new
    @party_command_window = Window_PartyCommand.new
    @actor_command_window = Window_ActorCommand.new
    @status_window.viewport = @info_viewport
    @party_command_window.viewport = @info_viewport
    @actor_command_window.viewport = @info_viewport
    @actor_command_window.setup(nil)
    @status_window.x = 128
    @status_window.y = $CP可见 ? 32 : 8
    @actor_command_window.x = 0
    @actor_command_window.y = 8
    @info_viewport.visible = false
  end
  #--------------------------------------------------------------------------
  # ● 更新资讯显示端口
  #--------------------------------------------------------------------------
  def update_info_viewport
    @party_command_window.update
    @actor_command_window.update
    @status_window.update    
  end
  #--------------------------------------------------------------------------
  # ● CP条生成
  #--------------------------------------------------------------------------
  def make_cp
    @blank_window = Window_Blank.new
    @cppic = {}
    @baseicons = Cache.system("Iconset")
    for iii in $game_party.members + $game_troop.members
      @cppic[iii] = Sprite.new
      @cppic[iii].bitmap = @baseicons
      @cppic[iii].x = 4
      @cppic[iii].y = 264
      @cppic[iii].z = 510
      @cppic[iii].zoom_x = 1.0
      @cppic[iii].zoom_y = 1.0
      @cppic[iii].opacity = 255
      @cppic[iii].visible = $CP可见
    end
    @basepic = Sprite.new
    @basepic.bitmap = Bitmap.new(384, 8)
    @basepic.x = 16
    @basepic.y = 272
    @basepic.z = 500
    @basepic.zoom_x = 1.0
    @basepic.zoom_y = 1.0
    @basepic.opacity = 255
    @basepic.bitmap.fill_rect(0, 0, 384, 8, Color.new(0, 128, 192, 255))
    @basepic.visible = $CP可见
    refresh_cp
  end
  #--------------------------------------------------------------------------
  # ● CP条更新
  #--------------------------------------------------------------------------
  def refresh_cp
    if @blank_window.disposed?
      return
    end
    @blank_window.x = 128 - @info_viewport.ox
    @basepic.x = 144 - @info_viewport.ox    
    for iii in $game_party.members + $game_troop.members
      if iii.is_a?(Game_Actor)
        if iii.weapon_id == 0
          @cppic[iii].src_rect.set(96, 192, 24, 24)
        else
          icon_index = $data_weapons[iii.weapon_id].icon_index
          @cppic[iii].src_rect.set(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
        end
      else
        @cppic[iii].src_rect.set(312, 216, 24, 24)
      end
      if iii.hp > 0
        @cppic[iii].visible = $CP可见
      else
        @cppic[iii].visible = false
      end
      if iii.waiting_time > 0
        @cppic[iii].x = 132 + 384 * (iii.max_waiting_time - iii.waiting_time) / iii.max_waiting_time - @info_viewport.ox
        @cppic[iii].y = 264 - 480 * (Graphics.frame_count % 2)
      else
        @cppic[iii].x = 132 + (iii.cp * 384 / 5000).to_i - @info_viewport.ox
        @cppic[iii].y = 264
      end      
    end
  end
  #--------------------------------------------------------------------------
  # ● CP条消去
  #--------------------------------------------------------------------------
  def dispose_cp
    for iii in $game_party.members + $game_troop.members
      @cppic[iii].dispose
    end
    @baseicons.dispose
    @basepic.dispose
    @blank_window.dispose
  end
end
#==============================================================================
# ■ Window_Blank
#------------------------------------------------------------------------------
#  用来放置CP的空白窗口。
#==============================================================================
class Window_Blank < Window_Base
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #--------------------------------------------------------------------------
  def initialize
    super(0, 264, 416, 24)
    self.visible = $CP可见
    self.z = 490    
  end
  #--------------------------------------------------------------------------
  # ● 生成窗口内容
  #--------------------------------------------------------------------------
  def create_contents
    #REM
  end
end
#==============================================================================
# ■ Window_ActorCommand
#------------------------------------------------------------------------------
#  选择角色命令(如「攻击」或「技能」)的窗口。
#==============================================================================
class Window_ActorCommand < Window_Command
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #--------------------------------------------------------------------------
  def initialize
    super(128, [], 1, 5)
    self.active = false
  end
  #--------------------------------------------------------------------------
  # ● 设置
  #     actor : 角色
  #--------------------------------------------------------------------------
  def setup(actor)
    s1 = Vocab::attack
    s2 = Vocab::skill
    s3 = Vocab::guard
    s4 = Vocab::item
    s5 = Vocab::escape
    if actor != nil
      if actor.class.skill_name_valid     # 是否指定职业技能文字
        s2 = actor.class.skill_name       # 替换「技能」命令文字
      end
      self.index = 0
    else
      self.index = -1
    end
    @commands = [s1, s2, s3, s4, s5]
    @item_max = 5
    refresh
  end
end
#==============================================================================
# ■ Sprite_Battler
#------------------------------------------------------------------------------
#  战斗显示用活动块。Game_Battler 类的实例监视、活动块的状态的监视。
#==============================================================================
class Sprite_Battler < Sprite_Base
  # 敌人血条的显示
  attr_accessor :hpmeter_value
  def create_hpmeter
    @hpmeter = Sprite.new
    @hpmeter.bitmap = Bitmap.new(70, 24)
    @hpmeter.visible = @battler_visible
    @hpmeter.z = 200
    @hpmeter.x = @battler.screen_x - 32
    @hpmeter.y = @battler.screen_y - 96
    @hpmeter.bitmap.fill_rect(0, 16, 64, 8, Color.new(0, 0, 0, 255))
    @hpmeter2 = Sprite.new
    @hpmeter2.bitmap = Bitmap.new(96, 32)
    @hpmeter2.visible = @battler_visible
    @hpmeter2.z = 201
    @hpmeter2.x = @hpmeter.x
    @hpmeter2.y = @hpmeter.y    
    @hpmeter_value = 0
    refresh_hpmeter
  end
  def refresh_hpmeter
    @hpmeter.bitmap.clear
    @hpmeter2.bitmap.clear
    @hpmeter.visible = @battler_visible
    unless $敌人血条显示
      @hpmeter.visible = false
    end
    if @battler.hidden
      @hpmeter.visible = false
    end
    if @battler.hp <= 0
      @hpmeter.visible = false
    end
    @hpmeter.x = @battler.screen_x - 32
    @hpmeter.y = @battler.screen_y - 64
    @hpmeter2.visible = @hpmeter.visible
    @hpmeter2.x = @hpmeter.x
    @hpmeter2.y = @hpmeter.y - 8
    if @hpmeter_value != @battler.hp
      @hpmeter.bitmap.fill_rect(0, 10, 70, 12, Color.new(0, 0, 0, 255))
      @hpmeter.bitmap.fill_rect(1, 11, 68, 10, Color.new(255, 255, 255, 255))
      @hpmeter.bitmap.fill_rect(2, 12, 66, 8, Color.new(0, 0, 0, 255))
      @hpmeter.bitmap.fill_rect(3, 13, (64 * (1.0 * @battler.hp / @battler.maxhp)).to_i, 6, Color.new(255, 0, 0, 255))
      @hpmeter2.bitmap.draw_number(32, 0, @battler.hp)
    end
  end
  def dispose_hpmeter
    @hpmeter.dispose
    @hpmeter2.dispose
  end
end
#==============================================================================
# ■ Window_BattleStatus
#------------------------------------------------------------------------------
#  显示战斗画面同伴状态的窗口。
#==============================================================================
class Window_BattleStatus < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #--------------------------------------------------------------------------
  def initialize
    if $CP可见
      super(0, 0, 416, 128)
    else
      super(0, 0, 416, 152)
    end
    refresh
    self.active = false
  end
end
#==============================================================================
# ■ Game_Enemy
#------------------------------------------------------------------------------
#  处理敌人的类。本类在 Game_Troop 类 ($game_troop) 的 内部使用。
#==============================================================================
class Game_Enemy < Game_Battler
  #--------------------------------------------------------------------------
  # ● 生成战斗行动
  #--------------------------------------------------------------------------
  def make_action
    @action.clear
    return unless movable?
    available_actions = []
    rating_max = 0
    for action in enemy.actions
      next unless conditions_met?(action)
      if action.kind == 1
        next unless skill_can_use?($data_skills[action.skill_id])
      end
      available_actions.push(action)
      rating_max = [rating_max, action.rating].max
    end
    ratings_total = 0
    rating_zero = rating_max - 3
    for action in available_actions
      next if action.rating <= rating_zero
      ratings_total += action.rating - rating_zero
    end
    return if ratings_total == 0
    value = rand(ratings_total)
    for action in available_actions
      next if action.rating <= rating_zero
      if value < action.rating - rating_zero
        @action.kind = action.kind
        @action.basic = action.basic
        @action.skill_id = action.skill_id
        @action.decide_random_target
        jjj = []
        for iii in self.states
          jjj.push(iii.id)
        end
        if jjj.include?(26)
# 26 号状态降低敌人的逃跑率 ====================================================
          if rand(100) < 30
            if @action.kind == 0
              if @action.basic == 2
                @action.basic = 0
              end
            end
          end
# ==============================================================================
        end
        return
      else
        value -= action.rating - rating_zero
      end
    end
  end
      
end
#==============================================================================
# ■ Game_Unit
#------------------------------------------------------------------------------
#  处理单位的类。这个类作为 Game_Party 类与 Game_Troop 类的超级类来使用。
#==============================================================================
class Game_Unit
  #--------------------------------------------------------------------------
  # ● 计算平均敏捷
  #--------------------------------------------------------------------------
  def average_agi
    result = 0
    n = 0
    for member in members
      if member.hidden or member.dead?
        next
      end
      result += member.agi
      n += 1
    end
    result /= n if n > 0
    result = 1 if result == 0
    return result
  end
end
#==============================================================================
# ■ Bitmap
#------------------------------------------------------------------------------
#  自制数字字库。
#==============================================================================
class Bitmap
  def draw_number(x, y, nu, pict = Bitmap.new("Graphics/System/Number+.png"))
    w=pict.width / 10
    h=pict.height
    ce = Rect.new(0,0,w,h)
    nu=nu.to_s
    ar = nu.split(//)
    for i in 0...ar.size
      ar[i] = ar[i].to_i
    end
    for sz in ar
      ce.x = sz * w 
      self.blt(x,y,pict,ce) 
      x+=w * 4 / 5
    end
  end
end
 | 
 |