查看: 1488|回复: 2

[已经解决] 关于Yanfly老师的Yanfly Engine Ace - 职业系统 v1.10

[复制链接]
梦石
0
星屑
319
在线时间
27 小时
注册时间
2021-8-13
回帖
2
发表于 2021-8-24 08:46:56 | 显示全部楼层 |阅读模式

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

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

×
    YEA - 特定职业#==============================================================================
#
# ▼ Yanfly Engine Ace - 职业系统插件:特定职业 v1.00
# -- 最后更新: 2011.12.23
# -- 使用难度: 普通
# -- 需要脚本: YEA - 职业系统 v1.03+
#
#==============================================================================

$imported = {} if $imported.nil?
$imported["YEA-ClassSpecifics"] = true

#==============================================================================
# ▼ Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2011.12.23 - Started Script and Finished.
#
#==============================================================================
# ▼ 介绍
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 本脚本可以让某个职业只能被设定为主职业或只能被设定为副职业。除此以外,还有副
# 职业只能在角色处于某个特定的主职业时才能被应用的功能。
#
#==============================================================================
# ▼ 安装方式
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 打开脚本编辑器,将本脚本拷贝/复制到一个在▼ 插件脚本之下▼ Main之上的新
# 脚本页/槽中.记得保存你的工程以使脚本生效.
#
# -----------------------------------------------------------------------------
# 职业备注 - 在数据库-职业中可以使用的备注.
# -----------------------------------------------------------------------------
# <仅为主职业>
# 该职业仅能作为主职业.
#
# <仅为副职业>
# 该职业仅能作为副职业.
#
# <需要主职业: x>
# <需要主职业: x, x>
# 该副职业仅在x号职业作为主职业时,才能被应用.
#
#==============================================================================
# ▼ 兼容性
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 本脚本仅为RPG Maker VX Ace编写.极不可能在无任何修改的情况下运行于RPG Maker VX.
#
# 本脚本需要配合脚本Yanfly Engine Ace - 职业系统 v1.03+来使用. 同时需要将本脚本
# 放在其之下.
#
#==============================================================================
# ▼ 编辑以下内容可能会出现电脑损坏、死机,电脑主人脑袋爆炸、昏迷、死亡或口臭
# 所以编辑了后果自负。
#==============================================================================

if $imported["YEA-ClassSystem"]

module YEA
  module REGEXP
  module CLASS
   
    PRIMARY_ONLY  = /<(?:PRIMARY_ONLY|仅为主职业)>/i
    SUBCLASS_ONLY = /<(?:SUBCLASS_ONLY|仅为副职业)>/i
    SUBCLASS_TO = /<(?:SUBCLASS_TO|需要主职业):[ ]*(\d+(?:\s*,\s*\d+)*)>/i
   
  end # CLASS
  end # REGEXP
end # YEA

#==============================================================================
# ■ DataManager
#==============================================================================

module DataManager
  
  #--------------------------------------------------------------------------
  # alias method: load_database
  #--------------------------------------------------------------------------
  class <<self; alias load_database_csp load_database; end
  def self.load_database
    load_database_csp
    load_notetags_csp
  end
  
  #--------------------------------------------------------------------------
  # new method: load_notetags_csp
  #--------------------------------------------------------------------------
  def self.load_notetags_csp
    for obj in $data_classes
      next if obj.nil?
      obj.load_notetags_csp
    end
  end
  
end # DataManager

#==============================================================================
# ■ RPG::Class
#==============================================================================

class RPG::Class < RPG::BaseItem
  
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :primary_only
  attr_accessor :subclass_only
  attr_accessor :subclass_to
  
  #--------------------------------------------------------------------------
  # common cache: load_notetags_csp
  #--------------------------------------------------------------------------
  def load_notetags_csp
    @primary_only = false
    @subclass_only = false
    @subclass_to = []
    #---
    self.note.split(/[\r\n]+/).each { |line|
      case line
      #---
      when YEA::REGEXP::CLASS::PRIMARY_ONLY
        @primary_only = true
        @subclass_only = false
        @subclass_to = []
      when YEA::REGEXP::CLASS::SUBCLASS_ONLY
        @primary_only = false
        @subclass_only = true
      when YEA::REGEXP::CLASS::SUBCLASS_TO
        @primary_only = false
        @subclass_only = true
        $1.scan(/\d+/).each { |num|
        @subclass_to.push(num.to_i) if num.to_i > 0 }
      end
    } # self.note.split
    #---
  end
  
end # RPG::Class

#==============================================================================
# ■ Game_Actor
#==============================================================================

class Game_Actor < Game_Battler
  
  #--------------------------------------------------------------------------
  # alias method: change_class
  #--------------------------------------------------------------------------
  alias game_actor_change_class_csp change_class
  def change_class(class_id, keep_exp = false)
    return if $data_classes[class_id].subclass_only
    game_actor_change_class_csp(class_id, keep_exp)
    correct_subclass
  end
  
  #--------------------------------------------------------------------------
  # alias method: change_subclass
  #--------------------------------------------------------------------------
  alias game_actor_change_subclass_csp change_subclass
  def change_subclass(class_id)
    return unless subclass_requirements_met?(class_id)
    game_actor_change_subclass_csp(class_id)
  end
  
  #--------------------------------------------------------------------------
  # new method: subclass_requirements_met?
  #--------------------------------------------------------------------------
  def subclass_requirements_met?(class_id)
    subclass = $data_classes[class_id]
    return false if subclass.primary_only
    return subclass_to?(class_id) if subclass.subclass_to != []
    return true
  end
  
  #--------------------------------------------------------------------------
  # new method: subclass_to?
  #--------------------------------------------------------------------------
  def subclass_to?(class_id)
    return true if class_id == 0
    subclass = $data_classes[class_id]
    return false if subclass.nil?
    for class_id in subclass.subclass_to
      return true if class_id == self.class.id
    end
    return false
  end
  
  #--------------------------------------------------------------------------
  # new method: correct_subclass
  #--------------------------------------------------------------------------
  def correct_subclass
    return if @subclass_id == 0
    subclass = $data_classes[@subclass_id]
    return if subclass.nil?
    return if subclass.subclass_to == []
    @subclass_id = 0 if !subclass_to?(@subclass_id)
  end
  
end # Game_Actor

#==============================================================================
# ■ Window_ClassList
#==============================================================================

class Window_ClassList < Window_Selectable
  
  #--------------------------------------------------------------------------
  # alias method: enable?
  #--------------------------------------------------------------------------
  alias window_classlist_enable_csp enable?
  def enable?(item)
    case @command_window.current_symbol
    when :primary
      return false if item.subclass_only
    when :subclass
      return false if item.primary_only
      return @actor.subclass_to?(item.id) if item.subclass_to != []
    end
    return window_classlist_enable_csp(item)
  end
  
end # Window_ClassList

end # $imported["YEA-ClassSystem"]

#==============================================================================
#
# ▼ End of File
#
#==============================================================================
在下脚本小白,想请问一下关于Yanfly老师的Yanfly Engine Ace - 职业系统 v1.10怎么让副职业也获得经验或者按主职业获得的经验的一定比例获得经验
下面是脚本
YEA - 职业系统#===============[fold=    YEA - 职业解锁等级]#==============================================================================
#
# ▼ Yanfly Engine Ace - 职业系统插件: 职业解锁等级 v1.00
# -- 最后更新: 2011.12.20
# -- 使用难度: 普通
# -- 需要脚本: YEA - 职业系统 v1.01+
#
#==============================================================================

$imported = {} if $imported.nil?
$imported["YEA-ClassUnlockLevel"] = true

#==============================================================================
# ▼ Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2011.12.20 - Started Script and Finished.
#
#==============================================================================
# ▼ 介绍
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 本脚本可以在角色的职业等级到达一定程度后,解锁某个职业。解锁职业需要的等级可
# 以设定为多个等级。请注意本脚本生效的前提是在脚本"YEA - 职业系统 v1.01+"中的
# MAINTAIN_LEVELS设定为false。
#
#==============================================================================
# ▼ 安装方式
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 打开脚本编辑器,将本脚本拷贝/复制到一个在▼ 插件脚本之下▼ Main之上的新
# 脚本页/槽中.记得保存你的工程以使脚本生效.
#
# -----------------------------------------------------------------------------
# 职业备注 - 在数据库-职业中可以使用的备注.
# -----------------------------------------------------------------------------
# <职业解锁条件>
#   职业 x: 等级 y
#   职业 x: 等级 y
#   ...
# </职业解锁条件>
#
# 设定某个职业解锁的条件,该职业需要x号职业的等级达到y级,解锁条件可以为一行或
# 多行。
#
#==============================================================================
# ▼ 兼容性
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 本脚本仅为RPG Maker VX Ace编写.极不可能在无任何修改的情况下运行于RPG Maker VX.
#
# 本脚本需要配合脚本Yanfly Engine Ace - 职业系统 v1.01+来使用. 同时需要将本脚本
# 放在其之下.
#
#==============================================================================
# ▼ 编辑以下内容可能会出现电脑损坏、死机,电脑主人脑袋爆炸、昏迷、死亡或口臭
# 所以编辑了后果自负。
#==============================================================================

if $imported["YEA-ClassSystem"] && !YEA::CLASS_SYSTEM::MAINTAIN_LEVELS

module YEA
  module REGEXP
  module CLASS
   
    LV_UNLOCK_ON =
      /<(?:LEVEL_UNLOCK_REQUIREMENTS|职业解锁条件)>/i
    LV_UNLOCK_OFF =
      /<\/(?:LEVEL_UNLOCK_REQUIREMENTS|职业解锁条件)>/i
    LV_UNLOCK_STR = /职业[ ](\d+): 等级[ ](\d+)/i
   
  end # CLASS
  end # REGEXP
end # YEA

#==============================================================================
# ■ DataManager
#==============================================================================

module DataManager
  
  #--------------------------------------------------------------------------
  # alias method: load_database
  #--------------------------------------------------------------------------
  class <<self; alias load_database_cul load_database; end
  def self.load_database
    load_database_cul
    load_notetags_cul
  end
  
  #--------------------------------------------------------------------------
  # new method: load_notetags_cul
  #--------------------------------------------------------------------------
  def self.load_notetags_cul
    for obj in $data_classes
      next if obj.nil?
      obj.load_notetags_cul
    end
  end
  
end # DataManager

#==============================================================================
# ■ RPG::Class
#==============================================================================

class RPG::Class < RPG::BaseItem
  
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :level_unlock
  
  #--------------------------------------------------------------------------
  # common cache: load_notetags_cul
  #--------------------------------------------------------------------------
  def load_notetags_cul
    @level_unlock = {}
    @level_unlock_on = false
    #---
    self.note.split(/[\r\n]+/).each { |line|
      case line
      #---
      when YEA::REGEXP::CLASS::LV_UNLOCK_ON
        @level_unlock_on = true
      when YEA::REGEXP::CLASS::LV_UNLOCK_OFF
        @level_unlock_on = false
      when YEA::REGEXP::CLASS::LV_UNLOCK_STR
        next unless @level_unlock_on
        @level_unlock[$1.to_i] = $2.to_i
      end
    } # self.note.split
    #---
  end
  
end # RPG::Class

#==============================================================================
# ■ Game_Actor
#==============================================================================

