Advertisement
TheSixth

Negative Stat Gain Fix for Vlue's W/A Randomization

Nov 7th, 2016
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.67 KB | None | 0 0
  1. =begin
  2.  
  3. Negative Bonus Fix for Vlue's W/A Randomizer v1.1
  4. Made by: Sixth
  5.  
  6. This snippet fixes the negative random stat gains from affixes in
  7. Vlue's W/A Randomizer script.
  8. Without this fix, you would gain positive stats even if you specified a
  9. negative stat gain for your affixes.
  10. This bug only affected the random parameter bonuses, the static ones are fine.
  11.  
  12. Also, with this snippet installed, the note-tags for the basic parameter
  13. randomization for your equipment has been sligthly altered to allow negative
  14. stat "bonuses" as well.
  15. Nothing changed in it's format, you just have to enter a + or - before the
  16. value, the rest is the same.
  17. Examples:
  18.  
  19.  - Old:         - New:           - Negative versions:
  20.   <ATK 15>       <ATK +15>        <ATK -15>
  21.   <LUK% 50>      <LUK% +50>       <LUK% -50>
  22.   <PRICE 10>     <PRICE +10>      <PRICE -10>
  23.  
  24. So, use the new versions from now on!
  25.  
  26. And finally, this snippet will fix some issues with my
  27. Equipment Parameter Description script, so if you are planning to use that,
  28. you will have to use this one too to avoid display errors!
  29.  
  30. Put this script right below Vlue's W/A Randomizer script!
  31.  
  32. =end
  33.  
  34. class Game_Party < Game_Unit
  35.  
  36.   def rrand(value)
  37.     base = rand(value)
  38.     base *= -1 if value < 0
  39.     return base
  40.   end
  41.  
  42.   def add_affix(item, id, prefix)
  43.     affix = AFFIXES[id.to_i]
  44.     if prefix && !affix[:name].nil?
  45.       item.name = affix[:name] + item.name
  46.     elsif !affix[:name].nil?
  47.       item.name = item.name + affix[:name]  
  48.     end
  49.     if !affix[:rarity].nil?
  50.       if item.rarity.nil? || item.rarity < affix[:rarity]
  51.         item.set_color(affix[:color]) if !affix[:color].nil?
  52.         item.rarity = affix[:rarity]
  53.       end
  54.     else
  55.       item.set_color(affix[:color]) if !affix[:color].nil?
  56.     end
  57.     item.change_desc(:desc,affix[:desc]) if affix[:desc]
  58.     item.change_desc(:pdesc,affix[:pdesc]) if affix[:pdesc]
  59.     item.change_desc(:sdesc,affix[:sdesc]) if affix[:sdesc]
  60.     if !item.is_a?(RPG::Armor) && !affix[:animation].nil?
  61.       item.animation_id = affix[:animation]
  62.     end
  63.     item.icon_index = affix[:icon] if !affix[:icon].nil?
  64.     if !item.is_a?(RPG::Item)
  65.       [:hp,:mp,:atk,:def,:mat,:mdf,:agi,:luk].each_with_index do |prm,i|
  66.         next unless affix[prm]
  67.         item.params[i] += rrand(affix[prm])
  68.       end
  69.       [:Shp,:Smp,:Satk,:Sdef,:Smat,:Smdf,:Sagi,:Sluk].each_with_index do |prm,i|
  70.         next unless affix[prm]
  71.         item.params[i] += affix[prm]
  72.       end
  73.       [:hpP,:mpP,:atkP,:defP,:matP,:mdfP,:agiP,:lukP].each_with_index do |prm,i|
  74.         next unless affix[prm]
  75.         add = item.params[i] * (rrand(affix[prm])) * 0.01
  76.         item.params[i] += add.to_i
  77.       end
  78.       [:ShpP,:SmpP,:SatkP,:SdefP,:SmatP,:SmdfP,:SagiP,:SlukP].each_with_index do |prm,i|
  79.         next unless affix[prm]
  80.         add = item.params[i] * affix[prm] * 0.01
  81.         item.params[i] += add.to_i
  82.       end
  83.     end
  84.     item.price += rrand(affix[:price]) if affix[:price]
  85.     item.price += affix[:Sprice] if affix[:Sprice]
  86.     if affix[:priceP]
  87.       add = item.price * (rrand(affix[:priceP])) * 0.01
  88.       item.price += add.to_i
  89.     end
  90.     if affix[:SpriceP]
  91.       add = item.price * affix[:SpriceP] * 0.01
  92.       item.price += add.to_i
  93.     end
  94.     if !affix[:features].nil? && !item.is_a?(RPG::Item)
  95.       for feature in affix[:features]
  96.         new_feature = RPG::BaseItem::Feature.new(*feature)
  97.         item.features.push(new_feature)
  98.       end
  99.     end
  100.     return true
  101.   end
  102.  
  103.   def set_static_bonus(item,param,i)
  104.     if item.note =~ /<#{param} ([+\-]\d+)>/i
  105.       item.params[i] += rrand($1.to_i)
  106.     end
  107.   end
  108.  
  109.   def set_percent_bonus(item,param,i)
  110.     if item.note =~ /<#{param}% ([+\-]\d+)>/i
  111.       add = item.params[i] * rrand($1.to_i) * 0.01
  112.       item.params[i] += add.to_i
  113.     end
  114.   end
  115.  
  116.   def edit_item(item)
  117.     if !item.is_a?(RPG::Item)
  118.       ["HP","MP","ATK","DEF","MAT","MDF","AGI","LUK"].each_with_index do |param,i|
  119.         set_static_bonus(item,param,i)
  120.         set_percent_bonus(item,param,i)
  121.       end
  122.     end
  123.     item.price += rrand($1.to_i) if item.note =~ /<PRICE ([+\-]\d+)>/
  124.     if item.note =~ /<PRICE% ([+\-]\d+)>/
  125.       add = item.price * rrand($1.to_i) * 0.01
  126.       item.price += add.to_i
  127.     end    
  128.   end
  129.  
  130. end
  131.  
  132. class RPG::BaseItem
  133.  
  134.   def change_desc(type,atxt)
  135.     case type
  136.     when :dessc
  137.       @description = atxt
  138.     when :pdesc
  139.       @description = atxt + @description
  140.     when :sdesc
  141.       @description = @description + atxt
  142.     end
  143.   end
  144.  
  145. end
  146. #==============================================================================
  147. # !!END OF SCRIPT!!
  148. #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement