查看: 2599|回复: 3

[已经解决] 人物属性加点与技能加点冲突

[复制链接]
梦石
0
星屑
1225
在线时间
564 小时
注册时间
2014-11-30
回帖
126
发表于 2015-6-6 15:41:40 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 309988769 于 2015-6-6 15:48 编辑

[pre lang="ruby"]#encoding:utf-8
#=============================================================================
#-----------RMVA加点系统正常向-v1.01---By:救世小树--------转载请注明出处-------
#=============================================================================

module Point_Tree
  
  POINT_VARIABLE = 34
  POINT_KIND     = 4             #设定加点种类
  #储存属性点的变量编号是34+角色id*(6+1),
  #即41号变量为一号角色自由点;42号起6个变量为1号角色6个种类的已加点值
  
  LEVEL_UP_POINT = 1
  #每升一级属性点增加数
  
  RESET_ITEM     = 20   #洗点水编号
  
  STR_POINT        = ["武力","谋略","政治","兵法"]#,"韧性","灵活","???"]
  #分别对应增加       [MHP,MMP,物攻,物防,魔攻,魔防,敏捷,幸运]
  POINT_ADD_PARAM = [[0 ,  0,   12,  0,   0,   0,   0,   0],     #体力
                     [0  , 0,   0,  0,   12,   0,   0,   0],     #精神
                     [0  ,  0,   0,  9,   0,   9,   0,   0],     #力量
                     [0  ,  0,   0,  0,   0,   0,   15,   0],     #魔力
#~                      [0  ,  0,   0,  0,   0,   0,   0,   0],     #韧性
#~                      [0  ,  0,   0,  0,   0,   0,   0,   0],     #灵活
                     
#~                      [0,0,0,0,0,0,0,0]
                    ]
                     #可以按上面的格式添加下去,不过要改POINT_KIND,STR_ALL,不然加了也白加
  
  #分别对应增加       [物理命中,物理闪避,必杀,必杀闪避,魔法闪避,魔法反射,物理反击,HP再生,Mp再生,Tp再生]
  POINT_ADD_XPARAM = [[0 , 0, 0, 0, 0, 0, 0, 0, 0, 0],
                      [0 , 0, 0, 0, 0, 0, 0, 0, 0, 0],
                      [0 , 0, 0, 0, 0, 0, 0, 0, 0, 0],
                      [0 , 0, 0, 0, 0, 0, 0, 0, 0, 0],
#~                       [0 , 0, 0, 0, 0, 0, 0, 0, 0, 0],
#~                       [0 , 0, 0, 0, 0, 0, 0, 0, 0, 0],
#~                     
#~                       [0,0,0,0,0,0,0,0,0,0]
                     ]
                     #这里的单位是万分之一数值也就是0.01%,我随便填了下【别嫌小,够大了,有心情你可以算算看平衡性】
  
  #各种名称
  ADDPOINT       = "加点"   #菜单中选项
  
  POINT_NAME     = "属性点" #未分配点数
  
  XARAM_NAME     = ["物理命中","物理闪避","暴击几率","暴击闪避","魔法闪避","魔法反射","物理反击","兵力回复率","气力回复率","怒气上升率"]
  def reset(actor_id)       #洗点
    for i in 1..6
      $game_variables[actor_id*(POINT_KIND+1) + POINT_VARIABLE]+=$game_variables[actor_id*(POINT_KIND+1) + POINT_VARIABLE+i]
      $game_variables[actor_id*(POINT_KIND+1) + POINT_VARIABLE+i]=0
    end
  end
  
  def temp_all
    r = 0
    for i in 0 .. POINT_KIND-1
      r+=$temp_point
    end
    return r
  end
  
  def point_add_param(actor_id)
    case actor_id
    when 1
      #分别对应增加       [MHP,MMP,物攻,物防,魔攻,魔防,敏捷,幸运]
      return [[0 ,  0,   12,  0,   0,   0,   0,   0],     #体力
              [0  , 0,   0,  0,   12,   0,   0,   0],     #精神
              [0  ,  0,   0,  9,   0,   9,   0,   0],     #力量
              [0  ,  0,   0,  0,   0,   0,   15,   0],     #魔力
             ]
    else
      return POINT_ADD_PARAM
    end
  end
  
  def point_add_xparam(actor_id)
    case actor_id
    when 1
      #分别对应增加 [物理命中,物理闪避,必杀,必杀闪避,魔法闪避,魔法反射,物理反击,HP再生,Mp再生,Tp再生]
      return [[0 , 0, 0, 0, 0, 0, 0, 0, 0, 0],
              [0 , 0, 0, 0, 0, 0, 0, 0, 0, 0],
              [0 , 0, 0, 0, 0, 0, 0, 0, 0, 0],
              [0 , 0, 0, 0, 0, 0, 0, 0, 0, 0],
             ]
    else
      return POINT_ADD_XPARAM
    end
  end
end
$temp_point = []
for i in 0 .. Point_Tree::POINT_KIND-1
  $temp_point.push(0)
end

