Project1

标题: 技能信息详细显示help窗口显示技能描述 [打印本页]

作者: 契约师Vi    时间: 6 天前
标题: 技能信息详细显示help窗口显示技能描述

如图:原本的文字不见了,想要重新显示原来的文本。再次表示感谢各位大佬
下面是脚本:
RUBY 代码复制
  1. #==============================================================================
  2. # ☆技能信息详细显示☆
  3. #------------------------------------------------------------------------------
  4. #  by -> 芯☆淡茹水
  5. #==============================================================================
  6. #  复制该脚本,插入到 main 前。
  7. #==============================================================================
  8. # 系统文字颜色
  9. SKILL_SYSTEM_COLOR = Color.new(192, 224, 255)
  10. # 技能名颜色
  11. SKILL_NAME_COLOR = Color.new(255, 128, 255)
  12. # 技能属性值颜色
  13. SKILL_RES_COLOR = Color.new(128, 255, 128)
  14. # 角色属性名称颜色
  15. SKILL_EM_COLOR = Color.new(255, 255, 128)
  16. # 技能说明颜色
  17. SKILL_TXT_COLOR = Color.new(128, 255, 255)
  18. #==============================================================================
  19. class Window_Skill_Help < Window_Base
  20.   #--------------------------------------------------------------------------
  21.   def initialize
  22.     super(396, 4, 240, 472)
  23.     self.contents = Bitmap.new(width - 32, height - 32)
  24.     self.z = 999
  25.     self.back_opacity = 220
  26.     self.visible = false
  27.   end
  28.   #--------------------------------------------------------------------------
  29.   def set_skill(skill_id, actor_id)
  30.     self.contents.clear
  31.     if skill_id == nil or actor_id == nil
  32.       return
  33.     end
  34.     skill = $data_skills[skill_id]
  35.     actor = $game_actors[actor_id]
  36.     x = y = 0
  37.     # 技能图标
  38.     bitmap = RPG::Cache.icon(skill.icon_name)
  39.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), 255)
  40.     # 技能名
  41.     self.contents.font.color = SKILL_NAME_COLOR
  42.     self.contents.font.size = 18
  43.     cx = contents.text_size(skill.name).width
  44.     self.contents.draw_text(x + 38, y, cx, 32, skill.name)
  45.     # 技能等级
  46.     level = actor.skill_level(skill.id)
  47.     n = (level + 1) / 2
  48.     name = "l" + n.to_s
  49.     for i in 0...level
  50.       bitmap = RPG::Cache.icon(name)
  51.       self.contents.blt(x + i * 20, y + 30, bitmap, Rect.new(0, 0, 20, 20), 255)
  52.     end
  53.     # 技能类型
  54.     if [5, 6].include?(skill.scope)
  55.       name = "skill_b"
  56.     elsif skill.atk_f > 0
  57.       name = "skill_a"
  58.     elsif skill.power > 0
  59.       name = "skill_m"
  60.     elsif skill.power < 0
  61.       name = "skill_r"
  62.     else
  63.       name = "skill_o"
  64.     end
  65.     bitmap = RPG::Cache.icon(name)
  66.     self.contents.blt(self.width - 60, y + 3, bitmap, Rect.new(0, 0, 24, 24), 255)
  67.     # 熟练度
  68.     self.contents.font.color = SKILL_SYSTEM_COLOR
  69.     self.contents.font.size = 16
  70.     self.contents.draw_text(x, y + 55, 64, 28, "熟练度:")
  71.     if skill.power != 0 or skill.atk_f != 0
  72.       txt = actor.skill_proficiency[skill.id].to_s
  73.     else
  74.       txt = "——"
  75.     end
  76.     cx = contents.text_size(txt).width
  77.     self.contents.font.color = SKILL_RES_COLOR
  78.     self.contents.draw_text(x + 64, y + 55, cx, 28, txt)
  79.     self.contents.font.color = SKILL_SYSTEM_COLOR
  80.     self.contents.draw_text(x + 66 + cx, y + 55, 28, 28, "/")
  81.     if actor.skill_level(skill.id) >= 10 or (skill.power == 0 and skill.atk_f == 0)
  82.       txt = "——"
  83.     else
  84.       txt = SKILL_LEVEL[actor.skill_level(skill.id)].to_s
  85.     end
  86.     self.contents.draw_text(x + 76 + cx, y + 55, 28, 28, txt)
  87.     # 消耗 SP
  88.     y += 77
  89.     self.contents.font.color = SKILL_SYSTEM_COLOR
  90.     txt = "消耗" + $data_system.words.sp + ":"
  91.     cx = contents.text_size(txt).width
  92.     self.contents.draw_text(x, y, cx, 28, txt)
  93.     self.contents.font.color = SKILL_RES_COLOR
  94.     self.contents.draw_text(x + cx + 6, y, 96, 28, skill.sp_cost.to_s)
  95.     # 效果范围
  96.     y += 22
  97.     self.contents.font.color = SKILL_SYSTEM_COLOR
  98.     self.contents.draw_text(x, y, 94, 28, "效果范围:")
  99.     scopes = ["——。", "敌单体。", "敌全体。", "己方单体。", "己方全体。",
  100.              "己方单体(HP 0)。", "己方全体(HP 0)。", "使用者。"]
  101.     txt = scopes[skill.scope]
  102.     self.contents.font.color = SKILL_RES_COLOR
  103.     cx = contents.text_size(txt).width
  104.     self.contents.draw_text(x + 84, y, cx, 28, txt)
  105.     # 命中率
  106.     y += 32
  107.     self.contents.font.color = SKILL_SYSTEM_COLOR
  108.     self.contents.draw_text(x + 104, y, 86, 28, "命中率:")
  109.     self.contents.font.color = SKILL_RES_COLOR
  110.     self.contents.draw_text(x + 166, y, 64, 28, skill.hit.to_s + " %")
  111.     # 威力
  112.     self.contents.font.color = SKILL_SYSTEM_COLOR
  113.     self.contents.draw_text(x, y, 46, 28, "威力:")
  114.     self.contents.font.color = SKILL_RES_COLOR
  115.     txt = skill.power != 0 ? skill.power.to_s : "——"
  116.     self.contents.draw_text(x + 62, y, 64, 28, txt)
  117.     # 攻击力
  118.     y += 20
  119.     self.contents.font.color = SKILL_SYSTEM_COLOR
  120.     self.contents.draw_text(x, y, 66, 28, "攻击力:")
  121.     self.contents.font.color = SKILL_RES_COLOR
  122.     txt = skill.atk_f > 0 ? skill.atk_f.to_s : "——"
  123.     self.contents.draw_text(x + 62, y, 66, 28, txt)
  124.     # 属性相关
  125.     y += 28
  126.     self.contents.font.color = SKILL_SYSTEM_COLOR
  127.     self.contents.draw_text(x, y, 124, 28, "角色属性关联:")
  128.     names = [$data_system.words.str + ":", $data_system.words.dex + ":",
  129.             $data_system.words.agi + ":", $data_system.words.int + ":"]
  130.     elementes = [skill.str_f, skill.dex_f, skill.agi_f, skill.int_f]
  131.     text = [skill.str_f.to_s + " %", skill.dex_f.to_s + " %",
  132.           skill.agi_f.to_s + " %", skill.int_f.to_s + " %"]
  133.     bitnames = ["str_s", "dex_s","agi_s","int_s"]
  134.     for i in 0...names.size
  135.       next if elementes[i] == 0
  136.       y += 30
  137.       name = names[i]
  138.       self.contents.font.size = 16
  139.       self.contents.font.color = SKILL_EM_COLOR
  140.       cx = contents.text_size(name).width
  141.       self.contents.draw_text(x, y, cx, 28, name)
  142.       name = bitnames[i]
  143.       bitmap = RPG::Cache.icon(name)
  144.       width = bitmap.width * elementes[i] / 100
  145.       rect = Rect.new(0, 0, width, bitmap.height)
  146.       self.contents.blt(x + cx + 3, y + 8, bitmap, rect, 255)
  147.       bitmap = RPG::Cache.icon("e0")
  148.       rect = Rect.new(0, 0, bitmap.width, bitmap.height)
  149.       self.contents.blt(x + cx + 2, y + 6, bitmap, rect, 255)
  150.       self.contents.font.size = 14
  151.       self.contents.font.color = SKILL_RES_COLOR
  152.       self.contents.draw_text(x + 110 + cx, y, 64, 28, text[i])
  153.     end
  154.     self.contents.font.size = 16
  155.     # 属性攻击
  156.     if skill.element_set != []
  157.       y += 30
  158.       self.contents.font.color = SKILL_SYSTEM_COLOR
  159.       self.contents.draw_text(x, y, 86, 28, "属性攻击:")
  160.       self.contents.font.color = SKILL_RES_COLOR
  161.       self.contents.font.size = 14
  162.       nx = 80
  163.       for i in 0...skill.element_set.size
  164.         name = $data_system.elements[skill.element_set[i]]
  165.         name = i == (skill.element_set.size - 1) ? name : name + ","
  166.         cx = contents.text_size(name).width
  167.         if nx + cx > self.width - 32
  168.           nx = 80
  169.           y += 16
  170.         end
  171.         self.contents.draw_text(nx, y, cx, 28, name)
  172.         nx += cx
  173.       end
  174.     else
  175.       y += 10
  176.     end
  177.     # 附加状态
  178.     self.contents.font.size = 16
  179.     if skill.plus_state_set != []
  180.       y += 20
  181.       self.contents.font.color = SKILL_SYSTEM_COLOR
  182.       self.contents.draw_text(x, y, 86, 28, "附加状态:")
  183.       self.contents.font.color = SKILL_RES_COLOR
  184.       nx = 80
  185.       self.contents.font.size = 14
  186.       for i in 0...skill.plus_state_set.size
  187.         name = $data_states[skill.plus_state_set[i]].name
  188.         name = i == (skill.plus_state_set.size - 1) ? name : name + ","
  189.         cx = contents.text_size(name).width
  190.         if nx + cx > self.width - 32
  191.           nx = 80
  192.           y += 16
  193.         end
  194.         self.contents.draw_text(nx, y, cx, 28, name)
  195.         nx += cx
  196.       end
  197.     end
  198.     # 解除状态
  199.     self.contents.font.size = 16
  200.     if skill.minus_state_set != []
  201.       y += 20
  202.       self.contents.font.color = SKILL_SYSTEM_COLOR
  203.       self.contents.draw_text(x, y, 86, 28, "解除状态:")
  204.       self.contents.font.color = SKILL_RES_COLOR
  205.       nx = 80
  206.       self.contents.font.size = 14
  207.       for i in 0...skill.minus_state_set.size
  208.         name = $data_states[skill.minus_state_set[i]].name
  209.         name = i == (skill.minus_state_set.size - 1) ? name : name + ","
  210.         cx = contents.text_size(name).width
  211.         if nx + cx > self.width - 32
  212.           nx = 80
  213.           y += 16
  214.         end
  215.         self.contents.draw_text(nx, y, cx, 28, name)
  216.         nx += cx
  217.       end
  218.     end
  219.     # 说明
  220.     self.contents.font.size = 16
  221.     x = 14
  222.     y += 30
  223.     self.contents.font.size = 14
  224.     self.contents.font.color = SKILL_TXT_COLOR
  225.     text = skill.description.scan(/./)
  226.     for i in 0...text.size
  227.       txt = text[i]
  228.       cx = contents.text_size(txt).width
  229.       if (x + cx) > self.width - 32
  230.         x = 0
  231.         y += 16
  232.         break if (y + 16) > self.height - 32
  233.       end
  234.       self.contents.draw_text(x, y, cx, 16, txt)
  235.       x += cx
  236.     end
  237.     self.height  = [y + 48, 472].min
  238.   end
  239. end
  240. #=============================================================================
  241. class Window_Skill < Window_Selectable
  242.   #--------------------------------------------------------------------------
  243.   # ● 初始化对像
  244.   #     actor : 角色
  245.   #--------------------------------------------------------------------------
  246.   def initialize(actor)
  247.     super(0, 64, 640, 416)
  248.     @actor = actor
  249.     @column_max = 2
  250.     refresh
  251.     self.index = 0
  252.     # 战斗中的情况下将窗口移至中央并将其半透明化
  253.     if $game_temp.in_battle
  254.       self.y = 0
  255.       self.height = 320
  256.       self.back_opacity = 160
  257.     end
  258.   end
  259. end
  260. #==============================================================================
  261. class Window_SkillStatus < Window_Base
  262.   #--------------------------------------------------------------------------
  263.   # ● 初始化对像
  264.   #     actor : 角色
  265.   #--------------------------------------------------------------------------
  266.   def initialize(actor)
  267.     super(0, 0, 640, 64)
  268.     self.contents = Bitmap.new(width - 32, height - 32)
  269.     @actor = actor
  270.     refresh
  271.   end
  272. end
  273. #=============================================================================
  274. class Scene_Skill
  275.   #--------------------------------------------------------------------------
  276.   def main
  277.     # 获取角色
  278.     @actor = $game_party.actors[@actor_index]
  279.     # 生成帮助窗口、状态窗口、特技窗口
  280.     @help_window = Window_Skill_Help.new
  281.     @status_window = Window_SkillStatus.new(@actor)
  282.     @skill_window = Window_Skill.new(@actor)
  283.     # 生成目标窗口 (设置为不可见・不活动)
  284.     @target_window = Window_Target.new
  285.     @target_window.visible = false
  286.     @target_window.active = false
  287.     # 执行过渡
  288.     Graphics.transition
  289.     # 主循环
  290.     loop do
  291.       # 刷新游戏画面
  292.       Graphics.update
  293.       # 刷新输入信息
  294.       Input.update
  295.       # 刷新画面
  296.       update
  297.       # 如果画面切换的话就中断循环
  298.       if $scene != self
  299.         break
  300.       end
  301.     end
  302.     # 准备过渡
  303.     Graphics.freeze
  304.     # 释放窗口
  305.     @help_window.dispose
  306.     @status_window.dispose
  307.     @skill_window.dispose
  308.     @target_window.dispose
  309.   end
  310.   #--------------------------------------------------------------------------
  311.   alias add_update_skill_xdrs update_skill
  312.   def update_skill
  313.     @help_window.x = (@skill_window.index + 1) % 2 * 392 + 4
  314.     @help_window.set_skill(@skill_window.skill.id, @actor.id)
  315.     @help_window.visible = true
  316.     add_update_skill_xdrs
  317.   end
  318.   #--------------------------------------------------------------------------
  319.   alias add_update_target_xdrs update_target
  320.   def update_target
  321.     @help_window.visible = false
  322.     add_update_target_xdrs
  323.   end
  324. end
  325. #============================================================================
  326. class Scene_Battle
  327.   #--------------------------------------------------------------------------
  328.   # ● 主处理
  329.   #--------------------------------------------------------------------------
  330.   def main
  331.     # 初始化战斗用的各种暂时数据
  332.     $game_temp.in_battle = true
  333.     $game_temp.battle_turn = 0
  334.     $game_temp.battle_event_flags.clear
  335.     $game_temp.battle_abort = false
  336.     $game_temp.battle_main_phase = false
  337.     $game_temp.battleback_name = $game_map.battleback_name
  338.     $game_temp.forcing_battler = nil
  339.     # 初始化战斗用事件解释器
  340.     $game_system.battle_interpreter.setup(nil, 0)
  341.     # 准备队伍
  342.     @troop_id = $game_temp.battle_troop_id
  343.     $game_troop.setup(@troop_id)
  344.     # 生成角色命令窗口
  345.     s1 = $data_system.words.attack
  346.     s2 = $data_system.words.skill
  347.     s3 = $data_system.words.guard
  348.     s4 = $data_system.words.item
  349.     @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4])
  350.     @actor_command_window.y = 160
  351.     @actor_command_window.back_opacity = 160
  352.     @actor_command_window.active = false
  353.     @actor_command_window.visible = false
  354.     # 生成其它窗口
  355.     @party_command_window = Window_PartyCommand.new
  356.     @help_window = Window_Help.new
  357.     @help_window.back_opacity = 160
  358.     @help_window.visible = false
  359.     @status_window = Window_BattleStatus.new
  360.     @message_window = Window_Message.new
  361.     @skill_help_window = Window_Skill_Help.new
  362.     # 生成活动块
  363.     @spriteset = Spriteset_Battle.new
  364.     # 初始化等待计数
  365.     @wait_count = 0
  366.     # 执行过渡
  367.     if $data_system.battle_transition == ""
  368.       Graphics.transition(20)
  369.     else
  370.       Graphics.transition(40, "Graphics/Transitions/" +
  371.         $data_system.battle_transition)
  372.     end
  373.     # 开始自由战斗回合
  374.     start_phase1
  375.     # 主循环
  376.     loop do
  377.       # 刷新游戏画面
  378.       Graphics.update
  379.       # 刷新输入信息
  380.       Input.update
  381.       # 刷新画面
  382.       update
  383.       # 如果画面切换的话就中断循环
  384.       if $scene != self
  385.         break
  386.       end
  387.     end
  388.     # 刷新地图
  389.     $game_map.refresh
  390.     # 准备过渡
  391.     Graphics.freeze
  392.     # 释放窗口
  393.     @actor_command_window.dispose
  394.     @party_command_window.dispose
  395.     @help_window.dispose
  396.     @status_window.dispose
  397.     @message_window.dispose
  398.     @skill_help_window.dispose
  399.     if @skill_window != nil
  400.       @skill_window.dispose
  401.     end
  402.     if @item_window != nil
  403.       @item_window.dispose
  404.     end
  405.     if @result_window != nil
  406.       @result_window.dispose
  407.     end
  408.     # 释放活动块
  409.     @spriteset.dispose
  410.     # 标题画面切换中的情况
  411.     if $scene.is_a?(Scene_Title)
  412.       # 淡入淡出画面
  413.       Graphics.transition
  414.       Graphics.freeze
  415.     end
  416.     # 战斗测试或者游戏结束以外的画面切换中的情况
  417.     if $BTEST and not $scene.is_a?(Scene_Gameover)
  418.       $scene = nil
  419.     end
  420.   end
  421.   #--------------------------------------------------------------------------
  422.   alias add_update_phase3_skill_select_xdrs update_phase3_skill_select
  423.   def update_phase3_skill_select
  424.     @help_window.visible = true
  425.     @skill_help_window.x = (@skill_window.index + 1) % 2 * 392 + 4
  426.     @skill_help_window.set_skill(@skill_window.skill.id, @active_battler.id)
  427.     @skill_help_window.visible = true
  428.     add_update_phase3_skill_select_xdrs
  429.   end
  430.   #--------------------------------------------------------------------------
  431.   def start_skill_select
  432.     # 生成特技窗口
  433.     @skill_window = Window_Skill.new(@active_battler)
  434.     # 无效化角色指令窗口
  435.     @actor_command_window.active = false
  436.     @actor_command_window.visible = false
  437.   end
  438.    #--------------------------------------------------------------------------
  439.   alias add_start_enemy_select_xdrs start_enemy_select
  440.   def start_enemy_select
  441.     @skill_help_window.visible = false
  442.     add_start_enemy_select_xdrs
  443.   end
  444.   #--------------------------------------------------------------------------
  445.   alias add_end_enemy_select_xdrs end_enemy_select
  446.   def end_enemy_select
  447.     @help_window.visible = false
  448.     add_end_enemy_select_xdrs
  449.   end
  450.   #--------------------------------------------------------------------------
  451.   alias add_start_actor_select_xdrs start_actor_select
  452.   def start_actor_select
  453.     @skill_help_window.visible = false
  454.     add_start_actor_select_xdrs
  455.   end
  456.   #--------------------------------------------------------------------------
  457.   alias add_end_actor_select_xdrs end_actor_select
  458.   def end_actor_select
  459.     @help_window.visible = false
  460.     add_end_actor_select_xdrs
  461.   end
  462.   #--------------------------------------------------------------------------
  463.   alias add_end_skill_select_xdrs end_skill_select
  464.   def end_skill_select
  465.     @skill_help_window.visible = false
  466.     add_end_skill_select_xdrs
  467.   end
  468. end
  469. #=============================================================================






欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1