| 
 
| 赞 | 0 |  
| VIP | 0 |  
| 好人卡 | 1 |  
| 积分 | 1 |  
| 经验 | 7377 |  
| 最后登录 | 2018-11-29 |  
| 在线时间 | 210 小时 |  
 Lv1.梦旅人 
	梦石0 星屑110 在线时间210 小时注册时间2012-6-25帖子51 | 
| 
本帖最后由 Ayahiyano 于 2013-6-19 22:37 编辑
x
加入我们,或者,欢迎回来。您需要 登录 才可以下载或查看,没有帐号?注册会员  
 装备随即属性脚本跟性格脚本冲突了,要怎么改?他说这里错了
 #encoding:utf-8#==============================================================================# ■ 装备说明增强#------------------------------------------------------------------------------#  修改了说明窗口,增强了装备的说明 作者:wyongcan  发布于66RPG   转载请注明#==============================================================================module Help  CODE ={    11 => "属性抗性",    12 => "弱化抗性",    13 => "状态抗性",    14 => "状态免疫",    21 => "普通能力",    22 => "添加能力",    23 => "特殊能力",    31 => "攻击附带属性",    32 => "攻击附带状态",    33 => "修正攻击速度",    34 => "添加攻击次数",    41 => "添加技能类型",    42 => "禁用技能类型",    43 => "添加技能",    44 => "禁用技能",    51 => "可装备武器类型",    52 => "可装备护甲类型",    53 => "固定装备",    54 => "禁用装备",    55 => "装备风格",    61 => "添加行动次数",    62 => "特殊标志",    63 => "消失效果",    64 => "队伍能力"}  #特殊标志  FLAG ={                0 => "自动战斗",                1 => "擅长防御",                2 => "保护弱者",                3 => "特技专注"}  #普通能力        PARAM ={                0 => "最大HP",                1 => "最大MP",                2 => "物理攻击",                3 => "物理防御",                4 => "魔法攻击",                5 => "魔法防御",                6 => "敏 捷 值",                7 => "幸 运 值"}  #添加能力        XPARAM ={                0 => "物理命中几率:",                1 => "物理闪避几率:",                2 => "必杀几率:",                3 => "必杀闪避几率:",                4 => "魔法闪避几率:",                5 => "魔法反射几率:",                6 => "物理反击几率:",                7 => "体力值再生速度:",                8 => "魔力值再生速度:",                9 => "特技值再生速度:"}  #特殊能力        SPARAM ={                0 => "受到攻击的几率",                1 => "防御效果比率",                2 => "恢复效果比率",                3 => "药理知识",                4 => "MP消费率",                5 => "TP消耗率",                6 => "物理伤害加成",                7 => "魔法伤害加成",                8 => "地形伤害加成",                9 => "经验获得加成"}#~   #效果范围#~         SCOPE ={#~                 0 => "特殊",#~                 1 => "单个敌人",#~                 2 => "全体敌人" ,#~                 3 => "一个随机敌人",#~                 4 => "两个随机敌人",#~                 5 => "三个随机敌人",#~                 6 => "四个随机敌人",#~                 7 => "单个队友",#~                 8 => "全体队友",#~                 9 => "单个队友(无法战斗)",#~                 10 => "全体队友(无法战斗)",#~                 11 => "使用者"}        @队伍能力 ={                0 => "遇敌几率减半",                1 => "随机遇敌无效",                2 => "敌人偷袭无效",                3 => "先制攻击几率上升",                4 => "获得金钱数量双倍",                5 => "物品掉落几率双倍"}  def self.ready    @状态 = {}    @武器类型 = {}    @防具类型 = {}    @属性 = {}    $data_states.each{|x| @状态[x.id] = x.name if x != nil}    elements = $data_system.elements    weapon_types = $data_system.weapon_types    armor_types = $data_system.armor_types    elements.each_with_index{|x,y| @属性[y] = x if x != ""}    weapon_types.each_with_index{|x,y| @武器类型[y] = x if x != ""}    armor_types.each_with_index{|x,y| @防具类型[y] = x if x != ""}  end  def self.getequiphelp(equip)    help = ""    param = []    equip.params.each_with_index{|x,y| param.push([PARAM[y],x])}    param = param.select{|x| x[1] != 0}    param.each{|x| help += x[0] + ":" + x[1].to_s + "\n"}    features = equip.features    features.select{|x| x.code == 55}.each{|x| help += CODE[x.code] + ":双持武器" + "\n"}#    features.select{|x| x.code == 11}.each{|x| help += CODE[x.code] + ":" + @属性[x.data_id] + "*" + x.value.to_s + "\n"}    features.select{|x| x.code == 12}.each{|x| help += CODE[x.code] + ":" + PARAM[x.data_id] + "*" + x.value.to_s + "\n"}    features.select{|x| x.code == 13}.each{|x| help += CODE[x.code] + ":" + @状态[x.data_id] + "*" + x.value.to_s + "\n"}   # features.select{|x| x.code == 14}.each{|x| help += CODE[x.code] + ":" + @状态[x.data_id] + "\n"}#    features.select{|x| x.code == 31}.each{|x| help += CODE[x.code] + ":" + @属性[x.data_id] + "\n"}#    features.select{|x| x.code == 32}.each{|x| help += CODE[x.code] + ":" + @状态[x.data_id] + "+" + x.value.to_s + "\n"}    features.select{|x| x.code == 33}.each{|x| help += CODE[x.code] + ":" + x.value.to_s + "\n"}    features.select{|x| x.code == 34}.each{|x| help += CODE[x.code] + ":" + x.value.to_s + "\n"}    features.select{|x| x.code == 41}.each{|x| help += CODE[x.code] + ":" + (x.data_id == 1 ? "特技" : "魔法")  + "\n"}    features.select{|x| x.code == 42}.each{|x| help += CODE[x.code] + ":" + (x.data_id == 1 ? "特技" : "魔法")  + "\n"}   features.select{|x| x.code == 43}.each{|x| help += CODE[x.code] + ":" + $data_skills[x.data_id].name  + "\n"}    features.select{|x| x.code == 44}.each{|x| help += CODE[x.code] + ":" + $data_skills[x.data_id].name  + "\n"}    features.select{|x| x.code == 51}.each{|x| help += CODE[x.code] + ":" + @武器类型[x.data_id]  + "\n"}    features.select{|x| x.code == 52}.each{|x| help += CODE[x.code] + ":" + @防具类型[x.data_id]  + "\n"}    features.select{|x| x.code == 61}.each{|x| help += CODE[x.code] + ":" + x.value.to_s  + "\n"}    features.select{|x| x.code == 62}.each{|x| help += CODE[x.code] + ":" + FLAG[x.data_id]  + "\n"}    features.select{|x| x.code == 64}.each{|x| help += CODE[x.code] + ":" + @队伍能力[x.data_id]  + "\n"}    featuresparam = []    featuresparam.push features.select{|x| x.code == 21}    featuresparam.push features.select{|x| x.code == 22}    featuresparam.push features.select{|x| x.code == 23}    featuresparam[0].each{|x| help += PARAM[x.data_id] + "*" + x.value.to_s + "\n"}    featuresparam[1].each{|x| help += XPARAM[x.data_id] + x.value.to_s + "\n"}    featuresparam[2].each{|x| help += SPARAM[x.data_id] + "*" + x.value.to_s + "\n"}    help  end  def self.getline(text,maxtext)    xtext = []    line = 0    text.each_line{|x| xtext.push x.sub(/\n/){}}    xtext.each{|x| x.size % maxtext != 0 ? line += x.size / maxtext + 1 : line += x.size / maxtext}    line  endend#==============================================================================# ■ Window_Help#------------------------------------------------------------------------------#  显示特技和物品等的说明、以及角色状态的窗口#============================================================================== class Window_Help < Window_Base  #--------------------------------------------------------------------------  # ● 初始化对象  #--------------------------------------------------------------------------  def initialize(line_number = 0)    super(0, 0, 210, fitting_height(line_number))    self.z = 150    contents.font.size = 14    hide  end  #--------------------------------------------------------------------------  # ● 设置内容  #--------------------------------------------------------------------------  def set_text(text)    if text != @text      @text = text      refresh    end  end  #--------------------------------------------------------------------------  # ● 清除  #--------------------------------------------------------------------------  def clear    set_text("")  end  #--------------------------------------------------------------------------  # ● 更新帮助位置  #--------------------------------------------------------------------------  def uppos(index,rect,window)    self.height = fitting_height2(Help.getline(@xtext,13))    create_contents    contents.font.size = 14    rect.x -= window.ox    rect.y -= window.oy    ax = rect.x + rect.width + 10    ax = rect.x - self.width + 10 if ax + self.width > window.width + 10    ax += window.x    ax = 0 if ax < 0    ay = rect.y + rect.height    ay = rect.y - self.height if ay + self.height > window.height    ay += window.y    ay = 0 if ay < 0    self.x = ax    self.y = ay    set_text(@xtext)    show  end  #--------------------------------------------------------------------------  # ● 设置物品  #     item : 技能、物品等  #--------------------------------------------------------------------------  def set_item(item)    if item == nil      set_text("")      return    end    @xtext = ""    @xtext = "名称:" + item.name + "\n"    @xtext += "介绍:" + item.description + "\n"    @xtext += "价格:" + item.price.to_s + "\n" if item.is_a?(RPG::EquipItem) || item.is_a?(RPG::Item)    @xtext += Help.getequiphelp(item) if item.is_a?(RPG::EquipItem)    @xtext = @xtext[0,@text.size - 2] if @xtext[@xtext.size - 2,2] == "\n"  end  #--------------------------------------------------------------------------  # ● 刷新  #--------------------------------------------------------------------------  def refresh    contents.clear    hide if @text == ""    draw_text_ex(4, 0, @text,width,40,false)  endend class Window_Base < Window  #--------------------------------------------------------------------------  # ● 计算窗口显示指定行数时的应用高度2*************************  #--------------------------------------------------------------------------  def fitting_height2(line_number)  line_number * contents.font.size + standard_padding * 2  end#~ draw_text_ex的增强,使其可以自动换行  原作者:叶子 修改:wyongcan  #--------------------------------------------------------------------------  # ● 绘制带有控制符的文本内容  #   如果传递了width参数的话,会自动换行  #--------------------------------------------------------------------------  def draw_text_ex(x, y, text, width = nil,textwidth = nil,normalfont = true)    reset_font_settings if normalfont == true    text = convert_escape_characters(text)    pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)}    if width != nil      pos[:height] = contents.font.size      pos[:width] = width      pos[:textwidth] = textwidth    end    process_character(text.slice!(0, 1), text, pos) until text.empty?  end  #--------------------------------------------------------------------------  # ● 文字的处理  #     c    : 文字  #     text : 绘制处理中的字符串缓存(字符串可能会被修改)  #     pos  : 绘制位置 {:x, :y, :new_x, :height}  #--------------------------------------------------------------------------  def process_character(c, text, pos)    case c    when "\r"   # 回车      return    when "\n"   # 换行      process_new_line(text, pos)    when "\f"   # 翻页      process_new_page(text, pos)    when "\e"   # 控制符      process_escape_character(obtain_escape_code(text), text, pos)    else        # 普通文字      pos[:textwidth] == nil ? text_width = text_size(c).width : text_width = pos[:textwidth]      if pos[:width] != nil && pos[:x] - pos[:new_x] + text_width > pos[:width]        process_new_line(text, pos)      end      process_normal_character(c, pos)    end  endend class Window_ItemList < Window_Selectable  #--------------------------------------------------------------------------  # ● 更新帮助内容  #--------------------------------------------------------------------------  def update_help    @help_window.set_item(item)    @help_window.uppos(index,item_rect(index),self) if index != -1 && item != nil   endend class Window_SkillList < Window_Selectable  #--------------------------------------------------------------------------  # ● 更新帮助内容  #--------------------------------------------------------------------------  def update_help    @help_window.set_item(item)    @help_window.uppos(index,item_rect(index),self) if index != -1 && item != nil   endend class Window_ShopBuy < Window_Selectable  #--------------------------------------------------------------------------  # ● 更新帮助内容  #--------------------------------------------------------------------------  def update_help    @help_window.set_item(item) if @help_window    @help_window.uppos(index,item_rect(index),self) if index != -1 && item != nil && @help_window    @status_window.item = item if @status_window  endend class Window_EquipSlot < Window_Selectable  #--------------------------------------------------------------------------  # ● 更新帮助内容  #--------------------------------------------------------------------------  def update_help    super    @help_window.set_item(item) if @help_window    @help_window.uppos(index,item_rect(index),self) if index != -1 && item != nil && @help_window    @status_window.set_temp_actor(nil) if @status_window  endend class Scene_Shop < Scene_MenuBase        alias on_sell_ok_old on_sell_ok        def on_sell_ok                on_sell_ok_old                @help_window.hide        end        alias on_buy_ok_old on_buy_ok        def on_buy_ok                on_buy_ok_old                @help_window.hide        end        alias on_number_ok_old on_number_ok        def on_number_ok                on_number_ok_old    @help_window.refresh                @help_window.show        end        alias on_number_cancel_old on_number_cancel        def on_number_cancel                on_number_cancel_old    @help_window.refresh                @help_window.show        endend class Scene_Title < Scene_Base  alias start_old start  def start    start_old    Help.ready  endendclass Window_Base < Window        alias old_process_new_line process_new_line        def process_new_line(text, pos)    old_process_new_line(text, pos)                pos[:height] = contents.font.size if pos[:width] != nil        endendclass Scene_ItemBase < Scene_MenuBase        alias old_on_actor_cancel on_actor_cancel  def on_actor_cancel    old_on_actor_cancel        @help_window.refresh  end        alias old_on_actor_ok on_actor_ok  def on_actor_ok    old_on_actor_ok        @help_window.refresh  endend
#encoding:utf-8 
#============================================================================== 
# ■ 装备说明增强 
#------------------------------------------------------------------------------ 
#  修改了说明窗口,增强了装备的说明 作者:wyongcan  发布于66RPG   转载请注明 
#============================================================================== 
module Help 
  CODE ={ 
    11 => "属性抗性", 
    12 => "弱化抗性", 
    13 => "状态抗性", 
    14 => "状态免疫", 
    21 => "普通能力", 
    22 => "添加能力", 
    23 => "特殊能力", 
    31 => "攻击附带属性", 
    32 => "攻击附带状态", 
    33 => "修正攻击速度", 
    34 => "添加攻击次数", 
    41 => "添加技能类型", 
    42 => "禁用技能类型", 
    43 => "添加技能", 
    44 => "禁用技能", 
    51 => "可装备武器类型", 
    52 => "可装备护甲类型", 
    53 => "固定装备", 
    54 => "禁用装备", 
    55 => "装备风格", 
    61 => "添加行动次数", 
    62 => "特殊标志", 
    63 => "消失效果", 
    64 => "队伍能力"} 
  #特殊标志 
  FLAG ={ 
                0 => "自动战斗", 
                1 => "擅长防御", 
                2 => "保护弱者", 
                3 => "特技专注"} 
  #普通能力 
        PARAM ={ 
                0 => "最大HP", 
                1 => "最大MP", 
                2 => "物理攻击", 
                3 => "物理防御", 
                4 => "魔法攻击", 
                5 => "魔法防御", 
                6 => "敏 捷 值", 
                7 => "幸 运 值"} 
  #添加能力 
        XPARAM ={ 
                0 => "物理命中几率:", 
                1 => "物理闪避几率:", 
                2 => "必杀几率:", 
                3 => "必杀闪避几率:", 
                4 => "魔法闪避几率:", 
                5 => "魔法反射几率:", 
                6 => "物理反击几率:", 
                7 => "体力值再生速度:", 
                8 => "魔力值再生速度:", 
                9 => "特技值再生速度:"} 
  #特殊能力 
        SPARAM ={ 
                0 => "受到攻击的几率", 
                1 => "防御效果比率", 
                2 => "恢复效果比率", 
                3 => "药理知识", 
                4 => "MP消费率", 
                5 => "TP消耗率", 
                6 => "物理伤害加成", 
                7 => "魔法伤害加成", 
                8 => "地形伤害加成", 
                9 => "经验获得加成"} 
