Project1
标题:
技能等级的脚本出现错误
[打印本页]
作者:
k_ichinose
时间:
2009-5-23 15:26
标题:
技能等级的脚本出现错误
class RPG::Skill < RPG::UsableItem
# 判斷技能是否有等級
def lvup?
self.note.split(/[\r\n]+/).each { |line|
return line =~ /\[(lvup|level up|升級|升级)\]/}
return false
end
# 判斷技能熟練度次數
def times_used_to_lvup
self.note.split(/[\r\n]+/).each { |line|
return $1.to_i if line =~ /\[(?:use_exp|熟練次數) (\d*)\]/}
return 20
end
# 判斷技能所需熟練度
def use_exp; return (100 / times_used_to_lvup); end
# 獲取技能最大等級
def maxlv
self.note.split(/[\r\n]+/).each { |line|
return $1.to_i if line =~ /\[(?:maxlv|最大等級|最大等级) (\d*)\]/}
return 1
end
# 獲取等級值
def get_value(lv, hash)
if hash.include?(lv)
return hash[lv]
else
ks = hash.keys.dup
ks.sort!
for i in 1..hash.size-1
k0 = ks[i-1]
k1 = ks[i]
k2 = ks[i+1]
if lv > k1 and lv < k2
return hash[k1]
elsif lv < k1
return hash[k0]
elsif lv > k2
next
end
end
end
end
end
class Game_Temp
alias skill_level_initialize initialize
attr_accessor :skill_level
def initialize
skill_level_initialize
@skill_level = 1
end
end
class Game_Battler
# 技能效果 + 熟練度提升
alias skill_level_skill_effect skill_effect
def skill_effect(user, skill)
if skill_effective?(user, skill)
exp = user.skill_exp[skill.id].to_i + skill.use_exp
user.change_skill_exp(skill.id, exp)
end
skill_level_skill_effect(user, skill)
end
end
class Game_Actor < Game_Battler
attr_accessor :skill_level
attr_accessor :skill_exp
alias skill_level_initialize initialize
# 可升級技能初始化
def initialize(actor_id)
skill_level_initialize(actor_id)
@skill_level = {}
@skill_exp = {}
for i in self.class.learnings
skill = $data_skills[i.skill_id]
if skill.lvup?
@skill_level[skill.id] ||= 1
@skill_exp[skill.id] ||= 0
end
end
end
# 更改技能熟練度
def change_skill_exp(id, exp)
@skill_exp[id] = [[exp, 99999].min, 0].max
while @skill_exp[id] >= 100
skill_level_up(id)
@skill_exp[id] = 0
end
end
# 更改技能等級
def skill_level_up(id, level=1)
return unless skill_lvup?(id)
@skill_level[id] = @skill_level[id].to_i+level
# 顯示升級提示窗口
@skill_lvup_window = Window_Base.new(0, (416-56)/2, 544,56)
text="技能[#{$data_skills[id].name}]等級提升"
@skill_lvup_window.contents.draw_text(0, 0, 512, Window_Base::WLH, text, 1)
Graphics.wait(60) # 等待60禎
@skill_lvup_window.dispose
end
# 角色技能是否能升级
def skill_lvup?(id)
return @skill_level[id] != $data_skills[id].maxlv
return $data_skills[id].lvup?
end
end
class Window_Base < Window
alias skill_level_draw_item_name draw_item_name
# 繪製技能名稱
def draw_item_name(item, x, y, enabled = true)
if item != nil and item.is_a?(RPG::Skill) and item.lvup?
draw_skill_name_lvup(item, x, y, enabled)
return
end
skill_level_draw_item_name(item, x, y, enabled)
end
# 繪製可升級技能名稱
def draw_skill_name_lvup(item, x, y, enabled = true)
draw_icon(item.icon_index, x, y, enabled)
self.contents.font.color = normal_color
self.contents.font.color.alpha = enabled ? 255 : 128
exp = @actor.skill_exp[item.id]
level = @actor.skill_level[item.id]
if @actor.skill_lvup?(item.id)
self.contents.draw_text(x + 24, y, 172, WLH, item.name+" LV:#{level}"+"(#{exp}%)")
else
self.contents.draw_text(x + 24, y, 172, WLH, item.name+" LV:#{level}")
end
end
end
class Game_Actor < Game_Battler
alias skill_level_skill_effective? skill_effective?
def skill_effective?(user, skill)
$game_temp.skill_level = user.skill_level[skill.id]
skill_level_skill_effective?(user, skill)
end
end
class Game_BattleAction
alias skill_level_set_skill set_skill
alias skill_level_skill skill
def set_skill(skill_id)
skill_level_set_skill(skill_id)
$game_temp.skill_level = @battler.skill_level[skill_id]
end
def skill
$game_temp.skill_level = @battler.skill_level[@skill_id]
skill_level_skill
end
end
class Window_Skill < Window_Selectable
alias skill_level_skill skill
def skill
$game_temp.skill_level = @actor.skill_level[@data[self.index].id]
skill_level_skill
end
end
复制代码
class Window_Skill < Window_Selectable
alias skill_level_skill skill
def skill
$game_temp.skill_level = @actor.skill_level[@data[self.index].id]
skill_level_skill
end
end出现错误……放到新工程中,敌人无法使用技能…… [LINE]1,#dddddd[/LINE]
此贴于 2009-6-6 10:31:26 被版主木葬枫提醒,请楼主看到后对本贴做出回应。
作者:
k_ichinose
时间:
2009-6-6 20:57
- -被54还被提醒,真是悲哀
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1