class Game_Actor < Game_Battler
  
  #--------------------------------------------------------------------------
  # check_level_unlocked_classes
  #--------------------------------------------------------------------------
  def check_level_unlocked_classes
    for item in $data_classes
      next if item.nil?
      next if unlocked_classes.include?(item.id)
      next if item.level_unlock == {}
      next unless class_unlock_level_requirements_met?(item)
      unlock_class(item.id)
    end
  end
  
  #--------------------------------------------------------------------------
  # class_unlock_level_requirements_met?
  #--------------------------------------------------------------------------
  def class_unlock_level_requirements_met?(item)
    for key in item.level_unlock
      class_id = key[0]
      level_req = key[1]
      return false if class_level(class_id) < level_req
    end
    return true
  end
  
end # Game_Actor

#==============================================================================
# ■ Window_ClassList
#==============================================================================

class Window_ClassList < Window_Selectable
  
  #--------------------------------------------------------------------------
  # alias method: actor=
  #--------------------------------------------------------------------------
  alias window_classlist_actor_equals_cul actor=
  def actor=(actor)
    return if @actor == actor
    actor.check_level_unlocked_classes
    window_classlist_actor_equals_cul(actor)
  end
  
end # Window_ClassList

end # $imported["YEA-ClassSystem"] && !YEA::CLASS_SYSTEM::MAINTAIN_LEVELS

#==============================================================================
#
# ▼ End of File
#
#==============================================================================
===============================================================
#
# ▼ Yanfly Engine Ace - 职业系统 v1.10
# -- 最后更新: 2012.01.29
# -- 使用难度: 普通, 困难
# -- 需要脚本: 无
#
#==============================================================================

$imported = {} if $imported.nil?
$imported["YEA-ClassSystem"] = true

#==============================================================================
# ▼ Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2012.08.06 - Leveling issue if class level exceeds actor level.
# 2012.01.29 - Visual Bug: Disabled classes now have faded icons.
# 2012.01.08 - Compatibility Update: Learn Skill Engine
# 2012.01.05 - Bug Fixed: Equipment no longer gets duplicated.
# 2012.01.04 - Update: Autobattle will no longer use skills not available to
#              that class for specific actors.
# 2012.01.02 - Efficiency Update.
# 2011.12.26 - Added custom command functionality.
# 2011.12.23 - Compatibility Update: Class Specifics.
# 2011.12.22 - Compatibility Update: Ace Menu Engine.
# 2011.12.20 - Compatibility Update: Class Unlock Level.
# 2011.12.19 - Started Script and Finished.
#
#==============================================================================
# ▼ 介绍
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 本脚本可以让玩家在菜单中随意更改角色的职业。你可以选择在职业改变后是否将职业
# 等级应用于角色等级。同时还可以设定角色的副职业。
#
#==============================================================================
# ▼ 安装方式
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 打开脚本编辑器,将本脚本拷贝/复制到一个在▼ 插件脚本之下▼ Main之上的新
# 脚本页/槽中.记得保存你的工程以使脚本生效.
#
# -----------------------------------------------------------------------------
# 角色备注 - 在数据库-角色中可以使用的备注.
# -----------------------------------------------------------------------------
# <解锁职业: x>
# <解锁职业: x, x>
# 这将为角色设置其默认的可解锁职业(可转职职业)。你可以一次设定多个可解锁职业,
#
# -----------------------------------------------------------------------------
# 职业备注 - 在数据库-职业中可以使用的备注.
# -----------------------------------------------------------------------------
# <图标: x>
# 设定该职业的图标,x为图标的index.
#
# <介绍>
#  内容
#  内容
# </介绍>
# 设定在职业帮助窗口中显示的介绍内容,该职业的介绍内容使用"|"来分行.
#
# -----------------------------------------------------------------------------
# 脚本 - 可使用的脚本.
# -----------------------------------------------------------------------------
# $game_actors[x].unlock_class(y)
# 解锁x号角色的y号职业,使其能够在职业场景里转成该职业。
#
# $game_actors[x].remove_class(y)
# 移除x号角色的y号职业,使其不能在职业场景里转成该职业。如果y号为x号职业的主
# 职业,则该职业不会被移除,除非玩家转职。如果y号为x号职业的副职业,则该职业会
# 变成未装备状态。
#
#==============================================================================
# ▼ 兼容性
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 本脚本仅为RPG Maker VX Ace编写.极不可能在无任何修改的情况下运行于RPG Maker VX.
#
#==============================================================================

module YEA
  module CLASS_SYSTEM
   
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # - 通用职业设置 -
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # 这些是有关职业系统的通用设置,控制脚本运行的数值和规则。
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    CLASS_MENU_TEXT = "职业"  # 在主菜单中显示的文本.
    MAINTAIN_LEVELS = false    # 是否取消职业等级功能. 默认: false.
    DEFAULT_UNLOCKS = [ 1, 11, 21, 31]   # 默认已解锁的职业.
   
    # 主职业和副职业共同显示的方式
    SUBCLASS_TEXT = "%s/%s"
   
    # 当角色拥有副职业时,设定副职业能力值(属性)继承的比率
    # 设定为0.0来关闭此功能
    SUBCLASS_STAT_RATE = 0.20
   
    # 是否将副职业的可用技能类型应用于角色
    SUBCLASS_SKILL_TYPES = true
   
    # 是否将副职业的可用武器类型应用于角色
    SUBCLASS_WEAPON_TYPES = true
   
    # 是否将副职业的可用护甲类型应用于角色
    SUBCLASS_ARMOUR_TYPES = true
   
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # - 职业场景指令 -
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # 在菜单中添加了可以进入职业场景的指令,你可以在下面设定指令的文本。
    #
    # -------------------------------------------------------------------------
    # :指令         介绍
    # -------------------------------------------------------------------------
    # :primary         改变主职业的指令.
    # :subclass        改变副职业的指令.
    #
    # :learn_skill     需要脚本 YEA - 技能学习系统
    #
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    COMMANDS =[ # 顺序为从上到下显示.
    # [ :指令,          "文本"],
      [ :primary,     "主职业"],
      [:subclass,     "副职业"],
      [:learn_skill,"学习技能"],
    # [ :custom1,    "自定义1"],
    # [ :custom2,    "自定义2"],
   
    ] # 别动这个括号.
   
    #--------------------------------------------------------------------------
    # - 自定义职业指令 -
    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    # 对于那些希望通过本脚本来为职业场景添加特殊效果的人,可以使用下面的哈希表
    # 来管理职业场景中的指令。你可以使用开关来禁用/隐藏指令。如果你不想把指令与
    # 开关相关联,把开关设定为0就行。
    #--------------------------------------------------------------------------
    CUSTOM_CLASS_COMMANDS ={
    # :指令    => [    启用开关,   显示开关,        处理方法,
      :custom1 => [           0,          0, :command_name1],
      :custom2 => [           0,          0, :command_name2],
    } # 别动这个括号.
   
    # 设定字体颜色.
    CURRENT_CLASS_COLOUR = 17     # 主职业的"窗口"颜色
    SUBCLASS_COLOUR      = 4      # 副职业的"窗口"颜色
   
    # 设定职业等级的显示,前提是 MAINTAIN_LEVELS 设定为 false.
    CLASS_LEVEL     = "LV%s"      # 等级的文本.
    LEVEL_FONT_SIZE = 16          # 等级的字体大小.
   
    # 职业列表中的职业排列和下面这个数组中的相同(数组中填入职业ID,或ID范围)
    # 任何未在列表中的职业会被隐藏.
    CLASS_ORDER = [41..999, 1..40]
   
    # 参数窗口中的字体大小.
    PARAM_FONT_SIZE = 20
   
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # - 开关设置 -
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # 以下为设定各种指令可见或可用的开关。如果某个指令可见而不可用,则玩家点了
    # 确定键也不会有任何反应。如果你不想用某个功能的话,将其开关设定为0
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    SWITCH_SHOW_CLASS      = 0    # 在主菜单中显示职业指令的开关
    SWITCH_ENABLE_CLASS    = 0    # 在主菜单中职业指令可用的开关
    SWITCH_SHOW_PRIMARY    = 0    # 在职业菜单中显示主职业指令的开关
    SWITCH_ENABLE_PRIMARY  = 0    # 在职业菜单中主职业指令可用的开关
    SWITCH_SHOW_SUBCLASS   = 0    # 在职业菜单中显示副职业指令的开关
    SWITCH_ENABLE_SUBCLASS = 0    # 在职业菜单中副职业指令可用的开关.
   
  end # CLASS_SYSTEM
end # YEA

#==============================================================================
# ▼ 编辑以下内容可能会出现电脑损坏、死机,电脑主人脑袋爆炸、昏迷、死亡或口臭
# 所以编辑了后果自负。
#==============================================================================

module YEA
  module CLASS_SYSTEM
    module_function
    #--------------------------------------------------------------------------
    # convert_integer_array
    #--------------------------------------------------------------------------
    def convert_integer_array(array)
      result = []
      array.each { |i|
        case i
        when Range; result |= i.to_a
        when Integer; result |=
        end }
      return result
    end
    #--------------------------------------------------------------------------
    # converted_contants
    #--------------------------------------------------------------------------
    DEFAULT_UNLOCKS = convert_integer_array(DEFAULT_UNLOCKS)
    CLASS_ORDER = convert_integer_array(CLASS_ORDER)
  end # CLASS_SYSTEM
  module REGEXP
  module ACTOR
   
    UNLOCKED_CLASSES =
      /<(?:UNLOCKED_CLASSES|解锁职业):[ ]*(\d+(?:\s*,\s*\d+)*)>/i
   
  end # ACTOR
  module CLASS
   
    ICON_INDEX = /<(?:ICON_INDEX|icon index|图标):[ ](\d+)>/i
    HELP_DESCRIPTION_ON  = /<(?:HELP_DESCRIPTION|介绍)>/i
    HELP_DESCRIPTION_OFF = /<\/(?:HELP_DESCRIPTION|介绍)>/i
   
  end # CLASS
  end # REGEXP
end # YEA

#==============================================================================
# ■ Switch
#==============================================================================

module Switch
  
  #--------------------------------------------------------------------------
  # self.class_show
  #--------------------------------------------------------------------------
  def self.class_show
    return true if YEA::CLASS_SYSTEM::SWITCH_SHOW_CLASS <= 0
    return $game_switches[YEA::CLASS_SYSTEM::SWITCH_SHOW_CLASS]
  end
  
  #--------------------------------------------------------------------------
  # self.class_enable
  #--------------------------------------------------------------------------
  def self.class_enable
    return true if YEA::CLASS_SYSTEM::SWITCH_ENABLE_CLASS <= 0
    return $game_switches[YEA::CLASS_SYSTEM::SWITCH_ENABLE_CLASS]
  end
  
  #--------------------------------------------------------------------------
  # self.primary_show
  #--------------------------------------------------------------------------
  def self.primary_show
    return true if YEA::CLASS_SYSTEM::SWITCH_SHOW_PRIMARY <= 0
    return $game_switches[YEA::CLASS_SYSTEM::SWITCH_SHOW_PRIMARY]
  end
  
  #--------------------------------------------------------------------------
  # self.primary_enable
  #--------------------------------------------------------------------------
  def self.primary_enable
    return true if YEA::CLASS_SYSTEM::SWITCH_ENABLE_PRIMARY <= 0
    return $game_switches[YEA::CLASS_SYSTEM::SWITCH_ENABLE_PRIMARY]
  end
  
  #--------------------------------------------------------------------------
  # self.subclass_show
  #--------------------------------------------------------------------------
  def self.subclass_show
    return true if YEA::CLASS_SYSTEM::SWITCH_SHOW_SUBCLASS <= 0
    return $game_switches[YEA::CLASS_SYSTEM::SWITCH_SHOW_SUBCLASS]
  end
  
  #--------------------------------------------------------------------------
  # self.subclass_enable
  #--------------------------------------------------------------------------
  def self.subclass_enable
    return true if YEA::CLASS_SYSTEM::SWITCH_ENABLE_SUBCLASS <= 0
    return $game_switches[YEA::CLASS_SYSTEM::SWITCH_ENABLE_SUBCLASS]
  end
   
end # Switch

#==============================================================================
# ■ Numeric
#==============================================================================

class Numeric
  
  #--------------------------------------------------------------------------
  # new method: group_digits
  #--------------------------------------------------------------------------
  unless $imported["YEA-CoreEngine"]
  def group; return self.to_s; end
  end # $imported["YEA-CoreEngine"]
   
end # Numeric

#==============================================================================
# ■ DataManager
#==============================================================================

module DataManager
  
  #--------------------------------------------------------------------------
  # alias method: load_database
  #--------------------------------------------------------------------------
  class <<self; alias load_database_cs load_database; end
  def self.load_database
    load_database_cs
    load_notetags_cs
  end
  
  #--------------------------------------------------------------------------
  # new method: load_notetags_cs
  #--------------------------------------------------------------------------
  def self.load_notetags_cs
    groups = [$data_actors, $data_classes]
    for group in groups
      for obj in group
        next if obj.nil?
        obj.load_notetags_cs
      end
    end
  end
  
end # DataManager

#==============================================================================
# ■ RPG::Actor
#==============================================================================

class RPG::Actor < RPG::BaseItem
  
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :unlocked_classes
  
  #--------------------------------------------------------------------------
  # common cache: load_notetags_cs
  #--------------------------------------------------------------------------
  def load_notetags_cs
    @unlocked_classes = []
    #---
    self.note.split(/[\r\n]+/).each { |line|
      case line
      #---
      when YEA::REGEXP::ACTOR::UNLOCKED_CLASSES
        $1.scan(/\d+/).each { |num|
        @unlocked_classes.push(num.to_i) if num.to_i > 0 }
      #---
      end
    } # self.note.split
    #---
  end
  
end # RPG::Actor

#==============================================================================
# ■ RPG::Class
#==============================================================================

class RPG::Class < RPG::BaseItem
  
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :icon_index
  
  #--------------------------------------------------------------------------
  # common cache: load_notetags_cs
  #--------------------------------------------------------------------------
  def load_notetags_cs
    @icon_index = 0
    @help_description_on = false
    #---
    self.note.split(/[\r\n]+/).each { |line|
      case line
      #---
      when YEA::REGEXP::CLASS::ICON_INDEX
        @icon_index = $1.to_i
      #---
      when YEA::REGEXP::CLASS::HELP_DESCRIPTION_ON
        @help_description_on = true
      when YEA::REGEXP::CLASS::HELP_DESCRIPTION_OFF
        @help_description_on = false
      #---
      else
        @description += line.to_s if @help_description_on
      end
    } # self.note.split
    #---
    @description.gsub!(/[|]/i) { "\n" }
  end
  
end # RPG::Class

#==============================================================================
# ■ Game_Temp
#==============================================================================

class Game_Temp
  
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :scene_class_index
  attr_accessor :scene_class_oy
  
end # Game_Temp

#==============================================================================
# ■ Game_Action
#==============================================================================

class Game_Action
  
  #--------------------------------------------------------------------------
  # alias method: valid?
  #--------------------------------------------------------------------------
  alias game_action_valid_cs valid?
  def valid?
    return false if check_auto_battle_class
    return game_action_valid_cs
  end
  
  #--------------------------------------------------------------------------
  # new method: check_auto_battle_class
  #--------------------------------------------------------------------------
  def check_auto_battle_class
    return false unless subject.actor?
    return false unless subject.auto_battle?
    return false if item.nil?
    return false if subject.added_skill_types.include?(item.stype_id)
    return false if item.id == subject.attack_skill_id
    return true
  end
  
end # Game_Action

#==============================================================================
# ■ Game_BattlerBase
#==============================================================================

class Game_BattlerBase
  
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :temp_flag
  
  #--------------------------------------------------------------------------
  # alias method: added_skill_types
  #--------------------------------------------------------------------------
  alias game_battlerbase_added_skill_types_cs added_skill_types
  def added_skill_types
    result = game_battlerbase_added_skill_types_cs
    result |= subclass_skill_types
    return result
  end
  
  #--------------------------------------------------------------------------
  # new method: subclass_skill_types
  #--------------------------------------------------------------------------
  def subclass_skill_types; return []; end
  
  #--------------------------------------------------------------------------
  # alias method: equip_wtype_ok?
  #--------------------------------------------------------------------------
  alias game_battlerbase_equip_wtype_ok_cs equip_wtype_ok?
  def equip_wtype_ok?(wtype_id)
    return true if subclass_equip_wtype?(wtype_id)
    return game_battlerbase_equip_wtype_ok_cs(wtype_id)
  end
  
  #--------------------------------------------------------------------------
  # new method: subclass_equip_wtype?
  #--------------------------------------------------------------------------
  def subclass_equip_wtype?(wtype_id); return false; end
  
  #--------------------------------------------------------------------------
  # alias method: equip_atype_ok?
  #--------------------------------------------------------------------------
  alias game_battlerbase_equip_atype_ok_cs equip_atype_ok?
  def equip_atype_ok?(atype_id)
    return true if subclass_equip_atype?(atype_id)
    return game_battlerbase_equip_atype_ok_cs(atype_id)
  end
  
  #--------------------------------------------------------------------------
  # new method: subclass_equip_atype?
  #--------------------------------------------------------------------------
  def subclass_equip_atype?(atype_id); return false; end
  
end # Game_BattlerBase

#==============================================================================
# ■ Game_Actor
#==============================================================================

class Game_Actor < Game_Battler
  
  #--------------------------------------------------------------------------
  # alias method: setup
  #--------------------------------------------------------------------------
  alias game_actor_setup_cs setup
  def setup(actor_id)
    game_actor_setup_cs(actor_id)
    init_unlocked_classes
    init_subclass
  end
  
  #--------------------------------------------------------------------------
  # new method: init_unlocked_classes
  #--------------------------------------------------------------------------
  def init_unlocked_classes
    @unlocked_classes = actor.unlocked_classes.clone
    @unlocked_classes.push(@class_id) if !@unlocked_classes.include?(@class_id)
    @unlocked_classes.sort!
  end
  
  #--------------------------------------------------------------------------
  # new method: init_subclass
  #--------------------------------------------------------------------------
  def init_subclass
    @subclass_id = 0
  end
  
  #--------------------------------------------------------------------------
  # new method: unlocked_classes
  #--------------------------------------------------------------------------
  def unlocked_classes
    init_unlocked_classes if @unlocked_classes.nil?
    return @unlocked_classes
  end
  
  #--------------------------------------------------------------------------
  # new method: unlock_class
  #--------------------------------------------------------------------------
  def unlock_class(class_id)
    init_unlocked_classes if @unlocked_classes.nil?
    return if @unlocked_classes.include?(class_id)
    @unlocked_classes.push(class_id)
    learn_class_skills(class_id)
  end
  
  #--------------------------------------------------------------------------
  # new method: remove_class
  #--------------------------------------------------------------------------
  def remove_class(class_id)
    init_unlocked_classes if @unlocked_classes.nil?
    return if class_id == @class_id
    @unlocked_classes.delete(class_id)
    @subclass_id = 0 if class_id == @subclass_id
    refresh
  end
  
  #--------------------------------------------------------------------------
  # new method: subclass
  #--------------------------------------------------------------------------
  def subclass
    init_subclass if @subclass_id.nil?
    return $data_classes[@subclass_id]
  end
  
  #--------------------------------------------------------------------------
  # alias method: change_class
  #--------------------------------------------------------------------------
  alias game_actor_change_class_cs change_class
  def change_class(class_id, keep_exp = false)
    @subclass_id = 0 if @subclass_id == class_id
    game_actor_change_class_cs(class_id, keep_exp)
    learn_class_skills(class_id)
    unlock_class(class_id)
  end
  
  #--------------------------------------------------------------------------
  # new method: learn_class_skills
  #--------------------------------------------------------------------------
  def learn_class_skills(class_id)
    return if class_id <= 0
    return if $data_classes[class_id].nil?
    $data_classes[class_id].learnings.each do |learning|
      learn_skill(learning.skill_id) if learning.level == class_level(class_id)
    end
  end
  
  #--------------------------------------------------------------------------
  # new method: change_subclass
  #--------------------------------------------------------------------------
  def change_subclass(class_id)
    return if class_id == @class_id
    unlock_class(class_id)
    @subclass_id = @subclass_id == class_id ? 0 : class_id
    learn_class_skills(@subclass_id)
    refresh
  end
        #————————————————————————–
        # new method: class_level Edited by DisturbedInside
        #————————————————————————–
        def class_level(class_id)
                return @level if YEA::CLASS_SYSTEM::MAINTAIN_LEVELS
                        temp_class = $data_classes[class_id]
                        @exp[class_id] = 0 if @exp[class_id].nil?
                        #declare a max level (using EXP)
                        #If you can’t find it, go to the class database and select exp curve
                        #then switch view to total at the top
                        @exp[max_level] = 2547133 #This is the value to change. It declares a max level
                        #You need to calculate how much exp for max level
                        #Do it manually if using Yanfly-Adjusting Limits
                        #To calculate max level exp if using Yanfly-adjusting limits is all math!!

                        # Level 99 = 2547133
                        # to calculate past there…. have to add on multiples of 50744
                        # Level 110 = 3156061
                        # To go from 99 -> 110 have to add on 12 multiples of 50744.
                        n = 1                       
                        loop do
                                break if temp_class.exp_for_level(n+1) > @exp[class_id]
                                n += 1
                                #add a restriction to “kick out” of loop if exp exceeds max level exp
                                break if temp_class.exp_for_level(n+1) > @exp[max_level]
                        end
                return n
        end
  
  #--------------------------------------------------------------------------
  # new method: subclass_level
  #--------------------------------------------------------------------------
  def subclass_level
    return 0 if @subclass_id == 0
    return @level if YEA::CLASS_SYSTEM::MAINTAIN_LEVELS
    return class_level(@subclass_id)
  end
  
  #--------------------------------------------------------------------------
  # alias method: param_base
  #--------------------------------------------------------------------------
  alias game_actor_param_base_cs param_base
  def param_base(param_id)
    result = game_actor_param_base_cs(param_id)
    unless subclass.nil?
      subclass_rate = YEA::CLASS_SYSTEM::SUBCLASS_STAT_RATE
      slevel = subclass_level
      result += subclass.params[param_id, slevel] * subclass_rate
    end
    return result.to_i
  end
  
  #--------------------------------------------------------------------------
  # new method: subclass_skill_types
  #--------------------------------------------------------------------------
  def subclass_skill_types
    return [] unless YEA::CLASS_SYSTEM::SUBCLASS_SKILL_TYPES
    return [] if subclass.nil?
    array = []
    for feature in subclass.features
      next unless feature.code == FEATURE_STYPE_ADD
      next if features_set(FEATURE_STYPE_ADD).include?(feature.data_id)
      array.push(feature.data_id)
    end
    return array
  end
  
  #--------------------------------------------------------------------------
  # new method: subclass_equip_wtype?
  #--------------------------------------------------------------------------
  def subclass_equip_wtype?(wtype_id)
    return false unless YEA::CLASS_SYSTEM::SUBCLASS_WEAPON_TYPES
    return false if subclass.nil?
    for feature in subclass.features
      next unless feature.code == FEATURE_EQUIP_WTYPE
      return true if wtype_id == feature.data_id
    end
    return super
  end
  
  #--------------------------------------------------------------------------
  # new method: subclass_equip_atype?
  #--------------------------------------------------------------------------
  def subclass_equip_atype?(atype_id)
    return false unless YEA::CLASS_SYSTEM::SUBCLASS_ARMOUR_TYPES
    return false if subclass.nil?
    for feature in subclass.features
      next unless feature.code == FEATURE_EQUIP_ATYPE
      return true if atype_id == feature.data_id
    end
    return super
  end
  
  #--------------------------------------------------------------------------
  # alias method: release_unequippable_items
  #--------------------------------------------------------------------------
  alias game_actor_release_unequippable_items_cs release_unequippable_items
  def release_unequippable_items(item_gain = true)
    item_gain = false if @temp_flag
    game_actor_release_unequippable_items_cs(item_gain)
  end
  