#~   #效果范围 
#~         SCOPE ={ 
#~                 0 => "特殊", 
#~                 1 => "单个敌人", 
#~                 2 => "全体敌人" , 
#~                 3 => "一个随机敌人", 
#~                 4 => "两个随机敌人", 
#~                 5 => "三个随机敌人", 
#~                 6 => "四个随机敌人", 
#~                 7 => "单个队友", 
#~                 8 => "全体队友", 
#~                 9 => "单个队友(无法战斗)", 
#~                 10 => "全体队友(无法战斗)", 
#~                 11 => "使用者"} 
        @队伍能力 ={ 
                0 => "遇敌几率减半", 
                1 => "随机遇敌无效", 
                2 => "敌人偷袭无效", 
                3 => "先制攻击几率上升", 
                4 => "获得金钱数量双倍", 
                5 => "物品掉落几率双倍"} 
  def self.ready 
    @状态 = {} 
    @武器类型 = {} 
    @防具类型 = {} 
    @属性 = {} 
    $data_states.each{|x| @状态[x.id] = x.name if x != nil} 
    elements = $data_system.elements 
    weapon_types = $data_system.weapon_types 
    armor_types = $data_system.armor_types 
    elements.each_with_index{|x,y| @属性[y] = x if x != ""} 
    weapon_types.each_with_index{|x,y| @武器类型[y] = x if x != ""} 
    armor_types.each_with_index{|x,y| @防具类型[y] = x if x != ""} 
  end 
  def self.getequiphelp(equip) 
    help = "" 
    param = [] 
    equip.params.each_with_index{|x,y| param.push([PARAM[y],x])} 
    param = param.select{|x| x[1] != 0} 
    param.each{|x| help += x[0] + ":" + x[1].to_s + "\n"} 
    features = equip.features 
    features.select{|x| x.code == 55}.each{|x| help += CODE[x.code] + ":双持武器" + "\n"} 
#    features.select{|x| x.code == 11}.each{|x| help += CODE[x.code] + ":" + @属性[x.data_id] + "*" + x.value.to_s + "\n"} 
    features.select{|x| x.code == 12}.each{|x| help += CODE[x.code] + ":" + PARAM[x.data_id] + "*" + x.value.to_s + "\n"} 
    features.select{|x| x.code == 13}.each{|x| help += CODE[x.code] + ":" + @状态[x.data_id] + "*" + x.value.to_s + "\n"} 
   # features.select{|x| x.code == 14}.each{|x| help += CODE[x.code] + ":" + @状态[x.data_id] + "\n"} 
#    features.select{|x| x.code == 31}.each{|x| help += CODE[x.code] + ":" + @属性[x.data_id] + "\n"} 
#    features.select{|x| x.code == 32}.each{|x| help += CODE[x.code] + ":" + @状态[x.data_id] + "+" + x.value.to_s + "\n"} 
    features.select{|x| x.code == 33}.each{|x| help += CODE[x.code] + ":" + x.value.to_s + "\n"} 
    features.select{|x| x.code == 34}.each{|x| help += CODE[x.code] + ":" + x.value.to_s + "\n"} 
    features.select{|x| x.code == 41}.each{|x| help += CODE[x.code] + ":" + (x.data_id == 1 ? "特技" : "魔法")  + "\n"} 
    features.select{|x| x.code == 42}.each{|x| help += CODE[x.code] + ":" + (x.data_id == 1 ? "特技" : "魔法")  + "\n"} 
   features.select{|x| x.code == 43}.each{|x| help += CODE[x.code] + ":" + $data_skills[x.data_id].name  + "\n"} 
    features.select{|x| x.code == 44}.each{|x| help += CODE[x.code] + ":" + $data_skills[x.data_id].name  + "\n"} 
    features.select{|x| x.code == 51}.each{|x| help += CODE[x.code] + ":" + @武器类型[x.data_id]  + "\n"} 
    features.select{|x| x.code == 52}.each{|x| help += CODE[x.code] + ":" + @防具类型[x.data_id]  + "\n"} 
    features.select{|x| x.code == 61}.each{|x| help += CODE[x.code] + ":" + x.value.to_s  + "\n"} 
    features.select{|x| x.code == 62}.each{|x| help += CODE[x.code] + ":" + FLAG[x.data_id]  + "\n"} 
    features.select{|x| x.code == 64}.each{|x| help += CODE[x.code] + ":" + @队伍能力[x.data_id]  + "\n"} 
    featuresparam = [] 
    featuresparam.push features.select{|x| x.code == 21} 
    featuresparam.push features.select{|x| x.code == 22} 
    featuresparam.push features.select{|x| x.code == 23} 
    featuresparam[0].each{|x| help += PARAM[x.data_id] + "*" + x.value.to_s + "\n"} 
    featuresparam[1].each{|x| help += XPARAM[x.data_id] + x.value.to_s + "\n"} 
    featuresparam[2].each{|x| help += SPARAM[x.data_id] + "*" + x.value.to_s + "\n"} 
    help 
  end 
  def self.getline(text,maxtext) 
    xtext = [] 
    line = 0 
    text.each_line{|x| xtext.push x.sub(/\n/){}} 
    xtext.each{|x| x.size % maxtext != 0 ? line += x.size / maxtext + 1 : line += x.size / maxtext} 
    line 
  end 
end 
#============================================================================== 
# ■ Window_Help 
#------------------------------------------------------------------------------ 
#  显示特技和物品等的说明、以及角色状态的窗口 
#============================================================================== 
  
class Window_Help < Window_Base 
  #-------------------------------------------------------------------------- 
  # ● 初始化对象 
  #-------------------------------------------------------------------------- 
  def initialize(line_number = 0) 
    super(0, 0, 210, fitting_height(line_number)) 
    self.z = 150 
    contents.font.size = 14 
    hide 
  end 
  #-------------------------------------------------------------------------- 
  # ● 设置内容 
  #-------------------------------------------------------------------------- 
  def set_text(text) 
    if text != @text 
      @text = text 
      refresh 
    end 
  end 
  #-------------------------------------------------------------------------- 
  # ● 清除 
  #-------------------------------------------------------------------------- 
  def clear 
    set_text("") 
  end 
  #-------------------------------------------------------------------------- 
  # ● 更新帮助位置 
  #-------------------------------------------------------------------------- 
  def uppos(index,rect,window) 
    self.height = fitting_height2(Help.getline(@xtext,13)) 
    create_contents 
    contents.font.size = 14 
    rect.x -= window.ox 
    rect.y -= window.oy 
    ax = rect.x + rect.width + 10 
    ax = rect.x - self.width + 10 if ax + self.width > window.width + 10 
    ax += window.x 
    ax = 0 if ax < 0 
    ay = rect.y + rect.height 
    ay = rect.y - self.height if ay + self.height > window.height 
    ay += window.y 
    ay = 0 if ay < 0 
    self.x = ax 
    self.y = ay 
    set_text(@xtext) 
    show 
  end 
  #-------------------------------------------------------------------------- 
  # ● 设置物品 
  #     item : 技能、物品等 
  #-------------------------------------------------------------------------- 
  def set_item(item) 
    if item == nil 
      set_text("") 
      return 
    end 
    @xtext = "" 
    @xtext = "名称:" + item.name + "\n" 
    @xtext += "介绍:" + item.description + "\n" 
    @xtext += "价格:" + item.price.to_s + "\n" if item.is_a?(RPG::EquipItem) || item.is_a?(RPG::Item) 
    @xtext += Help.getequiphelp(item) if item.is_a?(RPG::EquipItem) 
    @xtext = @xtext[0,@text.size - 2] if @xtext[@xtext.size - 2,2] == "\n" 
  end 
  #-------------------------------------------------------------------------- 
  # ● 刷新 
  #-------------------------------------------------------------------------- 
  def refresh 
    contents.clear 
    hide if @text == "" 
    draw_text_ex(4, 0, @text,width,40,false) 
  end 
end 
  
class Window_Base < Window 
  #-------------------------------------------------------------------------- 
  # ● 计算窗口显示指定行数时的应用高度2************************* 
  #-------------------------------------------------------------------------- 
  def fitting_height2(line_number) 
  line_number * contents.font.size + standard_padding * 2 
  end 
#~ draw_text_ex的增强,使其可以自动换行  原作者:叶子 修改:wyongcan 
  #-------------------------------------------------------------------------- 
  # ● 绘制带有控制符的文本内容 
  #   如果传递了width参数的话,会自动换行 
  #-------------------------------------------------------------------------- 
  def draw_text_ex(x, y, text, width = nil,textwidth = nil,normalfont = true) 
    reset_font_settings if normalfont == true 
    text = convert_escape_characters(text) 
    pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)} 
    if width != nil 
      pos[:height] = contents.font.size 
      pos[:width] = width 
      pos[:textwidth] = textwidth 
    end 
    process_character(text.slice!(0, 1), text, pos) until text.empty? 
  end 
  #-------------------------------------------------------------------------- 
  # ● 文字的处理 
  #     c    : 文字 
  #     text : 绘制处理中的字符串缓存(字符串可能会被修改) 
  #     pos  : 绘制位置 {:x, :y, :new_x, :height} 
  #-------------------------------------------------------------------------- 
  def process_character(c, text, pos) 
    case c 
    when "\r"   # 回车 
      return 
    when "\n"   # 换行 
      process_new_line(text, pos) 
    when "\f"   # 翻页 
      process_new_page(text, pos) 
    when "\e"   # 控制符 
      process_escape_character(obtain_escape_code(text), text, pos) 
    else        # 普通文字 
      pos[:textwidth] == nil ? text_width = text_size(c).width : text_width = pos[:textwidth] 
      if pos[:width] != nil && pos[:x] - pos[:new_x] + text_width > pos[:width] 
        process_new_line(text, pos) 
      end 
      process_normal_character(c, pos) 
    end 
  end 
end 
  
class Window_ItemList < Window_Selectable 
  #-------------------------------------------------------------------------- 
  # ● 更新帮助内容 
  #-------------------------------------------------------------------------- 
  def update_help 
    @help_window.set_item(item) 
    @help_window.uppos(index,item_rect(index),self) if index != -1 && item != nil  
  end 
end 
  
class Window_SkillList < Window_Selectable 
  #-------------------------------------------------------------------------- 
  # ● 更新帮助内容 
  #-------------------------------------------------------------------------- 
  def update_help 
    @help_window.set_item(item) 
    @help_window.uppos(index,item_rect(index),self) if index != -1 && item != nil  
  end 
end 
  
class Window_ShopBuy < Window_Selectable 
  #-------------------------------------------------------------------------- 
  # ● 更新帮助内容 
  #-------------------------------------------------------------------------- 
  def update_help 
    @help_window.set_item(item) if @help_window 
    @help_window.uppos(index,item_rect(index),self) if index != -1 && item != nil && @help_window 
    @status_window.item = item if @status_window 
  end 
end 
  
class Window_EquipSlot < Window_Selectable 
  #-------------------------------------------------------------------------- 
  # ● 更新帮助内容 
  #-------------------------------------------------------------------------- 
  def update_help 
    super 
    @help_window.set_item(item) if @help_window 
    @help_window.uppos(index,item_rect(index),self) if index != -1 && item != nil && @help_window 
    @status_window.set_temp_actor(nil) if @status_window 
  end 
end 
  
class Scene_Shop < Scene_MenuBase 
        alias on_sell_ok_old on_sell_ok 
        def on_sell_ok 
                on_sell_ok_old 
                @help_window.hide 
        end 
        alias on_buy_ok_old on_buy_ok 
        def on_buy_ok 
                on_buy_ok_old 
                @help_window.hide 
        end 
        alias on_number_ok_old on_number_ok 
        def on_number_ok 
                on_number_ok_old 
    @help_window.refresh 
                @help_window.show 
        end 
        alias on_number_cancel_old on_number_cancel 
        def on_number_cancel 
                on_number_cancel_old 
    @help_window.refresh 
                @help_window.show 
        end 
end 
  
class Scene_Title < Scene_Base 
  alias start_old start 
  def start 
    start_old 
    Help.ready 
  end 
end 
class Window_Base < Window 
        alias old_process_new_line process_new_line 
        def process_new_line(text, pos) 
    old_process_new_line(text, pos) 
                pos[:height] = contents.font.size if pos[:width] != nil 
        end 
end 
class Scene_ItemBase < Scene_MenuBase 
        alias old_on_actor_cancel on_actor_cancel 
  def on_actor_cancel 
    old_on_actor_cancel 
        @help_window.refresh 
  end 
        alias old_on_actor_ok on_actor_ok 
  def on_actor_ok 
    old_on_actor_ok 
        @help_window.refresh 
  end 
