Project1
标题:
冷却脚本与技能脚本冲突,跪求帮助
[打印本页]
作者:
望月神绮
时间:
2016-5-26 20:21
标题:
冷却脚本与技能脚本冲突,跪求帮助
我用的绿发的Eclair的豪华版技能冷却系统。将这份代码放在后面位置(我技能脚本后面)的话,它的实现是没有问题,但是我技能脚本在使用过程中就会出错,错误原因第133行发生了NoMethodError,private method ‘split’called for nil:NilClass。
然后如果把它放在前面,则会出现错误,错误显示是第77行发生了ArgunmentError wrong number of argunments(1 for 0)。
然后我贴脚本,首先是豪华冷却。
#=======================================================================
# 豪华版技能冷却系统 By 绿发的Eclair
# 使用方法:在特技名称后面用半角逗号分割,写上冷却回合数。
# 比如 十字斩,10 就是特技 十字斩 冷却10个回合了。
# 注意这个冷却是敌我通用的,不只是我方,敌人也不会使用冷却中的技能哦。
# 不想让特技窗口中显示冷却回合数, $冷却时间显示 = false 就行了。
# 冲突性:存在,但是除了RTAB外似乎整合难度不大。
#=======================================================================
$冷却时间显示 = true
module RPG
class Skill
def cold
return @name.split(/-/)[1]
end
def name(actor = nil)
if $冷却时间显示 and actor != nil and actor.cold[@id] != nil
a = (@name.split(/-/)[0] == nil ? 0 : @name.split(/-/)[0])
return a + "(" + actor.cold[@id].to_s + "回合冷却)"
else
return (@name.split(/-/)[0] == nil ? 0 : @name.split(/-/)[0])
end
end
end
end
class Game_Battler
attr_accessor :cold
alias initialize_cold :initialize
def initialize
@cold = {}
initialize_cold
end
def set_cold(key,val)
return if @cold[key] == nil
@cold[key] += val
@cold.delete(key) if @cold[key] <= 0
end
alias skill_can_use_addcold :skill_can_use?
def skill_can_use?(skill_id)
return false if @cold[skill_id] != nil
skill_can_use_addcold(skill_id)
end
end
class Scene_Battle
alias make_skill_action_result_addcold :make_skill_action_result
def make_skill_action_result
make_skill_action_result_addcold
if @skill.cold.to_i != 0
@active_battler.cold[@skill.id] = @skill.cold.to_i
end
end
alias start_phase4_addcold :start_phase4
def start_phase4
for i in $game_party.actors + $game_troop.enemies
for j in i.cold.keys
i.set_cold(j,-1)
end
end
start_phase4_addcold
end
end
class Window_Skill < Window_Selectable
def draw_item(index)
skill = @data[index]
if @actor.skill_can_use?(skill.id)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(skill.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
if $scene.is_a?(Scene_Battle)
self.contents.draw_text(x + 28, y, 204, 32, skill.name(@actor), 0)
else
self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)
end
self.contents.draw_text(x + 232, y, 48, 32, skill.sp_cost.to_s, 2)
end
end
class Game_Enemy < Game_Battler
def make_action
# 清除当前行动
self.current_action.clear
# 无法行动的情况
unless self.movable?
# 过程结束
return
end
# 抽取现在有效的行动
available_actions = []
rating_max = 0
for action in self.actions
# 确认回合条件
n = $game_temp.battle_turn
a = action.condition_turn_a
b = action.condition_turn_b
if (b == 0 and n != a) or
(b > 0 and (n < 1 or n < a or n % b != a % b))
next
end
# 确认 HP 条件
if self.hp * 100.0 / self.maxhp > action.condition_hp
next
end
if self.cold[action.skill_id] != nil
next
end
# 确认等级条件
if $game_party.max_level < action.condition_level
next
end
# 确认开关条件
switch_id = action.condition_switch_id
if switch_id > 0 and $game_switches[switch_id] == false
next
end
# 符合条件 : 添加本行动
available_actions.push(action)
if action.rating > rating_max
rating_max = action.rating
end
end
# 最大概率值作为 3 合计计算(0 除外)
ratings_total = 0
for action in available_actions
if action.rating > rating_max - 3
ratings_total += action.rating - (rating_max - 3)
end
end
# 概率合计不为 0 的情况下
if ratings_total > 0
# 生成随机数
value = rand(ratings_total)
# 设置对应生成随机数的当前行动
for action in available_actions
if action.rating > rating_max - 3
if value < action.rating - (rating_max - 3)
self.current_action.kind = action.kind
self.current_action.basic = action.basic
self.current_action.skill_id = action.skill_id
self.current_action.decide_random_target_for_enemy
return
else
value -= action.rating - (rating_max - 3)
end
end
end
end
end
end
#=======================================================================
#豪华版技能冷却系统
#=======================================================================
复制代码
然后是我的技能脚本
module RPG
#--------------------------------------------------------------------------
# ● Cache追加
#--------------------------------------------------------------------------
module Cache
def self.faces(filename)
self.load_bitmap("Graphics/Faces/", filename)
end
def self.menu(filename)
self.load_bitmap("Graphics/Menu/", filename)
end
def self.images(filename)
self.load_bitmap("Graphics/Images/", filename)
end
def self.menu(filename)
self.load_bitmap("Graphics/Menu/", filename)
end
def self.menu_icon(filename)
self.load_bitmap("Graphics/Menu_Icons/", filename)
end
def self.crystal(filename)
self.load_bitmap("Graphics/Crystal/", filename)
end
def self.members(filename)
self.load_bitmap("Graphics/Members/", filename)
end
def self.mission(filename)
self.load_bitmap("Graphics/Mission/", filename)
end
def self.cook(filename)
self.load_bitmap("Graphics/Cook/", filename)
end
end
#--------------------------------------------------------------------------
# ● 结晶回路用全局变量
#--------------------------------------------------------------------------
# 结晶石防具数据库起始ID,此为第一件结晶石的ID,其后不得再含有普通的防具。
ARMOR_BEGIN = 201
# 结晶石技能数据库起始ID,此为第一个结晶石技能的ID,其后不得再含有普通的技能。
SKILL_BEGIN = 201
#--------------------------------------------------------------------------
# ● 结晶回路的各个属性定义
#--------------------------------------------------------------------------
class Armor
# 防具数据库,结晶石是通过防具数据库进行设置的。
# 设置方法:
# 在属性防御上勾选此结晶所包含的属性,之后在名称栏中通过半角逗号分隔,将具
# 体属性值写于其中。如范例中:“火神的愤怒,25@5”,同时勾选了炎和雷属性,根
# 据从上到下的先后次序,炎属性为25,雷属性为5。
# 结晶石本身的属性以及本身的等级,通过描述一栏后追加分隔符的方法来给定。
# 具体可参考范例。
if self.id >= ARMOR_BEGIN
#--------------------------------------------------------------------------
# ● 重新定义名字
#--------------------------------------------------------------------------
def name
return @name.split(/,/)[0]
end
#--------------------------------------------------------------------------
# ● 定义结晶回路包含的属性值
#--------------------------------------------------------------------------
def crystal_element
return Array.new(CRYSTAL::ELE_NUMBER, 0) if @name.split(/,/).size == 1
data = @name.split(/,/)[1].split(/@/)
final = []
for i in 0...CRYSTAL::ELE_NUMBER
if self.guard_element_set.include?(i + 1)
if data.empty?
raise ("#{@id}号结晶石的属性未设置")
end
final[i] = data.shift.to_i
else
final[i] = 0
end
end
return final
end
#--------------------------------------------------------------------------
# ● 重新定义结晶回路的描述
#--------------------------------------------------------------------------
def description
return @description.split(/,/)[0]
end
#--------------------------------------------------------------------------
# ● 定义结晶回路的主要属性
#--------------------------------------------------------------------------
def element
return @description.split(/,/)[1].to_i
end
#--------------------------------------------------------------------------
# ● 定义结晶回路的等级
#--------------------------------------------------------------------------
def level
return @description.split(/,/)[2].to_i
end
#--------------------------------------------------------------------------
# ● 定义结晶回路的价格 也就是耗费的各个耀晶片数量
#--------------------------------------------------------------------------
def cost_sepich
@data = $data_armors[self.id+1].description.split(/#/)
final = []
for i in 0...CRYSTAL::ELE_NUMBER
if $data_armors[self.id+1].guard_element_set.include?(i+1)
if @data.empty?
break
end
final[i] = @data.shift.to_i
else
final[i] = 0
end
end
return final
end
#--------------------------------------------------------------------------
# ● 定义结晶回路的种类 为了让同样的回路不能装备多个用
#--------------------------------------------------------------------------
def cry_type
return $data_armors[self.id+1].name.to_i
end
end
end
class Skill
# 技能数据库,用来设置根据结晶属性值的多少学会的技能。
# 设置方法与防具数据库类似,勾选属性一栏的对应属性,然后通过名称给予需要的
# 结晶属性值。
if self.id >= SKILL_BEGIN
def name
return @name.split(/,/)[0]
end
def require_element
data = @name.split(/,/)[1].split(/@/)
final = []
for i in 0...CRYSTAL::ELE_NUMBER
if self.element_set.include?(i + 1)
if data.empty?
raise ("#{@id}号技能的属性未设置")
end
final[i] = data.shift.to_i
else
final[i] = 0
end
end
return final
end
def description
return @description.split(/,/)[0]
end
def element
return @description.split(/,/)[1].to_i
end
复制代码
能想办法颁布感我处理一下这个BUG吗……拜托各位大神了QAQ,跪求帮助
作者:
cinderelmini
时间:
2016-5-27 12:55
本帖最后由 cinderelmini 于 2016-5-27 21:08 编辑
module RPG
class Skill
def name(actor = nil)
_name = @name.split(/,/)[0] || @name
a = _name.split(/-/)[0]
if ($冷却时间显示 and actor and actor.cold[@id])
return "#{a}(#{actor.cold[@id].to_s}回合冷却)"
else
return a
end
end
def cold
_name = @name.split(/,/)[0] || @name
return _name.split(/-/)[1].to_i
end
end
end
复制代码
试试放在列表里这俩系统之下,然后设置的时候先填冷却再填结晶属性。
例【十字斩-3,1@2@5】
也许能成吧…………
发现冷却脚本里名字的设定好像有坑,代码已经改了,
脚本的顺序大概应该是:
·冷却
·结晶
·本楼这个
作者:
望月神绮
时间:
2016-5-27 16:26
cinderelmini 发表于 2016-5-27 12:55
试试放在列表里这俩系统之下,然后设置的时候先填冷却再填结晶属性。
例【十字斩-3,1@2@5】
也许能成吧…… ...
那个您好。
把您这段代码粘到了最后面(MAIN前),然后把冷却放在结晶属性后,冷却可以实现,结晶属性的技能还是会报错。然后把冷却放在结晶属性前,冷却不能实现,结晶属性还是会报错……求帮助……问题还是134行发生那个错误。
作者:
望月神绮
时间:
2016-5-27 18:56
cinderelmini 发表于 2016-5-27 12:55
试试放在列表里这俩系统之下,然后设置的时候先填冷却再填结晶属性。
例【十字斩-3,1@2@5】
也许能成吧…… ...
您给我的第5行在使用结晶的时候发生了错误,NoMethodError,private method ‘split’called for nil:NilClass。
然后我试了一下,冷却脚本也不好使了,在战斗测试里,我给技能加了十字斩-5,在技能里显示确实是十字斩,但是用完没有冷却显示。
如果需要工程的话我可以发上来,不过可能有些大,工程必须的贴图有些多……
作者:
望月神绮
时间:
2016-5-27 19:15
我添加的脚本有些多,要运行游戏需要许多图片支持,传不了那么大的文件。
如果您有时间的话可不可以告诉我您的QQ之类联系方式?我好把工程传给您。我只放了一个DATA上来……
我的QQ是815839513。谢谢您的帮助,拜托了……
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X5.0