LiTTleDRAgo

[RGSS] Falcon's Tax Script

Jan 15th, 2013
113
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #============================================================================
  2. # Tax Script 2.0
  3. #----------------------------------------------------------------------------
  4. # By Falcon
  5. # Thanks to Blizzard for the idea that triggered version 2.0
  6. #----------------------------------------------------------------------------
  7. # This system should be compatible with all shop systems, but the
  8. # Shop Status window will only show the tax/discount rate for the default
  9. #============================================================================
  10.  
  11. # setup the variable that will hold the tax rate
  12. class Game_System
  13.   attr_accessor :tax
  14.   alias init_tax initialize
  15.   def initialize
  16.     init_tax
  17.     @tax = 0
  18.   end
  19. end
  20.  
  21. # increase the price of the following items by the tax rate
  22. module RPG
  23.   class Item
  24.     alias price_tax price
  25.     def price() (price_tax + price_tax*($game_system.tax || 0) / 100).to_i end
  26.   end
  27.  
  28.   class Weapon
  29.     alias price_tax price
  30.     def price() (price_tax + price_tax*($game_system.tax || 0) / 100).to_i end
  31.   end
  32.  
  33.   class Armor
  34.     alias price_tax price
  35.     def price() (price_tax + price_tax*($game_system.tax || 0) / 100).to_i end
  36.   end
  37. end
  38.  
  39. class Window_ShopStatus < Window_Base
  40.   #--------------------------------------------------------------------------
  41.   # * Refresh
  42.   #--------------------------------------------------------------------------
  43.   def refresh
  44.     self.contents.clear
  45.     return if @item == nil
  46.     case @item
  47.     when RPG::Item
  48.       number = $game_party.item_number(@item.id)
  49.     when RPG::Weapon
  50.       number = $game_party.weapon_number(@item.id)
  51.     when RPG::Armor
  52.       number = $game_party.armor_number(@item.id)
  53.     end
  54.     self.contents.font.color = system_color
  55.     self.contents.draw_text(4, 0, 200, 32, "Number in Possession")
  56.     self.contents.font.color = normal_color
  57.     self.contents.draw_text(204, 0, 32, 32, number.to_s, 2)
  58.     self.contents.font.color = system_color
  59.     # If there is tax, then let the player know about it
  60.     tax = $game_system.tax || 0
  61.     if tax > 0 # If there is tax
  62.       self.contents.draw_text(4, 0, 200, 86, "Current Tax Rate")
  63.       self.contents.font.color = normal_color
  64.       self.contents.draw_text(132, 0, 104, 86, tax.to_s + "%", 2)
  65.     elsif tax < 0 # If there is a discount rate
  66.       self.contents.draw_text(4, 0, 200, 86, "Discount Rate")
  67.       self.contents.font.color = normal_color
  68.       self.contents.draw_text(122, 0, 124, 86, tax.to_s + "%", 2)
  69.     end
  70.     return if @item.is_a?(RPG::Item)
  71.     # Equipment adding information
  72.     for i in 0...$game_party.actors.size
  73.       # Get actor
  74.       actor = $game_party.actors[i]
  75.       # If equippable, then set to normal text color. If not, set to
  76.       # invalid text color.
  77.       if actor.equippable?(@item)
  78.         self.contents.font.color = normal_color
  79.       else
  80.         self.contents.font.color = disabled_color
  81.       end
  82.       # Draw actor's name
  83.       self.contents.draw_text(4, 64 + 64 * i, 120, 32, actor.name)
  84.       # Get current equipment
  85.       if @item.is_a?(RPG::Weapon)
  86.         item1 = $data_weapons[actor.weapon_id]
  87.       elsif @item.kind == 0
  88.         item1 = $data_armors[actor.armor1_id]
  89.       elsif @item.kind == 1
  90.         item1 = $data_armors[actor.armor2_id]
  91.       elsif @item.kind == 2
  92.         item1 = $data_armors[actor.armor3_id]
  93.       else
  94.         item1 = $data_armors[actor.armor4_id]
  95.       end
  96.       # If equippable
  97.       if actor.equippable?(@item)
  98.         # If weapon
  99.         if @item.is_a?(RPG::Weapon)
  100.           atk1 = item1 != nil ? item1.atk : 0
  101.           atk2 = @item != nil ? @item.atk : 0
  102.           change = atk2 - atk1
  103.         end
  104.         # If armor
  105.         if @item.is_a?(RPG::Armor)
  106.           pdef1 = item1 != nil ? item1.pdef : 0
  107.           mdef1 = item1 != nil ? item1.mdef : 0
  108.           pdef2 = @item != nil ? @item.pdef : 0
  109.           mdef2 = @item != nil ? @item.mdef : 0
  110.           change = pdef2 - pdef1 + mdef2 - mdef1
  111.         end
  112.         # Draw parameter change values
  113.         self.contents.draw_text(124, 64 + 64 * i, 112, 32,
  114.           sprintf("%+d", change), 2)
  115.       end
  116.       # Draw item
  117.       if item1 != nil
  118.         x = 4
  119.         y = 64 + 64 * i + 32
  120.         bitmap = RPG::Cache.icon(item1.icon_name)
  121.         opacity = self.contents.font.color == normal_color ? 255 : 128
  122.         self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  123.         self.contents.draw_text(x + 28, y, 212, 32, item1.name)
  124.       end
  125.     end
  126.   end
  127. end
RAW Paste Data