查看: 4411|回复: 1

[已经解决] 哪位大神知道附魔脚本怎么用?

[复制链接]
梦石
0
星屑
49
在线时间
491 小时
注册时间
2012-1-27
回帖
399

整合系统大赛RMVA达人

发表于 2013-2-11 22:37:06 | 显示全部楼层 |阅读模式

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

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

×
看了下代码,只知道在武器注释里添加<enchant>别的都看不懂~
[pre lang="ruby" line="1"]#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#  ▼ Traits Namer
#  Author: Kread-EX
#  Version: 1.01
#  Release date: 11/03/2012
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

#-------------------------------------------------------------------------------------------------
#  ▼ UPDATES
#-------------------------------------------------------------------------------------------------
# # 24/03/2012. Added methods used by Alchemic Synthesis.
# # 23/03/2012. Version 1.0, now help window generation is included.
#-------------------------------------------------------------------------------------------------
#  ▼ TERMS OF USAGE
#-------------------------------------------------------------------------------------------------
# #  You are free to adapt this work to suit your needs.
# #  You can use this work for commercial purposes if you like it.
# #  Credit is appreciated.
# #
# # For support:
# # grimoirecastle.wordpress.com
# # rpgmakerweb.com
# # rpgrevolution.com
#-------------------------------------------------------------------------------------------------
#  ▼ INTRODUCTION
#-------------------------------------------------------------------------------------------------
# # This is a core script. By itself, it doesn't do anything but it used by
# # Runic Enchantment and Alchemic Synthesis. The purpose of this script
# # is to provide an automated way to name traits: the script retrieve the traits
# # data and generates a name based on a customizable template.
#-------------------------------------------------------------------------------------------------

$imported = {} if $imported.nil?
$imported['KRX-TraitsNamer'] = true

puts 'Load: Traits Namer v1.01 by Kread-EX'

module KRX
  module TraitsNamer
