| 赞 | 349 |
| VIP | |
| 好人卡 | |
| 积分 | 299 |
| 经验 | |
| 最后登录 | 2026-10-1 |
| 在线时间 | 2423 小时 |
遠航の猫咪
- 梦石
- 3
- 星屑
- 26947
- 在线时间
- 2423 小时
- 注册时间
- 2005-10-15
- 回帖
- 987

|
楼主 |
发表于 2017-11-19 23:43:58
|
显示全部楼层
本帖最后由 SailCat 于 2017-11-19 23:45 编辑
……填的好辛苦……
终于把Game_Actor及Game_Battler搞完,只剩一堆Scene了……
附带技能做起来才知道就3行代码,多刀流、N连击这些也就是套个循环了事
但是装备栏扩展300行代码也没搞定,这还是在用了数组管理的情况下
默认的armor1……armor4写死了真心差评……
关键是……不但防具要扩展,武器也要扩展,不同职业要允许不同的扩展方法……扩展不但是栏位增加,也包括栏位重复,还有升级RGSS3的栏位封印……
Game_Actor(部分)[pre lang="ruby"] #--------------------------------------------------------------------------
# ● 装备固定判定
# slot : 装备栏,1以上为防具,0以下为武器
#--------------------------------------------------------------------------
def equip_fix?(slot)
if slot <= 0 # 武器
# 如果装备了武器,检查武器是否强制固定
weapon_id = @weapon_id_set[-slot]
return true if weapon_id > 0 and $data_weapons[weapon_id].equip_fixed
# 检查初期装备的设定
kind = @weapon_kinds[-slot]
if kind == -1 # 默认
return $data_actors[@actor_id].weapon_fix
elsif $data_actors[@actor_id].weapon_ext_set.size < -slot # 扩展
return $data_actors[@actor_id].weapon_ext_set[-slot - 1] < 0
else
return false
end
else # 防具
# 如果装备了防具,检查防具是否强制固定
armor_id = @armor_id_set[slot - 1]
return true if armor_id > 0 and $data_armors[armor_id].equip_fixed
# 检查初期装备的设定
kind = @armor_kinds[slot - 1]
if kind < 4 # 默认
return eval("$data_actors[@actor_id].armor#{kind+1}_fix")
else # 扩展
if $data_actors[@actor_id].armor_ext_set.size < slot - 4
return $data_actors[@actor_id].armor_ext_set[slot - 4] < 0
else
return false
end
end
end
end
#--------------------------------------------------------------------------
# ● 变更装备
# slot : 装备栏,1以上为防具,0以下为武器
# id : 武器 or 防具 ID (0 为解除装备)
#--------------------------------------------------------------------------
def equip(slot, id)
# 因封印被连锁卸除的装备类型
seal_kind = nil
if slot <= 0 # 武器
if id == 0 or $game_party.weapon_number(id) > 0
old_id = @weapon_id_set[-slot]
update_auto_state($data_weapons[old_id], $data_weapons[id])
$game_party.gain_weapon(old_id, 1)
@weapon_id_set[-slot] = id
$game_party.lose_weapon(id, 1)
seal_kind = $data_weapons[id] && $data_weapons[id].seal_equip_kind
end
else # 防具
if id == 0 or $game_party.armor_number(id) > 0
old_id = @armor_id_set[slot - 1]
update_auto_state($data_armors[old_id], $data_armors[id])
$game_party.gain_armor(old_id, 1)
@armor_id_set[slot - 1] = id
$game_party.lose_armor(id, 1)
seal_kind = $data_armors[id] && $data_armors[id].seal_equip_kind
end
end
if seal_kind
@weapon_kinds.each_with_index do |kind, i|
equip(-i, 0) if kind == seal_kind
end
@armor_kinds.each_with_index do |kind, i|
equip(i - 1, 0) if kind == seal_kind
end
end
end
#--------------------------------------------------------------------------
# ● 可以装备判定
# item : 物品
# slot : 指定判定的装备栏,1以上为防具,0以下为武器
#--------------------------------------------------------------------------
def equippable?(item, slot = nil)
# 不是装备物品的情况下
return false unless item.is_a?(RPG::Weapon) or item.is_a?(RPG::Armor)
# 装备栏被指定的情况下,获得该栏的装备类型
kind = slot && (slot <= 0 ? @weapon_kinds[-slot] : @armor_kinds[slot - 1])
# 此类装备被封印的情况下
return false if kind != nil and sealed_kinds.include?(kind)
# 武器的情况
if item.is_a?(RPG::Weapon)
# 包含当前的职业可以装备武器的场合
result = $data_classes[@class_id].weapon_set.include?(item.id)
# 检查装备栏位置是否对应
if kind != nil
result &&= item.kind == 0 || item.kind_set.include?(kind)
end
elsif item.is_a?(RPG::Armor)
# 包含当前的职业可以装备防具的场合
result = $data_classes[@class_id].armor_set.include?(item.id)
# 检查装备栏位置是否对应
result &&= item.kind_set.include?(kind) if kind != nil
end
# 检查能力需求
result &&= self.level >= item.level_require
result &&= self.maxhp >= item.maxhp_require
result &&= self.maxsp >= item.maxsp_require
result &&= self.str >= item.str_require
result &&= self.dex >= item.dex_require
result &&= self.agi >= item.agi_require
result &&= self.int >= item.int_require
return result
end
#--------------------------------------------------------------------------
# ● 被锁定的装备栏
#--------------------------------------------------------------------------
def sealed_kinds
(@weapon_kinds + @armor_kinds) & (equipment.map {|e| e.seal_equip_kind})
end
#--------------------------------------------------------------------------
# ● 装备附带技能的更改
# skill_id : 特技 ID
#--------------------------------------------------------------------------
def skill_learn?(skill_id); skills.include?(skill_id); end
def skills; (@skills | equipment.map {|e| e.skill_set}.flatten).sort; end
def learn_skill(skill_id); @skills |= [skill_id] if skill_id > 0; end
#--------------------------------------------------------------------------
# ● 更改职业 ID
# class_id : 新的职业 ID
#--------------------------------------------------------------------------
def class_id=(class_id)
if $data_classes[class_id] != nil
@class_id = class_id
# 卸掉所有的装备
@weapon_id_set.each_index {|i| equip(-i, 0)}
@armor_id_set.each_index {|i| equip(i - 1, 0)}
# 重新生成装备栏
make_equip_set
end
end
[/pre]
Game_Battler部分
[pre lang="ruby"] #--------------------------------------------------------------------------
# ● 应用通常攻击效果
# attacker : 攻击者 (battler)
#--------------------------------------------------------------------------
def attack_effect(attacker)
# 攻击者是敌人的情况下
if attacker.is_a?(Game_Enemy)
# 调用原来的方法
return sailcat_attack_effect_eqx(attacker)
end
# 攻击者无法攻击的情况下,结束
unless attacker.can_attack?
self.damage = "Miss"
return false
end
# 清除会心一击标志
self.critical = false
# 清除总伤害
total_damage = 0
total_missed = true
total_critical = false
# 循环每把武器
attacker.weapon_id_set.each_with_index do |w, i|
# 武器攻击动作有效的情况下
weapon = $data_weapons[w]
next unless attacker.attack_check?(weapon)
# 循环每一击
attacker.hit_count(i).times do
# 如果攻击会引发技能,调用技能效果
if weapon && weapon.attack_skill > 0
self.skill_effect(attacker, weapon.attack_skill)
total_missed &= self.damage != "Miss"
total_damage += self.damage if self.damage.is_a?(Numeric)
next
end
# 清除会心一击标志
self.critical = false
# 第一命中判定
hit_result = (rand(100) < attacker.hit(i))
# 命中的情况下
if hit_result == true
# 计算基本伤害
atk = attacker.atk(i)
atk = [atk - self.pdef / 2, 0].max if atk > 0
self.damage = atk * (20 + attacker.str) / 20
# 属性修正
self.damage *= elements_correct(attacker.element_set(i))
self.damage /= 100
# 伤害符号正确的情况下
if self.damage > 0
# 会心一击修正
if rand(100) < attacker.critical_rate(i) * attacker.dex / self.agi
self.damage *= 2
self.critical = true
end
# 防御修正
if self.guarding?
self.damage /= 2
end
end
# 分散
if self.damage.abs > 0
amp = [self.damage.abs * attacker.variance(i) / 100, 1].max
self.damage += rand(amp+1) + rand(amp+1) - amp
end
# 第二命中判定
eva = 8 * self.agi / attacker.dex + self.eva
hit = self.damage < 0 ? 100 : 100 - eva
hit = self.cant_evade? ? 100 : hit
hit_result = (rand(100) < hit)
end
# 命中的情况下
if hit_result == true
# 状态冲击解除
remove_states_shock
# HP 的伤害计算
self.hp -= self.damage
total_damage += self.damage
total_missed = false
total_critical |= self.critical
# 状态变化
@state_changed = false
states_plus(attacker.plus_state_set)
states_minus(attacker.minus_state_set)
attacker.states_plus(attacker.plus_state_self)
attacker.states_minus(attacker.minus_state_self)
# Miss 的情况下
else
# 伤害设置为 "Miss"
self.damage = "Miss"
# 清除会心一击标志
self.critical = false
end
end
# 此武器攻击完毕,执行消耗
attacker.attack_cost_extra(weapon)
end
# 一击也没有打中的情况下
if total_missed
# 伤害设置为 Miss
self.damage = "Miss"
else
# 设置总伤害及会心一击标志
self.damage = total_damage
self.critical = total_critical
end
# 过程结束
return true
end[/pre]
|
|