end # Game_Actor

#==============================================================================
# ■ Game_Interpreter
#==============================================================================

class Game_Interpreter
  
  #--------------------------------------------------------------------------
  # overwrite method: command_321
  #--------------------------------------------------------------------------
  def command_321
    actor = $game_actors[@params[0]]
    if actor && $data_classes[@params[1]]
      maintain = YEA::CLASS_SYSTEM::MAINTAIN_LEVELS
      actor.change_class(@params[1], maintain)
    end
  end
  
end # Game_Interpreter

#==============================================================================
# ■ Window_Base
#==============================================================================

class Window_Base < Window
  
  #--------------------------------------------------------------------------
  # overwrite method: draw_actor_class
  #--------------------------------------------------------------------------
  def draw_actor_class(actor, x, y, width = 112)
    change_color(normal_color)
    if actor.subclass.nil?
      text = actor.class.name
    else
      fmt = YEA::CLASS_SYSTEM::SUBCLASS_TEXT
      text = sprintf(fmt, actor.class.name, actor.subclass.name)
    end
    draw_text(x, y, width, line_height, text)
  end
  
end # Window_Base

#==============================================================================
# ■ Window_MenuCommand
#==============================================================================

class Window_MenuCommand < Window_Command
  
  #--------------------------------------------------------------------------
  # alias method: add_formation_command
  #--------------------------------------------------------------------------
  alias window_menucommand_add_formation_command_cs add_formation_command
  def add_formation_command
    add_class_command unless $imported["YEA-AceMenuEngine"]
    window_menucommand_add_formation_command_cs
  end
  
  #--------------------------------------------------------------------------
  # new method: add_class_command
  #--------------------------------------------------------------------------
  def add_class_command
    return unless Switch.class_show
    text = YEA::CLASS_SYSTEM::CLASS_MENU_TEXT
    add_command(text, :class, Switch.class_enable)
  end
  
end # Window_MenuCommand

#==============================================================================
# ■ Window_ClassCommand
#==============================================================================

class Window_ClassCommand < Window_Command
  
  #--------------------------------------------------------------------------
  # initialize
  #--------------------------------------------------------------------------
  def initialize(x, y)
    super(x, y)
    @actor = nil
  end
  
  #--------------------------------------------------------------------------
  # ● ウィンドウ幅の取得
  #--------------------------------------------------------------------------
  def window_width; return 160; end
  
  #--------------------------------------------------------------------------
  # actor=
  #--------------------------------------------------------------------------
  def actor=(actor)
    return if @actor == actor
    @actor = actor
    refresh
  end
  
  #--------------------------------------------------------------------------
  # item_window=
  #--------------------------------------------------------------------------
  def item_window=(window)
    @item_window = window
  end
  
  #--------------------------------------------------------------------------
  # visible_line_number
  #--------------------------------------------------------------------------
  def visible_line_number; return 4; end
  
  #--------------------------------------------------------------------------
  # make_command_list
  #--------------------------------------------------------------------------
  def make_command_list
    return if @actor.nil?
    for command in YEA::CLASS_SYSTEM::COMMANDS
      case command[0]
      when :primary
        next unless Switch.primary_show
        add_command(command[1], command[0], Switch.primary_enable)
      when :subclass
        next unless Switch.subclass_show
        add_command(command[1], command[0], Switch.subclass_enable)
      when :learn_skill
        next unless $imported["YEA-LearnSkillEngine"]
        add_learn_skill_command
      else
        process_custom_command(command)
      end
    end
    if !$game_temp.scene_class_index.nil?
      select($game_temp.scene_class_index)
      self.oy = $game_temp.scene_class_oy
    end
    $game_temp.scene_class_index = nil
    $game_temp.scene_class_oy = nil
  end
  
  #--------------------------------------------------------------------------
  # process_ok
  #--------------------------------------------------------------------------
  def process_ok
    $game_temp.scene_class_index = index
    $game_temp.scene_class_oy = self.oy
    super
  end
  
  #--------------------------------------------------------------------------
  # process_custom_command
  #--------------------------------------------------------------------------
  def process_custom_command(command)
    return unless YEA::CLASS_SYSTEM::CUSTOM_CLASS_COMMANDS.include?(command[0])
    show = YEA::CLASS_SYSTEM::CUSTOM_CLASS_COMMANDS[command[0]][1]
    continue = show <= 0 ? true : $game_switches[show]
    return unless continue
    text = command[1]
    switch = YEA::CLASS_SYSTEM::CUSTOM_CLASS_COMMANDS[command[0]][0]
    enabled = switch <= 0 ? true : $game_switches[switch]
    add_command(text, command[0], enabled)
  end
  
  #--------------------------------------------------------------------------
  # update
  #--------------------------------------------------------------------------
  def update
    super
    update_visible_windows
  end
  
  #--------------------------------------------------------------------------
  # update_visible_windows
  #--------------------------------------------------------------------------
  def update_visible_windows
    return if @current_index == current_symbol
    @current_index = current_symbol
    @item_window.refresh unless @item_window.nil?
  end
  
  #--------------------------------------------------------------------------
  # add_learn_skill_command
  #--------------------------------------------------------------------------
  def add_learn_skill_command
    return unless Switch.show_learn_skill
    name = YEA::LEARN_SKILL::COMMAND_NAME
    add_command(name, :learn_skill, true)
  end
  
end # Window_ClassCommand

#==============================================================================
# ■ Window_ClassStatus
#==============================================================================

class Window_ClassStatus < Window_Base
  
  #--------------------------------------------------------------------------
  # initialize
  #--------------------------------------------------------------------------
  def initialize(dx, dy)
    super(dx, dy, window_width, fitting_height(4))
    @actor = nil
  end
  
  #--------------------------------------------------------------------------
  # window_width
  #--------------------------------------------------------------------------
  def window_width; Graphics.width - 160; end
  
  #--------------------------------------------------------------------------
  # actor=
  #--------------------------------------------------------------------------
  def actor=(actor)
    return if @actor == actor
    @actor = actor
    refresh
  end
  
  #--------------------------------------------------------------------------
  # refresh
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    return if @actor.nil?
    draw_actor_face(@actor, 0, 0)
    draw_actor_simple_status(@actor, 108, line_height / 2)
  end
  
end # Window_ClassStatus

#==============================================================================
# ■ Window_ClassParam
#==============================================================================

class Window_ClassParam < Window_Base
  
  #--------------------------------------------------------------------------
  # initialize
  #--------------------------------------------------------------------------
  def initialize(dx, dy)
    super(dx, dy, window_width, Graphics.height - dy)
    @actor = nil
    @temp_actor = nil
    refresh
  end
  
  #--------------------------------------------------------------------------
  # window_width
  #--------------------------------------------------------------------------
  def window_width; return Graphics.width * 2 / 5; end
  
  #--------------------------------------------------------------------------
  # actor=
  #--------------------------------------------------------------------------
  def actor=(actor)
    return if @actor == actor
    @actor = actor
    refresh
  end
  
  #--------------------------------------------------------------------------
  # refresh
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    8.times {|i| draw_item(0, line_height * i, i) }
  end
  
  #--------------------------------------------------------------------------
  # set_temp_actor
  #--------------------------------------------------------------------------
  def set_temp_actor(temp_actor)
    return if @temp_actor == temp_actor
    @temp_actor = temp_actor
    refresh
  end
  
  #--------------------------------------------------------------------------
  # draw_item
  #--------------------------------------------------------------------------
  def draw_item(dx, dy, param_id)
    draw_background_colour(dx, dy)
    draw_param_name(dx + 4, dy, param_id)
    draw_current_param(dx + 4, dy, param_id) if @actor
    drx = (contents.width + 22) / 2
    draw_right_arrow(drx, dy)
    draw_new_param(drx + 22, dy, param_id) if @temp_actor
    reset_font_settings
  end
  
  #--------------------------------------------------------------------------
  # draw_background_colour
  #--------------------------------------------------------------------------
  def draw_background_colour(dx, dy)
    colour = Color.new(0, 0, 0, translucent_alpha/2)
    rect = Rect.new(dx+1, dy+1, contents.width - 2, line_height - 2)
    contents.fill_rect(rect, colour)
  end
  
  #--------------------------------------------------------------------------
  # overwrite method: draw_param_name
  #--------------------------------------------------------------------------
  def draw_param_name(dx, dy, param_id)
    contents.font.size = YEA::CLASS_SYSTEM::PARAM_FONT_SIZE
    change_color(system_color)
    draw_text(dx, dy, contents.width, line_height, Vocab::param(param_id))
  end
  
  #--------------------------------------------------------------------------
  # overwrite method: draw_current_param
  #--------------------------------------------------------------------------
  def draw_current_param(dx, dy, param_id)
    change_color(normal_color)
    dw = (contents.width + 22) / 2
    draw_text(0, dy, dw, line_height, @actor.param(param_id).group, 2)
    reset_font_settings
  end
  
  #--------------------------------------------------------------------------
  # draw_right_arrow
  #--------------------------------------------------------------------------
  def draw_right_arrow(x, y)
    change_color(system_color)
    draw_text(x, y, 22, line_height, "→", 1)
  end
  
  #--------------------------------------------------------------------------
  # draw_new_param
  #--------------------------------------------------------------------------
  def draw_new_param(dx, dy, param_id)
    contents.font.size = YEA::CLASS_SYSTEM::PARAM_FONT_SIZE
    new_value = @temp_actor.param(param_id)
    change_color(param_change_color(new_value - @actor.param(param_id)))
    draw_text(0, dy, contents.width-4, line_height, new_value.group, 2)
    reset_font_settings
  end
  