#===========================================================================
# ■ CONFIGURATION
#===========================================================================

    X_PARAMETERS = [
   
    'Accuracy',
    'Evasion',
    'Critical rate',
    'M. Evasion',
    'Counter rate',
    'HP Regen',
    'MP Regen',
    'TP Regen'
   
    ]
   
    S_PARAMETERS = [
   
    'Aggro effect',
    'Guard effect',
    'Recovery rate',
    'Pharmacology',
    'MP cost',
    'TP charge rate',
    'Physical damage',
    'Magical damage',
    'Floor damage',
    'EXP rate'
   
    ]

    SPECIAL_FLAGS = [
   
    'Autobattle',
    'Guard',
    'Cover',
    'TP Saver'
   
    ]
   
    PARTY_ABILITY = [
   
    'Half Encounter',
    'No Encounter',
    'No surprise attacks',
    'No preemptive attacks',
    'Gold x2',
    'Item Drops x2'
   
    ]
   
    CODENAMES = {
   
    11 => '%s resist: %d%%'       , # Element rate
    12 => '%s debuff rate: %d%%'  , # Debuff rate
    13 => '%s resist: %d%%'       , # State rate
    14 => 'Immunity: %s'          , # State immunity
    21 => '%s: %d%%'              , # Parameter rate
    22 => '%s: %d%%'              , # Additional parameter rate
    23 => '%s: %d%%'              , # Special parameter rate
    31 => 'Attack %s'             , # Physical attack attribute
    32 => 'Attack %s %d%%'        , # Physical attack state
    33 => 'Attack speed %d'       , # Attack speed correction
    34 => 'Attack x%d'            , # Additional attacks
    41 => 'Command: %s'           , # Add skill type
    42 => 'Seal: %s'              , # Seal skill type
    43 => 'Skill: %s'             , # Add skill
    44 => 'Skill Seal: %s'        , # Seal skill
    51 => 'Can equip: %s'         , # Add equip type (weapon)
    52 => 'Can equip: %s'         , # Add equip type (armor)
    53 => 'Fix equip: %s'         , # Fix equip slot
    54 => 'Seal equip: %s'        , # Seal equip slot
    55 => 'Dual Wielding'         , # Dual Wield
    61 => 'Bonus Actions: +%d%%'  , # Bonus actions
    62 => '%s'                    , # Special flag
    63 => 'Collapse type'         , # Collapse type (will never be used, I think)
    64 => '%s'                    , # Party ability
   
    }
   
    CODEHELP = {
   
    # Element rate
    11 => 'Grants %d%% %s resistance.',
    # Debuff rate
    12 => 'Grants %d%% resistance to %s debuff.',
    # State rate
    13 => 'Grants %d%% %s resistance.',
    # State immunity
    14 => 'Grants immunity to %s.',
    # Parameter rate
    21 => 'Raises %s by %d%%.',
    # Additional parameter rate
    22 => 'Raises %s by %d%%.',
    # Special parameter rate
    23 => 'Grants a %d% modifier to %s.',
    # Physical attack attribute
    31 => 'Adds %s element to normal attacks.',
    # Physical attack state
    32 => 'Adds %s to normal attacks (%d%% accuracy).',
    # Attack speed correction (bonus)
    33 => ['Raises attack speed by %d.',
    # Attack speed correction (malus)
    'Reduces attack speed by %d.'],
    # Additional attacks
    34 => 'Grants %d additional attacks.',
    # Add skill type
    41 => 'Enables the %s battle command.',
    # Seal skill type
    42 => 'Seals the %s battle command.',
    # Add skill
    43 => 'Allows the use of the %s skill',
    # Seal skill
    44 => 'Seals the %s skill.',
    # Add equip type (weapon)
    51 => 'Allows %s to be equipped.',
    # Add equip type (armor)
    52 => 'Allows %s to be equipped.',
    # Fix equip slot
    53 => 'Fixes the %s equipment slot.',
    # Seal equip slot
    54 => 'Seals the %s equipment slot.',
    # Dual Wield
    55 => 'Allows to use two weapons as the same time.',
    # Bonus actions
    61 => 'Raises the action rate by %d%%.',
    # Autobattle
    62 => ['The character will act on his/her own in battle.',
    # Guard
    'The character will permanently defend.',
    # Cover
    'The character will take hits for his/her wounded comrades.',
    # TP Saver
    'TP are kept after battles.'],
    # Collapse type (no need to use it but meh)
    63 => 'Alters the collapse animation.',
    # Half encounter
    64 => ['Halves the random encounter rate.',
    # No encounter
    'Disables random encounters.',
    # No surprise attacks
    'Disables surprise attacks.',
    # No preemptive attacks
    'Disables preemptive attacks.',
    # Gold x2
    'Doubles the money obtained after a battle.',
    # Item Drops x2
    'Doubles the drop rate of items.']
   
    }

    EFFECTS_CODENAMES = {
   
    11 => 'HP Recovery'                   , # HP Recovery
    12 => 'MP Recovery'                   , # MP Recovery
    13 => 'TP Recovery'                   , # TP Gain
    21 => 'Add %s'                        , # Add State
    22 => 'Cleanse %s'                    , # Remove State
    31 => '%s+'                           , # Add buff
    32 => '%s-'                           , # Add debuff
    33 => 'Dispel %s+'                    , # Remove buff
    34 => 'Cancel %s-'                    , # Remove debuff
    41 => 'Escape'                        , # Escape
    42 => '%s Bonus'                      , # Permanent stat growth
    43 => 'Learn %s'                      , # Permanent skill learning
    44 => 'Common Event'                  , # Common event
   
    }
   
    EFFECTS_CODEHELP = {
   
    # HP Recovery (static)
    11 => ['Restores %d HP.',
    # HP Recovery (dynamic)
    'Restores %d%% of maximum HP.'],
    # MP Recovery (static)
    12 => ['Restores %d MP.',
    # MP Recovery (dynamic)
    'Restores %d%% of maximum MP.'],
    # TP Gain
    13 => 'Restores %d%% TP.',
    # Add State
    21 => 'Inflicts %s (%d%% chance).',
    # Remove State
    22 => 'Cancels %s.',
    # Add buff
    31 => 'Increases %s for %d turns.',
    # Add debuff
    32 => 'Decreases %s for %d turns.',
    # Remove buff
    33 => 'Cancels a previously applied %s buff.',
    # Remove debuff
    34 => 'Dispels an active %s debuff.',
    # Escape
    41 => 'Automatically escape from battle.',
    # Permanent stat growth
    42 => 'Boosts %d by %d permanently.',
    # Permanent skill learning
    43 => 'Teaches the %s skill permanently.',
    # Common Event
    44 => 'Calls a common event.'
   
    }
   
