Advertisement
eugene222

Custom Gold Rates

Jul 23rd, 2014
369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.61 KB | None | 0 0
  1. #===============================================================================
  2. # ** Gold Rate States **
  3. #
  4. # Author:   Evgenij
  5. # Version:  1.1
  6. # Date:     23.07.2014
  7. #===============================================================================
  8. #
  9. # Changelog:
  10. #   V. 1.0 - 23.07.2014 - Script Created
  11. #   V. 1.1 - 23.07.2014 - Added options to choose where this script takes effect   
  12. #
  13. # Description
  14. #   Usually you can only add a feature which will double the gold and the effect
  15. #   is only for battle.
  16. #   With this script you can make custom rates for gold gaining, the rates also
  17. #   work for events and not only in battle.
  18. #
  19. # Notetags for States:
  20. #   <gold_rate: factor>
  21. #  
  22. #   Example: <gold_rate: 1.5>  
  23. #     When you normaly get 100 gold you would get 150 gold with active state.
  24. #       old_gold * 1.5 = new_gold
  25. #===============================================================================
  26. module EVG
  27.   module GoldRate
  28.     #---------------------------------------------------------------------------
  29.     # Should Goldrate States effect battle gold gaining?
  30.     #---------------------------------------------------------------------------
  31.     GOLDRATE_IN_BATTLE = true
  32.     #---------------------------------------------------------------------------
  33.     # Should Goldrate States effect shop gold gaining?
  34.     # Let this false, but if you insinst you can turn it on.
  35.     #---------------------------------------------------------------------------
  36.     GOLDRATE_IN_SHOP   = false
  37.    
  38.     #---------------------------------------------------------------------------
  39.     # Should Goldrate States effect event command gold gaining?
  40.     #---------------------------------------------------------------------------
  41.     GOLDRATE_IN_EVENT  = true
  42.  
  43.     #---------------------------------------------------------------------------
  44.     # If more than one State with a gold rate is active, should they all be
  45.     # multiplicated?
  46.     #     => then true
  47.     #
  48.     # Or should only the max value be taken?
  49.     #     => then false
  50.     #---------------------------------------------------------------------------
  51.     Inject_All_Rates = true
  52.    
  53.     #---------------------------------------------------------------------------
  54.   end
  55. end
  56. #===============================================================================
  57. class RPG::State
  58.   #-----------------------------------------------------------------------------
  59.   def gold_rate
  60.     return @gold_rate ||= if @note =~ /<gold_rate:\s*(.*)\s*>/i
  61.                             $1.to_f
  62.                           else
  63.                             1
  64.                           end
  65.   end
  66.   #-----------------------------------------------------------------------------                    
  67. end
  68. class Game_Troop
  69.   #--------------------------------------------------------------------------
  70.   alias :evg_gt_gt_goldbuff     :gold_total
  71.   #--------------------------------------------------------------------------
  72.   def gold_total
  73.     if EVG::GoldRate::GOLDRATE_IN_BATTLE && evg_gt_gt_goldbuff > 0
  74.       return (evg_gt_gt_goldbuff * $game_party.gold_rate).to_i
  75.     else
  76.       return evg_gt_gt_goldbuff
  77.     end
  78.   end
  79. end
  80. #===============================================================================
  81. class Game_Party
  82.   #-----------------------------------------------------------------------------
  83.   def gold_rate
  84.     rates = all_members.map(&:states).flatten.map(&:gold_rate)
  85.     return 1 if rates.size < 1
  86.     return rates.inject(&:*) if EVG::GoldRate::Inject_All_Rates
  87.     return rates.max
  88.   end
  89.   #-----------------------------------------------------------------------------
  90. end
  91.  
  92. class Game_Interpreter
  93.   #-----------------------------------------------------------------------------
  94.   alias :evg_gi_c125_goldbuff       :command_125
  95.   def command_125
  96.     if EVG::GoldRate::GOLDRATE_IN_EVENT
  97.       value = operate_value(@params[0], @params[1], @params[2])
  98.       value = (value * $game_party.gold_rate).to_i
  99.       $game_party.gain_gold(value)
  100.     else
  101.       evg_gi_c125_goldbuff
  102.     end
  103.   end
  104.   #-----------------------------------------------------------------------------
  105. end
  106. class Scene_Shop
  107.   alias :evg_ss_ds_goldbuff           :do_sell
  108.   def do_sell(number)
  109.     if EVG::GoldRate::GOLDRATE_IN_SHOP
  110.       $game_party.gain_gold(number * selling_price * $game_party.gold_rate)
  111.       $game_party.lose_item(@item, number)
  112.     else
  113.       evg_ss_ds_goldbuff(number)
  114.     end
  115.   end
  116. end
  117. #===============================================================================
  118. # SCRIPT END
  119. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement