查看: 2142|回复: 0

[原创发布] 【10月17日更新】技能扩展分类(非全原创)

[复制链接]
梦石
0
星屑
1581
在线时间
253 小时
注册时间
2019-4-11
回帖
32
发表于 2023-2-26 00:58:46 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 sxjkjly8010 于 2023-10-17 20:06 编辑

2月28日更新:
1.修复了一点显示bug
3月18日更新:
1.修复了一点显示bug
10月17日更新:
1.修复了一点显示bug

心血来潮把这个自己用奈々改的脚本改造又改成默认战斗系统可用发布了
给一些想要和我同样效果的RM作者一些帮助

默认战斗系统效果:
QQ图片20230226010024.png

可以实现的效果大概这种感觉:
QQ图片20230226005712.png
QQ图片20230226005723.png
QQ图片20230226005726.png

演示图里的箭头效果不在脚本里
想要实现的可以在def draw_skill_cost(rect, skill)前面插入下列代码
[pre lang="ruby"]
    if skill.changetoskills != []
      change_color(normal_color, enable?(skill))
      rect.x -= 10
      rect.y -= 1
      draw_text(rect, "▶", 2)
      rect.x += 10
      rect.y += 1
      draw_text(rect, ">", 2)
      return
    end[/pre]
QQ截图20230226010808.png
也可以放一个这样的脚本在最后
[pre lang="ruby"]
class Window_SkillList < Window_Selectable
  alias changeto_draw_skill_cost draw_skill_cost
  def draw_skill_cost(rect, skill)
    if skill.changetoskills != []
     change_color(normal_color, enable?(skill))
      rect.x -= 10
      rect.y -= 1
      draw_text(rect, "▶", 2)
      rect.x += 10
      rect.y += 1
      draw_text(rect, ">", 2)
      return
    end
    changeto_draw_skill_cost(rect, skill)
  end
end[/pre]

改造成默认战斗系统的同时多加了内容,LEARN_SWITCH默认是开启的
可以实现后续习得技能加入到扩展技能里,请注意习得的技能分类设为无

脚本:
[pre lang="ruby"]#==============================================================================
#                                 扩展技能分类
#   改造作者:Akahara
#   参考代码原作者:奈々(なな)
#   个人网址 http://heptanas.mamagoto.com/
#   使用部分代码作者:ももまる
#   个人网址 http://peachround.com/
#
#   ◇使用規約
#   使用される場合はスクリプト作成者として「奈々」を明記して下さい。
#   このスクリプトを改変したり、改変したものを配布するなどは自由ですが
#   その場合も元のスクリプトの作成者として名前は載せて下さい。
#
#------------------------------------------------------------------------------
#
#   在技能备注 <扩展分类 ID> (可以有多个)
#   可以让有该备注的技能选择后不是使用技能而是出现小窗口的多个技能
#   
#   拥有该备注的技能不会有任何效果,建议不要拥有技能消耗和效果
#  (没试过也忘了有了会怎样)
#
#==============================================================================

#感谢并使用了ももまる的LNX11XP战斗的代码
#已经有装LNX11XP战斗的请把27行(module LNX11_Window_FittingEXSkillList)
#到47行(最靠左的end)注释掉防止冲突
module LNX11_Window_FittingEXSkillList
  #--------------------------------------------------------------------------
  # ● [オーバーライド]:リフレッシュ
  #--------------------------------------------------------------------------
  def refresh
    make_item_list
    self.height = fitting_height(row_max)
    super
    self.oy = 0
  end
end

module AKAHARA
  module CHANGETOSKILL
    LEARN_SWITCH = true
    #开启此开关(true)后,扩展的技能需要习得才会显示在窗口里
    #如果开启,扩展的技能的分类建议选为无,并在习得扩展技能的时候一起习得
    #关闭此开关(false)后,扩展的技能无需习得就会显示在窗口里
  end
end

class RPG::Skill < RPG::UsableItem
  #--------------------------------------------------------------------------
  # ● 変化先スキルの定義(追加定義)
  #--------------------------------------------------------------------------  
  def changetoskills
    list = []
    @note.scan(/<扩展分类\s?(\d*)>/) {|s|
      list.push($data_skills[$1.to_i]) if $1
    }
    return list
  end
end

class Window_SkillList < Window_Selectable
  def data_num
    @data
  end
end

#==============================================================================
# ■ Scene_Battle
#------------------------------------------------------------------------------
#  バトル画面の処理を行うクラスです。
#==============================================================================

class Scene_Battle < Scene_Base
  alias start3 start
  def start
    start3
    @change = false
    @last_skill2 = nil
  end  
  #--------------------------------------------------------------------------
  # ● 全ウィンドウの作成
  #--------------------------------------------------------------------------
  alias create_all_windows2 create_all_windows
  def create_all_windows
    create_all_windows2
    create_changetoskill_window
  end
  #--------------------------------------------------------------------------
  # ● 変化先スキルウィンドウの作成
  #--------------------------------------------------------------------------
  def create_changetoskill_window
    @changetoskill_window = Window_BattleChangetoSkill.new(@help_window, @info_viewport)
    @changetoskill_window.set_handler(:ok,     method(:on_changetoskill_ok))
    @changetoskill_window.set_handler(:cancel, method(:on_changetoskill_cancel))
  end
  #--------------------------------------------------------------------------
  # ● スキル[決定]
  #--------------------------------------------------------------------------
  def on_skill_ok
    @change = false
    @skill = @skill_window.item
    @last_skill2 = @skill
    if @skill.changetoskills != []
      @skill_window.deactivate
      @skill_window.visible = true
      @change = true
      wx = Graphics.width/2 + (@skill_window.index % 2 == 0 ? 0 : -Graphics.width / 2.3)
      @changetoskill_window.x = wx
      wy = (@skill_window.cursor_rect.y-@skill_window.oy) + 50
      @changetoskill_window.y = wy
      if (@changetoskill_window.y+@changetoskill_window.height) >= Graphics.height
        @changetoskill_window.height = Graphics.height-@changetoskill_window.y
      end      
      @changetoskill_window.y = @skill_window.y + wy      
      @changetoskill_window.actor = BattleManager.actor
      @changetoskill_window.changetoskills = @skill.changetoskills
      @changetoskill_window.show.activate
      return
    end
    BattleManager.actor.input.set_skill(@skill.id)
    BattleManager.actor.last_skill.object = @skill
    if !@skill.need_selection?
      @skill_window.refresh
      @skill_window.hide
      next_command
    elsif @skill.for_opponent?
      select_enemy_selection
    else
      select_actor_selection
    end   
  end
  #--------------------------------------------------------------------------
  # ● 変化先スキル[決定]
  #--------------------------------------------------------------------------
  def on_changetoskill_ok
    @help_window.visible = false
    @changetoskill_window.visible = false
    @skill_window.visible = false
    @changetoskill = @changetoskill_window.item
    BattleManager.actor.input.set_skill(@changetoskill.id)
    BattleManager.actor.last_skill.object = @changetoskill
    if !@changetoskill.need_selection?
      @skill_window.refresh
      @skill_window.hide
      @changetoskill_window.hide
      next_command
    elsif @changetoskill.for_opponent?
      select_enemy_selection
    else
      select_actor_selection
    end
  end
  #--------------------------------------------------------------------------
  # ● 変化先スキル[キャンセル]
  #--------------------------------------------------------------------------
  def on_changetoskill_cancel
    @changetoskill_window.hide
    @skill_window.show.activate.select(@skill_window.data_num.index(@last_skill2) || 0)
  end
  #--------------------------------------------------------------------------
  # ● アクター[決定]
  #--------------------------------------------------------------------------
  alias changetoskill_on_actor_ok on_actor_ok
  def on_actor_ok
    @changetoskill_window.hide
    changetoskill_on_actor_ok
  end
  #--------------------------------------------------------------------------
  # ● アクター[キャンセル]
  #--------------------------------------------------------------------------
  alias changetoskill_on_actor_cancel on_actor_cancel
  def on_actor_cancel
    changetoskill_on_actor_cancel
    case @actor_command_window.current_symbol
    when :skill
      if @change == true
        @changetoskill_window.show.activate.select_last
        @skill_window.show.deactivate.select(@skill_window.data_num.index(@last_skill2) || 0)
        @help_window.visible = true
        @skill_window.visible = true
      else
        @changetoskill_window.hide
        @skill_window.hide
      end
    end
  end  
  #--------------------------------------------------------------------------
  # ● 敵キャラ[決定]
  #--------------------------------------------------------------------------
  alias changetoskill_on_enemy_ok on_enemy_ok
  def on_enemy_ok
    @changetoskill_window.hide
    changetoskill_on_enemy_ok
  end
  #--------------------------------------------------------------------------
  # ● 敵キャラ[キャンセル]
  #--------------------------------------------------------------------------
  alias changetoskill_on_enemy_cancel on_enemy_cancel
  def on_enemy_cancel
    changetoskill_on_enemy_cancel
    case @actor_command_window.current_symbol
    when :skill
      if @change == true
        @changetoskill_window.show.activate.select_last
        @skill_window.show.deactivate.select(@skill_window.data_num.index(@last_skill2) || 0)
        @help_window.visible = true
        @skill_window.visible = true
      else
        @changetoskill_window.hide
        @skill_window.hide
      end
    end
  end  
