class Game_Battler
def add_state(state_id, force = false)
# 无效状态的情况下
if $data_states[state_id] == nil
# 过程结束
return
end
# 无法强制附加的情况下
unless force
# 已存在的状态循环
for i in @states
# 新的状态和已经存在的状态 (-) 同时包含的情况下、
# 本状态不包含变化为新状态的状态变化 (-)
# (ex : 战斗不能与附加中毒同时存在的场合)
if $data_states[i].minus_state_set.include?(state_id) and
not $data_states[state_id].minus_state_set.include?(i)
# 过程结束
return
end
end
end
# 强制附加的场合
if force
for i in @states
# 旧状态i解除新状态state_id,state_id不解除i,并且i为强制附加
if $data_states[i].minus_state_set.include?(state_id) &&
!$data_states[state_id].minus_state_set.include?(i) &&
@states_turn[i] == -1
# 过程结束
return
end
end
# 设置为自然解除的最低回数 -1 (无效)
@states_turn[state_id] = -1
end
# 原先不存在本状态的情况下
unless state?(state_id)
# 状态 ID 追加到 @states 序列中
@states.push(state_id)
# 选项 [当作 HP 0 的状态] 有效的情况下
if $data_states[state_id].zero_hp
# HP 更改为 0
@hp = 0
end
# 所有状态的循环
for i in 1...$data_states.size
# 状态变化 (+) 处理
if $data_states[state_id].plus_state_set.include?(i)
add_state(i)
end
# 状态变化 (-) 处理
if $data_states[state_id].minus_state_set.include?(i)
# 强制附加时强制解除冲突状态
if force && !$data_states[i].minus_state_set.include?(state_id)
remove_state(i, true)
else
remove_state(i)
end
end
end
# 按比例大的排序 (值相等的情况下按照强度排序)
@states.sort! do |a, b|
state_a = $data_states[a]
state_b = $data_states[b]
if state_a.rating > state_b.rating
-1
elsif state_a.rating < state_b.rating
+1
elsif state_a.restriction > state_b.restriction
-1
elsif state_a.restriction < state_b.restriction
+1
else
a <=> b
end
end
end
# 不能强制附加的场合
unless @states_turn[state_id] == -1
# 设置为自然解除的最低回数
@states_turn[state_id] = $data_states[state_id].hold_turn
end
# 无法行动的场合
unless movable?
# 清除行动
@current_action.clear
end
# 检查 HP 及 SP 的最大值
@hp = [@hp, self.maxhp].min
@sp = [@sp, self.maxsp].min
end
end
#数据库中的武器附带公共状态
WEAPON_AUTO_STATES = []
#WEAPON_AUTO_STATES[1] = [18,19] # 1号武器附加18,19号状态
#防具附带公共状态
ARMOR_AUTO_STATES = []
ARMOR_AUTO_STATES[1] = [17,18]
#ARMOR_AUTO_STATES[5] = [19,20]
#ARMOR_AUTO_STATES[13] = [20,21]
####武器自动状态实现,防具自动状态脚本库定义实现
class Game_Actor < Game_Battler
# update_auto_state参数数量改变,重载setup
#--------------------------------------------------------------------------
# ● 设置
# actor_id : 角色 ID
#--------------------------------------------------------------------------
def setup(actor_id)
actor = $data_actors[actor_id]
@actor_id = actor_id
@name = actor.name
@character_name = actor.character_name
@character_hue = actor.character_hue
@battler_name = actor.battler_name
@battler_hue = actor.battler_hue
@class_id = actor.class_id
@weapon_id = actor.weapon_id
@armor1_id = actor.armor1_id
@armor2_id = actor.armor2_id
@armor3_id = actor.armor3_id
@armor4_id = actor.armor4_id
@armor5_id = actor.armor5_id
@armor6_id = actor.armor6_id
@armor7_id = actor.armor7_id
@level = actor.initial_level
@exp_list = Array.new(101)
make_exp_list
@exp = @exp_list[@level]
@skills = []
@hp = maxhp
@sp = maxsp
@states = []
@states_turn = {}
@maxhp_plus = 0
@maxsp_plus = 0
@str_plus = 0
@dex_plus = 0
@agi_plus = 0
@int_plus = 0
# 学会特技
for i in 1..@level
for j in $data_classes[@class_id].learnings
if j.level == i
learn_skill(j.skill_id)
end
end
end
# 刷新自动状态
update_auto_state(nil, $data_weapons[@weapon_id], 0)
update_auto_state(nil, $data_armors[@armor1_id], 1)
update_auto_state(nil, $data_armors[@armor2_id], 1)
update_auto_state(nil, $data_armors[@armor3_id], 1)
update_auto_state(nil, $data_armors[@armor4_id], 1)
update_auto_state(nil, $data_armors[@armor5_id], 1)
update_auto_state(nil, $data_armors[@armor6_id], 1)
update_auto_state(nil, $data_armors[@armor7_id], 1)
end
####################
# type(0: 武器 1: 防具)
def update_auto_state(old_equipment, new_equipment, type)
case type
when 0 #武器
removed = WEAPON_AUTO_STATES[old_equipment.id] if old_equipment != nil
if removed != nil
removed.each {|i| remove_state(i, true)}
end
added = WEAPON_AUTO_STATES[new_equipment.id] if new_equipment != nil
if added != nil
added.each {|i| add_state(i, true)}
end
if old_equipment != nil # 重附加
re_add_auto_state(0)
end
when 1 #防具
# 强制解除自动状态
if old_equipment != nil and old_equipment.auto_state_id != 0
remove_state(old_equipment.auto_state_id, true)
end
removed = ARMOR_AUTO_STATES[old_equipment.id] if old_equipment != nil
if removed != nil
removed.each {|i| remove_state(i, true)}
end
# 附加自动状态
if new_equipment != nil and new_equipment.auto_state_id != 0
add_state(new_equipment.auto_state_id, true)
end
added = ARMOR_AUTO_STATES[new_equipment.id] if new_equipment != nil
if added != nil
added.each {|i| add_state(i, true)}
end
if old_equipment != nil # 重附加
re_add_auto_state(old_equipment.kind + 1)
end
end
end
end
####装备替换时更新自动状态
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# ● 变更装备
# equip_type : 装备类型
# id : 武器 or 防具 ID (0 为解除装备)
#--------------------------------------------------------------------------
def equip(equip_type, id)
case equip_type
when 0 # 武器
if id == 0 or $game_party.weapon_number(id) > 0
update_auto_state($data_weapons[@weapon_id], $data_weapons[id], 0)
$game_party.gain_weapon(@weapon_id, 1)
@weapon_id = id
$game_party.lose_weapon(id, 1)
end
when 1 # 盾
if id == 0 or $game_party.armor_number(id) > 0
update_auto_state($data_armors[@armor1_id], $data_armors[id], 1)
$game_party.gain_armor(@armor1_id, 1)
@armor1_id = id
$game_party.lose_armor(id, 1)
end
when 2 # 头
if id == 0 or $game_party.armor_number(id) > 0
update_auto_state($data_armors[@armor2_id], $data_armors[id], 1)
$game_party.gain_armor(@armor2_id, 1)
@armor2_id = id
$game_party.lose_armor(id, 1)
end
when 3 # 身体
if id == 0 or $game_party.armor_number(id) > 0
update_auto_state($data_armors[@armor3_id], $data_armors[id], 1)
$game_party.gain_armor(@armor3_id, 1)
@armor3_id = id
$game_party.lose_armor(id, 1)
end
when 4 # 装饰品
if id == 0 or $game_party.armor_number(id) > 0
update_auto_state($data_armors[@armor4_id], $data_armors[id], 1)
$game_party.gain_armor(@armor4_id, 1)
@armor4_id = id
$game_party.lose_armor(id, 1)
end
when 5 # 道具
if id == 0 or $game_party.armor_number(id) > 0
update_auto_state($data_armors[@armor5_id], $data_armors[id], 1)
$game_party.gain_armor(@armor5_id, 1)
@armor5_id = id
$game_party.lose_armor(id, 1)
end
when 6 # 饰品
if id == 0 or $game_party.armor_number(id) > 0
update_auto_state($data_armors[@armor6_id], $data_armors[id], 1)
$game_party.gain_armor(@armor6_id, 1)
@armor6_id = id
$game_party.lose_armor(id, 1)
end
when 7 # 身体
if id == 0 or $game_party.armor_number(id) > 0
update_auto_state($data_armors[@armor7_id], $data_armors[id], 1)
$game_party.gain_armor(@armor7_id, 1)
@armor7_id = id
$game_party.lose_armor(id, 1)
end
end
end
end
####自动状态防冲突实现
class Game_Actor < Game_Battler
# equipment_type检测目前更换装备种类,重附加身上其他装备自动状态
def re_add_auto_state(equipment_type)
auto_states = []
if equipment_type != 0 # 武器
auto_states += gain_weapon_auto_state(@weapon_id)
end
if equipment_type != 1 # 防具1
auto_states += gain_armor_auto_state(@armor1_id)
end
if equipment_type != 2 # 防具2
auto_states += gain_armor_auto_state(@armor2_id)
end
if equipment_type != 3 # 防具3
auto_states += gain_armor_auto_state(@armor3_id)
end
if equipment_type != 4 # 防具4
auto_states += gain_armor_auto_state(@armor4_id)
end
if equipment_type != 5 # 防具5
auto_states += gain_armor_auto_state(@armor5_id)
end
if equipment_type != 6 # 防具6
auto_states += gain_armor_auto_state(@armor6_id)
end
if equipment_type != 7 # 防具7
auto_states += gain_armor_auto_state(@armor7_id)
end
auto_states.each {|i| add_state(i, true)}
end
# 获取武器自动状态
def gain_weapon_auto_state(weapon_id)
weapon_auto_states = []
if $data_weapons[weapon_id] != nil
if WEAPON_AUTO_STATES[weapon_id] != nil
weapon_auto_states += WEAPON_AUTO_STATES[weapon_id]
end
end
weapon_auto_states
end
# 获取防具自动状态
def gain_armor_auto_state(armor_id)
armor_auto_states = []
if $data_armors[armor_id] != nil
if $data_armors[armor_id].auto_state_id != 0
armor_auto_states.push($data_armors[armor_id].auto_state_id)
end
if ARMOR_AUTO_STATES[armor_id] != nil
armor_auto_states += ARMOR_AUTO_STATES[armor_id]
end
end
armor_auto_states
end
end