查看: 3590|回复: 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的方法实现,但不知道应该加在哪里
自己试了半天也没成功,知道的告诉下,谢谢


  1. #encoding:utf-8
  2. #===========================================================================
  3. #          RMVA 豪华型技能加点|技能被动效果:      v1.05
  4. #                       By希忆 66rpg.com
  5. #                                                 转载或修改请保留此类信息
  6. #===========================================================================
  7. # 所有和窗体有关的修改
  8. #
  9. # 大概没问题吧
  10. #===========================================================================


  11. class Window_BattleSkill < Window_SkillList
  12.   
  13.   def include?(item)
  14.     item && !item.passive && item.stype_id == @stype_id && @actor.has_skill?(item)
  15.   end
  16.   
  17. end

  18. class Window_SkillList < Window_Selectable

  19.   def include?(item)
  20.     item && item.stype_id == @stype_id && @actor.has_skill?(item)
  21.   end
  22.   
  23.   def draw_item_name(item, x, y, enabled = true, width = 172)
  24.     return unless item
  25.     draw_icon(item.icon_index, x, y, enabled)
  26.     change_color(normal_color, enabled)
  27.     draw_text(x + 24, y, width, line_height, item.name + "|Lv." + @actor.skill_level(item.id).to_s)
  28.   end
  29.   
  30. end

  31. class Window_AllSkill < Window_Selectable

  32.   def initialize(x, y, width, height)
  33.     super
  34.     @actor = nil
  35.     @stype_id = 0
  36.     @data = []
  37.   end
  38.   
  39.   def actor=(actor)
  40.     return if @actor == actor
  41.     @actor = actor
  42.     refresh
  43.     self.oy = 0
  44.   end

  45.   def stype_id=(stype_id)
  46.     return if @stype_id == stype_id
  47.     @stype_id = stype_id
  48.     refresh
  49.     self.oy = 0
  50.   end
  51.   
  52.   def col_max
  53.     return 1
  54.   end
  55.   
  56.   def item_max
  57.     @data ? @data.size : 1
  58.   end
  59.   
  60.   def item
  61.     @data && index >= 0 ? @data[index] : nil
  62.   end
  63.   
  64.   def current_item_enabled?
  65.     enable?(@data[index])
  66.   end
  67.   
  68.   def include?(item)
  69.     item && item.stype_id == @stype_id
  70.   end
  71.   
  72.   def enable?(item)
  73.     item != nil && @actor != nil && @actor.skill_can_levelup?(item)
  74.   end

  75.   def make_item_list
  76.     @data = @actor ? @actor.skills.select {|skill| include?(skill) } : []
  77.   end
  78.   
  79.   def select_last
  80.     select(@data.index(@actor.last_skill.object) || 0)
  81.   end
  82.   
  83.   def draw_item(index)
  84.     skill = @data[index]
  85.     if skill
  86.       rect = item_rect(index)
  87.       rect.width -= 4
  88.       draw_skill_name(skill, rect.x, rect.y, enable?(skill))
  89.       draw_skill_level(rect, skill)
  90.     end
  91.   end
  92.   
  93.   def draw_skill_name(skill, x, y, enabled = true, width = 172)
  94.     return unless skill
  95.     draw_icon(skill.icon_index, x, y, enabled)
  96.     change_color(normal_color, enabled)
  97.     text = skill.name
  98.     text += "<MAX>" if @actor.skill_max_learn?(skill)
  99.     draw_text(x + 24, y, width, line_height, text)
  100.   end
  101.   
  102.   def draw_skill_level(rect, skill)
  103.     draw_text(rect, @actor.skill_basic_level(skill.id).to_s, 2)
  104.     change_color(system_color, enable?(skill))
  105.     draw_text(rect, "Lv.  ", 2)
  106.   end
  107.   
  108.   def update_help
  109.     @help_window.set_item(item)
  110.   end
  111.   
  112.   def refresh
  113.     make_item_list
  114.     create_contents
  115.     draw_all_items
  116.   end
  117. end

  118. class Window_Base < Window

  119. #~ draw_text_ex的增强,使其可以自动换行  原作者:叶子 修改:wyongcan
  120.   #--------------------------------------------------------------------------
  121.   # ● 绘制带有控制符的文本内容
  122.   #   如果传递了width参数的话,会自动换行
  123.   #--------------------------------------------------------------------------
  124.   def draw_text_ex(x, y, text, width = nil,textwidth = nil,normalfont = true)
  125.     reset_font_settings if normalfont == true
  126.     text = convert_escape_characters(text)
  127.     pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)}
  128.     if width != nil
  129.       pos[:height] = contents.font.size
  130.       pos[:width] = width
  131.       pos[:textwidth] = textwidth
  132.     end
  133.     process_character(text.slice!(0, 1), text, pos) until text.empty?
  134.   end
  135.   #--------------------------------------------------------------------------
  136.   # ● 文字的处理
  137.   #     c    : 文字
  138.   #     text : 绘制处理中的字符串缓存(字符串可能会被修改)
  139.   #     pos  : 绘制位置 {:x, :y, :new_x, :height}
  140.   #--------------------------------------------------------------------------
  141.   def process_character(c, text, pos)
  142.     case c
  143.     when "\r"   # 回车
  144.       return
  145.     when "\n"   # 换行
  146.       process_new_line(text, pos)
  147.     when "\f"   # 翻页
  148.       process_new_page(text, pos)
  149.     when "\e"   # 控制符
  150.       process_escape_character(obtain_escape_code(text), text, pos)
  151.     else        # 普通文字
  152.       pos[:textwidth] == nil ? text_width = text_size(c).width : text_width = pos[:textwidth]
  153.       if pos[:width] != nil && pos[:x] - pos[:new_x] + text_width > pos[:width]
  154.         process_new_line(text, pos)
  155.       end
  156.       process_normal_character(c, pos)
  157.     end
  158.   end
  159. end

  160. class Window_SkillStatus < Window_Base
  161.   
  162.   def initialize(x, y)
  163.     super(x, y, window_width, fitting_height(4))
  164.     @actor = nil
  165.   end
  166.   
  167.   def window_width
  168.     Graphics.width - 160
  169.   end
  170.   
  171.   def actor=(actor)
  172.     return if @actor == actor
  173.     @actor = actor
  174.     refresh
  175.   end

  176.   def draw_actor_sp(actor,x,y)
  177.     change_color(system_color)
  178.     draw_text(x, y, 200, line_height, "SP:")
  179.     change_color(normal_color)
  180.     draw_text(x+48, y, 200, line_height, actor.sp)
  181.   end
  182.   
  183.   def refresh
  184.     contents.clear
  185.     return unless @actor
  186.     draw_actor_face(@actor, 0, 0)
  187.     draw_actor_simple_status(@actor, 108, line_height / 2)
  188.     draw_actor_sp(@actor,108,64)
  189.   end
  190. end



  191. class Window_AddHelp < Window_Base
  192.   def initialize(x, y, width, height)
  193.     super
  194.     @skill = nil
  195.     @actor = nil
  196.     refresh
  197.   end

  198.   def set_item(skill)
  199.     return if @skill == skill
  200.     @skill = skill
  201.     refresh
  202.   end
  203.   
  204.   def actor=(actor)
  205.     return if @actor == actor
  206.     @actor = actor
  207.     refresh
  208.   end
  209.   def line_width
  210.     Graphics.width/2-standard_padding*2
  211.   end
  212.   def draw_skill_name(skill,x,y)
  213.     draw_icon(skill.icon_index, x, y)
  214.     change_color(normal_color)
  215.     draw_text(x+24, y, line_width, line_height, skill.name)
  216.     if skill.passive
  217.       draw_text(x, y, line_width, line_height, "被动技能",2)
  218.     else
  219.       change_color(mp_cost_color)
  220.       draw_text(x, y, line_width, line_height, "MP "+@actor.skill_mp_cost(skill).to_s,2)
  221.     end
  222.   end
  223.   
  224.   def draw_skill_level(skill,x,y)
  225.     change_color(system_color)
  226.     draw_text(x, y, line_width, line_height,"Level ")
  227.     text =@actor.skill_basic_level(skill.id).to_s + "/"+skill.max_learn.to_s
  228.     change_color(normal_color)
  229.     draw_text(x+60, y, line_width-60, line_height,text)
  230.     draw_text(x, y, line_width, line_height,"升级所需SP: "+skill.sp_cost.to_s,2)
  231.   end
  232.   def draw_next_level(skill,x,y)
  233.     if skill.link_skill != 0
  234.       change_color(knockout_color)
  235.       draw_text(x, y, line_width, line_height,"绑定技能:"+$data_skills[skill.link_skill].name)
  236.       return
  237.     end
  238.     lvl = @actor.skill_next_level(skill)
  239.     if !lvl
  240.       change_color(system_color)
  241.       draw_text(x, y, line_width, line_height,"已精通。")
  242.     else
  243.       if @actor.level >= @actor.skill_next_level(skill)
  244.         change_color(normal_color)
  245.       else
  246.         change_color(crisis_color)
  247.       end
  248.       #draw_text(x, y, line_width, line_height,"需要等级: "+lvl.to_s)
  249.     end
  250.   end
  251.   def draw_former_skill(skill,x,y)
  252.     line = 0
  253.     skill.former.each do |former|
  254.       if former[0] != 0
  255.         txt = "需要: " + $data_skills[former[0]].name + "|Lv.#{former[1]}"
  256.         @actor.skill_basic_level(former[0]) >= former[1] ? change_color(system_color) : change_color(crisis_color)
  257.         draw_text(x, y+line*line_height, line_width, line_height,txt)
  258.         line += 1
  259.       end
  260.     end
  261.     line
  262.   end
  263.   def refresh
  264.     contents.clear
  265.     return if @skill == nil or @actor == nil
  266.     draw_skill_name(@skill,0,0)
  267.     draw_skill_level(@skill,0,line_height)
  268.     draw_next_level(@skill,0,line_height*2)
  269.     n = draw_former_skill(@skill,0,line_height*3)
  270.     draw_text_ex(0, line_height*(3+n), @skill.description, line_width)
  271.   end
  272.   
  273. end



  274. #==============================================================================
  275. # ■ Window_AddCommand
  276. #------------------------------------------------------------------------------
  277. #  
  278. #==============================================================================
  279. class Window_AddCommand < Window_Command
  280.   
  281.   def initialize
  282.     super(100, 120)
  283.     self.visible = false
  284.     self.active = false
  285.     @index = 0
  286.   end
  287.   #--------------------------------------------------------------------------
  288.   # ● コマンドリストの作成
  289.   #--------------------------------------------------------------------------
  290.   def make_command_list
  291.     add_command("提升一级",   :add1)
  292.     add_command("提升满",    :addf)
  293.     add_command("取消",    :cancel)
  294.   end
  295.   #--------------------------------------------------------------------------
  296.   # ● 決定ボタンが押されたときの処理
  297.   #--------------------------------------------------------------------------
  298.   def process_ok
  299.     Input.update
  300.     call_ok_handler
  301.   end
  302.   #--------------------------------------------------------------------------
  303.   # ● 按下取消键时的处理
  304.   #--------------------------------------------------------------------------
  305.   def process_cancel
  306.     Input.update
  307.     call_cancel_handler
  308.   end
  309.   #--------------------------------------------------------------------------
  310.   # ● 启用窗口
  311.   #--------------------------------------------------------------------------
  312.   def activate
  313.     temp = self.y + self.height - Graphics.height
  314.     if temp > 0
  315.       self.y -= Graphics.height - self.height
  316.     end
  317.     self.active = true
  318.     self
  319.   end
  320. end
复制代码
QQ截图333320190418195633.jpg

技能升级.rar

1.52 MB, 下载次数: 91

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

R考场第七期纪念奖

发表于 2019-4-19 22:42:35 | 显示全部楼层
原来的31行是
  1. draw_text(x + 24, y, width, line_height, item.name + "|Lv." + @actor.skill_level(item.id).to_s)
复制代码

现在修改成如下两行
  1. skill_level = [1, @actor.skill_level(item.id)].max
  2. draw_text(x + 24, y, width, line_height, item.name + "|Lv." + skill_level.to_s)
复制代码

点评

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.

在本版发帖返回顶部