设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 3969|回复: 1
打印 上一主题 下一主题

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

[复制链接]

Lv1.梦旅人

梦石
0
星屑
49
在线时间
491 小时
注册时间
2012-1-27
帖子
421

整合系统大赛RMVA达人

跳转到指定楼层
1
 楼主| 发表于 2013-2-11 22:37:06 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
看了下代码,只知道在武器注释里添加<enchant>别的都看不懂~
RUBY 代码复制
  1. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  2. #  ▼ Traits Namer
  3. #  Author: Kread-EX
  4. #  Version: 1.01
  5. #  Release date: 11/03/2012
  6. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  7.  
  8. #-------------------------------------------------------------------------------------------------
  9. #  ▼ UPDATES
  10. #-------------------------------------------------------------------------------------------------
  11. # # 24/03/2012. Added methods used by Alchemic Synthesis.
  12. # # 23/03/2012. Version 1.0, now help window generation is included.
  13. #-------------------------------------------------------------------------------------------------
  14. #  ▼ TERMS OF USAGE
  15. #-------------------------------------------------------------------------------------------------
  16. # #  You are free to adapt this work to suit your needs.
  17. # #  You can use this work for commercial purposes if you like it.
  18. # #  Credit is appreciated.
  19. # #
  20. # # For support:
  21. # # grimoirecastle.wordpress.com
  22. # # rpgmakerweb.com
  23. # # rpgrevolution.com
  24. #-------------------------------------------------------------------------------------------------
  25. #  ▼ INTRODUCTION
  26. #-------------------------------------------------------------------------------------------------
  27. # # This is a core script. By itself, it doesn't do anything but it used by
  28. # # Runic Enchantment and Alchemic Synthesis. The purpose of this script
  29. # # is to provide an automated way to name traits: the script retrieve the traits
  30. # # data and generates a name based on a customizable template.
  31. #-------------------------------------------------------------------------------------------------
  32.  
  33. $imported = {} if $imported.nil?
  34. $imported['KRX-TraitsNamer'] = true
  35.  
  36. puts 'Load: Traits Namer v1.01 by Kread-EX'
  37.  
  38. module KRX
  39.   module TraitsNamer
  40. #===========================================================================
  41. # ■ CONFIGURATION
  42. #===========================================================================
  43.  
  44.     X_PARAMETERS = [
  45.  
  46.     'Accuracy',
  47.     'Evasion',
  48.     'Critical rate',
  49.     'M. Evasion',
  50.     'Counter rate',
  51.     'HP Regen',
  52.     'MP Regen',
  53.     'TP Regen'
  54.  
  55.     ]
  56.  
  57.     S_PARAMETERS = [
  58.  
  59.     'Aggro effect',
  60.     'Guard effect',
  61.     'Recovery rate',
  62.     'Pharmacology',
  63.     'MP cost',
  64.     'TP charge rate',
  65.     'Physical damage',
  66.     'Magical damage',
  67.     'Floor damage',
  68.     'EXP rate'
  69.  
  70.     ]
  71.  
  72.     SPECIAL_FLAGS = [
  73.  
  74.     'Autobattle',
  75.     'Guard',
  76.     'Cover',
  77.     'TP Saver'
  78.  
  79.     ]
  80.  
  81.     PARTY_ABILITY = [
  82.  
  83.     'Half Encounter',
  84.     'No Encounter',
  85.     'No surprise attacks',
  86.     'No preemptive attacks',
  87.     'Gold x2',
  88.     'Item Drops x2'
  89.  
  90.     ]
  91.  
  92.     CODENAMES = {
  93.  
  94.     11 => '%s resist: %d%%'       , # Element rate
  95.     12 => '%s debuff rate: %d%%'  , # Debuff rate
  96.     13 => '%s resist: %d%%'       , # State rate
  97.     14 => 'Immunity: %s'          , # State immunity
  98.     21 => '%s: %d%%'              , # Parameter rate
  99.     22 => '%s: %d%%'              , # Additional parameter rate
  100.     23 => '%s: %d%%'              , # Special parameter rate
  101.     31 => 'Attack %s'             , # Physical attack attribute
  102.     32 => 'Attack %s %d%%'        , # Physical attack state
  103.     33 => 'Attack speed %d'       , # Attack speed correction
  104.     34 => 'Attack x%d'            , # Additional attacks
  105.     41 => 'Command: %s'           , # Add skill type
  106.     42 => 'Seal: %s'              , # Seal skill type
  107.     43 => 'Skill: %s'             , # Add skill
  108.     44 => 'Skill Seal: %s'        , # Seal skill
  109.     51 => 'Can equip: %s'         , # Add equip type (weapon)
  110.     52 => 'Can equip: %s'         , # Add equip type (armor)
  111.     53 => 'Fix equip: %s'         , # Fix equip slot
  112.     54 => 'Seal equip: %s'        , # Seal equip slot
  113.     55 => 'Dual Wielding'         , # Dual Wield
  114.     61 => 'Bonus Actions: +%d%%'  , # Bonus actions
  115.     62 => '%s'                    , # Special flag
  116.     63 => 'Collapse type'         , # Collapse type (will never be used, I think)
  117.     64 => '%s'                    , # Party ability
  118.  
  119.     }
  120.  
  121.     CODEHELP = {
  122.  
  123.     # Element rate
  124.     11 => 'Grants %d%% %s resistance.',
  125.     # Debuff rate
  126.     12 => 'Grants %d%% resistance to %s debuff.',
  127.     # State rate
  128.     13 => 'Grants %d%% %s resistance.',
  129.     # State immunity
  130.     14 => 'Grants immunity to %s.',
  131.     # Parameter rate
  132.     21 => 'Raises %s by %d%%.',
  133.     # Additional parameter rate
  134.     22 => 'Raises %s by %d%%.',
  135.     # Special parameter rate
  136.     23 => 'Grants a %d% modifier to %s.',
  137.     # Physical attack attribute
  138.     31 => 'Adds %s element to normal attacks.',
  139.     # Physical attack state
  140.     32 => 'Adds %s to normal attacks (%d%% accuracy).',
  141.     # Attack speed correction (bonus)
  142.     33 => ['Raises attack speed by %d.',
  143.     # Attack speed correction (malus)
  144.     'Reduces attack speed by %d.'],
  145.     # Additional attacks
  146.     34 => 'Grants %d additional attacks.',
  147.     # Add skill type
  148.     41 => 'Enables the %s battle command.',
  149.     # Seal skill type
  150.     42 => 'Seals the %s battle command.',
  151.     # Add skill
  152.     43 => 'Allows the use of the %s skill',
  153.     # Seal skill
  154.     44 => 'Seals the %s skill.',
  155.     # Add equip type (weapon)
  156.     51 => 'Allows %s to be equipped.',
  157.     # Add equip type (armor)
  158.     52 => 'Allows %s to be equipped.',
  159.     # Fix equip slot
  160.     53 => 'Fixes the %s equipment slot.',
  161.     # Seal equip slot
  162.     54 => 'Seals the %s equipment slot.',
  163.     # Dual Wield
  164.     55 => 'Allows to use two weapons as the same time.',
  165.     # Bonus actions
  166.     61 => 'Raises the action rate by %d%%.',
  167.     # Autobattle
  168.     62 => ['The character will act on his/her own in battle.',
  169.     # Guard
  170.     'The character will permanently defend.',
  171.     # Cover
  172.     'The character will take hits for his/her wounded comrades.',
  173.     # TP Saver
  174.     'TP are kept after battles.'],
  175.     # Collapse type (no need to use it but meh)
  176.     63 => 'Alters the collapse animation.',
  177.     # Half encounter
  178.     64 => ['Halves the random encounter rate.',
  179.     # No encounter
  180.     'Disables random encounters.',
  181.     # No surprise attacks
  182.     'Disables surprise attacks.',
  183.     # No preemptive attacks
  184.     'Disables preemptive attacks.',
  185.     # Gold x2
  186.     'Doubles the money obtained after a battle.',
  187.     # Item Drops x2
  188.     'Doubles the drop rate of items.']
  189.  
  190.     }
  191.  
  192.     EFFECTS_CODENAMES = {
  193.  
  194.     11 => 'HP Recovery'                   , # HP Recovery
  195.     12 => 'MP Recovery'                   , # MP Recovery
  196.     13 => 'TP Recovery'                   , # TP Gain
  197.     21 => 'Add %s'                        , # Add State
  198.     22 => 'Cleanse %s'                    , # Remove State
  199.     31 => '%s+'                           , # Add buff
  200.     32 => '%s-'                           , # Add debuff
  201.     33 => 'Dispel %s+'                    , # Remove buff
  202.     34 => 'Cancel %s-'                    , # Remove debuff
  203.     41 => 'Escape'                        , # Escape
  204.     42 => '%s Bonus'                      , # Permanent stat growth
  205.     43 => 'Learn %s'                      , # Permanent skill learning
  206.     44 => 'Common Event'                  , # Common event
  207.  
  208.     }
  209.  
  210.     EFFECTS_CODEHELP = {
  211.  
  212.     # HP Recovery (static)
  213.     11 => ['Restores %d HP.',
  214.     # HP Recovery (dynamic)
  215.     'Restores %d%% of maximum HP.'],
  216.     # MP Recovery (static)
  217.     12 => ['Restores %d MP.',
  218.     # MP Recovery (dynamic)
  219.     'Restores %d%% of maximum MP.'],
  220.     # TP Gain
  221.     13 => 'Restores %d%% TP.',
  222.     # Add State
  223.     21 => 'Inflicts %s (%d%% chance).',
  224.     # Remove State
  225.     22 => 'Cancels %s.',
  226.     # Add buff
  227.     31 => 'Increases %s for %d turns.',
  228.     # Add debuff
  229.     32 => 'Decreases %s for %d turns.',
  230.     # Remove buff
  231.     33 => 'Cancels a previously applied %s buff.',
  232.     # Remove debuff
  233.     34 => 'Dispels an active %s debuff.',
  234.     # Escape
  235.     41 => 'Automatically escape from battle.',
  236.     # Permanent stat growth
  237.     42 => 'Boosts %d by %d permanently.',
  238.     # Permanent skill learning
  239.     43 => 'Teaches the %s skill permanently.',
  240.     # Common Event
  241.     44 => 'Calls a common event.'
  242.  
  243.     }
  244.  
  245. #===========================================================================
  246. # ■ CUSTOM TRAITS/EFFECTS CONFIGURATION
  247. #===========================================================================
  248.  
  249.     # INSTRUCTIONS
  250.     # Here you can define custom traits names and descriptions.
  251.     #
  252.     # Syntax:
  253.     # [type, code, data_id, value 1, value2] => [name, description]
  254.     #
  255.     # type: 0 (for equipment), 1 (for usables)
  256.     #
  257.     # code: the code number. Refer to default naming to know what is what.
  258.     #
  259.     # data_id: the number of the option you've choosen in the trait droplist.
  260.     #
  261.     # value1: what you typed in the first field where you can write numbers.
  262.     # For equipment this is the only one.
  263.     #
  264.     # value2: usable items only. What you typed in the second field.
  265.     #
  266.     # description: If you want to also use a custom description. If you only
  267.     # want the custom name, set this to nil.
  268.  
  269.     CUSTOM_TRAITS = {
  270.  
  271.     [0, 32, 2, 50] => ['Poisonous', nil],
  272.     [0, 32, 2, 100] => ['Venomous', nil],
  273.  
  274.     [1, 11, 0, 0, 10] => ['HP Recovery XS', nil],
  275.     [1, 11, 0, 0, 25] => ['HP Recovery S', nil],
  276.     [1, 11, 0, 0, 50] => ['HP Recovery M', nil],
  277.     [1, 11, 0, 0, 75] => ['HP Recovery L', nil],
  278.     [1, 11, 0, 0, 100] => ['HP Recovery XL', 'Restores all HP!'],
  279.     [1, 12, 0, 0, 10] => ['MP Recovery XS', nil],
  280.     [1, 12, 0, 0, 25] => ['MP Recovery S', nil],
  281.     [1, 12, 0, 0, 50] => ['MP Recovery M', nil],
  282.     [1, 12, 0, 0, 75] => ['MP Recovery L', nil],
  283.     [1, 12, 0, 0, 100] => ['MP Recovery XL', 'Restores all MP!'],
  284.     [1, 13, 0, 2, 0] => ['TP Recovery XS', nil],
  285.     [1, 13, 0, 5, 0] => ['TP Recovery S', nil],
  286.     [1, 13, 0, 10, 0] => ['TP Recovery M', nil],
  287.     [1, 13, 0, 16, 0] => ['TP Recovery L', nil],
  288.     [1, 13, 0, 20, 0] => ['TP Recovery XL', nil],
  289.  
  290.     }
  291.  
  292. #===========================================================================
  293. # ■ CONFIGURATION ENDS HERE
  294. #===========================================================================
  295.     #--------------------------------------------------------------------------
  296.     # ● Generates traits name
  297.     #--------------------------------------------------------------------------
  298.     def self.feature_name(code, data_id, value)
  299.       custom = CUSTOM_TRAITS[[0, code, data_id, self.convert_value(code, value)]]
  300.       return custom[0] unless custom.nil? || custom[0].nil?
  301.       base_name = CODENAMES[code]
  302.       data_name = case code
  303.         when 11, 31
  304.           $data_system.elements[data_id]
  305.         when 12, 21
  306.           Vocab.param(data_id)
  307.         when 13, 14, 32
  308.           $data_states[data_id].name
  309.         when 22
  310.           X_PARAMETERS[data_id]
  311.         when 23
  312.           S_PARAMETERS[data_id]
  313.         when 41, 42
  314.           $data_system.skill_types[data_id]
  315.         when 43, 44
  316.           $data_skills[data_id].name
  317.         when 51
  318.           $data_system.weapon_types[data_id]
  319.         when 52
  320.           $data_system.armor_types[data_id]
  321.         when 53, 54
  322.           Vocab.etype(data_id)
  323.         when 62
  324.           SPECIAL_FLAGS[data_id]
  325.         when 64
  326.           PARTY_ABILITY[data_id]
  327.         end
  328.       final_value = case code
  329.         when 11, 13
  330.           100 - (value * 100)
  331.         when 33, 34
  332.           value
  333.         else
  334.           value * 100
  335.         end
  336.       if data_name.nil?
  337.         name = sprintf(base_name, final_value)
  338.       else
  339.         name = sprintf(base_name, data_name, final_value)
  340.       end
  341.       name
  342.     end
  343.     #--------------------------------------------------------------------------
  344.     # ● Generates traits description
  345.     #--------------------------------------------------------------------------
  346.     def self.feature_description(code, data_id, value)
  347.       custom = CUSTOM_TRAITS[[0, code, data_id, self.convert_value(code, value)]]
  348.       return custom[1] unless custom.nil? || custom[1].nil?
  349.       if CODEHELP[code].is_a?(Array)
  350.         base_help = CODEHELP[code][data_id]
  351.       else
  352.         base_help = CODEHELP[code]
  353.       end
  354.       data_name = case code
  355.         when 11, 31
  356.           $data_system.elements[data_id]
  357.         when 12, 21
  358.           Vocab.param(data_id)
  359.         when 13, 14, 32
  360.           $data_states[data_id].name
  361.         when 22
  362.           X_PARAMETERS[data_id]
  363.         when 23
  364.           S_PARAMETERS[data_id]
  365.         when 41, 42
  366.           $data_system.skill_types[data_id]
  367.         when 43, 44
  368.           $data_skills[data_id].name
  369.         when 51
  370.           $data_system.weapon_types[data_id]
  371.         when 52
  372.           $data_system.armor_types[data_id]
  373.         when 53, 54
  374.           Vocab.etype(data_id)
  375.         when 62
  376.           SPECIAL_FLAGS[data_id]
  377.         when 64
  378.           PARTY_ABILITY[data_id]
  379.         end
  380.       final_value = case code
  381.         when 11, 13
  382.           100 - (value * 100)
  383.         when 33, 34
  384.           value
  385.         else
  386.           value * 100
  387.         end
  388.       if data_name.nil?
  389.         name = sprintf(base_help, final_value)
  390.       else
  391.         name = sprintf(base_help, data_name, final_value)
  392.       end
  393.       name
  394.     end
  395.     #--------------------------------------------------------------------------
  396.     # ● Generates effects name
  397.     #--------------------------------------------------------------------------
  398.     def self.effect_name(code, data_id, value1, value2)
  399.       custom = CUSTOM_TRAITS[[1, code, data_id,
  400.       self.convert_value(code, value1, false),
  401.       self.convert_value(code, value2, false)]]
  402.       return custom[0] unless custom.nil? || custom[0].nil?
  403.       base_name = EFFECTS_CODENAMES[code]
  404.       data_name = case code
  405.         when 21, 22
  406.           $data_states[data_id].name
  407.         when 31, 32, 33, 34, 42
  408.           Vocab.param(data_id)
  409.         when 43
  410.           $data_skills[data_id]
  411.         end
  412.       if data_name.nil?
  413.         name = sprintf(base_name, value1, value2)
  414.       else
  415.         name = sprintf(base_name, data_name, value1, value2)
  416.       end
  417.       name
  418.     end
  419.     #--------------------------------------------------------------------------
  420.     # ● Generates effects description
  421.     #--------------------------------------------------------------------------
  422.     def self.effect_description(code, data_id, value1, value2)
  423.       custom = CUSTOM_TRAITS[[1, code, data_id,
  424.       self.convert_value(code, value1, false),
  425.       self.convert_value(code, value2, false)]]
  426.       return custom[1] unless custom.nil? || custom[1].nil?
  427.       if EFFECTS_CODEHELP[code].is_a?(Array)
  428.         base_help = value2 > 0 ? EFFECTS_CODEHELP[code][0] :
  429.         EFFECTS_CODEHELP[code][1]
  430.       else
  431.         base_help = EFFECTS_CODEHELP[code]
  432.       end
  433.       data_name = case code
  434.         when 21, 22
  435.           $data_states[data_id].name
  436.         when 31, 32, 33, 34, 42
  437.           Vocab.param(data_id)
  438.         when 43
  439.           $data_skills[data_id]
  440.         end
  441.       value1 = self.convert_value(code, value1, false)
  442.       value2 = self.convert_value(code, value2, false)
  443.       value1 = value2 if value1 == 0
  444.       if data_name.nil?
  445.         name = sprintf(base_help, value1, value2)
  446.       else
  447.         name = sprintf(base_help, data_name, value1, value2)
  448.       end
  449.       name
  450.     end
  451.     #--------------------------------------------------------------------------
  452.     # ● Converts the real value to the one entered in the editor
  453.     #--------------------------------------------------------------------------
  454.     def self.convert_value(code, value, feature = true)
  455.       if feature && [33, 34].include?(code)
  456.         return value.to_i
  457.       elsif feature && [21].include?(code)
  458.         return (value.to_f / 100)
  459.       elsif [11, 12].include?(code) && value <= 1
  460.         return (value.to_i * 100).to_i
  461.       elsif [21, 22].include?(code)
  462.         return (value * 100).to_i
  463.       else
  464.         value.to_i
  465.       end
  466.     end
  467.     #--------------------------------------------------------------------------
  468.     # ● Points towards either feature name or effect name
  469.     #--------------------------------------------------------------------------
  470.     def self.trait_name(trait)
  471.       if trait.is_a?(RPG::BaseItem::Feature)
  472.         return self.feature_name(trait.code, trait.data_id, trait.value)
  473.       end
  474.       self.effect_name(trait.code, trait.data_id, trait.value1, trait.value2)
  475.     end
  476.     #--------------------------------------------------------------------------
  477.     # ● Points towards either feature description or effect description
  478.     #--------------------------------------------------------------------------
  479.     def self.trait_description(trait)
  480.       if trait.is_a?(RPG::BaseItem::Feature)
  481.         return self.feature_description(trait.code, trait.data_id, trait.value)
  482.       end
  483.       self.effect_description(trait.code, trait.data_id, trait.value1,
  484.       trait.value2)
  485.     end
  486.   end
  487. end