class Game_Actor < Game_Battler
  include Point_Tree
  alias level_up_tre level_up
  def level_up
    level_up_tre
    @hp += mhp
    @mp += mmp
    $game_variables[self.id*(POINT_KIND+1) + POINT_VARIABLE] += LEVEL_UP_POINT
  end
  def point_plus(param_id)
    r=0
    for i in 0 .. POINT_KIND-1
      r+=$game_variables[self.id*(POINT_KIND+1) + POINT_VARIABLE+i+1]*point_add_param(@actor_id)[param_id]
    end
    return r
  end

  alias point_base_param param
  
  def param(param_id)
    value = param_base(param_id) + param_plus(param_id) + point_plus(param_id)
    value *= param_rate(param_id) * param_buff_rate(param_id)
    [[value, param_max(param_id)].min, param_min(param_id)].max.to_i
  end
  def xparam(xparam_id)
    xp = super(xparam_id)
    for i in 0 .. POINT_KIND-1
      xp+=($game_variables[self.id*(POINT_KIND+1) + POINT_VARIABLE+i+1]*point_add_xparam(@actor_id)[xparam_id]/10000.0)
    end
    return xp
  end
  def item_apply(user, item)
    super(user, item)
    if item.id == RESET_ITEM and item.is_a?(RPG::Item)
      reset(@actor_id)
      self.hp = [self.hp,self.mhp].min
      self.mp = [self.mp,self.mmp].min
    end
  end
end

class Window_Point_Command < Window_Command
  
  include Point_Tree
  #--------------------------------------------------------------------------
  # ● 初始化指令选择位置(类方法)
  #--------------------------------------------------------------------------
  def self.init_command_position
    @@last_command_symbol = nil
  end
  #--------------------------------------------------------------------------
  # ● 初始化对象
  #--------------------------------------------------------------------------
  def initialize(actor)
    @status_window = nil
    @actor = actor
    super(0,0)
    select_last
  end
  def actor=(actor)
    return if @actor == actor
    @actor = actor
    refresh
  end
  def status_window=(status_window)
    return if @status_window == status_window
    @status_window = status_window
  end
  #--------------------------------------------------------------------------
  # ● 获取窗口的宽度
  #--------------------------------------------------------------------------
  def window_width
    return 160
  end
  #--------------------------------------------------------------------------
  # ● 获取显示行数
  #--------------------------------------------------------------------------
  def visible_line_number
    item_max
  end
  def get_actor_point(id)
    s = $game_variables[@actor.id*(POINT_KIND+1)+POINT_VARIABLE+id+1].to_s
    return "("+s+")+"+$temp_point[id].to_s
  end
  #--------------------------------------------------------------------------
  # ● 生成指令列表
  #--------------------------------------------------------------------------
  def make_command_list
    for i in 0 .. POINT_KIND-1
      add_command(STR_POINT   + get_actor_point(i)  , :point_add  ,add_enabled)
    end
    add_command("确定",  :point_ok)
    add_command("取消",  :point_cancle)
  end
  #--------------------------------------------------------------------------
  # ● 按下确定键时的处理
  #--------------------------------------------------------------------------
  def process_ok
    @@last_command_symbol = current_symbol
    super
  end
  #--------------------------------------------------------------------------
  # ● 返回最后一个选项的位置
  #--------------------------------------------------------------------------
  def select_last
    select_symbol(@@last_command_symbol)
  end
  
  def add_enabled
    temp_all < $game_variables[@actor.id*(POINT_KIND+1) + POINT_VARIABLE]
  end

  def update_help
    @help_window.set_text(self.index+1) if @help_window
    @status_window.index = self.index if @status_window
  end
  
  #--------------------------------------------------------------------------
  # ● 光标向左移动
  #--------------------------------------------------------------------------
  def cursor_left(param)
    call_handler(:LEFT)
  end
  #--------------------------------------------------------------------------
  # ● 光标向右移动
  #--------------------------------------------------------------------------
  def cursor_right(param)
    call_handler(:RIGHT)
  end
end

if !ADJUST_X
#帮助窗口
class Window_Point_Help < Window_Base
  include Point_Tree
  def initialize(x,y,w,h)
    super(x, y, w, h)
  end
  
  def set_text(id)
    contents.clear
    if id <= POINT_KIND
      text = "\\}提升一点该属性"
    elsif id == POINT_KIND+1
      text = "\\}确认此次加点分配"
    elsif  id == POINT_KIND+2
      text = "\\}取消此次加点分配"
    end
    draw_text_ex(8, 8, text)
  end
end
end


