daily pastebin goal
19%
SHARE
TWEET

Custom Feature Extension for Vlue's W/A Randomizer by Sixth

TheSixth Sep 4th, 2015 133 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #===============================================================================
  2. # * [ACE] Custom Feature Extension for Vlue's Randomizer
  3. #===============================================================================
  4. # * Made by: Sixth (www.rpgmakervxace.net, www.forums.rpgmakerweb.com)
  5. # * Version: 1.3
  6. # * Updated: 22/05/2015
  7. # * Requires: Vlue's W/A Randomizer script
  8. #-------------------------------------------------------------------------------
  9. # * < Change Log >
  10. #-------------------------------------------------------------------------------
  11. # * Version 1.0 (04/01/2015)
  12. #   - Initial release.
  13. # * Version 1.1 (05/01/2015)
  14. #   - Fixed a crash issue. Opss! >.>
  15. # * Version 1.2 (22/03/2015)
  16. #   - Added several new options to change the item's properties, any of them!
  17. #     This includes things like damage formula, scope, element type, etc.
  18. #     Well, everything is included, literally.
  19. #   - Added an option to add new notes into the notefield of the new item.
  20. #     This makes it possible to add any custom effects from any custom scripts
  21. #     easily for your randomized items! That is if they use note-tags to get the
  22. #     new custom effects onto the item, of course.
  23. #     There is also an option to completely replace the current note-field with
  24. #     a new text, if you want.
  25. # * Version 1.3 (26/05/2015)
  26. #   - Fixed the issue of note-field settings not working.
  27. #-------------------------------------------------------------------------------
  28. # * < Description >
  29. #-------------------------------------------------------------------------------
  30. # * This script will rewrite some methods from Vlue's Randomizer script for
  31. #   my Enchant System, therefore this is required for my Enchant System script.
  32. # * This script will also add additional options for you to use for setting up
  33. #   your affixes in Vlue's W/A Randomizer script.
  34. #   These new options are:
  35. #   - Possibility of setting up random items too, not just equips!
  36. #   - Currently includes new affix setup options for the following scripts:
  37. #     ~ Convert Damage (Yanfly)
  38. #     ~ Critical Hit Effects (Victor)
  39. #     ~ Element Strengthen (Victor)
  40. # * From version 1.2, you can change your randomized items even further!
  41. #   Changing damage formulas, hit types, scopes, occasions, element types, and
  42. #   all other properties is possible now!
  43. # * Adding new notes to the note-field is also possible now!
  44. #-------------------------------------------------------------------------------
  45. # * < Instructions >
  46. #-------------------------------------------------------------------------------
  47. # * New affix options for making randomized items:
  48. #
  49. # ~ For adding random effects onto your items:
  50. #
  51. #   :effects => [[e.code,data_id,val1,val2]],
  52. #   #Examples: :effects => [[11,0,0,120],[12,0,0.1,0]], :effects => [[43,63,0,0]],
  53. #
  54. #   Replace 'e.code' with the effect's effect code. See the list below!
  55. #   Replace 'data_id' with the data ID of the effect. See list below!
  56. #   Replace 'val1' and 'val2' with the power of the effect.
  57. #   Some effects use 2 values, that is why there are two of them in the setup.
  58. #   See the list below for possible and valid value setups!
  59. #              
  60. #   You can define multiple effects for the affixes as shown in the examples!
  61. #
  62. #   Here is the list of item effect codes and valid setups for them:
  63. #
  64. #      effect       code         data_id              value1          value2
  65. #   HP Heal      ->  11 -> data_id is always 0 -> val1 is float -> val2 is integ
  66. #   MP Heal      ->  12 -> data_id is always 0 -> val1 is float -> val2 is integ
  67. #   TP Gain      ->  13 -> data_id is always 0 -> val1 is integ -> val2 is alw 0
  68. #   Add State    ->  21 -> data_id = state IDs -> val1 is float -> val2 is alw 0
  69. #   Rem State    ->  22 -> data_id = state IDs -> val1 is float -> val2 is alw 0
  70. #   Add Buff     ->  31 -> data_id = param IDs -> val1 is integ -> val2 is alw 0
  71. #   Add Debuff   ->  32 -> data_id = param IDs -> val1 is integ -> val2 is alw 0
  72. #   Rem Buff     ->  33 -> data_id = param IDs -> val1 is alw 0 -> val2 is alw 0
  73. #   Rem Debuff   ->  34 -> data_id = param IDs -> val1 is alw 0 -> val2 is alw 0
  74. #   Spec Effect  ->  41 -> data_id is always 0 -> val1 is alw 0 -> val2 is alw 0
  75. #   Grow         ->  42 -> data_id = param IDs -> val1 is alw 0 -> val2 is alw 0
  76. #   Learn Skill  ->  43 -> data_id = skill IDs -> val1 is alw 0 -> val2 is alw 0
  77. #   Common Event ->  44 -> data_id = event IDs -> val1 is alw 0 -> val2 is alw 0
  78. #
  79. #   float = -0.1, 0.03, -2.4, 1.34, etc. - Usually represents percentages.
  80. #   integ = 1, -3, -345, 460, 5600, etc. - Usually represents direct values.
  81. #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  82. # * New affix options for changing the item's properties (items only!):
  83. #
  84. #     :scope => value,
  85. #   This changes the scope of the item. Valid values are:
  86. #   0 = None, 1 = One Enemy, 2 = All Enemy, 3 = 1 Random Enemy,
  87. #   4 = 2 Random Enemies, 5 = 3 Random Enemies, 6 = 4 Random Enemies,
  88. #   7 = 1 Ally, 8 = All Allies, 9 = One Ally (Dead), 10 = All Allies (Dead),
  89. #   11 = The User
  90. #
  91. #     :occasion => value,
  92. #   This changes the occasion of the item. Valid values are:
  93. #   0 = Always, 1 = Only In Battle, 2 = Only From the Menu, 3 = Never
  94. #
  95. #     :speed => value,
  96. #   Changes the speed of the item. Uses integer values.
  97. #
  98. #     :success_rate => value,
  99. #   Changes the success rate of the item. Uses integer values, 100 = 100%.
  100. #
  101. #     :repeats => value,
  102. #   Changes the repeat times of the item. Uses integer values from 1 to 9.
  103. #
  104. #     :tp_gain => value,
  105. #   Changes the TP gain for using the item. Uses integer values.
  106. #
  107. #     :hit_type => value,
  108. #   Changes the hit type of the item. Valid values are:
  109. #   0 = Certain Hit, 1 = Physical Attack, 2 = Magical Attack
  110. #
  111. #     :damage_type => value,
  112. #   Changes the damage type of the item. Valid values are:
  113. #   0 = None, 1 = HP Damage, 2 = MP Damage, 3 = HP Recovery, 4 = MP Recovery,
  114. #   5 = HP Drain, 6 = MP Drain
  115. #
  116. #     :element_id => value,
  117. #   Changes the element type of the damage. Uses element IDs for the value.
  118. #   0 means it is a normal, non-elemental damage, the rest takes the elements
  119. #   from the database.
  120. #
  121. #     :dmg_formula => "formula",
  122. #   Changes the damage formula of the item. It is a string, and got the same
  123. #   properties like the damage formula in the database, meaning you can use
  124. #   the same stuffs in it like there (a = attacker, b = user, v = variables, etc).
  125. #
  126. #     :dmg_variance => value,
  127. #   Changes the damage variance of the item. Uses integer values.
  128. #
  129. #     :critical => true/false,
  130. #   Changes the critical flag for the item. If true, the item can hit criticals,
  131. #   if false, criticals will be disabled for the item.
  132. #
  133. #     :consumable => true/false,
  134. #   Changes the consumable flag for the item. If true, the item will be consumed
  135. #   upon usage, if false, it will not be consumed even after usage.
  136. #
  137. #     :itype => value,
  138. #   Changes the item's type. Valid values:
  139. #   1 = Regular Item, 2 = Key Item
  140. #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  141. # * New affix options for changing the note field of the items or adding extra
  142. #   notes for the items (any item, meaning items, weapons or armors):
  143. #
  144. #     :addnote => "text"
  145. #   Adds the specified text to the note field of the item.
  146. #   This way, people can add any extra effects from custom scripts which
  147. #   operate with note-tags on items. Handy tool!
  148. #
  149. #     :replacenote => "text"
  150. #   Replaces the original note field with the text defined for the items entirely.
  151. #   The replace happens before anything else is added to the notes with the above
  152. #   option, make sure to keep this in mind!
  153. #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  154. # * New affix options for Yanfly's Convert Damage script:
  155. #
  156. # ~ For adding a convert damage feature, you can use this new option:
  157. #
  158. #     :convert_damage => [[effect,value]],
  159. #     #Examples: :convert_damage => [[:hp_physical,0.05],[:mp_physical,0.01]],
  160. #                :convert_damage => [[:mp_magical,0.1]],
  161. #
  162. #   Replace 'effect' with a valid effect symbol.
  163. #   Valid symbols: :hp_physical, :hp_magical, :mp_physical, :mp_magical.
  164. #   Replace 'value' with the power of the effect.
  165. #   The 'value' uses float values, so 0.1 means 10%, 0.5 means 50%, 1.0 means 100%.
  166. #   You can define as many convert damage features as you want for an affix
  167. #   with a single ':convert_damage' setup as shown in the examples!
  168. #
  169. # ~ For adding an anti-convert feature, you can use this new option:
  170. #
  171. #     :anticonvert => [effect],
  172. #     #Examples: :anticonvert => [:hp_magical,:mp_physical],
  173. #                :anticonvert => [:mp_magical],
  174. #
  175. #   Replace 'effect' with a valid effect symbol.
  176. #   Valid symbols: :hp_physical, :hp_magical, :mp_physical, :mp_magical.
  177. #   You can define as many anti-convert features as you want for an affix
  178. #   with a single ':anticonvert' setup as shown in the examples!
  179. #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  180. # * New affix options for Victor's Critical Hit Effects script:
  181. #
  182. # ~ For adding a critical damage feature, you can use this new option:
  183. #  
  184. #     :cri_dmg => value,  #Examples: :cri_dmg => 60, :cri_dmg => -20,
  185. #  
  186. #   Replace the 'value' with the percentage bonus you want to add for the item.
  187. #   The 'value' represents percentages, so 1 = 1%, -20 = -20%, 100 = 100%, etc.
  188. #
  189. # ~ For adding a critical defense feature, you can use this new option:
  190. #
  191. #     :cri_def => value,  #Examples: :cri_def => 40, :cri_def => -50,
  192. #  
  193. #   Replace the 'value' with the percentage bonus you want to add for the item.
  194. #   The 'value' represents percentages, so 1 = 1%, -20 = -20%, 100 = 100%, etc.
  195. #
  196. # ~ For adding a critical state add feature, you can use this new option:
  197. #
  198. #     :cri_state_add => [[state_id,chance],[state_id,chance]],
  199. #     #Examples: :cri_state_add => [[2,20],[3,30]], :cri_state_add => [[4,14]],
  200. #
  201. #   Replace 'state_id' with the ID of the state you want to use for the feature.
  202. #   Replace 'chance' with the chance of occurence of the effect.
  203. #   The 'chance' value represents percentages, so 10 = 10%, 50 = 50%, etc.
  204. #   You can define as many crit state add features as you want for an affix
  205. #   with a single ':cri_state_add' setup as shown in the examples!
  206. #
  207. # ~ For adding a critical state remove feature, you can use this new option:
  208. #
  209. #     :cri_state_rem => [[state_id,chance],[state_id,chance]],
  210. #     #Examples: :cri_state_rem => [[1,8],[4,52]], :cri_state_rem => [[6,34]],
  211. #
  212. #   Replace 'state_id' with the ID of the state you want to use for the feature.
  213. #   Replace 'chance' with the chance of occurence of the effect.
  214. #   The 'chance' value represents percentages, so 10 = 10%, 50 = 50%, etc.
  215. #   You can define as many crit state remove features as you want for an affix
  216. #   with a single ':cri_state_rem' setup as shown in the examples!
  217. #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  218. # * New affix options for Victor's Element Strengthen script:
  219. #
  220. # ~ For adding an element strengthen feature, you can use this new option:
  221. #
  222. #     :ele_str => [[element_id,value],[element_id,value]],
  223. #     #Examples: :ele_str => [[3,20],[4,-28]], :ele_str => [[6,36]],
  224. #
  225. #   Replace 'element_id' with the ID of the element you want to use for the feature.
  226. #   Replace 'value' with the strenght of the effect.
  227. #   The 'value' represents percentages, so 10 = 10%, 50 = 50%, etc.
  228. #   You can define as many element strengthen features as you want for an affix
  229. #   with a single ':ele_str' setup as shown in the examples!
  230. #-------------------------------------------------------------------------------
  231. # * < Installation >
  232. #-------------------------------------------------------------------------------
  233. # * Put this scipt below Vlue's W/A Randomizer but above Main!
  234. #-------------------------------------------------------------------------------
  235. # * < Compatibility Info >
  236. #-------------------------------------------------------------------------------
  237. # * No known incompatibilities.
  238. #-------------------------------------------------------------------------------
  239. # * < Known Issues >
  240. #-------------------------------------------------------------------------------
  241. # * No known issues.
  242. #-------------------------------------------------------------------------------
  243. # * < Terms of Use >
  244. #-------------------------------------------------------------------------------
  245. # * Free to use for whatever purposes you want.
  246. # * Credit me (Sixth) in your game, pretty please! :P
  247. # * Posting modified versions of this script is allowed as long as you notice me
  248. #   about it with a link to it!
  249. #===============================================================================
  250. $imported = {} if $imported.nil?
  251. $imported["SixthRandomizerEX"] = true
  252. #===============================================================================
  253. # Settings:
  254. #===============================================================================
  255.  
  256. #Stack random item, when false all items are unique
  257. STACK_SAME_ITEM = true
  258.  
  259. #===============================================================================
  260. # End of Settings Part!
  261. # Editing below may lead to malfunctioning brain-cells! You have been warned!
  262. #===============================================================================
  263.  
  264. class Game_Party
  265.  
  266.   attr_accessor :saved_items
  267.  
  268.   alias sixth_ini_ritems1222 initialize
  269.   def initialize
  270.     sixth_ini_ritems1222
  271.     @saved_items = $data_items
  272.   end
  273.  
  274.   def add_weapon(id, amount, false_add = false, subnote=nil)
  275.     item = Marshal.load(Marshal.dump($data_weapons[id]))
  276.     edit_item(item)
  277.     edit_affixes(item, subnote)
  278.     if STACK_SAME_EQUIP
  279.       $data_weapons.each do |base_item|
  280.         next if base_item.nil?
  281.         if ( item.params == base_item.params &&
  282.             item.features.size == base_item.features.size &&
  283.             item.price == base_item.price &&
  284.             item.name == base_item.name &&
  285.             item.color == base_item.color)
  286.           $game_party.gain_item(base_item, amount) unless false_add
  287.           return base_item
  288.         end
  289.       end
  290.     end
  291.     item.note += @extra_note if !@extra_note.nil?
  292.     item.note += @extra_note2 if !@extra_note2.nil?
  293.     item.set_original(item.id)
  294.     item.id = $data_weapons.size
  295.     $data_weapons.push(item)
  296.     $game_party.gain_item(item, amount) unless false_add
  297.     return item
  298.   end
  299.  
  300.   def add_armor(id, amount, false_add = false, subnote=nil)
  301.     item = Marshal.load(Marshal.dump($data_armors[id]))
  302.     edit_item(item)
  303.     edit_affixes(item, subnote)
  304.     if STACK_SAME_EQUIP
  305.       $data_armors.each do |base_item|
  306.         next if base_item.nil?
  307.         if ( item.params == base_item.params &&
  308.             item.features.size == base_item.features.size &&
  309.             item.price == base_item.price &&
  310.             item.name == base_item.name &&
  311.             item.color == base_item.color)
  312.           $game_party.gain_item(base_item, amount) unless false_add
  313.           return base_item
  314.         end
  315.       end
  316.     end
  317.     item.note += @extra_note if !@extra_note.nil?
  318.     item.note += @extra_note2 if !@extra_note2.nil?
  319.     item.set_original(item.id)
  320.     item.id = $data_armors.size
  321.     $data_armors.push(item)
  322.     $game_party.gain_item(item, amount) unless false_add
  323.     return item
  324.   end
  325.  
  326.   def add_item(id, amount, false_add = false, subnote=nil)
  327.     item = Marshal.load(Marshal.dump($data_items[id]))
  328.     edit_item(item)
  329.     edit_affixes(item, subnote)
  330.     if STACK_SAME_ITEM
  331.       $data_items.each do |base_item|
  332.         next if base_item.nil?
  333.         if (item.price == base_item.price &&
  334.             item.effects.size == base_item.effects.size &&
  335.             item.name == base_item.name &&
  336.             item.color == base_item.color)
  337.           $game_party.gain_item(base_item, amount) unless false_add
  338.           return base_item
  339.         end
  340.       end
  341.     end
  342.     item.note += @extra_note if !@extra_note.nil?
  343.     item.note += @extra_note2 if !@extra_note2.nil?
  344.     item.set_original(item.id)
  345.     item.id = $data_items.size
  346.     $data_items.push(item)
  347.     $game_party.gain_item(item, amount) unless false_add
  348.     return item
  349.   end
  350.  
  351.   alias sixth_enchant_affix1223 add_affix
  352.   def add_affix(item, id, prefix)
  353.     affix = AFFIXES[id.to_i]
  354.     if prefix
  355.       @extra_note = ""
  356.     else
  357.       @extra_note2 = ""
  358.     end
  359.     # For adding/changing the note field of the items.
  360.     item.note = affix[:replacenote] if !affix[:replacenote].nil?
  361.     item.note = item.note + affix[:addnote] if !affix[:addnote].nil?
  362.     # For Victor's Critical Hit Effects
  363.     if prefix && !affix[:cri_dmg].nil?
  364.       @extra_note += "\r\n<critical damage: #{affix[:cri_dmg]}%>"
  365.     elsif !affix[:cri_dmg].nil?
  366.       @extra_note2 += "\r\n<critical damage: #{affix[:cri_dmg]}%>"
  367.     end
  368.     if prefix && !affix[:cri_def].nil?
  369.       @extra_note += "\r\n<critical defense: #{affix[:cri_def]}%>"
  370.     elsif !affix[:cri_def].nil?
  371.       @extra_note2 += "\r\n<critical defense: #{affix[:cri_def]}%>"
  372.     end
  373.     if prefix && !affix[:cri_state_add].nil?
  374.       for state in affix[:cri_state_add]
  375.         @extra_note += "\r\n<critical state add: #{state[0]}, #{state[1]}%>"
  376.       end
  377.     elsif !affix[:cri_state_add].nil?
  378.       for state in affix[:cri_state_add]
  379.         @extra_note2 += "\r\n<critical state add: #{state[0]}, #{state[1]}%>"
  380.       end
  381.     end
  382.     if prefix && !affix[:cri_state_rem].nil?
  383.       for state in affix[:cri_state_rem]
  384.         @extra_note += "\r\n<critical state remove: #{state[0]}, #{state[1]}%>"
  385.       end
  386.     elsif !affix[:cri_state_rem].nil?
  387.       for state in affix[:cri_state_rem]
  388.         @extra_note2 += "\r\n<critical state remove: #{state[0]}, #{state[1]}%>"
  389.       end
  390.     end
  391.     # For Victor's Element Strengthen
  392.     if prefix && !affix[:ele_str].nil?
  393.       for element in affix[:ele_str]
  394.         @extra_note += "\r\n<element strenghten #{element[0]}: #{element[1]}%>"
  395.       end
  396.     elsif !affix[:ele_str].nil?
  397.       for element in affix[:ele_str]
  398.         @extra_note2 += "\r\n<element strenghten #{element[0]}: #{element[1]}%>"
  399.       end
  400.     end
  401.     # For Yanfly's Convert Damage effects
  402.     if !affix[:convert_damage].nil? && !item.is_a?(RPG::Item)
  403.       for conv_dmg in affix[:convert_damage]
  404.         item.convert_dmg[conv_dmg[0]] = conv_dmg[1]
  405.       end
  406.     end
  407.     if !affix[:anticonvert].nil? && !item.is_a?(RPG::Item)
  408.       for anti_conv in affix[:anticonvert]
  409.         item.anticonvert.push(anti_conv)
  410.       end
  411.     end
  412.     # For item effects
  413.     if item.is_a?(RPG::Item)
  414.       # Item effects
  415.       if !affix[:effects].nil?
  416.         for effect in affix[:effects]
  417.           new_effect = RPG::UsableItem::Effect.new(effect[0], effect[1], effect[2], effect[3])
  418.           item.effects.push(new_effect)
  419.         end
  420.       end
  421.       # Item properties
  422.       item.scope = affix[:scope] if !affix[:scope].nil?
  423.       item.occasion = affix[:occasion] if !affix[:occasion].nil?
  424.       item.speed = affix[:speed] if !affix[:speed].nil?
  425.       item.success_rate = affix[:success_rate] if !affix[:success_rate].nil?
  426.       item.repeats = affix[:repeats] if !affix[:repeats].nil?
  427.       item.tp_gain = affix[:tp_gain] if !affix[:tp_gain].nil?
  428.       item.hit_type = affix[:hit_type] if !affix[:hit_type].nil?
  429.       item.damage.type = affix[:damage_type] if !affix[:damage_type].nil?
  430.       item.damage.element_id = affix[:element_id] if !affix[:element_id].nil?
  431.       item.damage.formula = affix[:dmg_formula] if !affix[:dmg_formula].nil?
  432.       item.damage.variance = affix[:dmg_variance] if !affix[:dmg_variance].nil?
  433.       item.damage.critical = affix[:critical] if !affix[:critical].nil?
  434.       item.consumable = affix[:consumable] if !affix[:consumable].nil?
  435.       item.itype_id = affix[:itype] if !affix[:itype].nil?
  436.     end
  437.     sixth_enchant_affix1223(item, id, prefix)
  438.   end
  439.  
  440. end
  441.  
  442. class Scene_Load
  443.  
  444.   alias sixth_load_ritems1222 on_load_success
  445.   def on_load_success
  446.     sixth_load_ritems1222
  447.     $data_items = $game_party.saved_items
  448.   end
  449.  
  450. end
  451. #==============================================================================
  452. # !!END OF SCRIPT!!
  453. #==============================================================================
RAW Paste Data
Top