#===========================================================================
# ■ CUSTOM TRAITS/EFFECTS CONFIGURATION
#===========================================================================

    # INSTRUCTIONS
    # Here you can define custom traits names and descriptions.
    #
    # Syntax:
    # [type, code, data_id, value 1, value2] => [name, description]
    #
    # type: 0 (for equipment), 1 (for usables)
    #
    # code: the code number. Refer to default naming to know what is what.
    #
    # data_id: the number of the option you've choosen in the trait droplist.
    #
    # value1: what you typed in the first field where you can write numbers.
    # For equipment this is the only one.
    #
    # value2: usable items only. What you typed in the second field.
    #
    # description: If you want to also use a custom description. If you only
    # want the custom name, set this to nil.

    CUSTOM_TRAITS = {
   
    [0, 32, 2, 50] => ['Poisonous', nil],
    [0, 32, 2, 100] => ['Venomous', nil],
   
    [1, 11, 0, 0, 10] => ['HP Recovery XS', nil],
    [1, 11, 0, 0, 25] => ['HP Recovery S', nil],
    [1, 11, 0, 0, 50] => ['HP Recovery M', nil],
    [1, 11, 0, 0, 75] => ['HP Recovery L', nil],
    [1, 11, 0, 0, 100] => ['HP Recovery XL', 'Restores all HP!'],
    [1, 12, 0, 0, 10] => ['MP Recovery XS', nil],
    [1, 12, 0, 0, 25] => ['MP Recovery S', nil],
    [1, 12, 0, 0, 50] => ['MP Recovery M', nil],
    [1, 12, 0, 0, 75] => ['MP Recovery L', nil],
    [1, 12, 0, 0, 100] => ['MP Recovery XL', 'Restores all MP!'],
    [1, 13, 0, 2, 0] => ['TP Recovery XS', nil],
    [1, 13, 0, 5, 0] => ['TP Recovery S', nil],
    [1, 13, 0, 10, 0] => ['TP Recovery M', nil],
    [1, 13, 0, 16, 0] => ['TP Recovery L', nil],
    [1, 13, 0, 20, 0] => ['TP Recovery XL', nil],
   
    }
   
#===========================================================================
# ■ CONFIGURATION ENDS HERE
#===========================================================================
    #--------------------------------------------------------------------------
    # ● Generates traits name
    #--------------------------------------------------------------------------
    def self.feature_name(code, data_id, value)
      custom = CUSTOM_TRAITS[[0, code, data_id, self.convert_value(code, value)]]
      return custom[0] unless custom.nil? || custom[0].nil?
      base_name = CODENAMES[code]
      data_name = case code
        when 11, 31
          $data_system.elements[data_id]
        when 12, 21
          Vocab.param(data_id)
        when 13, 14, 32
          $data_states[data_id].name
        when 22
          X_PARAMETERS[data_id]
        when 23
          S_PARAMETERS[data_id]
        when 41, 42
          $data_system.skill_types[data_id]
        when 43, 44
          $data_skills[data_id].name
        when 51
          $data_system.weapon_types[data_id]
        when 52
          $data_system.armor_types[data_id]
        when 53, 54
          Vocab.etype(data_id)
        when 62
          SPECIAL_FLAGS[data_id]
        when 64
          PARTY_ABILITY[data_id]
        end
      final_value = case code
        when 11, 13
          100 - (value * 100)
        when 33, 34
          value
        else
          value * 100
        end
      if data_name.nil?
        name = sprintf(base_name, final_value)
      else
        name = sprintf(base_name, data_name, final_value)
      end
      name
    end
    #--------------------------------------------------------------------------
    # ● Generates traits description
    #--------------------------------------------------------------------------
    def self.feature_description(code, data_id, value)
      custom = CUSTOM_TRAITS[[0, code, data_id, self.convert_value(code, value)]]
      return custom[1] unless custom.nil? || custom[1].nil?
      if CODEHELP[code].is_a?(Array)
        base_help = CODEHELP[code][data_id]
      else
        base_help = CODEHELP[code]
      end
      data_name = case code
        when 11, 31
          $data_system.elements[data_id]
        when 12, 21
          Vocab.param(data_id)
        when 13, 14, 32
          $data_states[data_id].name
        when 22
          X_PARAMETERS[data_id]
        when 23
          S_PARAMETERS[data_id]
        when 41, 42
          $data_system.skill_types[data_id]
        when 43, 44
          $data_skills[data_id].name
        when 51
          $data_system.weapon_types[data_id]
        when 52
          $data_system.armor_types[data_id]
        when 53, 54
          Vocab.etype(data_id)
        when 62
          SPECIAL_FLAGS[data_id]
        when 64
          PARTY_ABILITY[data_id]
        end
      final_value = case code
        when 11, 13
          100 - (value * 100)
        when 33, 34
          value
        else
          value * 100
        end
      if data_name.nil?
        name = sprintf(base_help, final_value)
      else
        name = sprintf(base_help, data_name, final_value)
      end
      name
    end
    #--------------------------------------------------------------------------
    # ● Generates effects name
    #--------------------------------------------------------------------------
    def self.effect_name(code, data_id, value1, value2)
      custom = CUSTOM_TRAITS[[1, code, data_id,
      self.convert_value(code, value1, false),
      self.convert_value(code, value2, false)]]
      return custom[0] unless custom.nil? || custom[0].nil?
      base_name = EFFECTS_CODENAMES[code]
      data_name = case code
        when 21, 22
          $data_states[data_id].name
        when 31, 32, 33, 34, 42
          Vocab.param(data_id)
        when 43
          $data_skills[data_id]
        end
      if data_name.nil?
        name = sprintf(base_name, value1, value2)
      else
        name = sprintf(base_name, data_name, value1, value2)
      end
      name
    end
    #--------------------------------------------------------------------------
    # ● Generates effects description
    #--------------------------------------------------------------------------
    def self.effect_description(code, data_id, value1, value2)
      custom = CUSTOM_TRAITS[[1, code, data_id,
      self.convert_value(code, value1, false),
      self.convert_value(code, value2, false)]]
      return custom[1] unless custom.nil? || custom[1].nil?
      if EFFECTS_CODEHELP[code].is_a?(Array)
        base_help = value2 > 0 ? EFFECTS_CODEHELP[code][0] :
        EFFECTS_CODEHELP[code][1]
      else
        base_help = EFFECTS_CODEHELP[code]
      end
      data_name = case code
        when 21, 22
          $data_states[data_id].name
        when 31, 32, 33, 34, 42
          Vocab.param(data_id)
        when 43
          $data_skills[data_id]
        end
      value1 = self.convert_value(code, value1, false)
      value2 = self.convert_value(code, value2, false)
      value1 = value2 if value1 == 0
      if data_name.nil?
        name = sprintf(base_help, value1, value2)
      else
        name = sprintf(base_help, data_name, value1, value2)
      end
      name
    end
    #--------------------------------------------------------------------------
    # ● Converts the real value to the one entered in the editor
    #--------------------------------------------------------------------------
    def self.convert_value(code, value, feature = true)
      if feature && [33, 34].include?(code)
        return value.to_i
      elsif feature && [21].include?(code)
        return (value.to_f / 100)
      elsif [11, 12].include?(code) && value <= 1
        return (value.to_i * 100).to_i
      elsif [21, 22].include?(code)
        return (value * 100).to_i
      else
        value.to_i
      end
    end
    #--------------------------------------------------------------------------
    # ● Points towards either feature name or effect name
    #--------------------------------------------------------------------------
    def self.trait_name(trait)
      if trait.is_a?(RPG::BaseItem::Feature)
        return self.feature_name(trait.code, trait.data_id, trait.value)
      end
      self.effect_name(trait.code, trait.data_id, trait.value1, trait.value2)
    end
    #--------------------------------------------------------------------------
    # ● Points towards either feature description or effect description
    #--------------------------------------------------------------------------
    def self.trait_description(trait)
      if trait.is_a?(RPG::BaseItem::Feature)
        return self.feature_description(trait.code, trait.data_id, trait.value)
      end
      self.effect_description(trait.code, trait.data_id, trait.value1,
      trait.value2)
    end
  end
