porlutia 发表于 2016-7-13 15:05:55

在有技能信息显示的脚本的情况下 如何将伤害显示显示为

  #--------------------------------------------------------------------------
  #取得当前角色
  #--------------------------------------------------------------------------
  class Scene_Battle
    alias lqc_phase3_setup_command_window phase3_setup_command_window
    def phase3_setup_command_window
      $active_now = $game_party.actors[@actor_index]
      lqc_phase3_setup_command_window
    end
  end
#==============================================================================
# ■ Window_Help
#------------------------------------------------------------------------------
#  特技及物品的说明、角色的状态显示的窗口。
#==============================================================================

class Window_SkillHelp < Window_Base
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #--------------------------------------------------------------------------
  def initialize
    super(320-50, 0, 320+50,416)
    self.contents = Bitmap.new(width - 32, height - 32)
    if $game_temp.in_battle
      self.height = 256+64
      self.back_opacity = 160
    end
  end  
  #--------------------------------------------------------------------------
  # ● 设置文本
  #     text  : 窗口显示的字符串
  #     align : 对齐方式 (0..左对齐、1..中间对齐、2..右对齐)
  #--------------------------------------------------------------------------
  def set_text(skill)
    if skill !=nil
      fontsize=18        #定义文字大小
      infx=100           #定义说明文字左边内容的宽度
      y=20               #定义行距
      self.contents.clear
      self.contents.font.color = normal_color
      self.contents.font.size = fontsize
      xx=0
      yy=0
      yy = -160 if $skill_second_page
      s=[]
      s=skill.description.scan(/./)
      space = self.contents.text_size(" ").width
      #一行显示21个字
      for i in s
        sss = self.contents.text_size(i)
        if (xx+sss.width)>(width - 32)#超过屏幕就换行
          yy+=y
          xx=4
        end
        self.contents.draw_text(xx, yy, sss.width, sss.height, i)
        xx+=sss.width
      end
      self.contents.font.size = fontsize
      #-------------------------------------------------------------------
      #描画技能类型
      #-------------------------------------------------------------------
          hurt_flag = false
          curse_flag = false
          heal_flag = false
          cure_flag = false
        if skill.common_event_id > 0
          the_event = Game_CommonEvent.new(skill.common_event_id)
          for i in the_event.list
            the_parameters = i.parameters
            the_code = i.code
            case the_code
              when 331
                if the_parameters == 1
                  hurt_flag = true
                end
              when 332
                if the_parameters == 1
                  hurt_flag = true
                end
              when 338
                if the_parameters == 0
                  hurt_flag = true
                end
                if the_parameters == 1
                  heal_flag = true
                end
              when 333
                curse_flag = true
              when 311
                if the_parameters == 0
                  heal_flag = true
                end
              when 312
                if the_parameters == 0
                  heal_flag = true
                end
              when 313
                cure_flag = true
            end
          end
        end
       
        xx=0
        yy+=y
        self.contents.font.color = system_color
        self.contents.draw_text(xx, yy, infx, sss.height, "技能类型")
        xx = infx
        if skill.occasion == 3
          self.contents.font.color = normal_color
          self.contents.draw_text(xx, yy, 40, sss.height, "被动")
          xx += 40
        end
        if skill.scope == 1 || skill.scope == 2
          if skill.atk_f > 0
            self.contents.font.color = Color.new(220, 20, 60, 255)
            self.contents.draw_text(xx, yy, 40, sss.height, "物理")
            xx += 40   
          elsif skill.power > 0
            self.contents.font.color = Color.new(0, 191, 255, 255)
            self.contents.draw_text(xx, yy, 40, sss.height, "魔法")
            xx += 40
          end
        end
        if skill.scope >= 3 and skill.scope <= 7
          if skill.atk_f < 0 or skill.power < 0 or heal_flag
            self.contents.font.color = Color.new(50, 205, 50, 255)
            self.contents.draw_text(xx, yy, 40, sss.height, "恢复")
            xx += 40
          end
        end
        if xx == 100
          self.contents.font.color = disabled_color
          self.contents.draw_text(xx, yy, 58, sss.height, "未分类")
          xx += 58
        end
      #-------------------------------------------------------------------
      #描画使用场合
      #-------------------------------------------------------------------
      if skill.occasion != 3
        xx=0
        yy+=y
        self.contents.font.color=system_color
        self.contents.draw_text(xx, yy, infx, sss.height, "使用时机")
        xx=infx
        case skill.occasion
          when 0
            i="任何时候"
          when 1
            i="仅战斗中"
          when 2
            i="仅菜单中"
        end
        self.contents.font.color=normal_color
        self.contents.draw_text(xx, yy, infx, sss.height, i)
      #-------------------------------------------------------------------
      #描画效果范围
      #-------------------------------------------------------------------
      xx=0
      yy+=y
      self.contents.font.color=system_color
      self.contents.draw_text(xx, yy, infx, sss.height, "效果范围")
      xx=infx                                 
      self.contents.font.color=normal_color
      case skill.scope
        when 0
          i="无"
        when 1
          i="敌方单体"
        when 2
          i="敌方全体"
        when 3
          i="我方单体"
        when 4
          i="我方全体"
        when 5
          i="我方战斗不能单体"
        when 6
          i="我方战斗不能全体"
        when 7
          i="自身"
      end
      self.contents.draw_text(xx, yy, infx, sss.height, i)
    #---------------------------------------------------------------------------
    #伤害估算
    #---------------------------------------------------------------------------
      if $game_temp.in_battle
      xx = 0
      yy += y
      #--------------------------------------------------
      #求对敌人伤害
      #--------------------------------------------------
      x_powers = 0
      x_user = $active_now
      if skill.scope == 1 or skill.scope == 2
        self.contents.font.color=system_color
        self.contents.draw_text(xx, yy, 100, sss.height, "预计威力")
        enemies_court = 0
        for x_enemy in $game_troop.enemies
        if x_enemy.is_a?(Game_Enemy)
        x_power = skill.power + x_user.atk * skill.atk_f / 100
        if x_power > 0
       # x_power -= x_enemy.pdef * skill.pdef_f / 200
       # x_power -= x_enemy.mdef * skill.mdef_f / 200
        x_power = .max
        end
        rate = 1.0
        rate += (x_user.str * skill.str_f / 2000)
        rate += (x_user.dex * skill.dex_f / 2000)
        rate += (x_user.agi * skill.agi_f / 2000)
        rate += (x_user.int * skill.int_f / 2000)
        x_power *= rate
        x_power *= x_enemy.elements_correct(skill.element_set).to_f
        x_power /= 100.0
        if x_power > 0
        if x_enemy.guarding?
          x_power /= 2
        end
        end
        x_powers += x_power
        enemies_court += 1
        end
      end
      out_power = enemies_court == 0 ? 0 : (x_powers / enemies_court)
      out_power_max = out_power * (100 + skill.variance) / 100.0
      out_power_max = out_power_max.to_i
      out_power_min = out_power * (100 - skill.variance) / 100.0
      out_power_min = out_power_min.to_i
      xx = 100
      #------------------------------------------------------------------------
      #------------------------------------------------------------------------
      self.draw_text_add(xx-1, yy-1, 100, sss.height, out_power_min.to_s + " - " + out_power_max.to_s,255,20,147,255)
      #-----------------------------------------------------------------------------
      #求对自己的恢复量
      #-----------------------------------------------------------------------------
      elsif skill.scope >= 3
        self.contents.font.color=Color.new(0,255,0,255)
        self.contents.draw_text(xx, yy, 100, sss.height, "预计恢复")
        actors_court = 0
        for x_actor in $game_party.actors
         if x_actor.is_a?(Game_Actor)
         x_power = skill.power + x_user.atk * skill.atk_f / 100
          if x_power > 0
       #    x_power -= x_actor.pdef * skill.pdef_f / 200
       #    x_power -= x_actor.mdef * skill.mdef_f / 200
           x_power = .max
          end
         rate = 1.0
         rate += (x_user.str * skill.str_f / 2000)
         rate += (x_user.dex * skill.dex_f / 2000)
         rate += (x_user.agi * skill.agi_f / 2000)
         rate += (x_user.int * skill.int_f / 2000)
         x_power *= rate
         x_power *= x_actor.elements_correct(skill.element_set).to_f
         x_power /= 100.0
         x_powers += x_power
         actors_court += 1
         end
        end
      out_power = actors_court == 0 ? 0 : (x_powers / actors_court)
      out_power_max = out_power * (100 + skill.variance) / 100.0
      out_power_max = - out_power_max.to_i
      out_power_min = out_power * (100 - skill.variance) / 100.0
      out_power_min = - out_power_min.to_i
      xx = 100
      self.draw_text_add(xx, yy, 100, sss.height, out_power_min.to_s + " - " + out_power_max.to_s,127,255,0,255)
    end
    #--------------------------------------------------------------------
    #计算命中率
    #--------------------------------------------------------------------
    if skill.scope == 1 or skill.scope == 2
    xx = 200
    self.contents.font.color=system_color
    self.contents.draw_text(xx, yy, 75, sss.height, "结算命中")
    xx += 75
    hit = skill.hit
    hit *= x_user.hit / 100
    s_hits = 0
    enemies_court = 0
    for x_enemy in $game_troop.enemies
      eva = 8 * x_enemy.agi / x_user.dex + x_enemy.eva
      s_hit = 100 - eva * skill.eva_f / 100
      s_hit = x_enemy.cant_evade? ? 100 : s_hit
      s_hits += s_hit * hit / 100
      enemies_court += 1
    end
    hit = enemies_court ? (s_hits / enemies_court) : 0
    hit = [.min,0].max
    self.draw_text_add(xx, yy, 100, sss.height, hit.to_s + "%",193,255,193,255)
    end
    xx=0
    yy+=y
    yy+=2
    self.contents.font.color=system_color
    self.contents.draw_text(xx, yy, infx, sss.height, "平均")
    xx+=infx
    self.contents.font.size = 22
      if skill.scope == 1 or skill.scope == 2
        self.contents.font.color=Color.new(255,215,0,255)
        self.contents.draw_text(xx, yy, infx, 22,(out_power * hit /100).to_i.to_s)
      elsif skill.scope >= 3
        self.contents.font.color=Color.new(255,215,0,255)
        self.contents.draw_text(xx, yy, infx, 22,out_power.to_i.to_s)
      end
    yy+=2
    end
    #--------------------------------------------------------------------
    #描画基础威力
    #--------------------------------------------------------------------
      xx=0
      yy+=y
      self.contents.font.size = fontsize
      self.contents.font.color=system_color
      self.contents.draw_text(xx, yy, infx, sss.height, "基本威力")
      xx=infx
      self.contents.font.color=normal_color
      self.contents.draw_text(xx, yy, infx*2, sss.height, skill.power.to_s)
    #--------------------------------------------------------------------
    #描画攻击计算依据
    #--------------------------------------------------------------------
    if skill.atk_f + skill.power != 0
      xx=0
      yy+=y
      self.contents.font.color=system_color
      self.contents.draw_text(xx, yy, infx, sss.height, "属性参数")
      xx=infx
      self.contents.font.color=normal_color
      infx = 54
      if skill.atk_f != 0
        self.contents.draw_text(xx, yy, infx, sss.height, "| ATK " )
        xx += infx
      end
      if skill.str_f != 0
        self.contents.draw_text(xx, yy, infx, sss.height, "| STR " )
        xx += infx
      end
      if skill.dex_f != 0
        self.contents.draw_text(xx, yy, infx, sss.height, "| DEX " )
        xx += infx
      end
      if skill.agi_f != 0
        self.contents.draw_text(xx, yy, infx, sss.height, "| AGI " )
        xx += infx
      end
      if skill.int_f != 0
        self.contents.draw_text(xx, yy, infx, sss.height, "| INT " )
        xx += infx
      end
        self.contents.draw_text(xx, yy, infx, sss.height, "|" )
      xx = 100
      yy += 10
      if skill.atk_f != 0
        self.contents.draw_text(xx, yy, infx, sss.height, "|  ")
        xx += infx
      end
      if skill.str_f != 0
        self.contents.draw_text(xx, yy, infx, sss.height, "|  ")
        xx += infx
      end
      if skill.dex_f != 0
        self.contents.draw_text(xx, yy, infx, sss.height, "|  ")
        xx += infx
      end
      if skill.agi_f != 0
        self.contents.draw_text(xx, yy, infx, sss.height, "|  ")
        xx += infx
      end
      if skill.int_f != 0
        self.contents.draw_text(xx, yy, infx, sss.height, "|  ")
        xx += infx
      end
        self.contents.draw_text(xx, yy, infx, sss.height, "|" )
      xx = 100
      yy += 10
      if skill.atk_f != 0
        self.contents.draw_text(xx, yy, infx, sss.height, "| " + skill.atk_f.to_s + " ")
        xx += infx
      end
      if skill.str_f != 0
        self.contents.draw_text(xx, yy, infx, sss.height, "| " + skill.str_f.to_s + " " )
        xx += infx
      end
      if skill.dex_f != 0
        self.contents.draw_text(xx, yy, infx, sss.height, "| " + skill.dex_f.to_s + " " )
        xx += infx
      end
      if skill.agi_f != 0
        self.contents.draw_text(xx, yy, infx, sss.height, "| " + skill.agi_f.to_s + " ")
        xx += infx
      end
      if skill.int_f != 0
        self.contents.draw_text(xx, yy, infx, sss.height, "| " + skill.int_f.to_s + " " )
        xx += infx
      end
        self.contents.draw_text(xx, yy, infx, sss.height, "|" )
      if $game_temp.in_battle
      xx=100
      yy += 10
      self.contents.font.color=normal_color
      if skill.atk_f != 0
        self.contents.draw_text(xx, yy, infx, sss.height, "|  ")
        xx += infx
      end
      if skill.str_f != 0
        self.contents.draw_text(xx, yy, infx, sss.height, "|  ")
        xx += infx
      end
      if skill.dex_f != 0
        self.contents.draw_text(xx, yy, infx, sss.height, "|  ")
        xx += infx
      end
      if skill.agi_f != 0
        self.contents.draw_text(xx, yy, infx, sss.height, "|  ")
        xx += infx
      end
      if skill.int_f != 0
        self.contents.draw_text(xx, yy, infx, sss.height, "|  ")
        xx += infx
      end
        self.contents.draw_text(xx, yy, infx, sss.height, "|" )
      xx=0
      yy+=10
      self.contents.font.color=system_color
      self.contents.draw_text(xx, yy, 100, sss.height, "角色属性")
      xx = 100
      self.contents.font.color=normal_color
      if skill.atk_f != 0
        self.contents.draw_text(xx, yy, infx, sss.height, "| " + $active_now.atk.to_s + " ")
        xx += infx
      end
      if skill.str_f != 0
        self.contents.draw_text(xx, yy, infx, sss.height, "| " + $active_now.str.to_s + " " )
        xx += infx
      end
      if skill.dex_f != 0
        self.contents.draw_text(xx, yy, infx, sss.height, "| " + $active_now.dex.to_s + " " )
        xx += infx
      end
      if skill.agi_f != 0
        self.contents.draw_text(xx, yy, infx, sss.height, "| " + $active_now.agi.to_s + " ")
        xx += infx
      end
      if skill.int_f != 0
        self.contents.draw_text(xx, yy, infx, sss.height, "| " + $active_now.int.to_s + " " )
        xx += infx
      end
        self.contents.draw_text(xx, yy, infx, sss.height, "|" )
      end
      end
      #-----------------------------------------------------------------------------
      #防御计算值
      #-----------------------------------------------------------------------------
      infx = 100
      xx = 0
      yy += y
      self.contents.font.color=system_color
      self.contents.draw_text(xx, yy, infx, sss.height, "伤害类型")
      xx=infx
      self.contents.font.color=normal_color
      if skill.pdef_f == 0 and skill.mdef_f != 0
      self.contents.draw_text(xx, yy, infx, sss.height, "[魔法]")
      elsif skill.pdef_f != 0 and skill.mdef_f == 0
      self.contents.draw_text(xx, yy, infx, sss.height, "[物理]")
      elsif skill.pdef_f != 0 and skill.mdef_f != 0
      self.contents.draw_text(xx, yy, infx, sss.height, "[混合]")
      elsif skill.pdef_f == 0 and skill.mdef_f == 0
      self.contents.draw_text(xx, yy, infx, sss.height, "[无视防御]")
      end
      #-----------------------------------------------------------------------
      #波动度
      #-----------------------------------------------------------------------
      unless $game_temp.in_battle
        xx=0
        yy+=y
        self.contents.font.color=system_color
        self.contents.draw_text(xx, yy, infx, sss.height, "威力波动度")
        xx=infx
        self.contents.font.color=normal_color
        self.contents.draw_text(xx, yy, infx*2, sss.height, skill.variance.to_s)
      #-----------------------------------------------------------------------
      #基本命中率
      #-----------------------------------------------------------------------
        xx=0
        yy+=y
        self.contents.font.color=system_color
        self.contents.draw_text(xx, yy, infx, sss.height, "基础命中")
        xx=infx
        self.contents.font.color=normal_color
        self.contents.draw_text(xx, yy, infx, sss.height, skill.hit.to_s)
        xx+=45
        if skill.eva_f != 100
          self.contents.font.color=system_color
          self.contents.draw_text(xx, yy, 90, sss.height, "无视百分之")
          xx+=90
          self.contents.font.color=normal_color
          self.contents.draw_text(xx, yy, 36, sss.height, (100 - skill.eva_f).to_s)
          xx+=36
          self.contents.font.color=system_color
          self.contents.draw_text(xx, yy, 36, sss.height, "回避")
        end
      end
 
      #-----------------------------------------------------------------------
      xx=0
      yy+=y
      element=""
      for i in skill.element_set
        if i <= 17
          element =element+" "+$data_system.elements
        end
      end
      self.contents.font.color=system_color
      self.contents.draw_text(xx, yy, infx, sss.height, "技能属性")
      xx=infx-space
      self.contents.font.color=normal_color
      s=[]
      s=element.scan(/./)
      #一行显示21个字
      for i in s
        sss = self.contents.text_size(i)
        if (xx+sss.width)>(width - 32)#超过屏幕就换行
          yy+=y
          xx=infx
        end
        self.contents.draw_text(xx, yy, sss.width, sss.height, i)
        xx+=sss.width
      end
      xx=0
      yy+=y
      race=""
      for i in skill.plus_state_set
          race += "["+$data_states.name+"]" if $data_states.name != ""
      end
      self.contents.font.color=system_color
      self.contents.draw_text(xx, yy, infx, sss.height, "附加状态")
      xx=infx
      self.contents.font.color=normal_color
      s=[]
      s=race.scan(/./)
      #一行显示21个字
      for i in s
        sss = self.contents.text_size(i)
        if (xx+sss.width)>(width - 32)#超过屏幕就换行
          yy+=y
          xx=infx
        end
        self.contents.draw_text(xx, yy, sss.width, sss.height, i)
        xx+=sss.width
      end
      xx=0
      yy+=y
      race=""
      for i in skill.minus_state_set
          race += "["+$data_states.name+"]" if $data_states.name != ""
      end
      self.contents.font.color=system_color
      self.contents.draw_text(xx, yy, infx, sss.height, "解除状态")
      xx=infx
      self.contents.font.color=normal_color
      s=[]
      s=race.scan(/./)
      #一行显示21个字
      for i in s
        sss = self.contents.text_size(i)
        if (xx+sss.width)>(width - 32)#超过屏幕就换行
          yy+=y
          xx=infx
        end
        self.contents.draw_text(xx, yy, sss.width, sss.height, i)
        xx+=sss.width
      end
      @actor = nil
    end
    end
    self.visible = true
  end
  def draw_text_add(xx,yy,width,height,i,red,green,blue,gray)
      self.contents.font.color = Color.new(0,0,0,255)
      self.contents.draw_text(xx-1, yy-1,width,height,i)
      self.contents.draw_text(xx, yy-1,width,height,i)
      self.contents.draw_text(xx+1, yy-1,width,height,i)
      self.contents.draw_text(xx-1, yy,width,height,i)
      self.contents.draw_text(xx+1, yy,width,height,i)
      self.contents.draw_text(xx-1, yy+1,width,height,i)
      self.contents.draw_text(xx, yy+1,width,height,i)
      self.contents.draw_text(xx+1, yy+1,width,height,i)
      self.contents.font.color = Color.new(red,green,blue,gray)
      self.contents.draw_text(xx, yy,width,height,i)
    end
end

在拥有这个技能信息显示的脚本时,如何实现伤害显示为某个变量 比如变量是伤害计算,
当技能的公共事件ID>0 && 变量:[伤害计算]不等于0时,
显示[伤害计算]

secondsen 发表于 2016-7-16 03:24:38

不明白你的意思。。

这个脚本没有显示伤害的功能吧。。
页: [1]
查看完整版本: 在有技能信息显示的脚本的情况下 如何将伤害显示显示为