end # Window_ClassParam

#==============================================================================
# ■ Window_ClassList
#==============================================================================

class Window_ClassList < Window_Selectable
  
  #--------------------------------------------------------------------------
  # initialize
  #--------------------------------------------------------------------------
  def initialize(dx, dy)
    dw = Graphics.width - (Graphics.width * 2 / 5)
    dh = Graphics.height - dy
    super(dx, dy, dw, dh)
    @actor = nil
    @command_window = nil
    @status_window
    @data = []
  end
  
  #--------------------------------------------------------------------------
  # actor=
  #--------------------------------------------------------------------------
  def actor=(actor)
    return if @actor == actor
    @actor = actor
    @last_item = nil
    refresh
    self.oy = 0
  end
  
  #--------------------------------------------------------------------------
  # command_window=
  #--------------------------------------------------------------------------
  def command_window=(command_window)
    @command_window = command_window
  end
  
  #--------------------------------------------------------------------------
  # status_window=
  #--------------------------------------------------------------------------
  def status_window=(status_window)
    @status_window = status_window
  end
  
  #--------------------------------------------------------------------------
  # item_max
  #--------------------------------------------------------------------------
  def item_max; return @data ? @data.size : 1; end
  
  #--------------------------------------------------------------------------
  # item
  #--------------------------------------------------------------------------
  def item; return @data && index >= 0 ? @data[index] : nil; end
  
  #--------------------------------------------------------------------------
  # current_item_enabled?
  #--------------------------------------------------------------------------
  def current_item_enabled?; return enable?(@data[index]); end
  
  #--------------------------------------------------------------------------
  # include?
  #--------------------------------------------------------------------------
  def include?(item)
    return true if YEA::CLASS_SYSTEM::DEFAULT_UNLOCKS.include?(item.id)
    return @actor.unlocked_classes.include?(item.id)
  end
  
  #--------------------------------------------------------------------------
  # enable?
  #--------------------------------------------------------------------------
  def enable?(item)
    return false if item == @actor.class
    return true
  end
  
  #--------------------------------------------------------------------------
  # make_item_list
  #--------------------------------------------------------------------------
  def make_item_list
    @data = []
    for class_id in YEA::CLASS_SYSTEM::CLASS_ORDER
      next if $data_classes[class_id].nil?
      item = $data_classes[class_id]
      @data.push(item) if include?(item)
    end
  end
  
  #--------------------------------------------------------------------------
  # select_last
  #--------------------------------------------------------------------------
  def select_last
    case @command_window.current_symbol
    when :primary
      select(@data.index(@actor.class))
    when :subclass
      select(0) if @actor.subclass.nil?
      select(@data.index(@actor.subclass)) unless @actor.subclass.nil?
    else
      select(0)
    end
  end
  
  #--------------------------------------------------------------------------
  # draw_item
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    return if item.nil?
    rect = item_rect(index)
    rect.width -= 4
    reset_font_settings
    set_item_colour(item)
    draw_class_icon(item, rect)
    draw_class_name(item, rect)
    draw_class_level(item, rect)
  end
  
  #--------------------------------------------------------------------------
  # set_item_colour
  #--------------------------------------------------------------------------
  def set_item_colour(item)
    if item == @actor.class
      change_color(text_color(YEA::CLASS_SYSTEM::CURRENT_CLASS_COLOUR))
    elsif item == @actor.subclass
      change_color(text_color(YEA::CLASS_SYSTEM::SUBCLASS_COLOUR))
    else
      change_color(normal_color, enable?(item))
    end
  end
  
  #--------------------------------------------------------------------------
  # draw_class_icon
  #--------------------------------------------------------------------------
  def draw_class_icon(item, rect)
    icon = item.icon_index
    draw_icon(icon, rect.x, rect.y, enable?(item))
  end
  
  #--------------------------------------------------------------------------
  # draw_class_name
  #--------------------------------------------------------------------------
  def draw_class_name(item, rect)
    text = item.name
    draw_text(24, rect.y, rect.width-24, line_height, text)
  end
  
  #--------------------------------------------------------------------------
  # draw_class_level
  #--------------------------------------------------------------------------
  def draw_class_level(item, rect)
    return if YEA::CLASS_SYSTEM::MAINTAIN_LEVELS
    return if @actor.nil?
    level = @actor.class_level(item.id)
    contents.font.size = YEA::CLASS_SYSTEM::LEVEL_FONT_SIZE
    text = sprintf(YEA::CLASS_SYSTEM::CLASS_LEVEL, level.group)
    draw_text(rect, text, 2)
  end
  
  #--------------------------------------------------------------------------
  # update_help
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_item(item)
    return if @actor.nil?
    return if @status_window.nil?
    update_param_window
  end
  
  #--------------------------------------------------------------------------
  # update_param_window
  #--------------------------------------------------------------------------
  def update_param_window
    return if @last_item == item
    @last_item = item
    class_id = item.nil? ? @actor.class_id : item.id
    temp_actor = Marshal.load(Marshal.dump(@actor))
    temp_actor.temp_flag = true
    case @command_window.current_symbol
    when :primary
      temp_actor.change_class(class_id, YEA::CLASS_SYSTEM::MAINTAIN_LEVELS)
    when :subclass
      temp_actor.change_subclass(class_id)
    end
    @status_window.set_temp_actor(temp_actor)
  end
  
  #--------------------------------------------------------------------------
  # update_class
  #--------------------------------------------------------------------------
  def update_class
    @last_item = nil
    update_help
    refresh
    activate
  end
  
  #--------------------------------------------------------------------------
  # refresh
  #--------------------------------------------------------------------------
  def refresh
    make_item_list
    create_contents
    draw_all_items
  end
  
end # Window_ClassList

#==============================================================================
# ■ Scene_Menu
#==============================================================================

class Scene_Menu < Scene_MenuBase
  
  #--------------------------------------------------------------------------
  # alias method: create_command_window
  #--------------------------------------------------------------------------
  alias scene_menu_create_command_window_cs create_command_window
  def create_command_window
    scene_menu_create_command_window_cs
    @command_window.set_handler(:class, method(:command_personal))
  end
  
  #--------------------------------------------------------------------------
  # alias method: on_personal_ok
  #--------------------------------------------------------------------------
  alias scene_menu_on_personal_ok_cs on_personal_ok
  def on_personal_ok
    case @command_window.current_symbol
    when :class
      SceneManager.call(Scene_Class)
    else
      scene_menu_on_personal_ok_cs
    end
  end
  
end # Scene_Menu

#==============================================================================
# ■ Scene_Class
#==============================================================================

class Scene_Class < Scene_MenuBase
  
  #--------------------------------------------------------------------------
  # start
  #--------------------------------------------------------------------------
  def start
    super
    create_help_window
    create_command_window
    create_status_window
    create_param_window
    create_item_window
    relocate_windows
  end
  
  #--------------------------------------------------------------------------
  # create_command_window
  #--------------------------------------------------------------------------
  def create_command_window
    wy = @help_window.height
    @command_window = Window_ClassCommand.new(0, wy)
    @command_window.viewport = @viewport
    @command_window.help_window = @help_window
    @command_window.actor = @actor
    @command_window.set_handler(:cancel,   method(:return_scene))
    @command_window.set_handler(:primary,  method(:command_class_change))
    @command_window.set_handler(:subclass, method(:command_class_change))
    process_custom_class_commands
    return if $game_party.in_battle
    @command_window.set_handler(:pagedown, method(:next_actor))
    @command_window.set_handler(:pageup,   method(:prev_actor))
    @command_window.set_handler(:learn_skill, method(:command_learn_skill))
  end
  
  #--------------------------------------------------------------------------
  # process_custom_class_commands
  #--------------------------------------------------------------------------
  def process_custom_class_commands
    for command in YEA::CLASS_SYSTEM::COMMANDS
      next unless YEA::CLASS_SYSTEM::CUSTOM_CLASS_COMMANDS.include?(command[0])
      called_method = YEA::CLASS_SYSTEM::CUSTOM_CLASS_COMMANDS[command[0]][2]
      @command_window.set_handler(command[0], method(called_method))
    end
  end
  
  #--------------------------------------------------------------------------
  # create_status_window
  #--------------------------------------------------------------------------
  def create_status_window
    wy = @help_window.height
    @status_window = Window_ClassStatus.new(@command_window.width, wy)
    @status_window.viewport = @viewport
    @status_window.actor = @actor
  end
  
  #--------------------------------------------------------------------------
  # create_param_window
  #--------------------------------------------------------------------------
  def create_param_window
    dx = Graphics.width - (Graphics.width * 2 / 5)
    dy = @status_window.y + @status_window.height
    @param_window = Window_ClassParam.new(dx, dy)
    @param_window.viewport = @viewport
    @param_window.actor = @actor
  end
  
  #--------------------------------------------------------------------------
  # create_item_window
  #--------------------------------------------------------------------------
  def create_item_window
    dy = @status_window.y + @status_window.height
    @item_window = Window_ClassList.new(0, dy)
    @item_window.help_window = @help_window
    @item_window.command_window = @command_window
    @item_window.status_window = @param_window
    @item_window.viewport = @viewport
    @item_window.actor = @actor
    @command_window.item_window = @item_window
    @item_window.set_handler(:ok,     method(:on_class_ok))
    @item_window.set_handler(:cancel, method(:on_class_cancel))
  end
  
  #--------------------------------------------------------------------------
  # relocate_windows
  #--------------------------------------------------------------------------
  def relocate_windows
    return unless $imported["YEA-AceMenuEngine"]
    case Menu.help_window_location
    when 0 # Top
      @help_window.y = 0
      @command_window.y = @help_window.height
      @param_window.y = @command_window.y + @command_window.height
    when 1 # Middle
      @command_window.y = 0
      @help_window.y = @command_window.height
      @param_window.y = @help_window.y + @help_window.height
    else # Bottom
      @command_window.y = 0
      @param_window.y = @command_window.height
      @help_window.y = @param_window.y + @param_window.height
    end
    @status_window.y = @command_window.y
    @item_window.y = @param_window.y
  end
  
  #--------------------------------------------------------------------------
  # on_actor_change
  #--------------------------------------------------------------------------
  def on_actor_change
    @command_window.actor = @actor
    @status_window.actor = @actor
    @param_window.actor = @actor
    @item_window.actor = @actor
    @command_window.activate
  end
  
  #--------------------------------------------------------------------------
  # command_class_change
  #--------------------------------------------------------------------------
  def command_class_change
    @item_window.activate
    @item_window.select_last
  end
  
  #--------------------------------------------------------------------------
  # on_class_cancel
  #--------------------------------------------------------------------------
  def on_class_cancel
    @item_window.unselect
    @command_window.activate
    @param_window.set_temp_actor(nil)
  end
  
  #--------------------------------------------------------------------------
  # on_class_ok
  #--------------------------------------------------------------------------
  def on_class_ok
    Sound.play_equip
    class_id = @item_window.item.id
    maintain = YEA::CLASS_SYSTEM::MAINTAIN_LEVELS
    hp = @actor.hp * 1.0 / @actor.mhp
    mp = @actor.mp * 1.0 / [@actor.mmp, 1].max
    case @command_window.current_symbol
    when :primary
      @actor.change_class(class_id, maintain)
    when :subclass
      @actor.change_subclass(class_id)
    else
      @item_window.activate
      return
    end
    @actor.hp = (@actor.mhp * hp).to_i
    @actor.mp = (@actor.mmp * mp).to_i
    @status_window.refresh
    @item_window.update_class
  end
  
  #--------------------------------------------------------------------------
  # new method: command_learn_skill
  #--------------------------------------------------------------------------
  def command_learn_skill
    return unless $imported["YEA-LearnSkillEngine"]
    SceneManager.call(Scene_LearnSkill)
  end
  
  #--------------------------------------------------------------------------
  # command_name1
  #--------------------------------------------------------------------------
  def command_name1
    # Do nothing.
  end
  
  #--------------------------------------------------------------------------
  # command_name2
  #--------------------------------------------------------------------------
  def command_name2
    # Do nothing.
  end
  