#角色状态窗口
class Window_Point_Actor < Window_Base
  include Point_Tree
  
  
  def initialize(actor)
    super(160, 0, Graphics.width - 160, Graphics.height)
    @actor = actor
    @index = 0
    refresh
  end
  def actor=(actor)
    return if @actor == actor
    @actor = actor
    refresh
  end
  def index=(index)
    return if @index == index
    @index = index
    refresh
  end
  def line_height
    return 24
  end
  def refresh
    contents.clear
    contents.font.size = 32
    draw_actor_name(@actor, 100, 0)
    draw_actor_class(@actor, 240, 0)
    draw_actor_face(@actor, 2, 0)
    contents.font.size = 20
    draw_actor_level(@actor, 102,  24)
    draw_actor_point(100,48)
    contents.font.size = 16
    draw_actor_param_point(8,16 * 6)
    draw_actor_xparam_point(8,16 * 14)
    draw_text(8,100,172,24,"←→:切换角色")
  end
  def draw_actor_point(x,y)
    draw_text(x,y,200,line_height,"  未分配"+POINT_NAME + ":" + $game_variables[@actor.id*(POINT_KIND+1) + POINT_VARIABLE].to_s)
    draw_text(x,y+line_height,200,line_height,"此次分配"+POINT_NAME + ":" + temp_all.to_s)
  end
  def draw_actor_param_point(x,y)
    8.times {|i| draw_actor_param_to_s(x,y,i)}
  end
  def draw_actor_xparam_point(x,y)
    10.times {|i| draw_actor_xparam_to_s(x,y,i)}
  end
  
  def draw_actor_param_to_s(x,y,param_id)
    a=0
    for i in 0 .. POINT_KIND-1
      a+=$temp_point*point_add_param(@actor.id)[param_id]
    end
    s1 = Vocab::param(param_id)
    s2 = @actor.param(param_id).to_s
    s3 = (@actor.param(param_id) + a).to_s
    if @index < POINT_KIND
      if point_add_param(@actor.id)[@index][param_id]==0
        s4 = ""
      else
        s4 = "+" + point_add_param(@actor.id)[@index][param_id].to_s
      end
    else
      s4 = ""
    end
   
    change_color(system_color)
    draw_text(x,y+16*param_id,100,line_height,s1)
    change_color(normal_color)
    s2+= " →"
    draw_text(x+82,y+16*param_id,120,line_height,s2,2)
    contents.font.color = Color.new(0,255,0)
    draw_text(x+150,y+16*param_id,100,line_height,s3,2)
    contents.font.color = Color.new(0,255,0)
    contents.font.size = 14
    draw_text(x+266,y+16*param_id,100,line_height,s4,2)
    contents.font.size = 16
  end
  
  def draw_actor_xparam_to_s(x,y,xparam_id)
    a=0.00
    for i in 0 .. POINT_KIND-1
      a+=($temp_point*point_add_xparam(@actor.id)[xparam_id]/10000.0)
    end
    s1 = XARAM_NAME[xparam_id]
    s2 = sprintf("%03.2f%%",@actor.xparam(xparam_id)*100)
    s3 = sprintf("%03.2f%%",(@actor.xparam(xparam_id) + a)*100)

    if @index < POINT_KIND
      if point_add_xparam(@actor.id)[@index][xparam_id]==0
        s4=""
      else
        s4 = sprintf("+%03.2f%%",point_add_xparam(@actor.id)[@index][xparam_id]/100.0)
      end
    else
      s4 = ""
    end
   
    change_color(system_color)
    draw_text(x,y+16*xparam_id,100,line_height,s1)
    change_color(normal_color)
    s2+= " →"
    draw_text(x+82,y+16*xparam_id,150,line_height,s2,2)
    change_color(system_color)
    draw_text(x+150,y+16*xparam_id,120,line_height,s3,2)
    change_color(normal_color)
    contents.font.size = 14
    draw_text(x+266,y+16*xparam_id,100,line_height,s4)
    contents.font.size = 16
   
  end
end

class Scene_Point < Scene_MenuBase
  include Point_Tree
  def start
    super
    Window_Point_Command::init_command_position
    create_background
    @actor = $game_party.menu_actor
    create_command_window
    create_status_window
    create_help_window
    @command_window.activate
  end
  def terminate
    super
    dispose_background
  end
  
  def create_command_window
    @command_window = Window_Point_Command.new(@actor)
    @command_window.set_handler(:cancel,      method(:return_scene))
    @command_window.set_handler(:RIGHT,    method(:next_actor))
    @command_window.set_handler(:LEFT,      method(:prev_actor))
    @command_window.set_handler(:point_add,   method(:add_point))
    @command_window.set_handler(:point_ok,    method(:add_ok))
    @command_window.set_handler(:point_cancle,method(:add_cancle))
   
  end
  def return_scene
    add_cancle
    SceneManager.return
  end
  def create_status_window
    @status_window = Window_Point_Actor.new(@actor)
    @command_window.status_window = @status_window
  end
  def create_help_window
    @help_window = Window_Point_Help.new(0,@command_window.height,160,Graphics.height-@command_window.height)
    @help_window.viewport = @viewport
    @command_window.help_window = @help_window
  end
  
  def add_point
    if temp_all >= $game_variables[@actor.id*(POINT_KIND+1) + POINT_VARIABLE]
      @command_window.activate
      return
    end
    $temp_point[@command_window.index] += 1
    @status_window.refresh
    @command_window.refresh
    @command_window.activate
  end
  

  def add_ok
    for i in 0 .. POINT_KIND-1
      $game_variables[@actor.id*(POINT_KIND+1) + POINT_VARIABLE+i+1] += $temp_point
    end
    $game_variables[@actor.id*(POINT_KIND+1) + POINT_VARIABLE] -= temp_all
    add_cancle
  end
  
  def add_cancle
    for i in 0 .. POINT_KIND-1
      $temp_point=0
    end
    @status_window.refresh
    @command_window.refresh
    @command_window.activate
  end
  
  
  def next_actor
    @actor = $game_party.menu_actor_next
    on_actor_change
  end
  #--------------------------------------------------------------------------
  # ● 切换到上一个角色
  #--------------------------------------------------------------------------
  def prev_actor
    @actor = $game_party.menu_actor_prev
    on_actor_change
  end
  #--------------------------------------------------------------------------
  # ● 切换角色
  #--------------------------------------------------------------------------
  def on_actor_change
    add_cancle
    @status_window.actor = @actor
    @command_window.actor = @actor
    @command_window.activate
  end
  
  
end

class Window_MenuCommand < Window_Command
  alias add_original_commands_old add_original_commands
  def add_original_commands
    add_original_commands_old
    add_command(Point_Tree::ADDPOINT,    :addpoint)
  end
end

class Scene_Menu < Scene_MenuBase
  alias create_command_window_old create_command_window
  def create_command_window
    create_command_window_old
    @command_window.set_handler(:addpoint,method(:on_ok))
  end
  def on_ok
    SceneManager.call(Scene_Point)
  end
end



class Scene_ItemBase < Scene_MenuBase
  def item_usable?
    if item.id == Point_Tree::RESET_ITEM
      return true
    end
    user.usable?(item) && item_effects_valid?
  end
end

#==============================================================================
#
# ▼ 以下为我的修改,主要为了适应1024*576分辨率。By风宥雪
#
#==============================================================================
if ADJUST_X
#帮助窗口
class Window_Point_Help < Window_Help
  include Point_Tree
  def set_text(id)
    contents.clear
    if id <= POINT_KIND
      text = "提升一点该属性"
    elsif id == POINT_KIND+1
      text = "确认此次加点分配"
    elsif  id == POINT_KIND+2
      text = "取消此次加点分配"
    end
    draw_text_ex(8, 8, text)
  end
end
#加点命令窗口
class Window_Point_Command < Window_Command
  #--------------------------------------------------------------------------
  # ● 初始化对象
  #--------------------------------------------------------------------------
  def initialize(actor)
    @status_window = nil
    @actor = actor
    super(ADJUST_X,ADJUST_Y)
    select_last
  end
  #--------------------------------------------------------------------------
  # ● 获取窗口的高度
  #--------------------------------------------------------------------------
  def window_height
    ADJUST_CY
  end
end
#角色状态窗口
class Window_Point_Actor < Window_Base
  def initialize(actor)
    super(160+ADJUST_X, ADJUST_Y, ADJUST_CX - 160, ADJUST_CY)
    @actor = actor
    @index = 0
    refresh
  end
  #基础属性
   def draw_actor_param_to_s(x,y,param_id)
    #坐标下调一点
    y += 25
    a=0
    for i in 0 .. POINT_KIND-1
      a+=$temp_point*point_add_param(@actor.id)[param_id]
    end
    #属性名称
    s1 = Vocab::param(param_id)
    #当前值
    s2 = @actor.param(param_id).to_s
    #新值
    s3 = (@actor.param(param_id) + a).to_s
    #加点效果
    if @index < POINT_KIND
      if point_add_param(@actor.id)[@index][param_id]==0
        s4 = ""
      else
        s4 = "+" + point_add_param(@actor.id)[@index][param_id].to_s
      end
    else
      s4 = ""
    end
    #特殊属性
    change_color(system_color)
    draw_text(x,y+16*param_id,100,line_height,s1)
    change_color(normal_color)
    s2+= " →"
    draw_text(x+52,y+16*param_id,150,line_height,s2,2)
    contents.font.color = Color.new(0,255,0) if a > 0
    contents.font.bold = true
    draw_text(x+150,y+16*param_id,120,line_height,s3,2)
    #contents.font.color = Color.new(0,255,0)
    #contents.font.bold = true
    draw_text(250,y+16*param_id,100,line_height,s4,2)
    contents.font.bold = false
  end
  
  def draw_actor_xparam_to_s(x,y,xparam_id)
    #坐标下调一点
    y += 25
    a=0.00
    for i in 0 .. POINT_KIND-1
      a+=($temp_point*point_add_xparam(@actor.id)[xparam_id]/10000.0)
    end
    s1 = XARAM_NAME[xparam_id]
    s2 = sprintf("%03.2f%%",@actor.xparam(xparam_id)*100)
    s3 = sprintf("%03.2f%%",(@actor.xparam(xparam_id) + a)*100)

    if @index < POINT_KIND
      if point_add_xparam(@actor.id)[@index][xparam_id]==0
        s4=""
      else
        s4 = sprintf("+%03.2f%%",point_add_xparam(@actor.id)[@index][xparam_id]/100.0)
      end
    else
      s4 = ""
    end
    change_color(system_color)
    draw_text(x,y+16*xparam_id,100,line_height,s1)
    change_color(normal_color)
    s2+= " →"
    draw_text(x+52,y+16*xparam_id,150,line_height,s2,2)
    contents.font.color = Color.new(0,255,0)  if a > 0
    contents.font.bold = true
    draw_text(x+150,y+16*xparam_id,120,line_height,s3,2)
    #contents.font.color = Color.new(0,255,0)
    #contents.font.bold = true
    draw_text(250,y+16*xparam_id,100,line_height,s4,2)
    contents.font.bold = false
  end
