查看: 1795|回复: 2

[已经过期] 如何让这个脚本对技能的注释也有效?

[复制链接]
梦石
0
星屑
710
在线时间
663 小时
注册时间
2012-10-21
回帖
251
发表于 2014-9-2 23:40:02 | 显示全部楼层 |阅读模式

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

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

×
这是一个元素吸收的脚本,受到相应元素攻击时不受伤害反而加血,

这个脚本能对玩家、职业、武器装备、状态、敌人的进行元素吸收,只要注释写<element absorb: x>,x是元素id就好
但是技能不行……我想让它也能够读取技能中的注释,使得学习某个技能后也能拥有这样的吸收效果,请问要怎么改呢?

[pre lang="ruby" line="1"]#==============================================================================
#
# ▼ Yanfly Engine Ace - Element Absorb v1.01
# -- Last Updated: 2012.01.23
# -- Level: Normal, Hard
# -- Requires: n/a
#
#==============================================================================

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

#==============================================================================
# ▼ Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2012.01.23 - Compatibility Update: Doppelganger
# 2011.12.14 - Started Script and Finished.
#
#==============================================================================
# ▼ Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Absorbing elements have been taken out of RPG Maker VX Ace despite being a
# possible feature in the past RPG Maker iterations. This script brings back
# the ability to absorb elemental rates by applying them as traits for actors,
# classes, weapons, armours, enemies, and states.
#
# If a target is inherently strong against the element absorbed, then more
# will be absorbed. If the target is inherently weak to the element absorbed,
# then less will be absorbed. The rate of which absorption takes effect is
# dependent on the target's natural affinity to the element.
#
#==============================================================================
# ▼ Instructions
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
#
# -----------------------------------------------------------------------------
# Actor Notetags - These notetags go in the actors notebox in the database.
# -----------------------------------------------------------------------------
# <element absorb: x>
# <element absorb: x, x>
# Grants a trait to absorb element x and heal the battler.
#
# -----------------------------------------------------------------------------
# Class Notetags - These notetags go in the class notebox in the database.
# -----------------------------------------------------------------------------
# <element absorb: x>
# <element absorb: x, x>
# Grants a trait to absorb element x and heal the battler.
#
# -----------------------------------------------------------------------------
# Weapons Notetags - These notetags go in the weapons notebox in the database.
# -----------------------------------------------------------------------------
# <element absorb: x>
# <element absorb: x, x>
# Grants a trait to absorb element x and heal the battler.
#
# -----------------------------------------------------------------------------
# Armour Notetags - These notetags go in the armours notebox in the database.
# -----------------------------------------------------------------------------
# <element absorb: x>
# <element absorb: x, x>
# Grants a trait to absorb element x and heal the battler.
#
# -----------------------------------------------------------------------------
# Enemy Notetags - These notetags go in the enemies notebox in the database.
# -----------------------------------------------------------------------------
# <element absorb: x>
# <element absorb: x, x>
# Grants a trait to absorb element x and heal the battler.
#
# -----------------------------------------------------------------------------
# State Notetags - These notetags go in the states notebox in the database.
# -----------------------------------------------------------------------------
# <element absorb: x>
# <element absorb: x, x>
# Grants a trait to absorb element x and heal the battler.
#
#==============================================================================
# ▼ Compatibility
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
# it will run with RPG Maker VX without adjusting.
#
#==============================================================================

module YEA
  module ELEMENT_ABSORB
   
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # - Absorption Settings -
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # Here, you can change how the game handles absorption when there are
    # multiple elements being calculated. If the following setting is set to
    # true, then the absorption takes priority. If false, then absorption is
    # ignored and the damage is calculated normally.
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    MULTI_ELEMENT_ABSORB_PRIORITY = true
   
  end # ELEMENT_ABSORB
end # YEA

#==============================================================================
# ▼ Editting anything past this point may potentially result in causing
# computer damage, incontinence, explosion of user's head, coma, death, and/or
# halitosis so edit at your own risk.
#==============================================================================

module YEA
  module REGEXP
  module BASEITEM
   
    ELE_ABSORB = /<(?:ELEMENT_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
星屑
2308
在线时间
4033 小时
注册时间
2010-10-4
回帖
10548

开拓者贵宾

发表于 2014-9-3 12:48:13 | 显示全部楼层
重定义 DataManager.load_notetags_eabs 、Game_BattlerBase#element_absorb? 方法。

点评

1.我在def self.load_notetags_eabs里,groups = [$data_actors……里面添加了$data_skills,但是无效…… 2.element_absorb?里要怎么改?return true if self.skill.element_absorb.inclu?   发表于 2014-9-3 12:55

评分

参与人数 1星屑 +132 收起 理由
VIPArcher + 132 喵。

查看全部评分

回复

使用道具 举报

梦石
0
星屑
710
在线时间
663 小时
注册时间
2012-10-21
回帖
251
 楼主| 发表于 2014-9-3 12:56:41 | 显示全部楼层
Game_BattlerBase#element_absorb?
里面添加
      return true if self.skill.element_absorb.include?(element_id)
就出错了……

点评

自己理解着改吧。我只说,依样画葫芦是改不出来的  发表于 2014-9-4 12:30
敌人没有技能的话,就会使得效果无效吧?不会出bug弹错吧?  发表于 2014-9-3 17:08
请在理解的基础上修改,尤其要理解 Game_BattlerBase 和 Game_Actor 。友情提示:默认脚本中敌人是没有技能的  发表于 2014-9-3 16:06
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部