end # Scene_Class

#==============================================================================
#
# ▼ End of File
#
#==============================================================================[/fold]
梦石
0
星屑
29901
在线时间
5734 小时
注册时间
2016-3-8
回帖
1653
发表于 2021-8-24 11:02:09 | 显示全部楼层
[pre lang="ruby"]=begin
#==============================================================================
** EST - YEA - SUBCLASS ADD ON : GAIN EXP , LEARN SKILL, WORKING TRAIT, ETC
REWRITTEN !!!
v 3.07
#------------------------------------------------------------------------------
Author : ESTRIOLE
also credits: Disturbed Inside for class level bugfix which i modified more

Version History:
  v 1.00 - 2012.06.21 > First relase
  v 2.00 - final - 2012.06.25 > updated skill and trait from subclass works
  v 3.00 - 2013.03.24 > - rewritten the script. to make it lots more
                        compatible with another script.
                        - add ability to set class max level by notetags:
                        <class_max_lv: 20>
                        to set the class max lv to 20.
                        - add ability to set subclass exp rate for each class.
                        so when that class is equipped as subclass. how many
                        percent exp it will gained.
                        <sub_exp_rate: 50>
                        to set the class sub exp rate to 50 percent
  v 3.01 - 2013.03.29 > - add configuration to set when exp divided by sub exp
                        rate below 1. it could set exp gain to 1 instead of 0.
                        example1: slimex2 give 8 exp * subrate 10% = 0,8 -> 1 exp
                        example2: slimex2 give 0 exp * subrate 10% = 0 -> 0 exp.
  v 3.02 - 2013.05.26 > - add support for float percentage sub exp rate. ex:
                        <sub_exp_rate: 1.5> means 1.5% rate.
                        even i doubt people will use it... but the function is available in case
                        someone crazy enough to use it :D.
                        - add ability to boost/reduce sub exp rate
                        give notetags to actor/class/weapon/armor/state
                        <sub_exp_mod: 30> means +30%
                        it's direct addition to current rate so if the rate 50% it will become 80%
                        <sub_exp_mod: -30> means -30%
                        it's direct substraction to current rate so if the rate 50% it will become 20%
                        all actor/class/subclass/weapon/armor/state mod stacks
                        usefull to make accessory that make your subclass gain (+30% battle exp)
                        - add ability to grant multiplier to sub_exp_rate. ex:
                        <sub_exp_mult: 150> will multiply current rate to 150%
                        multiplier STACKS
  v 3.03 - 2013.05.28 > - add MAIN EXP RATE function. this function is SEPARATE
                        with SUB EXP RATE. means increasing MAIN EXP RATE didn't
                        raise sub exp gained. ONLY raised exp gained by main class.
                        notetags the class with:
                        <main_exp_rate: 75> -> to set main class exp rate to 75 percent
                        - add ability to boost/reduce main exp rate
                        give notetags to actor/class/weapon/armor/state
                        <main_exp_mod: 30> means +30%
                        it's direct addition to current rate so if the rate 50% it will become 80%
                        <main_exp_mod: -30> means -30%
                        it's direct substraction to current rate so if the rate 50% it will become 20%
                        all actor/class/subclass/weapon/armor/state mod stacks
                        usefull to make accessory that make your mainclass gain (+30% battle exp)
                        - add ability to grant multiplier to main_exp_rate. ex:
                        <main_exp_mult: 150> will multiply current rate to 150%
                        multiplier STACKS
  v 3.04 - 2013.10.22 > - add compatibility patch to yanfly adjust limit script                        
  v 3.05 - 2014.01.09 > - stop exp gain when max level reached. (both subclass and main class works now)
                        in case the exp gained will make the actor exceed max level... it will add to maximum exp
                        you can get to reach next level and ignore the rest.  
  v 3.06 - 2014.01.16 > - compatibility patch with yanfly victory aftermath. to recognize exp rate.
  v 3.07 - 2014.07.16 > - fix the script. IF maintain level set to true. stop the sub exp gain.
                        since the level should be the same with main class.
                        
#------------------------------------------------------------------------------
  This script is addon to YEA class system. Subclass equipped will gain
  full or some exp. gain skill as the subclass level up. actor will have
  all the subclass trait. also if using Tsukihime Effect Manager. subclass
  can be given 'effect' too like normal class.
#------------------------------------------------------------------------------
Compatibility
   1) REQUIRES the script YEA - Class System. put this script below yanfly class script

   -> built in compatibility with Tsukihime Effect Manager script
   -> built in compatibility with Formar extra trait lv up script
   -> built in compatibility with yanfly adjust limit

   2) put this script BELOW yanfly victory aftermath
   
HOW TO USE:
1) by plugging this script automatically...
    - subclass gain exp (default sub_exp_rate is using what you defined in config)
    - subclass's skill and trait gained by actor
    - subclass's effect is executed (if using tsukihime effect manager)
   
2) you can set a class max level by notetagging the class with:

    <class_max_lv: 20>
    to set the class max lv to 20. change the number as you want.

3) to customize each class to have different sub exp rate. give the class

    <sub_exp_rate: 50>
    to set the class sub exp rate to 50%.  change the number as you want.
   
    support float percentage. ex:
   
    <sub_exp_rate: 2.5>
    to set the class sub exp rate to 2.5%   

4) you can give sub_exp_rate modifier by notetagging:
    actor / class / subclass / weapon / armor / state
   
    <sub_exp_mod: 30> means +30% increase to sub exp rate

    it's direct addition so if current sub_exp_rate is 50% it will become 80%
    support negative value too
   
    <sub_exp_mod: -30> means -30% decrease to sub exp rate
   
    it's direct substraction so if current sub_exp_rate is 50% it will become 20%
    ALL sub exp rate modifier STACKS
    so example current sub exp rate 50%
    actor +10%, class -5%, subclass -5%, weapon +100%, armor1 -10%, armor2 -5%, state1 10%, state2 - 10%
    final rate = (50%) +10% -5% -5% +100% -10% -5% +10% + 10%
    count it yourself :D.

5) you can give sub_exp_rate multiplier by notetagging:
    actor / class / subclass / weapon / armor / state
   
    <sub_exp_mult: 150> means sub exp rate multiplied by 150%

    it's multiplication so if current sub_exp_rate is 50% it will become 75%
    current sub_exp rate is sub exp rate after adding sub_exp_mod
    ALL sub exp rate multiplier STACKS
    so example current sub exp rate 50% (after adding exp_mod)
    actor *150%, class *50%, subclass *500%, weapon *125%, armor1 *250%, armor2 *105%, state1 *410%, state2 *310%
    final rate = (50%) * 150% * 500% * 125% * 250% * 105% * 410% * 310%
    count it yourself :D.

6) to customize each class to have different main exp rate. give the class

    <main_exp_rate: 50>
    to set the class main exp rate to 50%.  change the number as you want.
   
    support float percentage. ex:
   
    <main_exp_rate: 2.5>
    to set the class main exp rate to 2.5%   

7) you can give main_exp_rate modifier by notetagging:
    actor / class / subclass / weapon / armor / state
   
    <main_exp_mod: 30> means +30% increase to main exp rate

    it's direct addition so if current main_exp_rate is 50% it will become 80%
    support negative value too
   
    <main_exp_mod: -30> means -30% decrease to main exp rate
   
    it's direct substraction so if current main_exp_rate is 50% it will become 20%
    ALL main exp rate modifier STACKS
    so example current main exp rate 50%
    actor +10%, class -5%, subclass -5%, weapon +100%, armor1 -10%, armor2 -5%, state1 10%, state2 - 10%
    final rate = (50%) +10% -5% -5% +100% -10% -5% +10% + 10%
    count it yourself :D.

8) you can give main_exp_rate multiplier by notetagging:
    actor / class / subclass / weapon / armor / state
   
    <main_exp_mult: 150> means main exp rate multiplied by 150%

    it's multiplication so if current main_exp_rate is 50% it will become 75%
    current main_exp rate is main exp rate after adding main_exp_mod
    ALL main exp rate multiplier STACKS
    so example current main exp rate 50% (after adding exp_mod)
    actor *150%, class *50%, subclass *500%, weapon *125%, armor1 *250%, armor2 *105%, state1 *410%, state2 *310%
    final rate = (50%) * 150% * 500% * 125% * 250% * 105% * 410% * 310%
    count it yourself :D.
   
interesting play with subexpmod and subexpmult...
create a subclass only which have no growth in subclass. but after equipping
some accessory that increase subexpmod. it will have some growth and raised lv.
could create a weapon/armor which is strong but subexpmult = 0%. so no growth.   

#------------------------------------------------------------------------------
=end

module ESTRIOLE
  SUB_EXP_RATE = 50   #default sub exp rate (in percentage so 50 means 50% exp,
                      #200 means 200% exp. etc). when no notetags set for that class
  MAIN_EXP_RATE = 100 #default MAIN exp rate (in percentage so 50 means 50% exp,
                      #200 means 200% exp. etc). when no notetags set for that class
                      #better to leave it at 100%
  SUBCLASS_VOCAB = "Subclass"
  SUBCLASS_MIN_1_EXP = true #if true minimum 1 exp gained when the result exp x sub exp rate is between 0 - 1
  
  module VICTORY_AFTERMATH
  VICTORY_SUB_EXP  = "+%sSUBEXP"      # Text used to display SUB EXP. IF USING YANFLY VICTORY AFTERMATH SCRIPT
  end

end

class RPG::BaseItem
  def sub_exp_mod
    return nil if !@note[/<sub_exp_mod:(.*)>/i]
    a = @note[/<sub_exp_mod:(.*)>/i].scan(/:(.*)/).flatten[0].scan(/(?:"(.*?)"| ([-\w.\w]+)|([-\w.\w]+),|,([-\w.\w]+))/).flatten.compact
    return noteargs = a[0].to_f
  end   
  def sub_exp_mult
    return nil if !@note[/<sub_exp_mult:(.*)>/i]
    a = @note[/<sub_exp_mult:(.*)>/i].scan(/:(.*)/).flatten[0].scan(/(?:"(.*?)"| ([-\w.\w]+)|([-\w.\w]+),|,([-\w.\w]+))/).flatten.compact
    return noteargs = a[0].to_f
  end   
  def main_exp_mod
    return nil if !@note[/<main_exp_mod:(.*)>/i]
    a = @note[/<main_exp_mod:(.*)>/i].scan(/:(.*)/).flatten[0].scan(/(?:"(.*?)"| ([-\w.\w]+)|([-\w.\w]+),|,([-\w.\w]+))/).flatten.compact
    return noteargs = a[0].to_f
  end   
  def main_exp_mult
    return nil if !@note[/<main_exp_mult:(.*)>/i]
    a = @note[/<main_exp_mult:(.*)>/i].scan(/:(.*)/).flatten[0].scan(/(?:"(.*?)"| ([-\w.\w]+)|([-\w.\w]+),|,([-\w.\w]+))/).flatten.compact
    return noteargs = a[0].to_f
  end   
