查看: 1417|回复: 4

[有事请教] YEA属性吸收的拓展需求(固定属性有效度和拓展增伤)

[复制链接]
梦石
0
星屑
192
在线时间
85 小时
注册时间
2024-1-8
回帖
11
发表于 2025-2-2 16:05:45 | 显示全部楼层 |阅读模式
悬赏100星屑未解决
本帖最后由 神隐的主犯 于 2025-2-6 19:40 编辑

厚着脸皮继续求助。首先先粘贴一下我的yea的属性吸收代码。

首先是在下的需求是——在我方(或者敌人)持有xx状态或者装备了xx装备,习得xx被动技能的情况下
属性有效度会固定锁死。

(固定有效度方面)、

(举个例子,假如敌人目前已经持有了yea这个脚本的火属性吸收效果,如果此时玩家给敌人挂了一个龙炎buff————效果为火有效度锁定为200%)

(那么实际效果是吸收效果会消失,用伤害为100的火技能去打会扣200血。)

(如果多个锁定效果同时生效,取最大的有效度。比如火有效锁定为50%和火属性有效度锁定为200%,实际效果是火属性有效度200%)



(拓展增伤方面)

(我之前试了老鹰大佬的属性减抗与比例加成,但是老鹰佬的代码和yea的吸收冲突了。应用加成后吸收就会出错。)

(预想的效果为————主角获得xxbuff或者装备了某个饰品,自身造成xx属性伤害时增伤一定比例,多个效果为加法计算)【本效果不无视有效度】

(举例1——————敌人火抗200%,主角持有火伤增加50%的buff。使用100火伤的机能时伤害为100*2*1.5=300

举例2——————敌人持有yea的火吸收,主角持有火伤增加50%的buff。使用100火伤的机能时伤害为100*2*1.5*吸收=BOSS回血300点

举例3————敌人持有yea的火吸收,但是同时持有(固定火抗为200%),主角持有火伤增加50%的buff,使用100火伤的机能时伤害为100*2*1.5=300

)



ps——如果不方便同时搞,优先能实现和yea吸收不冲突的固定属性有效度也行








[pre lang="ruby"]#==============================================================================
#
# ▼ Yanfly Engine Ace - 属性吸收 v1.02
# -- 最后更新: 2012.08.23
# -- 使用难度: 简单
# -- 需要脚本: 无
#
#==============================================================================

$imported = {} if $imported.nil?
$imported["YEA-Element Absorb"] = true

#==============================================================================
# ▼ Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2012.01.23 - Compatibility Update: Doppelganger
# 2011.12.14 - Started Script and Finished.
#
#==============================================================================
# ▼ 介绍
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 属性吸收是一个被RPG Maker VX Ace抛弃的,之前RM都有的功能.
# 本脚本将重新为角色,职业,武器,护甲,敌人,状态增加属性吸收的特性。
#
# 如果目标有高于100%属性抗性的特性,则会吸收更多的伤害,有低于100%属性抗性的特性,
# 会吸收较少的伤害.
#
#==============================================================================
# ▼ 安装方式
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 打开脚本编辑器,将本脚本拷贝/复制到一个在▼ 插件脚本之下▼ Main之上的新
# 脚本页/槽中.记得保存你的工程以使脚本生效.
#
# -----------------------------------------------------------------------------
# 角色备注 - 在数据库-角色中可以使用的备注.
# -----------------------------------------------------------------------------
# <属性吸收: x>
# <属性吸收: x, x>
# x号属性的伤害会被该角色吸收.
#
# -----------------------------------------------------------------------------
# 职业备注 - 在数据库-职业中可以使用的备注.
# -----------------------------------------------------------------------------
# <属性吸收: x>
# <属性吸收: x, x>
# x号属性的伤害会被该职业吸收.
#
# -----------------------------------------------------------------------------
# 武器备注 - 在数据库-武器中可以使用的备注.
# -----------------------------------------------------------------------------
# <属性吸收: x>
# <属性吸收: x, x>
# x号属性的伤害会被装备该武器的角色吸收.
#
# -----------------------------------------------------------------------------
# 护甲备注 - 在数据库-护甲中可以使用的备注.
# -----------------------------------------------------------------------------
# <属性吸收: x>
# <属性吸收: x, x>
# x号属性的伤害会被装备该胡杰的角色吸收.
#
# -----------------------------------------------------------------------------
# 敌人备注 - 在数据库-敌人中可以使用的备注.
# -----------------------------------------------------------------------------
# <属性吸收: x>
# <属性吸收: x, x>
# x号属性的伤害会被该敌人吸收.
#
# -----------------------------------------------------------------------------
# 状态备注 - 在数据库-状态中可以使用的备注.
# -----------------------------------------------------------------------------
# <属性吸收: x>
# <属性吸收: x, x>
# x号属性的伤害会被获得该状态的角色/敌人吸收.
#
#==============================================================================
# ▼ 兼容性
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 本脚本仅为RPG Maker VX Ace编写.极不可能在无任何修改的情况下运行于RPG Maker VX.
#
#==============================================================================

