设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1536|回复: 3
打印 上一主题 下一主题

[已经过期] 技能分类角色各自分类名称,出错了,请高手帮忙

[复制链接]

Lv3.寻梦者

梦石
0
星屑
3176
在线时间
1442 小时
注册时间
2009-7-27
帖子
1454
跳转到指定楼层
1
发表于 2015-6-3 17:28:02 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 爆焰 于 2015-6-4 13:40 编辑

技能分类,我想不同的角色实现不同的技能分类,可是老是出错。
case @commands
   when 0
     s1 = "特技"
     s2 = "钢拳"
     s3 = "怒技"
  @commands = [s1, s2, s3]
   when 1
  s1 = "特技"
     s2 = "替身"
     s3 = "怒技"
  @commands = [s1, s2, s3]  
…………
这样写错了吗?
  1. #==============================================================================
  2. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  3. #==============================================================================

  4. #==============================================================================
  5. # ■ Liuliu_Window_SkillCommand
  6. #==============================================================================
  7. class Liuliu_Window_SkillCommand < Window_Selectable
  8. attr_accessor :commands
  9. #--------------------------------------------------------------------------
  10. # ● 初始化,生成commands窗口
  11. #--------------------------------------------------------------------------
  12.   def initialize(actor)
  13.   super(0, 0, 160, 288)
  14.   case @commands
  15.    when 0
  16.      s1 = "特技"
  17.      s2 = "钢拳"
  18.      s3 = "怒技"
  19.   @commands = [s1, s2, s3]
  20.    when 1
  21.   s1 = "特技"
  22.      s2 = "替身"
  23.      s3 = "怒技"
  24.   @commands = [s1, s2, s3]  
  25. end

  26.   #————————生成commands窗口
  27.   for i in 0...actor.skills.size
  28.     skill = $data_skills[actor.skills[i]]
  29.     if skill != nil  
  30.       push = true
  31.       for com in @commands
  32.         if com == skill.desc
  33.           push = false
  34.         end
  35.       end
  36.       if push == true
  37.         @commands.push(skill.desc)
  38.       end
  39.     end
  40.   end
  41.   if @commands == []
  42.     @commands.push("普通技能")
  43.   end      
  44.   @item_max = @commands.size
  45.   self.contents = Bitmap.new(width - 32, @item_max*32)
  46.   refresh
  47.   self.index = 0
  48. end
  49. #--------------------------------------------------------------------------
  50. #--------------------------------------------------------------------------
  51. def refresh
  52.    self.contents.clear
  53.    for i in 0...@item_max
  54.      draw_item(i, normal_color)
  55.    end
  56. end
  57. #--------------------------------------------------------------------------
  58. #--------------------------------------------------------------------------
  59. def draw_item(index, color)
  60.    self.contents.font.color = color
  61.    y = index * 32
  62.    self.contents.draw_text(4, y, 128, 32, @commands[index])
  63. end
  64. #--------------------------------------------------------------------------
  65. # 只描绘原文字
  66. #--------------------------------------------------------------------------
  67. def update_help
  68.    @help_window.set_text(@commands[self.index])
  69. end
  70. end
  71. #==============================================================================
  72. # ■ Window_Skill
  73. #==============================================================================
  74. class Liuliu_Window_SkillList < Window_Selectable
  75. #--------------------------------------------------------------------------
  76. #--------------------------------------------------------------------------
  77. def initialize(actor)
  78.    super(160, 0, 480, 416)
  79.    @actor = actor
  80.    refresh
  81.    self.index = 0
  82.    # 战斗中的情况下将窗口移至中央并将其半透明化
  83.    if $game_temp.in_battle
  84.      self.y = 64
  85.      self.height = 256
  86.      self.back_opacity = 160
  87.    end
  88. end
  89. #--------------------------------------------------------------------------
  90. #--------------------------------------------------------------------------
  91. def skill
  92.    return @data[self.index]
  93. end
  94. #--------------------------------------------------------------------------
  95. #--------------------------------------------------------------------------
  96. def refresh
  97.    if self.contents != nil
  98.      self.contents.dispose
  99.      self.contents = nil
  100.    end
  101.    @data = []
  102. end
  103. #--------------------------------------------------------------------------
  104. #--------------------------------------------------------------------------
  105. def set_item(command)
  106.    refresh
  107.    for i in [email protected]
  108.      skill = $data_skills[@actor.skills[i]]
  109.      if skill != nil and skill.desc == command
  110.        @data.push(skill)
  111.      end
  112.    end
  113.    @item_max = @data.size
  114.    if @item_max > 0
  115.      self.contents = Bitmap.new(width - 32, row_max * 32)
  116.      self.contents.clear
  117.      for i in 0...@item_max
  118.        draw_item(i)
  119.      end
  120.    end
  121. end
  122. #-----------------------------------------------------------------------
  123. #--------------------------------------------------------------------------
  124. def draw_item(index)
  125.    skill = @data[index]
  126.    if @actor.skill_can_use?(skill.id)
  127.      self.contents.font.color = normal_color
  128.    else
  129.      self.contents.font.color = disabled_color
  130.    end
  131.    x = 4
  132.    y = index * 32
  133.    rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  134.    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  135.    bitmap = RPG::Cache.icon(skill.icon_name)
  136.    opacity = self.contents.font.color == normal_color ? 255 : 128
  137.    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  138.    self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)
  139.    self.contents.draw_text(x + 390, y, 16, 32, ":", 1)
  140.    self.contents.draw_text(x + 400, y, 40, 32, skill.sp_cost.to_s, 2)
  141. end
  142. #--------------------------------------------------------------------------
  143. #--------------------------------------------------------------------------
  144. def update_help
  145.    @help_window.set_text(self.skill == nil ? "" : self.skill.description)
  146. end
  147. end
  148. #==============================================================================
  149. # ■ Liuliu_Scene_Skill
  150. #==============================================================================
  151. class Scene_Skill
  152. #--------------------------------------------------------------------------
  153. # ● 初始化对像
  154. #     actor_index : 角色索引
  155. #--------------------------------------------------------------------------
  156. def initialize(actor_index = 0)
  157.    @actor_index = actor_index
  158.    @actor = $game_party.actors[@actor_index]
  159. end
  160. #--------------------------------------------------------------------------
  161. #--------------------------------------------------------------------------
  162. def main
  163.    @status_window = Window_SkillStatus.new(@actor)
  164.    @itemcommand_window = Liuliu_Window_SkillCommand.new($game_party.actors[@actor_index])
  165.    @command_index = @itemcommand_window.index
  166.    @skill_window = Liuliu_Window_SkillList.new($game_party.actors[@actor_index])
  167.    @skill_window.active = false
  168.    @help_window = Window_Help.new
  169.    @help_window.x = 0
  170.    @help_window.y = 416
  171.    @itemcommand_window.help_window = @help_window
  172.    @skill_window.help_window = @help_window
  173.    @target_window = Window_Target.new
  174.    @target_window.visible = false
  175.    @target_window.active = false
  176.    @skill_window.set_item(@itemcommand_window.commands[@command_index])
  177.    Graphics.transition
  178.    loop do
  179.      Graphics.update
  180.      Input.update
  181.      update
  182.      if $scene != self
  183.        break
  184.      end
  185.    end
  186.    Graphics.freeze
  187.    @itemcommand_window.dispose
  188.    @skill_window.dispose
  189.    @status_window.dispose
  190.    @help_window.dispose
  191.    @target_window.dispose
  192. end
  193. #--------------------------------------------------------------------------
  194. #--------------------------------------------------------------------------
  195. def update
  196.    @itemcommand_window.update
  197.    @skill_window.update
  198.    @help_window.update
  199.    @target_window.update
  200.    if @command_index != @itemcommand_window.index
  201.      @command_index = @itemcommand_window.index
  202.      @skill_window.set_item(@itemcommand_window.commands[@command_index])
  203.    end
  204.    if @itemcommand_window.active
  205.      update_itemcommand
  206.      return
  207.    end
  208.    if @skill_window.active
  209.      update_itemlist
  210.      return
  211.    end
  212.    if @target_window.active
  213.      update_target
  214.      return
  215.    end
  216. end
  217. #--------------------------------------------------------------------------
  218. #--------------------------------------------------------------------------
  219. def update_itemcommand
  220.    if Input.trigger?(Input::B)
  221.      $game_system.se_play($data_system.cancel_se)
  222.      $scene = Scene_Menu.new(0)
  223.      return
  224.    end
  225.    if Input.trigger?(Input::C)
  226.      $game_system.se_play($data_system.decision_se)
  227.      @itemcommand_window.active = false
  228.      @skill_window.active = true
  229.      @skill_window.index = 0
  230.      return
  231.    end
  232. end
  233. #--------------------------------------------------------------------------
  234. #--------------------------------------------------------------------------
  235. def update_itemlist
  236.    if Input.trigger?(Input::B)
  237.      $game_system.se_play($data_system.cancel_se)
  238.      @itemcommand_window.active = true
  239.      @skill_window.active = false
  240.      @skill_window.index = 0
  241.      @itemcommand_window.index = @command_index
  242.      return
  243.    end
  244.    if Input.trigger?(Input::C)
  245.      # 获取特技窗口现在选择的特技的数据
  246.      @skill = @skill_window.skill
  247.      # 不能使用的情况下
  248.      if @skill == nil or not @actor.skill_can_use?(@skill.id)
  249.        # 演奏冻结 SE
  250.        $game_system.se_play($data_system.buzzer_se)
  251.        return
  252.      end
  253.      # 演奏确定 SE
  254.      $game_system.se_play($data_system.decision_se)
  255.      # 效果范围是我方的情况下
  256.      if @skill.scope >= 3
  257.        # 激活目标窗口
  258.        @skill_window.active = false
  259.        @target_window.x = (@skill_window.index + 1) % 2 * 304
  260.        @target_window.visible = true
  261.        @target_window.active = true
  262.        # 设置效果范围 (单体/全体) 的对应光标位置
  263.        if @skill.scope == 4 || @skill.scope == 6
  264.          @target_window.index = -1
  265.        elsif @skill.scope == 7
  266.          @target_window.index = @actor_index - 10
  267.        else
  268.          @target_window.index = 0
  269.        end
  270.      # 效果在我方以外的情况下
  271.      else
  272.        # 公共事件 ID 有效的情况下
  273.        if @skill.common_event_id > 0
  274.          # 预约调用公共事件
  275.          $game_temp.common_event_id = @skill.common_event_id
  276.          # 演奏特技使用时的 SE
  277.          $game_system.se_play(@skill.menu_se)
  278.          # 消耗 SP
  279.          @actor.sp -= @skill.sp_cost
  280.          # 再生成各窗口的内容
  281.          @status_window.refresh
  282.          @skill_window.refresh
  283.          @target_window.refresh
  284.          # 切换到地图画面
  285.          $scene = Scene_Map.new
  286.          return
  287.        end
  288.      end
  289.      return
  290.    end
  291. end
  292. #--------------------------------------------------------------------------
  293. #--------------------------------------------------------------------------
  294. def update_target
  295.    if Input.trigger?(Input::B)
  296.      $game_system.se_play($data_system.cancel_se)
  297.      @skill_window.refresh
  298.      @skill_window.active = true
  299.      @target_window.visible = false
  300.      @target_window.active = false
  301.      @skill_window.set_item(@itemcommand_window.commands[@command_index])
  302.      return
  303.    end
  304.    
  305.    # 按下 C 键的情况下
  306.    if Input.trigger?(Input::C)
  307.      # 因为 SP 不足而无法使用的情况下
  308.      unless @actor.skill_can_use?(@skill.id)
  309.        # 演奏冻结 SE
  310.        $game_system.se_play($data_system.buzzer_se)
  311.        return
  312.      end
  313.      # 目标是全体的情况下
  314.      if @target_window.index == -1
  315.        # 对同伴全体应用特技使用效果
  316.        used = false
  317.        for i in $game_party.actors
  318.          used |= i.skill_effect(@actor, @skill)
  319.        end
  320.      end
  321.      # 目标是使用者的情况下
  322.      if @target_window.index <= -2
  323.        # 对目标角色应用特技的使用效果
  324.        target = $game_party.actors[@target_window.index + 10]
  325.        used = target.skill_effect(@actor, @skill)
  326.      end
  327.      # 目标是单体的情况下
  328.      if @target_window.index >= 0
  329.        # 对目标角色应用特技的使用效果
  330.        target = $game_party.actors[@target_window.index]
  331.        used = target.skill_effect(@actor, @skill)
  332.      end
  333.      # 使用特技的情况下
  334.      if used
  335.        # 演奏特技使用时的 SE
  336.        $game_system.se_play(@skill.menu_se)
  337.        # 消耗 SP
  338.        @actor.sp -= @skill.sp_cost
  339.        # 再生成各窗口内容
  340.        @status_window.refresh
  341.        #@skill_window.refresh
  342.        @target_window.refresh
  343.        # 全灭的情况下
  344.        if $game_party.all_dead?
  345.          # 切换到游戏结束画面
  346.          $scene = Scene_Gameover.new
  347.          return
  348.        end
  349.        # 公共事件 ID 有效的情况下
  350.        if @skill.common_event_id > 0
  351.          # 预约调用公共事件
  352.          $game_temp.common_event_id = @skill.common_event_id
  353.          # 切换到地图画面
  354.          $scene = Scene_Map.new
  355.          return
  356.        end
  357.      end
  358.      # 无法使用特技的情况下
  359.      unless used
  360.        # 演奏冻结 SE
  361.        $game_system.se_play($data_system.buzzer_se)
  362.      end
  363.      return
  364.    end
  365. end
  366. end
  367. #==============================================================================
  368. # ■ Window_SkillStatus
  369. #------------------------------------------------------------------------------
  370. #  显示特技画面、特技使用者的窗口。
  371. #==============================================================================
  372. class Window_SkillStatus < Window_Base
  373. #--------------------------------------------------------------------------
  374. # ● 初始化对像
  375. #     actor : 角色
  376. #--------------------------------------------------------------------------
  377. def initialize(actor)
  378.    super(0, 288, 160, 128)
  379.    self.contents = Bitmap.new(width - 32, height - 32)
  380.    @actor = actor
  381.    refresh
  382. end
  383. #--------------------------------------------------------------------------
  384. # ● 刷新
  385. #--------------------------------------------------------------------------
  386. def refresh
  387.    self.contents.clear
  388.    draw_actor_name(@actor, 4, 0)
  389.    draw_actor_hp(@actor, 4, 32, 120)
  390.    draw_actor_sp(@actor, 4, 64, 120)
  391. end
  392. end
  393. #==============================================================================
  394. # ■ RPG追加定义,使用@符号分类
  395. #==============================================================================
  396. module RPG
  397. class Skill
  398.    def description
  399.      description = @description.split(/@/)[0]
  400.      return description != nil ? description : ''
  401.    end
  402.    def desc
  403.      desc = @description.split(/@/)[1]
  404.      return desc != nil ? desc : "普通技能"
  405.    end
  406. end
  407. end
  408. #==============================================================================
  409. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  410. #==============================================================================
  411. #==============================================================================
  412. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  413. #==============================================================================
  414. class Scene_Battle
  415. #--------------------------------------------------------------------------
  416. # ● 刷新画面 (角色命令回合 : 选择特技) ★★★★★★★★★★★★★★★★★
  417. #--------------------------------------------------------------------------
  418. def update_phase3_skill_select
  419.   # 设置特技窗口为可视状态
  420.   @skill_window.visible = true
  421.   @itemcommand_window.visible = true
  422.   @itemcommand_window.update
  423.   if @command_index != @itemcommand_window.index
  424.     @command_index = @itemcommand_window.index
  425.     @skill_window.set_item(@itemcommand_window.commands[@command_index])
  426.     @skill_window.index = 0
  427.   end
  428.   @skill_window.update
  429.   # 按下 B 键的情况下
  430.   if Input.trigger?(Input::B)
  431.     # 演奏取消 SE
  432.     $game_system.se_play($data_system.cancel_se)
  433.     if @itemcommand_window.active==false
  434.       @itemcommand_window.active = true
  435.       @skill_window.active = false
  436.       return
  437.     end
  438.     # 结束特技选择
  439.     end_skill_select
  440.     return
  441.   end
  442.   # 按下 C 键的情况下
  443.   if Input.trigger?(Input::C)
  444.     if @itemcommand_window.active
  445.       @itemcommand_window.active = false
  446.       @skill_window.active = true
  447.       # 演奏确定 SE
  448.       $game_system.se_play($data_system.decision_se)
  449.       return
  450.     end
  451.     # 获取特技选择窗口现在选择的特技的数据
  452.     @skill = @skill_window.skill
  453.     # 无法使用的情况下
  454.     if @skill == nil or not @active_battler.skill_can_use?(@skill.id)
  455.       # 演奏冻结 SE
  456.       $game_system.se_play($data_system.buzzer_se)
  457.       return
  458.     end
  459.     # 演奏确定 SE
  460.     $game_system.se_play($data_system.decision_se)
  461.     # 设置行动
  462.     @active_battler.current_action.skill_id = @skill.id
  463.     # 设置特技窗口为不可见状态
  464.     @skill_window.visible = false
  465.     @itemcommand_window.visible = false
  466.     # 效果范围是敌单体的情况下
  467.     if @skill.scope == 1
  468.       # 开始选择敌人
  469.       start_enemy_select
  470.     # 效果范围是我方单体的情况下
  471.     elsif @skill.scope == 3 or @skill.scope == 5
  472.       # 开始选择角色
  473.       start_actor_select
  474.     # 效果范围不是单体的情况下
  475.     else
  476.       # 选择特技结束
  477.       end_skill_select
  478.       # 转到下一位角色的指令输入
  479.       phase3_next_actor
  480.     end
  481.     return
  482.   end
  483. end
  484. #--------------------------------------------------------------------------
  485. # ● 开始选择特技 ★★★★★★★★★★★★★★★★★★★★★★★★★★★★
  486. #--------------------------------------------------------------------------
  487. def start_skill_select
  488.   @skill_window = Liuliu_Window_SkillList.new(@active_battler)
  489.   @skill_window.help_window = @help_window
  490.   @itemcommand_window = Liuliu_Window_SkillCommand.new(@active_battler)
  491.   @itemcommand_window.opacity = 160
  492.   @itemcommand_window.y = 64
  493.   @itemcommand_window.height -= 32
  494.   @itemcommand_window.active = true
  495.   @itemcommand_window.help_window = @help_window
  496.   @skill_window.active = false
  497.   @command_index = @itemcommand_window.index
  498.   @skill_window.set_item(@itemcommand_window.commands[@command_index])
  499.   @actor_command_window.active = false
  500.   @actor_command_window.visible = false
  501. end
  502. #--------------------------------------------------------------------------
  503. # ● 选择特技结束 ★★★★★★★★★★★★★★★★★★★★★★★★★★★★
  504. #--------------------------------------------------------------------------
  505. def end_skill_select
  506.   # 释放特技窗口
  507.   @itemcommand_window.dispose
  508.   @itemcommand_window = nil
  509.   @skill_window.dispose
  510.   @skill_window = nil
  511.   # 隐藏帮助窗口
  512.   @help_window.visible = false
  513.   # 有效化角色指令窗口
  514.   @actor_command_window.active = true
  515.   @actor_command_window.visible = true
  516. end
  517. end
  518. #==============================================================================
  519. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  520. #==============================================================================
