| 赞 | 349 |
| VIP | |
| 好人卡 | |
| 积分 | 301 |
| 经验 | |
| 最后登录 | 2026-11-7 |
| 在线时间 | 2428 小时 |
遠航の猫咪
- 梦石
- 3
- 星屑
- 27057
- 在线时间
- 2428 小时
- 注册时间
- 2005-10-15
- 回帖
- 989

|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
本帖最后由 SailCat 于 2017-11-29 22:18 编辑
说明:
1. 本脚本分为几个模块,其中[装备增强系统核心]为必选模块,其他为可选模块,根据功能选择
2. 除了[装备增强系统核心]可以独立运行以外,其余模块均需要依赖[数据库通用备注接口]插件来运行
3. 本脚本的后续更新会按模块区分,请注意版本依赖
4. 所有可选模块均经过测试,保证本文中的最新版本不会互相冲突
0. 装备增强系统核心
功能:
修正原RGSS默认系统关于自动状态的bug,并作为其他装备增强的依赖插件版本历史v1.1
再次细分伤害计算式(应该不能更细了)
v1.0
初期版本
代码
1. 武器攻击特效
功能:
1. 武器攻击时可以引发技能(不消耗SP),用技能代替武器的攻击
2. 武器攻击力可以是浮动值,并且可以是负数,或者挂接角色和对象能力
3. 武器的命中率、必杀机率、必杀倍率、分散度可以如VA一样自行定义
4. 武器的攻击可以为攻击者增加或者解除状态
5. 武器可以攻击多次,可以攻击全体、全域或随机对象
6. 默认伤害公式中的参数自定,或者直接自定伤害公式
版本历史v1.1
修正了一些已知问题
v1.0
初期版本
代码- #==============================================================================
- # ■ 装备增强-武器攻击特效 v1.1 by SailCat
- #------------------------------------------------------------------------------
- # 方法:本脚本插入到Main之前使用,并依赖以下脚本:
- # 1. 数据库通用备注接口插件(2.0版以上,插入在其之后)
- # 2. 装备增强系统核心插件(1.1版以上,插入在其之后)
- # 3. 如果要使用复杂动画,需要战斗动画增强插件(插入在其之后)
- # 版本:v1.1 (Build 171129)
- # 效果:
- # 1. 武器攻击时可以引发技能(不消耗SP),用技能代替武器的攻击
- # 2. 武器攻击力可以是浮动值,并且可以是负数
- # 3. 武器的命中率、必杀机率、必杀倍率、分散度可以如VA一样自行定义
- # 4. 武器的攻击可以为攻击者增加或者解除状态
- # 5. 武器可以攻击多次,可以攻击全体、全域或随机对象
- # 配置:有一条配置项,用于动画显示效果,见下方脚本配置
- # 冲突:其他同类脚本
- # 说明:
- # 0. 以下备注均写在描述里,具体格式见依赖的通用备注接口插件相关说明
- # (当[XX集]内容只有一条时,方括号可省略)
- # (备注内容太多写不下时,可用超长备注法)
- # 1. 武器攻击引发技能:as=技能ID,默认为0(不引发技能)
- # 技能侧的对象侧动画设为无时,会用武器的对象侧动画设置自动覆盖播放
- # 2. 自定义攻击力:ak:攻击力公式
- # 攻击力公式的结果需为数值(如-52)或子界(如2..9)或集合(如[1,2,4,8])
- # 公式中可以用a、b、v、s分别代表攻击者、攻击对象、变量、开关
- # 若公式中包括对攻击对象的引用,则在战斗外显示攻击力时,以自己为假想对象
- # 3. 自定义命中率:aa=值,默认为100(RGSS预设)
- # 4. 自定义必杀机率:ac=值,默认为4(RGSS预设)
- # 5. 自定义必杀倍率:ab=值,默认为2(RGSS预设)
- # 6. 必杀时无视防御:ai
- # 7. 自定义分散度:av=值,默认为15(RGSS预设)
- # 8. 攻击时为攻击者附加状态:ap=[状态ID集]
- # 9. 攻击时为攻击者解除状态:am=[状态ID集]
- # 10.攻击多次:ah=值,默认为1
- # 11.攻击对象变更:al=0-11的值,其中,通常时:
- # 0:无效; 1:选定敌人单体;2:敌人全体; 3:选定我方单体
- # 4:我方全体; 5:我方HP0 单体;6:我方HP0全体;7:自己
- # 8:随机一名敌人;9:随机一名同伴;10:随机一人; 11:所有人
- # 在状态限制“普通攻击同伴”时:
- # 0:无效; 1:随机一名同伴;2:我方全体; 3:随机一名敌人
- # 4:敌人全体; 5:随机敌方HP0; 6:敌方HP0全体;7:自己
- # 8:随机一名同伴;9:随机一名敌人;10:随机一人; 11:所有人
- # 在状态限制“普通攻击敌人”时:
- # 0:无效; 1:随机一名敌人;2:敌人全体; 3:随机一名同伴
- # 4:我方全体; 5:随机我方HP0 ;6:我方HP0全体;7:自己
- # 8:随机一名敌人;9:随机一名同伴;10:随机一人; 11:所有人
- # 12.伤害公式自定义:af:伤害公式
- # 公式中可以用a、b、v、s分别代表攻击者、攻击对象、变量、开关
- # 伤害公式完全代替默认的伤害计算,攻击力公式还要再受防御、倍率的修正
- # 13.伤害倍率变更,若不定义伤害公式,则可以设定武器的伤害计算倍率:
- # 攻击力F:fk=值;防御力F:ff=值;魔防力F:fm=值;回避力F:fe=值
- # 力量F: fs=值;灵巧F: fd=值;速度F: fa=值;魔力F: fi=值
- #==============================================================================
- #==============================================================================
- # ■ SailCat's 插件公用
- #==============================================================================
- module SailCat
- $sailcat_import ||= {}
- #--------------------------------------------------------------------------
- # ● 脚本配置区
- #--------------------------------------------------------------------------
- module Equip_Config
- # 简化动画(多次攻击只播放1次动画)
- # 如果关闭(设为false),额外依赖战斗动画增强插件
- USE_SIMPLE_ANIMATION = false
- end
- #--------------------------------------------------------------------------
- # ● 植入与依赖检查
- #--------------------------------------------------------------------------
- dependency = []
- unless $sailcat_import[:DataNoteCore].to_f >= 2.0
- dependency.push "[DataNoteCore] 通用数据库备注接口(v2.0以上版本)"
- end
- unless $sailcat_import[:EquipCore] >= 1.1
- dependency.push "[EquipCore] 装备增强系统核心(v1.1以上版本)"
- end
- unless Equip_Config::USE_SIMPLE_ANIMATION
- unless $sailcat_import[:BattleAnimation] >= 1.0
- dependency.push "[BattleAnimation] 战斗动画增强(v1.0以上版本)"
- end
- end
- raise "缺少依赖插件:\n" + dependency.join("\n") unless dependency.empty?
- $sailcat_import[:EquipWeaponEffect] = 1.0
- end
- module RPG
- #============================================================================
- # ■ RPG::Weapon
- #----------------------------------------------------------------------------
- # 数据库的武器类扩展
- #============================================================================
- class Weapon
- #--------------------------------------------------------------------------
- # ● 备注定义
- #--------------------------------------------------------------------------
- def attack_skill; _as(0); end
- def atk_formula; _ak("@atk"); end
- def hit; _aa(100); end
- def critical_rate; _ac(4); end
- def critical_fold; _ab(2); end
- def critical_pierce; _ai(false); end
- def variance; _av(15); end
- def plus_state_self; flat_array(_ap([])); end
- def minus_state_self; flat_array(_am([])); end
- def hit_count; _ah(1); end
- def scope; _al(1); end
- def damage_formula; _af(nil); end
- def atk_f; _fk(100); end
- def pdef_f; _ff(100); end
- def mdef_f; _fm(0); end
- def eva_f; _fe(100); end
- def str_f; _fs(100); end
- def dex_f; _fd(0); end
- def agi_f; _fa(0); end
- def int_f; _fi(0); end
- #--------------------------------------------------------------------------
- # ● 攻击力
- #--------------------------------------------------------------------------
- def atk(actor = nil, target = nil, fix = nil)
- f = lambda {|a, b, s, v| eval(atk_formula) rescue @atk}
- result = f.call(actor, target || actor, $game_switches, $game_variables)
- # 子界的情况下,返回子界范围中一个随机值
- if result.is_a?(Range)
- min = result.first
- max = result.exclude_end? ? result.last - 1: result.last
- return min + Integer((max - min) * fix) if fix
- return min + Integer(rand(max - min + 1))
- # 数组的情况下,返回数组中一个随机值
- elsif result.is_a?(Array)
- return result[0].to_i if result.size == 1
- return result.sort[Integer((result.size - 1) * fix)].to_i if fix
- return result[rand(result.size)].to_i
- # 数值的情况下,返回原值
- else
- return result.to_i
- end
- end
- #--------------------------------------------------------------------------
- # ● 伤害
- #--------------------------------------------------------------------------
- def eval_damage(actor, target)
- result = lambda {|a, b, s, v| eval(damage_formula) rescue 0}
- result.call(actor, target, $game_switches, $game_variables)
- end
- end
- end
- #==============================================================================
- # ■ Game_Actor
- #==============================================================================
- class Game_Actor
- #--------------------------------------------------------------------------
- # ● 获取基本攻击力
- #--------------------------------------------------------------------------
- def base_atk(other = self)
- fix = $game_temp.in_battle ? nil : 0.5
- current_weapon ? current_weapon.atk(self, other, fix) : 0
- end
- #--------------------------------------------------------------------------
- # ● 获取实际攻击力
- #--------------------------------------------------------------------------
- def atk(other = self)
- n = @states.inject(base_atk(other)) do |v, i|
- v *= $data_states[i].atk_rate / 100.0
- end
- return Integer(n)
- end
- #--------------------------------------------------------------------------
- # ● 获取命中率
- #--------------------------------------------------------------------------
- def hit
- n = current_weapon ? current_weapon.hit : 100
- for i in @states
- n *= $data_states[i].hit_rate / 100.0
- end
- return Integer(n)
- end
- #--------------------------------------------------------------------------
- # ● 获取必杀机率
- #--------------------------------------------------------------------------
- def critical_rate
- current_weapon ? current_weapon.critical_rate : super
- end
- #--------------------------------------------------------------------------
- # ● 获取必杀倍率
- #--------------------------------------------------------------------------
- def critical_fold
- current_weapon ? current_weapon.critical_fold : super
- end
- #--------------------------------------------------------------------------
- # ● 获取必杀忽略防御
- #--------------------------------------------------------------------------
- def critical_pierce
- current_weapon ? current_weapon.critical_pierce : false
- end
- #--------------------------------------------------------------------------
- # ● 获取攻击次数
- #--------------------------------------------------------------------------
- def hit_count
- current_weapon ? current_weapon.hit_count : super
- end
- #--------------------------------------------------------------------------
- # ● 获取分散度
- #--------------------------------------------------------------------------
- def variance
- current_weapon ? current_weapon.variance : super
- end
- #--------------------------------------------------------------------------
- # ● 获取攻击范围
- #--------------------------------------------------------------------------
- def attack_scope
- current_weapon ? [[current_weapon.scope, 11].min, 0].max : 1
- end
- #--------------------------------------------------------------------------
- # ● 获取攻击力F
- #--------------------------------------------------------------------------
- def atk_f
- current_weapon ? current_weapon.atk_f : super
- end
- #--------------------------------------------------------------------------
- # ● 获取防御力F
- #--------------------------------------------------------------------------
- def pdef_f
- current_weapon ? current_weapon.pdef_f : super
- end
- #--------------------------------------------------------------------------
- # ● 获取魔防力F
- #--------------------------------------------------------------------------
- def mdef_f
- current_weapon ? current_weapon.mdef_f : super
- end
- #--------------------------------------------------------------------------
- # ● 获取力量F
- #--------------------------------------------------------------------------
- def str_f
- current_weapon ? current_weapon.str_f : super
- end
- #--------------------------------------------------------------------------
- # ● 获取灵巧F
- #--------------------------------------------------------------------------
- def dex_f
- current_weapon ? current_weapon.dex_f : super
- end
- #--------------------------------------------------------------------------
- # ● 获取速度F
- #--------------------------------------------------------------------------
- def agi_f
- current_weapon ? current_weapon.agi_f : super
- end
- #--------------------------------------------------------------------------
- # ● 获取魔力F
- #--------------------------------------------------------------------------
- def int_f
- current_weapon ? current_weapon.int_f : super
- end
- #--------------------------------------------------------------------------
- # ● 获取回避F
- #--------------------------------------------------------------------------
- def eva_f
- current_weapon ? current_weapon.eva_f : super
- end
- #--------------------------------------------------------------------------
- # ● 获取普通攻击对自己的状态变化(+)
- #--------------------------------------------------------------------------
- def plus_state_self
- current_weapon ? current_weapon.plus_state_self : []
- end
- #--------------------------------------------------------------------------
- # ● 获取普通攻击对自己的状态变化(-)
- #--------------------------------------------------------------------------
- def minus_state_self
- current_weapon ? current_weapon.minus_state_self : []
- end
- #--------------------------------------------------------------------------
- # ● 自定义公式判定
- #--------------------------------------------------------------------------
- def attack_formula_set?
- current_weapon ? current_weapon.damage_formula != nil : false
- end
- end
- #==============================================================================
- # ■ Game_Battler
- #==============================================================================
- class Game_Battler
- include SailCat::Equip_Config
- #--------------------------------------------------------------------------
- # ● 方法重定义
- #--------------------------------------------------------------------------
- unless method_defined?(:sailcat_equipwe_attack_effect)
- alias sailcat_equipwe_attack_effect attack_effect
- alias sailcat_equipwe_pre_attack pre_attack
- alias sailcat_equipwe_post_attack post_attack
- alias sailcat_equipwe_calculate_attack_damage calculate_attack_damage
- alias sailcat_equipwe_calculate_attack_basic_atk calculate_attack_basic_atk
- alias sailcat_equipwe_calculate_attack_basic_def calculate_attack_basic_def
- alias sailcat_equipwe_calculate_attack_critical calculate_attack_critical
- alias sailcat_equipwe_apply_hit apply_hit
- alias sailcat_equipwe_post_attack post_attack
- end
- #--------------------------------------------------------------------------
- # ● 应用通常攻击效果
- # attacker : 攻击者 (battler)
- #--------------------------------------------------------------------------
- def attack_effect(attacker)
- # 攻击者是敌人的情况下
- if attacker.enemy?
- # 调用原来的方法
- return sailcat_equipwe_attack_effect(attacker)
- end
- # 攻击预处理
- pre_attack(attacker)
- weapon = attacker.current_weapon
- # 武器可以攻击多次的情况下
- attacker.hit_count.times do
- # 清除会心一击标志
- self.critical = false
- # 取得动画ID
- animation2_id = attacker.animation2_id
- # 攻击会引发技能的情况下
- if weapon and (skill = $data_skills[weapon.attack_skill]) != nil
- # 调用技能的效果
- skill_effect(attacker, skill)
- # 修正动画为技能的动画
- if skill.animation2_id > 0
- animation2_id = $scene.animation2_id = skill.animation2_id
- end
- else
- # 执行普通攻击效果
- perform_attack(attacker)
- end
- # 记录伤害
- record_damage
- # 如果不使用简单动画,追加动画效果
- pend_animation(animation2_id) unless USE_SIMPLE_ANIMATION
- end
- # 攻击后续处理
- post_attack(attacker)
- # 过程结束
- return true
- end
- #--------------------------------------------------------------------------
- # ● 攻击准备
- # attacker : 攻击者 (battler)
- #--------------------------------------------------------------------------
- def pre_attack(attacker)
- sailcat_equipwe_pre_attack(attacker)
- if attacker.actor?
- @total_damage = 0
- @total_missed = true
- @total_critical = false
- end
- end
- #--------------------------------------------------------------------------
- # ● 记录伤害
- #--------------------------------------------------------------------------
- def record_damage
- return if self.damage == "Miss"
- @total_missed = false
- @total_critical |= self.critical
- @total_damage += self.damage if self.damage.is_a?(Numeric)
- end
- #--------------------------------------------------------------------------
- # ● 攻击收尾
- # attacker : 攻击者 (battler)
- #--------------------------------------------------------------------------
- def post_attack(attacker)
- sailcat_equipwe_post_attack(attacker)
- if attacker.actor?
- self.damage = @total_missed ? "Miss" : @total_damage
- self.critical = @total_critical
- end
- end
- #--------------------------------------------------------------------------
- # ● 计算攻击伤害
- # attacker : 攻击者 (battler)
- #--------------------------------------------------------------------------
- def calculate_attack_damage(attacker)
- if attacker.actor? and attacker.attack_formula_set?
- self.damage = attacker.current_weapon.eval_damage(attacker, self)
- calculate_attack_modifier(attacker)
- else
- sailcat_equipwe_calculate_attack_damage(attacker)
- end
- end
- #--------------------------------------------------------------------------
- # ● 攻击者的攻击力
- # attacker : 攻击者 (battler)
- #--------------------------------------------------------------------------
- def calculate_attack_basic_atk(attacker)
- if attacker.actor?
- self.damage = attacker.atk(self) * attacker.atk_f / 100
- else
- sailcat_equipwe_calculate_attack_basic_atk(attacker)
- end
- end
- #--------------------------------------------------------------------------
- # ● 攻击对象的防御力
- # attacker : 攻击者 (battler)
- #--------------------------------------------------------------------------
- def calculate_attack_basic_def(attacker)
- if self.damage > 0
- # 如果攻击者会心无视防御
- if attacker.actor? and attacker.critical_pierce
- # 提前判定会心
- if judge_critical(attacker)
- self.damage *= attacker.critical_fold
- self.critical = true
- end
- end
- # 不是无视防御或判定不成功时
- unless self.critical
- self.damage -= self.pdef * attacker.pdef_f / 200
- self.damage -= self.mdef * attacker.mdef_f / 200
- self.damage = [self.damage, 0].max
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 计算会心修正
- # attacker : 攻击者 (battler)
- #--------------------------------------------------------------------------
- def calculate_attack_critical(attacker)
- # 已经先行判定过的情况下,返回
- return if attacker.actor? and attacker.critical_pierce
- if self.damage > 0 and judge_critical(attacker)
- self.damage *= attacker.critical_fold
- self.critical = true
- end
- end
- #--------------------------------------------------------------------------
- # ● 应用击中结果
- # attacker : 攻击者 (battler)
- #--------------------------------------------------------------------------
- def apply_hit(attacker)
- sailcat_equipwe_apply_hit(attacker)
- # 攻击者对自身的状态变化
- if attacker.actor?
- attacker.states_plus(attacker.plus_state_self)
- attacker.states_minus(attacker.minus_state_self)
- end
- end
- end
- #==============================================================================
- # ■ Scene_Battle
- #==============================================================================
- class Scene_Battle
- include SailCat::Equip_Config
- #--------------------------------------------------------------------------
- # ● 方法重定义
- #--------------------------------------------------------------------------
- unless method_defined?(:sailcat_equipwe_start_enemy_select)
- alias sailcat_equipwe_start_enemy_select start_enemy_select
- alias sailcat_equipwe_make_basic_action_result make_basic_action_result
- end
- #--------------------------------------------------------------------------
- # ● 开始选择敌人
- #--------------------------------------------------------------------------
- def start_enemy_select
- # 当前动作是普通攻击的情况下
- if @active_battler.current_action.kind == 0 and
- @active_battler.current_action.basic == 0
- # 检查攻击范围
- case @active_battler.attack_scope
- # 敌单体
- when 1
- return sailcat_equipwe_start_enemy_select
- # 我单体
- when 3, 5
- return start_actor_select
- # 其他不需要选择的情况
- else
- return phase3_next_actor
- end
- end
- sailcat_equipwe_start_enemy_select
- end
- #--------------------------------------------------------------------------
- # ● 生成基本行动结果
- #--------------------------------------------------------------------------
- def make_basic_action_result
- # 当前行动者是角色的情况下
- if @active_battler.actor?
- # 当前动作是普通攻击的情况下
- if @active_battler.current_action.basic == 0
- @animation1_id = @active_battler.animation1_id
- @animation2_id = @active_battler.animation2_id
- set_attack_target_battlers(@active_battler.attack_scope)
- # 应用通常攻击效果
- return @target_battlers.each {|t| t.attack_effect(@active_battler)}
- end
- end
- sailcat_equipwe_make_basic_action_result
- end
- #--------------------------------------------------------------------------
- # ● 生成攻击的对象侧集合
- # scope : 攻击范围
- #--------------------------------------------------------------------------
- def set_attack_target_battlers(scope)
- # 限制为“普通攻击同伴”的情况下
- if @active_battler.restriction == 3
- # 所有分敌我的范围反转
- case scope
- when 1
- scope = 9
- when 2, 4
- scope = 6 - scope
- when 3
- scope = 8
- when 5, 6
- scope = scope + 7
- when 8, 9
- scope = 17 - scope
- end
- # 限制为“普通攻击敌人”的情况下
- elsif @active_battler.restriction == 2
- # 所有需选择的范围改成随机
- case scope
- when 1
- scope = 8
- when 3
- scope = 9
- when 5
- scope = 14
- end
- end
- # 取得选择的目标
- index = @active_battler.current_action.target_index
- case scope
- when 0 # 无效
- @target_battlers = []
- when 1 # 选定敌单体
- @target_battlers = [$game_troop.smooth_target_enemy(index)]
- when 2 # 敌全体
- @target_battlers = $game_troop.enemies.select {|e| e.exist?}
- when 3 # 选定我单体
- @target_battlers = [$game_party.smooth_target_actor(index)]
- when 4 # 我全体
- @target_battlers = $game_party.actors.select {|a| a.exist?}
- when 5 # 选定我单体HP0
- actor = $game_party.actors[index]
- @target_battlers = (actor and actor.hp0?) ? [actor] : []
- when 6 # 我全体HP0
- @target_battlers = $game_party.actors.select {|a| a && a.hp0?}
- when 7 # 自己
- @target_battlers = [@active_battler]
- when 8 # 随机敌单体
- @target_battlers = [$game_troop.random_target_enemy]
- when 9 # 随机我单体
- @target_battlers = [$game_party.random_target_actor]
- when 10 # 随机一人
- ts = ($game_party.actors + $game_troop.enemies).reject {|t| !t.exist?}
- @target_battlers = ts.size > 1 ? [ts[rand(ts.size)]] : ts
- when 11 # 所有人
- @target_battlers = $game_party.actors + $game_troop.enemies
- @target_battlers.reject! {|t| !t.exist?}
- when 12 # 随机敌单体HP0
- @target_battlers = [$game_troop.random_target_enemy_hp0]
- when 13 # 敌全体HP0
- @target_battlers = $game_troop.enemies.select {|e| e && e.hp0?}
- when 14 # 随机我单体HP0
- @target_battlers = [$game_party.random_target_actor_hp0]
- end
- # 如果有攻击自己的情况,放在最后处理
- @target_battlers.sort! {|a, b| b == @active_battler ? -1 : 0}
- end
- end
复制代码
2. 武器攻击消耗
功能:
1.武器消耗游戏数据
2.武器攻击僵直版本历史v1.0
初期版本
代码- #==============================================================================
- # ■ 装备增强-武器攻击消耗 v1.0 by SailCat
- #------------------------------------------------------------------------------
- # 方法:本脚本插入到Main之前使用,并依赖以下脚本:
- # 1. 数据库通用备注接口插件(2.0版以上,插入在其之后)
- # 2. 装备增强系统核心插件(1.1版以上,插入在其之后)
- # 版本:v1.0 (Build 171126)
- # 效果:
- # 1. 武器攻击时消耗游戏数据,如HP、SP、EXP、道具、武器、防具、金钱、变量
- # 2. 武器攻击消耗额外的回合,即攻击僵直
- # 3. 消耗时会有检查,如果消耗不够,攻击无法进行(HP和EXP不检查)
- # 配置:插件为即插即用型,没有任何配置项,也不需要在脚本中设定任何东西
- # 冲突:其他同类脚本
- # 说明:
- # 0. 备注均写在描述里,具体格式见依赖的通用备注接口插件相关说明
- # (当[XX集]内容只有一条时,方括号可省略)
- # (条件太多写不下时,可用超长备注法)
- # 1. 消耗 HP :ch=值,接受负数(攻击回复HP),如果不够消耗,攻击后会死亡
- # 2. 消耗 SP :cs=值,接受负数(攻击回复SP)
- # 3. 消耗道具:ci=[道具ID集],写4或4.01消耗4号道具1个,4.05即4号道具5个
- # 写成4.00表示要求持有4号道具但不会消耗
- # 4. 消耗武器:cw=[武器ID集],说明同上,写作0表示消耗自身(一次性武器)
- # 5. 消耗防具:ca=[防具ID集],说明同上
- # 6. 消耗金钱:cg=值,接受负数(攻击获得金钱)
- # 7. 消耗经验:cx=值,接受负数(攻击获得经验),如果不够消耗,经验归零
- # 8. 消耗变量:cv={变量ID=>消耗值},写成hash形式,不能省略花括号
- # 若消耗值为负数,则攻击会积累这个变量的数值
- # 9. 消耗回合:cd=值,之后X回合内,“攻击”指令不能使用
- #==============================================================================
- #==============================================================================
- # ■ SailCat's 插件公用
- #==============================================================================
- module SailCat
- $sailcat_import ||= {}
- #--------------------------------------------------------------------------
- # ● 植入与依赖检查
- #--------------------------------------------------------------------------
- dependency = []
- unless $sailcat_import[:DataNoteCore].to_f >= 2.0
- dependency.push "[DataNoteCore] 通用数据库备注接口(v2.0以上版本)"
- end
- unless $sailcat_import[:EquipCore] >= 1.1
- dependency.push "[EquipCore] 装备增强系统核心(v1.1以上版本)"
- end
- raise "缺少依赖插件:\n" + dependency.join("\n") unless dependency.empty?
- $sailcat_import[:EquipWeaponCost] = 1.0
- end
- module RPG
- #============================================================================
- # ■ Equip_ItemCost
- #----------------------------------------------------------------------------
- # 处理消耗道具、武器、防具的内部类
- #============================================================================
- class Equip_ItemCost
- #--------------------------------------------------------------------------
- # ● 定义实例变量
- #--------------------------------------------------------------------------
- attr_accessor :id # 消耗的物品ID
- attr_accessor :number # 消耗的数目
- #--------------------------------------------------------------------------
- # ● 初期化
- #--------------------------------------------------------------------------
- def initialize(n)
- n = 0 unless n.is_a?(Numeric)
- n += 0.01 if n.is_a?(Fixnum)
- @id = Integer(n).abs
- @number = [Integer((n - @id) * 100.0 + 1e-6), 0].max
- end
- #--------------------------------------------------------------------------
- # ● 检查符合性
- #--------------------------------------------------------------------------
- def match?(proc)
- return true if @id == 0
- proc.call(@id) >= [@number, 1].max
- end
- end
- #============================================================================
- # ■ RPG::Weapon
- #----------------------------------------------------------------------------
- # 数据库的武器类扩展
- #============================================================================
- class Weapon
- #--------------------------------------------------------------------------
- # ● 备注定义
- #--------------------------------------------------------------------------
- def hp_cost; _ch(0); end
- def sp_cost; _cs(0); end
- def exp_cost; _cx(0).abs; end
- def gold_cost; _cg(0); end
- def cooldown; _cd(0).abs; end
- def variable_cost; _cv({}); end
- def item_cost; _ci([]).to_a.map {|f| Equip_ItemCost.new(f)}; end
- def weapon_cost; _cw([]).to_a.map {|f| Equip_ItemCost.new(f)}; end
- def armor_cost; _ca([]).to_a.map {|f| Equip_ItemCost.new(f)}; end
- #--------------------------------------------------------------------------
- # ● 变量消耗判定
- #--------------------------------------------------------------------------
- def variable_match?
- variable_cost.each do |k, v|
- return false if $game_variables[k] < v
- end
- return true
- end
- #--------------------------------------------------------------------------
- # ● 道具消耗判定
- #--------------------------------------------------------------------------
- def item_match?(set, proc)
- set.each do |s|
- return false unless s.match?(proc)
- end
- return true
- end
- end
- end
- #==============================================================================
- # ■ Game_Actor
- #==============================================================================
- class Game_Actor
- #--------------------------------------------------------------------------
- # ● 方法重定义
- #--------------------------------------------------------------------------
- unless method_defined?(:sailcat_equipwc_skill_can_use?)
- alias sailcat_equipwc_skill_can_use? skill_can_use?
- end
- #--------------------------------------------------------------------------
- # ● 定义实例变量
- #--------------------------------------------------------------------------
- attr_reader :attack_cooldown # 攻击僵直回合数
- #--------------------------------------------------------------------------
- # ● 攻击僵直判定
- #--------------------------------------------------------------------------
- def attack_cooldown?
- @attack_cooldown > 0
- end
- #--------------------------------------------------------------------------
- # ● 重置攻击僵直
- #--------------------------------------------------------------------------
- def reset_attack_cooldown
- @attack_cooldown = 0
- end
- #--------------------------------------------------------------------------
- # ● 设置攻击僵直
- # turn : 僵直回合数
- #--------------------------------------------------------------------------
- def set_attack_cooldown(turn)
- @attack_cooldown = [@attack_cooldown, turn].max
- end
- #--------------------------------------------------------------------------
- # ● 更新攻击僵直,该方法一回合调用一次
- #--------------------------------------------------------------------------
- def update_attack_cooldown
- @attack_cooldown -= 1 if @attack_cooldown > 0
- end
- #--------------------------------------------------------------------------
- # ● 攻击有效判定
- #--------------------------------------------------------------------------
- def attack_check?
- # 战斗不能的情况下,攻击无效
- if dead?
- return false
- # 强制行动的情况下,攻击有效
- elsif current_action.forcing
- return true
- # 僵直中不能动弹的情况下,攻击无效
- elsif not movable? or attack_cooldown?
- return false
- # 空手的情况下,攻击有效
- elsif current_weapon == nil
- return true
- # 道具不够的情况下,攻击无效
- elsif not current_weapon.item_match?(current_weapon.item_cost,
- Proc.new{|n| $game_party.item_number(n)})
- return false
- # 武器不够的情况下,攻击无效
- elsif not current_weapon.item_match?(current_weapon.weapon_cost,
- Proc.new{|n| $game_party.weapon_number(n)})
- return false
- # 防具不够的情况下,攻击无效
- elsif not current_weapon.item_match?(current_weapon.armor_cost,
- Proc.new{|n| $game_party.armor_number(n)})
- return false
- # 金钱不够的情况下,攻击无效
- elsif $game_party.gold < current_weapon.gold_cost
- return false
- # 变量不够的情况下,攻击无效
- elsif not current_weapon.variable_match?
- return false
- # SP 不够的情况下,攻击无效
- elsif @sp < current_weapon.sp_cost
- return false
- end
- # 攻击有效
- return true
- end
- #--------------------------------------------------------------------------
- # ● 执行攻击消耗
- #--------------------------------------------------------------------------
- def perform_attack_cost
- return if current_weapon == nil
- weapon = current_weapon
- self.hp -= weapon.hp_cost
- self.sp -= weapon.sp_cost
- self.exp -= weapon.exp_cost
- $game_party.lose_gold(weapon.gold_cost)
- weapon.item_cost.each {|i| $game_party.lose_item(i.id, i.number)}
- weapon.weapon_cost.each {|i| $game_party.lose_weapon(i.id, i.number)}
- weapon.armor_cost.each {|i| $game_party.lose_armor(i.id, i.number)}
- weapon.variable_cost.each_pair {|k, v| $game_variables[k] -= v}
- unless weapon.weapon_cost.select {|i| i.id == 0}.empty?
- if $game_party.weapon_number(weapon.id) == 0
- equip(-all_weapons.index(weapon), 0)
- end
- $game_party.lose_weapon(weapon.id, 1)
- end
- set_attack_cooldown(weapon.cooldown)
- end
- #--------------------------------------------------------------------------
- # ● 可以使用特技判定
- # skill_id : 特技 ID
- #--------------------------------------------------------------------------
- def skill_can_use?(skill_id)
- # 技能有效的情况下
- if $data_skills[skill_id] and $game_temp.in_battle
- # 技能需要用到武器,但是僵直中的情况下
- if $data_skills[skill_id].atk_f > 0 and attack_cooldown?
- # 不能使用
- return false
- end
- end
- # 原始判定
- return sailcat_equipwc_skill_can_use?(skill_id)
- end
- end
- #==============================================================================
- # ■ Game_Party
- #==============================================================================
- class Game_Party
- #--------------------------------------------------------------------------
- # ● 清除攻击僵直
- #--------------------------------------------------------------------------
- def reset_attack_cooldown
- actors.each {|a| a.reset_attack_cooldown}
- end
- #--------------------------------------------------------------------------
- # ● 更新攻击僵直,该方法一回合调用一次
- #--------------------------------------------------------------------------
- def update_attack_cooldown
- actors.each {|a| a.update_attack_cooldown}
- end
- end
- #==============================================================================
- # ■ Game_Battler
- #==============================================================================
- class Game_Battler
- #--------------------------------------------------------------------------
- # ● 方法重定义
- #--------------------------------------------------------------------------
- unless method_defined?(:sailcat_equipwc_pre_attack)
- alias sailcat_equipwc_post_attack post_attack
- end
- #--------------------------------------------------------------------------
- # ● 攻击判定
- # attacker : 攻击者 (battler)
- #--------------------------------------------------------------------------
- def judge_attack(attacker)
- attacker.actor? ? attacker.attack_check? : true
- end
- #--------------------------------------------------------------------------
- # ● 攻击收尾
- # attacker : 攻击者 (battler)
- #--------------------------------------------------------------------------
- def post_attack(attacker)
- sailcat_equipwc_post_attack(attacker)
- # 不是强制行动的情况下,执行攻击消耗
- if attacker.actor? and not attacker.current_action.forcing
- attacker.perform_attack_cost
- end
- end
- end
- #==============================================================================
- # ■ Scene_Battle
- #==============================================================================
- class Scene_Battle
- #--------------------------------------------------------------------------
- # ● 方法重定义
- #--------------------------------------------------------------------------
- unless method_defined? :sailcat_equipwc_start_phase1
- alias sailcat_equipwc_start_phase1 start_phase1
- alias sailcat_equipwc_start_phase4 start_phase4
- alias sailcat_equipwc_setup_command_window phase3_setup_command_window
- alias sailcat_equipwc_update_basic_command update_phase3_basic_command
- end
- #--------------------------------------------------------------------------
- # ● 开始自由战斗回合
- #--------------------------------------------------------------------------
- def start_phase1
- sailcat_equipwc_start_phase1
- # 清除攻击僵直
- $game_party.reset_attack_cooldown
- end
- #--------------------------------------------------------------------------
- # ● 开始主回合
- #--------------------------------------------------------------------------
- def start_phase4
- sailcat_equipwc_start_phase4
- # 更新攻击僵直
- $game_party.update_attack_cooldown
- end
- #--------------------------------------------------------------------------
- # ● 设置角色指令窗口
- #--------------------------------------------------------------------------
- def phase3_setup_command_window
- sailcat_equipwc_setup_command_window
- # 如果不能攻击就把攻击指令无效化
- if @active_battler.attack_check?
- normal_color = @actor_command_window.normal_color
- @actor_command_window.draw_item(0, normal_color)
- else
- @actor_command_window.disable_item(0)
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面 (角色命令回合 : 基本命令)
- #--------------------------------------------------------------------------
- def update_phase3_basic_command
- if Input.trigger?(Input::C)
- # 攻击指令无效的情况下
- if @actor_command_window.index == 0 and not @active_battler.attack_check?
- # 演奏冻结 SE
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- end
- sailcat_equipwc_update_basic_command
- end
- end
复制代码
3. 装备附带技能
功能:
1.装备给予、封印技能的使用可能
2.装备辅助技能的学习版本历史v1.0
初期版本
代码- #==============================================================================
- # ■ 装备附带技能 v1.0 by SailCat
- #------------------------------------------------------------------------------
- # 方法:本脚本插入到Main之前使用,并依赖以下脚本:
- # 1. 数据库通用备注接口插件(2.0版以上,插入在其之后)
- # 2. 装备增强系统核心插件(1.1版以上,插入在其之后)
- # 版本:v1.0 (Build 171126)
- # 效果:
- # 1. 武器和防具装上后可以使用其附带的技能,卸下就不能再使用
- # 2. 附带技能不影响技能的学习,如果装上后再学会此技能,卸下也不会忘却
- # 3. 武器和防具装上后可以帮助角色学习该附带技能
- # 4. 武器和防具也可以封印技能
- # 配置:插件为即插即用型,没有任何配置项,也不需要在脚本中设定任何东西
- # 冲突:其他同类脚本
- # 说明:
- # 0. 备注均写在描述里,具体格式见依赖的通用备注接口插件相关说明
- # (当[XX集]内容只有一条时,方括号可省略)
- # (条件太多写不下时,可用超长备注法)
- # 1. 武器和防具的附带技能:qs=[技能ID集]
- # 技能ID写成整数,表示附带这个技能,没有其他效果
- # 技能ID写成小数,则小数点后三位有特殊含义(以下xx取值01-99,省略为01)
- # .0xx,用附带技能XX次后永久习得这个技能
- # .1xx,用附带技能命中XX个战斗者后永久习得这个技能
- # .2xx,用附带技能击杀XX个战斗者后永久习得这个技能
- # .3xx,使用该装备战斗胜利XX次后永久习得这个技能
- # .4xx,使用该装备战斗逃跑XX次后永久习得这个技能
- # .5xx,使用该装备战斗失败XX次后永久习得这个技能
- # .6xx,使用该装备战斗XX回合后永久习得这个技能
- # 技能ID写成负数,表示装备会封印这个技能,注意写成负小数的话小数部分无效
- #==============================================================================
- #==============================================================================
- # ■ SailCat's 插件公用
- #==============================================================================
- module SailCat
- $sailcat_import ||= {}
- #--------------------------------------------------------------------------
- # ● 植入与依赖检查
- #--------------------------------------------------------------------------
- dependency = []
- unless $sailcat_import[:DataNoteCore].to_f >= 2.0
- dependency.push "[DataNoteCore] 通用数据库备注接口(v2.0以上版本)"
- end
- unless $sailcat_import[:EquipCore] >= 1.1
- dependency.push "[EquipCore] 装备增强系统核心(v1.1以上版本)"
- end
- raise "缺少依赖插件:\n" + dependency.join("\n") unless dependency.empty?
- $sailcat_import[:EquipWithSkill] = 1.0
- end
- module RPG
- #============================================================================
- # ■ Equip_Skill
- #----------------------------------------------------------------------------
- # 处理装备附带技能的内部类
- #============================================================================
- class Equip_Skill
- #--------------------------------------------------------------------------
- # ● 定义实例变量
- #--------------------------------------------------------------------------
- attr_accessor :skill_id # 附带的技能ID
- attr_accessor :trigger_type # 永久习得所需的类型
- attr_accessor :trigger_count # 永久习得所需的次数
- #--------------------------------------------------------------------------
- # ● 初期化
- #--------------------------------------------------------------------------
- def initialize(n)
- n = 0 unless n.is_a?(Numeric)
- if n.is_a?(Fixnum)
- @skill_id = n.abs
- @trigger_type = n > 0 ? 0 : -1
- @trigger_count = 0
- else
- @skill_id = Integer(n.abs)
- if n < 0
- @trigger_type = -1
- @trigger_count = 0
- else
- n = n.abs
- @trigger_type = [Integer((n - @skill_id) * 10 + 1e-6), 6].min
- @trigger_count = [Integer((n - @skill_id) * 1e3 + 1e-6) % 100, 1].max
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 判定
- #--------------------------------------------------------------------------
- def add?; @trigger_type >= 0; end
- def seal?; @trigger_type < 0; end
- def learn?; @trigger_count > 0; end
- end
- #============================================================================
- # ■ RPG::Weapon
- #----------------------------------------------------------------------------
- # 数据库的武器类扩展
- #============================================================================
- class Weapon
- #--------------------------------------------------------------------------
- # ● 备注定义
- #--------------------------------------------------------------------------
- def skills; _qs([]).to_a.map {|f| Equip_Skill.new(f)}; end
- def skills_add; skills.select {|s| s.add?}.map {|s| s.skill_id}; end
- def skills_seal; skills.select {|s| s.seal?}.map {|s| s.skill_id}; end
- def skills_learn; skills.select {|s| s.learn?}; end
- end
- #============================================================================
- # ■ RPG::Armor
- #----------------------------------------------------------------------------
- # 数据库的防具类扩展
- #============================================================================
- class Armor
- #--------------------------------------------------------------------------
- # ● 备注定义
- #--------------------------------------------------------------------------
- def skills; _qs([]).to_a.map {|f| Equip_Skill.new(f)}; end
- def skills_add; skills.select {|s| s.add?}.map {|s| s.skill_id}; end
- def skills_seal; skills.select {|s| s.seal?}.map {|s| s.skill_id}; end
- def skills_learn; skills.select {|s| s.learn?}; end
- end
- end
- #==============================================================================
- # ■ Game_Actor
- #==============================================================================
- class Game_Actor
- #--------------------------------------------------------------------------
- # ● 定义实例变量
- #--------------------------------------------------------------------------
- attr_reader :equip_learn # 来自装备的习得进度
- #--------------------------------------------------------------------------
- # ● 方法重定义
- #--------------------------------------------------------------------------
- unless method_defined?(:sailcat_equipws_post_setup)
- alias sailcat_equipws_post_setup post_setup
- alias sailcat_equipws_equip equip
- alias sailcat_equipws_skill_can_use? skill_can_use?
- end
- #--------------------------------------------------------------------------
- # ● 后续处理内容
- #--------------------------------------------------------------------------
- def post_setup
- sailcat_equipws_post_setup
- @equip_learn = {}
- update_learn_skill_by_equip
- end
- #--------------------------------------------------------------------------
- # ● 更新装备习得技能
- # items : 要更新的装备
- #--------------------------------------------------------------------------
- def update_learn_skill_by_equip(items = self.equipment)
- # 循环所有装备的可习得技能
- items.each do |e|
- e.skills_learn.each do |s|
- # 已学会的情况下继续
- next if skill_learn?(s.skill_id, true)
- # 目前习得清单里没有的情况下
- if not @equip_learn.has_key?(s)
- @equip_learn[s.skill_id] = {s.trigger_type => s.trigger_count}
- # 已有的话,加入这种习得方式
- elsif @equip_learn[s.skill_id].has_key?(s.trigger_type)
- @equip_learn[s.skill_id][s.trigger_type] = s.trigger_count
- # 习得方式存在的情况下,更新进度
- else
- v = @equip_learn[s.skill_id][s.trigger_type]
- @equip_learn[s.skill_id][s.trigger_type] = [s.trigger_count, v].min
- end
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 更新习得进度
- # type : 习得方式
- # skill_id : 技能ID
- #--------------------------------------------------------------------------
- def update_equip_learning(type, skill_id = -1)
- # 获得以此种方式可更新的技能列表
- learn_set = equipment.map {|e| e.skills_learn}.flatten
- learn_set.reject! {|s| s.skill_id != skill_id} if skill_id > -1
- learn_set.select {|s| s.trigger_type == type}.each do |s|
- # 如果装备习得列表里有这个技能(未学会)
- if @equip_learn.has_key?(s.skill_id)
- # 更新进度
- @equip_learn[s.skill_id][s.trigger_type] -= 1
- # 进度已满时,习得技能
- if @equip_learn[s.skill_id][s.trigger_type] == 0
- learn_skill(s.skill_id)
- @equip_learn.delete(s.skill_id)
- end
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 变更装备
- # equip_type : 装备类型
- # id : 武器 or 防具 ID (0 为解除装备)
- #--------------------------------------------------------------------------
- def equip(equip_type, id)
- sailcat_equipws_equip(equip_type, id)
- # 装备有效的情况下
- item = equip_type >= 1 ? $data_armors[id] : $data_weapons[id]
- update_learn_skill_by_equip([item]) if item
- end
- #--------------------------------------------------------------------------
- # ● 特技习得判定
- # skill_id : 特技 ID
- # innate : 只判定内在技能
- #--------------------------------------------------------------------------
- def skill_learn?(skill_id, innate = false)
- innate ? @skills.include?(skill_id) : skills.include?(skill_id)
- end
- #--------------------------------------------------------------------------
- # ● 可以使用的特技表
- #--------------------------------------------------------------------------
- def skills
- (@skills | equipment.map {|e| e.skills_add}.flatten).sort
- end
- #--------------------------------------------------------------------------
- # ● 觉悟特技
- # skill_id : 特技 ID
- #--------------------------------------------------------------------------
- def learn_skill(skill_id)
- @skills |= [skill_id] if skill_id > 0
- end
- #--------------------------------------------------------------------------
- # ● 可以使用特技判定
- # skill_id : 特技 ID
- #--------------------------------------------------------------------------
- def skill_can_use?(skill_id)
- # 技能被装备封印的情况下
- if equipment.map {|e| e.skills_seal}.flatten.include?(skill_id)
- # 不能使用
- return false
- end
- # 原始判定
- return sailcat_equipws_skill_can_use?(skill_id)
- end
- end
- #==============================================================================
- # ■ Scene_Battle
- #==============================================================================
- class Scene_Battle
- #--------------------------------------------------------------------------
- # ● 方法重定义
- #--------------------------------------------------------------------------
- unless method_defined? :sailcat_equipws_battle_end
- alias sailcat_equipws_battle_end battle_end
- alias sailcat_equipws_start_phase4 start_phase4
- alias sailcat_equipws_update_phase4_step5 update_phase4_step5
- end
- #--------------------------------------------------------------------------
- # ● 战斗结束
- # result : 結果 (0:胜利 1:逃跑 2:失败)
- #--------------------------------------------------------------------------
- def battle_end(result)
- # 更新按战斗结果刷新的装备学习技能
- $game_party.actors.each {|a| a.update_equip_learning(result + 3)}
- sailcat_equipws_battle_end(result)
- end
- #--------------------------------------------------------------------------
- # ● 开始主回合
- #--------------------------------------------------------------------------
- def start_phase4
- sailcat_equipws_start_phase4
- # 更新按回合积累刷新的装备学习技能
- $game_party.actors.each {|a| a.update_equip_learning(6)}
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面 (主回合步骤 5 : 显示伤害)
- #--------------------------------------------------------------------------
- def update_phase4_step5
- # 更新按使用技能刷新的装备学习技能
- if @active_battler.actor?
- id = @active_battler.current_action.skill_id
- if id > 0
- @active_battler.update_equip_learning(0, id)
- @target_battlers.each do |t|
- @active_battler.update_equip_learning(1, id) if t.damage != "Miss"
- @active_battler.update_equip_learning(2, id) if t.hp0?
- end
- end
- end
- sailcat_equipws_update_phase4_step5
- end
- end
复制代码
4. 装备能力加成
功能:
1.装备加成的能力突破数据库内容,比如武器能加回避,防具能加攻击,武器防具都能加HP、SP
2.装备弱化、强化属性和状态
3.装备多个自动状态版本历史v1.1
修正了一处已知问题
v1.0
初期版本
代码- #==============================================================================
- # ■ 装备增强-装备能力加成 v1.1 by SailCat
- #------------------------------------------------------------------------------
- # 方法:本脚本插入到Main之前使用,并依赖以下脚本:
- # 1. 数据库通用备注接口插件(2.0版以上,插入在其之后)
- # 2. 装备增强系统核心插件(1.1版以上,插入在其之后)
- # 版本:v1.1 (Build 171129)
- # 效果:武器和防具可以增强的角色能力多样化,并不止默认的那些
- # 配置:插件为即插即用型,没有任何配置项,也不需要在脚本中设定任何东西
- # 冲突:其他同类脚本
- # 说明:
- # 0. 备注均写在描述里,具体格式见依赖的通用备注接口插件相关说明
- # (当[XX集]内容只有一条时,方括号可省略)
- # (条件太多写不下时,可用超长备注法)
- # 1. 武器的回避率修正:qv=值
- # 2. 防具的攻击力修正:qk=值
- # 3. 武器和防具防御属性:qe=[属性ID集],正数强化(减半),负数弱点(加倍)
- # 防具可以直接设定防御属性,这里一般只需要设定负数即弱点属性
- # 4. 武器和防具防御状态:qt=[状态ID集],正数强化(抵抗),负数弱化(必中)
- # 防具可以直接设定防御状态,这里一般只需要设定负数即弱点状态
- # 5. 武器和防具的自动状态:qa=[状态ID集],防具会和数据库内的设定合并
- # 6. 武器和防具加成MaxHP:qh=值
- # 7. 武器和防具加成MaxSP:qm=值
- #==============================================================================
- #==============================================================================
- # ■ SailCat's 插件公用
- #==============================================================================
- module SailCat
- $sailcat_import ||= {}
- #--------------------------------------------------------------------------
- # ● 植入与依赖检查
- #--------------------------------------------------------------------------
- dependency = []
- unless $sailcat_import[:DataNoteCore].to_f >= 2.0
- dependency.push "[DataNoteCore] 通用数据库备注接口(v2.0以上版本)"
- end
- unless $sailcat_import[:EquipCore] >= 1.1
- dependency.push "[EquipCore] 装备增强系统核心(v1.1以上版本)"
- end
- raise "缺少依赖插件:\n" + dependency.join("\n") unless dependency.empty?
- $sailcat_import[:EquipStatBonus] = 1.0
- end
- module RPG
- #============================================================================
- # ■ RPG::Weapon
- #----------------------------------------------------------------------------
- # 数据库的武器类扩展
- #============================================================================
- class Weapon
- #--------------------------------------------------------------------------
- # ● 备注定义
- #--------------------------------------------------------------------------
- def eva; _qv(0); end
- def mod_element_set; flat_array(_qe([])); end
- def guard_element_set;mod_element_set.select {|f| f > 0}; end
- def weak_element_set; mod_element_set.select {|f| f < 0}.map {|f| -f};end
- def mod_state_set; flat_array(_qt([])); end
- def guard_state_set; mod_state_set.select {|f| f > 0}; end
- def weak_state_set; mod_state_set.select {|f| f < 0}.map {|f| -f}; end
- def auto_state_set; flat_array(_qa([])); end
- def maxhp_plus; _qh(0) end
- def maxsp_plus; _qm(0) end
- #--------------------------------------------------------------------------
- # ● 获得加成值
- #--------------------------------------------------------------------------
- def stat(type)
- [maxhp_plus, maxsp_plus, str_plus, dex_plus, agi_plus, int_plus,
- pdef, mdef, eva][type] || 0
- end
- end
- #============================================================================
- # ■ RPG::Armor
- #----------------------------------------------------------------------------
- # 数据库的防具类扩展
- #============================================================================
- class Armor
- #--------------------------------------------------------------------------
- # ● 备注定义
- #--------------------------------------------------------------------------
- def atk; _qk(0); end
- def mod_element_set; flat_array(_qe([])); end
- def weak_element_set; mod_element_set.select {|f| f < 0}.map {|f| -f};end
- def mod_state_set; flat_array(_qt([])); end
- def weak_state_set; mod_state_set.select {|f| f < 0}.map {|f| -f}; end
- def auto_state_set; flat_array(_qa([])) | [@auto_state_id]; end
- def maxhp_plus; _qh(0) end
- def maxsp_plus; _qm(0) end
- #--------------------------------------------------------------------------
- # ● 重定义:属性防御
- #--------------------------------------------------------------------------
- def guard_element_set
- mod_element_set.select {|f| f > 0} | @guard_element_set
- end
- #--------------------------------------------------------------------------
- # ● 重定义:状态防御
- #--------------------------------------------------------------------------
- def guard_state_set
- mod_state_set.select {|f| f > 0} | @guard_state_set
- end
- #--------------------------------------------------------------------------
- # ● 获得加成值
- #--------------------------------------------------------------------------
- def stat(type)
- [maxhp_plus, maxsp_plus, str_plus, dex_plus, agi_plus, int_plus,
- pdef, mdef, eva][type] || 0
- end
- end
- end
- #==============================================================================
- # ■ Game_Actor
- #==============================================================================
- class Game_Actor
- #--------------------------------------------------------------------------
- # ● 方法重定义
- #--------------------------------------------------------------------------
- unless method_defined?(:sailcat_equipsb_states_plus)
- alias sailcat_equipsb_post_setup post_setup
- alias sailcat_equipsb_states_plus states_plus
- alias sailcat_equipsb_base_atk base_atk
- alias sailcat_equipsb_equip equip
- end
- #--------------------------------------------------------------------------
- # ● 后续处理内容
- #--------------------------------------------------------------------------
- def post_setup
- sailcat_equipsb_post_setup
- weapons.each {|weapon| update_auto_state(nil, weapon)}
- end
- #--------------------------------------------------------------------------
- # ● 取得属性修正值
- # element_id : 属性 ID
- #--------------------------------------------------------------------------
- def element_rate(element_id)
- # 获取对应属性有效度的数值
- table = [0,200,150,100,50,0,-100]
- result = table[$data_classes[@class_id].element_ranks[element_id]]
- # 防具能防御本属性的情况下效果减半,对本属性弱点的情况下效果加倍
- for item in equipment
- result /= 2 if item.guard_element_set.include?(element_id)
- result *= 2 if item.weak_element_set.include?(element_id)
- end
- # 状态能防御本属性的情况下效果减半
- for i in @states
- if $data_states[i].guard_element_set.include?(element_id)
- result /= 2
- end
- end
- # 过程结束
- return result
- end
- #--------------------------------------------------------------------------
- # ● 装备的状态总防御度
- # state_id : 状态 ID
- #--------------------------------------------------------------------------
- def state_defense(state_id)
- equipment.inject(0) do |v, item|
- v += 1 if item.guard_state_set.include?(state_id)
- v -= 1 if item.weak_state_set.include?(state_id)
- v
- end
- end
- #--------------------------------------------------------------------------
- # ● 判定防御状态
- # state_id : 状态 ID
- #--------------------------------------------------------------------------
- def state_guard?(state_id); state_defense(state_id) > 0; end
- def state_weak?(state_id); state_defense(state_id) < 0; end
- #--------------------------------------------------------------------------
- # ● 状态变化 (+) 的适用
- # plus_state_set : 状态变化 (+)
- #--------------------------------------------------------------------------
- def states_plus(plus_state_set)
- # 清除有效标志
- effective = false
- weak_states = []
- # 循环所有附加状态
- for i in plus_state_set
- # 对此状态弱点的情况下,必中
- if state_weak?(i)
- @state_changed = true
- weak_states.push(i)
- add_state(i)
- end
- end
- # 继续执行余下的状态
- effective |= sailcat_equipsb_states_plus(plus_state_set - weak_states)
- # 过程结束
- return effective
- end
- #--------------------------------------------------------------------------
- # ● 获取基本数值
- # type : 数值类型 (0-8)
- # min : 数值的最小值
- # max : 数值的最大值
- #--------------------------------------------------------------------------
- def base_value(type, min = -2147483648, max = 2147483647)
- case type
- when 0..5
- n = prota.parameters[type, @level]
- when 6..8
- n = 0
- end
- n += equipment.inject(0) {|v, item| v += item.stat(type)}
- return [[n, min].max, max].min
- end
- #--------------------------------------------------------------------------
- # ● 获取基本 MaxHP
- #--------------------------------------------------------------------------
- def base_maxhp; base_value(0, 1, 9999); end
- #--------------------------------------------------------------------------
- # ● 获取基本 MaxSP
- #--------------------------------------------------------------------------
- def base_maxsp; base_value(1, 0, 9999); end
- #--------------------------------------------------------------------------
- # ● 获取基本力量
- #--------------------------------------------------------------------------
- def base_str; base_value(2, 1, 999); end
- #--------------------------------------------------------------------------
- # ● 获取基本灵巧
- #--------------------------------------------------------------------------
- def base_dex; base_value(3, 1, 999); end
- #--------------------------------------------------------------------------
- # ● 获取基本速度
- #--------------------------------------------------------------------------
- def base_agi; base_value(4, 1, 999); end
- #--------------------------------------------------------------------------
- # ● 获取基本魔力
- #--------------------------------------------------------------------------
- def base_int; base_value(5, 1, 999); end
- #--------------------------------------------------------------------------
- # ● 获取基本物理防御
- #--------------------------------------------------------------------------
- def base_pdef; base_value(6, 0); end
- #--------------------------------------------------------------------------
- # ● 获取基本魔法防御
- #--------------------------------------------------------------------------
- def base_mdef; base_value(7, 0); end
- #--------------------------------------------------------------------------
- # ● 获取基本回避修正
- #--------------------------------------------------------------------------
- def base_eva; base_value(8, -100, 100); end
- #--------------------------------------------------------------------------
- # ● 获取基本攻击力
- #--------------------------------------------------------------------------
- if $sailcat_import[:EquipWeaponEffect]
- def base_atk(other = self)
- n = sailcat_equipsb_base_atk(other)
- armors.inject(n) {|v, armor| v += armor.atk}
- end
- else
- def base_atk
- n = sailcat_equipsb_base_atk
- armors.inject(n) {|v, armor| v += armor.atk}
- end
- end
- #--------------------------------------------------------------------------
- # ● 更新自动状态
- # old_equip : 卸下防具/武器
- # new_equip : 装备防具/武器
- #--------------------------------------------------------------------------
- def update_auto_state(old_equip, new_equip)
- # 强制解除卸下防具的自动状态
- old_equip.auto_state_set.each {|s| deprive_state(s)} if old_equip
- # 强制附加装备防具的自动状态
- new_equip.auto_state_set.each {|s| enforce_state(s)} if new_equip
- end
- #--------------------------------------------------------------------------
- # ● 变更装备
- # equip_type : 装备类型
- # id : 武器 or 防具 ID (0 为解除装备)
- #--------------------------------------------------------------------------
- def equip(equip_type, id)
- # 武器的话,也要更新自动状态
- old_weapon = current_weapon && current_weapon.clone if equip_type <= 0
- sailcat_equipsb_equip(equip_type, id)
- update_auto_state(old_weapon, $data_weapons[id]) if equip_type <= 0
- end
- end
复制代码
5. 装备用作道具
功能:
1.将装备当作道具来使用,引发技能或道具的效果
版本历史v1.0
初期版本
代码- #==============================================================================
- # ■ 装备增强-装备用作道具 v1.0 by SailCat
- #------------------------------------------------------------------------------
- # 方法:本脚本插入到Main之前使用,并依赖以下脚本:
- # 1. 数据库通用备注接口插件(2.0版以上,插入在其之后)
- # 2. 装备增强系统核心插件(1.1版以上,插入在其之后)
- # 版本:v1.0 (Build 171129)
- # 效果:
- # 1. 装备可以在战斗中当作一次性或者反复使用的道具来使用
- # 2. 使用效果可以是等同某种道具(不耗该道具)或等同某种技能(不耗SP)
- # 配置:插件为即插即用型,没有任何配置项,也不需要在脚本中设定任何东西
- # 冲突:可能和道具界面增强脚本冲突
- # 脚本最后的draw_item方法如果和其他脚本冲突,可以去掉,插件功能不变
- # 但这样可使用的武器/防具将会变成灰色显示的颜色,如果要修正这个问题
- # 在你的脚本中搜索下列内容
- # if item.is_a?(RPG::Item) and
- # $game_party.item_can_use?(item.id)
- # 将最后一处相关内容改为
- # if (item.is_a?(RPG::Item) and
- # $game_party.item_can_use?(item.id)) or
- # (item.is_a?(RPG::Weapon) or item.is_a?(RPG::Armor) and
- # item.usable? and $game_temp.in_battle)
- # 即可
- # 说明:
- # 0. 以下备注均写在描述里,具体格式见依赖的通用备注接口插件相关说明
- # (当[XX集]内容只有一条时,方括号可省略)
- # (备注内容太多写不下时,可用超长备注法)
- # 1. 装备使用效果等于技能:us=技能ID
- # 2. 装备使用效果等于道具:us=道具ID的负数
- # 如此设定是因为装备的使用效果必须是道具或技能之一,二者互斥
- # 3. 装备使用是否消耗:uc+(消耗)或uc-(不消耗),默认不消耗
- # 4. 用来在战斗中使用的装备,只能是队伍所持的装备,不包括身上已经穿着的装备
- #==============================================================================
- #==============================================================================
- # ■ SailCat's 插件公用
- #==============================================================================
- module SailCat
- $sailcat_import ||= {}
- #--------------------------------------------------------------------------
- # ● 植入与依赖检查
- #--------------------------------------------------------------------------
- dependency = []
- unless $sailcat_import[:DataNoteCore].to_f >= 2.0
- dependency.push "[DataNoteCore] 通用数据库备注接口(v2.0以上版本)"
- end
- unless $sailcat_import[:EquipCore] >= 1.1
- dependency.push "[EquipCore] 装备增强系统核心(v1.1以上版本)"
- end
- raise "缺少依赖插件:\n" + dependency.join("\n") unless dependency.empty?
- $sailcat_import[:EquipUsable] = 1.0
- end
- module RPG
- #============================================================================
- # ■ RPG::Weapon
- #----------------------------------------------------------------------------
- # 数据库的武器类扩展
- #============================================================================
- class Weapon
- #--------------------------------------------------------------------------
- # ● 备注定义
- #--------------------------------------------------------------------------
- def item_id; _us(0) < 0 ? -_us : 0; end
- def skill_id; _us(0) > 0 ? _us : 0; end
- def usable?; item_id > 0 or skill_id > 0; end
- def consumable?; _uc(false); end
- #--------------------------------------------------------------------------
- # ● 作为道具使用时的引发效果
- #--------------------------------------------------------------------------
- def item_or_skill
- if item_id > 0
- return $data_items[item_id]
- elsif skill_id > 0
- return $data_skills[skill_id]
- else
- return nil
- end
- end
- #--------------------------------------------------------------------------
- # ● 作为道具使用时的对象范围
- #--------------------------------------------------------------------------
- def use_scope
- item_or_skill ? item_or_skill.scope : 0
- end
- end
- #============================================================================
- # ■ RPG::Armor
- #----------------------------------------------------------------------------
- # 数据库的防具类扩展
- #============================================================================
- class Armor
- #--------------------------------------------------------------------------
- # ● 备注定义
- #--------------------------------------------------------------------------
- def item_id; _us(0) < 0 ? -_us : 0; end
- def skill_id; _us(0) > 0 ? _us : 0; end
- def usable?; item_id > 0 or skill_id > 0; end
- def consumable?; _uc(false); end
- #--------------------------------------------------------------------------
- # ● 作为道具使用时的引发效果
- #--------------------------------------------------------------------------
- def item_or_skill
- if item_id > 0
- return $data_items[item_id]
- elsif skill_id > 0
- return $data_skills[skill_id]
- else
- return nil
- end
- end
- #--------------------------------------------------------------------------
- # ● 作为道具使用时的对象范围
- #--------------------------------------------------------------------------
- def use_scope
- item_or_skill ? item_or_skill.scope : 0
- end
- end
- end
- #==============================================================================
- # ■ Game_BattleAction
- #==============================================================================
- class Game_BattleAction
- #--------------------------------------------------------------------------
- # ● 定义实例变量
- #--------------------------------------------------------------------------
- attr_accessor :equip_id # 武器或防具的 ID
- #--------------------------------------------------------------------------
- # ● 方法重定义
- #--------------------------------------------------------------------------
- unless method_defined?(:sailcat_equipuse_clear)
- alias sailcat_equipuse_clear clear
- alias sailcat_equipuse_for_one_friend? for_one_friend?
- alias sailcat_equipuse_for_one_friend_hp0? for_one_friend_hp0?
- end
- #--------------------------------------------------------------------------
- # ● 清除
- #--------------------------------------------------------------------------
- def clear
- sailcat_equipuse_clear
- @equip_id = 0
- end
- #--------------------------------------------------------------------------
- # ● 己方单体使用判定
- #--------------------------------------------------------------------------
- def for_one_friend?
- if @kind == 3
- e = @equip_id > 0 ? $data_armors[@equip_id] : $data_weapons[-@equip_id]
- return [3, 5].include?(e.use_scope)
- end
- return sailcat_equipuse_for_one_friend?
- end
- #--------------------------------------------------------------------------
- # ● 己方单体用 (HP 0) 判定
- #--------------------------------------------------------------------------
- def for_one_friend_hp0?
- if @kind == 3
- i = @equip_id > 0 ? $data_armors[@equip_id] : $data_weapons[-@equip_id]
- return [5].include?(i.use_scope)
- end
- return sailcat_equipuse_for_one_friend_hp0?
- end
- end
- #==============================================================================
- # ■ Game_Battler
- #==============================================================================
- class Game_Battler
- #--------------------------------------------------------------------------
- # ● 应用装备的使用效果
- # user : 装备的使用者
- # equip : 被使用的装备
- #--------------------------------------------------------------------------
- def equip_effect(user, equip)
- return false if user.is_a?(Game_Enemy) or equip.nil?
- if equip.item_or_skill.is_a?(RPG::Item)
- return item_effect(equip.item_or_skill)
- elsif equip.item_or_skill.is_a?(RPG::Skill)
- return skill_effect(user, equip.item_or_skill)
- end
- end
- end
- #==============================================================================
- # ■ Scene_Battle
- #==============================================================================
- class Scene_Battle
- #--------------------------------------------------------------------------
- # ● 方法重定义
- #--------------------------------------------------------------------------
- unless method_defined?(:sailcat_equipuse_start_enemy_select)
- alias sailcat_equipuse_update_phase3_item_select update_phase3_item_select
- alias sailcat_equipuse_update_phase4_step2 update_phase4_step2
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面 (角色命令回合 : 选择物品)
- #--------------------------------------------------------------------------
- def update_phase3_item_select
- # 按下 C 键的情况下
- if Input.trigger?(Input::C)
- # 获取物品窗口现在选择的物品资料
- @item = @item_window.item
- # 如果是选择了武器或防具来使用的情况下
- if @item.is_a?(RPG::Weapon) or @item.is_a?(RPG::Armor)
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 设置行动
- equip_id = @item.id * (@item.is_a?(RPG::Weapon) ? -1 : 1)
- @active_battler.current_action.kind = 3
- @active_battler.current_action.equip_id = equip_id
- # 设置物品窗口为不可见状态
- @item_window.visible = false
- # 效果范围是敌单体的情况下
- if @item.use_scope == 1
- # 开始选择敌人
- start_enemy_select
- # 效果范围是我方单体的情况下
- elsif @item.use_scope == 3 or @item.use_scope == 5
- # 开始选择角色
- start_actor_select
- # 效果范围不是单体的情况下
- else
- # 物品选择结束
- end_item_select
- # 转到下一位角色的指令输入
- phase3_next_actor
- end
- return
- end
- end
- sailcat_equipuse_update_phase3_item_select
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面 (主回合步骤 2 : 开始行动)
- #--------------------------------------------------------------------------
- def update_phase4_step2
- sailcat_equipuse_update_phase4_step2
- make_equipuse_action_result if @active_battler.current_action.kind == 3
- end
- #--------------------------------------------------------------------------
- # ● 生成装备使用行动结果
- #--------------------------------------------------------------------------
- def make_equipuse_action_result
- # 获取装备
- if @active_battler.current_action.equip_id < 0
- @item = $data_weapons[-@active_battler.current_action.equip_id]
- number = $game_party.weapon_number(@item.id)
- else
- @item = $data_armors[@active_battler.current_action.equip_id]
- number = $game_party.armor_number(@item.id)
- end
- # 因为装备耗尽而无法使用的情况下
- unless number > 0
- # 移至步骤 1
- @phase4_step = 1
- return
- end
- # 消耗品的情况下
- if @item.consumable?
- # 使用的装备减 1
- if @item.is_a?(RPG::Weapon)
- $game_party.lose_weapon(@item.id, 1)
- else
- $game_party.lose_armor(@item.id, 1)
- end
- end
- # 在帮助窗口显示装备名称
- @help_window.set_text(@item.name, 1)
- # 设置动画 ID
- @animation1_id = @item.item_or_skill.animation1_id
- @animation2_id = @item.item_or_skill.animation2_id
- # 设置公共事件 ID
- @common_event_id = @item.item_or_skill.common_event_id
- # 设置对像侧战斗者
- set_target_battlers(@item.use_scope)
- # 应用物品效果
- for target in @target_battlers
- target.equip_effect(@active_battler, @item)
- end
- end
- end
- #==============================================================================
- # ■ Window_Item
- #==============================================================================
- class Window_Item
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- if self.contents != nil
- self.contents.dispose
- self.contents = nil
- end
- @data = []
- # 添加物品
- for i in 1...$data_items.size
- if $game_party.item_number(i) > 0
- @data.push($data_items[i])
- end
- end
- # 在战斗中以外添加武器、防具,或添加战斗中可用的武器、防具
- for i in 1...$data_weapons.size
- if $game_party.weapon_number(i) > 0
- if not $game_temp.in_battle or $data_weapons[i].usable?
- @data.push($data_weapons[i])
- end
- end
- end
- for i in 1...$data_armors.size
- if $game_party.armor_number(i) > 0
- if not $game_temp.in_battle or $data_armors[i].usable?
- @data.push($data_armors[i])
- end
- end
- end
- # 如果项目数不是 0 就生成位图、重新描绘全部项目
- @item_max = @data.size
- if @item_max > 0
- self.contents = Bitmap.new(width - 32, row_max * 32)
- for i in 0...@item_max
- draw_item(i)
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 描绘项目
- # index : 项目编号
- #--------------------------------------------------------------------------
- def draw_item(index)
- item = @data[index]
- case item
- when RPG::Item
- number = $game_party.item_number(item.id)
- when RPG::Weapon
- number = $game_party.weapon_number(item.id)
- when RPG::Armor
- number = $game_party.armor_number(item.id)
- end
- if (item.is_a?(RPG::Item) and
- $game_party.item_can_use?(item.id)) or
- (item.is_a?(RPG::Weapon) or item.is_a?(RPG::Armor) and
- item.usable? and $game_temp.in_battle)
- 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(item.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)
- self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
- self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
- self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
- end
- end
复制代码 |
评分
-
查看全部评分
|