end 
 
 #==============================================================================# # ▼ Yanfly Engine Ace - TP Manager v1.02# -- Last Updated: 2011.12.10# -- Level: Hard# -- Requires: n/a# #============================================================================== $imported = {} if $imported.nil?$imported["YEA-TPManager"] = true #==============================================================================# ▼ Updates# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# 2011.12.10 - Added <tp cost: x> notetag.# 2011.12.06 - Fixed an error in one of the formulas.# 2011.12.05 - Started Script and Finished.# #==============================================================================# ▼ Introduction# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# The TP system in RPG Maker VX Ace is actually rather limiting. A lot of the# system is hardcoded in giving Ace users very little control over how much TP# gain a battler can receive from particular actions and situations. This# script gives you the ability to adjust how much TP actors will acquire from# various actions, different TP modes, and letting players select and pick what# TP mode they want for each actor (akin to Final Fantasy X).# #==============================================================================# ▼ Instructions# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# To install this script, open up your script editor and copy/paste this script# to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.# # -----------------------------------------------------------------------------# Actor Notetags - These notetags go in the actors notebox in the database.# -----------------------------------------------------------------------------# <tp mode: x># This sets the actor's default TP mode to x. If this tag isn't used, the# default TP mode will be set to whatever the module uses as default.# # <unlock tp: x># <unlock tp: x, x># This unlocks what TP modes the actor can use by default. If this tag isn't# used, the default unlocked TP modes will be whatever the module uses.# # -----------------------------------------------------------------------------# Item Notetags - These notetags go in the item notebox in the database.# -----------------------------------------------------------------------------# <unlock tp: x># <unlock tp: x, x># When this item is used upon an actor, that actor will learn TP Mode(s) x,# making it available to change in the TP Menu.# # -----------------------------------------------------------------------------# Skill Notetags - These notetags go in the skill notebox in the database.# -----------------------------------------------------------------------------# <unlock tp: x># <unlock tp: x, x># When this skill targets an actor, that actor will learn TP Mode(s) x thus,# making it available to change in the TP Menu.# # <learn unlock tp: x># <learn unlock tp: x, x># When an actor learns a skill with this notetag, that actor will learn# TP Mode(s) x making it available to change in the TP Menu.# # <tp cost: x># When this notetag appears in a skill's notebox, the TP cost for that skill# becomes x. This notetag allows TP costs to surpass 100 TP, which is the max# TP cost in the RPG Maker VX Ace database editor.# # -----------------------------------------------------------------------------# Enemy Notetags - These notetags go in the enemy notebox in the database.# -----------------------------------------------------------------------------# <tp mode: x># This sets the enemy's default TP mode to x. If this tag isn't used, the# default TP mode will be set to whatever the module uses as default.# # -----------------------------------------------------------------------------# Script Calls - These commands are used with script calls.# -----------------------------------------------------------------------------# change_tp_mode(x, y)# Replace x with the ID of the actor you want to change to the TP Mode y. This# will also unlock the TP mode for the actor, and make it available under the# skill menu for changing.# # unlock_tp_mode(x, y)# Replace x with the ID of the actor you want to learn for the TP Mode y. This# will cause the actor to learn the TP mode and have it accessible in the skill# menu for changing.# # remove_tp_mode(x, y)# Replace x with the ID of the actor you want to remove the TP Mode y. This# will cause the actor to forget the TP mode and no longer have it accessible# through the skill menu for changing.# # unlock_all_tp_modes(x)# Replace x with the ID of the actor you want to unlock all TP modes for. This# will make all the TP modes available to the actor from the skill menu.# # remove_all_tp_modes(x)# Removes all TP modes for actor x except for the actor's default TP mode.# This removes all TP modes from being available in the actor's skill menu.# #==============================================================================# ▼ Compatibility# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that# it will run with RPG Maker VX without adjusting.# #============================================================================== module YEA  module TP_MANAGER     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-    # - General TP Settings -    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-    # Here, you can adjust global settings for TP including the maximum TP,    # whether or not you want the player to change TP modes, and more.    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-    TP_LIMIT  = 100         # Sets the maximum TP. Default: 100    DEFAULT_TP_MODE = 0            # This is the TP mode everybody starts with                                   # unless changed through notetags.    DEFAULT_UNLOCKS = [0, 1, 2, 3,4,5,6,7,8,9,10,11,12,13,14,15,]     # These modes are unlocked for all actors                                   # unless changed through notetags.    LOW_HP = 0.25           # Percent for what is considered low HP.    LOW_MP = 0.25           # Percent for what is considered low MP.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-    # - TP Mode Change Settings -    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-    # Adjust the settings here for TP Mode Menu related items. Also, be sure    # to bind the TP_MODE_SWITCH to a switch ID. If that switch is on, the    # TP Mode item will appear in the skill menu. If off, it won't appear.    # If you set it to 0, then TP mode will always be enabled.    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-    MENU_NAME = "性格"   # The displayed name for the TP Menu.    TP_MODE_SWITCH  = 0     # Switch ID used for enabling TP Mode menu.    DEFAULT_ENABLE  = true  # Enable switch by default?    CHANGE_TP_RESET = true  # Reset TP to 0 whenever a mode is changed?    EQUIPPED_COLOUR = 17    # Window text colour used for equipped TP mode.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-    # - TP Modes -    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-    # TP modes have a number of things that can change the way actors gain TP.    # Adjust the settings below to change how much gain and loss incurs per    # each of the different actions.    #     # Setting        Description    # -------------------------------------------------------------------------    # - :name        - Name that appears in the TP Mode menu.    # - :icon        - Icon used for the TP Mode menu.    # - :description - Help window description. Use \n for line breaks.    # - :preserve_tp - Carry over TP from last battle to next battle?    # - :init_tp     - TP at the start of each battle if no TP preservation.    # - :regen_tp    - TP regenerated each turn. Uses a formula.    # - :take_hp_dmg - TP charged by receiving HP damage. Uses a formula.    # - :deal_hp_dmg - TP gained by dealing HP damage. Uses a formula.    # - :heal_hp_dmg - TP gained through healing HP damage. Uses a formula.    # - :ally_hp_dmg - TP gained when allies take HP damage. Uses a formula.    # - :take_mp_dmg - TP charged by receiving MP damage. Uses a formula.    # - :deal_mp_dmg - TP gained by dealing MP damage. Uses a formula.    # - :heal_mp_dmg - TP gained through healing MP damage. Uses a formula.    # - :ally_mp_dmg - TP gained when allies take MP damage. Uses a formula.    # - :deal_state  - TP gained when user inflicts a state to a foe. Formula.    # - :gain_state  - TP gained when user gains a state from a foe. Formula.    # - :kill_ally   - TP gained when an ally is killed. Uses a formula.    # - :kill_enemy  - TP gained when killing an enemy. Uses a formula.    # - :win_battle  - TP gained whenever a battle is won. Uses a formula.    # - :flee_battle - TP gained whenever party escapes. Uses a formula.    # - :lose_battle - TP gained whenever a battle is lost. Uses a formula.    # - :low_hp_turn - TP gained at the end of a turn with user at low HP.    # - :low_mp_turn - TP gained at the end of a turn with user at low MP.    # - :only_ally   - TP gained when user is only ally alive.    # - :evasion     - TP gained when user evades an attack.    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-    TP_MODES ={     # TP Mode => { Settings }    # -------------------------------------------------------------------------      0 => { # This is the default mode.      # :setting     => Adjust settings as you see fit.        :name        => "苦行僧",        :icon        => 121,        :description => "在等待或者受到攻击时增加TP.",        :preserve_tp => false,        :init_tp     => "rand * 25",        :regen_tp    => "100 * trg",        :take_hp_dmg => "50 * damage_rate * tcr",        :deal_hp_dmg => "0",        :heal_hp_dmg => "0",        :ally_hp_dmg => "0",        :take_mp_dmg => "0",        :deal_mp_dmg => "0",        :heal_mp_dmg => "0",        :ally_mp_dmg => "0",        :deal_state  => "0",        :gain_state  => "0",        :kill_ally   => "0",        :kill_enemy  => "0",        :win_battle  => "0",        :flee_battle => "0",        :lose_battle => "0",        :low_hp_turn => "0",        :low_mp_turn => "0",        :only_alive  => "0",        :evasion     => "0",      }, # Do not remove this.    # -------------------------------------------------------------------------      1 => { # New TP mode!      # :setting     => Adjust settings as you see fit.        :name        => "难友",        :icon        => 122,        :description => "每当同伴受伤都增加TP.",        :preserve_tp => true,        :init_tp     => "0",        :regen_tp    => "0",        :take_hp_dmg => "0",        :deal_hp_dmg => "0",        :heal_hp_dmg => "0",        :ally_hp_dmg => "20 * tcr",        :take_mp_dmg => "0",        :deal_mp_dmg => "0",        :heal_mp_dmg => "0",        :ally_mp_dmg => "0",        :deal_state  => "0",        :gain_state  => "0",        :kill_ally   => "0",        :kill_enemy  => "0",        :win_battle  => "0",        :flee_battle => "0",        :lose_battle => "0",        :low_hp_turn => "0",        :low_mp_turn => "0",        :only_alive  => "0",        :evasion     => "0",      }, # Do not remove this.    # -------------------------------------------------------------------------      2 => { # New TP mode!      # :setting     => Adjust settings as you see fit.        :name        => "勇者",        :icon        => 116,        :description => "进攻和治疗时增加TP.",        :preserve_tp => true,        :init_tp     => "0",        :regen_tp    => "0",        :take_hp_dmg => "0",        :deal_hp_dmg => "[@result.hp_damage * 100 / mhp, 16].min * tcr",        :heal_hp_dmg => "0",        :ally_hp_dmg => "0",        :take_mp_dmg => "0",        :deal_mp_dmg => "0",        :heal_mp_dmg => "0",        :ally_mp_dmg => "0",        :deal_state  => "0",        :gain_state  => "0",        :kill_ally   => "0",        :kill_enemy  => "0",        :win_battle  => "0",        :flee_battle => "0",        :lose_battle => "0",        :low_hp_turn => "0",        :low_mp_turn => "0",        :only_alive  => "0",        :evasion     => "0",      }, # Do not remove this.    # -------------------------------------------------------------------------      3 => { # New TP mode!      # :setting     => Adjust settings as you see fit.        :name        => "守护者",        :icon        => 112,        :description => "治疗时增加TP.",        :preserve_tp => true,        :init_tp     => "0",        :regen_tp    => "0",        :take_hp_dmg => "0",        :deal_hp_dmg => "0",        :heal_hp_dmg => "[@result.hp_damage * -100 / mhp, 16].min * tcr",        :ally_hp_dmg => "0",        :take_mp_dmg => "0",        :deal_mp_dmg => "0",        :heal_mp_dmg => "0",        :ally_mp_dmg => "0",        :deal_state  => "0",        :gain_state  => "0",        :kill_ally   => "0",        :kill_enemy  => "0",        :win_battle  => "0",        :flee_battle => "0",        :lose_battle => "0",        :low_hp_turn => "0",        :low_mp_turn => "0",        :only_alive  => "0",        :evasion     => "0",      }, # Do not remove this.    # -------------------------------------------------------------------------      4 => { # New TP mode!      # :setting     => Adjust settings as you see fit.        :name        => "中断者",        :icon        => 215,        :description => "恢复MP损害受到MP损伤或者同伴受到损伤时提高TP.",        :preserve_tp => true,        :init_tp     => "0",        :regen_tp    => "0",        :take_hp_dmg => "0",        :deal_hp_dmg => "0",        :heal_hp_dmg => "0",        :ally_hp_dmg => "0",        :take_mp_dmg => "50 * damage_rate * tcr",        :deal_mp_dmg => "[@result.mp_damage / 4, 16].min * tcr",        :heal_mp_dmg => "0",        :ally_mp_dmg => "20 * tcr",        :deal_state  => "0",        :gain_state  => "0",        :kill_ally   => "0",        :kill_enemy  => "0",        :win_battle  => "0",        :flee_battle => "0",        :lose_battle => "0",        :low_hp_turn => "0",        :low_mp_turn => "0",        :only_alive  => "0",        :evasion     => "0",      }, # Do not remove this.    # -------------------------------------------------------------------------      5 => { # New TP mode!      # :setting     => Adjust settings as you see fit.        :name        => "炼金术士",        :icon        => 193,        :description => "恢复同伴MP时增加TP.",        :preserve_tp => true,        :init_tp     => "0",        :regen_tp    => "0",        :take_hp_dmg => "0",        :deal_hp_dmg => "0",        :heal_hp_dmg => "0",        :ally_hp_dmg => "0",        :take_mp_dmg => "0",        :deal_mp_dmg => "0",        :heal_mp_dmg => "[@result.mp_damage / -4, 16].min * tcr",        :ally_mp_dmg => "0",        :deal_state  => "0",        :gain_state  => "0",        :kill_ally   => "0",        :kill_enemy  => "0",        :win_battle  => "0",        :flee_battle => "0",        :lose_battle => "0",        :low_hp_turn => "0",        :low_mp_turn => "0",        :only_alive  => "0",        :evasion     => "0",      }, # Do not remove this.    # -------------------------------------------------------------------------      6 => { # New TP mode!      # :setting     => Adjust settings as you see fit.        :name        => "杀手",        :icon        => 115,        :description => "当同伴死亡时增加TP.",        :preserve_tp => true,        :init_tp     => "0",        :regen_tp    => "0",        :take_hp_dmg => "0",        :deal_hp_dmg => "0",        :heal_hp_dmg => "0",        :ally_hp_dmg => "0",        :take_mp_dmg => "0",        :deal_mp_dmg => "0",        :heal_mp_dmg => "0",        :ally_mp_dmg => "0",        :deal_state  => "0",        :gain_state  => "0",        :kill_ally   => "0",        :kill_enemy  => "25 * tcr",        :win_battle  => "0",        :flee_battle => "0",        :lose_battle => "0",        :low_hp_turn => "0",        :low_mp_turn => "0",        :only_alive  => "0",        :evasion     => "0",      }, # Do not remove this.    # -------------------------------------------------------------------------      7 => { # New TP mode!      # :setting     => Adjust settings as you see fit.        :name        => "复仇者",        :icon        => 1,        :description => "当同伴死亡时增加TP.",        :preserve_tp => true,        :init_tp     => "0",        :regen_tp    => "0",        :take_hp_dmg => "0",        :deal_hp_dmg => "0",        :heal_hp_dmg => "0",        :ally_hp_dmg => "0",        :take_mp_dmg => "0",        :deal_mp_dmg => "0",        :heal_mp_dmg => "0",        :ally_mp_dmg => "0",        :deal_state  => "0",        :gain_state  => "0",        :kill_ally   => "50 * tcr",        :kill_enemy  => "0",        :win_battle  => "0",        :flee_battle => "0",        :lose_battle => "0",        :low_hp_turn => "0",        :low_mp_turn => "0",        :only_alive  => "0",        :evasion     => "0",      }, # Do not remove this.    # -------------------------------------------------------------------------      8 => { # New TP mode!      # :setting     => Adjust settings as you see fit.        :name        => "胜利者",        :icon        => 113,        :description => "不管是否战斗都增加TP.",        :preserve_tp => true,        :init_tp     => "0",        :regen_tp    => "0",        :take_hp_dmg => "0",        :deal_hp_dmg => "0",        :heal_hp_dmg => "0",        :ally_hp_dmg => "0",        :take_mp_dmg => "0",        :deal_mp_dmg => "0",        :heal_mp_dmg => "0",        :ally_mp_dmg => "0",        :deal_state  => "0",        :gain_state  => "0",        :kill_ally   => "0",        :kill_enemy  => "0",        :win_battle  => "20 * tcr",        :flee_battle => "0",        :lose_battle => "0",        :low_hp_turn => "0",        :low_mp_turn => "0",        :only_alive  => "0",        :evasion     => "0",      }, # Do not remove this.    # -------------------------------------------------------------------------      9 => { # New TP mode!      # :setting     => Adjust settings as you see fit.        :name        => "胆小鬼",        :icon        => 114,        :description => "不管是否逃跑都增加TP.",        :preserve_tp => true,        :init_tp     => "0",        :regen_tp    => "0",        :take_hp_dmg => "0",        :deal_hp_dmg => "0",        :heal_hp_dmg => "0",        :ally_hp_dmg => "0",        :take_mp_dmg => "0",        :deal_mp_dmg => "0",        :heal_mp_dmg => "0",        :ally_mp_dmg => "0",        :deal_state  => "0",        :gain_state  => "0",        :kill_ally   => "0",        :kill_enemy  => "0",        :win_battle  => "0",        :flee_battle => "0",        :lose_battle => "20 * tcr",        :low_hp_turn => "0",        :low_mp_turn => "0",        :only_alive  => "0",        :evasion     => "0",      }, # Do not remove this.    # -------------------------------------------------------------------------      10 => { # New TP mode!      # :setting     => Adjust settings as you see fit.        :name        => "狂人",        :icon        => 48,        :description => "不管战斗结束后多少TP都增加.",        :preserve_tp => true,        :init_tp     => "0",        :regen_tp    => "0",        :take_hp_dmg => "0",        :deal_hp_dmg => "0",        :heal_hp_dmg => "0",        :ally_hp_dmg => "0",        :take_mp_dmg => "0",        :deal_mp_dmg => "0",        :heal_mp_dmg => "0",        :ally_mp_dmg => "0",        :deal_state  => "0",        :gain_state  => "0",        :kill_ally   => "0",        :kill_enemy  => "0",        :win_battle  => "0",        :flee_battle => "0",        :lose_battle => "0",        :low_hp_turn => "16 * tcr",        :low_mp_turn => "0",        :only_alive  => "0",        :evasion     => "0",      }, # Do not remove this.    # -------------------------------------------------------------------------      11 => { # New TP mode!      # :setting     => Adjust settings as you see fit.        :name        => "调剂师",        :icon        => 49,        :description => "不管战斗结束后多少MP都增加TP.",        :preserve_tp => true,        :init_tp     => "0",        :regen_tp    => "0",        :take_hp_dmg => "0",        :deal_hp_dmg => "0",        :heal_hp_dmg => "0",        :ally_hp_dmg => "0",        :take_mp_dmg => "0",        :deal_mp_dmg => "0",        :heal_mp_dmg => "0",        :ally_mp_dmg => "0",        :deal_state  => "0",        :gain_state  => "0",        :kill_ally   => "0",        :kill_enemy  => "0",        :win_battle  => "0",        :flee_battle => "0",        :lose_battle => "0",        :low_hp_turn => "0",        :low_mp_turn => "16 * tcr",        :only_alive  => "0",        :evasion     => "0",      }, # Do not remove this.    # -------------------------------------------------------------------------      12 => { # New TP mode!      # :setting     => Adjust settings as you see fit.        :name        => "战略家",        :icon        => 10,        :description => "每当使敌人状态受到攻击提高TP.",        :preserve_tp => true,        :init_tp     => "0",        :regen_tp    => "0",        :take_hp_dmg => "0",        :deal_hp_dmg => "0",        :heal_hp_dmg => "0",        :ally_hp_dmg => "0",        :take_mp_dmg => "0",        :deal_mp_dmg => "0",        :heal_mp_dmg => "0",        :ally_mp_dmg => "0",        :deal_state  => "16 * tcr",        :gain_state  => "0",        :kill_ally   => "0",        :kill_enemy  => "0",        :win_battle  => "0",        :flee_battle => "0",        :lose_battle => "0",        :low_hp_turn => "0",        :low_mp_turn => "0",        :only_alive  => "0",        :evasion     => "0",      }, # Do not remove this.    # -------------------------------------------------------------------------      13 => { # New TP mode!      # :setting     => Adjust settings as you see fit.        :name        => "病人",        :icon        => 3,        :description => "每当状态受到攻击提高TP.",        :preserve_tp => true,        :init_tp     => "0",        :regen_tp    => "0",        :take_hp_dmg => "0",        :deal_hp_dmg => "0",        :heal_hp_dmg => "0",        :ally_hp_dmg => "0",        :take_mp_dmg => "0",        :deal_mp_dmg => "0",        :heal_mp_dmg => "0",        :ally_mp_dmg => "0",        :deal_state  => "0",        :gain_state  => "16 * tcr",        :kill_ally   => "0",        :kill_enemy  => "0",        :win_battle  => "0",        :flee_battle => "0",        :lose_battle => "0",        :low_hp_turn => "0",        :low_mp_turn => "0",        :only_alive  => "0",        :evasion     => "0",      }, # Do not remove this.    # -------------------------------------------------------------------------      14 => { # New TP mode!      # :setting     => Adjust settings as you see fit.        :name        => "舞者",        :icon        => 12,        :description => "每当成功地逃避攻击提高TP.",        :preserve_tp => true,        :init_tp     => "0",        :regen_tp    => "0",        :take_hp_dmg => "0",        :deal_hp_dmg => "0",        :heal_hp_dmg => "0",        :ally_hp_dmg => "0",        :take_mp_dmg => "0",        :deal_mp_dmg => "0",        :heal_mp_dmg => "0",        :ally_mp_dmg => "0",        :deal_state  => "0",        :gain_state  => "0",        :kill_ally   => "0",        :kill_enemy  => "0",        :win_battle  => "0",        :flee_battle => "0",        :lose_battle => "0",        :low_hp_turn => "0",        :low_mp_turn => "0",        :only_alive  => "0",        :evasion     => "16 * tcr",      }, # Do not remove this.    # -------------------------------------------------------------------------      15 => { # New TP mode!      # :setting     => Adjust settings as you see fit.        :name        => "独行侠",        :icon        => 14,        :description => "当只剩最后一人时增加TP.",        :preserve_tp => true,        :init_tp     => "0",        :regen_tp    => "0",        :take_hp_dmg => "0",        :deal_hp_dmg => "0",        :heal_hp_dmg => "0",        :ally_hp_dmg => "0",        :take_mp_dmg => "0",        :deal_mp_dmg => "0",        :heal_mp_dmg => "0",        :ally_mp_dmg => "0",        :deal_state  => "0",        :gain_state  => "0",        :kill_ally   => "0",        :kill_enemy  => "0",        :win_battle  => "0",        :flee_battle => "0",        :lose_battle => "0",        :low_hp_turn => "0",        :low_mp_turn => "0",        :only_alive  => "16 * tcr",        :evasion     => "0",      }, # Do not remove this.    # -------------------------------------------------------------------------    } # Do not remove this.   end # TP_MANAGERend # YEA #==============================================================================# ▼ Editting anything past this point may potentially result in causing# computer damage, incontinence, explosion of user's head, coma, death, and/or# halitosis so edit at your own risk.#============================================================================== module YEA  module REGEXP  module ACTOR     TP_MODE   = /<(?:TP_MODE|tp mode):[ ](\d+)>/i    UNLOCK_TP = /<(?:UNLOCK_TP|unlock tp):[ ]*(\d+(?:\s*,\s*\d+)*)>/i   end # ACTOR  module ENEMY     TP_MODE   = /<(?:TP_MODE|tp mode):[ ](\d+)>/i   end # ENEMY  module BASEITEM     UNLOCK_TP = /<(?:UNLOCK_TP|unlock tp):[ ]*(\d+(?:\s*,\s*\d+)*)>/i    LEARN_TP = /<(?:LEARN_UNLOCK_TP|learn unlock tp):[ ]*(\d+(?:\s*,\s*\d+)*)>/i    TP_COST  = /<(?:TP_COST|tp cost):[ ](\d+)>/i   end # BASEITEM  end # REGEXPend # YEA #==============================================================================# ■ Switch#============================================================================== module Switch   #--------------------------------------------------------------------------  # self.tp_mode  #--------------------------------------------------------------------------  def self.tp_mode    return true if YEA::TP_MANAGER::TP_MODE_SWITCH <= 0    return $game_switches[YEA::TP_MANAGER::TP_MODE_SWITCH]  end   #--------------------------------------------------------------------------  # self.tp_mode_set  #--------------------------------------------------------------------------  def self.tp_mode_set(item)    return if YEA::TP_MANAGER::TP_MODE_SWITCH <= 0    $game_switches[YEA::TP_MANAGER::TP_MODE_SWITCH] = item  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_tpm load_database; end  def self.load_database    load_database_tpm    load_notetags_tpm  end   #--------------------------------------------------------------------------  # new method: load_notetags_tpm  #--------------------------------------------------------------------------  def self.load_notetags_tpm    groups = [$data_actors, $data_enemies, $data_items, $data_skills]    for group in groups      for obj in group        next if obj.nil?        obj.load_notetags_tpm      end    end  end   #--------------------------------------------------------------------------  # alias method: setup_new_game  #--------------------------------------------------------------------------  class <<self; alias setup_new_game_tpm setup_new_game; end  def self.setup_new_game    setup_new_game_tpm    Switch.tp_mode_set(YEA::TP_MANAGER::DEFAULT_ENABLE)  end end # DataManager #==============================================================================# ■ RPG::Actor#============================================================================== class RPG::Actor < RPG::BaseItem   #--------------------------------------------------------------------------  # public instance variables  #--------------------------------------------------------------------------  attr_accessor :tp_mode  attr_accessor :unlocked_tp_modes   #--------------------------------------------------------------------------  # common cache: load_notetags_tpm  #--------------------------------------------------------------------------  def load_notetags_tpm    @tp_mode = nil    @unlocked_tp_modes = []    #---    self.note.split(/[\r\n]+/).each { |line|      case line      #---      when YEA::REGEXP::ACTOR::TP_MODE        @tp_mode = $1.to_i      when YEA::REGEXP::ACTOR::UNLOCK_TP        $1.scan(/\d+/).each { |num|         @unlocked_tp_modes.push(num.to_i) if num.to_i > 0 }      #---      end    } # self.note.split    #---    @tp_mode = YEA::TP_MANAGER::DEFAULT_TP_MODE if @tp_mode.nil?    if @unlocked_tp_modes.empty?      @unlocked_tp_modes = YEA::TP_MANAGER::DEFAULT_UNLOCKS.clone    end    @unlocked_tp_modes.push(@tp_mode) if !@unlocked_tp_modes.include?(@tp_mode)    @unlocked_tp_modes.uniq!    @unlocked_tp_modes.sort!  end end # RPG::Actor #==============================================================================# ■ RPG::Enemy#============================================================================== class RPG::Enemy < RPG::BaseItem   #--------------------------------------------------------------------------  # public instance variables  #--------------------------------------------------------------------------  attr_accessor :tp_mode   #--------------------------------------------------------------------------  # common cache: load_notetags_tpm  #--------------------------------------------------------------------------  def load_notetags_tpm    @tp_mode = YEA::TP_MANAGER::DEFAULT_TP_MODE    #---    self.note.split(/[\r\n]+/).each { |line|      case line      #---      when YEA::REGEXP::ENEMY::TP_MODE        @tp_mode = $1.to_i      #---      end    } # self.note.split    #---  end end # RPG::Enemy #==============================================================================# ■ RPG::BaseItem#============================================================================== class RPG::BaseItem   #--------------------------------------------------------------------------  # public instance variables  #--------------------------------------------------------------------------  attr_accessor :unlocked_tp_modes  attr_accessor :learn_tp_modes  attr_accessor :tp_cost   #--------------------------------------------------------------------------  # common cache: load_notetags_tpm  #--------------------------------------------------------------------------  def load_notetags_tpm    @unlocked_tp_modes = []    @learn_tp_modes = []    #---    self.note.split(/[\r\n]+/).each { |line|      case line      #---      when YEA::REGEXP::BASEITEM::UNLOCK_TP        $1.scan(/\d+/).each { |num|         @unlocked_tp_modes.push(num.to_i) if num.to_i > 0 }      when YEA::REGEXP::BASEITEM::LEARN_TP        $1.scan(/\d+/).each { |num|         @learn_tp_modes.push(num.to_i) if num.to_i > 0 }      when YEA::REGEXP::BASEITEM::TP_COST        next unless self.is_a?(RPG::Skill)        @tp_cost = $1.to_i      #---      end    } # self.note.split    #---  end end # RPG::BaseItem #==============================================================================# ■ BattleManager#============================================================================== module BattleManager  #--------------------------------------------------------------------------  # alias method: load_database  #--------------------------------------------------------------------------  class <<self; alias battle_end_tpm battle_end;end  def self.battle_end(result)    battle_end_tpm(result)    case result    when 0      for member in $game_party.alive_members        member.tp += eval(member.tp_setting(:win_battle))      end    when 1      for member in $game_party.alive_members        member.tp += eval(member.tp_setting(:flee_battle))      end    end  end   end # BattleManager #==============================================================================# ■ Game_BattlerBase#============================================================================== class Game_BattlerBase  #--------------------------------------------------------------------------  # public instance variables  #--------------------------------------------------------------------------  attr_accessor :tp_mode  attr_accessor :unlocked_tp_modes   #--------------------------------------------------------------------------  # overwrite method: max_tp  #--------------------------------------------------------------------------  def max_tp; return YEA::TP_MANAGER::TP_LIMIT; end   #--------------------------------------------------------------------------  # anti-crash methods: max_tp, unlocked_tp_modes  #--------------------------------------------------------------------------  def tp_mode; return 0; end  def unlocked_tp_modes; return [0]; end   #--------------------------------------------------------------------------  # new method: tp_setting  #--------------------------------------------------------------------------  def tp_setting(setting)    return YEA::TP_MANAGER::TP_MODES[tp_mode][setting]  end   #--------------------------------------------------------------------------  # alias method: preserve_tp?  #--------------------------------------------------------------------------  alias game_battlerbase_preserve_tp_tpm preserve_tp?  def preserve_tp?    return true if tp_setting(:preserve_tp)    return game_battlerbase_preserve_tp_tpm  end end # Game_BattlerBase #==============================================================================# ■ Game_Battler#============================================================================== class Game_Battler < Game_BattlerBase   #--------------------------------------------------------------------------  # overwrite method: init_tp  #--------------------------------------------------------------------------  def init_tp    self.tp = eval(tp_setting(:init_tp))  end   #--------------------------------------------------------------------------  # overwrite method: charge_tp_by_damage  #--------------------------------------------------------------------------  def charge_tp_by_damage(damage_rate)    self.tp += eval(tp_setting(:take_hp_dmg))  end   #--------------------------------------------------------------------------  # new method: charge_tp_by_mp_damage  #--------------------------------------------------------------------------  def charge_tp_by_mp_damage(damage_rate)    self.tp += eval(tp_setting(:take_mp_dmg))  end   #--------------------------------------------------------------------------  # overwrite method:   #--------------------------------------------------------------------------  def regenerate_tp    self.tp += eval(tp_setting(:regen_tp))    self.tp += eval(tp_setting(:low_hp_turn)) if self.hp < tp_low_hp    self.tp += eval(tp_setting(:low_mp_turn)) if self.mp < tp_low_mp    if friends_unit.alive_members.size == 1      self.tp += eval(tp_setting(:only_alive))    end  end   #--------------------------------------------------------------------------  # new method: tp_low_hp  #--------------------------------------------------------------------------  def tp_low_hp    return self.mhp * YEA::TP_MANAGER::LOW_HP  end   #--------------------------------------------------------------------------  # new method: tp_low_mp  #--------------------------------------------------------------------------  def tp_low_mp    return self.mmp * YEA::TP_MANAGER::LOW_MP  end   #--------------------------------------------------------------------------  # alias method: execute_damage  #--------------------------------------------------------------------------  alias game_battler_execute_damage_tpm execute_damage  def execute_damage(user)    game_battler_execute_damage_tpm(user)    return unless $game_party.in_battle    if @result.hp_damage > 0      user.tp += eval(user.tp_setting(:deal_hp_dmg))      gain_tp_ally_hp_damage    elsif @result.hp_damage < 0      user.tp += eval(user.tp_setting(:heal_hp_dmg))    end    if @result.mp_damage > 0      user.tp += eval(user.tp_setting(:deal_mp_dmg))      gain_tp_ally_mp_damage      charge_tp_by_mp_damage(@result.mp_damage)    elsif @result.mp_damage < 0      user.tp += eval(user.tp_setting(:heal_mp_dmg))    end    user.tp += eval(user.tp_setting(:kill_enemy)) if self.hp == 0    gain_tp_kill_ally if self.hp == 0  end   #--------------------------------------------------------------------------  # new method: gain_tp_ally_hp_damage  #--------------------------------------------------------------------------  def gain_tp_ally_hp_damage    for member in friends_unit.alive_members      next if member == self      member.tp += eval(member.tp_setting(:ally_hp_dmg))    end  end   #--------------------------------------------------------------------------  # new method: gain_tp_ally_mp_damage  #--------------------------------------------------------------------------  def gain_tp_ally_mp_damage    for member in friends_unit.alive_members      next if member == self      member.tp += eval(member.tp_setting(:ally_mp_dmg))    end  end   #--------------------------------------------------------------------------  # new method: gain_tp_kill_ally  #--------------------------------------------------------------------------  def gain_tp_kill_ally    for member in friends_unit.alive_members      next if member == self      member.tp += eval(member.tp_setting(:kill_ally))    end  end   #--------------------------------------------------------------------------  # alias method: item_effect_add_state  #--------------------------------------------------------------------------  alias game_battler_item_effect_add_state_tpm item_effect_add_state  def item_effect_add_state(user, item, effect)    original_states = states.clone    game_battler_item_effect_add_state_tpm(user, item, effect)    return unless $game_party.in_battle    if original_states != states && opponents_unit.members.include?(user)      user.tp += eval(user.tp_setting(:deal_state))      self.tp += eval(tp_setting(:gain_state))    end  end   #--------------------------------------------------------------------------  # alias method: item_apply  #--------------------------------------------------------------------------  alias game_battler_item_apply_tpm item_apply  def item_apply(user, item)    game_battler_item_apply_tpm(user, item)    return unless $game_party.in_battle    return if @result.hit?    self.tp += eval(tp_setting(:evasion))  end   #--------------------------------------------------------------------------  # alias method: item_test  #--------------------------------------------------------------------------  alias game_battler_item_test_tpm item_test  def item_test(user, item)    return false if item.for_dead_friend? != dead?    return true if item.unlocked_tp_modes.size > 0    return game_battler_item_test_tpm(user, item)  end   #--------------------------------------------------------------------------  # alias method: item_user_effect  #--------------------------------------------------------------------------  alias game_battler_item_user_effect_tpm item_user_effect  def item_user_effect(user, item)    game_battler_item_user_effect_tpm(user, item)    return unless actor?    for mode in item.unlocked_tp_modes      unlock_tp_mode(mode)    end  end end # Game_Battler #==============================================================================# ■ Game_Actor#============================================================================== class Game_Actor < Game_Battler   #--------------------------------------------------------------------------  # alias method: setup  #--------------------------------------------------------------------------  alias game_actor_setup_tpm setup  def setup(actor_id)    game_actor_setup_tpm(actor_id)    @tp_mode = actor.tp_mode    @unlocked_tp_modes = actor.unlocked_tp_modes.clone  end   #--------------------------------------------------------------------------  # new method: tp_mode  #--------------------------------------------------------------------------  def tp_mode    @tp_mode = actor.tp_mode if @tp_mode.nil?    return @tp_mode  end   #--------------------------------------------------------------------------  # new method: unlocked_tp_modes  #--------------------------------------------------------------------------  def unlocked_tp_modes    if @unlocked_tp_modes.empty?      @unlocked_tp_modes = actor.unlocked_tp_modes.clone    end    return @unlocked_tp_modes.uniq  end   #--------------------------------------------------------------------------  # new method: change_tp_mode  #--------------------------------------------------------------------------  def change_tp_mode(mode)    @tp_mode = mode    unlock_tp_mode(mode)    self.tp = 0 if YEA::TP_MANAGER::CHANGE_TP_RESET  end   #--------------------------------------------------------------------------  # new method: unlock_tp_mode  #--------------------------------------------------------------------------  def unlock_tp_mode(mode)    if @unlocked_tp_modes.empty?      @unlocked_tp_modes = actor.unlocked_tp_modes.clone    end    @unlocked_tp_modes.push(mode)    @unlocked_tp_modes.uniq!    @unlocked_tp_modes.sort!  end   #--------------------------------------------------------------------------  # new method: remove_tp_mode  #--------------------------------------------------------------------------  def remove_tp_mode(mode)    if @unlocked_tp_modes.empty?      @unlocked_tp_modes = actor.unlocked_tp_modes.clone    end    @unlocked_tp_modes.delete(mode)    @tp_mode = @unlocked_tp_modes[0] if @tp_mode == mode  end   #--------------------------------------------------------------------------  # alias method: learn_skill  #--------------------------------------------------------------------------  alias game_actor_learn_skill_tpm learn_skill  def learn_skill(skill_id)    game_actor_learn_skill_tpm(skill_id)    for mode in $data_skills[skill_id].learn_tp_modes      unlock_tp_mode(mode)    end  end end # Game_Actor #==============================================================================# ■ Game_Enemy#============================================================================== class Game_Enemy < Game_Battler   #--------------------------------------------------------------------------  # new method: tp_mode  #--------------------------------------------------------------------------  def tp_mode; return enemy.tp_mode; end end # Game_Enemy #==============================================================================# ■ Game_Interpreter#============================================================================== class Game_Interpreter   #--------------------------------------------------------------------------  # new method: change_tp_mode  #--------------------------------------------------------------------------  def change_tp_mode(actor_id, mode)    $game_actors[actor_id].change_tp_mode(mode)  end   #--------------------------------------------------------------------------  # new method: unlock_tp_mode  #--------------------------------------------------------------------------  def unlock_tp_mode(actor_id, mode)    $game_actors[actor_id].unlock_tp_mode(mode)  end   #--------------------------------------------------------------------------  # new method: remove_tp_mode  #--------------------------------------------------------------------------  def remove_tp_mode(actor_id, mode)    $game_actors[actor_id].remove_tp_mode(mode)  end   #--------------------------------------------------------------------------  # new method: unlock_all_tp_modes  #--------------------------------------------------------------------------  def unlock_all_tp_modes(actor_id)    for key in YEA::TP_MANAGER::TP_MODES      $game_actors[actor_id].unlock_tp_mode(key[0])    end  end   #--------------------------------------------------------------------------  # new method: remove_all_tp_modes  #--------------------------------------------------------------------------  def remove_all_tp_modes(actor_id)    for key in YEA::TP_MANAGER::TP_MODES      next if key[0] == $data_actors[actor_id].tp_mode      $game_actors[actor_id].remove_tp_mode(key[0])    end  end end # Game_Interpreter #==============================================================================# ■ Window_SkillCommand#============================================================================== class Window_SkillCommand < Window_Command   #--------------------------------------------------------------------------  # alias method: make_command_list  #--------------------------------------------------------------------------  alias window_skillcommand_make_command_list_tpm make_command_list  def make_command_list    return unless @actor    window_skillcommand_make_command_list_tpm   end   #--------------------------------------------------------------------------  # new method: add_tp_modes  #--------------------------------------------------------------------------  def add_tp_modes    return unless Switch.tp_mode    add_command(YEA::TP_MANAGER::MENU_NAME, :tp_mode, true, :tp_mode)  end end # Window_SkillCommand #==============================================================================# ■ Window_SkillList#============================================================================== class Window_SkillList < Window_Selectable   #--------------------------------------------------------------------------  # new method: tp_mode?  #--------------------------------------------------------------------------  def tp_mode?; return @stype_id == :tp_mode; end   #--------------------------------------------------------------------------  # new method: tp_mode  #--------------------------------------------------------------------------  def tp_mode    return nil unless tp_mode?    return @data[index]  end   #--------------------------------------------------------------------------  # alias method: make_item_list  #--------------------------------------------------------------------------  alias window_skilllist_make_item_list_tpm make_item_list  def make_item_list    if tp_mode?      @data = @actor.unlocked_tp_modes      @data.sort!    else      window_skilllist_make_item_list_tpm    end  end   #--------------------------------------------------------------------------  # alias method: draw_item  #--------------------------------------------------------------------------  alias window_skilllist_draw_item_tpm draw_item  def draw_item(index)    if tp_mode?      draw_tp_mode_item(index)    else      window_skilllist_draw_item_tpm(index)    end  end   #--------------------------------------------------------------------------  # new method: draw_tp_mode_item  #--------------------------------------------------------------------------  def draw_tp_mode_item(index)    tp_mode = @data[index]    return unless YEA::TP_MANAGER::TP_MODES.include?(tp_mode)    rect = item_rect(index)    rect.width -= 4    icon = YEA::TP_MANAGER::TP_MODES[tp_mode][:icon]    draw_icon(icon, rect.x, rect.y)    change_color(tp_mode_colour(tp_mode))    name = YEA::TP_MANAGER::TP_MODES[tp_mode][:name]    draw_text(rect.x+24, rect.y, rect.width-24, line_height, name)  end   #--------------------------------------------------------------------------  # new method: tp_mode_colour  #--------------------------------------------------------------------------  def tp_mode_colour(mode)    if @actor.tp_mode == mode      return text_color(YEA::TP_MANAGER::EQUIPPED_COLOUR)    else      return normal_color    end  end   #--------------------------------------------------------------------------  # alias method: current_item_enabled?  #--------------------------------------------------------------------------  alias window_skilllist_current_item_enabled current_item_enabled?  def current_item_enabled?    if tp_mode?      return @actor.tp_mode != @data[index]    else      return window_skilllist_current_item_enabled    end  end   #--------------------------------------------------------------------------  # alias method: update_help  #--------------------------------------------------------------------------  alias window_skilllist_update_help_tpm update_help  def update_help    if tp_mode?      tp_mode = @data[index]      if YEA::TP_MANAGER::TP_MODES.include?(tp_mode)        text = YEA::TP_MANAGER::TP_MODES[tp_mode][:description]      else        text = ""      end      @help_window.set_text(text)    else      window_skilllist_update_help_tpm    end  end end # Window_SkillList #==============================================================================# ■ Scene_Skill#============================================================================== class Scene_Skill < Scene_ItemBase   #--------------------------------------------------------------------------  # alias method: create_command_window  #--------------------------------------------------------------------------  alias scene_skill_create_command_window_tpm create_command_window  def create_command_window    scene_skill_create_command_window_tpm    @command_window.set_handler(:tp_mode,    method(:command_skill))  end   #--------------------------------------------------------------------------  # alias method: on_item_ok  #--------------------------------------------------------------------------  alias scene_skill_on_item_ok_tpm on_item_ok  def on_item_ok    if @item_window.tp_mode?      Sound.play_equip      user.change_tp_mode(@item_window.tp_mode)      @status_window.refresh      @item_window.refresh      @item_window.activate    else      scene_skill_on_item_ok_tpm    end  end end # Scene_Skill #==============================================================================# # ▼ End of File# #==============================================================================
