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

Project1

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

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

[复制链接]

Lv2.观梦者

梦石
0
星屑
309
在线时间
27 小时
注册时间
2021-8-13
帖子
9
跳转到指定楼层
1
发表于 2021-8-24 08:46:56 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
    YEA - 特定职业
在下脚本小白,想请问一下关于Yanfly老师的Yanfly Engine Ace - 职业系统 v1.10怎么让副职业也获得经验或者按主职业获得的经验的一定比例获得经验
下面是脚本
YEA - 职业系统
===============================================================
#
# ▼ 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]

Lv5.捕梦者

梦石
0
星屑
26183
在线时间
5282 小时
注册时间
2016-3-8
帖子
1656
2
发表于 2021-8-24 11:02:09 | 只看该作者
RUBY 代码复制
  1. =begin
  2. #==============================================================================
  3.  ** EST - YEA - SUBCLASS ADD ON : GAIN EXP , LEARN SKILL, WORKING TRAIT, ETC
  4.  REWRITTEN !!!
  5.  v 3.07
  6. #------------------------------------------------------------------------------
  7.  Author : ESTRIOLE
  8.  also credits: Disturbed Inside for class level bugfix which i modified more
  9.  
  10.  Version History:
  11.   v 1.00 - 2012.06.21 > First relase
  12.   v 2.00 - final - 2012.06.25 > updated skill and trait from subclass works
  13.   v 3.00 - 2013.03.24 > - rewritten the script. to make it lots more
  14.                         compatible with another script.
  15.                         - add ability to set class max level by notetags:
  16.                         <class_max_lv: 20>
  17.                         to set the class max lv to 20.
  18.                         - add ability to set subclass exp rate for each class.
  19.                         so when that class is equipped as subclass. how many
  20.                         percent exp it will gained.
  21.                         <sub_exp_rate: 50>
  22.                         to set the class sub exp rate to 50 percent
  23.   v 3.01 - 2013.03.29 > - add configuration to set when exp divided by sub exp
  24.                         rate below 1. it could set exp gain to 1 instead of 0.
  25.                         example1: slimex2 give 8 exp * subrate 10% = 0,8 -> 1 exp
  26.                         example2: slimex2 give 0 exp * subrate 10% = 0 -> 0 exp.
  27.   v 3.02 - 2013.05.26 > - add support for float percentage sub exp rate. ex:
  28.                         <sub_exp_rate: 1.5> means 1.5% rate.
  29.                         even i doubt people will use it... but the function is available in case
  30.                         someone crazy enough to use it :D.
  31.                         - add ability to boost/reduce sub exp rate
  32.                         give notetags to actor/class/weapon/armor/state
  33.                         <sub_exp_mod: 30> means +30%
  34.                         it's direct addition to current rate so if the rate 50% it will become 80%
  35.                         <sub_exp_mod: -30> means -30%
  36.                         it's direct substraction to current rate so if the rate 50% it will become 20%
  37.                         all actor/class/subclass/weapon/armor/state mod stacks
  38.                         usefull to make accessory that make your subclass gain (+30% battle exp)
  39.                         - add ability to grant multiplier to sub_exp_rate. ex:
  40.                         <sub_exp_mult: 150> will multiply current rate to 150%
  41.                         multiplier STACKS
  42.   v 3.03 - 2013.05.28 > - add MAIN EXP RATE function. this function is SEPARATE
  43.                         with SUB EXP RATE. means increasing MAIN EXP RATE didn't
  44.                         raise sub exp gained. ONLY raised exp gained by main class.
  45.                         notetags the class with:
  46.                         <main_exp_rate: 75> -> to set main class exp rate to 75 percent
  47.                         - add ability to boost/reduce main exp rate
  48.                         give notetags to actor/class/weapon/armor/state
  49.                         <main_exp_mod: 30> means +30%
  50.                         it's direct addition to current rate so if the rate 50% it will become 80%
  51.                         <main_exp_mod: -30> means -30%
  52.                         it's direct substraction to current rate so if the rate 50% it will become 20%
  53.                         all actor/class/subclass/weapon/armor/state mod stacks
  54.                         usefull to make accessory that make your mainclass gain (+30% battle exp)
  55.                         - add ability to grant multiplier to main_exp_rate. ex:
  56.                         <main_exp_mult: 150> will multiply current rate to 150%
  57.                         multiplier STACKS
  58.   v 3.04 - 2013.10.22 > - add compatibility patch to yanfly adjust limit script                        
  59.   v 3.05 - 2014.01.09 > - stop exp gain when max level reached. (both subclass and main class works now)
  60.                         in case the exp gained will make the actor exceed max level... it will add to maximum exp
  61.                         you can get to reach next level and ignore the rest.  
  62.   v 3.06 - 2014.01.16 > - compatibility patch with yanfly victory aftermath. to recognize exp rate.
  63.   v 3.07 - 2014.07.16 > - fix the script. IF maintain level set to true. stop the sub exp gain.
  64.                         since the level should be the same with main class.
  65.                         
  66. #------------------------------------------------------------------------------
  67.   This script is addon to YEA class system. Subclass equipped will gain
  68.   full or some exp. gain skill as the subclass level up. actor will have
  69.   all the subclass trait. also if using Tsukihime Effect Manager. subclass
  70.   can be given 'effect' too like normal class.
  71. #------------------------------------------------------------------------------
  72.  Compatibility
  73.    1) REQUIRES the script YEA - Class System. put this script below yanfly class script
  74.  
  75.    -> built in compatibility with Tsukihime Effect Manager script
  76.    -> built in compatibility with Formar extra trait lv up script
  77.    -> built in compatibility with yanfly adjust limit
  78.  
  79.    2) put this script BELOW yanfly victory aftermath
  80.    
  81.  HOW TO USE:
  82.  1) by plugging this script automatically...
  83.     - subclass gain exp (default sub_exp_rate is using what you defined in config)
  84.     - subclass's skill and trait gained by actor
  85.     - subclass's effect is executed (if using tsukihime effect manager)
  86.     
  87.  2) you can set a class max level by notetagging the class with:
  88.  
  89.     <class_max_lv: 20>
  90.     to set the class max lv to 20. change the number as you want.
  91.  
  92.  3) to customize each class to have different sub exp rate. give the class
  93.  
  94.     <sub_exp_rate: 50>
  95.     to set the class sub exp rate to 50%.  change the number as you want.
  96.     
  97.     support float percentage. ex:
  98.     
  99.     <sub_exp_rate: 2.5>
  100.     to set the class sub exp rate to 2.5%   
  101.  
  102.  4) you can give sub_exp_rate modifier by notetagging:
  103.     actor / class / subclass / weapon / armor / state
  104.     
  105.     <sub_exp_mod: 30> means +30% increase to sub exp rate
  106.  
  107.     it's direct addition so if current sub_exp_rate is 50% it will become 80%
  108.     support negative value too
  109.     
  110.     <sub_exp_mod: -30> means -30% decrease to sub exp rate
  111.     
  112.     it's direct substraction so if current sub_exp_rate is 50% it will become 20%
  113.     ALL sub exp rate modifier STACKS
  114.     so example current sub exp rate 50%
  115.     actor +10%, class -5%, subclass -5%, weapon +100%, armor1 -10%, armor2 -5%, state1 10%, state2 - 10%
  116.     final rate = (50%) +10% -5% -5% +100% -10% -5% +10% + 10%
  117.     count it yourself :D.
  118.  
  119.  5) you can give sub_exp_rate multiplier by notetagging:
  120.     actor / class / subclass / weapon / armor / state
  121.     
  122.     <sub_exp_mult: 150> means sub exp rate multiplied by 150%
  123.  
  124.     it's multiplication so if current sub_exp_rate is 50% it will become 75%
  125.     current sub_exp rate is sub exp rate after adding sub_exp_mod
  126.     ALL sub exp rate multiplier STACKS
  127.     so example current sub exp rate 50% (after adding exp_mod)
  128.     actor *150%, class *50%, subclass *500%, weapon *125%, armor1 *250%, armor2 *105%, state1 *410%, state2 *310%
  129.     final rate = (50%) * 150% * 500% * 125% * 250% * 105% * 410% * 310%
  130.     count it yourself :D.
  131.  
  132.  6) to customize each class to have different main exp rate. give the class
  133.  
  134.     <main_exp_rate: 50>
  135.     to set the class main exp rate to 50%.  change the number as you want.
  136.     
  137.     support float percentage. ex:
  138.     
  139.     <main_exp_rate: 2.5>
  140.     to set the class main exp rate to 2.5%   
  141.  
  142.  7) you can give main_exp_rate modifier by notetagging:
  143.     actor / class / subclass / weapon / armor / state
  144.     
  145.     <main_exp_mod: 30> means +30% increase to main exp rate
  146.  
  147.     it's direct addition so if current main_exp_rate is 50% it will become 80%
  148.     support negative value too
  149.     
  150.     <main_exp_mod: -30> means -30% decrease to main exp rate
  151.     
  152.     it's direct substraction so if current main_exp_rate is 50% it will become 20%
  153.     ALL main exp rate modifier STACKS
  154.     so example current main exp rate 50%
  155.     actor +10%, class -5%, subclass -5%, weapon +100%, armor1 -10%, armor2 -5%, state1 10%, state2 - 10%
  156.     final rate = (50%) +10% -5% -5% +100% -10% -5% +10% + 10%
  157.     count it yourself :D.
  158.  
  159.  8) you can give main_exp_rate multiplier by notetagging:
  160.     actor / class / subclass / weapon / armor / state
  161.     
  162.     <main_exp_mult: 150> means main exp rate multiplied by 150%
  163.  
  164.     it's multiplication so if current main_exp_rate is 50% it will become 75%
  165.     current main_exp rate is main exp rate after adding main_exp_mod
  166.     ALL main exp rate multiplier STACKS
  167.     so example current main exp rate 50% (after adding exp_mod)
  168.     actor *150%, class *50%, subclass *500%, weapon *125%, armor1 *250%, armor2 *105%, state1 *410%, state2 *310%
  169.     final rate = (50%) * 150% * 500% * 125% * 250% * 105% * 410% * 310%
  170.     count it yourself :D.
  171.     
  172. interesting play with subexpmod and subexpmult...
  173. create a subclass only which have no growth in subclass. but after equipping
  174. some accessory that increase subexpmod. it will have some growth and raised lv.
  175. could create a weapon/armor which is strong but subexpmult = 0%. so no growth.   
  176.  
  177. #------------------------------------------------------------------------------
  178. =end
  179.  
  180. module ESTRIOLE
  181.   SUB_EXP_RATE = 50   #default sub exp rate (in percentage so 50 means 50% exp,
  182.                       #200 means 200% exp. etc). when no notetags set for that class
  183.   MAIN_EXP_RATE = 100 #default MAIN exp rate (in percentage so 50 means 50% exp,
  184.                       #200 means 200% exp. etc). when no notetags set for that class
  185.                       #better to leave it at 100%
  186.   SUBCLASS_VOCAB = "Subclass"
  187.   SUBCLASS_MIN_1_EXP = true #if true minimum 1 exp gained when the result exp x sub exp rate is between 0 - 1
  188.  
  189.   module VICTORY_AFTERMATH
  190.   VICTORY_SUB_EXP  = "+%sSUBEXP"      # Text used to display SUB EXP. IF USING YANFLY VICTORY AFTERMATH SCRIPT
  191.   end
  192.  
  193. end
  194.  
  195. class RPG::BaseItem
  196.   def sub_exp_mod
  197.     return nil if !@note[/<sub_exp_mod:(.*)>/i]
  198.     a = @note[/<sub_exp_mod:(.*)>/i].scan(/:(.*)/).flatten[0].scan(/(?:"(.*?)"| ([-\w.\w]+)|([-\w.\w]+),|,([-\w.\w]+))/).flatten.compact
  199.     return noteargs = a[0].to_f
  200.   end   
  201.   def sub_exp_mult
  202.     return nil if !@note[/<sub_exp_mult:(.*)>/i]
  203.     a = @note[/<sub_exp_mult:(.*)>/i].scan(/:(.*)/).flatten[0].scan(/(?:"(.*?)"| ([-\w.\w]+)|([-\w.\w]+),|,([-\w.\w]+))/).flatten.compact
  204.     return noteargs = a[0].to_f
  205.   end   
  206.   def main_exp_mod
  207.     return nil if !@note[/<main_exp_mod:(.*)>/i]
  208.     a = @note[/<main_exp_mod:(.*)>/i].scan(/:(.*)/).flatten[0].scan(/(?:"(.*?)"| ([-\w.\w]+)|([-\w.\w]+),|,([-\w.\w]+))/).flatten.compact
  209.     return noteargs = a[0].to_f
  210.   end   
  211.   def main_exp_mult
  212.     return nil if !@note[/<main_exp_mult:(.*)>/i]
  213.     a = @note[/<main_exp_mult:(.*)>/i].scan(/:(.*)/).flatten[0].scan(/(?:"(.*?)"| ([-\w.\w]+)|([-\w.\w]+),|,([-\w.\w]+))/).flatten.compact
  214.     return noteargs = a[0].to_f
  215.   end   
  216. end
  217. #Notetags ability to set max level for each class instead of using actor max_lv
  218. class RPG::Class < RPG::BaseItem
  219.   def max_level
  220.     return nil if !@note[/<class_max_lv:(.*)>/i]
  221.     a = @note[/<class_max_lv:(.*)>/i].scan(/:(.*)/).flatten[0].scan(/(?:"(.*?)"| ([-\w.\w]+)|([-\w.\w]+),|,([-\w.\w]+))/).flatten.compact
  222.     return noteargs = a[0].to_i
  223.   end
  224.   def sub_exp_rate
  225.     return nil if !@note[/<sub_exp_rate:(.*)>/i]
  226.     a = @note[/<sub_exp_rate:(.*)>/i].scan(/:(.*)/).flatten[0].scan(/(?:"(.*?)"| ([-\w.\w]+)|([-\w.\w]+),|,([-\w.\w]+))/).flatten.compact
  227.     return noteargs = a[0].to_f
  228.   end  
  229.   def main_exp_rate
  230.     return nil if !@note[/<main_exp_rate:(.*)>/i]
  231.     a = @note[/<main_exp_rate:(.*)>/i].scan(/:(.*)/).flatten[0].scan(/(?:"(.*?)"| ([-\w.\w]+)|([-\w.\w]+),|,([-\w.\w]+))/).flatten.compact
  232.     return noteargs = a[0].to_f
  233.   end  
  234. end
  235.  
  236. class Game_Actor < Game_Battler
  237.   def main_exp_rate(class_id)
  238.     exprate = $data_classes[class_id].main_exp_rate ? $data_classes[class_id].main_exp_rate * 0.01 : ESTRIOLE::MAIN_EXP_RATE  * 0.01
  239.     exprate = (exprate + main_exp_mod) * main_exp_mult
  240.     exprate = [exprate,0].max #disallow negative exp rate
  241.   end
  242.   def main_exp_mod
  243.     actormod = (self.actor.main_exp_mod ? self.actor.main_exp_mod : 0) rescue 0
  244.     classmod = (self.class.main_exp_mod ? self.class.main_exp_mod : 0) rescue 0
  245.     subclassmod = (self.subclass.main_exp_mod ? self.subclass.main_exp_mod : 0) rescue 0
  246.     equipsmod = 0
  247.     equips.each do |equip|
  248.       next if !equip
  249.       equipsmod += equip.main_exp_mod if equip.main_exp_mod
  250.     end   
  251.     statesmod = 0
  252.     states.each do |state|
  253.       statesmod += state.main_exp_mod if state.main_exp_mod
  254.     end
  255.     return main_exp_mod = (actormod + classmod + subclassmod + equipsmod + statesmod) * 0.01
  256.   end
  257.   def main_exp_mult
  258.     actor_mult = (self.actor.main_exp_mult ? self.main_exp_mult * 0.01 : 1) rescue 1
  259.     class_mult = (self.class.main_exp_mult ? self.class.main_exp_mult * 0.01 : 1) rescue 1
  260.     subclass_mult = (self.subclass.main_exp_mult ? self.subclass.main_exp_mult * 0.01 : 1) rescue 1
  261.     equips_mult = 1
  262.     equips.each do |equip|
  263.       next if !equip
  264.       equips_mult = equips_mult * equip.main_exp_mult * 0.01 if equip.main_exp_mult
  265.     end   
  266.     states_mult = 1
  267.     states.each do |state|
  268.       states_mult = states_mult * state.main_exp_mult * 0.01 if state.main_exp_mult
  269.     end
  270.     return main_exp_mult = actor_mult * class_mult * subclass_mult * equips_mult * states_mult
  271.   end
  272.  
  273.   def sub_exp_rate(class_id)
  274.     exprate = $data_classes[class_id].sub_exp_rate ? $data_classes[class_id].sub_exp_rate * 0.01 : ESTRIOLE::SUB_EXP_RATE  * 0.01
  275.     exprate = (exprate + sub_exp_mod) * sub_exp_mult
  276.     exprate = [exprate,0].max #disallow negative exp rate
  277.   end
  278.   def sub_exp_mod
  279.     actormod = (self.actor.sub_exp_mod ? self.actor.sub_exp_mod : 0) rescue 0
  280.     classmod = (self.class.sub_exp_mod ? self.class.sub_exp_mod : 0) rescue 0
  281.     subclassmod = (self.subclass.sub_exp_mod ? self.subclass.sub_exp_mod : 0) rescue 0
  282.     equipsmod = 0
  283.     equips.each do |equip|
  284.       next if !equip
  285.       equipsmod += equip.sub_exp_mod if equip.sub_exp_mod
  286.     end   
  287.     statesmod = 0
  288.     states.each do |state|
  289.       statesmod += state.sub_exp_mod if state.sub_exp_mod
  290.     end
  291.     return sub_exp_mod = (actormod + classmod + subclassmod + equipsmod + statesmod) * 0.01
  292.   end
  293.   def sub_exp_mult
  294.     actor_mult = (self.actor.sub_exp_mult ? self.sub_exp_mult * 0.01 : 1) rescue 1
  295.     class_mult = (self.class.sub_exp_mult ? self.class.sub_exp_mult * 0.01 : 1) rescue 1
  296.     subclass_mult = (self.subclass.sub_exp_mult ? self.subclass.sub_exp_mult * 0.01 : 1) rescue 1
  297.     equips_mult = 1
  298.     equips.each do |equip|
  299.       next if !equip
  300.       equips_mult = equips_mult * equip.sub_exp_mult * 0.01 if equip.sub_exp_mult
  301.     end   
  302.     states_mult = 1
  303.     states.each do |state|
  304.       states_mult = states_mult * state.sub_exp_mult * 0.01 if state.sub_exp_mult
  305.     end
  306.     return sub_exp_mult = actor_mult * class_mult * subclass_mult * equips_mult * states_mult
  307.   end
  308.  
  309. # buxfix for yanfly class level method. i make it read the 'max level' from database
  310.   def class_level(class_id)
  311.   return @level if YEA::CLASS_SYSTEM::MAINTAIN_LEVELS
  312.   temp_class = $data_classes[class_id]
  313.   @exp[class_id] = 0 if @exp[class_id].nil?
  314.   max_lv = temp_class.max_level == nil ? actor.max_level : temp_class.max_level
  315.   maxlv_exp = temp_class.exp_for_level(max_lv)
  316.   #below part is taken from bugfix by disturbed inside
  317.     n = 1
  318.     loop do
  319.     break if temp_class.exp_for_level(n+1) > @exp[class_id]
  320.     n += 1
  321.     #add a restriction to “kick out” of loop if exp exceeds max level exp
  322.     break if temp_class.exp_for_level(n+1) > maxlv_exp
  323.     end
  324.   return n
  325.   #end bugfix by disturbed inside here
  326.   end  
  327.  
  328. # patch for max level using class max level instead of using actor (if notetags exist)
  329.   alias est_yan_game_actor_max_level max_level
  330.   def max_level
  331.     return $data_classes[@class_id].max_level if $data_classes[@class_id].max_level != nil
  332.     return est_yan_game_actor_max_level
  333.   end
  334.   def subclass_max_level
  335.     return 0 if @subclass_id == 0
  336.     return $data_classes[@subclass_id].max_level if $data_classes[@subclass_id].max_level != nil
  337.     return actor.max_level
  338.   end
  339.  
  340. # to prevent initial level more than initial class max level
  341.   alias est_yan_game_actor_setup setup
  342.   def setup(actor_id)
  343.     est_yan_game_actor_setup(actor_id)
  344.     if $data_classes[@class_id].max_level
  345.     @level = [actor.initial_level,$data_classes[@class_id].max_level].min
  346.     init_exp
  347.     init_skills
  348.     clear_param_plus
  349.     recover_all
  350.     end
  351.   end
  352.  
  353. # new method to add exp to subclass  
  354.   def subclass_add_exp(class_id,value)
  355.     return if !@subclass_id
  356.     return if @subclass_id == 0
  357.     return if YEA::CLASS_SYSTEM::MAINTAIN_LEVELS
  358.     last_level = class_level(class_id).to_i
  359.     last_skills = skills
  360.     exprate = sub_exp_rate(class_id)
  361.     expvalue = (value * exprate).to_i
  362.     expvalue = [expvalue,1].max if ESTRIOLE::SUBCLASS_MIN_1_EXP && value != 0
  363.     @exp[class_id] = @exp[class_id] + expvalue
  364.     @exp[class_id] = [@exp[class_id],subclass.exp_for_level(subclass_max_level)].min
  365.       #learn skill if sub level can learn it
  366.       self.subclass.learnings.each do |learning|
  367.         learn_skill(learning.skill_id) if learning.level <= class_level(class_id).to_i
  368.            # formar extra traits lv up patch
  369.            if @extra_features && class_level(class_id).to_i > last_level && learning.note =~ /<extratrait (.*)>/i
  370.             @extra_features.features += $data_weapons[$1.to_i].features if EXTRA_FEATURES_SOURCE == 0
  371.             @extra_features.features += $data_armors[$1.to_i].features if EXTRA_FEATURES_SOURCE == 1
  372.             @extra_features.features += $data_states[$1.to_i].features if EXTRA_FEATURES_SOURCE == 2
  373.            end
  374.            #end formar extra traits lv up patch
  375.         end
  376.     # display subclass level up msg
  377.     display_level_up_sub(skills - last_skills) if class_level(class_id).to_i > last_level
  378.   end
  379.  
  380. # new method subclass -> to get data classes of subclass  
  381.   def subclass
  382.     @subclass_id = 0 if @subclass_id.nil?
  383.     $data_classes[@subclass_id]
  384.   end
  385.  
  386. # to make subclass traits works...
  387.   alias est_yan_subclass_feature_objects feature_objects
  388.   def feature_objects
  389.     return est_yan_subclass_feature_objects + [self.subclass] if @subclass_id && @subclass_id != 0
  390.     return est_yan_subclass_feature_objects
  391.   end
  392.  
  393. # compatibility patch with tsukihime effect manager. so you can have subclass
  394. # that can give you 'effects'
  395.   if $imported["Effect_Manager"]
  396.     alias est_yan_hime_effect_objects effect_objects
  397.     def effect_objects
  398.       return est_yan_hime_effect_objects + [self.subclass] if @subclass_id && @subclass_id != 0
  399.       return est_yan_hime_effect_objects
  400.     end
  401.   end
  402.  
  403. # new method to display level up when subclass level  
  404.   def display_level_up_sub(new_skills)
  405.     return if !@subclass_id || @subclass_id == 0
  406.     level_sub = class_level(@subclass_id).to_i
  407.     $game_message.new_page
  408.     temp = ESTRIOLE::SUBCLASS_VOCAB
  409.     text = "%s's %s now reached %s %s!"
  410.     text = "%s's %s now reached\n%s %s!" if SceneManager.scene_is?(Scene_Battle)
  411.     $game_message.add(sprintf(text, @name, temp ,Vocab::level ,level_sub))
  412.     new_skills.each do |skill|
  413.       $game_message.add(sprintf(Vocab::ObtainSkill, skill.name))
  414.     end
  415.   end
  416.  
  417.   #patch compatibility to yanfly adjust limit
  418.   if $imported["YEA-AdjustLimits"] == true
  419.   def param_base(param_id)
  420.     result = game_actor_param_base_cs(param_id)
  421.     unless subclass.nil?
  422.       subclass_rate = YEA::CLASS_SYSTEM::SUBCLASS_STAT_RATE
  423.       slevel = subclass_level
  424.       result += subclass.params[param_id, slevel] * subclass_rate if slevel <= 99
  425.       result += subclass.above_lv99_params(param_id, slevel) * subclass_rate if slevel > 99
  426.     end
  427.     return result.to_i
  428.   end
  429.   end
  430.  
  431. # alias method gain exp to also gain subclass exp.
  432. # before i use change_exp. but then i realize it will break when using change_level method
  433. # so i use gain_exp method instead. but... gain_exp only occur when you get exp
  434. # from enemy/battle. and not working for event command that grant exp. so i also
  435. # alias command_315 to handle that.
  436. # so basically battle use gain_exp method, event use command_315 method.
  437.   alias est_yan_gain_exp gain_exp
  438.   def gain_exp(exp,enabled = false)
  439.     new_exp = (exp * main_exp_rate(@class_id) * final_exp_rate).to_i
  440.     new_exp = [new_exp,1].max if ESTRIOLE::SUBCLASS_MIN_1_EXP && exp != 0
  441.     max_exp = self.class.exp_for_level(max_level) - self.exp
  442.     new_exp = [new_exp,max_exp].min
  443.     est_yan_gain_exp(new_exp)
  444.     subclass_add_exp(@subclass_id,exp) if @subclass_id
  445.   end
  446.  
  447. end
  448.  
  449. class Game_Interpreter
  450.   #Overwrite command_315 to make it also gain subclass exp. read gain_exp comment.:D
  451.   #have to overwrite to implement main exp rate which SEPARATED with sub exp rate
  452.   #so increasing main sub exp rate didn't raise sub exp gained.
  453.   def command_315
  454.     value = operate_value(@params[2], @params[3], @params[4])
  455.     iterate_actor_var(@params[0], @params[1]) do |actor|
  456.       new_value = (value * actor.main_exp_rate(actor.class.id) * actor.final_exp_rate).to_i
  457.       new_value = [new_value,1].max if ESTRIOLE::SUBCLASS_MIN_1_EXP && value != 0
  458.       new_value = actor.exp + new_value
  459.       max_exp =  actor.class.exp_for_level(actor.max_level)
  460.       new_value = [new_value,max_exp].min
  461.       actor.change_exp(new_value, @params[5])
  462.     end
  463.     value = operate_value(@params[2], @params[3], @params[4])
  464.     iterate_actor_var(@params[0], @params[1]) do |actor|
  465.       actor.subclass_add_exp(actor.subclass.id, value * actor.final_exp_rate) if actor.subclass
  466.     end
  467.   end
  468. end
  469.  
  470.  
  471. #yanfly aftermath exp rate patch
  472. class Window_VictoryEXP_Back < Window_Selectable
  473.  
  474.   #--------------------------------------------------------------------------
  475.   # initialize
  476.   #--------------------------------------------------------------------------
  477.   def initialize
  478.     super(0, fitting_height(1), Graphics.width, window_height)
  479.     self.z = 200
  480.     self.openness = 0
  481.   end
  482.  
  483.   #--------------------------------------------------------------------------
  484.   # window_height
  485.   #--------------------------------------------------------------------------
  486.   def window_height
  487.     return Graphics.height - fitting_height(4) - fitting_height(1)
  488.   end
  489.  
  490.   #--------------------------------------------------------------------------
  491.   # col_max
  492.   #--------------------------------------------------------------------------
  493.   def col_max; return item_max; end
  494.  
  495.   #--------------------------------------------------------------------------
  496.   # spacing
  497.   #--------------------------------------------------------------------------
  498.   def spacing; return 8; end
  499.  
  500.   #--------------------------------------------------------------------------
  501.   # item_max
  502.   #--------------------------------------------------------------------------
  503.   def item_max; return $game_party.battle_members.size; end
  504.  
  505.   #--------------------------------------------------------------------------
  506.   # open
  507.   #--------------------------------------------------------------------------
  508.   def open
  509.     @exp_total = $game_troop.exp_total
  510.     super
  511.   end
  512.  
  513.   #--------------------------------------------------------------------------
  514.   # item_rect
  515.   #--------------------------------------------------------------------------
  516.   def item_rect(index)
  517.     rect = Rect.new
  518.     rect.width = item_width
  519.     rect.height = contents.height
  520.     rect.x = index % col_max * (item_width + spacing)
  521.     rect.y = index / col_max * item_height
  522.     return rect
  523.   end
  524.  
  525.   #--------------------------------------------------------------------------
  526.   # draw_item
  527.   #--------------------------------------------------------------------------
  528.   def draw_item(index)
  529.     actor = $game_party.battle_members[index]
  530.     return if actor.nil?
  531.     rect = item_rect(index)
  532.     reset_font_settings
  533.     draw_actor_name(actor, rect)
  534.     draw_exp_gain(actor, rect)
  535.     draw_sub_exp_gain(actor, rect)
  536.     draw_jp_gain(actor, rect)
  537.     draw_actor_face(actor, rect)
  538.   end
  539.  
  540.   #--------------------------------------------------------------------------
  541.   # draw_actor_name
  542.   #--------------------------------------------------------------------------
  543.   def draw_actor_name(actor, rect)
  544.     name = actor.name
  545.     draw_text(rect.x, rect.y+line_height, rect.width, line_height, name, 1)
  546.   end
  547.  
  548.   #--------------------------------------------------------------------------
  549.   # draw_actor_face
  550.   #--------------------------------------------------------------------------
  551.   def draw_actor_face(actor, rect)
  552.     face_name = actor.face_name
  553.     face_index = actor.face_index
  554.     bitmap = Cache.face(face_name)
  555.     rw = [rect.width, 96].min
  556.     face_rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96, rw, 96)
  557.     rx = (rect.width - rw) / 2 + rect.x
  558.     contents.blt(rx, rect.y + line_height * 2, bitmap, face_rect, 255)
  559.   end
  560.  
  561.   #--------------------------------------------------------------------------
  562.   # draw_exp_gain
  563.   #--------------------------------------------------------------------------
  564.   def draw_exp_gain(actor, rect)
  565.     dw = rect.width - (rect.width - [rect.width, 96].min) / 2
  566.     dy = rect.y + line_height * 2 + 96
  567.     fmt = YEA::VICTORY_AFTERMATH::VICTORY_EXP
  568.     text = sprintf(fmt, actor_exp_gain(actor).group)
  569.     contents.font.size = YEA::VICTORY_AFTERMATH::FONTSIZE_EXP
  570.     change_color(power_up_color)
  571.     draw_text(rect.x, dy, dw, line_height, text, 2)
  572.   end
  573.  
  574.   #--------------------------------------------------------------------------
  575.   # actor_exp_gain
  576.   #--------------------------------------------------------------------------
  577.   def actor_exp_gain(actor)
  578.     n = @exp_total * actor.main_exp_rate(actor.class.id) * actor.final_exp_rate
  579.     return n.to_i
  580.   end
  581.  
  582.   def actor_sub_exp_gain(actor)
  583.     return nil if !actor.subclass
  584.     n = @exp_total * actor.sub_exp_rate(actor.subclass.id) * actor.final_exp_rate
  585.     return n.to_i
  586.   end
  587.  
  588.   def draw_sub_exp_gain(actor, rect)
  589.     return if !actor_sub_exp_gain(actor)
  590.     return if YEA::CLASS_SYSTEM::MAINTAIN_LEVELS
  591.     dw = rect.width - (rect.width - [rect.width, 96].min) / 2
  592.     dy = rect.y + line_height * 4 + 96
  593.     fmt = ESTRIOLE::VICTORY_AFTERMATH::VICTORY_SUB_EXP
  594.     text = sprintf(fmt, actor_sub_exp_gain(actor).group)
  595.     contents.font.size = YEA::VICTORY_AFTERMATH::FONTSIZE_EXP
  596.     change_color(power_up_color)
  597.     draw_text(rect.x, dy, dw, line_height, text, 2)
  598.   end
  599.  
  600.  
  601.   #--------------------------------------------------------------------------
  602.   # draw_jp_gain
  603.   #--------------------------------------------------------------------------
  604.   def draw_jp_gain(actor, rect)
  605.     return unless $imported["YEA-JPManager"]
  606.     dw = rect.width - (rect.width - [rect.width, 96].min) / 2
  607.     dy = rect.y + line_height * 0
  608.     fmt = YEA::JP::VICTORY_AFTERMATH
  609.     text = sprintf(fmt, actor_jp_gain(actor).group, Vocab::jp)
  610.     contents.font.size = YEA::VICTORY_AFTERMATH::FONTSIZE_EXP
  611.     change_color(power_up_color)
  612.     draw_text(rect.x, dy, dw, line_height, text, 2)
  613.   end
  614.  
  615.   #--------------------------------------------------------------------------
  616.   # actor_jp_gain
  617.   #--------------------------------------------------------------------------
  618.   def actor_jp_gain(actor)
  619.     n = actor.battle_jp_earned
  620.     if actor.exp + actor_exp_gain(actor) > actor.exp_for_level(actor.level + 1)
  621.       n += YEA::JP::LEVEL_UP unless actor.max_level?
  622.     end
  623.     return n
  624.   end
  625.  
  626. end # Window_VictoryEXP_Back
  627.  
  628. class Window_VictoryEXP_Front < Window_VictoryEXP_Back  
  629.   def draw_item(index)
  630.     actor = $game_party.battle_members[index]
  631.     return if actor.nil?
  632.     rect = item_rect(index)
  633.     draw_actor_exp(actor, rect)
  634.     draw_actor_sub_exp(actor, rect)
  635.   end
  636.   def draw_actor_exp(actor, rect)
  637.     if actor.max_level?
  638.       draw_exp_gauge(actor, rect, 1.0)
  639.       return
  640.     end
  641.     total_ticks = YEA::VICTORY_AFTERMATH::EXP_TICKS
  642.     bonus_exp = actor_exp_gain(actor) * @ticks / total_ticks
  643.     now_exp = actor.exp - actor.current_level_exp + bonus_exp
  644.     next_exp = actor.next_level_exp - actor.current_level_exp
  645.     rate = now_exp * 1.0 / next_exp
  646.     draw_exp_gauge(actor, rect, rate)
  647.   end
  648.  
  649.   def draw_actor_sub_exp(actor, rect)
  650.     return if !actor.subclass
  651.     return if YEA::CLASS_SYSTEM::MAINTAIN_LEVELS
  652.     rect.y += line_height * 2
  653.     if actor.subclass_level == actor.subclass_max_level
  654.       draw_sub_exp_gauge(actor, rect, 1.0)
  655.       return
  656.     end
  657.     total_ticks = YEA::VICTORY_AFTERMATH::EXP_TICKS
  658.     bonus_exp = actor_sub_exp_gain(actor) * @ticks / total_ticks
  659.     now_exp = actor.exp[actor.subclass.id] - actor.subclass.exp_for_level(actor.subclass_level) + bonus_exp
  660.     next_exp = actor.subclass.exp_for_level(actor.subclass_level+1) - actor.subclass.exp_for_level(actor.subclass_level)
  661.     rate = now_exp * 1.0 / next_exp
  662.     draw_sub_exp_gauge(actor, rect, rate)
  663.   end
  664.   def draw_exp_gauge(actor, rect, rate)
  665.     rate = [[rate, 1.0].min, 0.0].max
  666.     dx = (rect.width - [rect.width, 96].min) / 2 + rect.x
  667.     dy = rect.y + line_height * 1 + 96
  668.     dw = [rect.width, 96].min
  669.     colour1 = rate >= 1.0 ? lvl_gauge1 : exp_gauge1
  670.     colour2 = rate >= 1.0 ? lvl_gauge2 : exp_gauge2
  671.     draw_gauge(dx, dy, dw, rate, colour1, colour2)
  672.     fmt = YEA::VICTORY_AFTERMATH::EXP_PERCENT
  673.     text = sprintf(fmt, [rate * 100, 100.00].min)
  674.     if [rate * 100, 100.00].min == 100.00
  675.       text = YEA::VICTORY_AFTERMATH::LEVELUP_TEXT
  676.       text = YEA::VICTORY_AFTERMATH::MAX_LVL_TEXT if actor.max_level?
  677.     end
  678.     draw_text(dx, dy, dw, line_height, text, 1)
  679.   end
  680.   def draw_sub_exp_gauge(actor, rect, rate)
  681.     rate = [[rate, 1.0].min, 0.0].max
  682.     dx = (rect.width - [rect.width, 96].min) / 2 + rect.x
  683.     dy = rect.y + line_height * 1 + 96
  684.     dw = [rect.width, 96].min
  685.     colour1 = rate >= 1.0 ? lvl_gauge1 : exp_gauge1
  686.     colour2 = rate >= 1.0 ? lvl_gauge2 : exp_gauge2
  687.     draw_gauge(dx, dy, dw, rate, colour1, colour2)
  688.     fmt = YEA::VICTORY_AFTERMATH::EXP_PERCENT
  689.     text = sprintf(fmt, [rate * 100, 100.00].min)
  690.     if [rate * 100, 100.00].min == 100.00
  691.       text = YEA::VICTORY_AFTERMATH::LEVELUP_TEXT
  692.       text = YEA::VICTORY_AFTERMATH::MAX_LVL_TEXT if actor.subclass_level == actor.subclass_max_level
  693.     end
  694.     draw_text(dx, dy, dw, line_height, text, 1)
  695.   end
  696. end # Window_VictoryEXP_Front
回复 支持 1 反对 0

使用道具 举报

Lv2.观梦者

梦石
0
星屑
309
在线时间
27 小时
注册时间
2021-8-13
帖子
9
3
 楼主| 发表于 2021-8-25 08:39:17 | 只看该作者
alexncf125 发表于 2021-8-24 11:02
=begin
#==============================================================================
** EST - YEA ...

万分感谢
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2025-6-18 00:06

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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