end[/pre]
[pre lang="ruby" line="1"]#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#  ▼ Runic Enchantment
#  Author: Kread-EX
#  Version 1.06
#  Release date: 11/03/2012
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

#-------------------------------------------------------------------------------------------------
#  ▼ UPDATES
#-------------------------------------------------------------------------------------------------
# # 02/06/2012. Now lists equipped items.
# # 19/03/2012. Fixed a crashing bug.
# # 17/03/2012. Added the option to limit runes to either the weapon or the
# # armor. Runes can also be set as impossible to double up on the same
# # equipment piece.
# # Also, bugfixes.
#-------------------------------------------------------------------------------------------------
#  ▼ TERMS OF USAGE
#-------------------------------------------------------------------------------------------------
# #  You are free to adapt this work to suit your needs.
# #  You can use this work for commercial purposes if you like it.
# #  Credit is appreciated.
# #
# # For support:
# # grimoirecastle.wordpress.com
# # rpgmakerweb.com
# # rpgrevolution.com
#-------------------------------------------------------------------------------------------------
#  ▼ INTRODUCTION
#-------------------------------------------------------------------------------------------------
# # An enchantment system inspired from Dragon's Age. Recommended to use only
# # for unique weapons and armors.
#-------------------------------------------------------------------------------------------------
#  ▼ INSTRUCTIONS
#-------------------------------------------------------------------------------------------------
# # REQUIRES THE TRAITS NAMER:
# # http://grimoirecastle.wordpress. ... ripts/traits-namer/
# #
# # Tag enchant-able weapons with <enchant> in their notebox.
# # Modify rune slots with <rune_slots: x>
# #
# # Runes are armors with the <rune> notetag and None as an armor type.
# # <weapon_rune> Limits the rune to a weapon.
# # <armor_rune> Limits the rune to an armor.
# # <unique_rune> Only one of those on the same piece.
# #
# # Use SceneManager.call(Scene_Enchant) to enter the scene or use Yanfly's
# # Ace Menu Engine.
#-------------------------------------------------------------------------------------------------
#  ▼ COMPATIBILITY
#-------------------------------------------------------------------------------------------------
# # List of aliases and overwrites:
# #
# # DataManager
# # load_database (alias)
# # load_sandal_notetags (new method)
# #
# # RPG::EquipItem
# # can_enchant (new attr method)
# # rune_slots (new attr method)
# # rune_type (new attr method)
# # rune_unique (new attr method)
# # load_sandal_notetags (new method)
# # is_rune? (new method)
# # static_rune_params (new method)
# #
# # Game_Actor
# # feature_objects (alias)
# #
# # Game_Party
# # enchants_w (new method)
# # enchants_a (new method)
# # equipped_items (new method)
# #
# # Scene_Enchant (new class)
# # Window_EnchantList (new class)
# # Window_RuneList (new class)
# # Window_ViewRunes (new class)
# # Window_ViewRunesTraits (new class)
#-------------------------------------------------------------------------------------------------

