查看: 2631|回复: 14

[有事请教] 如何让一个状态能够覆盖被装备赋予的自动状态

[复制链接]

素材区好人

梦石
5
星屑
12559
在线时间
4345 小时
注册时间
2011-7-21
回帖
2264

超评测参与极短28参与极短27参与极短26参与极短25参与极短24参与极短23参与极短22参与极短21参与

发表于 2025-8-7 20:30:58 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
本帖最后由 无忧谷主幻 于 2025-8-7 20:32 编辑

有2个状态,一个坚盾,一个上级坚盾,这两个状态只能存在一个,比如更上位的上级坚盾能够覆盖下位的坚盾,如果坚盾是通过技能或其他事件赋予的,只需要在状态变化勾上减号即可,但如果坚盾是装备赋予的就没用了
即使上级坚盾勾上减号,也无法覆盖被装备赋予的坚盾状态,那么如何才能覆盖被装备赋予的状态呢?
PS:毕竟是装备赋予的,如果上级坚盾消失后,原本的坚盾又会从新生效
梦石
0
星屑
442
在线时间
55 小时
注册时间
2024-5-5
回帖
4
发表于 2025-8-8 09:48:30 | 显示全部楼层
本帖最后由 7G8XJtX 于 2025-8-8 19:39 编辑

可能写的比较稀碎)应该不会出bug)
add_state改了下自动状态冲突时的附加方式,
下面一堆会在更换装备时刷新一遍全身装备的自动状态
这样原本被抵消的状态就会重附加了
[fold][pre lang="ruby"]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.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.minus_state_set.include?(state_id) &&
          !$data_states[state_id].minus_state_set.include?(i) &&
          @states_turn == -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.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
        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[/pre][/fold]
[fold][pre lang="ruby"]#数据库中的武器附带公共状态
WEAPON_AUTO_STATES = []
#WEAPON_AUTO_STATES[1] = [18,19] # 1号武器附加18,19号状态

#防具附带公共状态
ARMOR_AUTO_STATES = []
#ARMOR_AUTO_STATES[1] = [18,19]
#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
    @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)
  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
    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
    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[/pre][/fold]
Project1.zip (203.05 KB, 下载次数: 3)
回复

使用道具 举报

素材区好人

梦石
5
星屑
12559
在线时间
4345 小时
注册时间
2011-7-21
回帖
2264

超评测参与极短28参与极短27参与极短26参与极短25参与极短24参与极短23参与极短22参与极短21参与

 楼主| 发表于 2025-8-8 23:24:22 | 显示全部楼层
7G8XJtX 发表于 2025-8-8 09:48
可能写的比较稀碎)应该不会出bug)
add_state改了下自动状态冲突时的附加方式,
下面一堆会在更换装备时刷 ...

感谢,没想到装备附带多个状态以及卸下一个装备后,会取消另一个装备相同的自动状态,这两个我已经放弃的功能能够解决
不过能够技能施加的状态覆盖自动状态的功能还是失败了,果然没那么容易吗?
3.png 2.png 1.png
回复

使用道具 举报

梦石
0
星屑
442
在线时间
55 小时
注册时间
2024-5-5
回帖
4
发表于 2025-8-8 23:52:56 | 显示全部楼层
无忧谷主幻 发表于 2025-8-8 23:24
感谢,没想到装备附带多个状态以及卸下一个装备后,会取消另一个装备相同的自动状态,这两个我已经放弃的 ...

非强制附加也暂时覆盖自动状态吗,稍微有点不会了)
回复

使用道具 举报

素材区好人

梦石
5
星屑
12559
在线时间
4345 小时
注册时间
2011-7-21
回帖
2264

超评测参与极短28参与极短27参与极短26参与极短25参与极短24参与极短23参与极短22参与极短21参与

 楼主| 发表于 2025-8-9 13:34:36 | 显示全部楼层
7G8XJtX 发表于 2025-8-8 23:52
非强制附加也暂时覆盖自动状态吗,稍微有点不会了)

不过能有这两个意外收获,还是很感谢
回复

使用道具 举报

素材区好人

梦石
5
星屑
12559
在线时间
4345 小时
注册时间
2011-7-21
回帖
2264

超评测参与极短28参与极短27参与极短26参与极短25参与极短24参与极短23参与极短22参与极短21参与

 楼主| 发表于 2025-8-9 17:14:56 | 显示全部楼层
7G8XJtX 发表于 2025-8-8 23:52
非强制附加也暂时覆盖自动状态吗,稍微有点不会了)

突然发现,为何与装备扩展不兼容?@armor5~@armor7 应该都添加了啊
1.png
轩辕菜单+复杂物品分类.zip (489.35 KB, 下载次数: 4)
[pre lang="ruby"]
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.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.minus_state_set.include?(state_id) &&
          !$data_states[state_id].minus_state_set.include?(i) &&
          @states_turn == -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.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
        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