end

class Scene_Point < Scene_MenuBase
  def create_help_window
    @help_window = Window_Point_Help.new()
    @help_window.viewport = @viewport
    @command_window.help_window = @help_window
  end
end

end
[/pre]



===============================================================================================================





[pre lang="ruby"]#encoding:utf-8
#===========================================================================
#          RMVA 豪华型技能加点|技能被动效果:        v1.05
#                       By希忆 66rpg.com
#                                                 转载或修改请保留此类信息
#===========================================================================
# 在游戏系统类的实现
#
# 完工了,大概
#===========================================================================
#角色类,新增一堆方法。
class Game_Actor < Game_Battler
  
  #初始化角色
  #@skill_level:存放技能等级数据的哈希表,技能id=>技能等级
  #@sp:剩余技能点
  alias setup_201410131453 setup
  def setup(actor_id)
    @skill_level=Hash.new(0)
    setup_201410131453(actor_id)
    @sp = (@level-1) * SkillLevel::LEVELUPSP + SkillLevel::INITIALSP
    auto_skill_levelup if self.class.auto_sp
  end
  
  #读取技能点的方法,如果是自动升级技能的职业,则没必要有技能点
  def sp
    return 0 if self.class.auto_sp
    @sp
  end
  
  #读取技能基础等级,
  #锁定技能等级优先度最高,
  #链接技能等级次之,这个我好像在计算技能最终等级的方法里面又来了一遍。
  #主要是技能基础等级是升级技能的窗口看到的等级,最终等级是使用技能的窗口。
  def skill_basic_level(skill_id)
    return 0 if skill_id == 0
    lock = $data_skills[skill_id].lock_level
    return lock if lock != 0
    lnk = $data_skills[skill_id].link_skill
    return skill_basic_level(lnk) if lnk != 0
    @skill_level[skill_id]
  end
  
  #获取装备增加技能的等级之和
  def skill_plus_level(skill_id)
    self.equips.compact.inject(0){|skl,eqp| skl+eqp.add_skill(skill_id)}
  end
  
  #读取技能最终等级,如果技能基础等级为零,则不加装备提升直接等于零。
  #最后返回基础等级+装备附加与技能最大等级中的小值
  def skill_level(skill_id)
    return 0 if skill_id == 0
    lock = $data_skills[skill_id].lock_level
    return lock if lock != 0
    lnk = $data_skills[skill_id].link_skill
    return skill_level(lnk) if lnk != 0
    return 0 unless @skills.include?(skill_id)
    return 0 if skill_basic_level(skill_id) == 0
    [skill_basic_level(skill_id) + skill_plus_level(skill_id) ,\
    $data_skills[skill_id].max_level].min
  end
  
  #升一级技能技能能升级就升级,返回成功,否则返回失败
  def level_up_skill(skill_id)
    skl = $data_skills[skill_id]
    if skill_can_levelup?(skl)
      @sp -= skl.sp_cost
      @skill_level[skill_id] += 1
      return true
    else
      return false
    end
  end
  
  #初始化角色时初始化技能的方法,
  #这里是不管默认的技能设定直接加载能学到的所有技能,也就是职业列表下的那些。
  def init_skills
    @skills = []
    self.class.learnings.each do |learning|
      @skills.push(learning.skill_id)
    end
    @skills.sort!
  end
  
  #主要用在技能列表的窗口里的。确保只有技能等级为1级及以上的技能才能显示。
  def has_skill?(skill)
    skills.include?(skill) && skill_basic_level(skill.id) > 0
  end
  
  #判断是否学习了技能,同样要确保只有技能等级为1级及以上的技能才能显示。
  #和上面的区别是上面的可以有装备附带,状态附带的技能等级不为0的技能
  #这里只能是职业列表下“领悟”的技能,装备状态附带的都不算
  def skill_learn?(skill)
    skill.is_a?(RPG::Skill) && @skills.include?(skill.id) && skill_basic_level(skill.id) > 0
  end
  
  #判断前置技能是否都满足
  def skill_former_match?(skill)
    skill.former.each do |former|
      return false unless skill_basic_level(former[0]) >= former[1]
    end
    true
  end
  
  #判断技能是否已经学到精通了、
  def skill_max_learn?(skill)
    skill_basic_level(skill.id) == skill.max_learn
  end
  
  #计算学习下一等级的技能所需要的人物等级
  #如果精通了return false【感觉好像有点奇葩。。。】
  def skill_next_level(skill)
    return false if skill_max_learn?(skill)
    skill.learn_level[0] + skill_basic_level(skill.id) * skill.learn_level[1]
  end
  
  #技能能否升级?首先看是否锁定,是否链接,是否精通,
  #再看等级是否符合学习下一级,sp是否足够,前置技能是否满足要求。
  def skill_can_levelup?(skill)
    return false if skill.lock_level != 0
    return false if skill.link_skill != 0
    return false if skill_max_learn?(skill)
    @level >= skill_next_level(skill) && @sp >= skill.sp_cost && skill_former_match?(skill)
  end
  
  #好像没什么用处。。。当初修改的用意是直接设置技能等级,后来觉得不好控制。。。
  #反正就放着吧,不去管它好了
  def learn_skill(skill_id,sk_level=0)
    unless skill_learn?($data_skills[skill_id])
      @skills.push(skill_id)
      @skills.sort!
      @skill_level[skill_id]=sk_level unless @skill_level.has_key?(skill_id)
    end
  end
  
  #自动升级技能。
  def auto_skill_levelup
    @skills.each do |skill|
      skl=$data_skills[skill]
      if self.class.auto_sp
        while skill_next_level(skl) && skill_next_level(skl) <= @level do
          @skill_level[skill] += 1
        end
      elsif skl.auto_levelup
        while level_up_skill(skill) do
        end
      end
    end
  end
  
  #升级时发生的事情,等级+1,sp增加,如果是自动升级技能的职业则自动升级技能