# Quits if the Traits Namer isn't found

if $imported.nil? || $imported['KRX-TraitsNamer'].nil?
       
msgbox('You need the Traits Namer in order to use Runic Enchantment. Loading aborted.')

else

$imported['KRX-Enchantment'] = true

puts 'Load: Enchantment v1.06 by Kread-EX'

#===========================================================================
# ■ CONFIGURATION
#===========================================================================

module KRX
  
  # The max rune slots by default.
  RUNE_SLOTS_MAX = 5
   
  module VOCAB
    # Runes name in menus.
    RUNE_NAME = '符文'
    # Runes traits name
    RUNE_TRAITS_NAME = '属性'
  end
#===========================================================================
# ■ CONFIGURATION ENDS HERE
#===========================================================================
  module REGEXP
    ALLOW_ENCHANT = /<enchant>/i
    RUNE = /<rune>/i
    RUNE_SLOTS = /<rune_slots:[ ]*(\d+)>/i
    RUNE_WEAPON = /<weapon_rune>/i
    RUNE_ARMOR = /<armor_rune>/i
    RUNE_UNIQUE = /<unique_rune>/i
  end
end

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

module DataManager
        #--------------------------------------------------------------------------
        # ● Loads the database
        #--------------------------------------------------------------------------
        class << self
                alias_method(:krx_sandal_dm_load_database, :load_database)
        end
        def self.load_database
                krx_sandal_dm_load_database
                load_sandal_notetags
        end  
        #--------------------------------------------------------------------------
        # ● Loads the note tags
        #--------------------------------------------------------------------------
        def self.load_sandal_notetags
                groups = [$data_weapons, $data_armors]
                for group in groups
                        for obj in group
                                next if obj.nil?
                                obj.load_sandal_notetags
                        end
                end
                puts "Read: Enchantment Notetags"
        end
end

#===========================================================================
# ■ RPG::EquipItem
#===========================================================================

class RPG::EquipItem
        #--------------------------------------------------------------------------
        # ● Public instance variables
        #--------------------------------------------------------------------------
  attr_reader   :can_enchant
  attr_reader   :rune_slots
  attr_reader   :rune_type
  attr_reader   :rune_unique
        #--------------------------------------------------------------------------
        # ● Loads the note tags
        #--------------------------------------------------------------------------
        def load_sandal_notetags
    @rune_slots = KRX::RUNE_SLOTS_MAX
                @note.split(/[\r\n]+/).each do |line|
                        case line
                        when KRX::REGEXP::ALLOW_ENCHANT
                                @can_enchant = true
      when KRX::REGEXP::RUNE
        @is_rune = true
      when KRX::REGEXP::RUNE_SLOTS
        @rune_slots = $1.to_i
      when KRX::REGEXP::RUNE_WEAPON
        @rune_type = :weapon
      when KRX::REGEXP::RUNE_ARMOR
        @rune_type = :armor
      when KRX::REGEXP::RUNE_UNIQUE
        @rune_unique = true
                        end
                end
        end
        #--------------------------------------------------------------------------
        # ● Determine if the item is a rune
        #--------------------------------------------------------------------------
  def is_rune?
    @is_rune && self.is_a?(RPG::Armor)
  end
end

#===========================================================================
# ■ Game_Actor
#===========================================================================

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # ● Returns the list of traits
  #--------------------------------------------------------------------------
  alias_method(:krx_sandal_ga_fo, :feature_objects)
  def feature_objects
    runes = []
    equips.compact.each do |equip|
      container = equip.is_a?(RPG::Weapon) ? $game_party.enchants_w :
      $game_party.enchants_a
      next if container[equip.id].nil?
      ids = container[equip.id]
      ids.each do |id|
        next if id.nil?
        runes.push($data_armors[id])
      end
    end
    krx_sandal_ga_fo + runes.compact
  end
end

#===========================================================================
# ■ Game_Party
#===========================================================================

