| 赞 | 3  | 
 
| VIP | 0 | 
 
| 好人卡 | 0 | 
 
| 积分 | 22 | 
 
| 经验 | 46374 | 
 
| 最后登录 | 2025-7-3 | 
 
| 在线时间 | 1015 小时 | 
 
 
 
 
 
Lv3.寻梦者 
	- 梦石
 - 0 
 
        - 星屑
 - 2245 
 
        - 在线时间
 - 1015 小时
 
        - 注册时间
 - 2015-10-17
 
        - 帖子
 - 1288
 
 
 
 | 
	
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员  
 
x
 
 本帖最后由 fjm 于 2025-4-8 15:21 编辑  
 
问下如何增加变异的种类,例如初级变异增加10%的能力,中级变异增加20%,高级变异增加30% 
初级变异出现几率10%,中级5%,高级1% 
 
 
 
class Game_Actor < Game_Battler 
  attr_accessor :tan_pet_id       #宠物ID,为0则代表人物,否则为宠物 
  attr_accessor :tan_pet_by       #变异标志 
  attr_accessor :tan_pet_param    #宠物随机成长属性数组 
   
  #-------------------------------------------------------------------------- 
  # ● 宠物初始化 
  #-------------------------------------------------------------------------- 
  def init_pet 
    @tan_pet_id = self.actor.note =~ /<pet = (\d+?)>/i ? $1.to_i : 0 
    @tan_pet_by = false 
    @tan_pet_by = true if rand(100) <= Tan_pet_set::Tan_pet_by 
    @nickname = "" if is_pet? 
    @nickname = "初级变异" if is_pet_by? 
    init_pet_param 
    self.hp = self.mhp 
    self.mp = self.mmp 
  end 
  #-------------------------------------------------------------------------- 
  # ● 是否宠物对象 
  #-------------------------------------------------------------------------- 
  def is_pet? 
    return false if @tan_pet_id == 0 or @tan_pet_id == nil 
    return true 
  end 
  #-------------------------------------------------------------------------- 
  # ● 是否变异 
  #-------------------------------------------------------------------------- 
  def is_pet_by? 
    return true if is_pet? && @tan_pet_by 
    return false 
  end 
  #-------------------------------------------------------------------------- 
  # ● 设置变异 
  #-------------------------------------------------------------------------- 
  def set_pet_by(b) 
    @tan_pet_by = b 
  end 
  #-------------------------------------------------------------------------- 
  # ● 宠物成长属性初始化 
  #-------------------------------------------------------------------------- 
  def init_pet_param 
    @tan_pet_param = [0] * 8 
    if @tan_pet_id != 0 
      for i in 0..7 
        a = Tan_pet_set::Tan_pet_base_param[@tan_pet_id] 
        b = Tan_pet_set::Tan_pet_rand_param[@tan_pet_id] * rand() 
        v = format("%.2f",a + b).to_f 
        v = format("%.2f",v * Tan_pet_set::Tan_pet_by_num).to_f if is_pet_by? 
        @tan_pet_param = v 
      end 
    end 
  end 
  #-------------------------------------------------------------------------- 
  # ● 获取宠物成长率(指定属性) 
  #-------------------------------------------------------------------------- 
  def get_pet_oneup_param(index) 
    @tan_pet_param[index] 
  end 
  #-------------------------------------------------------------------------- 
  # ● 获取宠物成长区间(指定属性) 
  #-------------------------------------------------------------------------- 
  def get_pet_param_lvup_num(index,bb) 
    a = format("%.2f",Tan_pet_set::Tan_pet_base_param[@tan_pet_id][index]).to_f 
    b = format("%.2f",Tan_pet_set::Tan_pet_rand_param[@tan_pet_id][index]).to_f 
    ra = format("%.2f",a * Tan_pet_set::Tan_pet_by_num).to_f 
    rb = format("%.2f",(a + b) * Tan_pet_set::Tan_pet_by_num).to_f 
    if !bb 
      return a.to_s + "~" + (a + b).to_s 
    else 
      return ra.to_s + "~" + rb.to_s 
    end 
  end 
  #-------------------------------------------------------------------------- 
  # ● 获取宠物成长率(全部属性) 
  #-------------------------------------------------------------------------- 
  def get_pet_allup_param 
    @tan_pet_param 
  end 
  #-------------------------------------------------------------------------- 
  # ● 设定宠物成长率 
  #-------------------------------------------------------------------------- 
  def set_pet_up_param(newuppar)# = [0] * 8) 
    return if newuppar == nil or newuppar.size != 8 
    @tan_pet_param.size.times {|i| @tan_pet_param = newuppar} 
    self.hp = self.mhp 
    self.mp = self.mmp 
  end 
  #-------------------------------------------------------------------------- 
  # ● 获取宠物ID(@tan_pet_id) 
  #-------------------------------------------------------------------------- 
  def get_pet_id 
    @tan_pet_id 
  end 
  #-------------------------------------------------------------------------- 
  # ● 宠物技能算法,宠物升级时一定几率学会设定里的技能 
  #-------------------------------------------------------------------------- 
  def co(pid) 
    arr = [];mii = [];n=[];f=[] 
    for ti in 0...Tan_pet_set::Tan_pet_rand_skills[pid].size 
      n.push Tan_pet_set::Tan_pet_rand_skills[pid][ti][0] 
      f.push Tan_pet_set::Tan_pet_rand_skills[pid][ti][1] 
    end 
    r = rand f.max;b = f.max 
    f.each {|v| if v >= r;arr.push v;else;arr.push nil;end} 
    unless arr.compact.empty? 
      arr.each {|a| 
      if a;mii.push a - rand(a) - r 
      else;mii.push b;end} 
      x = mii.index mii.min 
    else 
      x = f.index f.max 
    end 
    return n[x] 
  end 
   
  #以下是方法重写# 
   
  #-------------------------------------------------------------------------- 
  # ● 设置(人物、宠物初始化) 
  #-------------------------------------------------------------------------- 
  alias tan_pet_setup setup 
  def setup(actor_id) 
    tan_pet_setup(actor_id) 
    init_pet 
    #@name = @name + actor_id.to_s if is_pet?#宠物名字后加ID方便区分 
    init_skills 
  end 
  #-------------------------------------------------------------------------- 
  # ● 获取装备栏的数组(宠物只能装备饰品,可改)0代表武器1盾牌2头盔3铠甲4饰品 
  #-------------------------------------------------------------------------- 
  #alias tan_pet_equip_slots equip_slots 
  #def equip_slots 
    #return [4] if is_pet? 
    #tan_pet_equip_slots  
  #end 
  #-------------------------------------------------------------------------- 
  # ● 获取普通能力的基础值(宠物会有随机成长值的波动) 
  # 人物的普通能力的基础值方法不变,宠物则=数据库设定+随机成长值 
  #-------------------------------------------------------------------------- 
  alias tan_pet_param_base param_base 
  def param_base(param_id) 
    v = tan_pet_param_base(param_id) 
    v = v + @tan_pet_param[param_id] * @level if is_pet? 
    return v.to_i 
  end 
  #-------------------------------------------------------------------------- 
  # ● 重写初始化技能方法 
  # 人物的技能初始化不变,宠物则为技能栏里随机选择一个作为天赋,其他技能作废 
  #-------------------------------------------------------------------------- 
  alias tan_pet_init_skills init_skills 
  def init_skills 
    if is_pet? 
      @skills = [] 
      tf_skill = self.class.learnings 
      tf_skills = tf_skill.size 
      learn_skill(tf_skill[rand(tf_skills)].skill_id) if tf_skills > 0 
      learn_skill(tf_skill[rand(tf_skills)].skill_id) if tf_skills > 0 
      learn_skill(tf_skill[rand(tf_skills)].skill_id) if tf_skills > 0 
      learn_skill(tf_skill[rand(tf_skills)].skill_id) if tf_skills > 0 
      learn_skill(tf_skill[rand(tf_skills)].skill_id) if tf_skills > 0 
      learn_skill(tf_skill[rand(tf_skills)].skill_id) if tf_skills > 0 
      learn_skill(tf_skill[rand(tf_skills)].skill_id) if tf_skills > 0 
      learn_skill(tf_skill[rand(tf_skills)].skill_id) if tf_skills > 0 
  else 
      tan_pet_init_skills 
    end 
  end 
  #-------------------------------------------------------------------------- 
  # ● 重写升级方法 
  # 人物升级不变,宠物升级学会技能则从设定的数组里随机取一个技能 
  #-------------------------------------------------------------------------- 
 # alias tan_pet_level_up level_up 
 # def level_up 
   # if is_pet? 
     # @level += 1 
      #if @level % Tan_pet_set::Tan_pet_skill == 0 && @level <= Tan_pet_set::Tan_skillmax 
       # learn_skill(co(@tan_pet_id)) if Tan_pet_set::Tan_pet_rand_skills[@tan_pet_id].size > 0 
      #end 
   # else 
     # tan_pet_level_up 
    #end 
    #self.hp = self.mhp 
   # self.mp = self.mmp 
  #end 
end 
    
 
 
 
=begin 
# 宠物系统,作者:66RPG的tan12345 
# 功能:随机生成宠物(也就是数据库里的人物)的成长值、初始技能、升级技能 
# 宠物只能装备饰品装备(如果不需要,请删除equip_slots方法,在宠物系统的90-94行) 
#  
# 使用方法:在数据库-人物-备注栏里填写<pet = i>代表宠物,i为宠物id 
# 在下面的Tan_pet_set里设定宠物的成长与升级时学会的技能 
# 建议: 
# 宠物所对应的职业,建议成长曲线为平线 
# (即数据库-职业-宠物职业-8个属性的成长不要在数据库设定,这样取成长值也方便) 
# 注意: 
# 1.技能随机算法修改了菜鸟飞啊飞的多项比例选一的脚本, 
#   原地址:http://bbs.66rpg.com/thread-224387-1-1.html 
# 2.如果宠物只能装备饰品装备, 
#   那么数据库设定里人物可以有初始化装备,宠物不可以初始化装备,否则报错。 
# 3.请保证一个宠物id对应一个角色,如果出现多个角色对应1个宠物id的情况,数据会混乱(主要是图鉴混乱)。 
=end 
module Tan_pet_set 
   
  #变异几率 
  Tan_pet_by = 10 
  #变异的宠物比一般宠物成长属性的倍数 
  Tan_pet_by_num = 1.1 
  #代表宠物每3级就学会一次技能(领悟技能的成功率在Tan_pet_rand_skills定义) 
  Tan_pet_skill=3 
  #宠物升级到30级后就不会再领悟技能 
  Tan_skillmax = 99  
   
  Tan_pet_base_param = [] 
  Tan_pet_rand_param = [] 
  Tan_pet_rand_skills = [] 
   
  #id号宠物的基础成长值     HP, MP, atk, def, mat, mdf, agi, luk 
  Tan_pet_base_param[1] = [20, 1, 0.5,  0.5,  0.5,  0.5,  0.8,  0.8] 
  #id号宠物的成长浮动值     HP, MP, atk, def, mat, mdf, agi, luk 
  Tan_pet_rand_param[1] = [20, 1, 0.5,  0.5,  0.5,  0.5,  0.8,  0.8] 
  #id号宠物升级时一定几率学会的技能,格式:[技能id,权重] 
  Tan_pet_rand_skills[1] = [] 
   
  Tan_pet_base_param[2] = [120, 1.1, 5,  5,  5,  5,  5,  5] 
  Tan_pet_rand_param[2] = [0, 0, 0,  0,  0,  0,  0,  0] 
  Tan_pet_rand_skills[2] = [] 
   
  Tan_pet_base_param[3] = [120, 1.1, 5,  5,  5,  5,  5,  5] 
  Tan_pet_rand_param[3] = [0, 0, 0,  0,  0,  0,  0,  0] 
  Tan_pet_rand_skills[3] = [] 
   
  Tan_pet_base_param[4] = [120, 1.1, 5,  5,  5,  5,  5,  5] 
  Tan_pet_rand_param[4] = [0, 0, 0,  0,  0,  0,  0,  0] 
  Tan_pet_rand_skills[4] = [] 
   
  Tan_pet_base_param[5] = [0, 0, 0,  0,  0,  0,  0,  0] 
  Tan_pet_rand_param[5] = [0, 0, 0,  0,  0,  0,  0,  0] 
  Tan_pet_rand_skills[5] = [] 
   
  Tan_pet_base_param[6] = [0, 0, 0,  0,  0,  0,  0,  0] 
  Tan_pet_rand_param[6] = [0, 0, 0,  0,  0,  0,  0,  0] 
  Tan_pet_rand_skills[6] = [] 
   
  Tan_pet_base_param[7] = [0, 0, 0,  0,  0,  0,  0,  0] 
  Tan_pet_rand_param[7] = [0, 0, 0,  0,  0,  0,  0,  0] 
  Tan_pet_rand_skills[7] = [] 
   
  Tan_pet_base_param[8] = [0, 0, 0,  0,  0,  0,  0,  0] 
  Tan_pet_rand_param[8] = [0, 0, 0,  0,  0,  0,  0,  0] 
  Tan_pet_rand_skills[8] = [] 
   
  Tan_pet_base_param[9] = [0, 0, 0,  0,  0,  0,  0,  0] 
  Tan_pet_rand_param[9] = [0, 0, 0,  0,  0,  0,  0,  0] 
  Tan_pet_rand_skills[9] = [] 
   
  Tan_pet_base_param[10] = [0, 0, 0,  0,  0,  0,  0,  0] 
  Tan_pet_rand_param[10] = [0, 0, 0,  0,  0,  0,  0,  0] 
  Tan_pet_rand_skills[10] = [] 
   
  Tan_pet_base_param[11] = [0, 0, 0,  0,  0,  0,  0,  0] 
  Tan_pet_rand_param[11] = [0, 0, 0,  0,  0,  0,  0,  0] 
  Tan_pet_rand_skills[11] = [] 
   
  Tan_pet_base_param[12] = [0, 0, 0,  0,  0,  0,  0,  0] 
  Tan_pet_rand_param[12] = [0, 0, 0,  0,  0,  0,  0,  0] 
  Tan_pet_rand_skills[12] = [] 
   
  Tan_pet_base_param[13] = [0, 0, 0,  0,  0,  0,  0,  0] 
  Tan_pet_rand_param[13] = [0, 0, 0,  0,  0,  0,  0,  0] 
  Tan_pet_rand_skills[13] = [] 
   
  Tan_pet_base_param[14] = [0, 0, 0,  0,  0,  0,  0,  0] 
  Tan_pet_rand_param[14] = [0, 0, 0,  0,  0,  0,  0,  0] 
  Tan_pet_rand_skills[14] = [] 
   
  Tan_pet_base_param[15] = [0, 0, 0,  0,  0,  0,  0,  0] 
  Tan_pet_rand_param[15] = [0, 0, 0,  0,  0,  0,  0,  0] 
  Tan_pet_rand_skills[15] = [] 
   
   Tan_pet_base_param[16] = [30, 1.1, 1,  1,  1,  1,  1,  1] 
  Tan_pet_rand_param[16] =  [30, 1.1, 1,  1,  1,  1,  1,  1] 
  Tan_pet_rand_skills[16] = [] 
   
  Tan_pet_base_param[17] = [30, 1.1, 1,  1,  1,  1,  1,  1] 
  Tan_pet_rand_param[17] = [30, 1.1, 1,  1,  1,  1,  1,  1] 
  Tan_pet_rand_skills[17] = [] 
   
  Tan_pet_base_param[18] = [30, 1.1, 1,  1,  1,  1,  1,  1] 
  Tan_pet_rand_param[18] = [30, 1.1, 1,  1,  1,  1,  1,  1] 
  Tan_pet_rand_skills[18] = [] 
   
  Tan_pet_base_param[19] = [30, 1.1, 2.5,  2,  1,  1.5,  2,  2] 
  Tan_pet_rand_param[19] = [30, 1.1, 2.5,  2,  1,  1.5,  2,  2] 
  Tan_pet_rand_skills[19] = [] 
   
end 
 
 
 
 
 
 |   
 
 
 
 |