查看: 4458|回复: 1

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

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

整合系统大赛RMVA达人

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

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

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

×
看了下代码,只知道在武器注释里添加<enchant>别的都看不懂~
  1. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  2. #  ▼ Traits Namer
  3. #  Author: Kread-EX
  4. #  Version: 1.01
  5. #  Release date: 11/03/2012
  6. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

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

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

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

  34. module KRX
  35.   module TraitsNamer
  36. #===========================================================================
  37. # ■ CONFIGURATION
  38. #===========================================================================

  39.     X_PARAMETERS = [
  40.    
  41.     'Accuracy',
  42.     'Evasion',
  43.     'Critical rate',
  44.     'M. Evasion',
  45.     'Counter rate',
  46.     'HP Regen',
  47.     'MP Regen',
  48.     'TP Regen'
  49.    
  50.     ]
  51.    
  52.     S_PARAMETERS = [
  53.    
  54.     'Aggro effect',
  55.     'Guard effect',
  56.     'Recovery rate',
  57.     'Pharmacology',
  58.     'MP cost',
  59.     'TP charge rate',
  60.     'Physical damage',
  61.     'Magical damage',
  62.     'Floor damage',
  63.     'EXP rate'
  64.    
  65.     ]

  66.     SPECIAL_FLAGS = [
  67.    
  68.     'Autobattle',
  69.     'Guard',
  70.     'Cover',
  71.     'TP Saver'
  72.    
  73.     ]
  74.    
  75.     PARTY_ABILITY = [
  76.    
  77.     'Half Encounter',
  78.     'No Encounter',
  79.     'No surprise attacks',
  80.     'No preemptive attacks',
  81.     'Gold x2',
  82.     'Item Drops x2'
  83.    
  84.     ]
  85.    
  86.     CODENAMES = {
  87.    
  88.     11 => '%s resist: %d%%'       , # Element rate
  89.     12 => '%s debuff rate: %d%%'  , # Debuff rate
  90.     13 => '%s resist: %d%%'       , # State rate
  91.     14 => 'Immunity: %s'          , # State immunity
  92.     21 => '%s: %d%%'              , # Parameter rate
  93.     22 => '%s: %d%%'              , # Additional parameter rate
  94.     23 => '%s: %d%%'              , # Special parameter rate
  95.     31 => 'Attack %s'             , # Physical attack attribute
  96.     32 => 'Attack %s %d%%'        , # Physical attack state
  97.     33 => 'Attack speed %d'       , # Attack speed correction
  98.     34 => 'Attack x%d'            , # Additional attacks
  99.     41 => 'Command: %s'           , # Add skill type
  100.     42 => 'Seal: %s'              , # Seal skill type
  101.     43 => 'Skill: %s'             , # Add skill
  102.     44 => 'Skill Seal: %s'        , # Seal skill
  103.     51 => 'Can equip: %s'         , # Add equip type (weapon)
  104.     52 => 'Can equip: %s'         , # Add equip type (armor)
  105.     53 => 'Fix equip: %s'         , # Fix equip slot
  106.     54 => 'Seal equip: %s'        , # Seal equip slot
  107.     55 => 'Dual Wielding'         , # Dual Wield
  108.     61 => 'Bonus Actions: +%d%%'  , # Bonus actions
  109.     62 => '%s'                    , # Special flag
  110.     63 => 'Collapse type'         , # Collapse type (will never be used, I think)
  111.     64 => '%s'                    , # Party ability
  112.    
  113.     }
  114.    
  115.     CODEHELP = {
  116.    
  117.     # Element rate
  118.     11 => 'Grants %d%% %s resistance.',
  119.     # Debuff rate
  120.     12 => 'Grants %d%% resistance to %s debuff.',
  121.     # State rate
  122.     13 => 'Grants %d%% %s resistance.',
  123.     # State immunity
  124.     14 => 'Grants immunity to %s.',
  125.     # Parameter rate
  126.     21 => 'Raises %s by %d%%.',
  127.     # Additional parameter rate
  128.     22 => 'Raises %s by %d%%.',
  129.     # Special parameter rate
  130.     23 => 'Grants a %d% modifier to %s.',
  131.     # Physical attack attribute
  132.     31 => 'Adds %s element to normal attacks.',
  133.     # Physical attack state
  134.     32 => 'Adds %s to normal attacks (%d%% accuracy).',
  135.     # Attack speed correction (bonus)
  136.     33 => ['Raises attack speed by %d.',
  137.     # Attack speed correction (malus)
  138.     'Reduces attack speed by %d.'],
  139.     # Additional attacks
  140.     34 => 'Grants %d additional attacks.',
  141.     # Add skill type
  142.     41 => 'Enables the %s battle command.',
  143.     # Seal skill type
  144.     42 => 'Seals the %s battle command.',
  145.     # Add skill
  146.     43 => 'Allows the use of the %s skill',
  147.     # Seal skill
  148.     44 => 'Seals the %s skill.',
  149.     # Add equip type (weapon)
  150.     51 => 'Allows %s to be equipped.',
  151.     # Add equip type (armor)
  152.     52 => 'Allows %s to be equipped.',
  153.     # Fix equip slot
  154.     53 => 'Fixes the %s equipment slot.',
  155.     # Seal equip slot
  156.     54 => 'Seals the %s equipment slot.',
  157.     # Dual Wield
  158.     55 => 'Allows to use two weapons as the same time.',
  159.     # Bonus actions
  160.     61 => 'Raises the action rate by %d%%.',
  161.     # Autobattle
  162.     62 => ['The character will act on his/her own in battle.',
  163.     # Guard
  164.     'The character will permanently defend.',
  165.     # Cover
  166.     'The character will take hits for his/her wounded comrades.',
  167.     # TP Saver
  168.     'TP are kept after battles.'],
  169.     # Collapse type (no need to use it but meh)
  170.     63 => 'Alters the collapse animation.',
  171.     # Half encounter
  172.     64 => ['Halves the random encounter rate.',
  173.     # No encounter
  174.     'Disables random encounters.',
  175.     # No surprise attacks
  176.     'Disables surprise attacks.',
  177.     # No preemptive attacks
  178.     'Disables preemptive attacks.',
  179.     # Gold x2
  180.     'Doubles the money obtained after a battle.',
  181.     # Item Drops x2
  182.     'Doubles the drop rate of items.']
  183.    
  184.     }

  185.     EFFECTS_CODENAMES = {
  186.    
  187.     11 => 'HP Recovery'                   , # HP Recovery
  188.     12 => 'MP Recovery'                   , # MP Recovery
  189.     13 => 'TP Recovery'                   , # TP Gain
  190.     21 => 'Add %s'                        , # Add State
  191.     22 => 'Cleanse %s'                    , # Remove State
  192.     31 => '%s+'                           , # Add buff
  193.     32 => '%s-'                           , # Add debuff
  194.     33 => 'Dispel %s+'                    , # Remove buff
  195.     34 => 'Cancel %s-'                    , # Remove debuff
  196.     41 => 'Escape'                        , # Escape
  197.     42 => '%s Bonus'                      , # Permanent stat growth
  198.     43 => 'Learn %s'                      , # Permanent skill learning
  199.     44 => 'Common Event'                  , # Common event
  200.    
  201.     }
  202.    
  203.     EFFECTS_CODEHELP = {
  204.    
  205.     # HP Recovery (static)
  206.     11 => ['Restores %d HP.',
  207.     # HP Recovery (dynamic)
  208.     'Restores %d%% of maximum HP.'],
  209.     # MP Recovery (static)
  210.     12 => ['Restores %d MP.',
  211.     # MP Recovery (dynamic)
  212.     'Restores %d%% of maximum MP.'],
  213.     # TP Gain
  214.     13 => 'Restores %d%% TP.',
  215.     # Add State
  216.     21 => 'Inflicts %s (%d%% chance).',
  217.     # Remove State
  218.     22 => 'Cancels %s.',
  219.     # Add buff
  220.     31 => 'Increases %s for %d turns.',
  221.     # Add debuff
  222.     32 => 'Decreases %s for %d turns.',
  223.     # Remove buff
  224.     33 => 'Cancels a previously applied %s buff.',
  225.     # Remove debuff
  226.     34 => 'Dispels an active %s debuff.',
  227.     # Escape
  228.     41 => 'Automatically escape from battle.',
  229.     # Permanent stat growth
  230.     42 => 'Boosts %d by %d permanently.',
  231.     # Permanent skill learning
  232.     43 => 'Teaches the %s skill permanently.',
  233.     # Common Event
  234.     44 => 'Calls a common event.'
  235.    
  236.     }
  237.    
  238. #===========================================================================
  239. # ■ CUSTOM TRAITS/EFFECTS CONFIGURATION
  240. #===========================================================================

  241.     # INSTRUCTIONS
  242.     # Here you can define custom traits names and descriptions.
  243.     #
  244.     # Syntax:
  245.     # [type, code, data_id, value 1, value2] => [name, description]
  246.     #
  247.     # type: 0 (for equipment), 1 (for usables)
  248.     #
  249.     # code: the code number. Refer to default naming to know what is what.
  250.     #
  251.     # data_id: the number of the option you've choosen in the trait droplist.
  252.     #
  253.     # value1: what you typed in the first field where you can write numbers.
  254.     # For equipment this is the only one.
  255.     #
  256.     # value2: usable items only. What you typed in the second field.
  257.     #
  258.     # description: If you want to also use a custom description. If you only
  259.     # want the custom name, set this to nil.

  260.     CUSTOM_TRAITS = {
  261.    
  262.     [0, 32, 2, 50] => ['Poisonous', nil],
  263.     [0, 32, 2, 100] => ['Venomous', nil],
  264.    
  265.     [1, 11, 0, 0, 10] => ['HP Recovery XS', nil],
  266.     [1, 11, 0, 0, 25] => ['HP Recovery S', nil],
  267.     [1, 11, 0, 0, 50] => ['HP Recovery M', nil],
  268.     [1, 11, 0, 0, 75] => ['HP Recovery L', nil],
  269.     [1, 11, 0, 0, 100] => ['HP Recovery XL', 'Restores all HP!'],
  270.     [1, 12, 0, 0, 10] => ['MP Recovery XS', nil],
  271.     [1, 12, 0, 0, 25] => ['MP Recovery S', nil],
  272.     [1, 12, 0, 0, 50] => ['MP Recovery M', nil],
  273.     [1, 12, 0, 0, 75] => ['MP Recovery L', nil],
  274.     [1, 12, 0, 0, 100] => ['MP Recovery XL', 'Restores all MP!'],
  275.     [1, 13, 0, 2, 0] => ['TP Recovery XS', nil],
  276.     [1, 13, 0, 5, 0] => ['TP Recovery S', nil],
  277.     [1, 13, 0, 10, 0] => ['TP Recovery M', nil],
  278.     [1, 13, 0, 16, 0] => ['TP Recovery L', nil],
  279.     [1, 13, 0, 20, 0] => ['TP Recovery XL', nil],
  280.    
  281.     }
  282.    
  283. #===========================================================================
  284. # ■ CONFIGURATION ENDS HERE
  285. #===========================================================================
  286.     #--------------------------------------------------------------------------
  287.     # ● Generates traits name
  288.     #--------------------------------------------------------------------------
  289.     def self.feature_name(code, data_id, value)
  290.       custom = CUSTOM_TRAITS[[0, code, data_id, self.convert_value(code, value)]]
  291.       return custom[0] unless custom.nil? || custom[0].nil?
  292.       base_name = CODENAMES[code]
  293.       data_name = case code
  294.         when 11, 31
  295.           $data_system.elements[data_id]
  296.         when 12, 21
  297.           Vocab.param(data_id)
  298.         when 13, 14, 32
  299.           $data_states[data_id].name
  300.         when 22
  301.           X_PARAMETERS[data_id]
  302.         when 23
  303.           S_PARAMETERS[data_id]
  304.         when 41, 42
  305.           $data_system.skill_types[data_id]
  306.         when 43, 44
  307.           $data_skills[data_id].name
  308.         when 51
  309.           $data_system.weapon_types[data_id]
  310.         when 52
  311.           $data_system.armor_types[data_id]
  312.         when 53, 54
  313.           Vocab.etype(data_id)
  314.         when 62
  315.           SPECIAL_FLAGS[data_id]
  316.         when 64
  317.           PARTY_ABILITY[data_id]
  318.         end
  319.       final_value = case code
  320.         when 11, 13
  321.           100 - (value * 100)
  322.         when 33, 34
  323.           value
  324.         else
  325.           value * 100
  326.         end
  327.       if data_name.nil?
  328.         name = sprintf(base_name, final_value)
  329.       else
  330.         name = sprintf(base_name, data_name, final_value)
  331.       end
  332.       name
  333.     end
  334.     #--------------------------------------------------------------------------
  335.     # ● Generates traits description
  336.     #--------------------------------------------------------------------------
  337.     def self.feature_description(code, data_id, value)
  338.       custom = CUSTOM_TRAITS[[0, code, data_id, self.convert_value(code, value)]]
  339.       return custom[1] unless custom.nil? || custom[1].nil?
  340.       if CODEHELP[code].is_a?(Array)
  341.         base_help = CODEHELP[code][data_id]
  342.       else
  343.         base_help = CODEHELP[code]
  344.       end
  345.       data_name = case code
  346.         when 11, 31
  347.           $data_system.elements[data_id]
  348.         when 12, 21
  349.           Vocab.param(data_id)
  350.         when 13, 14, 32
  351.           $data_states[data_id].name
  352.         when 22
  353.           X_PARAMETERS[data_id]
  354.         when 23
  355.           S_PARAMETERS[data_id]
  356.         when 41, 42
  357.           $data_system.skill_types[data_id]
  358.         when 43, 44
  359.           $data_skills[data_id].name
  360.         when 51
  361.           $data_system.weapon_types[data_id]
  362.         when 52
  363.           $data_system.armor_types[data_id]
  364.         when 53, 54
  365.           Vocab.etype(data_id)
  366.         when 62
  367.           SPECIAL_FLAGS[data_id]
  368.         when 64
  369.           PARTY_ABILITY[data_id]
  370.         end
  371.       final_value = case code
  372.         when 11, 13
  373.           100 - (value * 100)
  374.         when 33, 34
  375.           value
  376.         else
  377.           value * 100
  378.         end
  379.       if data_name.nil?
  380.         name = sprintf(base_help, final_value)
  381.       else
  382.         name = sprintf(base_help, data_name, final_value)
  383.       end
  384.       name
  385.     end
  386.     #--------------------------------------------------------------------------
  387.     # ● Generates effects name
  388.     #--------------------------------------------------------------------------
  389.     def self.effect_name(code, data_id, value1, value2)
  390.       custom = CUSTOM_TRAITS[[1, code, data_id,
  391.       self.convert_value(code, value1, false),
  392.       self.convert_value(code, value2, false)]]
  393.       return custom[0] unless custom.nil? || custom[0].nil?
  394.       base_name = EFFECTS_CODENAMES[code]
  395.       data_name = case code
  396.         when 21, 22
  397.           $data_states[data_id].name
  398.         when 31, 32, 33, 34, 42
  399.           Vocab.param(data_id)
  400.         when 43
  401.           $data_skills[data_id]
  402.         end
  403.       if data_name.nil?
  404.         name = sprintf(base_name, value1, value2)
  405.       else
  406.         name = sprintf(base_name, data_name, value1, value2)
  407.       end
  408.       name
  409.     end
  410.     #--------------------------------------------------------------------------
  411.     # ● Generates effects description
  412.     #--------------------------------------------------------------------------
  413.     def self.effect_description(code, data_id, value1, value2)
  414.       custom = CUSTOM_TRAITS[[1, code, data_id,
  415.       self.convert_value(code, value1, false),
  416.       self.convert_value(code, value2, false)]]
  417.       return custom[1] unless custom.nil? || custom[1].nil?
  418.       if EFFECTS_CODEHELP[code].is_a?(Array)
  419.         base_help = value2 > 0 ? EFFECTS_CODEHELP[code][0] :
  420.         EFFECTS_CODEHELP[code][1]
  421.       else
  422.         base_help = EFFECTS_CODEHELP[code]
  423.       end
  424.       data_name = case code
  425.         when 21, 22
  426.           $data_states[data_id].name
  427.         when 31, 32, 33, 34, 42
  428.           Vocab.param(data_id)
  429.         when 43
  430.           $data_skills[data_id]
  431.         end
  432.       value1 = self.convert_value(code, value1, false)
  433.       value2 = self.convert_value(code, value2, false)
  434.       value1 = value2 if value1 == 0
  435.       if data_name.nil?
  436.         name = sprintf(base_help, value1, value2)
  437.       else
  438.         name = sprintf(base_help, data_name, value1, value2)
  439.       end
  440.       name
  441.     end
  442.     #--------------------------------------------------------------------------
  443.     # ● Converts the real value to the one entered in the editor
  444.     #--------------------------------------------------------------------------
  445.     def self.convert_value(code, value, feature = true)
  446.       if feature && [33, 34].include?(code)
  447.         return value.to_i
  448.       elsif feature && [21].include?(code)
  449.         return (value.to_f / 100)
  450.       elsif [11, 12].include?(code) && value <= 1
  451.         return (value.to_i * 100).to_i
  452.       elsif [21, 22].include?(code)
  453.         return (value * 100).to_i
  454.       else
  455.         value.to_i
  456.       end
  457.     end
  458.     #--------------------------------------------------------------------------
  459.     # ● Points towards either feature name or effect name
  460.     #--------------------------------------------------------------------------
  461.     def self.trait_name(trait)
  462.       if trait.is_a?(RPG::BaseItem::Feature)
  463.         return self.feature_name(trait.code, trait.data_id, trait.value)
  464.       end
  465.       self.effect_name(trait.code, trait.data_id, trait.value1, trait.value2)
  466.     end
  467.     #--------------------------------------------------------------------------
  468.     # ● Points towards either feature description or effect description
  469.     #--------------------------------------------------------------------------
  470.     def self.trait_description(trait)
  471.       if trait.is_a?(RPG::BaseItem::Feature)
  472.         return self.feature_description(trait.code, trait.data_id, trait.value)
  473.       end
  474.       self.effect_description(trait.code, trait.data_id, trait.value1,
  475.       trait.value2)
  476.     end
  477.   end
  478. end