end
#==============================================================================
# ■ Window_Battlechangetoskill
#------------------------------------------------------------------------------
#  バトル画面で、使用する変化先スキルを選択するウィンドウです。
#==============================================================================

class Window_BattleChangetoSkill < Window_SkillList
  include LNX11_Window_FittingEXSkillList
  include AKAHARA::CHANGETOSKILL
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #     info_viewport : 情報表示用ビューポート
  #--------------------------------------------------------------------------
  def initialize(help_window, info_viewport)
    y = help_window.height
    super(0, y, Graphics.width / 2.3, info_viewport.rect.y - y)
    self.visible = false
    self.windowskin = Cache.system("window")
    @help_window = help_window
    @info_viewport = info_viewport
    @changetoskills = nil
  end
  def col_max
    return 1
  end
  #--------------------------------------------------------------------------
  # ● 変化先スキルの設定
  #--------------------------------------------------------------------------
  def changetoskills=(changetoskills)
    return if @changetoskills == changetoskills
    @changetoskills = changetoskills
    refresh
    self.oy = 0
  end
  #--------------------------------------------------------------------------
  # ● スキルリストの作成
  #--------------------------------------------------------------------------
  def make_item_list
    if @changetoskills
      if LEARN_SWITCH
        @changetoskills1 = @changetoskills.clone
        @changetoskills.each {|i| @changetoskills1.delete(i) if !@actor.skill_learn?(i)}
        @data = @changetoskills1
      else
        @data = @changetoskills
      end
    else
      @data = []
    end
  end
  #--------------------------------------------------------------------------
  # ● ウィンドウの表示
  #--------------------------------------------------------------------------
  def show
    select(0)
    @help_window.show
    super
  end
  #--------------------------------------------------------------------------
  # ● ウィンドウの非表示
  #--------------------------------------------------------------------------
  def hide
    @help_window.hide
    super
  end
end

#==============================================================================
# ■ Scene_Skill
#------------------------------------------------------------------------------
#  スキル画面の処理を行うクラスです。処理共通化の便宜上、スキルも「アイテム」
# として扱っています。
#==============================================================================