RUBY 代码复制
  1. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  2. #  ▼ Runic Enchantment
  3. #  Author: Kread-EX
  4. #  Version 1.06
  5. #  Release date: 11/03/2012
  6. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  7.  
  8. #-------------------------------------------------------------------------------------------------
  9. #  ▼ UPDATES
  10. #-------------------------------------------------------------------------------------------------
  11. # # 02/06/2012. Now lists equipped items.
  12. # # 19/03/2012. Fixed a crashing bug.
  13. # # 17/03/2012. Added the option to limit runes to either the weapon or the
  14. # # armor. Runes can also be set as impossible to double up on the same
  15. # # equipment piece.
  16. # # Also, bugfixes.
  17. #-------------------------------------------------------------------------------------------------
  18. #  ▼ TERMS OF USAGE
  19. #-------------------------------------------------------------------------------------------------
  20. # #  You are free to adapt this work to suit your needs.
  21. # #  You can use this work for commercial purposes if you like it.
  22. # #  Credit is appreciated.
  23. # #
  24. # # For support:
  25. # # grimoirecastle.wordpress.com
  26. # # rpgmakerweb.com
  27. # # rpgrevolution.com
  28. #-------------------------------------------------------------------------------------------------
  29. #  ▼ INTRODUCTION
  30. #-------------------------------------------------------------------------------------------------
  31. # # An enchantment system inspired from Dragon's Age. Recommended to use only
  32. # # for unique weapons and armors.
  33. #-------------------------------------------------------------------------------------------------
  34. #  ▼ INSTRUCTIONS
  35. #-------------------------------------------------------------------------------------------------
  36. # # REQUIRES THE TRAITS NAMER:
  37. # # [url]http://grimoirecastle.wordpress.com/rgss3-scripts/core-scripts/traits-namer/[/url]
  38. # #
  39. # # Tag enchant-able weapons with <enchant> in their notebox.
  40. # # Modify rune slots with <rune_slots: x>
  41. # #
  42. # # Runes are armors with the <rune> notetag and None as an armor type.
  43. # # <weapon_rune> Limits the rune to a weapon.
  44. # # <armor_rune> Limits the rune to an armor.
  45. # # <unique_rune> Only one of those on the same piece.
  46. # #
  47. # # Use SceneManager.call(Scene_Enchant) to enter the scene or use Yanfly's
  48. # # Ace Menu Engine.
  49. #-------------------------------------------------------------------------------------------------
  50. #  ▼ COMPATIBILITY
  51. #-------------------------------------------------------------------------------------------------
  52. # # List of aliases and overwrites:
  53. # #
  54. # # DataManager
  55. # # load_database (alias)
  56. # # load_sandal_notetags (new method)
  57. # #
  58. # # RPG::EquipItem
  59. # # can_enchant (new attr method)
  60. # # rune_slots (new attr method)
  61. # # rune_type (new attr method)
  62. # # rune_unique (new attr method)
  63. # # load_sandal_notetags (new method)
  64. # # is_rune? (new method)
  65. # # static_rune_params (new method)
  66. # #
  67. # # Game_Actor
  68. # # feature_objects (alias)
  69. # #
  70. # # Game_Party
  71. # # enchants_w (new method)
  72. # # enchants_a (new method)
  73. # # equipped_items (new method)
  74. # #
  75. # # Scene_Enchant (new class)
  76. # # Window_EnchantList (new class)
  77. # # Window_RuneList (new class)
  78. # # Window_ViewRunes (new class)
  79. # # Window_ViewRunesTraits (new class)
  80. #-------------------------------------------------------------------------------------------------
  81.  
  82. # Quits if the Traits Namer isn't found
  83.  
  84. if $imported.nil? || $imported['KRX-TraitsNamer'].nil?
  85.  
  86. msgbox('You need the Traits Namer in order to use Runic Enchantment. Loading aborted.')
  87.  
  88. else
  89.  
  90. $imported['KRX-Enchantment'] = true
  91.  
  92. puts 'Load: Enchantment v1.06 by Kread-EX'
  93.  
  94. #===========================================================================
  95. # ■ CONFIGURATION
  96. #===========================================================================
  97.  
  98. module KRX
  99.  
  100.   # The max rune slots by default.
  101.   RUNE_SLOTS_MAX = 5
  102.  
  103.   module VOCAB
  104.     # Runes name in menus.
  105.     RUNE_NAME = '符文'
  106.     # Runes traits name
  107.     RUNE_TRAITS_NAME = '属性'
  108.   end
  109. #===========================================================================
  110. # ■ CONFIGURATION ENDS HERE
  111. #===========================================================================
  112.   module REGEXP
  113.     ALLOW_ENCHANT = /<enchant>/i
  114.     RUNE = /<rune>/i
  115.     RUNE_SLOTS = /<rune_slots:[ ]*(\d+)>/i
  116.     RUNE_WEAPON = /<weapon_rune>/i
  117.     RUNE_ARMOR = /<armor_rune>/i
  118.     RUNE_UNIQUE = /<unique_rune>/i
  119.   end
  120. end
  121.  
  122. #===========================================================================
  123. # ■ DataManager
  124. #===========================================================================
  125.  
  126. module DataManager
  127.         #--------------------------------------------------------------------------
  128.         # ● Loads the database
  129.         #--------------------------------------------------------------------------
  130.         class << self
  131.                 alias_method(:krx_sandal_dm_load_database, :load_database)
  132.         end
  133.         def self.load_database
  134.                 krx_sandal_dm_load_database
  135.                 load_sandal_notetags
  136.         end  
  137.         #--------------------------------------------------------------------------
  138.         # ● Loads the note tags
  139.         #--------------------------------------------------------------------------
  140.         def self.load_sandal_notetags
  141.                 groups = [$data_weapons, $data_armors]
  142.                 for group in groups
  143.                         for obj in group
  144.                                 next if obj.nil?
  145.                                 obj.load_sandal_notetags
  146.                         end
  147.                 end
  148.                 puts "Read: Enchantment Notetags"
  149.         end
  150. end
  151.  
  152. #===========================================================================
  153. # ■ RPG::EquipItem
  154. #===========================================================================
  155.  
  156. class RPG::EquipItem
  157.         #--------------------------------------------------------------------------
  158.         # ● Public instance variables
  159.         #--------------------------------------------------------------------------
  160.   attr_reader   :can_enchant
  161.   attr_reader   :rune_slots
  162.   attr_reader   :rune_type
  163.   attr_reader   :rune_unique
  164.         #--------------------------------------------------------------------------
  165.         # ● Loads the note tags
  166.         #--------------------------------------------------------------------------
  167.         def load_sandal_notetags
  168.     @rune_slots = KRX::RUNE_SLOTS_MAX
  169.                 @note.split(/[\r\n]+/).each do |line|
  170.                         case line
  171.                         when KRX::REGEXP::ALLOW_ENCHANT
  172.                                 @can_enchant = true
  173.       when KRX::REGEXP::RUNE
  174.         @is_rune = true
  175.       when KRX::REGEXP::RUNE_SLOTS
  176.         @rune_slots = $1.to_i
  177.       when KRX::REGEXP::RUNE_WEAPON
  178.         @rune_type = :weapon
  179.       when KRX::REGEXP::RUNE_ARMOR
  180.         @rune_type = :armor
  181.       when KRX::REGEXP::RUNE_UNIQUE
  182.         @rune_unique = true
  183.                         end
  184.                 end
  185.         end
  186.         #--------------------------------------------------------------------------
  187.         # ● Determine if the item is a rune
  188.         #--------------------------------------------------------------------------
  189.   def is_rune?
  190.     @is_rune && self.is_a?(RPG::Armor)
  191.   end
  192. end
  193.  
  194. #===========================================================================
  195. # ■ Game_Actor
  196. #===========================================================================
  197.  
  198. class Game_Actor < Game_Battler
  199.   #--------------------------------------------------------------------------
  200.   # ● Returns the list of traits
  201.   #--------------------------------------------------------------------------
  202.   alias_method(:krx_sandal_ga_fo, :feature_objects)
  203.   def feature_objects
  204.     runes = []
  205.     equips.compact.each do |equip|
  206.       container = equip.is_a?(RPG::Weapon) ? $game_party.enchants_w :
  207.       $game_party.enchants_a
  208.       next if container[equip.id].nil?
  209.       ids = container[equip.id]
  210.       ids.each do |id|
  211.         next if id.nil?
  212.         runes.push($data_armors[id])
  213.       end
  214.     end
  215.     krx_sandal_ga_fo + runes.compact
  216.   end
  217. end
  218.  
  219. #===========================================================================
  220. # ■ Game_Party
  221. #===========================================================================
  222.  
  223. class Game_Party < Game_Unit
  224.         #--------------------------------------------------------------------------
  225.         # ● Returns the items equipped by all actors
  226.         #--------------------------------------------------------------------------
  227.   def equipped_items
  228.     result = []
  229.     members.each {|actor| result.push(actor.equips)}
  230.     return result.flatten
  231.   end
  232.         #--------------------------------------------------------------------------
  233.         # ● Returns weapon enchantments
  234.         #--------------------------------------------------------------------------
  235.   def enchants_w
  236.     @enchants_w ||= {}
  237.   end
  238.         #--------------------------------------------------------------------------
  239.         # ● Returns armor enchantments
  240.         #--------------------------------------------------------------------------
  241.   def enchants_a
  242.     @enchants_a ||= {}
  243.   end
  244.         #--------------------------------------------------------------------------
  245.         # ● Inscribes a rune
  246.         #--------------------------------------------------------------------------
  247.   def inscribe_rune(e_type, e_id, r_id, r_index)
  248.     container = e_type == RPG::Weapon ? @enchants_w : @enchants_a
  249.     container[e_id] = [] if container[e_id].nil?
  250.     if container[e_id][r_index] != nil
  251.       item = $data_armors[container[e_id][r_index]]
  252.       gain_item(item, 1)
  253.     end
  254.     lose_item($data_armors[r_id], 1) unless r_id.nil?
  255.     container[e_id][r_index] = r_id
  256.   end
  257. end
  258.  
  259. #==========================================================================
  260. # ■ Window_EnchantList
  261. #==========================================================================
  262.  
  263. class Window_EnchantList < Window_ItemList
  264.         #--------------------------------------------------------------------------
  265.         # ● Object Initialize
  266.         #--------------------------------------------------------------------------
  267.         def initialize(x, y, w, h)
  268.                 super(x, y, w, h)
  269.                 refresh
  270.     select(0)
  271.     activate
  272.         end
  273.         #--------------------------------------------------------------------------
  274.         # ● Enable (always true)
  275.         #--------------------------------------------------------------------------
  276.         def enable?(item)
  277.                 item != nil
  278.         end
  279.         #--------------------------------------------------------------------------
  280.         # ● Creates the list based on the recipes
  281.         #--------------------------------------------------------------------------
  282.         def make_item_list
  283.                 @data = []
  284.     ($game_party.all_items + $game_party.equipped_items).each do |itm|
  285.       next if @data.include?(itm)
  286.       @data.push(itm) if itm.is_a?(RPG::EquipItem) && itm.can_enchant
  287.     end
  288.         end
  289.   #--------------------------------------------------------------------------
  290.   # ● Displays the item
  291.   #--------------------------------------------------------------------------
  292.   def draw_item(index)
  293.     item = @data[index]
  294.     if item
  295.       rect = item_rect(index)
  296.       rect.width -= 4
  297.       draw_item_name(item, rect.x, rect.y, enable?(item))
  298.     end
  299.   end
  300.         #--------------------------------------------------------------------------
  301.         # ● Returns the number of columns
  302.         #--------------------------------------------------------------------------
  303.         def col_max
  304.                 return 1
  305.         end
  306.         #--------------------------------------------------------------------------
  307.         # ● Assigns a rune window
  308.         #--------------------------------------------------------------------------
  309.         def rune_window=(value)
  310.                 @rune_window = value
  311.         end
  312.         #--------------------------------------------------------------------------
  313.         # ● Refreshes the help and rune windows
  314.         #--------------------------------------------------------------------------
  315.         def update_help
  316.                 @help_window.set_item(item)
  317.                 @rune_window.set_item(item) unless @rune_window.nil?
  318.         end
  319. end
  320.  
  321. #==========================================================================
  322. # ■ Window_RuneList
  323. #==========================================================================
  324.  
  325. class Window_RuneList < Window_ItemList
  326.         #--------------------------------------------------------------------------
  327.         # ● Object Initialize
  328.         #--------------------------------------------------------------------------
  329.         def initialize(x, y, w, h)
  330.                 super(x, y, w, h)
  331.                 refresh
  332.     select(0)
  333.     hide
  334.         end
  335.         #--------------------------------------------------------------------------
  336.         # ● Enable
  337.         #--------------------------------------------------------------------------
  338.         def enable?(item)
  339.     return true if item.nil?
  340.     if item.rune_unique
  341.       ti = SceneManager.scene.target_item
  342.       container = ti.class == RPG::Weapon ? $game_party.enchants_w :
  343.       $game_party.enchants_a
  344.       slots = container[ti.id]
  345.       return !slots.include?(item.id)
  346.     end
  347.     if item.rune_type == :weapon
  348.       return SceneManager.scene.target_item.class == RPG::Weapon
  349.     elsif item.rune_type == :armor
  350.       return SceneManager.scene.target_item.class == RPG::Armor
  351.     end
  352.                 return true
  353.         end
  354.         #--------------------------------------------------------------------------
  355.         # ● Creates the list based on the recipes
  356.         #--------------------------------------------------------------------------
  357.         def make_item_list
  358.                 @data = $game_party.all_items.select do |itm|
  359.       itm.is_a?(RPG::EquipItem) && itm.is_rune?
  360.     end
  361.     @data.insert(0, nil)
  362.         end
  363.         #--------------------------------------------------------------------------
  364.         # ● Returns the number of columns
  365.         #--------------------------------------------------------------------------
  366.         def col_max
  367.                 return 1
  368.         end
  369.         #--------------------------------------------------------------------------
  370.         # ● Assigns a traits window
  371.         #--------------------------------------------------------------------------
  372.         def traits_window=(value)
  373.                 @traits_window = value
  374.         end
  375.   #--------------------------------------------------------------------------
  376.   # ● Updates the help window
  377.   #--------------------------------------------------------------------------
  378.   def update_help
  379.     @help_window.set_item(item) unless @help_window.nil?
  380.     @traits_window.set_item(item) unless @traits_window.nil?
  381.   end
  382. end
  383.  
  384. #==========================================================================
  385. # ■ Window_ViewRunes
  386. #==========================================================================
  387.  
  388. class Window_ViewRunes < Window_Selectable
  389.         #--------------------------------------------------------------------------
  390.         # ● Object Initialize
  391.         #--------------------------------------------------------------------------
  392.         def initialize(x, y, width, height)
  393.                 super
  394.                 set_item
  395.         end
  396.         #--------------------------------------------------------------------------
  397.         # ● Refresh the contents
  398.         #--------------------------------------------------------------------------
  399.         def set_item(item = nil)
  400.                 contents.clear
  401.                 return if item.nil?
  402.     container = item.is_a?(RPG::Weapon) ? $game_party.enchants_w :
  403.     $game_party.enchants_a
  404.     container[item.id] = [] if container[item.id].nil?
  405.     @data = container[item.id]
  406.     filler = item.rune_slots - @data.size
  407.     filler.times {@data.push(nil)} if filler > 0
  408.                 draw_item_runes(item)
  409.         end
  410.         #--------------------------------------------------------------------------
  411.         # ● Returns the selected rune
  412.         #--------------------------------------------------------------------------
  413.   def get_item
  414.     $data_armors[@data[index]]
  415.   end
  416.         #--------------------------------------------------------------------------
  417.         # ● Displays the item's runes
  418.         #--------------------------------------------------------------------------
  419.         def draw_item_runes(item)
  420.     # Draws the sys text
  421.                 change_color(system_color)
  422.                 contents.draw_text(4, 0, width, line_height, KRX::VOCAB::RUNE_NAME)
  423.                 change_color(normal_color)
  424.                 (1..item.rune_slots).each do |i|
  425.       contents.draw_text(4, line_height * i, width, line_height, "#{i}.")
  426.     end
  427.     # Draws the runes
  428.                 @data.each_index do |i|
  429.       next if @data[i].nil?
  430.                         rune = $data_armors[@data[i]]
  431.       draw_item_name(rune, 28, line_height * (i + 1), true, width - 24)
  432.                 end
  433.         end
  434.         #--------------------------------------------------------------------------
  435.         # ● Returns the number of columns
  436.         #--------------------------------------------------------------------------
  437.         def col_max
  438.                 return 1
  439.         end
  440.   #--------------------------------------------------------------------------
  441.   # ● Returns the max number of rows
  442.   #--------------------------------------------------------------------------
  443.   def item_max
  444.     @data ? @data.size : 1
  445.   end
  446.   #--------------------------------------------------------------------------
  447.   # ● Sets the rectangle for selections
  448.   #--------------------------------------------------------------------------
  449.   def item_rect(index)
  450.     rect = Rect.new
  451.     rect.width = item_width
  452.     rect.height = item_height
  453.     rect.x = index % col_max * (item_width + spacing)
  454.     rect.y = (index / col_max * item_height) + line_height
  455.     rect
  456.   end
  457.         #--------------------------------------------------------------------------
  458.         # ● Assigns a traits window
  459.         #--------------------------------------------------------------------------
  460.         def traits_window=(value)
  461.                 @traits_window = value
  462.         end
  463.   #--------------------------------------------------------------------------
  464.   # ● Updates the help window
  465.   #--------------------------------------------------------------------------
  466.   def update_help
  467.     unless @help_window.nil?
  468.       itm = @data[index].nil? ? nil : get_item
  469.       @help_window.set_item(itm)
  470.     end
  471.     @traits_window.set_item(@data[index]) unless @traits_window.nil?
  472.   end
  473. end
  474.  
  475. #==========================================================================
  476. # ■ Window_ViewRunesTraits
  477. #==========================================================================
  478.  
  479. class Window_ViewRunesTraits < Window_Base
  480.         #--------------------------------------------------------------------------
  481.         # ● Object Initialize
  482.         #--------------------------------------------------------------------------
  483.         def initialize(x, y, width, height)
  484.                 super
  485.                 set_item
  486.         end
  487.         #--------------------------------------------------------------------------
  488.         # ● Refresh the contents
  489.         #--------------------------------------------------------------------------
  490.         def set_item(item = nil)
  491.                 contents.clear
  492.                 return if item.nil?
  493.     item = $data_armors[item] if item.is_a?(Integer)
  494.     draw_rune_traits(item)
  495.         end
  496.         #--------------------------------------------------------------------------
  497.         # ● Displays the rune's traits
  498.         #--------------------------------------------------------------------------
  499.         def draw_rune_traits(item)
  500.     # Draws the sys text
  501.                 change_color(system_color)
  502.                 contents.draw_text(4, 0, width, line_height, KRX::VOCAB::RUNE_TRAITS_NAME)
  503.                 change_color(normal_color)
  504.     # Draws the traits
  505.                 item.features.each_index do |i|
  506.       f = item.features[i]
  507.       name = KRX::TraitsNamer.feature_name(f.code, f.data_id, f.value)
  508.       contents.draw_text(4, line_height * (i + 1), width - 24, line_height, name)
  509.                 end
  510.         end
  511. end
  512.  
  513. #==========================================================================
  514. # ■ Scene_Enchant
  515. #==========================================================================
  516.  
  517. class Scene_Enchant < Scene_ItemBase
  518.         #--------------------------------------------------------------------------
  519.         # ● Scene start
  520.         #--------------------------------------------------------------------------
  521.         def start
  522.     super
  523.     create_help_window
  524.     create_traits_window
  525.     create_rune_window
  526.     create_enchant_window
  527.     create_runelist_window
  528.   end
  529.         #--------------------------------------------------------------------------
  530.         # ● Creates the window showing the rune's traits
  531.         #--------------------------------------------------------------------------
  532.   def create_traits_window
  533.     wx = ww = Graphics.width / 2
  534.     wh = (Graphics.height - @help_window.height) / 2
  535.     wy = Graphics.height - wh
  536.     @traits_window = Window_ViewRunesTraits.new(wx, wy, ww, wh)
  537.   end
  538.         #--------------------------------------------------------------------------
  539.         # ● Creates the window showing the current rune set
  540.         #--------------------------------------------------------------------------
  541.   def create_rune_window
  542.     wy = @help_window.height
  543.     wx = ww = Graphics.width / 2
  544.     wh = (Graphics.height - wy) / 2
  545.     @rune_window = Window_ViewRunes.new(wx, wy, ww, wh)
  546.     @rune_window.help_window = @help_window
  547.     @rune_window.traits_window = @traits_window
  548.     @rune_window.set_handler(:ok, method(:on_slot_ok))
  549.     @rune_window.set_handler(:cancel, method(:on_slot_cancel))
  550.   end
  551.         #--------------------------------------------------------------------------
  552.         # ● Creates the window listing the enchantable equipment
  553.         #--------------------------------------------------------------------------
  554.   def create_enchant_window
  555.     wy = @help_window.height
  556.     ww = Graphics.width / 2
  557.     wh = Graphics.height - wy
  558.     @enchant_window = Window_EnchantList.new(0, wy, ww, wh)
  559.     @enchant_window.set_handler(:ok, method(:on_item_ok))
  560.     @enchant_window.set_handler(:cancel, method(:return_scene))
  561.     @enchant_window.help_window = @help_window
  562.     @enchant_window.rune_window = @rune_window
  563.     @enchant_window.update_help
  564.   end
  565.         #--------------------------------------------------------------------------
  566.         # ● Creates the window listing the available runes
  567.         #--------------------------------------------------------------------------
  568.   def create_runelist_window
  569.     wy = @help_window.height
  570.     ww = Graphics.width / 2
  571.     wh = Graphics.height - wy
  572.     @runelist_window = Window_RuneList.new(0, wy, ww, wh)
  573.     @runelist_window.help_window = @help_window
  574.     @runelist_window.traits_window = @traits_window
  575.     @runelist_window.set_handler(:ok, method(:on_rune_ok))
  576.     @runelist_window.set_handler(:cancel, method(:on_rune_cancel))
  577.   end
  578.         #--------------------------------------------------------------------------
  579.         # ● Validates the item selection
  580.         #--------------------------------------------------------------------------
  581.   def on_item_ok
  582.     @enchant_window.deactivate
  583.     @rune_window.select(0)
  584.     @rune_window.activate
  585.   end
  586.         #--------------------------------------------------------------------------
  587.         # ● Validates the rune slot selection
  588.         #--------------------------------------------------------------------------
  589.   def on_slot_ok
  590.     @rune_window.deactivate
  591.     @enchant_window.hide
  592.     @runelist_window.show.select(0)
  593.     @runelist_window.activate
  594.   end
  595.         #--------------------------------------------------------------------------
  596.         # ● Cancels the rune slot selection
  597.         #--------------------------------------------------------------------------
  598.   def on_slot_cancel
  599.     @rune_window.unselect
  600.     @enchant_window.select_last
  601.     @enchant_window.activate
  602.     @traits_window.set_item(nil)
  603.   end
  604.         #--------------------------------------------------------------------------
  605.         # ● Validates the rune selection
  606.         #--------------------------------------------------------------------------
  607.   def on_rune_ok
  608.     e_type = @enchant_window.item.class
  609.     e_id = @enchant_window.item.id
  610.     r_index = @rune_window.index
  611.     r_id = @runelist_window.item != nil ? @runelist_window.item.id : nil
  612.     $game_party.inscribe_rune(e_type, e_id, r_id, r_index)
  613.     @rune_window.set_item(@enchant_window.item)
  614.     @rune_window.activate
  615.     @runelist_window.hide.refresh
  616.     @runelist_window.unselect
  617.     @enchant_window.show
  618.   end
  619.         #--------------------------------------------------------------------------
  620.         # ● Cancels the rune selection
  621.         #--------------------------------------------------------------------------
  622.   def on_rune_cancel
  623.     @rune_window.activate
  624.     @runelist_window.hide.unselect
  625.     @runelist_window.deactivate
  626.     @enchant_window.show
  627.   end
  628.         #--------------------------------------------------------------------------
  629.         # ● Returns the target item
  630.         #--------------------------------------------------------------------------
  631.   def target_item
  632.     @enchant_window.item
  633.   end
  634. end
  635.  
  636. ## Menu inclusion, with Yanfly's Ace Menu Engine
  637. if $imported["YEA-AceMenuEngine"]
  638.  
  639. #==========================================================================
  640. #  ■ Scene_Menu
  641. #==========================================================================
  642.  
  643. class Scene_Menu < Scene_MenuBase
  644.         #--------------------------------------------------------------------------
  645.         # ● Switch to the enchant scene
  646.         #--------------------------------------------------------------------------
  647.         def command_enchant
  648.     SceneManager.call(Scene_Enchant)
  649.   end
  650. end
  651.  
  652. end ## End of Yanfly's Menu inclusion
  653.  
  654. end ## End of Traits Namer's check.

Lv3.寻梦者

唯一的信徒

梦石
0
星屑
1665
在线时间
1357 小时
注册时间
2013-1-29
帖子
1637
2
发表于 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 把物品当成宝石了囧

查看全部评分

回复 支持 反对

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-11-22 06:35

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表