复制代码

博客:我的博客

Lv3.寻梦者

梦石
0
星屑
1743
在线时间
485 小时
注册时间
2006-1-7
帖子
1073
2
发表于 2015-6-3 19:07:02 | 只看该作者
好像是在数据库中,技能的说明最后加上@ 再写上分类。例:
火焰I
初级火焰魔法,对单人造成火焰伤害。@普通技能

这个版本是从哪里提取出来的吧?
这里之划分了3个分类,普通技能,恢复技能,和 其他技能
建议你重新找一个技能分类的脚本去。

http://6rweb.sinaapp.com/articles/4492

点评

那你把1楼的脚本中24-43去掉试试。不行再说。  发表于 2015-6-3 19:56
请问要如何做到一开始已经分类好了?而不是有了新技能才增加分类  发表于 2015-6-3 19:27
初从文,三年不中;后习武,校场发一矢,中鼓吏,逐之出;遂学医,有所成。自撰一良方,服之,卒。
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
3176
在线时间
1442 小时
注册时间
2009-7-27
帖子
1454
3
 楼主| 发表于 2015-6-4 13:41:07 | 只看该作者
请高手帮忙
回复 支持 反对

使用道具 举报

Lv4.逐梦者

「Pemercyia」


Urhurrenna

梦石
0
星屑
9397
在线时间
2748 小时
注册时间
2008-9-5
帖子
3543