#  alias skill_system_levelup level_up
  def level_up
#    skill_system_levelup
    @level += 1
    @sp += SkillLevel::LEVELUPSP
    auto_skill_levelup
  end
  
  #被动技能提升的基础属性(加法叠加的部分)
  #SkillLevel.formula:带入公式计算。
  def skill_plus(param_id)
    skills.inject(0) do |plu,skl|
      plu + SkillLevel.formula(self.skill_level(skl.id),skl.param_add(param_id))
    end
  end
  
  #被动技能提升的基础属性倍率(乘法叠加)
  def skill_rate(param_id)
    skills.inject(1.00) do |plu,skl|
      plu * SkillLevel.formula(self.skill_level(skl.id),skl.param_rate(param_id))
    end
  end
  
  #被动技能影响的属性抗性(乘法叠加)
  def skill_element_rate(element_id)
    skills.inject(1.00) do |plu,skl|
      plu * SkillLevel.formula(self.skill_level(skl.id),skl.element_rate(element_id))
    end
  end
  
  #状态提升的基础属性(加法叠加的部分)
  def state_param_plus(param_id)
    states.inject(0) do |plu,sta|
      plu + SkillLevel.formula(@state_level[sta.id],sta.param_add(param_id))
    end
  end
  #状态提升的基础属性倍率(乘法叠加)
  def state_param_rate(param_id)
    states.inject(1.00) do |plu,sta|
      plu * SkillLevel.formula(@state_level[sta.id],sta.param_rate(param_id))
    end
  end
  #状态额外影响的属性抗性(乘法叠加)
  def state_element_rate(element_id)
    states.inject(1.00) do |plu,sta|
      plu * SkillLevel.formula(@state_level[sta.id],sta.element_rate(element_id))
    end
  end
  
  #基础属性的计算,添加了被动技能的提升,按默认的先加后乘
  def param(param_id)
    value = param_base(param_id) + param_plus(param_id) +
            skill_plus(param_id) + state_param_plus(param_id)
    value *= param_rate(param_id) * param_buff_rate(param_id) *
             skill_rate(param_id) * state_param_rate(param_id)
    [[value, param_max(param_id)].min, param_min(param_id)].max.to_i
  end
  
  #状态影响的附加属性xparam
  def state_xparam(xparam_id)
    states.inject(0.0) do |plu,sta|
      plu + SkillLevel.formula(@state_level[sta.id],sta.xparam(xparam_id))
    end
  end
  #附加属性xparam的计算,命中暴击什么的,迭代加算。
  def xparam(xparam_id)
    state_xparam(xparam_id) + @skills.inject(super(xparam_id)) do |plu,skl|
      plu + SkillLevel.formula(self.skill_level(skl),$data_skills[skl].xparam(xparam_id))
    end
  end
  
  #状态影响特殊属性sparam的计算
  def state_sparam(sparam_id)
    states.inject(1.0) do |plu,sta|
      plu * SkillLevel.formula(@state_level[sta.id],sta.sparam(sparam_id))
    end
  end
  #特殊属性sparam的计算,经验值比率什么的,迭代连乘计算。
  def sparam(sparam_id)
    state_sparam(sparam_id)*skills.inject(super(sparam_id)) do |plu,skl|
      plu * SkillLevel.formula(self.skill_level(skl.id),skl.sparam(sparam_id))
    end
  end
  
  #技能消耗mp由于技能等级修正的倍率,
  #反正就是到SkillLevel.formula找对应编号的公式。
  def skill_mp_rate(skill)
    SkillLevel.formula(skill_level(skill.id),skill.mp_type)
  end
  
  #计算最终技能消耗mp的量
  def skill_mp_cost(skill)
    (skill.mp_cost * mcr * skill_mp_rate(skill)).to_i
  end
  
  #计算暴击伤害倍率super:Game_Battler中的critical_rate,返回1.5
  #人物提升,职业提升,被动技能修正和装备提升
  def critical_rate
    v = super
    v *= (1.0 + self.actor.critical_rate/100.0)
    v *= (1.0 + self.class.critical_rate/100.0)
    v *= skills.inject(1.00) do |plu,skl|
      plu * SkillLevel.formula(self.skill_level(skl.id),skl.critical_rate)
    end
    v*equips.compact.inject(1.00){ |rat,equip| rat*(1.00+equip.critical_rate/100.0) }
  end
  
  #属性伤害修正。
  def element_rate(element_id)
    super(element_id) * skill_element_rate(element_id) * state_element_rate(element_id)
  end
  
  #被动技能影响的属性强化效果。
  def skill_element_damage(element_id)
    skills.inject(1.00) do |plu,skl|
      plu * SkillLevel.formula(self.skill_level(skl.id),skl.element_damage(element_id))
    end
  end
  
  def state_element_damage(element_id)
    states.inject(1.00) do |plu,sta|
      plu * SkillLevel.formula(@state_level[sta.id],sta.element_damage(element_id))
    end
  end
  
  #基础属性强化,角色备注和职业备注修正。
  def basic_element_damage(element_id)
    (1.0 + self.actor.element_damage(element_id)/100.0) *
    (1.0 + self.class.element_damage(element_id)/100.0)
  end
  
  #计算最终属性强化基础技能装备迭代连乘
  def element_damage(element_id)
    basic_element_damage(element_id) *
    equips.compact.inject(skill_element_damage(element_id)) do |rat,equip|
      rat*(1.00+equip.element_damage(element_id)/100.0)
    end
  end

  #受到hp伤害转移给mp的比例,遍历计算并返回最大值
  def damage_convert
    skl = skills.collect{|sk| sk = SkillLevel.formula(self.skill_level(sk.id),sk.damage_convert)}
    sta = states.collect{|st| st = SkillLevel.formula(@state_level[st.id],st.damage_convert)}
    (skl+sta).max
  end
  
  #洗技能了,
  alias item_apply_201411181846 item_apply
  def item_apply(user, item)
    item_apply_201411181846(user, item)
    if item.is_a?(RPG::Item) and item.id == SkillLevel::RESETITEM
      if self.reset_skill
        self.hp = [self.hp,self.mhp].min
        self.mp = [self.mp,self.mmp].min
      end
    end
  end
  
  #洗技能的方法
  def reset_skill
    return false if self.class.auto_sp
    @sp = (@level-1) * SkillLevel::LEVELUPSP + SkillLevel::INITIALSP
    @skills.each  { |skill| @skill_level[skill]=0 }
    return true
  end
  