[/pre]
回复

使用道具 举报

梦石
0
星屑
442
在线时间
55 小时
注册时间
2024-5-5
回帖
4
发表于 2025-8-9 23:03:46 | 显示全部楼层
本帖最后由 7G8XJtX 于 2025-8-9 23:06 编辑
无忧谷主幻 发表于 2025-8-9 17:14
突然发现,为何与装备扩展不兼容?@armor5~@armor7 应该都添加了啊


你这里写成actor.armor5_id的话应该是调用$data_actors对象的armor5_id方法,但原版只有1到4的,也就是角色游戏开始身上4个防具,“装备项扩充&修正”里的setup是直接设了三个实例变量默认初期不装装备。嘛,我写的东西倒也没做兼容)
回复

使用道具 举报

素材区好人

梦石
5
星屑
12559
在线时间
4345 小时
注册时间
2011-7-21
回帖
2264

超评测参与极短28参与极短27参与极短26参与极短25参与极短24参与极短23参与极短22参与极短21参与

 楼主| 发表于 2025-8-10 11:11:04 | 显示全部楼层
7G8XJtX 发表于 2025-8-9 23:03
你这里写成actor.armor5_id的话应该是调用$data_actors对象的armor5_id方法,但原版只有1到4的,也就是角 ...

试着加了这段,还是不行,果然要从基础逻辑开始改吗?
[pre lang="ruby"]class RPG::Actor
  attr_accessor :armor5_id, :armor6_id, :armor7_id
  def initialize
    super
    @armor5_id = 0  # 默认不装备
    @armor6_id = 0
    @armor7_id = 0
  end
end[/pre]
回复

使用道具 举报

梦石
0
星屑
39236
在线时间
11155 小时
注册时间
2009-3-15
回帖
4768
发表于 2025-8-12 01:53:55 | 显示全部楼层
本帖最后由 soulsaga 于 2025-8-16 02:01 编辑

[pre lang="ruby"]
class Game_Battler
def states
    s=@states.clone
    for a in s
     for i in $data_states[a].minus_state_set
     s.delete(i) if s.include?(i)
   end
   end
    return s
    end
  end
end[/pre]

其实只要直接控制状态本身的就行了
只需要在状态变化勾上减号即可

下面的脚本即使装备多个附加相同状态的装备
卸下一个后还会保留同一个状态
[pre lang="ruby"]
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
  # ● 更新自动状态
  #     old_armor : 卸下防具
  #     new_armor : 装备防具
  #--------------------------------------------------------------------------
  def update_auto_state(old_armor, new_armor, type=1)
    add_state($data_armors[@armor1_id].auto_state_id, true) if @armor1_id!=0
    add_state($data_armors[@armor2_id].auto_state_id, true) if @armor2_id!=0
    add_state($data_armors[@armor3_id].auto_state_id, true) if @armor3_id!=0
    add_state($data_armors[@armor4_id].auto_state_id, true) if @armor4_id!=0
    add_state($data_armors[@armor5_id].auto_state_id, true) if @armor5_id!=0
    add_state($data_armors[@armor6_id].auto_state_id, true) if @armor6_id!=0
    add_state($data_armors[@armor7_id].auto_state_id, true) if @armor7_id!=0
    # 强制解除卸下防具的自动状态
    if old_armor != nil and old_armor.auto_state_id != 0
      remove_state(old_armor.auto_state_id, true)
    end
    # 强制附加装备防具的自动状态
    if new_armor != nil and new_armor.auto_state_id != 0
      add_state(new_armor.auto_state_id, true)
    end
  end
end[/pre]

@armor5_id = 0
@armor6_id = 0
@armor7_id = 0

setup那里改成0

update_auto_state(nil, $data_weapons[@weapon_id], 0)那也注译掉否则会报错
回复

使用道具 举报

素材区好人

梦石
5
星屑
12559
在线时间
4345 小时
注册时间
2011-7-21
回帖
2264

超评测参与极短28参与极短27参与极短26参与极短25参与极短24参与极短23参与极短22参与极短21参与

 楼主| 发表于 2025-8-15 23:46:26 | 显示全部楼层
soulsaga 发表于 2025-8-12 01:53
class Game_Battler
def states
    s=@states.clone

感谢,第一个问题大体上已经实现了,不过小瑕疵还是有的
因为12行报错,我删掉了12行的end,成功运行
首先,角色赋予了比坚盾更高一级的镜盾状态(3回合后消失)
1.png
之后,3回合过去,镜盾消失,变回坚盾,此时可以看到,状态动画已经切换回坚盾了,然而状态栏里的名字依然还是镜盾
2.png
之后,再次行动后,状态名才被改回来
3.png

至于更新自动状态,和装备扩展并不兼容,如果强行添加@armor5~@armor7,便会报错(上面几楼上传了装备扩展的工程)
4.png
5.png
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部