class Game_Party < Game_Unit
        #--------------------------------------------------------------------------
        # ● Returns the items equipped by all actors
        #--------------------------------------------------------------------------
  def equipped_items
    result = []
    members.each {|actor| result.push(actor.equips)}
    return result.flatten
  end
        #--------------------------------------------------------------------------
        # ● Returns weapon enchantments
        #--------------------------------------------------------------------------
  def enchants_w
    @enchants_w ||= {}
  end
        #--------------------------------------------------------------------------
        # ● Returns armor enchantments
        #--------------------------------------------------------------------------
  def enchants_a
    @enchants_a ||= {}
  end
        #--------------------------------------------------------------------------
        # ● Inscribes a rune
        #--------------------------------------------------------------------------
  def inscribe_rune(e_type, e_id, r_id, r_index)
    container = e_type == RPG::Weapon ? @enchants_w : @enchants_a
    container[e_id] = [] if container[e_id].nil?
    if container[e_id][r_index] != nil
      item = $data_armors[container[e_id][r_index]]
      gain_item(item, 1)
    end
    lose_item($data_armors[r_id], 1) unless r_id.nil?
    container[e_id][r_index] = r_id
  end
end

#==========================================================================
# ■ Window_EnchantList
#==========================================================================
       
class Window_EnchantList < Window_ItemList
        #--------------------------------------------------------------------------
        # ● Object Initialize
        #--------------------------------------------------------------------------
        def initialize(x, y, w, h)
                super(x, y, w, h)
                refresh
    select(0)
    activate
        end
        #--------------------------------------------------------------------------
        # ● Enable (always true)
        #--------------------------------------------------------------------------
        def enable?(item)
                item != nil
        end
        #--------------------------------------------------------------------------
        # ● Creates the list based on the recipes
        #--------------------------------------------------------------------------
        def make_item_list
                @data = []
    ($game_party.all_items + $game_party.equipped_items).each do |itm|
      next if @data.include?(itm)
      @data.push(itm) if itm.is_a?(RPG::EquipItem) && itm.can_enchant
    end
        end
  #--------------------------------------------------------------------------
  # ● Displays the item
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    if item
      rect = item_rect(index)
      rect.width -= 4
      draw_item_name(item, rect.x, rect.y, enable?(item))
    end
  end
        #--------------------------------------------------------------------------
        # ● Returns the number of columns
        #--------------------------------------------------------------------------
        def col_max
                return 1
        end
        #--------------------------------------------------------------------------
        # ● Assigns a rune window
        #--------------------------------------------------------------------------
        def rune_window=(value)
                @rune_window = value
        end
        #--------------------------------------------------------------------------
        # ● Refreshes the help and rune windows
        #--------------------------------------------------------------------------
        def update_help
                @help_window.set_item(item)
                @rune_window.set_item(item) unless @rune_window.nil?
        end
end

#==========================================================================
# ■ Window_RuneList
#==========================================================================
       
class Window_RuneList < Window_ItemList
        #--------------------------------------------------------------------------
        # ● Object Initialize
        #--------------------------------------------------------------------------
        def initialize(x, y, w, h)
                super(x, y, w, h)
                refresh
    select(0)
    hide
        end
        #--------------------------------------------------------------------------
        # ● Enable
        #--------------------------------------------------------------------------
        def enable?(item)
    return true if item.nil?
    if item.rune_unique
      ti = SceneManager.scene.target_item
      container = ti.class == RPG::Weapon ? $game_party.enchants_w :
      $game_party.enchants_a
      slots = container[ti.id]
      return !slots.include?(item.id)
    end
    if item.rune_type == :weapon
      return SceneManager.scene.target_item.class == RPG::Weapon
    elsif item.rune_type == :armor
      return SceneManager.scene.target_item.class == RPG::Armor
    end
                return true
        end
        #--------------------------------------------------------------------------
        # ● Creates the list based on the recipes
        #--------------------------------------------------------------------------
        def make_item_list
                @data = $game_party.all_items.select do |itm|
      itm.is_a?(RPG::EquipItem) && itm.is_rune?
    end
    @data.insert(0, nil)
        end
        #--------------------------------------------------------------------------
        # ● Returns the number of columns
        #--------------------------------------------------------------------------
        def col_max
                return 1
        end
        #--------------------------------------------------------------------------
        # ● Assigns a traits window
        #--------------------------------------------------------------------------
        def traits_window=(value)
                @traits_window = value
        end
  #--------------------------------------------------------------------------
  # ● Updates the help window
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_item(item) unless @help_window.nil?
    @traits_window.set_item(item) unless @traits_window.nil?
  end
end

#==========================================================================
# ■ Window_ViewRunes
#==========================================================================
       
