赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 0 |
经验 | 5367 |
最后登录 | 2022-1-21 |
在线时间 | 80 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 40
- 在线时间
- 80 小时
- 注册时间
- 2014-11-3
- 帖子
- 71
|
3楼
楼主 |
发表于 2016-1-3 11:49:35
|
只看该作者
15968715431 发表于 2016-1-3 09:21
亲。请检查设置。宠物系统里是需要设置的。多少个角色就要设置多少个。不然会出错的。~~~ 或者其它的没设置 ...
可是我看不出来哪里有问题啊?麻烦大神帮我看一下……感激不尽- #———————————————————————————————————————
- # ●PMSYS By.Clov
- # *口袋怪兽系列系统
- # Ver:1.0 Date:2011.5.29
- # Ver:1.1 Date:2013.8.19
- # *备注
- # -“角色ID”为数据库中的角色ID
- # -“宠物ID”为宠物系统的独立ID
- #———————————————————————————————————————
- module PMSYS
- #指定宠物ID不被系统自动占用
- PID = [20,21]
- #指定角色ID性别概率(最大100%,母性为准)
- XB = {3=>20}
- #所有能力值成长率基数{基数=>概率} 概率设定最大100
- C1 = {0.2=>5, 0.1=>10, 0.075=>20, 0.05=>30, 0.025=>35}
- #单独能力值成长率倍数{倍数=>概率} 概率设定最大200
- C2 = {5=>5, 4=>10, 3=>15, 2=>20, 1=>25,
- 0=>50,
- -5=>5, -4=>10, -3=>15, -2=>20, -1=>25}
- #———————————————————————————————————————
- # ●PMSC
- # *宠物生成
- # Ver:1.0 Date:2013.8.19
- # *兼容性
- # 关系:PMSC > (Actors = Actor = Party)
- # -宠物数据库 > (生成内容 = 生成内容 = 生成内容)
- # 逻辑:PMSC >> Actors >> Actor >> Party
- # -生成宠物数据>>宠物包装外壳>>应用宠物数据>>添加数据到队列
- #———————————————————————————————————————
- class PMSC
- #—————————————————————————————————————
- #●初始化
- attr_accessor :data #数据表单
- attr_accessor :id #编号管理器
- def initialize
- #操作数据(0号宠物为nil)
- @data = {:actor=>[nil], :class=>[nil], #宠物角色、职业数据
- :pmc1=>[nil], :pmc2=>[nil], #宠物成长率基数、倍数
- :pmxb=>[nil]} #宠物性别
- #编号初始化(索引:宠物ID(@pid) 单元:角色ID(@aid))
- @id = [0]; @aid = 0; @pid = 0
- #指定编号(0表示指定位置)
- PMSYS::PID.each {|i| @id[i] = 0}
- #自定义成长率
- @dc1 = @dc2 = nil
- end
- #●生成编号
- def new_pid
- #需找空位ID(nil表示为空位置)
- @id.include?(nil) ? @id.index(nil) : @id.size
- end
- #—————————————————————————————————————
- #●读取数据
- def [](type)
- @data[type]
- end
- #●删除数据
- def data_del(id)
- @id[id] = nil
- @data[:actor].delete(id)
- @data[:class].delete(id)
- @data[:pmc1].delete(id)
- @data[:pmc2].delete(id)
- @data[:pmxb].delete(id)
- end
- #●查看指定数据是否存在(:actor为标准)
- def data?(id)
- @data[:actor][id]
- end
- #—————————————————————————————————————
- #●准备数据
- def pm_data(aid, pid)
- #取得角色ID
- @aid = aid
- #取得宠物ID
- @pid = pid
- #更新编号管理器
- @id[@pid] = @aid
- #记录成长率基数
- @c1 = nil
- #记录成长率倍数
- @c2 = []
- #宠物性别
- @xb = nil
- #角色副本
- @pm_actor = data_actor.dup
- #职业副本
- @pm_class = data_class.dup
- end
- #—————————————————————————————————————
- #●宠物角色数据接口
- def data_actor
- $data_actors[@aid]
- end
- #●宠物职业数据接口
- def data_class
- $data_classes[@aid]
- end
- #—————————————————————————————————————
- #●宠物角色副本操作
- def pm_actor
- @pm_actor
- end
- #●宠物职业副本操作
- def pm_class
- @pm_class
- end
- #—————————————————————————————————————
- #●自定义基数数据
- def pm_c1(c1, x=10, y=10)
- @dc1 = c1 ? [c1, x, y] : nil
- end
- #●自定义倍数数据
- def pm_c2(c2, x=10, y=20)
- @dc2 = c2 ? [c2, x, y] : nil
- end
- #—————————————————————————————————————
- #●取得所有能力值成长率基数 概率设定最大100
- def rc1
- #自定义数据为nil时使用默认数据
- c1 = @dc1 ? @dc1 : [PMSYS::C1, 10, 10]
- Ratios.Mo(*c1)[0]
- end
- #●取得每项能力值成长率倍数 概率设定最大200
- def rc2
- #自定义数据为nil时使用默认数据
- c2 = @dc2 ? @dc2 : [PMSYS::C2, 10, 20]
- Ratios.Mo(*c2)[0]
- end
- #—————————————————————————————————————
- #●生成宠物能力值
- def ini_params
- #取得能力值二维数组副本
- @params = @pm_class.params.dup
- #记录所有属性
- @x = []
- end
- #—————————————————————————————————————
- #●方法1:按概率生成
- #属性:rc1*rc2=@x[i]
- def pm_params1
- #初始化
- ini_params
- #取得基数
- c1 = rc1
- for i in 0..7
- c2 = rc2 #取得倍数
- @x[i] = 1+c1*c2 #更新属性
- @c2.push c2 #纪录倍数
- end
- #纪录基数
- @c1 = c1
- #生成完毕
- end_params
- end
- #●方法2:自定义生成
- #属性:dc1*dc2[i]=@x[i]
- def pm_params2(dc1=0,dc2=[0,0,0,0,0,0,0,0])
- #初始化
- ini_params
- #取得基数
- c1 = dc1
- for i in 0..7
- c2 = dc2[i] #取得倍数
- @x[i] = 1+c1*c2 #更新属性
- @c2.push c2 #纪录倍数
- end
- #纪录基数
- @c1 = c1
- #生成完毕
- end_params
- end
- #—————————————————————————————————————
- #●进行生成>应用到数据>结束
- def end_params
- for lv in 1..99
- for par in 0..7
- @params[par,lv] = [@params[par,lv] * @x[par], 9999].min
- end
- end
- #更新能力值
- @pm_class.params = @params
- #更新职业(新能力值的职业ID)
- @pm_actor.class_id = @pid
- end
- #—————————————————————————————————————
- #●生成宠物性别
- def pm_xb
- i = 0
- x = ["雌性", "雄性"]
- l = PMSYS::XB[@aid]
- unless l ; i = rand(x.size)
- else ; i = rand(100) < l ? 0 : 1
- end
- @xb = x[i]
- end
- #—————————————————————————————————————
- #●数据表单更新
- def pm_update
- #宠物角色数据
- @data[:actor][@pid] = @pm_actor
- #宠物职业数据
- @data[:class][@pid] = @pm_class
- #宠物成长率基数
- @data[:pmc1][@pid] = @c1
- #宠物成长率倍数
- @data[:pmc2][@pid] = @c2
- #宠物性别
- @data[:pmxb][@pid] = @xb
- #传递新的宠物ID到角色包装外壳
- $game_actors.pmsc_id = @pid
- end
- #—————————————————————————————————————
- #●确认加入队列
- def pm_add
- #加入队列
- $game_party.add_actor(@pid)
- end
- #—————————————————————————————————————
- #★逻辑集
- #●随机数据生成
- def ios_data(aid, pid = 0)
- #使用指定编号还是生成编号
- pid = pid > 0 ? pid : new_pid
- #·1·准备数据(数据库中ID号角色、职业)
- pm_data(aid, pid)
- #·2·操作数据(能力值生成)
- pm_params1
- #·2·操作数据(性别生成)
- pm_xb
- #·3·更新数据(应用操作完毕的数据)
- pm_update
- end
- #●自定义数据生成
- def def_data(aid, pid = 0, dc1=0, dc2=[0,0,0,0,0,0,0,0])
- #使用指定编号还是生成编号
- pid = pid > 0 ? pid : new_pid
- #·1·准备数据(数据库中ID号角色、职业)
- pm_data(aid, pid)
- #·2·操作数据(能力值生成)
- pm_params2(dc1,dc2)
- #·2·操作数据(性别生成)
- pm_xb
- #·3·更新数据(应用操作完毕的数据)
- pm_update
- end
- #●随机生成后加入队列
- def ios_actor(aid, pid = 0)
- #·1·随机生成数据
- ios_data(aid, pid)
- #·2·加入队列
- pm_add
- end
- #●自定义生成后加入队列
- def def_actor(aid, pid = 0, dc1=0, dc2=[0,0,0,0,0,0,0,0])
- #·1·自定生成数据
- def_data(aid, pid, dc1, dc2)
- #·2·加入队列
- pm_add
- end
- end
- end
- #———————————————————————————————————————
- # ●多项概率选一(Ratios) By.Clov
- #———————————————————————————————————————
- module Ratios
- #——————————————————————————————————————
- #●使用:Ratios.Mo({数据=>概率},模拟器X,模拟器Y)
- #——————————————————————————————————————
- def self.Mo(data = {}, x = 10, y = 10)
- k = data.keys #数据
- v = data.values #数据概率
- i = 0 #放置位置ID
- e = 0 #放置种类ID
- t = Table.new(x, y) #模拟器
- x.times {|xi| #运行模拟器x轴
- y.times {|yi| #运行模拟器y轴
- t[xi,yi] = e #放置当前种类
- i += 1 #位置ID前进
- (e += 1 ; i = 0) if (i >= v[e]) #种类ID更换
- }
- }
- r1 = rand(x) #抓取x位置
- r2 = rand(y) #抓取y位置
- c = t[r1,r2] #抓取模拟器
- return [k[c],v[c]] #返回抓取的数据及其概率
- end
- #——————————————————————————————————————
- #●使用 Ratios.Co({数据=>概率},分比数)
- #——————————————————————————————————————
- def self.Co(data = {}, b = 100)
- r = rand b;n = data.keys;f = data.values;arr = [];mii = []
- 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],f[x]]
- end
- end
- #———————————————————————————————————————
- # ●新的浮点数(Numeric) By.Clov
- #———————————————————————————————————————
- class Numeric
- #——————————————————————————————————————
- #●使用:self.toif(float)
- #取整重算,返回新的self浮点数( f 为浮点数)
- #——————————————————————————————————————
- def toif(f)
- (self * f).round / f
- end
- end
复制代码- #==============================================================================
- # ■ DataManager
- #==============================================================================
- module DataManager
- #--------------------------------------------------------------------------
- # ★ 生成各种游戏对象
- #--------------------------------------------------------------------------
- def self.create_game_objects
- $game_temp = Game_Temp.new
- $game_system = Game_System.new
- $game_timer = Game_Timer.new
- $game_message = Game_Message.new
- $game_switches = Game_Switches.new
- $game_variables = Game_Variables.new
- $game_self_switches = Game_SelfSwitches.new
- $game_actors = Game_Actors.new
- $game_party = Game_Party.new
- $game_troop = Game_Troop.new
- $game_map = Game_Map.new
- $game_player = Game_Player.new
- #—————————————————————————————————————
- $game_pmsc = PMSYS::PMSC.new
- #—————————————————————————————————————
- end
- #--------------------------------------------------------------------------
- # ★ 生成存档内容
- #--------------------------------------------------------------------------
- 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[:pmsc] = $game_pmsc
- #—————————————————————————————————————
- 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]
- #—————————————————————————————————————
- $game_pmsc = contents[:pmsc]
- #—————————————————————————————————————
- end
- end
- #==============================================================================
- # ■ Window_Base
- # *只修改了文字矩形宽度
- #==============================================================================
- class Window_Base < Window
- #--------------------------------------------------------------------------
- # ★ 绘制等级
- #--------------------------------------------------------------------------
- def draw_actor_level(actor, x, y)
- change_color(system_color)
- draw_text(x, y, 46, line_height, Vocab::level_a)
- change_color(normal_color)
- draw_text(x + 32, y, 36, line_height, actor.level, 2)
- end
- #--------------------------------------------------------------------------
- # ★ 以 当前值/最大值 这样的分数形式绘制当前值和最大值
- # current : 当前值
- # max : 最大值
- # color1 : 当前值的颜色
- # color2 : 最大值的颜色
- #--------------------------------------------------------------------------
- def draw_current_and_max_values(x, y, width, current, max, color1, color2)
- change_color(color1)
- xr = x + width + 4
- if width < 96
- draw_text(xr - 64, y, 62, line_height, current, 2)
- else
- draw_text(xr - 116, y, 62, line_height, current, 2)
- change_color(color2)
- draw_text(xr - 60, y, 12, line_height, "/", 2)
- draw_text(xr - 62, y, 62, line_height, max, 2)
- end
- end
- #--------------------------------------------------------------------------
- # ★ 绘制能力值
- #--------------------------------------------------------------------------
- def draw_actor_param(actor, x, y, param_id)
- change_color(system_color)
- draw_text(x, y, 120, line_height, Vocab::param(param_id))
- change_color(normal_color)
- draw_text(x + 120, y, 48, line_height, actor.param(param_id), 2)
- end
- end
- #==============================================================================
- # ■ Window_Status
- #==============================================================================
- class Window_Status < Window_Selectable
- #--------------------------------------------------------------------------
- # ★ 刷新
- #--------------------------------------------------------------------------
- def refresh
- contents.clear
- draw_pm
- draw_block1 (line_height * 0)
- draw_horz_line(line_height * 1)
- draw_block2 (line_height * 2)
- draw_horz_line(line_height * 6+8)
- draw_block3 (line_height * 7)
- draw_horz_line(line_height * 13)
- draw_block4 (line_height * 14)
- end
- #--------------------------------------------------------------------------
- # ★ 绘制能力值成长率、总成长率
- #--------------------------------------------------------------------------
- def draw_pm
- #获得宠物ID
- id = @actor.id
- #成长率基数
- c1 = $game_pmsc[:pmc1][id]
- #成长率倍数
- c2 = $game_pmsc[:pmc2][id]
- #总成长率
- all_c = 0
- c2.each {|i| all_c += 1+c1*i}
- all_c = all_c.toif(1000.0)
- #窗口边距
- sp = standard_padding
- #字体大小
- ts = 90
- #字体名字
- tn = contents.font.name
- #更改字体
- contents.font.name = "黑体"
- #更改字体大小
- contents.font.size = ts
- #更改字体透明度
- contents.font.color.alpha = 180
- #描绘标准尺寸
- r = contents.text_size(all_c)
- #描绘的宽、高
- w, h = r.width, r.height
- #窗口的宽、高
- gw, gh = self.width, self.height
- #右对齐
- x = gw-r.width-sp-10
- #上对齐
- y = gh-r.height-sp-81
- #描绘背景
- contents.fill_rect(x, y, w, h, line_color)
- #描绘总成长率
- draw_text(x, y, w*2, h, all_c)
- #字体设置恢复
- reset_font_settings
- contents.font.name = tn
- #绘制能力值成长率
- x = 32+196 ; y = 3
- c2.each {|i| y += 1 ; y += 1 if y == 6
- draw_text(x, y*line_height+4, 64, line_height, (1+c1*i).toif(1000.0))}
- end
- #--------------------------------------------------------------------------
- # ★ 绘制区域 2
- #--------------------------------------------------------------------------
- def draw_block2(y)
- draw_actor_face(@actor, 0, y+4)
- draw_basic_info(136, y+4)
- draw_equipments(288, y-8)
- end
- #--------------------------------------------------------------------------
- # ★ 绘制区域 3 (能力值、经验信息)
- #--------------------------------------------------------------------------
- def draw_block3(y)
- draw_parameters(32, y+4)
- draw_exp_info(288, y)
- end
- #--------------------------------------------------------------------------
- # ★ 绘制基本信息(头像、图标、性别、HP/MP/LV)
- #--------------------------------------------------------------------------
- def draw_basic_info(x, y)
- draw_actor_level(@actor, x-40, y + line_height * 0)
- draw_actor_icons(@actor, x-40, y + line_height * 1)
- draw_actor_hp(@actor, x-40, y + line_height * 2)
- draw_actor_mp(@actor, x-40, y + line_height * 3)
- xb = $game_pmsc[:pmxb][@actor.id]
- draw_text(x + 38, y + line_height * 0, 64, 24, xb) if xb
- end
- #--------------------------------------------------------------------------
- # ★ 绘制经验值信息
- #--------------------------------------------------------------------------
- def draw_exp_info(x, y)
- s1 = @actor.max_level? ? "-------" : @actor.exp
- s2 = @actor.max_level? ? "-------" : @actor.next_level_exp - @actor.exp
- s_next = sprintf(Vocab::ExpNext, Vocab::level)
- change_color(system_color)
- draw_text(x, y + line_height * 0, 180, line_height, Vocab::ExpTotal)
- draw_text(x, y + line_height * 1+8, 180, line_height, s_next)
- change_color(normal_color)
- draw_text(x+50, y + line_height * 0, 180, line_height, s1, 2)
- draw_text(x+50, y + line_height * 1+6, 180, line_height, s2, 2)
- end
- end
- #==============================================================================
- # ■ Game_Actor
- #==============================================================================
- class Game_Actor < Game_Battler
- #--------------------------------------------------------------------------
- # ★ 获取角色实例
- #--------------------------------------------------------------------------
- def actor
- $game_pmsc[:actor][@actor_id]
- end
- #--------------------------------------------------------------------------
- # ★ 获取职业实例
- #--------------------------------------------------------------------------
- def class
- $game_pmsc[:class][@class_id]
- end
- end
- #==============================================================================
- # ■ Game_Actors
- #==============================================================================
- class Game_Actors
- #--------------------------------------------------------------------------
- # ● 初始化对象
- #--------------------------------------------------------------------------
- def initialize
- @data = []
- end
- #--------------------------------------------------------------------------
- # ★ 获取角色
- #--------------------------------------------------------------------------
- def [](actor_id)
- @data[actor_id]
- end
- #--------------------------------------------------------------------------
- # ● 生成角色
- #--------------------------------------------------------------------------
- def pmsc_id=(actor_id)
- @data[actor_id] = Game_Actor.new(actor_id)
- end
- end
- #==============================================================================
- # ■ Game_Party
- #==============================================================================
- class Game_Party < Game_Unit
- #--------------------------------------------------------------------------
- # ★ 设置初期队伍
- #--------------------------------------------------------------------------
- def setup_starting_members
- @actors = $data_system.party_members.clone
- #—————————————————————————————————————
- #●def_data:定义数据
- @actors.each {|i| $game_pmsc.def_data(i, i)}
- #—————————————————————————————————————
- end
- #--------------------------------------------------------------------------
- # ★ 设置战斗测试用队伍
- #--------------------------------------------------------------------------
- def setup_battle_test_members
- $data_system.test_battlers.each do |battler|
- #—————————————————————————————————————
- #●ios_data:随机数据
- $game_pmsc.ios_data(battler.actor_id, battler.actor_id)
- #—————————————————————————————————————
- actor = $game_actors[battler.actor_id]
- actor.change_level(battler.level, false)
- actor.init_equips(battler.equips)
- actor.recover_all
- add_actor(actor.id)
- end
- end
- end
复制代码 |
|