module YEA
  module ELEMENT_ABSORB
   
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # - 吸收设置 -
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # 设定多属性伤害的最终效果。设定为true为属性吸收优先,false为无视属性吸收
    # 伤害照常计算。
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    MULTI_ELEMENT_ABSORB_PRIORITY = true
   
  end # ELEMENT_ABSORB
end # YEA

#==============================================================================
# ▼ 编辑以下内容可能会出现电脑损坏、死机,电脑主人脑袋爆炸、昏迷、死亡或口臭
# 所以编辑了后果自负。
#==============================================================================

module YEA
  module REGEXP
  module BASEITEM
   
    ELE_ABSORB = /<(?:ELEMENT_ABSORB|属性吸收):[ ]*(\d+(?:\s*,\s*\d+)*)>/i
   
  end # BASEITEM
  end # REGEXP
end # YEA

#==============================================================================
# ■ DataManager
#==============================================================================

module DataManager
  
  #--------------------------------------------------------------------------
  # alias method: load_database
  #--------------------------------------------------------------------------
  class <<self; alias load_database_eabs load_database; end
  def self.load_database
    load_database_eabs
    load_notetags_eabs
  end
  
  #--------------------------------------------------------------------------
  # new method: load_notetags_eabs
  #--------------------------------------------------------------------------
  def self.load_notetags_eabs
    groups = [$data_actors, $data_classes, $data_weapons, $data_armors,
      $data_enemies, $data_states]
    for group in groups
      for obj in group
        next if obj.nil?
        obj.load_notetags_eabs
      end
    end
  end
  
end # DataManager

#==============================================================================
# ■ RPG::BaseItem
#==============================================================================

class RPG::BaseItem
  
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :element_absorb
  
  #--------------------------------------------------------------------------
  # common cache: load_notetags_eabs
  #--------------------------------------------------------------------------
  def load_notetags_eabs
    @element_absorb = []
    #---
    self.note.split(/[\r\n]+/).each { |line|
      case line
      #---
      when YEA::REGEXP::BASEITEM::ELE_ABSORB
        $1.scan(/\d+/).each { |num|
        @element_absorb.push(num.to_i) if num.to_i > 0 }
      #---
      end
    } # self.note.split
    #---
  end
  
end # RPG::BaseItem

#==============================================================================
# ■ Game_BattlerBase
#==============================================================================

class Game_BattlerBase
  
  #--------------------------------------------------------------------------
  # alias method: element_rate
  #--------------------------------------------------------------------------
  alias game_battler_element_rate_eabs element_rate
  def element_rate(element_id)
    result = game_battler_element_rate_eabs(element_id)
    if element_absorb?(element_id)
      result = [result - 2.0, -0.01].min
    end
    return result
  end
  
  #--------------------------------------------------------------------------
  # new method: element_absorb?
  #--------------------------------------------------------------------------
  def element_absorb?(element_id)
    if actor?
      return true if self.actor.element_absorb.include?(element_id)
      return true if self.class.element_absorb.include?(element_id)
      for equip in equips
        next if equip.nil?
        return true if equip.element_absorb.include?(element_id)
      end
    else
      return true if self.enemy.element_absorb.include?(element_id)
      if $imported["YEA-Doppelganger"] && !self.class.nil?
        return true if self.class.element_absorb.include?(element_id)
      end
    end
    for state in states
      next if state.nil?
      return true if state.element_absorb.include?(element_id)
    end
    return false
  end
  
end # Game_BattlerBase

#==============================================================================
# ■ Game_Battler
#==============================================================================

class Game_Battler < Game_BattlerBase
  
  #--------------------------------------------------------------------------
  # alias method: elements_max_rate
  #--------------------------------------------------------------------------
  alias game_battler_elements_max_rate_eabs elements_max_rate
  def elements_max_rate(elements)
    result = game_battler_elements_max_rate_eabs(elements)
    if YEA::ELEMENT_ABSORB::MULTI_ELEMENT_ABSORB_PRIORITY
      for element_id in elements
        next unless element_absorb?(element_id)
        result = [result - 2.0, -0.01].min
        return result
      end
    end
    return result
  end
  
