赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 1 |
经验 | 1647 |
最后登录 | 2017-8-10 |
在线时间 | 17 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 17 小时
- 注册时间
- 2017-1-18
- 帖子
- 50
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 李舜生 于 2017-1-20 19:48 编辑
##==============================================================================
# 自定义技能禁用 by Silentever(夜光云)
# (技能开关)
#
# 2015-09-13 发布
#==============================================================================
# ▼ 设定
#
# 此脚本的功能是让玩家在游戏内手动禁用技能或解除技能的禁用。
# 为了呼出禁用界面使用:【 SceneManager.call(Scene_ActiveSkill) 】
# 已经在主菜单里面添加了进入界面的选项。
# 基本上基础系统在开启跟关闭技能没有任何限制,不过可以通过以下选择性功能追加限制。
# 可以选择同时全部启用。选择使用限制的场合,所有技能会以禁用状态初始化。
#
# 【选择性限制:数量上限】
# 限制角色开启的技能数量。
#
# 【选择性限制:COST制】
# 通过COST限制角色开启的技能数量。
#
# 【选择性模式:层积数值化开关】
# 把技能的开关变成一种数值,基本上可以理解成一个“伪技能等级”系统。
# 可以把“技能点”复数分配给同一个技能,同时也能从技能扣除该“等级”。
# 不过本脚本不会提供任何追加影响,请善用“stacklv”这个变量。
# (建议配合上面的限制功能。)
#
# 【严谨】编辑选择性功能时请注意不能删除0号角色/技能,
# 0号实际上是不存在的对象,但这里会将这个当作默认数据使用。
# 因此没有特别指定数值的角色/技能皆会使用默认数据,即0号的数据。
#==============================================================================
module ActiveSkills
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# ● 基础
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Sealable_Stype = [3, 4] # 可开关的技能类型
Active_Title = "技能整备" # 菜单中显示指令
Active_Icon = 143 # 开启技能显示图标
Active_Text = "On" # 开启技能显示文字
Active_Color = 2 # 开启/COST颜色
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# ● 启用数量限制
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Skill_Limit = false
Limit_Title = "上限" # 显示名称
#--------------------------------------------------------------------------
# 设置角色开启上限数值
#--------------------------------------------------------------------------
Actor_Limit = {
# 角色ID => 公式(字符串)
0 => "5 + level * 0.3",
1 => "8 + level * 0.3",
2 => "4 + level * 0.4",
} # Do Not Remove
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# ● 启用COST限制
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Skill_Active_Cost = true
Active_Cost_Title = "COST" # 显示名称
#--------------------------------------------------------------------------
# 设置角色COST上限数值
#--------------------------------------------------------------------------
Actor_Cost = {
# 角色ID => 公式(字符串)
0 => "10 + level * 1.5",
1 => "12 + level * 1.4",
2 => "10 + level * 1.6",
} # Do Not Remove
#--------------------------------------------------------------------------
# 设置技能COST数值
#--------------------------------------------------------------------------
Skill_Cost = {
# 技能ID => 公式(字符串)
0 => "3",
1 => "4",
2 => "6",
} # Do Not Remove
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# ● 启用层积数值化开关
# 最终层积上限是角色的技能上限+技能本体上限。
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Skill_Stack_Level = true
#--------------------------------------------------------------------------
# 设置角色的层积上限。
# 仅0号用【公式(字符串)】
# 在角色中指定0号技能,会代替0号数据成为该角色专用的默认数据。
#--------------------------------------------------------------------------
Actor_Max_Stack = {
# 角色ID => { 技能ID => 公式 (用“,”分开) }
0 => "0",
1 => {6=>"3"},
2 => {0=>"1", 12=>"2"},
} # Do Not Remove
#--------------------------------------------------------------------------
# 设置技能的层积上限。
#--------------------------------------------------------------------------
Skill_Max_Stack = {
# 技能ID => 公式(字符串)
0 => "3",
1 => "5",
2 => "6",
} # Do Not Remove
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
end
#==============================================================================
# ▼ 脚本内容
#==============================================================================
class Game_Actor < Game_Battler
include ActiveSkills
#--------------------------------------------------------------------------
# NewMethod: 开启技能数组
#--------------------------------------------------------------------------
def active_skills
skills.select {|skill| !skill_sealed?(skill.id) &&
Sealable_Stype.include?(skill.stype_id)}; end
#--------------------------------------------------------------------------
# NewMethod: 开启技能
#--------------------------------------------------------------------------
def skill_activate(skill)
return unless skill_sealed?(skill.id)
actor.features.delete_if {|f| f.code == 44 && f.data_id == skill.id}; end
#--------------------------------------------------------------------------
# NewMethod: 关闭技能数组
#--------------------------------------------------------------------------
def sealed_skills
skills.select {|skill| skill_sealed?(skill.id) &&
Sealable_Stype.include?(skill.stype_id)}; end
#--------------------------------------------------------------------------
# NewMethod: 关闭技能
#--------------------------------------------------------------------------
def skill_deactivate(skill)
return if skill_sealed?(skill.id)
actor.features.push(RPG::BaseItem::Feature.new(44, skill.id, 0)); end
#--------------------------------------------------------------------------
# NewMethod: 关闭所有技能
#--------------------------------------------------------------------------
def deactivate_all_skills
active_skills.each {|skill| skill_deactivate(skill)}; end
#------------------------------------------------------------------------
# NewMethod: 判断是否可开启(空方法)
#------------------------------------------------------------------------
def skill_activable?(skill); true; end
end
#==============================================================================
# ■ Window_SkillCommand
#==============================================================================
class Window_ActiveSkillCommand < Window_SkillCommand
#--------------------------------------------------------------------------
# ● 生成指令列表
#--------------------------------------------------------------------------
def make_command_list
return unless @actor
@actor.added_skill_types.sort.each do |stype_id|
next unless ActiveSkills::Sealable_Stype.include?(stype_id)
name = $data_system.skill_types[stype_id]
add_command(name, :skill, true, stype_id)
end
end
end
#==============================================================================
# ■ Window_ActiveSkillStatus
#==============================================================================
class Window_ActiveSkillStatus < Window_SkillStatus
#--------------------------------------------------------------------------
# OverWrite: 以 当前值/最大值 这样的分数形式绘制当前值和最大值
#--------------------------------------------------------------------------
def draw_current_and_max_values(x, y, width, current, max, color1, color2)
change_color(color1)
draw_text(x, y, width-text_size('/00').width, line_height, current, 2)
change_color(color2)
draw_text(x, y, width-text_size('00').width, line_height, "/", 2)
draw_text(x, y, width, line_height, max, 2)
end
end
#==============================================================================
# ■ Window_ActiveSkill
#==============================================================================
class Window_ActiveSkill < Window_SkillList
#--------------------------------------------------------------------------
# OverWrite: 以 当前值/最大值 这样的分数形式绘制当前值和最大值
#--------------------------------------------------------------------------
def draw_current_and_max_values(x, y, width, current, max, color1, color2)
change_color(color1)
draw_text(x, y, width-text_size('/0').width, line_height, current, 2)
change_color(color2)
draw_text(x, y, width-text_size('0').width, line_height, "/", 2)
draw_text(x, y, width, line_height, max, 2)
end
#--------------------------------------------------------------------------
# OverWrite: 查询此技能是否可用
#--------------------------------------------------------------------------
def enable?(item)
return false unless item
return [email protected]_sealed?(item.id) || @actor.skill_activable?(item); end
#--------------------------------------------------------------------------
# OverWrite: 绘制技能的使用消耗
#--------------------------------------------------------------------------
def draw_skill_cost(rect, skill)
return unless [email protected]_sealed?(skill.id)
change_color(text_color(ActiveSkills::Active_Color))
draw_icon(ActiveSkills::Active_Icon, rect.x + rect.width-28, rect.y)
draw_text(rect, ActiveSkills::Active_Text, 2)
end
end
#==============================================================================
# ▼ 限制基础
#==============================================================================
if ActiveSkills::Skill_Limit || ActiveSkills::Skill_Active_Cost ||
ActiveSkills::Skill_Stack_Level
#==========================================================================
# ■ RPG::Skill
#==========================================================================
class RPG::Skill < RPG::UsableItem
include ActiveSkills; end
#==========================================================================
# ■ Game_Actor
#==========================================================================
class Game_Actor < Game_Battler
#------------------------------------------------------------------------
# AliasMethod: 初始化禁用状态
#------------------------------------------------------------------------
alias :setup_swc :setup
def setup(actor_id)
setup_swc(actor_id)
active_skills.each {|skill| skill_deactivate(skill)}; end
end
#==========================================================================
# ■ Window_ActiveSkillStatus
#==========================================================================
class Window_ActiveSkillStatus < Window_SkillStatus
#------------------------------------------------------------------------
# OverWrite: 绘制简单的状态
#------------------------------------------------------------------------
def draw_actor_simple_status(actor, x, y)
draw_actor_name(actor, x, y)
draw_actor_level(actor, x, y + line_height * 1)
draw_actor_class(actor, x + 120, y)
end
end
end
#==============================================================================
# ▼ 数量限制相关
#==============================================================================
if ActiveSkills::Skill_Limit
#==========================================================================
# ■ Game_Actor
#==========================================================================
class Game_Actor < Game_Battler
#------------------------------------------------------------------------
# NewMethod: 数量上限
#------------------------------------------------------------------------
def skill_limit
(eval Actor_Limit[actor_id] rescue eval Actor_Limit[0]).to_i; end
#------------------------------------------------------------------------
# NewMethod: 技能数量总和
#------------------------------------------------------------------------
def total_skills
active_skills.size; end
#------------------------------------------------------------------------
# NewMethod: 判断是否可开启(数量不超过上限)
#------------------------------------------------------------------------
alias :skill_activable_swc_limit :skill_activable?
def skill_activable?(skill)
skill_activable_swc_limit(skill) &&
(total_skills < skill_limit); end
end
#==========================================================================
# ■ Window_ActiveSkillStatus
#==========================================================================
class Window_ActiveSkillStatus < Window_SkillStatus
#------------------------------------------------------------------------
# AliasMethod: 绘制简单的状态
#------------------------------------------------------------------------
alias :draw_actor_simple_status_swc_limit :draw_actor_simple_status
def draw_actor_simple_status(actor, x, y)
draw_actor_simple_status_swc_limit(actor, x, y)
dx = x + 120; dy = y + line_height * 1; dw = contents.width-228
change_color(system_color)
draw_text(dx, dy, dw, line_height, ActiveSkills::Limit_Title)
draw_current_and_max_values(dx, dy, dw,
actor.total_skills, actor.skill_limit, normal_color, system_color)
end
end
end
#==============================================================================
# ▼ COST相关
#==============================================================================
if ActiveSkills::Skill_Active_Cost
#==========================================================================
# ■ RPG::Skill
#==========================================================================
class RPG::Skill < RPG::UsableItem
#------------------------------------------------------------------------
# NewMethod: 技能COST
#------------------------------------------------------------------------
def active_cost; (eval Skill_Cost[@id] rescue eval Skill_Cost[0]).to_i; end
end
#==========================================================================
# ■ Game_Actor
#==========================================================================
class Game_Actor < Game_Battler
#------------------------------------------------------------------------
# NewMethod: COST上限
#------------------------------------------------------------------------
def max_skill_cost
(eval Actor_Cost[actor_id] rescue eval Actor_Cost[0]).to_i; end
#------------------------------------------------------------------------
# NewMethod: COST总和
#------------------------------------------------------------------------
def total_skill_cost
(active_skills.inject(0) {|v, skill| v += skill.active_cost if skill}).to_i; end
#------------------------------------------------------------------------
# NewMethod: 判断是否可开启(COST不超过上限)
#------------------------------------------------------------------------
alias :skill_activable_swc_cost :skill_activable?
def skill_activable?(skill)
skill_activable_swc_cost(skill) &&
(total_skill_cost + skill.active_cost <= max_skill_cost); end
end
#==========================================================================
# ■ Window_ActiveSkillStatus
#==========================================================================
class Window_ActiveSkillStatus < Window_SkillStatus
#------------------------------------------------------------------------
# AliasMethod: 绘制简单的状态
#------------------------------------------------------------------------
alias :draw_actor_simple_status_swc_cost :draw_actor_simple_status
def draw_actor_simple_status(actor, x, y)
draw_actor_simple_status_swc_cost(actor, x, y)
dx = x + 120; dy = y + line_height * 2; dw = contents.width-228
change_color(system_color)
draw_text(dx, dy, dw, line_height, ActiveSkills::Active_Cost_Title)
draw_current_and_max_values(dx, dy, dw,
actor.total_skill_cost, actor.max_skill_cost, normal_color, system_color)
end
end
#==========================================================================
# ■ Window_ActiveSkill
#==========================================================================
class Window_ActiveSkill < Window_SkillList
#------------------------------------------------------------------------
# OverWrite: 绘制技能的使用消耗
#------------------------------------------------------------------------
def draw_skill_cost(rect, skill)
change_color(text_color(ActiveSkills::Active_Color))
draw_icon(ActiveSkills::Active_Icon, rect.x + rect.width-28, rect.y) unless
@actor.skill_sealed?(skill.id)
draw_text(rect, skill.active_cost, 2)
end
end
end
#==============================================================================
# ▼ 层积数值相关
#==============================================================================
if ActiveSkills::Skill_Stack_Level
#==========================================================================
# ■ RPG::Skill
#==========================================================================
class RPG::Skill < RPG::UsableItem
#------------------------------------------------------------------------
# NewMethod: 层积上限
#------------------------------------------------------------------------
def max_stack; (eval Skill_Max_Stack[@id] rescue eval Skill_Max_Stack[0]).to_i; end
end
#==========================================================================
# ■ Game_Actor
#==========================================================================
class Game_Actor < Game_Battler
attr_accessor :stacklv
#------------------------------------------------------------------------
# AliasMethod: 初始化禁用状态(层积)
#------------------------------------------------------------------------
alias :setup_swc_stack :setup
def setup(actor_id)
@stacklv = Hash.new
@stacklv.default = 0
setup_swc_stack(actor_id)
end
#------------------------------------------------------------------------
# NewMethod: 角色的层积等级上限
#------------------------------------------------------------------------
def max_stack(skill)
skill.max_stack + (
eval Actor_Max_Stack[actor_id][skill.id] rescue
eval Actor_Max_Stack[actor_id][0] rescue
eval Actor_Max_Stack[0]).to_i; end
#------------------------------------------------------------------------
# NewMethod: 根据层积等级获取技能数组
#------------------------------------------------------------------------
def active_skills_by_stack(stacklv)
active_skills.select {|skill| @stacklv[skill.id] == stacklv}; end
#--------------------------------------------------------------------------
# NewMethod: 开启技能
#--------------------------------------------------------------------------
alias :skill_activate_swc_stack :skill_activate
def skill_activate(skill)
@stacklv[skill.id] += 1
skill_activate_swc_stack(skill) if @stacklv[skill.id] > 0; end
#--------------------------------------------------------------------------
# NewMethod: 关闭技能
#--------------------------------------------------------------------------
alias :skill_deactivate_swc_stack :skill_deactivate
def skill_deactivate(skill)
@stacklv[skill.id] ||= 0
@stacklv[skill.id] = [@stacklv[skill.id] - 1, 0].max
skill_deactivate_swc_stack(skill) if @stacklv[skill.id] == 0; end
#------------------------------------------------------------------------
# OverWrite: 技能数量总和(层积加算)
#------------------------------------------------------------------------
def total_skills
(active_skills.inject(0) {|v, skill| v += @stacklv[skill.id] if skill}).to_i; end
#------------------------------------------------------------------------
# OverWrite: COST总和(层积加算)
#------------------------------------------------------------------------
def total_skill_cost
(active_skills.inject(0) {|v, skill|
v += skill.active_cost * @stacklv[skill.id] if skill}).to_i; end
#------------------------------------------------------------------------
# AliasMethod: 判断是否可开启(层积不超过上限)
#------------------------------------------------------------------------
alias :skill_activable_swc_stacklv :skill_activable?
def skill_activable?(skill)
skill_activable_swc_stacklv(skill) &&
(@stacklv[skill.id] < max_stack(skill)); end
end
#==========================================================================
# ■ Window_ActiveSkillStatus
#==========================================================================
class Window_ActiveSkillStatus < Window_SkillStatus
#------------------------------------------------------------------------
# AliasMethod: 绘制简单的状态
#------------------------------------------------------------------------
alias :draw_actor_simple_status_swc_stack :draw_actor_simple_status
def draw_actor_simple_status(actor, x, y)
draw_actor_simple_status_swc_stack(actor, x, y)
change_color(system_color)
draw_text(x, y + line_height * 2, contents.width-108, line_height, "A:解除")
end
end
#==========================================================================
# ■ Window_ActiveSkill
#==========================================================================
class Window_ActiveSkill < Window_SkillList
#------------------------------------------------------------------------
# OverWrite: 查询此技能是否可用
#------------------------------------------------------------------------
def enable?(item)
return false unless item
return @actor.skill_activable?(item); end
#------------------------------------------------------------------------
# OverWrite: 绘制技能的使用消耗
#------------------------------------------------------------------------
def draw_skill_cost(rect, skill)
if ActiveSkills::Skill_Active_Cost
draw_text(rect.x, rect.y, rect.width-text_size('0/0').width,
rect.height, "x", 2)
change_color(text_color(ActiveSkills::Active_Color))
draw_text(rect.x, rect.y, rect.width-text_size(' x0/0').width,
rect.height, skill.active_cost, 2); end
draw_current_and_max_values(rect.x, rect.y, rect.width,
@actor.stacklv[skill.id], @actor.max_stack(skill),
normal_color, system_color)
end
end
end
#==============================================================================
# ■ Window_MenuCommand
#==============================================================================
class Window_MenuCommand < Window_Command
#--------------------------------------------------------------------------
# OverWrite: 向指令列表添加主要的指令
#--------------------------------------------------------------------------
def add_main_commands
add_command(Vocab::item, :item, main_commands_enabled)
add_command(Vocab::skill, :skill, main_commands_enabled)
add_command(ActiveSkills::Active_Title,:act_skill,main_commands_enabled)
add_command(Vocab::equip, :equip, main_commands_enabled)
add_command(Vocab::status, :status, main_commands_enabled)
end
end
#==============================================================================
# ■ Scene_Menu
#==============================================================================
class Scene_Menu < Scene_MenuBase
#--------------------------------------------------------------------------
# AliasMethod: 生成指令窗口
#--------------------------------------------------------------------------
alias :create_command_window_swc :create_command_window
def create_command_window
@command_window = Window_MenuCommand.new
create_command_window_swc
@command_window.set_handler(:act_skill, method(:command_personal))
end
#--------------------------------------------------------------------------
# AliasMethod: 个人指令“确定”
#--------------------------------------------------------------------------
alias :on_personal_ok_swc :on_personal_ok
def on_personal_ok
on_personal_ok_swc
if @command_window.current_symbol == :act_skill
SceneManager.call(Scene_ActiveSkill)
end
end
end
#==============================================================================
# ■ Scene_ActiveSkill
#==============================================================================
class Scene_ActiveSkill < Scene_Skill
#--------------------------------------------------------------------------
# ● 生成指令窗口
#--------------------------------------------------------------------------
def create_command_window
wy = @help_window.height
@command_window = Window_ActiveSkillCommand.new(0, wy)
@command_window.viewport = @viewport
@command_window.help_window = @help_window
@command_window.actor = @actor
@command_window.set_handler(:skill, method(:command_skill))
@command_window.set_handler(:cancel, method(:return_scene))
@command_window.set_handler(:pagedown, method(:next_actor))
@command_window.set_handler(:pageup, method(:prev_actor))
end
#--------------------------------------------------------------------------
# NewMethod: 生成状态窗口
#--------------------------------------------------------------------------
def create_status_window
y = @help_window.height
@status_window = Window_ActiveSkillStatus.new(@command_window.width, y)
@status_window.viewport = @viewport
@status_window.actor = @actor
end
#--------------------------------------------------------------------------
# NewMethod: 生成物品窗口
#--------------------------------------------------------------------------
def create_item_window
wy = @status_window.y + @status_window.height
ww = Graphics.width
wh = Graphics.height - wy
@item_window = Window_ActiveSkill.new(0, wy, ww, wh)
@item_window.actor = @actor
@item_window.viewport = @viewport
@item_window.help_window = @help_window
@item_window.set_handler(:ok, method(:on_item_ok))
@item_window.set_handler(:cancel, method(:on_item_cancel))
@command_window.skill_window = @item_window
end
#--------------------------------------------------------------------------
# NewMethod: 物品“确定”
#--------------------------------------------------------------------------
def on_item_ok
Sound.play_equip
if @actor.skill_sealed?(item.id) || ActiveSkills::Skill_Stack_Level
@actor.skill_activate(item)
else; @actor.skill_deactivate(item); end
@status_window.refresh
@item_window.refresh
@item_window.activate
end
#--------------------------------------------------------------------------
# NewMethod: 更新画面
#--------------------------------------------------------------------------
def update
super
if ActiveSkills::Skill_Stack_Level && @item_window.active && Input.trigger?(:A)
if [email protected]_sealed?(item.id)
Sound.play_equip
@actor.skill_deactivate(item)
@status_window.refresh
@item_window.refresh
@item_window.activate
else; Sound.play_buzzer; end
end
end
end
我导入论坛里面大佬的这个后,出现了问题[attachimg]321031注释掉它后,它周围的代码出错,都注释掉后,其他地方又出错= =。
[/attachimg]https://rpg.blue/forum.php?mod=attachment&aid=MzIxMDMzfGRmNjU0ZTkzfDE3MzE3ODUzNDJ8MHw%3D |
|