class Scene_Skill < Scene_ItemBase
  #--------------------------------------------------------------------------
  # ● 開始処理
  #--------------------------------------------------------------------------
  alias start2 start
  def start
    start2
    create_changetoitem_window
    @change = false
    @last_skill2 = nil
  end
  #--------------------------------------------------------------------------
  # ● 変化先アイテムウィンドウの作成
  #--------------------------------------------------------------------------
  def create_changetoitem_window
    wx = 0
    wy = @status_window.y + @status_window.height
    ww = Graphics.width / 2.3
    wh = Graphics.height - wy
    @changetoitem_window = Window_ChangetoSkillList.new(wx, wy, ww, wh)
    @changetoitem_window.actor = @actor
    @changetoitem_window.viewport = @viewport
    @changetoitem_window.help_window = @help_window
    @changetoitem_window.set_handler(:ok,     method(:on_changetoitem_ok))
    @changetoitem_window.set_handler(:cancel, method(:on_changetoitem_cancel))
    @changetoitem_window.hide
  end
  #--------------------------------------------------------------------------
  # ● 現在選択されているアイテムの取得
  #--------------------------------------------------------------------------
  def item
    @change ? @changetoitem_window.item : @item_window.item
  end
  #--------------------------------------------------------------------------
  # ● カーソルが左列にあるかの判定
  #--------------------------------------------------------------------------
  def cursor_left?
    @change ? @changetoitem_window.index % 2 == 0 : @item_window.index % 2 == 0
  end
  #--------------------------------------------------------------------------
  # ● アイテム[決定]
  #--------------------------------------------------------------------------
  def on_item_ok
    @change = false
    @last_skill2 = item
    if item.changetoskills != []
      @item_window.deactivate
      wx = Graphics.width/2 + (@item_window.index % 2 == 0 ? 0 : -Graphics.width / 2.3)
      @changetoitem_window.x = wx      
      wy = (@item_window.cursor_rect.y-@item_window.oy) + 50
      @changetoitem_window.y = wy
      if (@changetoitem_window.y+@changetoitem_window.height) >= Graphics.height
        @changetoitem_window.height = Graphics.height-@changetoitem_window.y
      end      
      @changetoitem_window.changetoskills = item.changetoskills
      @changetoitem_window.select(0)
      @change = true
      @changetoitem_window.show.activate
      return
    end
    @actor.last_skill.object = item
    determine_item
  end
  #--------------------------------------------------------------------------
  # ● 変化先アイテム[決定]
  #--------------------------------------------------------------------------
  def on_changetoitem_ok
    @actor.last_skill.object = item
    determine_item
  end
  #--------------------------------------------------------------------------
  # ● 変化先アイテム[キャンセル]
  #--------------------------------------------------------------------------
  def on_changetoitem_cancel
    @changetoitem_window.hide
    @item_window.show.activate.select(@item_window.data_num.index(@last_skill2) || 0)
  end
  #--------------------------------------------------------------------------
  # ● アクター[キャンセル]
  #--------------------------------------------------------------------------
  def on_actor_cancel
    hide_sub_window(@actor_window)
    if @change == true
      @changetoitem_window.show.activate.select_last
      @item_window.show.deactivate   
    else
      @changetoitem_window.hide
      @item_window.show.activate
    end
  end
end
#==============================================================================
# ■ Window_ChangetoSkillList
#------------------------------------------------------------------------------
#  スキル画面で、使用できるスキルの一覧を表示するウィンドウです。
#==============================================================================

class Window_ChangetoSkillList < Window_SkillList
  include LNX11_Window_FittingEXSkillList
  include AKAHARA::CHANGETOSKILL
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(x, y, width, height)
    super
    self.windowskin = Cache.system("window")   
    @actor = nil
    @stype_id = 0
    @data = []
    @changetoskills = nil
  end
  def col_max
    return 1
  end  
  #--------------------------------------------------------------------------
  # ● 変化先スキルの設定
  #--------------------------------------------------------------------------
  def changetoskills=(changetoskills)
    return if @changetoskills == changetoskills
    @changetoskills = changetoskills
    refresh
    self.oy = 0
  end
  #--------------------------------------------------------------------------
  # ● スキルリストの作成
  #--------------------------------------------------------------------------
  def make_item_list
    if @changetoskills
      if LEARN_SWITCH
        @changetoskills1 = @changetoskills.clone
        @changetoskills.each {|i| @changetoskills1.delete(i) if !@actor.skill_learn?(i)}
        @data = @changetoskills1
      else
        @data = @changetoskills
      end
    else
      @data = []
    end
  end
end[/pre]
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

在本版发帖返回顶部