end # Game_Battler

#==============================================================================
#
# ▼ End of File
#
#==============================================================================[/pre]

梦石
0
星屑
4385
在线时间
2677 小时
注册时间
2012-3-1
回帖
680
发表于 2025-2-4 03:42:26 | 显示全部楼层
本帖最后由 卡奥尼特 于 2025-2-5 21:19 编辑

嗯…… 关于这个,目前有一个类似的脚本,就是这个。

说起来。

前阵子有个大佬给我写了类似的脚本,但是没有任何注释与使用说明,我根据自己的理解将注释部分进行了补充。

我把这个脚本贴出来。

脚本部分
  1. #encoding:utf-8
  2. #==============================================================================
  3. # ■ Meiyu_ElementCore
  4. #------------------------------------------------------------------------------
  5. #  元素核心脚本
  6. #==============================================================================
  7. =begin

  8. 默认公式:
  9. (base + plus) * rate + flat

  10. 使用方法:
  11. 除技能/物品以外的备注栏

  12. 其中,y 可以是 v[n], 将变量加入计算。

  13. <DEALT ELEMENT x RATE: y%>
  14. 计算ID为x属性的技能,伤害比率改为y%

  15. <DEALT ELEMENT x PLUS: +y%>
  16. <DEALT ELEMENT x PLUS: -y%>
  17. 计算ID为x属性的技能,伤害提升/减少y%

  18. <DEALT ELEMENT x FLAT: +y%>
  19. <DEALT ELEMENT x FLAT: -y%>
  20. 计算ID为x属性的技能,伤害额外提升/减少y%

  21. =end

  22. #----------------------------------------------------------------------------
  23. # ● 脚本部分
  24. #----------------------------------------------------------------------------
  25. #----------------------------------------------------------------------------
  26. # ● Game_BattlerBase
  27. #----------------------------------------------------------------------------
  28. class Game_BattlerBase
  29.   #--------------------------------------------------------------------------
  30.   # ● 常量(特性)
  31.   #--------------------------------------------------------------------------
  32.   MEIYU_ELEMENTCORE_TAG_PLUS = /<DEALT ELEMENT (\d+) PLUS:\s*(.+)%>/i
  33.   MEIYU_ELEMENTCORE_TAG_RATE = /<DEALT ELEMENT (\d+) RATE:\s*(.+)%>/i
  34.   MEIYU_ELEMENTCORE_TAG_FLAT = /<DEALT ELEMENT (\d+) FLAT:\s*(.+)%>/i
  35.   #--------------------------------------------------------------------------
  36.   # ● 获取Tag数组
  37.   #--------------------------------------------------------------------------
  38.   def meiyu_ElementCore_all_tags(reg)
  39.     feature_objects.inject([]) {|r, obj| r + obj.note.scan(reg)}
  40.   end
  41.   #--------------------------------------------------------------------------
  42.   # ● 获取元素增强Tag数组(限定元素ID)
  43.   #--------------------------------------------------------------------------
  44.   def meiyu_ElementCore_dealt_element_tags(reg, e_id)
  45.     meiyu_ElementCore_all_tags(reg).select {|match| match[0].to_i == e_id}
  46.   end
  47.   #--------------------------------------------------------------------------
  48.   # ● 获取元素增强sum值(限定元素ID)
  49.   #--------------------------------------------------------------------------
  50.   def meiyu_ElementCore_dealt_element_sum(reg, e_id)
  51.     meiyu_ElementCore_dealt_element_tags(reg, e_id).inject(0) do |r, match|
  52.       if (match[1] =~ /V\[(\d+)\]/i)
  53.         variable_id = $1.to_i
  54.         r += $game_variables[variable_id].to_f / 100
  55.       elsif (match[1] =~ /([+-]?\d+)/)
  56.         r += $1.to_f / 100
  57.       end
  58.       r
  59.     end
  60.   end
  61.   #--------------------------------------------------------------------------
  62.   # ● 获取元素增强pi值(限定元素ID)
  63.   #--------------------------------------------------------------------------
  64.   def meiyu_ElementCore_dealt_element_pi(reg, e_id)
  65.     meiyu_ElementCore_dealt_element_tags(reg, e_id).inject(1) do |r, match|
  66.       if (match[1] =~ /V\[(\d+)\]/i)
  67.         variable_id = $1.to_i
  68.         r *= $game_variables[variable_id].to_f / 100
  69.       elsif (match[1] =~ /([+-]?\d+)/)
  70.         r *= $1.to_f / 100
  71.       end
  72.       r
  73.     end
  74.   end
  75.   #--------------------------------------------------------------------------
  76.   # ● 获取元素增强Plus
  77.   #--------------------------------------------------------------------------
  78.   def meiyu_ElementCore_dealt_element_plus(e_id)
  79.     meiyu_ElementCore_dealt_element_sum(MEIYU_ELEMENTCORE_TAG_PLUS, e_id)
  80.   end
  81.   #--------------------------------------------------------------------------
  82.   # ● 获取元素增强Rate
  83.   #--------------------------------------------------------------------------
  84.   def meiyu_ElementCore_dealt_element_rate(e_id)
  85.     meiyu_ElementCore_dealt_element_pi(MEIYU_ELEMENTCORE_TAG_RATE, e_id)
  86.   end
  87.   #--------------------------------------------------------------------------
  88.   # ● 获取元素增强Flat
  89.   #--------------------------------------------------------------------------
  90.   def meiyu_ElementCore_dealt_element_flat(e_id)
  91.     meiyu_ElementCore_dealt_element_sum(MEIYU_ELEMENTCORE_TAG_FLAT, e_id)
  92.   end
  93. end

  94. #----------------------------------------------------------------------------
  95. # ● Game_Battler
  96. #----------------------------------------------------------------------------
  97. class Game_Battler < Game_BattlerBase
  98.   #--------------------------------------------------------------------------
  99.   # ● 获取技能/物品的属性修正值
  100.   #--------------------------------------------------------------------------
  101.   alias meiyu_ElementCore_item_element_rate item_element_rate
  102.   def item_element_rate(user, item)
  103.     e_id = meiyu_ElementCore_item_element_id(user, item)
  104.     base = meiyu_ElementCore_item_element_rate(user, item)
  105.     plus = user.meiyu_ElementCore_dealt_element_plus(e_id)
  106.     rate = user.meiyu_ElementCore_dealt_element_rate(e_id)
  107.     flat = user.meiyu_ElementCore_dealt_element_flat(e_id)
  108.     result = (base + plus) * rate + flat
  109.     puts "EID = #{e_id} (#{base} + #{plus}) * #{rate} + #{flat} = #{result}"
  110.     (base + plus) * rate + flat
  111.   end
  112.   #--------------------------------------------------------------------------
  113.   # ● 获取技能/物品的属性ID
  114.   #--------------------------------------------------------------------------
  115.   def meiyu_ElementCore_item_element_id(user, item)
  116.     if (item.damage.element_id < 0) and (not user.atk_elements.empty?)
  117.       element_rate_array = user.atk_elements.collect {|id| element_rate(id)}
  118.       index = element_rate_array.index(element_rate_array.max)
  119.       user.atk_elements[index]
  120.     else
  121.       item.damage.element_id
  122.     end
  123.   end
  124. end