end
#Notetags ability to set max level for each class instead of using actor max_lv
class RPG::Class < RPG::BaseItem
  def max_level
    return nil if !@note[/<class_max_lv:(.*)>/i]
    a = @note[/<class_max_lv:(.*)>/i].scan(/:(.*)/).flatten[0].scan(/(?:"(.*?)"| ([-\w.\w]+)|([-\w.\w]+),|,([-\w.\w]+))/).flatten.compact
    return noteargs = a[0].to_i
  end
  def sub_exp_rate
    return nil if !@note[/<sub_exp_rate:(.*)>/i]
    a = @note[/<sub_exp_rate:(.*)>/i].scan(/:(.*)/).flatten[0].scan(/(?:"(.*?)"| ([-\w.\w]+)|([-\w.\w]+),|,([-\w.\w]+))/).flatten.compact
    return noteargs = a[0].to_f
  end  
  def main_exp_rate
    return nil if !@note[/<main_exp_rate:(.*)>/i]
    a = @note[/<main_exp_rate:(.*)>/i].scan(/:(.*)/).flatten[0].scan(/(?:"(.*?)"| ([-\w.\w]+)|([-\w.\w]+),|,([-\w.\w]+))/).flatten.compact
    return noteargs = a[0].to_f
  end  
end

class Game_Actor < Game_Battler
  def main_exp_rate(class_id)
    exprate = $data_classes[class_id].main_exp_rate ? $data_classes[class_id].main_exp_rate * 0.01 : ESTRIOLE::MAIN_EXP_RATE  * 0.01
    exprate = (exprate + main_exp_mod) * main_exp_mult
    exprate = [exprate,0].max #disallow negative exp rate
  end
  def main_exp_mod
    actormod = (self.actor.main_exp_mod ? self.actor.main_exp_mod : 0) rescue 0
    classmod = (self.class.main_exp_mod ? self.class.main_exp_mod : 0) rescue 0
    subclassmod = (self.subclass.main_exp_mod ? self.subclass.main_exp_mod : 0) rescue 0
    equipsmod = 0
    equips.each do |equip|
      next if !equip
      equipsmod += equip.main_exp_mod if equip.main_exp_mod
    end   
    statesmod = 0
    states.each do |state|
      statesmod += state.main_exp_mod if state.main_exp_mod
    end
    return main_exp_mod = (actormod + classmod + subclassmod + equipsmod + statesmod) * 0.01
  end
  def main_exp_mult
    actor_mult = (self.actor.main_exp_mult ? self.main_exp_mult * 0.01 : 1) rescue 1
    class_mult = (self.class.main_exp_mult ? self.class.main_exp_mult * 0.01 : 1) rescue 1
    subclass_mult = (self.subclass.main_exp_mult ? self.subclass.main_exp_mult * 0.01 : 1) rescue 1
    equips_mult = 1
    equips.each do |equip|
      next if !equip
      equips_mult = equips_mult * equip.main_exp_mult * 0.01 if equip.main_exp_mult
    end   
    states_mult = 1
    states.each do |state|
      states_mult = states_mult * state.main_exp_mult * 0.01 if state.main_exp_mult
    end
    return main_exp_mult = actor_mult * class_mult * subclass_mult * equips_mult * states_mult
  end
  
  def sub_exp_rate(class_id)
    exprate = $data_classes[class_id].sub_exp_rate ? $data_classes[class_id].sub_exp_rate * 0.01 : ESTRIOLE::SUB_EXP_RATE  * 0.01
    exprate = (exprate + sub_exp_mod) * sub_exp_mult
    exprate = [exprate,0].max #disallow negative exp rate
  end
  def sub_exp_mod
    actormod = (self.actor.sub_exp_mod ? self.actor.sub_exp_mod : 0) rescue 0
    classmod = (self.class.sub_exp_mod ? self.class.sub_exp_mod : 0) rescue 0
    subclassmod = (self.subclass.sub_exp_mod ? self.subclass.sub_exp_mod : 0) rescue 0
    equipsmod = 0
    equips.each do |equip|
      next if !equip
      equipsmod += equip.sub_exp_mod if equip.sub_exp_mod
    end   
    statesmod = 0
    states.each do |state|
      statesmod += state.sub_exp_mod if state.sub_exp_mod
    end
    return sub_exp_mod = (actormod + classmod + subclassmod + equipsmod + statesmod) * 0.01
  end
  def sub_exp_mult
    actor_mult = (self.actor.sub_exp_mult ? self.sub_exp_mult * 0.01 : 1) rescue 1
    class_mult = (self.class.sub_exp_mult ? self.class.sub_exp_mult * 0.01 : 1) rescue 1
    subclass_mult = (self.subclass.sub_exp_mult ? self.subclass.sub_exp_mult * 0.01 : 1) rescue 1
    equips_mult = 1
    equips.each do |equip|
      next if !equip
      equips_mult = equips_mult * equip.sub_exp_mult * 0.01 if equip.sub_exp_mult
    end   
    states_mult = 1
    states.each do |state|
      states_mult = states_mult * state.sub_exp_mult * 0.01 if state.sub_exp_mult
    end
    return sub_exp_mult = actor_mult * class_mult * subclass_mult * equips_mult * states_mult
  end
  
# buxfix for yanfly class level method. i make it read the 'max level' from database
  def class_level(class_id)
  return @level if YEA::CLASS_SYSTEM::MAINTAIN_LEVELS
  temp_class = $data_classes[class_id]
  @exp[class_id] = 0 if @exp[class_id].nil?
  max_lv = temp_class.max_level == nil ? actor.max_level : temp_class.max_level
  maxlv_exp = temp_class.exp_for_level(max_lv)
  #below part is taken from bugfix by disturbed inside
    n = 1
    loop do
    break if temp_class.exp_for_level(n+1) > @exp[class_id]
    n += 1
    #add a restriction to “kick out” of loop if exp exceeds max level exp
    break if temp_class.exp_for_level(n+1) > maxlv_exp
    end
  return n
  #end bugfix by disturbed inside here
  end  
  
# patch for max level using class max level instead of using actor (if notetags exist)
  alias est_yan_game_actor_max_level max_level
  def max_level
    return $data_classes[@class_id].max_level if $data_classes[@class_id].max_level != nil
    return est_yan_game_actor_max_level
  end
  def subclass_max_level
    return 0 if @subclass_id == 0
    return $data_classes[@subclass_id].max_level if $data_classes[@subclass_id].max_level != nil
    return actor.max_level
  end
  
# to prevent initial level more than initial class max level
  alias est_yan_game_actor_setup setup
  def setup(actor_id)
    est_yan_game_actor_setup(actor_id)
    if $data_classes[@class_id].max_level
    @level = [actor.initial_level,$data_classes[@class_id].max_level].min
    init_exp
    init_skills
    clear_param_plus
    recover_all
    end
  end
  
# new method to add exp to subclass  
  def subclass_add_exp(class_id,value)
    return if !@subclass_id
    return if @subclass_id == 0
    return if YEA::CLASS_SYSTEM::MAINTAIN_LEVELS
    last_level = class_level(class_id).to_i
    last_skills = skills
    exprate = sub_exp_rate(class_id)
    expvalue = (value * exprate).to_i
    expvalue = [expvalue,1].max if ESTRIOLE::SUBCLASS_MIN_1_EXP && value != 0
    @exp[class_id] = @exp[class_id] + expvalue
    @exp[class_id] = [@exp[class_id],subclass.exp_for_level(subclass_max_level)].min
      #learn skill if sub level can learn it
      self.subclass.learnings.each do |learning|
        learn_skill(learning.skill_id) if learning.level <= class_level(class_id).to_i
           # formar extra traits lv up patch
           if @extra_features && class_level(class_id).to_i > last_level && learning.note =~ /<extratrait (.*)>/i
            @extra_features.features += $data_weapons[$1.to_i].features if EXTRA_FEATURES_SOURCE == 0
            @extra_features.features += $data_armors[$1.to_i].features if EXTRA_FEATURES_SOURCE == 1
            @extra_features.features += $data_states[$1.to_i].features if EXTRA_FEATURES_SOURCE == 2
           end
           #end formar extra traits lv up patch
        end
    # display subclass level up msg
    display_level_up_sub(skills - last_skills) if class_level(class_id).to_i > last_level
  end
  
# new method subclass -> to get data classes of subclass  
  def subclass
    @subclass_id = 0 if @subclass_id.nil?
    $data_classes[@subclass_id]
  end

# to make subclass traits works...
  alias est_yan_subclass_feature_objects feature_objects
  def feature_objects
    return est_yan_subclass_feature_objects + [self.subclass] if @subclass_id && @subclass_id != 0
    return est_yan_subclass_feature_objects
  end

# compatibility patch with tsukihime effect manager. so you can have subclass
# that can give you 'effects'
  if $imported["Effect_Manager"]
    alias est_yan_hime_effect_objects effect_objects
    def effect_objects
      return est_yan_hime_effect_objects + [self.subclass] if @subclass_id && @subclass_id != 0
      return est_yan_hime_effect_objects
    end
  end
  
# new method to display level up when subclass level  
  def display_level_up_sub(new_skills)
    return if !@subclass_id || @subclass_id == 0
    level_sub = class_level(@subclass_id).to_i
    $game_message.new_page
    temp = ESTRIOLE::SUBCLASS_VOCAB
    text = "%s's %s now reached %s %s!"
    text = "%s's %s now reached\n%s %s!" if SceneManager.scene_is?(Scene_Battle)
    $game_message.add(sprintf(text, @name, temp ,Vocab::level ,level_sub))
    new_skills.each do |skill|
      $game_message.add(sprintf(Vocab::ObtainSkill, skill.name))
    end
  end

  #patch compatibility to yanfly adjust limit
  if $imported["YEA-AdjustLimits"] == true
  def param_base(param_id)
    result = game_actor_param_base_cs(param_id)
    unless subclass.nil?
      subclass_rate = YEA::CLASS_SYSTEM::SUBCLASS_STAT_RATE
      slevel = subclass_level
      result += subclass.params[param_id, slevel] * subclass_rate if slevel <= 99
      result += subclass.above_lv99_params(param_id, slevel) * subclass_rate if slevel > 99
    end
    return result.to_i
  end
  end
   