复制代码
  1. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  2. #  ▼ Runic Enchantment
  3. #  Author: Kread-EX
  4. #  Version 1.06
  5. #  Release date: 11/03/2012
  6. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

  7. #-------------------------------------------------------------------------------------------------
  8. #  ▼ UPDATES
  9. #-------------------------------------------------------------------------------------------------
  10. # # 02/06/2012. Now lists equipped items.
  11. # # 19/03/2012. Fixed a crashing bug.
  12. # # 17/03/2012. Added the option to limit runes to either the weapon or the
  13. # # armor. Runes can also be set as impossible to double up on the same
  14. # # equipment piece.
  15. # # Also, bugfixes.
  16. #-------------------------------------------------------------------------------------------------
  17. #  ▼ TERMS OF USAGE
  18. #-------------------------------------------------------------------------------------------------
  19. # #  You are free to adapt this work to suit your needs.
  20. # #  You can use this work for commercial purposes if you like it.
  21. # #  Credit is appreciated.
  22. # #
  23. # # For support:
  24. # # grimoirecastle.wordpress.com
  25. # # rpgmakerweb.com
  26. # # rpgrevolution.com
  27. #-------------------------------------------------------------------------------------------------
  28. #  ▼ INTRODUCTION
  29. #-------------------------------------------------------------------------------------------------
  30. # # An enchantment system inspired from Dragon's Age. Recommended to use only
  31. # # for unique weapons and armors.
  32. #-------------------------------------------------------------------------------------------------
  33. #  ▼ INSTRUCTIONS
  34. #-------------------------------------------------------------------------------------------------
  35. # # REQUIRES THE TRAITS NAMER:
  36. # # [url]http://grimoirecastle.wordpress.com/rgss3-scripts/core-scripts/traits-namer/[/url]
  37. # #
  38. # # Tag enchant-able weapons with <enchant> in their notebox.
  39. # # Modify rune slots with <rune_slots: x>
  40. # #
  41. # # Runes are armors with the <rune> notetag and None as an armor type.
  42. # # <weapon_rune> Limits the rune to a weapon.
  43. # # <armor_rune> Limits the rune to an armor.
  44. # # <unique_rune> Only one of those on the same piece.
  45. # #
  46. # # Use SceneManager.call(Scene_Enchant) to enter the scene or use Yanfly's
  47. # # Ace Menu Engine.
  48. #-------------------------------------------------------------------------------------------------
  49. #  ▼ COMPATIBILITY
  50. #-------------------------------------------------------------------------------------------------
  51. # # List of aliases and overwrites:
  52. # #
  53. # # DataManager
  54. # # load_database (alias)
  55. # # load_sandal_notetags (new method)
  56. # #
  57. # # RPG::EquipItem
  58. # # can_enchant (new attr method)
  59. # # rune_slots (new attr method)
  60. # # rune_type (new attr method)
  61. # # rune_unique (new attr method)
  62. # # load_sandal_notetags (new method)
  63. # # is_rune? (new method)
  64. # # static_rune_params (new method)
  65. # #
  66. # # Game_Actor
  67. # # feature_objects (alias)
  68. # #
  69. # # Game_Party
  70. # # enchants_w (new method)
  71. # # enchants_a (new method)
  72. # # equipped_items (new method)
  73. # #
  74. # # Scene_Enchant (new class)
  75. # # Window_EnchantList (new class)
  76. # # Window_RuneList (new class)
  77. # # Window_ViewRunes (new class)
  78. # # Window_ViewRunesTraits (new class)
  79. #-------------------------------------------------------------------------------------------------

  80. # Quits if the Traits Namer isn't found

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

  84. else

  85. $imported['KRX-Enchantment'] = true

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

  87. #===========================================================================
  88. # ■ CONFIGURATION
  89. #===========================================================================

  90. module KRX
  91.   
  92.   # The max rune slots by default.
  93.   RUNE_SLOTS_MAX = 5
  94.    
  95.   module VOCAB
  96.     # Runes name in menus.
  97.     RUNE_NAME = '符文'
  98.     # Runes traits name
  99.     RUNE_TRAITS_NAME = '属性'
  100.   end
  101. #===========================================================================
  102. # ■ CONFIGURATION ENDS HERE
  103. #===========================================================================
  104.   module REGEXP
  105.     ALLOW_ENCHANT = /<enchant>/i
  106.     RUNE = /<rune>/i
  107.     RUNE_SLOTS = /<rune_slots:[ ]*(\d+)>/i
  108.     RUNE_WEAPON = /<weapon_rune>/i
  109.     RUNE_ARMOR = /<armor_rune>/i
  110.     RUNE_UNIQUE = /<unique_rune>/i
  111.   end
  112. end

  113. #===========================================================================
  114. # ■ DataManager
  115. #===========================================================================

  116. module DataManager
  117.         #--------------------------------------------------------------------------
  118.         # ● Loads the database
  119.         #--------------------------------------------------------------------------
  120.         class << self
  121.                 alias_method(:krx_sandal_dm_load_database, :load_database)
  122.         end
  123.         def self.load_database
  124.                 krx_sandal_dm_load_database
  125.                 load_sandal_notetags
  126.         end  
  127.         #--------------------------------------------------------------------------
  128.         # ● Loads the note tags
  129.         #--------------------------------------------------------------------------
  130.         def self.load_sandal_notetags
  131.                 groups = [$data_weapons, $data_armors]
  132.                 for group in groups
  133.                         for obj in group
  134.                                 next if obj.nil?
  135.                                 obj.load_sandal_notetags
  136.                         end
  137.                 end
  138.                 puts "Read: Enchantment Notetags"
  139.         end
  140. end

  141. #===========================================================================
  142. # ■ RPG::EquipItem
  143. #===========================================================================

  144. class RPG::EquipItem
  145.         #--------------------------------------------------------------------------
  146.         # ● Public instance variables
  147.         #--------------------------------------------------------------------------
  148.   attr_reader   :can_enchant
  149.   attr_reader   :rune_slots
  150.   attr_reader   :rune_type
  151.   attr_reader   :rune_unique
  152.         #--------------------------------------------------------------------------
  153.         # ● Loads the note tags
  154.         #--------------------------------------------------------------------------
  155.         def load_sandal_notetags
  156.     @rune_slots = KRX::RUNE_SLOTS_MAX
  157.                 @note.split(/[\r\n]+/).each do |line|
  158.                         case line
  159.                         when KRX::REGEXP::ALLOW_ENCHANT
  160.                                 @can_enchant = true
  161.       when KRX::REGEXP::RUNE
  162.         @is_rune = true
  163.       when KRX::REGEXP::RUNE_SLOTS
  164.         @rune_slots = $1.to_i
  165.       when KRX::REGEXP::RUNE_WEAPON
  166.         @rune_type = :weapon
  167.       when KRX::REGEXP::RUNE_ARMOR
  168.         @rune_type = :armor
  169.       when KRX::REGEXP::RUNE_UNIQUE
  170.         @rune_unique = true
  171.                         end
  172.                 end
  173.         end
  174.         #--------------------------------------------------------------------------
  175.         # ● Determine if the item is a rune
  176.         #--------------------------------------------------------------------------
  177.   def is_rune?
  178.     @is_rune && self.is_a?(RPG::Armor)
  179.   end
  180. end

  181. #===========================================================================
  182. # ■ Game_Actor
  183. #===========================================================================

  184. class Game_Actor < Game_Battler
  185.   #--------------------------------------------------------------------------
  186.   # ● Returns the list of traits
  187.   #--------------------------------------------------------------------------
  188.   alias_method(:krx_sandal_ga_fo, :feature_objects)
  189.   def feature_objects
  190.     runes = []
  191.     equips.compact.each do |equip|
  192.       container = equip.is_a?(RPG::Weapon) ? $game_party.enchants_w :
  193.       $game_party.enchants_a
  194.       next if container[equip.id].nil?
  195.       ids = container[equip.id]
  196.       ids.each do |id|
  197.         next if id.nil?
  198.         runes.push($data_armors[id])
  199.       end
  200.     end
  201.     krx_sandal_ga_fo + runes.compact
  202.   end
  203. end

  204. #===========================================================================
  205. # ■ Game_Party
  206. #===========================================================================

  207. class Game_Party < Game_Unit
  208.         #--------------------------------------------------------------------------
  209.         # ● Returns the items equipped by all actors
  210.         #--------------------------------------------------------------------------
  211.   def equipped_items
  212.     result = []
  213.     members.each {|actor| result.push(actor.equips)}
  214.     return result.flatten
  215.   end
  216.         #--------------------------------------------------------------------------
  217.         # ● Returns weapon enchantments
  218.         #--------------------------------------------------------------------------
  219.   def enchants_w
  220.     @enchants_w ||= {}
  221.   end
  222.         #--------------------------------------------------------------------------
  223.         # ● Returns armor enchantments
  224.         #--------------------------------------------------------------------------
  225.   def enchants_a
  226.     @enchants_a ||= {}
  227.   end
  228.         #--------------------------------------------------------------------------
  229.         # ● Inscribes a rune
  230.         #--------------------------------------------------------------------------
  231.   def inscribe_rune(e_type, e_id, r_id, r_index)
  232.     container = e_type == RPG::Weapon ? @enchants_w : @enchants_a
  233.     container[e_id] = [] if container[e_id].nil?
  234.     if container[e_id][r_index] != nil
  235.       item = $data_armors[container[e_id][r_index]]
  236.       gain_item(item, 1)
  237.     end
  238.     lose_item($data_armors[r_id], 1) unless r_id.nil?
  239.     container[e_id][r_index] = r_id
  240.   end
  241. end

  242. #==========================================================================
  243. # ■ Window_EnchantList
  244. #==========================================================================
  245.        
  246. class Window_EnchantList < Window_ItemList
  247.         #--------------------------------------------------------------------------
  248.         # ● Object Initialize
  249.         #--------------------------------------------------------------------------
  250.         def initialize(x, y, w, h)
  251.                 super(x, y, w, h)
  252.                 refresh
  253.     select(0)
  254.     activate
  255.         end
  256.         #--------------------------------------------------------------------------
  257.         # ● Enable (always true)
  258.         #--------------------------------------------------------------------------
  259.         def enable?(item)
  260.                 item != nil
  261.         end
  262.         #--------------------------------------------------------------------------
  263.         # ● Creates the list based on the recipes
  264.         #--------------------------------------------------------------------------
  265.         def make_item_list
  266.                 @data = []
  267.     ($game_party.all_items + $game_party.equipped_items).each do |itm|
  268.       next if @data.include?(itm)
  269.       @data.push(itm) if itm.is_a?(RPG::EquipItem) && itm.can_enchant
  270.     end
  271.         end
  272.   #--------------------------------------------------------------------------
  273.   # ● Displays the item
  274.   #--------------------------------------------------------------------------
  275.   def draw_item(index)
  276.     item = @data[index]
  277.     if item
  278.       rect = item_rect(index)
  279.       rect.width -= 4
  280.       draw_item_name(item, rect.x, rect.y, enable?(item))
  281.     end
  282.   end
  283.         #--------------------------------------------------------------------------
  284.         # ● Returns the number of columns
  285.         #--------------------------------------------------------------------------
  286.         def col_max
  287.                 return 1
  288.         end
  289.         #--------------------------------------------------------------------------
  290.         # ● Assigns a rune window
  291.         #--------------------------------------------------------------------------
  292.         def rune_window=(value)
  293.                 @rune_window = value
  294.         end
  295.         #--------------------------------------------------------------------------
  296.         # ● Refreshes the help and rune windows
  297.         #--------------------------------------------------------------------------
  298.         def update_help
  299.                 @help_window.set_item(item)
  300.                 @rune_window.set_item(item) unless @rune_window.nil?
  301.         end
  302. end

  303. #==========================================================================
  304. # ■ Window_RuneList
  305. #==========================================================================
  306.        
  307. class Window_RuneList < Window_ItemList
  308.         #--------------------------------------------------------------------------
  309.         # ● Object Initialize
  310.         #--------------------------------------------------------------------------
  311.         def initialize(x, y, w, h)
  312.                 super(x, y, w, h)
  313.                 refresh
  314.     select(0)
  315.     hide
  316.         end
  317.         #--------------------------------------------------------------------------
  318.         # ● Enable
  319.         #--------------------------------------------------------------------------
  320.         def enable?(item)
  321.     return true if item.nil?
  322.     if item.rune_unique
  323.       ti = SceneManager.scene.target_item
  324.       container = ti.class == RPG::Weapon ? $game_party.enchants_w :
  325.       $game_party.enchants_a
  326.       slots = container[ti.id]
  327.       return !slots.include?(item.id)
  328.     end
  329.     if item.rune_type == :weapon
  330.       return SceneManager.scene.target_item.class == RPG::Weapon
  331.     elsif item.rune_type == :armor
  332.       return SceneManager.scene.target_item.class == RPG::Armor
  333.     end
  334.                 return true
  335.         end
  336.         #--------------------------------------------------------------------------
  337.         # ● Creates the list based on the recipes
  338.         #--------------------------------------------------------------------------
  339.         def make_item_list
  340.                 @data = $game_party.all_items.select do |itm|
  341.       itm.is_a?(RPG::EquipItem) && itm.is_rune?
  342.     end
  343.     @data.insert(0, nil)
  344.         end
  345.         #--------------------------------------------------------------------------
  346.         # ● Returns the number of columns
  347.         #--------------------------------------------------------------------------
  348.         def col_max
  349.                 return 1
  350.         end
  351.         #--------------------------------------------------------------------------
  352.         # ● Assigns a traits window
  353.         #--------------------------------------------------------------------------
  354.         def traits_window=(value)
  355.                 @traits_window = value
  356.         end
  357.   #--------------------------------------------------------------------------
  358.   # ● Updates the help window
  359.   #--------------------------------------------------------------------------
  360.   def update_help
  361.     @help_window.set_item(item) unless @help_window.nil?
  362.     @traits_window.set_item(item) unless @traits_window.nil?
  363.   end
  364. end

  365. #==========================================================================
  366. # ■ Window_ViewRunes
  367. #==========================================================================
  368.        
  369. class Window_ViewRunes < Window_Selectable
  370.         #--------------------------------------------------------------------------
  371.         # ● Object Initialize
  372.         #--------------------------------------------------------------------------
  373.         def initialize(x, y, width, height)
  374.                 super
  375.                 set_item
  376.         end
  377.         #--------------------------------------------------------------------------
  378.         # ● Refresh the contents
  379.         #--------------------------------------------------------------------------
  380.         def set_item(item = nil)
  381.                 contents.clear
  382.                 return if item.nil?
  383.     container = item.is_a?(RPG::Weapon) ? $game_party.enchants_w :
  384.     $game_party.enchants_a
  385.     container[item.id] = [] if container[item.id].nil?
  386.     @data = container[item.id]
  387.     filler = item.rune_slots - @data.size
  388.     filler.times {@data.push(nil)} if filler > 0
  389.                 draw_item_runes(item)
  390.         end
  391.         #--------------------------------------------------------------------------
  392.         # ● Returns the selected rune
  393.         #--------------------------------------------------------------------------
  394.   def get_item
  395.     $data_armors[@data[index]]
  396.   end
  397.         #--------------------------------------------------------------------------
  398.         # ● Displays the item's runes
  399.         #--------------------------------------------------------------------------
  400.         def draw_item_runes(item)
  401.     # Draws the sys text
  402.                 change_color(system_color)
  403.                 contents.draw_text(4, 0, width, line_height, KRX::VOCAB::RUNE_NAME)
  404.                 change_color(normal_color)
  405.                 (1..item.rune_slots).each do |i|
  406.       contents.draw_text(4, line_height * i, width, line_height, "#{i}.")
  407.     end
  408.     # Draws the runes
  409.                 @data.each_index do |i|
  410.       next if @data[i].nil?
  411.                         rune = $data_armors[@data[i]]
  412.       draw_item_name(rune, 28, line_height * (i + 1), true, width - 24)
  413.                 end
  414.         end
  415.         #--------------------------------------------------------------------------
  416.         # ● Returns the number of columns
  417.         #--------------------------------------------------------------------------
  418.         def col_max
  419.                 return 1
  420.         end
  421.   #--------------------------------------------------------------------------
  422.   # ● Returns the max number of rows
  423.   #--------------------------------------------------------------------------
  424.   def item_max
  425.     @data ? @data.size : 1
  426.   end
  427.   #--------------------------------------------------------------------------
  428.   # ● Sets the rectangle for selections
  429.   #--------------------------------------------------------------------------
  430.   def item_rect(index)
  431.     rect = Rect.new
  432.     rect.width = item_width
  433.     rect.height = item_height
  434.     rect.x = index % col_max * (item_width + spacing)
  435.     rect.y = (index / col_max * item_height) + line_height
  436.     rect
  437.   end
  438.         #--------------------------------------------------------------------------
  439.         # ● Assigns a traits window
  440.         #--------------------------------------------------------------------------
  441.         def traits_window=(value)
  442.                 @traits_window = value
  443.         end
  444.   #--------------------------------------------------------------------------
  445.   # ● Updates the help window
  446.   #--------------------------------------------------------------------------
  447.   def update_help
  448.     unless @help_window.nil?
  449.       itm = @data[index].nil? ? nil : get_item
  450.       @help_window.set_item(itm)
  451.     end
  452.     @traits_window.set_item(@data[index]) unless @traits_window.nil?
  453.   end
  454. end

  455. #==========================================================================
  456. # ■ Window_ViewRunesTraits
  457. #==========================================================================
  458.        
  459. class Window_ViewRunesTraits < Window_Base
  460.         #--------------------------------------------------------------------------
  461.         # ● Object Initialize
  462.         #--------------------------------------------------------------------------
  463.         def initialize(x, y, width, height)
  464.                 super
  465.                 set_item
  466.         end
  467.         #--------------------------------------------------------------------------
  468.         # ● Refresh the contents
  469.         #--------------------------------------------------------------------------
  470.         def set_item(item = nil)
  471.                 contents.clear
  472.                 return if item.nil?
  473.     item = $data_armors[item] if item.is_a?(Integer)
  474.     draw_rune_traits(item)
  475.         end
  476.         #--------------------------------------------------------------------------
  477.         # ● Displays the rune's traits
  478.         #--------------------------------------------------------------------------
  479.         def draw_rune_traits(item)
  480.     # Draws the sys text
  481.                 change_color(system_color)
  482.                 contents.draw_text(4, 0, width, line_height, KRX::VOCAB::RUNE_TRAITS_NAME)
  483.                 change_color(normal_color)
  484.     # Draws the traits
  485.                 item.features.each_index do |i|
  486.       f = item.features[i]
  487.       name = KRX::TraitsNamer.feature_name(f.code, f.data_id, f.value)
  488.       contents.draw_text(4, line_height * (i + 1), width - 24, line_height, name)
  489.                 end
  490.         end
  491. end

  492. #==========================================================================
  493. # ■ Scene_Enchant
  494. #==========================================================================

  495. class Scene_Enchant < Scene_ItemBase
  496.         #--------------------------------------------------------------------------
  497.         # ● Scene start
  498.         #--------------------------------------------------------------------------
  499.         def start
  500.     super
  501.     create_help_window
  502.     create_traits_window
  503.     create_rune_window
  504.     create_enchant_window
  505.     create_runelist_window
  506.   end
  507.         #--------------------------------------------------------------------------
  508.         # ● Creates the window showing the rune's traits
  509.         #--------------------------------------------------------------------------
  510.   def create_traits_window
  511.     wx = ww = Graphics.width / 2
  512.     wh = (Graphics.height - @help_window.height) / 2
  513.     wy = Graphics.height - wh
  514.     @traits_window = Window_ViewRunesTraits.new(wx, wy, ww, wh)
  515.   end
  516.         #--------------------------------------------------------------------------
  517.         # ● Creates the window showing the current rune set
  518.         #--------------------------------------------------------------------------
  519.   def create_rune_window
  520.     wy = @help_window.height
  521.     wx = ww = Graphics.width / 2
  522.     wh = (Graphics.height - wy) / 2
  523.     @rune_window = Window_ViewRunes.new(wx, wy, ww, wh)
  524.     @rune_window.help_window = @help_window
  525.     @rune_window.traits_window = @traits_window
  526.     @rune_window.set_handler(:ok, method(:on_slot_ok))
  527.     @rune_window.set_handler(:cancel, method(:on_slot_cancel))
  528.   end
  529.         #--------------------------------------------------------------------------
  530.         # ● Creates the window listing the enchantable equipment
  531.         #--------------------------------------------------------------------------
  532.   def create_enchant_window
  533.     wy = @help_window.height
  534.     ww = Graphics.width / 2
  535.     wh = Graphics.height - wy
  536.     @enchant_window = Window_EnchantList.new(0, wy, ww, wh)
  537.     @enchant_window.set_handler(:ok, method(:on_item_ok))
  538.     @enchant_window.set_handler(:cancel, method(:return_scene))
  539.     @enchant_window.help_window = @help_window
  540.     @enchant_window.rune_window = @rune_window
  541.     @enchant_window.update_help
  542.   end
  543.         #--------------------------------------------------------------------------
  544.         # ● Creates the window listing the available runes
  545.         #--------------------------------------------------------------------------
  546.   def create_runelist_window
  547.     wy = @help_window.height
  548.     ww = Graphics.width / 2
  549.     wh = Graphics.height - wy
  550.     @runelist_window = Window_RuneList.new(0, wy, ww, wh)
  551.     @runelist_window.help_window = @help_window
  552.     @runelist_window.traits_window = @traits_window
  553.     @runelist_window.set_handler(:ok, method(:on_rune_ok))
  554.     @runelist_window.set_handler(:cancel, method(:on_rune_cancel))
  555.   end
  556.         #--------------------------------------------------------------------------
  557.         # ● Validates the item selection
  558.         #--------------------------------------------------------------------------
  559.   def on_item_ok
  560.     @enchant_window.deactivate
  561.     @rune_window.select(0)
  562.     @rune_window.activate
  563.   end
  564.         #--------------------------------------------------------------------------
  565.         # ● Validates the rune slot selection
  566.         #--------------------------------------------------------------------------
  567.   def on_slot_ok
  568.     @rune_window.deactivate
  569.     @enchant_window.hide
  570.     @runelist_window.show.select(0)
  571.     @runelist_window.activate
  572.   end
  573.         #--------------------------------------------------------------------------
  574.         # ● Cancels the rune slot selection
  575.         #--------------------------------------------------------------------------
  576.   def on_slot_cancel
  577.     @rune_window.unselect
  578.     @enchant_window.select_last
  579.     @enchant_window.activate
  580.     @traits_window.set_item(nil)
  581.   end
  582.         #--------------------------------------------------------------------------
  583.         # ● Validates the rune selection
  584.         #--------------------------------------------------------------------------
  585.   def on_rune_ok
  586.     e_type = @enchant_window.item.class
  587.     e_id = @enchant_window.item.id
  588.     r_index = @rune_window.index
  589.     r_id = @runelist_window.item != nil ? @runelist_window.item.id : nil
  590.     $game_party.inscribe_rune(e_type, e_id, r_id, r_index)
  591.     @rune_window.set_item(@enchant_window.item)
  592.     @rune_window.activate
  593.     @runelist_window.hide.refresh
  594.     @runelist_window.unselect
  595.     @enchant_window.show
  596.   end
  597.         #--------------------------------------------------------------------------
  598.         # ● Cancels the rune selection
  599.         #--------------------------------------------------------------------------
  600.   def on_rune_cancel
  601.     @rune_window.activate
  602.     @runelist_window.hide.unselect
  603.     @runelist_window.deactivate
  604.     @enchant_window.show
  605.   end
  606.         #--------------------------------------------------------------------------
  607.         # ● Returns the target item
  608.         #--------------------------------------------------------------------------
  609.   def target_item
  610.     @enchant_window.item
  611.   end
  612. end

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

  615. #==========================================================================
  616. #  ■ Scene_Menu
  617. #==========================================================================
  618.        
  619. class Scene_Menu < Scene_MenuBase
  620.         #--------------------------------------------------------------------------
  621.         # ● Switch to the enchant scene
  622.         #--------------------------------------------------------------------------
  623.         def command_enchant
  624.     SceneManager.call(Scene_Enchant)
  625.   end
  626. end

  627. end ## End of Yanfly's Menu inclusion

  628. end ## End of Traits Namer's check.
复制代码

唯一的信徒

梦石
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.

在本版发帖返回顶部