class Window_ViewRunes < Window_Selectable
        #--------------------------------------------------------------------------
        # ● Object Initialize
        #--------------------------------------------------------------------------
        def initialize(x, y, width, height)
                super
                set_item
        end
        #--------------------------------------------------------------------------
        # ● Refresh the contents
        #--------------------------------------------------------------------------
        def set_item(item = nil)
                contents.clear
                return if item.nil?
    container = item.is_a?(RPG::Weapon) ? $game_party.enchants_w :
    $game_party.enchants_a
    container[item.id] = [] if container[item.id].nil?
    @data = container[item.id]
    filler = item.rune_slots - @data.size
    filler.times {@data.push(nil)} if filler > 0
                draw_item_runes(item)
        end
        #--------------------------------------------------------------------------
        # ● Returns the selected rune
        #--------------------------------------------------------------------------
  def get_item
    $data_armors[@data[index]]
  end
        #--------------------------------------------------------------------------
        # ● Displays the item's runes
        #--------------------------------------------------------------------------
        def draw_item_runes(item)
    # Draws the sys text
                change_color(system_color)
                contents.draw_text(4, 0, width, line_height, KRX::VOCAB::RUNE_NAME)
                change_color(normal_color)
                (1..item.rune_slots).each do |i|
      contents.draw_text(4, line_height * i, width, line_height, "#{i}.")
    end
    # Draws the runes
                @data.each_index do |i|
      next if @data.nil?
                        rune = $data_armors[@data]
      draw_item_name(rune, 28, line_height * (i + 1), true, width - 24)
                end
        end
        #--------------------------------------------------------------------------
        # ● Returns the number of columns
        #--------------------------------------------------------------------------
        def col_max
                return 1
        end
  #--------------------------------------------------------------------------
  # ● Returns the max number of rows
  #--------------------------------------------------------------------------
  def item_max
    @data ? @data.size : 1
  end
  #--------------------------------------------------------------------------
  # ● Sets the rectangle for selections
  #--------------------------------------------------------------------------
  def item_rect(index)
    rect = Rect.new
    rect.width = item_width
    rect.height = item_height
    rect.x = index % col_max * (item_width + spacing)
    rect.y = (index / col_max * item_height) + line_height
    rect
  end
        #--------------------------------------------------------------------------
        # ● Assigns a traits window
        #--------------------------------------------------------------------------
        def traits_window=(value)
                @traits_window = value
        end
  #--------------------------------------------------------------------------
  # ● Updates the help window
  #--------------------------------------------------------------------------
  def update_help
    unless @help_window.nil?
      itm = @data[index].nil? ? nil : get_item
      @help_window.set_item(itm)
    end
    @traits_window.set_item(@data[index]) unless @traits_window.nil?
  end
end

#==========================================================================
# ■ Window_ViewRunesTraits
#==========================================================================
       
class Window_ViewRunesTraits < Window_Base
        #--------------------------------------------------------------------------
        # ● Object Initialize
        #--------------------------------------------------------------------------
        def initialize(x, y, width, height)
                super
                set_item
        end
        #--------------------------------------------------------------------------
        # ● Refresh the contents
        #--------------------------------------------------------------------------
        def set_item(item = nil)
                contents.clear
                return if item.nil?
    item = $data_armors[item] if item.is_a?(Integer)
    draw_rune_traits(item)
        end
        #--------------------------------------------------------------------------
        # ● Displays the rune's traits
        #--------------------------------------------------------------------------
        def draw_rune_traits(item)
    # Draws the sys text
                change_color(system_color)
                contents.draw_text(4, 0, width, line_height, KRX::VOCAB::RUNE_TRAITS_NAME)
                change_color(normal_color)
    # Draws the traits
                item.features.each_index do |i|
      f = item.features
      name = KRX::TraitsNamer.feature_name(f.code, f.data_id, f.value)
      contents.draw_text(4, line_height * (i + 1), width - 24, line_height, name)
                end
        end
end

#==========================================================================
# ■ Scene_Enchant
#==========================================================================