复制代码
回复

使用道具 举报

梦石
0
星屑
192
在线时间
85 小时
注册时间
2024-1-8
回帖
11
 楼主| 发表于 2025-2-5 19:13:47 | 显示全部楼层
卡奥尼特 发表于 2025-2-4 03:42
嗯…… 关于这个,目前有一个类似的脚本,就是这个。

说起来。

试了一下…………果然覆盖掉了yea的这个吸收属性……

点评

这样嗷,害。  发表于 2025-2-5 19:52
回复

使用道具 举报

梦石
0
星屑
4385
在线时间
2677 小时
注册时间
2012-3-1
回帖
680
发表于 2025-2-5 20:17:39 | 显示全部楼层
本帖最后由 卡奥尼特 于 2025-2-5 21:05 编辑
神隐的主犯 发表于 2025-2-5 19:13
试了一下…………果然覆盖掉了yea的这个吸收属性……




隐藏这么说起来,吸收。
我用这个的时候,将rate设定为负数后,
所呈现的效果,我攻击敌人,变成了回血。

具体做法,是先将 RATE 改为 0%。
然后是将 FLAT 设定为负值。比如 -100%,-50% 什么的。
然后敌人使用相关的属性攻击,就变成了回血效果。

你之前测试的脚本做不到,我改成了我现在使用的版本。




姆,我好像搞反了,这个改的是攻击方的,不是对手方。
只适用于元素增伤。
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部