#============================================================================== 
#  
# ▼ Yanfly Engine Ace - TP Manager v1.02 
# -- Last Updated: 2011.12.10 
# -- Level: Hard 
# -- Requires: n/a 
#  
#============================================================================== 
  
$imported = {} if $imported.nil? 
$imported["YEA-TPManager"] = true 
  
#============================================================================== 
# ▼ Updates 
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 
# 2011.12.10 - Added <tp cost: x> notetag. 
# 2011.12.06 - Fixed an error in one of the formulas. 
# 2011.12.05 - Started Script and Finished. 
#  
#============================================================================== 
# ▼ Introduction 
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 
# The TP system in RPG Maker VX Ace is actually rather limiting. A lot of the 
# system is hardcoded in giving Ace users very little control over how much TP 
# gain a battler can receive from particular actions and situations. This 
# script gives you the ability to adjust how much TP actors will acquire from 
# various actions, different TP modes, and letting players select and pick what 
# TP mode they want for each actor (akin to Final Fantasy X). 
#  
#============================================================================== 
# ▼ Instructions 
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 
# To install this script, open up your script editor and copy/paste this script 
# to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save. 
#  
# ----------------------------------------------------------------------------- 
# Actor Notetags - These notetags go in the actors notebox in the database. 
# ----------------------------------------------------------------------------- 
# <tp mode: x> 
# This sets the actor's default TP mode to x. If this tag isn't used, the 
# default TP mode will be set to whatever the module uses as default. 
#  
# <unlock tp: x> 
# <unlock tp: x, x> 
# This unlocks what TP modes the actor can use by default. If this tag isn't 
# used, the default unlocked TP modes will be whatever the module uses. 
#  
# ----------------------------------------------------------------------------- 
# Item Notetags - These notetags go in the item notebox in the database. 
# ----------------------------------------------------------------------------- 
# <unlock tp: x> 
# <unlock tp: x, x> 
# When this item is used upon an actor, that actor will learn TP Mode(s) x, 
# making it available to change in the TP Menu. 
#  
# ----------------------------------------------------------------------------- 
# Skill Notetags - These notetags go in the skill notebox in the database. 
# ----------------------------------------------------------------------------- 
# <unlock tp: x> 
# <unlock tp: x, x> 
# When this skill targets an actor, that actor will learn TP Mode(s) x thus, 
# making it available to change in the TP Menu. 
#  
# <learn unlock tp: x> 
# <learn unlock tp: x, x> 
# When an actor learns a skill with this notetag, that actor will learn 
# TP Mode(s) x making it available to change in the TP Menu. 
#  
# <tp cost: x> 
# When this notetag appears in a skill's notebox, the TP cost for that skill 
# becomes x. This notetag allows TP costs to surpass 100 TP, which is the max 
# TP cost in the RPG Maker VX Ace database editor. 
#  
# ----------------------------------------------------------------------------- 
# Enemy Notetags - These notetags go in the enemy notebox in the database. 
# ----------------------------------------------------------------------------- 
# <tp mode: x> 
# This sets the enemy's default TP mode to x. If this tag isn't used, the 
# default TP mode will be set to whatever the module uses as default. 
#  
# ----------------------------------------------------------------------------- 
# Script Calls - These commands are used with script calls. 
# ----------------------------------------------------------------------------- 
# change_tp_mode(x, y) 
# Replace x with the ID of the actor you want to change to the TP Mode y. This 
# will also unlock the TP mode for the actor, and make it available under the 
# skill menu for changing. 
#  
# unlock_tp_mode(x, y) 
# Replace x with the ID of the actor you want to learn for the TP Mode y. This 
# will cause the actor to learn the TP mode and have it accessible in the skill 
# menu for changing. 
#  
# remove_tp_mode(x, y) 
# Replace x with the ID of the actor you want to remove the TP Mode y. This 
# will cause the actor to forget the TP mode and no longer have it accessible 
# through the skill menu for changing. 
#  
# unlock_all_tp_modes(x) 
# Replace x with the ID of the actor you want to unlock all TP modes for. This 
# will make all the TP modes available to the actor from the skill menu. 
#  
# remove_all_tp_modes(x) 
# Removes all TP modes for actor x except for the actor's default TP mode. 
# This removes all TP modes from being available in the actor's skill menu. 
#  
#============================================================================== 
# ▼ Compatibility 
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 
# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that 
# it will run with RPG Maker VX without adjusting. 
#  
#============================================================================== 
  
