查看: 3542|回复: 6

[已经解决] 等级的显示

[复制链接]
梦石
0
星屑
2245
在线时间
1015 小时
注册时间
2015-10-17
回帖
1077
发表于 2019-4-18 20:00:47 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 fjm 于 2019-4-19 20:16 编辑

下面图片,实际技能等级LV.  0,让它显示LV  1       该怎么改
感觉可以用0+1,后面+1的方法实现,但不知道应该加在哪里
自己试了半天也没成功,知道的告诉下,谢谢


[pre lang="ruby"]#encoding:utf-8
#===========================================================================
#          RMVA 豪华型技能加点|技能被动效果:      v1.05
#                       By希忆 66rpg.com
#                                                 转载或修改请保留此类信息
#===========================================================================
# 所有和窗体有关的修改
#
# 大概没问题吧
#===========================================================================


class Window_BattleSkill < Window_SkillList
  
  def include?(item)
    item && !item.passive && item.stype_id == @stype_id && @actor.has_skill?(item)
  end
  
end

class Window_SkillList < Window_Selectable

  def include?(item)
    item && item.stype_id == @stype_id && @actor.has_skill?(item)
  end
  
  def draw_item_name(item, x, y, enabled = true, width = 172)
    return unless item
    draw_icon(item.icon_index, x, y, enabled)
    change_color(normal_color, enabled)
    draw_text(x + 24, y, width, line_height, item.name + "|Lv." + @actor.skill_level(item.id).to_s)
  end
  
end

class Window_AllSkill < Window_Selectable

  def initialize(x, y, width, height)
    super
    @actor = nil
    @stype_id = 0
    @data = []
  end
  
  def actor=(actor)
    return if @actor == actor
    @actor = actor
    refresh
    self.oy = 0
  end

  def stype_id=(stype_id)
    return if @stype_id == stype_id
    @stype_id = stype_id
    refresh
    self.oy = 0
  end
  
  def col_max
    return 1
  end
  
  def item_max
    @data ? @data.size : 1
  end
  
  def item
    @data && index >= 0 ? @data[index] : nil
  end
  
  def current_item_enabled?
    enable?(@data[index])
  end
  
  def include?(item)
    item && item.stype_id == @stype_id
  end
  
  def enable?(item)
    item != nil && @actor != nil && @actor.skill_can_levelup?(item)
  end

  def make_item_list
    @data = @actor ? @actor.skills.select {|skill| include?(skill) } : []
  end
  
  def select_last
    select(@data.index(@actor.last_skill.object) || 0)
  end
  
  def draw_item(index)
    skill = @data[index]
    if skill
      rect = item_rect(index)
      rect.width -= 4
      draw_skill_name(skill, rect.x, rect.y, enable?(skill))
      draw_skill_level(rect, skill)
    end
  end
  
  def draw_skill_name(skill, x, y, enabled = true, width = 172)
    return unless skill
    draw_icon(skill.icon_index, x, y, enabled)
    change_color(normal_color, enabled)
    text = skill.name
    text += "<MAX>" if @actor.skill_max_learn?(skill)
    draw_text(x + 24, y, width, line_height, text)
  end
  
  def draw_skill_level(rect, skill)
    draw_text(rect, @actor.skill_basic_level(skill.id).to_s, 2)
    change_color(system_color, enable?(skill))
    draw_text(rect, "Lv.  ", 2)
  end
  
  def update_help
    @help_window.set_item(item)
  end
  
  def refresh
    make_item_list
    create_contents
    draw_all_items
  end
end

class Window_Base < Window

#~ draw_text_ex的增强,使其可以自动换行  原作者:叶子 修改:wyongcan
  #--------------------------------------------------------------------------
  # ● 绘制带有控制符的文本内容
  #   如果传递了width参数的话,会自动换行
  #--------------------------------------------------------------------------
  def draw_text_ex(x, y, text, width = nil,textwidth = nil,normalfont = true)
    reset_font_settings if normalfont == true
    text = convert_escape_characters(text)
    pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)}
    if width != nil
      pos[:height] = contents.font.size
      pos[:width] = width
      pos[:textwidth] = textwidth
    end
    process_character(text.slice!(0, 1), text, pos) until text.empty?
  end
  #--------------------------------------------------------------------------
  # ● 文字的处理
  #     c    : 文字
  #     text : 绘制处理中的字符串缓存(字符串可能会被修改)
  #     pos  : 绘制位置 {:x, :y, :new_x, :height}
  #--------------------------------------------------------------------------
  def process_character(c, text, pos)
    case c
    when "\r"   # 回车
      return
    when "\n"   # 换行
      process_new_line(text, pos)
    when "\f"   # 翻页
      process_new_page(text, pos)
    when "\e"   # 控制符
      process_escape_character(obtain_escape_code(text), text, pos)
    else        # 普通文字
      pos[:textwidth] == nil ? text_width = text_size(c).width : text_width = pos[:textwidth]
      if pos[:width] != nil && pos[:x] - pos[:new_x] + text_width > pos[:width]
        process_new_line(text, pos)
      end
      process_normal_character(c, pos)
    end
  end
end

class Window_SkillStatus < Window_Base
  
  def initialize(x, y)
    super(x, y, window_width, fitting_height(4))
    @actor = nil
  end
  
  def window_width
    Graphics.width - 160
  end
  
  def actor=(actor)
    return if @actor == actor
    @actor = actor
    refresh
  end

  def draw_actor_sp(actor,x,y)
    change_color(system_color)
    draw_text(x, y, 200, line_height, "SP:")
    change_color(normal_color)
    draw_text(x+48, y, 200, line_height, actor.sp)
  end
  
  def refresh
    contents.clear
    return unless @actor
    draw_actor_face(@actor, 0, 0)
    draw_actor_simple_status(@actor, 108, line_height / 2)
    draw_actor_sp(@actor,108,64)
  end