end

#有关洗点水的使用判断,想和上面洗点放在一起。于是没有放进场景相关。
class Scene_ItemBase < Scene_MenuBase
  def item_usable?
    if item.id == SkillLevel::RESETITEM
      return false if item_target_actors[0].class.auto_sp
      return true
    end
    user.usable?(item) && item_effects_valid?
  end
end

class Game_Enemy
  #敌人属性强化
  def element_damage(id)
    1.0 + self.enemy.element_damage(id)/100.0
  end
  #敌人暴击倍率 super:Game_Battler定义的critical_rate,返回1.5
  def critical_rate
    super * (1+self.enemy.element_damage/100.0)
  end
  #敌人的技能等级,要么锁定,要么1
  def skill_level(skill_id)
    lock = $data_skills[skill_id].lock_level if $data_skills[skill_id]
    return lock if lock != 0
    return 1
  end
    #状态提升的基础属性(加法叠加的部分)
  def state_param_plus(param_id)
    states.inject(0) do |plu,sta|
      plu + SkillLevel.formula(@state_level[sta.id],sta.param_add(param_id))
    end
  end
  #状态提升的基础属性倍率(乘法叠加)
  def state_param_rate(param_id)
    states.inject(1.00) do |plu,sta|
      plu * SkillLevel.formula(@state_level[sta.id],sta.param_rate(param_id))
    end
  end
  #状态额外影响的属性抗性(乘法叠加)
  def state_element_rate(element_id)
    states.inject(1.00) do |plu,sta|
      plu * SkillLevel.formula(@state_level[sta.id],sta.element_rate(element_id))
    end
  end
  
  #基础属性的计算,添加了被动技能的提升,按默认的先加后乘
  def param(param_id)
    value = param_base(param_id) + param_plus(param_id) +
            state_param_plus(param_id)
    value *= param_rate(param_id) * param_buff_rate(param_id) *
             state_param_rate(param_id)
    [[value, param_max(param_id)].min, param_min(param_id)].max.to_i
  end
  
  #状态影响的附加属性xparam
  def state_xparam(xparam_id)
    states.inject(0.0) do |plu,sta|
      plu + SkillLevel.formula(@state_level[sta.id],sta.xparam(xparam_id))
    end
  end
  #附加属性xparam的计算,命中暴击什么的,迭代加算。
  def xparam(xparam_id)
    state_xparam(xparam_id) + super(xparam_id)
  end
  
  #状态影响特殊属性sparam的计算
  def state_sparam(sparam_id)
    states.inject(1.0) do |plu,sta|
      plu * SkillLevel.formula(@state_level[sta.id],sta.sparam(sparam_id))
    end
  end
  #特殊属性sparam的计算,经验值比率什么的,迭代连乘计算。
  def sparam(sparam_id)
    super(sparam_id)*state_sparam(sparam_id)
  end
  def state_element_damage(element_id)
    states.inject(1.00) do |plu,sta|
      plu * SkillLevel.formula(@state_level[sta.id],sta.element_damage(element_id))
    end
  end
  def element_rate(element_id)
    super(element_id) * state_element_rate(element_id)
  end