module YEA 
  module TP_MANAGER 
  
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 
    # - General TP Settings - 
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 
    # Here, you can adjust global settings for TP including the maximum TP, 
    # whether or not you want the player to change TP modes, and more. 
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 
    TP_LIMIT  = 100         # Sets the maximum TP. Default: 100 
    DEFAULT_TP_MODE = 0            # This is the TP mode everybody starts with 
                                   # unless changed through notetags. 
    DEFAULT_UNLOCKS = [0, 1, 2, 3,4,5,6,7,8,9,10,11,12,13,14,15,]  
    # These modes are unlocked for all actors 
                                   # unless changed through notetags. 
    LOW_HP = 0.25           # Percent for what is considered low HP. 
    LOW_MP = 0.25           # Percent for what is considered low MP. 
  
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 
    # - TP Mode Change Settings - 
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 
    # Adjust the settings here for TP Mode Menu related items. Also, be sure 
    # to bind the TP_MODE_SWITCH to a switch ID. If that switch is on, the 
    # TP Mode item will appear in the skill menu. If off, it won't appear. 
    # If you set it to 0, then TP mode will always be enabled. 
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 
    MENU_NAME = "性格"   # The displayed name for the TP Menu. 
    TP_MODE_SWITCH  = 0     # Switch ID used for enabling TP Mode menu. 
    DEFAULT_ENABLE  = true  # Enable switch by default? 
    CHANGE_TP_RESET = true  # Reset TP to 0 whenever a mode is changed? 
    EQUIPPED_COLOUR = 17    # Window text colour used for equipped TP mode. 
  
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 
    # - TP Modes - 
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 
    # TP modes have a number of things that can change the way actors gain TP. 
    # Adjust the settings below to change how much gain and loss incurs per 
    # each of the different actions. 
    #  
    # Setting        Description 
    # ------------------------------------------------------------------------- 
    # - :name        - Name that appears in the TP Mode menu. 
    # - :icon        - Icon used for the TP Mode menu. 
    # - :description - Help window description. Use \n for line breaks. 
    # - :preserve_tp - Carry over TP from last battle to next battle? 
    # - :init_tp     - TP at the start of each battle if no TP preservation. 
    # - :regen_tp    - TP regenerated each turn. Uses a formula. 
    # - :take_hp_dmg - TP charged by receiving HP damage. Uses a formula. 
    # - :deal_hp_dmg - TP gained by dealing HP damage. Uses a formula. 
    # - :heal_hp_dmg - TP gained through healing HP damage. Uses a formula. 
    # - :ally_hp_dmg - TP gained when allies take HP damage. Uses a formula. 
    # - :take_mp_dmg - TP charged by receiving MP damage. Uses a formula. 
    # - :deal_mp_dmg - TP gained by dealing MP damage. Uses a formula. 
    # - :heal_mp_dmg - TP gained through healing MP damage. Uses a formula. 
    # - :ally_mp_dmg - TP gained when allies take MP damage. Uses a formula. 
    # - :deal_state  - TP gained when user inflicts a state to a foe. Formula. 
    # - :gain_state  - TP gained when user gains a state from a foe. Formula. 
    # - :kill_ally   - TP gained when an ally is killed. Uses a formula. 
    # - :kill_enemy  - TP gained when killing an enemy. Uses a formula. 
    # - :win_battle  - TP gained whenever a battle is won. Uses a formula. 
    # - :flee_battle - TP gained whenever party escapes. Uses a formula. 
    # - :lose_battle - TP gained whenever a battle is lost. Uses a formula. 
    # - :low_hp_turn - TP gained at the end of a turn with user at low HP. 
    # - :low_mp_turn - TP gained at the end of a turn with user at low MP. 
    # - :only_ally   - TP gained when user is only ally alive. 
    # - :evasion     - TP gained when user evades an attack. 
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 
    TP_MODES ={  
    # TP Mode => { Settings } 
    # ------------------------------------------------------------------------- 
      0 => { # This is the default mode. 
      # :setting     => Adjust settings as you see fit. 
        :name        => "苦行僧", 
        :icon        => 121, 
        :description => "在等待或者受到攻击时增加TP.", 
        :preserve_tp => false, 
        :init_tp     => "rand * 25", 
        :regen_tp    => "100 * trg", 
        :take_hp_dmg => "50 * damage_rate * tcr", 
        :deal_hp_dmg => "0", 
        :heal_hp_dmg => "0", 
        :ally_hp_dmg => "0", 
        :take_mp_dmg => "0", 
        :deal_mp_dmg => "0", 
        :heal_mp_dmg => "0", 
        :ally_mp_dmg => "0", 
        :deal_state  => "0", 
        :gain_state  => "0", 
        :kill_ally   => "0", 
        :kill_enemy  => "0", 
        :win_battle  => "0", 
        :flee_battle => "0", 
        :lose_battle => "0", 
        :low_hp_turn => "0", 
        :low_mp_turn => "0", 
        :only_alive  => "0", 
        :evasion     => "0", 
      }, # Do not remove this. 
    # ------------------------------------------------------------------------- 
      1 => { # New TP mode! 
      # :setting     => Adjust settings as you see fit. 
        :name        => "难友", 
        :icon        => 122, 
        :description => "每当同伴受伤都增加TP.", 
        :preserve_tp => true, 
        :init_tp     => "0", 
        :regen_tp    => "0", 
        :take_hp_dmg => "0", 
        :deal_hp_dmg => "0", 
        :heal_hp_dmg => "0", 
        :ally_hp_dmg => "20 * tcr", 
        :take_mp_dmg => "0", 
        :deal_mp_dmg => "0", 
        :heal_mp_dmg => "0", 
        :ally_mp_dmg => "0", 
        :deal_state  => "0", 
        :gain_state  => "0", 
        :kill_ally   => "0", 
        :kill_enemy  => "0", 
        :win_battle  => "0", 
        :flee_battle => "0", 
        :lose_battle => "0", 
        :low_hp_turn => "0", 
        :low_mp_turn => "0", 
        :only_alive  => "0", 
        :evasion     => "0", 
      }, # Do not remove this. 
    # ------------------------------------------------------------------------- 
      2 => { # New TP mode! 
      # :setting     => Adjust settings as you see fit. 
        :name        => "勇者", 
        :icon        => 116, 
        :description => "进攻和治疗时增加TP.", 
        :preserve_tp => true, 
        :init_tp     => "0", 
        :regen_tp    => "0", 
        :take_hp_dmg => "0", 
        :deal_hp_dmg => "[@result.hp_damage * 100 / mhp, 16].min * tcr", 
        :heal_hp_dmg => "0", 
        :ally_hp_dmg => "0", 
        :take_mp_dmg => "0", 
        :deal_mp_dmg => "0", 
        :heal_mp_dmg => "0", 
        :ally_mp_dmg => "0", 
        :deal_state  => "0", 
        :gain_state  => "0", 
        :kill_ally   => "0", 
        :kill_enemy  => "0", 
        :win_battle  => "0", 
        :flee_battle => "0", 
        :lose_battle => "0", 
        :low_hp_turn => "0", 
        :low_mp_turn => "0", 
        :only_alive  => "0", 
        :evasion     => "0", 
      }, # Do not remove this. 
    # ------------------------------------------------------------------------- 
      3 => { # New TP mode! 
      # :setting     => Adjust settings as you see fit. 
        :name        => "守护者", 
        :icon        => 112, 
        :description => "治疗时增加TP.", 
        :preserve_tp => true, 
        :init_tp     => "0", 
        :regen_tp    => "0", 
        :take_hp_dmg => "0", 
        :deal_hp_dmg => "0", 
        :heal_hp_dmg => "[@result.hp_damage * -100 / mhp, 16].min * tcr", 
        :ally_hp_dmg => "0", 
        :take_mp_dmg => "0", 
        :deal_mp_dmg => "0", 
        :heal_mp_dmg => "0", 
        :ally_mp_dmg => "0", 
        :deal_state  => "0", 
        :gain_state  => "0", 
        :kill_ally   => "0", 
        :kill_enemy  => "0", 
        :win_battle  => "0", 
        :flee_battle => "0", 
        :lose_battle => "0", 
        :low_hp_turn => "0", 
        :low_mp_turn => "0", 
        :only_alive  => "0", 
        :evasion     => "0", 
      }, # Do not remove this. 
    # ------------------------------------------------------------------------- 
      4 => { # New TP mode! 
      # :setting     => Adjust settings as you see fit. 
        :name        => "中断者", 
        :icon        => 215, 
        :description => "恢复MP损害受到MP损伤或者同伴受到损伤时提高TP.", 
        :preserve_tp => true, 
        :init_tp     => "0", 
        :regen_tp    => "0", 
        :take_hp_dmg => "0", 
        :deal_hp_dmg => "0", 
        :heal_hp_dmg => "0", 
        :ally_hp_dmg => "0", 
        :take_mp_dmg => "50 * damage_rate * tcr", 
        :deal_mp_dmg => "[@result.mp_damage / 4, 16].min * tcr", 
        :heal_mp_dmg => "0", 
        :ally_mp_dmg => "20 * tcr", 
        :deal_state  => "0", 
        :gain_state  => "0", 
        :kill_ally   => "0", 
        :kill_enemy  => "0", 
        :win_battle  => "0", 
        :flee_battle => "0", 
        :lose_battle => "0", 
        :low_hp_turn => "0", 
        :low_mp_turn => "0", 
        :only_alive  => "0", 
        :evasion     => "0", 
      }, # Do not remove this. 
    # ------------------------------------------------------------------------- 
      5 => { # New TP mode! 
      # :setting     => Adjust settings as you see fit. 
        :name        => "炼金术士", 
        :icon        => 193, 
        :description => "恢复同伴MP时增加TP.", 
        :preserve_tp => true, 
        :init_tp     => "0", 
        :regen_tp    => "0", 
        :take_hp_dmg => "0", 
        :deal_hp_dmg => "0", 
        :heal_hp_dmg => "0", 
        :ally_hp_dmg => "0", 
        :take_mp_dmg => "0", 
        :deal_mp_dmg => "0", 
        :heal_mp_dmg => "[@result.mp_damage / -4, 16].min * tcr", 
        :ally_mp_dmg => "0", 
        :deal_state  => "0", 
        :gain_state  => "0", 
        :kill_ally   => "0", 
        :kill_enemy  => "0", 
        :win_battle  => "0", 
        :flee_battle => "0", 
        :lose_battle => "0", 
        :low_hp_turn => "0", 
        :low_mp_turn => "0", 
        :only_alive  => "0", 
        :evasion     => "0", 
      }, # Do not remove this. 
    # ------------------------------------------------------------------------- 
      6 => { # New TP mode! 
      # :setting     => Adjust settings as you see fit. 
        :name        => "杀手", 
        :icon        => 115, 
        :description => "当同伴死亡时增加TP.", 
        :preserve_tp => true, 
        :init_tp     => "0", 
        :regen_tp    => "0", 
        :take_hp_dmg => "0", 
        :deal_hp_dmg => "0", 
        :heal_hp_dmg => "0", 
        :ally_hp_dmg => "0", 
        :take_mp_dmg => "0", 
        :deal_mp_dmg => "0", 
        :heal_mp_dmg => "0", 
        :ally_mp_dmg => "0", 
        :deal_state  => "0", 
        :gain_state  => "0", 
        :kill_ally   => "0", 
        :kill_enemy  => "25 * tcr", 
        :win_battle  => "0", 
        :flee_battle => "0", 
        :lose_battle => "0", 
        :low_hp_turn => "0", 
        :low_mp_turn => "0", 
        :only_alive  => "0", 
        :evasion     => "0", 
      }, # Do not remove this. 
    # ------------------------------------------------------------------------- 
      7 => { # New TP mode! 
      # :setting     => Adjust settings as you see fit. 
        :name        => "复仇者", 
        :icon        => 1, 
        :description => "当同伴死亡时增加TP.", 
        :preserve_tp => true, 
        :init_tp     => "0", 
        :regen_tp    => "0", 
        :take_hp_dmg => "0", 
        :deal_hp_dmg => "0", 
        :heal_hp_dmg => "0", 
        :ally_hp_dmg => "0", 
        :take_mp_dmg => "0", 
        :deal_mp_dmg => "0", 
        :heal_mp_dmg => "0", 
        :ally_mp_dmg => "0", 
        :deal_state  => "0", 
        :gain_state  => "0", 
        :kill_ally   => "50 * tcr", 
        :kill_enemy  => "0", 
        :win_battle  => "0", 
        :flee_battle => "0", 
        :lose_battle => "0", 
        :low_hp_turn => "0", 
        :low_mp_turn => "0", 
        :only_alive  => "0", 
        :evasion     => "0", 
      }, # Do not remove this. 
    # ------------------------------------------------------------------------- 
      8 => { # New TP mode! 
      # :setting     => Adjust settings as you see fit. 
        :name        => "胜利者", 
        :icon        => 113, 
        :description => "不管是否战斗都增加TP.", 
        :preserve_tp => true, 
        :init_tp     => "0", 
        :regen_tp    => "0", 
        :take_hp_dmg => "0", 
        :deal_hp_dmg => "0", 
        :heal_hp_dmg => "0", 
        :ally_hp_dmg => "0", 
        :take_mp_dmg => "0", 
        :deal_mp_dmg => "0", 
        :heal_mp_dmg => "0", 
        :ally_mp_dmg => "0", 
        :deal_state  => "0", 
        :gain_state  => "0", 
        :kill_ally   => "0", 
        :kill_enemy  => "0", 
        :win_battle  => "20 * tcr", 
        :flee_battle => "0", 
        :lose_battle => "0", 
        :low_hp_turn => "0", 
        :low_mp_turn => "0", 
        :only_alive  => "0", 
        :evasion     => "0", 
      }, # Do not remove this. 
    # ------------------------------------------------------------------------- 
      9 => { # New TP mode! 
      # :setting     => Adjust settings as you see fit. 
        :name        => "胆小鬼", 
        :icon        => 114, 
        :description => "不管是否逃跑都增加TP.", 
        :preserve_tp => true, 
        :init_tp     => "0", 
        :regen_tp    => "0", 
        :take_hp_dmg => "0", 
        :deal_hp_dmg => "0", 
        :heal_hp_dmg => "0", 
        :ally_hp_dmg => "0", 
        :take_mp_dmg => "0", 
        :deal_mp_dmg => "0", 
        :heal_mp_dmg => "0", 
        :ally_mp_dmg => "0", 
        :deal_state  => "0", 
        :gain_state  => "0", 
        :kill_ally   => "0", 
        :kill_enemy  => "0", 
        :win_battle  => "0", 
        :flee_battle => "0", 
        :lose_battle => "20 * tcr", 
        :low_hp_turn => "0", 
        :low_mp_turn => "0", 
        :only_alive  => "0", 
        :evasion     => "0", 
      }, # Do not remove this. 
    # ------------------------------------------------------------------------- 
      10 => { # New TP mode! 
      # :setting     => Adjust settings as you see fit. 
        :name        => "狂人", 
        :icon        => 48, 
        :description => "不管战斗结束后多少TP都增加.", 
        :preserve_tp => true, 
        :init_tp     => "0", 
        :regen_tp    => "0", 
        :take_hp_dmg => "0", 
        :deal_hp_dmg => "0", 
        :heal_hp_dmg => "0", 
        :ally_hp_dmg => "0", 
        :take_mp_dmg => "0", 
        :deal_mp_dmg => "0", 
        :heal_mp_dmg => "0", 
        :ally_mp_dmg => "0", 
        :deal_state  => "0", 
        :gain_state  => "0", 
        :kill_ally   => "0", 
        :kill_enemy  => "0", 
        :win_battle  => "0", 
        :flee_battle => "0", 
        :lose_battle => "0", 
        :low_hp_turn => "16 * tcr", 
        :low_mp_turn => "0", 
        :only_alive  => "0", 
        :evasion     => "0", 
      }, # Do not remove this. 
    # ------------------------------------------------------------------------- 
      11 => { # New TP mode! 
      # :setting     => Adjust settings as you see fit. 
        :name        => "调剂师", 
        :icon        => 49, 
        :description => "不管战斗结束后多少MP都增加TP.", 
        :preserve_tp => true, 
        :init_tp     => "0", 
        :regen_tp    => "0", 
        :take_hp_dmg => "0", 
        :deal_hp_dmg => "0", 
        :heal_hp_dmg => "0", 
        :ally_hp_dmg => "0", 
        :take_mp_dmg => "0", 
        :deal_mp_dmg => "0", 
        :heal_mp_dmg => "0", 
        :ally_mp_dmg => "0", 
        :deal_state  => "0", 
        :gain_state  => "0", 
        :kill_ally   => "0", 
        :kill_enemy  => "0", 
        :win_battle  => "0", 
        :flee_battle => "0", 
        :lose_battle => "0", 
        :low_hp_turn => "0", 
        :low_mp_turn => "16 * tcr", 
        :only_alive  => "0", 
        :evasion     => "0", 
      }, # Do not remove this. 
    # ------------------------------------------------------------------------- 
      12 => { # New TP mode! 
      # :setting     => Adjust settings as you see fit. 
        :name        => "战略家", 
        :icon        => 10, 
        :description => "每当使敌人状态受到攻击提高TP.", 
        :preserve_tp => true, 
        :init_tp     => "0", 
        :regen_tp    => "0", 
        :take_hp_dmg => "0", 
        :deal_hp_dmg => "0", 
        :heal_hp_dmg => "0", 
        :ally_hp_dmg => "0", 
        :take_mp_dmg => "0", 
        :deal_mp_dmg => "0", 
        :heal_mp_dmg => "0", 
        :ally_mp_dmg => "0", 
        :deal_state  => "16 * tcr", 
        :gain_state  => "0", 
        :kill_ally   => "0", 
        :kill_enemy  => "0", 
        :win_battle  => "0", 
        :flee_battle => "0", 
        :lose_battle => "0", 
        :low_hp_turn => "0", 
        :low_mp_turn => "0", 
        :only_alive  => "0", 
        :evasion     => "0", 
      }, # Do not remove this. 
    # ------------------------------------------------------------------------- 
      13 => { # New TP mode! 
      # :setting     => Adjust settings as you see fit. 
        :name        => "病人", 
        :icon        => 3, 
        :description => "每当状态受到攻击提高TP.", 
        :preserve_tp => true, 
        :init_tp     => "0", 
        :regen_tp    => "0", 
        :take_hp_dmg => "0", 
        :deal_hp_dmg => "0", 
        :heal_hp_dmg => "0", 
        :ally_hp_dmg => "0", 
        :take_mp_dmg => "0", 
        :deal_mp_dmg => "0", 
        :heal_mp_dmg => "0", 
        :ally_mp_dmg => "0", 
        :deal_state  => "0", 
        :gain_state  => "16 * tcr", 
        :kill_ally   => "0", 
        :kill_enemy  => "0", 
        :win_battle  => "0", 
        :flee_battle => "0", 
        :lose_battle => "0", 
        :low_hp_turn => "0", 
        :low_mp_turn => "0", 
        :only_alive  => "0", 
        :evasion     => "0", 
      }, # Do not remove this. 
    # ------------------------------------------------------------------------- 
      14 => { # New TP mode! 
      # :setting     => Adjust settings as you see fit. 
        :name        => "舞者", 
        :icon        => 12, 
        :description => "每当成功地逃避攻击提高TP.", 
        :preserve_tp => true, 
        :init_tp     => "0", 
        :regen_tp    => "0", 
        :take_hp_dmg => "0", 
        :deal_hp_dmg => "0", 
        :heal_hp_dmg => "0", 
        :ally_hp_dmg => "0", 
        :take_mp_dmg => "0", 
        :deal_mp_dmg => "0", 
        :heal_mp_dmg => "0", 
        :ally_mp_dmg => "0", 
        :deal_state  => "0", 
        :gain_state  => "0", 
        :kill_ally   => "0", 
        :kill_enemy  => "0", 
        :win_battle  => "0", 
        :flee_battle => "0", 
        :lose_battle => "0", 
        :low_hp_turn => "0", 
        :low_mp_turn => "0", 
        :only_alive  => "0", 
        :evasion     => "16 * tcr", 
      }, # Do not remove this. 
    # ------------------------------------------------------------------------- 
      15 => { # New TP mode! 
      # :setting     => Adjust settings as you see fit. 
        :name        => "独行侠", 
        :icon        => 14, 
        :description => "当只剩最后一人时增加TP.", 
        :preserve_tp => true, 
        :init_tp     => "0", 
        :regen_tp    => "0", 
        :take_hp_dmg => "0", 
        :deal_hp_dmg => "0", 
        :heal_hp_dmg => "0", 
        :ally_hp_dmg => "0", 
        :take_mp_dmg => "0", 
        :deal_mp_dmg => "0", 
        :heal_mp_dmg => "0", 
        :ally_mp_dmg => "0", 
        :deal_state  => "0", 
        :gain_state  => "0", 
        :kill_ally   => "0", 
        :kill_enemy  => "0", 
        :win_battle  => "0", 
        :flee_battle => "0", 
        :lose_battle => "0", 
        :low_hp_turn => "0", 
        :low_mp_turn => "0", 
        :only_alive  => "16 * tcr", 
        :evasion     => "0", 
      }, # Do not remove this. 
    # ------------------------------------------------------------------------- 
    } # Do not remove this. 
  
  end # TP_MANAGER 