end



class Window_AddHelp < Window_Base
  def initialize(x, y, width, height)
    super
    @skill = nil
    @actor = nil
    refresh
  end

  def set_item(skill)
    return if @skill == skill
    @skill = skill
    refresh
  end
  
  def actor=(actor)
    return if @actor == actor
    @actor = actor
    refresh
  end
  def line_width
    Graphics.width/2-standard_padding*2
  end
  def draw_skill_name(skill,x,y)
    draw_icon(skill.icon_index, x, y)
    change_color(normal_color)
    draw_text(x+24, y, line_width, line_height, skill.name)
    if skill.passive
      draw_text(x, y, line_width, line_height, "被动技能",2)
    else
      change_color(mp_cost_color)
      draw_text(x, y, line_width, line_height, "MP "+@actor.skill_mp_cost(skill).to_s,2)
    end
  end
  
  def draw_skill_level(skill,x,y)
    change_color(system_color)
    draw_text(x, y, line_width, line_height,"Level ")
    text =@actor.skill_basic_level(skill.id).to_s + "/"+skill.max_learn.to_s
    change_color(normal_color)
    draw_text(x+60, y, line_width-60, line_height,text)
    draw_text(x, y, line_width, line_height,"升级所需SP: "+skill.sp_cost.to_s,2)
  end
  def draw_next_level(skill,x,y)
    if skill.link_skill != 0
      change_color(knockout_color)
      draw_text(x, y, line_width, line_height,"绑定技能:"+$data_skills[skill.link_skill].name)
      return
    end
    lvl = @actor.skill_next_level(skill)
    if !lvl
      change_color(system_color)
      draw_text(x, y, line_width, line_height,"已精通。")
    else
      if @actor.level >= @actor.skill_next_level(skill)
        change_color(normal_color)
      else
        change_color(crisis_color)
      end
      #draw_text(x, y, line_width, line_height,"需要等级: "+lvl.to_s)
    end
  end
  def draw_former_skill(skill,x,y)
    line = 0
    skill.former.each do |former|
      if former[0] != 0
        txt = "需要: " + $data_skills[former[0]].name + "|Lv.#{former[1]}"
        @actor.skill_basic_level(former[0]) >= former[1] ? change_color(system_color) : change_color(crisis_color)
        draw_text(x, y+line*line_height, line_width, line_height,txt)
        line += 1
      end
    end
    line
  end
  def refresh
    contents.clear
    return if @skill == nil or @actor == nil
    draw_skill_name(@skill,0,0)
    draw_skill_level(@skill,0,line_height)
    draw_next_level(@skill,0,line_height*2)
    n = draw_former_skill(@skill,0,line_height*3)
    draw_text_ex(0, line_height*(3+n), @skill.description, line_width)
  end
  
end



#==============================================================================
# ■ Window_AddCommand
#------------------------------------------------------------------------------
#  
#==============================================================================
class Window_AddCommand < Window_Command
  
  def initialize
    super(100, 120)
    self.visible = false
    self.active = false
    @index = 0
  end
  #--------------------------------------------------------------------------
  # ● コマンドリストの作成
  #--------------------------------------------------------------------------
  def make_command_list
    add_command("提升一级",   :add1)
    add_command("提升满",    :addf)
    add_command("取消",    :cancel)
  end
  #--------------------------------------------------------------------------
  # ● 決定ボタンが押されたときの処理
  #--------------------------------------------------------------------------
  def process_ok
    Input.update
    call_ok_handler
  end
  #--------------------------------------------------------------------------
  # ● 按下取消键时的处理
  #--------------------------------------------------------------------------
  def process_cancel
    Input.update
    call_cancel_handler
  end
  #--------------------------------------------------------------------------
  # ● 启用窗口
  #--------------------------------------------------------------------------
  def activate
    temp = self.y + self.height - Graphics.height
    if temp > 0
      self.y -= Graphics.height - self.height
    end
    self.active = true
    self
  end
end[/pre]
QQ截图333320190418195633.jpg

技能升级.rar

1.52 MB, 下载次数: 91

梦石
10
星屑
39550
在线时间
1919 小时
注册时间
2010-11-14
回帖
3214

R考场第七期纪念奖

发表于 2019-4-19 22:42:35 | 显示全部楼层
原来的31行是
[pre lang="ruby"]draw_text(x + 24, y, width, line_height, item.name + "|Lv." + @actor.skill_level(item.id).to_s)[/pre]
现在修改成如下两行
[pre lang="ruby"]skill_level = [1, @actor.skill_level(item.id)].max
draw_text(x + 24, y, width, line_height, item.name + "|Lv." + skill_level.to_s)[/pre]

点评

fjm
感谢KB大神,终于解决了这个问题了  发表于 2019-4-20 09:44
fjm
说错了是111行和113行  发表于 2019-4-20 09:24
fjm
我看了下,估计111行和131行可能也要修改下,帮忙看下怎么改,谢谢  发表于 2019-4-20 09:24
fjm
非常感谢,但我改了31行,还是显示LV 0,麻烦帮忙再看下  发表于 2019-4-19 23:32
对了,这个只是让0级变成1级,1级以后并没有+1.要达到那个效果的话可以把下面第一行写成skill_level = @actor.skill_level(item.id) + 1  发表于 2019-4-19 22:59

评分

参与人数 2星屑 +50 赞 +1 收起 理由
VIPArcher + 50 认可答案
fjm + 1 认可答案

查看全部评分

用头画头像,用脚写脚本
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部