Hi all,
Night_Runner's Tax Script
Version 1.0
Author Night_Runner
Release Date 4th April 2012
Exclusive Script at RPG RPG RevolutionIntroduction Based off the version by The Falcon, this script allows developers the ability to dynamically set the tax at each shop by an evented command.
Features - Optional: Show the tax in the shop's status window
- Dynamically change the tax for each shop
* Note: This can also be used for a good/evil system to set the tax to reflect the relationship with the shop owner - Different tax for buying and selling
Script CODE
#==============================================================================
# ** XP: Night_Runner's 'Tax' Script.
#------------------------------------------------------------------------------
# History:
# Date Created: 4/Apr/2012
# Created for: Nub Cake
# @> http://www.rpgrevolution.com/forums/index.php?showtopic=56063
#
# Description:
# This script allows a basic tax system, where you can specify the tax on
# items sold or bought in shops.
#
# How to Install:
# Copy this entire script. In your game editor select Tools >> Script Editor.
# Along the left, scroll down to the bottom, right click on 'Main', and
# select 'Insert'. Paste the code on the right.
#
# How to Use:
# Before you open the shop have the shop event run the script
# (Evented Commands > Page 3 > Bottom Right)
# $game_system.buy_tax = 10
# $game_system.sell_tax = 50
# and this script will make the cost of goods bought cost an extra 10% of what
# they usually cost, and will make goods sell for an extra 50% of what they
# usually cost when you sell them.
#==============================================================================
#==============================================================================
# ** Customisation
#==============================================================================
module NR_Tax
# Default Sell Tax
# Value: Integer
# Description: Defaults to 0% tax at the start of a new game
Default_Sell_Tax = 0
# Default Buy Tax
# Value: Integer
# Description: Defaults to 0% tax at the start of a new game
Default_Buy_Tax = 0
# Show In Buy Status Window
# Value: true / false
# Description: whether or not to show the tax in the status window
Show_In_Buy_Status_Window = true
# Show In Sell Status Window
# Value: true / false
# Description: whether or not to show the tax in the status window
Show_In_Sell_Status_Window = true
# Text In Status Window
# Value: String
# Description: The text to show next to the tax percent in the status window
Text_In_Status_Window = 'Current Tax Rate'
end
#==============================================================================
# ** Game_System
#------------------------------------------------------------------------------
# Edited to have buyers and sellers tax.
#==============================================================================
class Game_System
#--------------------------------------------------------------------------
# * Alias Mehtods
#--------------------------------------------------------------------------
alias nr_tax_initialize initialize unless $@
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :sell_tax
attr_accessor :buy_tax
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(*args)
# Set the default values for the tax
@sell_tax = NR_Tax::Default_Sell_Tax.to_i
@buy_tax = NR_Tax::Default_Buy_Tax.to_i
# Run the original intialize
return nr_tax_initialize
end
end
#==============================================================================
# ** Window_ShopSell
#------------------------------------------------------------------------------
# Edited to show the tax affected item costs.
#==============================================================================
class Window_ShopSell
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
for i in 1...$data_items.size
if $game_party.item_number(i) > 0
@data.push($data_items[i])
end
end
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0
@data.push($data_weapons[i])
end
end
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0
@data.push($data_armors[i])
end
end
# If item count is not 0, make a bitmap and draw all items
@item_max = @data.size
if @item_max > 0
# Apply the tax
for i in 0...@data.size
item = @data[i].clone
item.price = (item.price * (100 + $game_system.sell_tax) + 50) / 100
@data[i] = item
end
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max
draw_item(i)
end
end
end
end
#==============================================================================
# ** Window_ShopBuy
#------------------------------------------------------------------------------
# Edited to show the tax affected item costs.
#==============================================================================
class Window_ShopBuy
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
for goods_item in @shop_goods
case goods_item[0]
when 0
item = $data_items[goods_item[1]]
when 1
item = $data_weapons[goods_item[1]]
when 2
item = $data_armors[goods_item[1]]
end
if item != nil
@data.push(item)
end
end
# If item count is not 0, make a bit map and draw all items
@item_max = @data.size
if @item_max > 0
# Apply the tax
for i in 0...@data.size
item = @data[i].clone
item.price = (item.price * (100 + $game_system.buy_tax) + 50) / 100
@data[i] = item
end
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max
draw_item(i)
end
end
end
end
#==============================================================================
# ** Window_ShopStatus
#------------------------------------------------------------------------------
# This window displays number of items in possession and the actor's equipment
# on the shop screen.
#==============================================================================
class Window_ShopStatus
#--------------------------------------------------------------------------
# * Alias Methods
#--------------------------------------------------------------------------
alias nr_tax_refresh refresh unless $@
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :buy_sell
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh(*args)
# Run the original refresh
nr_tax_refresh(*args)
# Skip if appropriate
return if @item == nil
if @buy_sell
return if not NR_Tax::Show_In_Sell_Status_Window
else
return if not NR_Tax::Show_In_Buy_Status_Window
end
# Draw the title information
self.contents.font.color = system_color
self.contents.draw_text(4, 32, 200, 32, NR_Tax::Text_In_Status_Window.to_s)
# Draw the tax depending whether the playe is buying or selling goods.
self.contents.font.color = normal_color
if @buy_sell == :sell
tax = $game_system.sell_tax
else
tax = $game_system.buy_tax
end
self.contents.draw_text(0,32,contents.width,32,"#{tax}%",2)
end
end
#==============================================================================
# ** Window_ShopStatus
#------------------------------------------------------------------------------
# This window displays number of items in possession and the actor's equipment
# on the shop screen.
#==============================================================================
class Scene_Shop
#--------------------------------------------------------------------------
# * Alias Methods
#--------------------------------------------------------------------------
alias nr_tax_update update unless $@
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update(*args)
# Run the original refresh
nr_tax_update(*args)
# Set the status window to show the appropriate tax depending on whether
# or not the sell window is active.
@status_window.buy_sell = @sell_window.active ? :sell : :buy
end
end
#==============================================================================
# ** End of Script.
#==============================================================================
CustomizationSee lines 35 - 50 of the script for customising.
Compatibility This script completely overwrites what's drawn on the Window_ShopBuy and Window_ShopSell (as opposed to the Window_ShopStatus, where it merely adds it's text to draw), so if you have another script which overwrites how Window_ShopBuy and Window_ShopSell look then this will not be compatible.
The script was designed this way to reduce lag, and can be adapted to work without overwriting Window_ShopBuy and Window_ShopSell if it were requested.
Screenshot 

DEMO N/A
Installation Copy this entire script. In your game editor select Tools >> Script Editor.
Along the left, scroll down to the bottom, right click on 'Main', and select 'Insert'. Paste the code on the right.
FAQAsk away.
Terms, Conditions and Credits Use as you see fit, you don't need to credit me if you don't want to (that doesn't in any way imply that you can credit someone else for my script, merely that you don't have to credit me).
I credit The Falcon for the screenshots for his original tax system concept, and Nub Cake for requesting this script.