end # YEA 
  
#============================================================================== 
# ▼ Editting anything past this point may potentially result in causing 
# computer damage, incontinence, explosion of user's head, coma, death, and/or 
# halitosis so edit at your own risk. 
#============================================================================== 
  
module YEA 
  module REGEXP 
  module ACTOR 
  
    TP_MODE   = /<(?:TP_MODE|tp mode):[ ](\d+)>/i 
    UNLOCK_TP = /<(?:UNLOCK_TP|unlock tp):[ ]*(\d+(?:\s*,\s*\d+)*)>/i 
  
  end # ACTOR 
  module ENEMY 
  
    TP_MODE   = /<(?:TP_MODE|tp mode):[ ](\d+)>/i 
  
  end # ENEMY 
  module BASEITEM 
  
    UNLOCK_TP = /<(?:UNLOCK_TP|unlock tp):[ ]*(\d+(?:\s*,\s*\d+)*)>/i 
    LEARN_TP = /<(?:LEARN_UNLOCK_TP|learn unlock tp):[ ]*(\d+(?:\s*,\s*\d+)*)>/i 
    TP_COST  = /<(?:TP_COST|tp cost):[ ](\d+)>/i 
  
  end # BASEITEM 
  end # REGEXP 
end # YEA 
  
#============================================================================== 
# ■ Switch 
#============================================================================== 
  