class Scene_Enchant < Scene_ItemBase
        #--------------------------------------------------------------------------
        # ● Scene start
        #--------------------------------------------------------------------------
        def start
    super
    create_help_window
    create_traits_window
    create_rune_window
    create_enchant_window
    create_runelist_window
  end
        #--------------------------------------------------------------------------
        # ● Creates the window showing the rune's traits
        #--------------------------------------------------------------------------
  def create_traits_window
    wx = ww = Graphics.width / 2
    wh = (Graphics.height - @help_window.height) / 2
    wy = Graphics.height - wh
    @traits_window = Window_ViewRunesTraits.new(wx, wy, ww, wh)
  end
        #--------------------------------------------------------------------------
        # ● Creates the window showing the current rune set
        #--------------------------------------------------------------------------
  def create_rune_window
    wy = @help_window.height
    wx = ww = Graphics.width / 2
    wh = (Graphics.height - wy) / 2
    @rune_window = Window_ViewRunes.new(wx, wy, ww, wh)
    @rune_window.help_window = @help_window
    @rune_window.traits_window = @traits_window
    @rune_window.set_handler(:ok, method(:on_slot_ok))
    @rune_window.set_handler(:cancel, method(:on_slot_cancel))
  end
        #--------------------------------------------------------------------------
        # ● Creates the window listing the enchantable equipment
        #--------------------------------------------------------------------------
  def create_enchant_window
    wy = @help_window.height
    ww = Graphics.width / 2
    wh = Graphics.height - wy
    @enchant_window = Window_EnchantList.new(0, wy, ww, wh)
    @enchant_window.set_handler(:ok, method(:on_item_ok))
    @enchant_window.set_handler(:cancel, method(:return_scene))
    @enchant_window.help_window = @help_window
    @enchant_window.rune_window = @rune_window
    @enchant_window.update_help
  end
        #--------------------------------------------------------------------------
        # ● Creates the window listing the available runes
        #--------------------------------------------------------------------------
  def create_runelist_window
    wy = @help_window.height
    ww = Graphics.width / 2
    wh = Graphics.height - wy
    @runelist_window = Window_RuneList.new(0, wy, ww, wh)
    @runelist_window.help_window = @help_window
    @runelist_window.traits_window = @traits_window
    @runelist_window.set_handler(:ok, method(:on_rune_ok))
    @runelist_window.set_handler(:cancel, method(:on_rune_cancel))
  end
        #--------------------------------------------------------------------------
        # ● Validates the item selection
        #--------------------------------------------------------------------------
  def on_item_ok
    @enchant_window.deactivate
    @rune_window.select(0)
    @rune_window.activate
  end
        #--------------------------------------------------------------------------
        # ● Validates the rune slot selection
        #--------------------------------------------------------------------------
  def on_slot_ok
    @rune_window.deactivate
    @enchant_window.hide
    @runelist_window.show.select(0)
    @runelist_window.activate
  end
        #--------------------------------------------------------------------------
        # ● Cancels the rune slot selection
        #--------------------------------------------------------------------------
  def on_slot_cancel
    @rune_window.unselect
    @enchant_window.select_last
    @enchant_window.activate
    @traits_window.set_item(nil)
  end
        #--------------------------------------------------------------------------
        # ● Validates the rune selection
        #--------------------------------------------------------------------------
  def on_rune_ok
    e_type = @enchant_window.item.class
    e_id = @enchant_window.item.id
    r_index = @rune_window.index
    r_id = @runelist_window.item != nil ? @runelist_window.item.id : nil
    $game_party.inscribe_rune(e_type, e_id, r_id, r_index)
    @rune_window.set_item(@enchant_window.item)
    @rune_window.activate
    @runelist_window.hide.refresh
    @runelist_window.unselect
    @enchant_window.show
  end
        #--------------------------------------------------------------------------
        # ● Cancels the rune selection
        #--------------------------------------------------------------------------
  def on_rune_cancel
    @rune_window.activate
    @runelist_window.hide.unselect
    @runelist_window.deactivate
    @enchant_window.show
  end
        #--------------------------------------------------------------------------
        # ● Returns the target item
        #--------------------------------------------------------------------------
  def target_item
    @enchant_window.item
  end
end

## Menu inclusion, with Yanfly's Ace Menu Engine
if $imported["YEA-AceMenuEngine"]

#==========================================================================
#  ■ Scene_Menu
#==========================================================================
       
class Scene_Menu < Scene_MenuBase
        #--------------------------------------------------------------------------
        # ● Switch to the enchant scene
        #--------------------------------------------------------------------------
        def command_enchant
    SceneManager.call(Scene_Enchant)
  end
end

end ## End of Yanfly's Menu inclusion

end ## End of Traits Namer's check.[/pre]

唯一的信徒

梦石
0
星屑
1697
在线时间
1359 小时
注册时间
2013-1-29
回帖
1537
发表于 2013-2-12 08:57:12 | 显示全部楼层
以下均翻译自该脚本作者博客。
使用简介
默认,你是不能给武器附魔。如果需要开启此功能,请给你的武器打上这个注释:
  1. <enchant>
复制代码
你也可以设置最大的附魔空位
  1. <rune_slots: x>
复制代码
脚本中也有设置的地方,用于设置默认最大的空位
  1. RUNE_SLOTS_MAX = 5 #默认最多有5个空位
复制代码
附魔宝石
实际上来讲,附魔宝石就是一种带有注释:<rune> 的防具。请保证把这个防具的类型设置为“无”,否则角色可以装备这个防具。
还有更多的选项。
  1. <weapon_rune>
  2. <armor_rune>
  3. <unique>
复制代码
附魔界面呼出:
  1. SceneManager.call(Scene_Enchant)
复制代码
翻译结束。

评分

参与人数 2星屑 +45 梦石 +1 收起 理由
Mic_洛洛 + 1 认可答案
狱冥幻翼 + 45 把物品当成宝石了囧

查看全部评分

回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部