# alias method gain exp to also gain subclass exp.
# before i use change_exp. but then i realize it will break when using change_level method
# so i use gain_exp method instead. but... gain_exp only occur when you get exp
# from enemy/battle. and not working for event command that grant exp. so i also
# alias command_315 to handle that.
# so basically battle use gain_exp method, event use command_315 method.
  alias est_yan_gain_exp gain_exp
  def gain_exp(exp,enabled = false)
    new_exp = (exp * main_exp_rate(@class_id) * final_exp_rate).to_i
    new_exp = [new_exp,1].max if ESTRIOLE::SUBCLASS_MIN_1_EXP && exp != 0
    max_exp = self.class.exp_for_level(max_level) - self.exp
    new_exp = [new_exp,max_exp].min
    est_yan_gain_exp(new_exp)
    subclass_add_exp(@subclass_id,exp) if @subclass_id
  end

end

class Game_Interpreter
  #Overwrite command_315 to make it also gain subclass exp. read gain_exp comment.:D
  #have to overwrite to implement main exp rate which SEPARATED with sub exp rate
  #so increasing main sub exp rate didn't raise sub exp gained.
  def command_315
    value = operate_value(@params[2], @params[3], @params[4])
    iterate_actor_var(@params[0], @params[1]) do |actor|
      new_value = (value * actor.main_exp_rate(actor.class.id) * actor.final_exp_rate).to_i
      new_value = [new_value,1].max if ESTRIOLE::SUBCLASS_MIN_1_EXP && value != 0
      new_value = actor.exp + new_value
      max_exp =  actor.class.exp_for_level(actor.max_level)
      new_value = [new_value,max_exp].min
      actor.change_exp(new_value, @params[5])
    end
    value = operate_value(@params[2], @params[3], @params[4])
    iterate_actor_var(@params[0], @params[1]) do |actor|
      actor.subclass_add_exp(actor.subclass.id, value * actor.final_exp_rate) if actor.subclass
    end
  end
end


#yanfly aftermath exp rate patch
class Window_VictoryEXP_Back < Window_Selectable
  
  #--------------------------------------------------------------------------
  # initialize
  #--------------------------------------------------------------------------
  def initialize
    super(0, fitting_height(1), Graphics.width, window_height)
    self.z = 200
    self.openness = 0
  end
  
  #--------------------------------------------------------------------------
  # window_height
  #--------------------------------------------------------------------------
  def window_height
    return Graphics.height - fitting_height(4) - fitting_height(1)
  end
  
  #--------------------------------------------------------------------------
  # col_max
  #--------------------------------------------------------------------------
  def col_max; return item_max; end
  
  #--------------------------------------------------------------------------
  # spacing
  #--------------------------------------------------------------------------
  def spacing; return 8; end
  
  #--------------------------------------------------------------------------
  # item_max
  #--------------------------------------------------------------------------
  def item_max; return $game_party.battle_members.size; end
  
  #--------------------------------------------------------------------------
  # open
  #--------------------------------------------------------------------------
  def open
    @exp_total = $game_troop.exp_total
    super
  end
  
  #--------------------------------------------------------------------------
  # item_rect
  #--------------------------------------------------------------------------
  def item_rect(index)
    rect = Rect.new
    rect.width = item_width
    rect.height = contents.height
    rect.x = index % col_max * (item_width + spacing)
    rect.y = index / col_max * item_height
    return rect
  end
  
  #--------------------------------------------------------------------------
  # draw_item
  #--------------------------------------------------------------------------
  def draw_item(index)
    actor = $game_party.battle_members[index]
    return if actor.nil?
    rect = item_rect(index)
    reset_font_settings
    draw_actor_name(actor, rect)
    draw_exp_gain(actor, rect)
    draw_sub_exp_gain(actor, rect)
    draw_jp_gain(actor, rect)
    draw_actor_face(actor, rect)
  end
  
  #--------------------------------------------------------------------------
  # draw_actor_name
  #--------------------------------------------------------------------------
  def draw_actor_name(actor, rect)
    name = actor.name
    draw_text(rect.x, rect.y+line_height, rect.width, line_height, name, 1)
  end
  
  #--------------------------------------------------------------------------
  # draw_actor_face
  #--------------------------------------------------------------------------
  def draw_actor_face(actor, rect)
    face_name = actor.face_name
    face_index = actor.face_index
    bitmap = Cache.face(face_name)
    rw = [rect.width, 96].min
    face_rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96, rw, 96)
    rx = (rect.width - rw) / 2 + rect.x
    contents.blt(rx, rect.y + line_height * 2, bitmap, face_rect, 255)
  end
  
  #--------------------------------------------------------------------------
  # draw_exp_gain
  #--------------------------------------------------------------------------
  def draw_exp_gain(actor, rect)
    dw = rect.width - (rect.width - [rect.width, 96].min) / 2
    dy = rect.y + line_height * 2 + 96
    fmt = YEA::VICTORY_AFTERMATH::VICTORY_EXP
    text = sprintf(fmt, actor_exp_gain(actor).group)
    contents.font.size = YEA::VICTORY_AFTERMATH::FONTSIZE_EXP
    change_color(power_up_color)
    draw_text(rect.x, dy, dw, line_height, text, 2)
  end
  
  #--------------------------------------------------------------------------
  # actor_exp_gain
  #--------------------------------------------------------------------------
  def actor_exp_gain(actor)
    n = @exp_total * actor.main_exp_rate(actor.class.id) * actor.final_exp_rate
    return n.to_i
  end
  
  def actor_sub_exp_gain(actor)
    return nil if !actor.subclass
    n = @exp_total * actor.sub_exp_rate(actor.subclass.id) * actor.final_exp_rate
    return n.to_i
  end

  def draw_sub_exp_gain(actor, rect)
    return if !actor_sub_exp_gain(actor)
    return if YEA::CLASS_SYSTEM::MAINTAIN_LEVELS
    dw = rect.width - (rect.width - [rect.width, 96].min) / 2
    dy = rect.y + line_height * 4 + 96
    fmt = ESTRIOLE::VICTORY_AFTERMATH::VICTORY_SUB_EXP
    text = sprintf(fmt, actor_sub_exp_gain(actor).group)
    contents.font.size = YEA::VICTORY_AFTERMATH::FONTSIZE_EXP
    change_color(power_up_color)
    draw_text(rect.x, dy, dw, line_height, text, 2)
  end
  
  
  #--------------------------------------------------------------------------
  # draw_jp_gain
  #--------------------------------------------------------------------------
  def draw_jp_gain(actor, rect)
    return unless $imported["YEA-JPManager"]
    dw = rect.width - (rect.width - [rect.width, 96].min) / 2
    dy = rect.y + line_height * 0
    fmt = YEA::JP::VICTORY_AFTERMATH
    text = sprintf(fmt, actor_jp_gain(actor).group, Vocab::jp)
    contents.font.size = YEA::VICTORY_AFTERMATH::FONTSIZE_EXP
    change_color(power_up_color)
    draw_text(rect.x, dy, dw, line_height, text, 2)
  end
  
  #--------------------------------------------------------------------------
  # actor_jp_gain
  #--------------------------------------------------------------------------
  def actor_jp_gain(actor)
    n = actor.battle_jp_earned
    if actor.exp + actor_exp_gain(actor) > actor.exp_for_level(actor.level + 1)
      n += YEA::JP::LEVEL_UP unless actor.max_level?
    end
    return n
  end
  
end # Window_VictoryEXP_Back

class Window_VictoryEXP_Front < Window_VictoryEXP_Back  
  def draw_item(index)
    actor = $game_party.battle_members[index]
    return if actor.nil?
    rect = item_rect(index)
    draw_actor_exp(actor, rect)
    draw_actor_sub_exp(actor, rect)
  end
  def draw_actor_exp(actor, rect)
    if actor.max_level?
      draw_exp_gauge(actor, rect, 1.0)
      return
    end
    total_ticks = YEA::VICTORY_AFTERMATH::EXP_TICKS
    bonus_exp = actor_exp_gain(actor) * @ticks / total_ticks
    now_exp = actor.exp - actor.current_level_exp + bonus_exp
    next_exp = actor.next_level_exp - actor.current_level_exp
    rate = now_exp * 1.0 / next_exp
    draw_exp_gauge(actor, rect, rate)
  end
  
  def draw_actor_sub_exp(actor, rect)
    return if !actor.subclass
    return if YEA::CLASS_SYSTEM::MAINTAIN_LEVELS
    rect.y += line_height * 2
    if actor.subclass_level == actor.subclass_max_level
      draw_sub_exp_gauge(actor, rect, 1.0)
      return
    end
    total_ticks = YEA::VICTORY_AFTERMATH::EXP_TICKS
    bonus_exp = actor_sub_exp_gain(actor) * @ticks / total_ticks
    now_exp = actor.exp[actor.subclass.id] - actor.subclass.exp_for_level(actor.subclass_level) + bonus_exp
    next_exp = actor.subclass.exp_for_level(actor.subclass_level+1) - actor.subclass.exp_for_level(actor.subclass_level)
    rate = now_exp * 1.0 / next_exp
    draw_sub_exp_gauge(actor, rect, rate)
  end
  def draw_exp_gauge(actor, rect, rate)
    rate = [[rate, 1.0].min, 0.0].max
    dx = (rect.width - [rect.width, 96].min) / 2 + rect.x
    dy = rect.y + line_height * 1 + 96
    dw = [rect.width, 96].min
    colour1 = rate >= 1.0 ? lvl_gauge1 : exp_gauge1
    colour2 = rate >= 1.0 ? lvl_gauge2 : exp_gauge2
    draw_gauge(dx, dy, dw, rate, colour1, colour2)
    fmt = YEA::VICTORY_AFTERMATH::EXP_PERCENT
    text = sprintf(fmt, [rate * 100, 100.00].min)
    if [rate * 100, 100.00].min == 100.00
      text = YEA::VICTORY_AFTERMATH::LEVELUP_TEXT
      text = YEA::VICTORY_AFTERMATH::MAX_LVL_TEXT if actor.max_level?
    end
    draw_text(dx, dy, dw, line_height, text, 1)
  end
  def draw_sub_exp_gauge(actor, rect, rate)
    rate = [[rate, 1.0].min, 0.0].max
    dx = (rect.width - [rect.width, 96].min) / 2 + rect.x
    dy = rect.y + line_height * 1 + 96
    dw = [rect.width, 96].min
    colour1 = rate >= 1.0 ? lvl_gauge1 : exp_gauge1
    colour2 = rate >= 1.0 ? lvl_gauge2 : exp_gauge2
    draw_gauge(dx, dy, dw, rate, colour1, colour2)
    fmt = YEA::VICTORY_AFTERMATH::EXP_PERCENT
    text = sprintf(fmt, [rate * 100, 100.00].min)
    if [rate * 100, 100.00].min == 100.00
      text = YEA::VICTORY_AFTERMATH::LEVELUP_TEXT
      text = YEA::VICTORY_AFTERMATH::MAX_LVL_TEXT if actor.subclass_level == actor.subclass_max_level
    end
    draw_text(dx, dy, dw, line_height, text, 1)
  end
end # Window_VictoryEXP_Front[/pre]
回复 1 0

使用道具 举报

梦石
0
星屑
319
在线时间
27 小时
注册时间
2021-8-13
回帖
2
 楼主| 发表于 2021-8-25 08:39:17 | 显示全部楼层
alexncf125 发表于 2021-8-24 11:02
=begin
#==============================================================================
** EST - YEA ...

万分感谢
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部