module Switch 
  
  #-------------------------------------------------------------------------- 
  # self.tp_mode 
  #-------------------------------------------------------------------------- 
  def self.tp_mode 
    return true if YEA::TP_MANAGER::TP_MODE_SWITCH <= 0 
    return $game_switches[YEA::TP_MANAGER::TP_MODE_SWITCH] 
  end 
  
  #-------------------------------------------------------------------------- 
  # self.tp_mode_set 
  #-------------------------------------------------------------------------- 
  def self.tp_mode_set(item) 
    return if YEA::TP_MANAGER::TP_MODE_SWITCH <= 0 
    $game_switches[YEA::TP_MANAGER::TP_MODE_SWITCH] = item 
  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_tpm load_database; end 
  def self.load_database 
    load_database_tpm 
    load_notetags_tpm 
  end 
  
  #-------------------------------------------------------------------------- 
  # new method: load_notetags_tpm 
  #-------------------------------------------------------------------------- 
  def self.load_notetags_tpm 
    groups = [$data_actors, $data_enemies, $data_items, $data_skills] 
    for group in groups 
      for obj in group 
        next if obj.nil? 
        obj.load_notetags_tpm 
      end 
    end 
  end 
  
  #-------------------------------------------------------------------------- 
  # alias method: setup_new_game 
  #-------------------------------------------------------------------------- 
  class <<self; alias setup_new_game_tpm setup_new_game; end 
  def self.setup_new_game 
    setup_new_game_tpm 
    Switch.tp_mode_set(YEA::TP_MANAGER::DEFAULT_ENABLE) 
  end 
  
end # DataManager 
  
#============================================================================== 
# ■ RPG::Actor 
#============================================================================== 
  
class RPG::Actor < RPG::BaseItem 
  
  #-------------------------------------------------------------------------- 
  # public instance variables 
  #-------------------------------------------------------------------------- 
  attr_accessor :tp_mode 
  attr_accessor :unlocked_tp_modes 
  
  #-------------------------------------------------------------------------- 
  # common cache: load_notetags_tpm 
  #-------------------------------------------------------------------------- 
  def load_notetags_tpm 
    @tp_mode = nil 
    @unlocked_tp_modes = [] 
    #--- 
    self.note.split(/[\r\n]+/).each { |line| 
      case line 
      #--- 
      when YEA::REGEXP::ACTOR::TP_MODE 
        @tp_mode = $1.to_i 
      when YEA::REGEXP::ACTOR::UNLOCK_TP 
        $1.scan(/\d+/).each { |num|  
        @unlocked_tp_modes.push(num.to_i) if num.to_i > 0 } 
      #--- 
      end 
    } # self.note.split 
    #--- 
    @tp_mode = YEA::TP_MANAGER::DEFAULT_TP_MODE if @tp_mode.nil? 
    if @unlocked_tp_modes.empty? 
      @unlocked_tp_modes = YEA::TP_MANAGER::DEFAULT_UNLOCKS.clone 
    end 
    @unlocked_tp_modes.push(@tp_mode) if !@unlocked_tp_modes.include?(@tp_mode) 
    @unlocked_tp_modes.uniq! 
    @unlocked_tp_modes.sort! 
  end 
  
end # RPG::Actor 
  
#============================================================================== 
# ■ RPG::Enemy 
#============================================================================== 
  
class RPG::Enemy < RPG::BaseItem 
  
  #-------------------------------------------------------------------------- 
  # public instance variables 
  #-------------------------------------------------------------------------- 
  attr_accessor :tp_mode 
  
  #-------------------------------------------------------------------------- 
  # common cache: load_notetags_tpm 
  #-------------------------------------------------------------------------- 
  def load_notetags_tpm 
    @tp_mode = YEA::TP_MANAGER::DEFAULT_TP_MODE 
    #--- 
    self.note.split(/[\r\n]+/).each { |line| 
      case line 
      #--- 
      when YEA::REGEXP::ENEMY::TP_MODE 
        @tp_mode = $1.to_i 
      #--- 
      end 
    } # self.note.split 
    #--- 
  end 
  
end # RPG::Enemy 
  
#============================================================================== 
# ■ RPG::BaseItem 
#============================================================================== 
  
class RPG::BaseItem 
  
  #-------------------------------------------------------------------------- 
  # public instance variables 
  #-------------------------------------------------------------------------- 
  attr_accessor :unlocked_tp_modes 
  attr_accessor :learn_tp_modes 
  attr_accessor :tp_cost 
  
  #-------------------------------------------------------------------------- 
  # common cache: load_notetags_tpm 
  #-------------------------------------------------------------------------- 
  def load_notetags_tpm 
    @unlocked_tp_modes = [] 
    @learn_tp_modes = [] 
    #--- 
    self.note.split(/[\r\n]+/).each { |line| 
      case line 
      #--- 
      when YEA::REGEXP::BASEITEM::UNLOCK_TP 
        $1.scan(/\d+/).each { |num|  
        @unlocked_tp_modes.push(num.to_i) if num.to_i > 0 } 
      when YEA::REGEXP::BASEITEM::LEARN_TP 
        $1.scan(/\d+/).each { |num|  
        @learn_tp_modes.push(num.to_i) if num.to_i > 0 } 
      when YEA::REGEXP::BASEITEM::TP_COST 
        next unless self.is_a?(RPG::Skill) 
        @tp_cost = $1.to_i 
      #--- 
      end 
    } # self.note.split 
    #--- 
  end 
  
end # RPG::BaseItem 
  
#============================================================================== 
# ■ BattleManager 
#============================================================================== 
  
module BattleManager 
  #-------------------------------------------------------------------------- 
  # alias method: load_database 
  #-------------------------------------------------------------------------- 
  class <<self; alias battle_end_tpm battle_end;end 
  def self.battle_end(result) 
    battle_end_tpm(result) 
    case result 
    when 0 
      for member in $game_party.alive_members 
        member.tp += eval(member.tp_setting(:win_battle)) 
      end 
    when 1 
      for member in $game_party.alive_members 
        member.tp += eval(member.tp_setting(:flee_battle)) 
      end 
    end 
  end 
  
  
  
end # BattleManager 
  
#============================================================================== 
# ■ Game_BattlerBase 
#============================================================================== 
  
class Game_BattlerBase 
  #-------------------------------------------------------------------------- 
  # public instance variables 
  #-------------------------------------------------------------------------- 
  attr_accessor :tp_mode 
  attr_accessor :unlocked_tp_modes 
  
  #-------------------------------------------------------------------------- 
  # overwrite method: max_tp 
  #-------------------------------------------------------------------------- 
  def max_tp; return YEA::TP_MANAGER::TP_LIMIT; end 
  
  #-------------------------------------------------------------------------- 
  # anti-crash methods: max_tp, unlocked_tp_modes 
  #-------------------------------------------------------------------------- 
  def tp_mode; return 0; end 
  def unlocked_tp_modes; return [0]; end 
  
  #-------------------------------------------------------------------------- 
  # new method: tp_setting 
  #-------------------------------------------------------------------------- 
  def tp_setting(setting) 
    return YEA::TP_MANAGER::TP_MODES[tp_mode][setting] 
  end 
  
  #-------------------------------------------------------------------------- 
  # alias method: preserve_tp? 
  #-------------------------------------------------------------------------- 
  alias game_battlerbase_preserve_tp_tpm preserve_tp? 
  def preserve_tp? 
    return true if tp_setting(:preserve_tp) 
    return game_battlerbase_preserve_tp_tpm 
  end 
  
end # Game_BattlerBase 
  
#============================================================================== 
# ■ Game_Battler 
#============================================================================== 
  