开拓者短篇八RM组冠军短篇九导演组亚军白银编剧

4
发表于 2015-6-4 13:58:15 | 只看该作者
本帖最后由 cinderelmini 于 2015-6-4 19:57 编辑

卧槽!文字被吞了?!

总之,LZ的条件分歧写错惹,改了一下用角色ID来做判定~
蓝后技能的分类操作参考阿尔西斯和帕吉尔的4个技能的注释。
PS:没办法让技能自己分好类,要这样做的话必须在脚本里把要分类的技能都枚举出来做分歧,
这样还不如在注释里填类型~
Project1.zip (203.79 KB, 下载次数: 93)


如果是要每个角色有不同数量的的分类的话,
分类的时候这样做:
  1.   case actor.id
  2.   when 1
  3.     s1 = "特技"
  4.     s2 = "钢拳"
  5.     s3 = "怒技"
  6.     s4 = "d"
  7.     @commands = [s1, s2, s3, s4]
  8.   when 2
  9.     s1 = "特技"
  10.     s2 = "替身"
  11.     s3 = "怒技"
  12.     s4 = "e"
  13.     s5 = "f"
  14.     @commands = [s1, s2, s3, s4, s5]
  15.   # 依次类推,填角色ID做分歧
  16.   else
  17.     s1 = "a"
  18.     s2 = "b"
  19.     s3 = "c"
  20.     @commands = [s1, s2, s3]
  21.   end
复制代码

点评

本楼已更新~(其实就是你原来的那种写法就好→_→,窝以为都是3个类型于是统一了选项数目……  发表于 2015-6-4 19:59
好奇问一下,有没有办法让某个角色是4个分类或者以上的办法?我试了一下不成功  发表于 2015-6-4 17:47
回复 支持 反对

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-9-23 05:24

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表