Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # ------------------------------------------------------------------------------
- # Same Time Percentage Stack Snippet
- # Dependencies: Upg Equips
- # ------------------------------------------------------------------------------
- # Usage:
- # Causes percentages to stack even when all upgrades are used at the same time
- # Updates
- # 20 Mar 2013 - Initial release
- # ------------------------------------------------------------------------------
- class Scene_UpgradableItem < Scene_ItemBase
- def modify_stats(failed = false)
- percents = {} # maps stat ids to an array of percentages
- raws = {} # maps stat ids to an array of values
- # Goes through all the items and condenses all the upgrades into above
- # two hashes
- @upgraders.each{ |item|
- update_item_upgrades(item) #add each 1 to curr upgs list
- stats = item.upgrade_mods.stat_mods
- stats.keys.each{ |key|
- if stats[key]
- percents[key] = [] if !percents[key]
- raws[key] = [] if !raws[key]
- percents[key].push(stats[key][:percent]) unless !stats[key][:percent]
- raws[key].push(stats[key][:raw]) unless !stats[key][:raw]
- end # End - if stats[key]
- }
- } # End - @upgraders.each
- (0...EquipUpgrades::Max::StatId).each{|id|
- if percents[id] # Modify stats by multiplying percentages
- percents[id].sort!.each do |val|
- curr_val = @upg_equip.params[id]
- mod = upgrade_failed?(failed, curr_val * val) # handle failure case
- @upg_equip.params[id] += mod # + orig_val
- end
- end # End - if percents[id]
- if raws[id] # Modify stats by adding raw values
- raws[id].each { |val|
- val = upgrade_failed?(failed, val)
- @upg_equip.params[id]+= val # handle failure case
- }
- end # End - if raws[id]
- } # End - (0...EquipUpgrades::Max::StatId).each
- end # End - modify_stats
- end # End - Scene_UpgradableItem
Advertisement
Add Comment
Please, Sign In to add comment