class Game_Battler < Game_BattlerBase 
  
  #-------------------------------------------------------------------------- 
  # overwrite method: init_tp 
  #-------------------------------------------------------------------------- 
  def init_tp 
    self.tp = eval(tp_setting(:init_tp)) 
  end 
  
  #-------------------------------------------------------------------------- 
  # overwrite method: charge_tp_by_damage 
  #-------------------------------------------------------------------------- 
  def charge_tp_by_damage(damage_rate) 
    self.tp += eval(tp_setting(:take_hp_dmg)) 
  end 
  
  #-------------------------------------------------------------------------- 
  # new method: charge_tp_by_mp_damage 
  #-------------------------------------------------------------------------- 
  def charge_tp_by_mp_damage(damage_rate) 
    self.tp += eval(tp_setting(:take_mp_dmg)) 
  end 
  
  #-------------------------------------------------------------------------- 
  # overwrite method:  
  #-------------------------------------------------------------------------- 
  def regenerate_tp 
    self.tp += eval(tp_setting(:regen_tp)) 
    self.tp += eval(tp_setting(:low_hp_turn)) if self.hp < tp_low_hp 
    self.tp += eval(tp_setting(:low_mp_turn)) if self.mp < tp_low_mp 
    if friends_unit.alive_members.size == 1 
      self.tp += eval(tp_setting(:only_alive)) 
    end 
  end 
  
  #-------------------------------------------------------------------------- 
  # new method: tp_low_hp 
  #-------------------------------------------------------------------------- 
  def tp_low_hp 
    return self.mhp * YEA::TP_MANAGER::LOW_HP 
  end 
  
  #-------------------------------------------------------------------------- 
  # new method: tp_low_mp 
  #-------------------------------------------------------------------------- 
  def tp_low_mp 
    return self.mmp * YEA::TP_MANAGER::LOW_MP 
  end 
  
  #-------------------------------------------------------------------------- 
  # alias method: execute_damage 
  #-------------------------------------------------------------------------- 
  alias game_battler_execute_damage_tpm execute_damage 
  def execute_damage(user) 
    game_battler_execute_damage_tpm(user) 
    return unless $game_party.in_battle 
    if @result.hp_damage > 0 
      user.tp += eval(user.tp_setting(:deal_hp_dmg)) 
      gain_tp_ally_hp_damage 
    elsif @result.hp_damage < 0 
      user.tp += eval(user.tp_setting(:heal_hp_dmg)) 
    end 
    if @result.mp_damage > 0 
      user.tp += eval(user.tp_setting(:deal_mp_dmg)) 
      gain_tp_ally_mp_damage 
      charge_tp_by_mp_damage(@result.mp_damage) 
    elsif @result.mp_damage < 0 
      user.tp += eval(user.tp_setting(:heal_mp_dmg)) 
    end 
    user.tp += eval(user.tp_setting(:kill_enemy)) if self.hp == 0 
    gain_tp_kill_ally if self.hp == 0 
  end 
  
  #-------------------------------------------------------------------------- 
  # new method: gain_tp_ally_hp_damage 
  #-------------------------------------------------------------------------- 
  def gain_tp_ally_hp_damage 
    for member in friends_unit.alive_members 
      next if member == self 
      member.tp += eval(member.tp_setting(:ally_hp_dmg)) 
    end 
  end 
  
  #-------------------------------------------------------------------------- 
  # new method: gain_tp_ally_mp_damage 
  #-------------------------------------------------------------------------- 
  def gain_tp_ally_mp_damage 
    for member in friends_unit.alive_members 
      next if member == self 
      member.tp += eval(member.tp_setting(:ally_mp_dmg)) 
    end 
  end 
  
  #-------------------------------------------------------------------------- 
  # new method: gain_tp_kill_ally 
  #-------------------------------------------------------------------------- 
  def gain_tp_kill_ally 
    for member in friends_unit.alive_members 
      next if member == self 
      member.tp += eval(member.tp_setting(:kill_ally)) 
    end 
  end 
  
  #-------------------------------------------------------------------------- 
  # alias method: item_effect_add_state 
  #-------------------------------------------------------------------------- 
  alias game_battler_item_effect_add_state_tpm item_effect_add_state 
  def item_effect_add_state(user, item, effect) 
    original_states = states.clone 
    game_battler_item_effect_add_state_tpm(user, item, effect) 
    return unless $game_party.in_battle 
    if original_states != states && opponents_unit.members.include?(user) 
      user.tp += eval(user.tp_setting(:deal_state)) 
      self.tp += eval(tp_setting(:gain_state)) 
    end 
  end 
  
  #-------------------------------------------------------------------------- 
  # alias method: item_apply 
  #-------------------------------------------------------------------------- 
  alias game_battler_item_apply_tpm item_apply 
  def item_apply(user, item) 
    game_battler_item_apply_tpm(user, item) 
    return unless $game_party.in_battle 
    return if @result.hit? 
    self.tp += eval(tp_setting(:evasion)) 
  end 
  
  #-------------------------------------------------------------------------- 
  # alias method: item_test 
  #-------------------------------------------------------------------------- 
  alias game_battler_item_test_tpm item_test 
  def item_test(user, item) 
    return false if item.for_dead_friend? != dead? 
    return true if item.unlocked_tp_modes.size > 0 
    return game_battler_item_test_tpm(user, item) 
  end 
  
  #-------------------------------------------------------------------------- 
  # alias method: item_user_effect 
  #-------------------------------------------------------------------------- 
  alias game_battler_item_user_effect_tpm item_user_effect 
  def item_user_effect(user, item) 
    game_battler_item_user_effect_tpm(user, item) 
    return unless actor? 
    for mode in item.unlocked_tp_modes 
      unlock_tp_mode(mode) 
    end 
  end 
  
end # Game_Battler 
  
#============================================================================== 
# ■ Game_Actor 
#============================================================================== 
  
class Game_Actor < Game_Battler 
  
  #-------------------------------------------------------------------------- 
  # alias method: setup 
  #-------------------------------------------------------------------------- 
  alias game_actor_setup_tpm setup 
  def setup(actor_id) 
    game_actor_setup_tpm(actor_id) 
    @tp_mode = actor.tp_mode 
    @unlocked_tp_modes = actor.unlocked_tp_modes.clone 
  end 
  
  #-------------------------------------------------------------------------- 
  # new method: tp_mode 
  #-------------------------------------------------------------------------- 
  def tp_mode 
    @tp_mode = actor.tp_mode if @tp_mode.nil? 
    return @tp_mode 
  end 
  
  #-------------------------------------------------------------------------- 
  # new method: unlocked_tp_modes 
  #-------------------------------------------------------------------------- 
  def unlocked_tp_modes 
    if @unlocked_tp_modes.empty? 
      @unlocked_tp_modes = actor.unlocked_tp_modes.clone 
    end 
    return @unlocked_tp_modes.uniq 
  end 
  
  #-------------------------------------------------------------------------- 
  # new method: change_tp_mode 
  #-------------------------------------------------------------------------- 
  def change_tp_mode(mode) 
    @tp_mode = mode 
    unlock_tp_mode(mode) 
    self.tp = 0 if YEA::TP_MANAGER::CHANGE_TP_RESET 
  end 
  
  #-------------------------------------------------------------------------- 
  # new method: unlock_tp_mode 
  #-------------------------------------------------------------------------- 
  def unlock_tp_mode(mode) 
    if @unlocked_tp_modes.empty? 
      @unlocked_tp_modes = actor.unlocked_tp_modes.clone 
    end 
    @unlocked_tp_modes.push(mode) 
    @unlocked_tp_modes.uniq! 
    @unlocked_tp_modes.sort! 
  end 
  
  #-------------------------------------------------------------------------- 
  # new method: remove_tp_mode 
  #-------------------------------------------------------------------------- 
  def remove_tp_mode(mode) 
    if @unlocked_tp_modes.empty? 
      @unlocked_tp_modes = actor.unlocked_tp_modes.clone 
    end 
    @unlocked_tp_modes.delete(mode) 
    @tp_mode = @unlocked_tp_modes[0] if @tp_mode == mode 
  end 
  
  #-------------------------------------------------------------------------- 
  # alias method: learn_skill 
  #-------------------------------------------------------------------------- 
  alias game_actor_learn_skill_tpm learn_skill 
  def learn_skill(skill_id) 
    game_actor_learn_skill_tpm(skill_id) 
    for mode in $data_skills[skill_id].learn_tp_modes 
      unlock_tp_mode(mode) 
    end 
  end 
  
end # Game_Actor 
  
#============================================================================== 
# ■ Game_Enemy 
#============================================================================== 
  
class Game_Enemy < Game_Battler 
  
  #-------------------------------------------------------------------------- 
  # new method: tp_mode 
  #-------------------------------------------------------------------------- 
  def tp_mode; return enemy.tp_mode; end 
  
end # Game_Enemy 
  
#============================================================================== 
# ■ Game_Interpreter 
#============================================================================== 
  
class Game_Interpreter 
  
  #-------------------------------------------------------------------------- 
  # new method: change_tp_mode 
  #-------------------------------------------------------------------------- 
  def change_tp_mode(actor_id, mode) 
    $game_actors[actor_id].change_tp_mode(mode) 
  end 
  
  #-------------------------------------------------------------------------- 
  # new method: unlock_tp_mode 
  #-------------------------------------------------------------------------- 
  def unlock_tp_mode(actor_id, mode) 
    $game_actors[actor_id].unlock_tp_mode(mode) 
  end 
  
  #-------------------------------------------------------------------------- 
  # new method: remove_tp_mode 
  #-------------------------------------------------------------------------- 
  def remove_tp_mode(actor_id, mode) 
    $game_actors[actor_id].remove_tp_mode(mode) 
  end 
  
  #-------------------------------------------------------------------------- 
  # new method: unlock_all_tp_modes 
  #-------------------------------------------------------------------------- 
  def unlock_all_tp_modes(actor_id) 
    for key in YEA::TP_MANAGER::TP_MODES 
      $game_actors[actor_id].unlock_tp_mode(key[0]) 
    end 
  end 
  
  #-------------------------------------------------------------------------- 
  # new method: remove_all_tp_modes 
  #-------------------------------------------------------------------------- 
  def remove_all_tp_modes(actor_id) 
    for key in YEA::TP_MANAGER::TP_MODES 
      next if key[0] == $data_actors[actor_id].tp_mode 
      $game_actors[actor_id].remove_tp_mode(key[0]) 
    end 
  end 
  
end # Game_Interpreter 
  
#============================================================================== 
# ■ Window_SkillCommand 
#============================================================================== 
  
class Window_SkillCommand < Window_Command 
  
  #-------------------------------------------------------------------------- 
  # alias method: make_command_list 
  #-------------------------------------------------------------------------- 
  alias window_skillcommand_make_command_list_tpm make_command_list 
  def make_command_list 
    return unless @actor 
    window_skillcommand_make_command_list_tpm 
  
  end 
  
  #-------------------------------------------------------------------------- 
  # new method: add_tp_modes 
  #-------------------------------------------------------------------------- 
  def add_tp_modes 
    return unless Switch.tp_mode 
    add_command(YEA::TP_MANAGER::MENU_NAME, :tp_mode, true, :tp_mode) 
  end 
  
end # Window_SkillCommand 
  
#============================================================================== 
# ■ Window_SkillList 
#============================================================================== 
  
class Window_SkillList < Window_Selectable 
  
  #-------------------------------------------------------------------------- 
  # new method: tp_mode? 
  #-------------------------------------------------------------------------- 
  def tp_mode?; return @stype_id == :tp_mode; end 
  
  #-------------------------------------------------------------------------- 
  # new method: tp_mode 
  #-------------------------------------------------------------------------- 
  def tp_mode 
    return nil unless tp_mode? 
    return @data[index] 
  end 
  
  #-------------------------------------------------------------------------- 
  # alias method: make_item_list 
  #-------------------------------------------------------------------------- 
  alias window_skilllist_make_item_list_tpm make_item_list 
  def make_item_list 
    if tp_mode? 
      @data = @actor.unlocked_tp_modes 
      @data.sort! 
    else 
      window_skilllist_make_item_list_tpm 
    end 
  end 
  
  #-------------------------------------------------------------------------- 
  # alias method: draw_item 
  #-------------------------------------------------------------------------- 
  alias window_skilllist_draw_item_tpm draw_item 
  def draw_item(index) 
    if tp_mode? 
      draw_tp_mode_item(index) 
    else 
      window_skilllist_draw_item_tpm(index) 
    end 
  end 
  
  #-------------------------------------------------------------------------- 
  # new method: draw_tp_mode_item 
  #-------------------------------------------------------------------------- 
  def draw_tp_mode_item(index) 
    tp_mode = @data[index] 
    return unless YEA::TP_MANAGER::TP_MODES.include?(tp_mode) 
    rect = item_rect(index) 
    rect.width -= 4 
    icon = YEA::TP_MANAGER::TP_MODES[tp_mode][:icon] 
    draw_icon(icon, rect.x, rect.y) 
    change_color(tp_mode_colour(tp_mode)) 
    name = YEA::TP_MANAGER::TP_MODES[tp_mode][:name] 
    draw_text(rect.x+24, rect.y, rect.width-24, line_height, name) 
  end 
  
  #-------------------------------------------------------------------------- 
  # new method: tp_mode_colour 
  #-------------------------------------------------------------------------- 
  def tp_mode_colour(mode) 
    if @actor.tp_mode == mode 
      return text_color(YEA::TP_MANAGER::EQUIPPED_COLOUR) 
    else 
      return normal_color 
    end 
  end 
  
  #-------------------------------------------------------------------------- 
  # alias method: current_item_enabled? 
  #-------------------------------------------------------------------------- 
  alias window_skilllist_current_item_enabled current_item_enabled? 
  def current_item_enabled? 
    if tp_mode? 
      return @actor.tp_mode != @data[index] 
    else 
      return window_skilllist_current_item_enabled 
    end 
  end 
  
  #-------------------------------------------------------------------------- 
  # alias method: update_help 
  #-------------------------------------------------------------------------- 
  alias window_skilllist_update_help_tpm update_help 
  def update_help 
    if tp_mode? 
      tp_mode = @data[index] 
      if YEA::TP_MANAGER::TP_MODES.include?(tp_mode) 
        text = YEA::TP_MANAGER::TP_MODES[tp_mode][:description] 
      else 
        text = "" 
      end 
      @help_window.set_text(text) 
    else 
      window_skilllist_update_help_tpm 
    end 
  end 
  
end # Window_SkillList 
  
#============================================================================== 
# ■ Scene_Skill 
#============================================================================== 
  
class Scene_Skill < Scene_ItemBase 
  
  #-------------------------------------------------------------------------- 
  # alias method: create_command_window 
  #-------------------------------------------------------------------------- 
  alias scene_skill_create_command_window_tpm create_command_window 
  def create_command_window 
    scene_skill_create_command_window_tpm 
    @command_window.set_handler(:tp_mode,    method(:command_skill)) 
  end 
  
  #-------------------------------------------------------------------------- 
  # alias method: on_item_ok 
  #-------------------------------------------------------------------------- 
  alias scene_skill_on_item_ok_tpm on_item_ok 
  def on_item_ok 
    if @item_window.tp_mode? 
      Sound.play_equip 
      user.change_tp_mode(@item_window.tp_mode) 
      @status_window.refresh 
      @item_window.refresh 
      @item_window.activate 
    else 
      scene_skill_on_item_ok_tpm 
    end 
  end 
  
end # Scene_Skill 
  
#============================================================================== 
#  
# ▼ End of File 
#  
#============================================================================== 
 | 
 |