赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 4 |
经验 | 0 |
最后登录 | 2023-7-20 |
在线时间 | 36 小时 |
Lv2.观梦者
- 梦石
- 0
- 星屑
- 382
- 在线时间
- 36 小时
- 注册时间
- 2018-4-14
- 帖子
- 51
|
事先申明,此脚本不是由我写的。作者为:66RPG的tan12345
不要将所有脚本放在一块
==============================以下是脚本==============================
=begin
# 宠物系统-无限生成宠物
# 作者:66RPG的tan12345
# 使用方法:
# 1.正常入队(指定ID:actor_id):
# $game_party.tan_add_actor(actor_id)
# 2.正常入队(初始化人物,建议少用)(指定ID:actor_id):
# $game_party.tan_add_actor(actor_id,false,true)
# 3.副本入队(将ID为actor_id的人物以副本的形式加入队伍,强制初始化):
# $game_party.tan_add_actor(actor_id,true)
# 4.正常离队(指定ID:actor_id):
# $game_party.tan_remove_actor(actor_id)
# 5.离队后删除副本(指定ID:actor_id,
# 该方法会将指定ID的人物清除掉,如果不能确定宠物是否副本生成的,请慎用):
# $game_party.tan_remove_actor(actor_id,true)
=end
class Game_Party < Game_Unit
#--------------------------------------------------------------------------
# ● 寻找空位
#--------------------------------------------------------------------------
def get_nil_actorid
for i in 1..$data_actors.size
return i if $data_actors == nil
end
end
#--------------------------------------------------------------------------
# ● 无限生成专用的队员管理-入队
# a参数代表加入队伍的是否模版
# b参数代表是否需要初始化
# a为true时(加入的是模版)b也必须为true(初始化)
#--------------------------------------------------------------------------
def tan_add_actor(actor_id,a = false,b = false)
if a#加入的是模板
new_actor_id = get_nil_actorid
$data_actors[new_actor_id] = $data_actors[actor_id]
$game_actors[new_actor_id].setup(new_actor_id)
add_actor(new_actor_id)
else#正常加入
$game_actors[actor_id].setup(actor_id) if b
add_actor(actor_id)
end
end
#--------------------------------------------------------------------------
# ● 无限生成专用的队员管理-离队
# a参数代表是否需要清空离队人物(宠物)的数据
#--------------------------------------------------------------------------
def tan_remove_actor(actor_id,a = false)
if a#清除数据
remove_actor(actor_id)
$data_actors[actor_id] = nil
else#普通离队
remove_actor(actor_id)
end
end
end
#--------------------------------------------------------------------------
# ● 重写存档读档,保证新生成的数据存在。
#--------------------------------------------------------------------------
module DataManager
#--------------------------------------------------------------------------
# ● 生成存档内容
#--------------------------------------------------------------------------
def self.make_save_contents
contents = {}
contents[:system] = $game_system
contents[:timer] = $game_timer
contents[:message] = $game_message
contents[:switches] = $game_switches
contents[:variables] = $game_variables
contents[:self_switches] = $game_self_switches
contents[:actors] = $game_actors
contents[:party] = $game_party
contents[:troop] = $game_troop
contents[:map] = $game_map
contents[:player] = $game_player
contents[:weapons] = $data_weapons
contents[:armors] = $data_armors
###########################################
contents[:pactors] = $data_actors
###########################################
contents
end
#--------------------------------------------------------------------------
# ● 展开存档内容
#--------------------------------------------------------------------------
def self.extract_save_contents(contents)
$game_system = contents[:system]
$game_timer = contents[:timer]
$game_message = contents[:message]
$game_switches = contents[:switches]
$game_variables = contents[:variables]
$game_self_switches = contents[:self_switches]
$game_actors = contents[:actors]
$game_party = contents[:party]
$game_troop = contents[:troop]
$game_map = contents[:map]
$game_player = contents[:player]
$data_weapons = contents[:weapons]
$data_armors = contents[:armors]
###########################################
$data_actors = contents[:pactors]
###########################################
end
end
第一个脚本 宠物无限生成
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
#--------------------------------------------------------------------------
# ● 获取普通能力的基础值(宠物会有随机成长值的波动)
# 人物的普通能力的基础值方法不变,宠物则=数据库设定+随机成长值
#--------------------------------------------------------------------------
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
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
# 功能:随机生成宠物(也就是数据库里的人物)的成长值、初始技能、升级技能
# # 使用方法:在数据库-人物-备注栏里填写<pet = i>代表宠物,i为宠物只能装备饰品装备(如果不需要,请删除equip_slots方法,在宠物系统的90-94行)
## 在下面的Tan_pet_set里设定宠物的成长与升级
宠物id
时学会的技能
# 建议:
# 宠物所对应的职业,建议成长曲线为平线
# (即数据库-职业-宠物职业-8个属性的成长不要在数据库设定,这样取成长值也方便)
# 注意:
# 1.技能随机算法修改了菜鸟飞啊飞的多项比例选一的脚本,
# 原地址:http://bbs.66rpg.com/thread-224387-1-1.html
# 2.如果宠物只能装备饰品装备,
# 那么数据库设定里人物可以有初始化装备,宠物不可以初始化装备,否则报错。
# 3.请保证一个宠物id对应一个角色,如果出现多个角色对应1个宠物id的情况,数据会混乱(主要是图鉴混乱)。
=end
module Tan_pet_set
#变异几率
Tan_pet_by = 0
#变异的宠物比一般宠物成长属性的倍数
Tan_pet_by_num = 1
#代表宠物每3级就学会一次技能(领悟技能的成功率在Tan_pet_rand_skills定义)
Tan_pet_skill=10
#宠物升级到30级后就不会再领悟技能
Tan_skillmax = 80
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] = [10, 10, 5.5, 5.5, 5.5, 5.5, 5.5, 5.0]
#id号宠物的成长浮动值 HP, MP, atk, def, mat, mdf, agi, luk
Tan_pet_rand_param[1] = [0, 0, 0, 0, 0, 0, 0, 0]
#id号宠物升级时一定几率学会的技能,格式:[技能id,权重]
Tan_pet_rand_skills[1] = [[160,100],[161,100],[162,100],[163,100]]
end
第三个 宠物数据设定
介绍[由我自己写的]
在数据库角色备注里输入<pet = 1>
1代表ID
在脚本内输入
$game_party.tan_add_actor(1,true)让ID为1角色加入队伍
脚本在编辑事件的第3页
1为宠物ID
其它设置基本上都可以改。 |
|