end



class Game_Battler < Game_BattlerBase
  
  #attr_reader :state_level
  #@state_level 保存状态等级的数组
  alias initialize_201410131453 initialize
  def initialize
    initialize_201410131453
    @state_level = Hash.new(0)
  end
  
  #属性修正的计算,将使用者属性强化也计算在内的
  def item_element_rate(user, item)
    if item.damage.element_id < 0
      user.atk_elements.empty? ? 1.0 : elements_max_rate(user)
    else
      element_rate(item.damage.element_id)*user.element_damage(item.damage.element_id)
    end
  end
  
  #将使用者属性强化也计算在内的最有效属性。
  def elements_max_rate(user)
    user.atk_elements.inject([0.0]) {|r, i| r.push(element_rate(i)*user.element_damage(i)) }.max
  end
  
  def damage_convert #受到hp伤害转移给mp的比例
    0
  end
  
  #计算伤害,SkillLevel.formula找公式算修正。
  def make_damage_value(user, item)
    value = item.damage.eval(user, self, $game_variables)
    if item.is_a?(RPG::Skill)
      value *= SkillLevel.formula(user.skill_level(item.id),item.damage_increase_type)
    end
   
    value *= item_element_rate(user, item)
    value *= pdr if item.physical?
    value *= mdr if item.magical?
    value *= rec if item.damage.recover?
    value = apply_critical(value,user) if @result.critical
    value = apply_variance(value, item.damage.variance)
    value = apply_guard(value)
   
    if value > 0 && damage_convert > 0
      valmp = [(value*damage_convert).to_i,self.mp].min
      self.mp -= valmp
      value -= valmp
    end
    @result.make_damage(value.to_i, item)
  end
  
  #计算暴击修正,添加了参数user
  def apply_critical(value,user)
    value * user.critical_rate
  end
  
  #基础暴击修正
  def critical_rate
    1.5
  end
  
  #状态附加,添加参数user,写的有点奇怪。如果有明确的user,
  #就提取技能等级user.skill_level($data_states[state_id].link_skill)
  #然后按SkillLevel.formula公式算得到附加概率,如果随机数比概率大(算是失败)
  #就直接返回,再下去按部就班如果没有状态就附加新状态,如果有明确的user,
  #状态的等级就等于之前提取的技能等级,否则为1。
  def add_state(state_id,user = nil)
    if state_addable?(state_id)
      if user != nil
        lv = user.skill_level($data_states[state_id].link_skill)
      else
        lv = 1
      end
      return if rand > SkillLevel.formula(lv,$data_states[state_id].chance)
      add_new_state(state_id) unless state?(state_id)
      if user != nil
        @state_level[state_id] = lv
      else
        @state_level[state_id] = 1
      end
      reset_state_counts(state_id)
      @result.added_states.push(state_id).uniq!
    end
  end
  
  def item_effect_add_state_attack(user, item, effect)
    user.atk_states.each do |state_id|
      chance = effect.value1
      chance *= state_rate(state_id)
      chance *= user.atk_states_rate(state_id)
      chance *= luk_effect_rate(user)
      if rand < chance
        add_state(state_id,user)
        @result.success = true
      end
    end
  end

  def item_effect_add_state_normal(user, item, effect)
    chance = effect.value1
    chance *= state_rate(effect.data_id) if opposite?(user)
    chance *= luk_effect_rate(user)      if opposite?(user)
    if rand < chance
      add_state(effect.data_id,user)
      @result.success = true
    end
  end
  
end
[/pre]


就是升级没有人物加点的加点数,只有技能升级的技能点,搞了很久,找不到解决的办法,望高手帮我解决一下
梦石
0
星屑
62
在线时间
839 小时
注册时间
2010-6-26
回帖
652
发表于 2015-6-6 19:28:03 | 显示全部楼层
看了一眼,试过上下调换顺序么

点评

不行的,会导致其他冲突  发表于 2015-6-10 11:47

评分

参与人数 1星屑 +132 收起 理由
VIPArcher + 132 我很赞同

查看全部评分

新手们!不要被看扁了!我们也会用论坛搜索,我们也会自己找脚本,我们也会自己点击关闭按钮旁边的小问号!
回复

使用道具 举报

梦石
0
星屑
1881
在线时间
414 小时
注册时间
2012-7-30
回帖
68
发表于 2015-6-6 20:14:19 | 显示全部楼层
在游戏系统类的153行level_up函数里加上$game_variables[self.id*(POINT_KIND+1) + POINT_VARIABLE] += LEVEL_UP_POINT

点评

请问具体是怎么添加的,我试了一下,就报错了。是直接把@level += 1中的1去掉,然后复制。还是直接复制在后面了?  发表于 2015-7-3 20:37
回复

使用道具 举报

梦石
0
星屑
1187
在线时间
12 小时
注册时间
2015-7-22
回帖
4
发表于 2015-7-29 11:20:44 | 显示全部楼层
用那个非变量版然后把加属性点的放在下面
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部