Help - Search - Members - Calendar
Full Version: Shop Taxes VX
RPG RPG Revolution Forums > Scripting > Script Submissions > RGSS2-Submissions
Delyemerald2
Script Info
With this script you can add taxes to shops, or even add discounts. Depending on the item's price, you can make taxes or discounts everywhere. You can even create shops which will give you money when you buy an item if you overdo the discounts.

Features
Taxes (in percentage)
Discounts (in percentage)
Taxes (in amounts)
Discounts (in amounts)
Free items
Free items with money
Items (that are free normally) with a price

Screens
[Show/Hide] Normally

[Show/Hide] With Tax

[Show/Hide] With Discount

[Show/Hide] Overdid it a little =P


Script
[Show/Hide] Beta 2.5
CODE
#============================================================================
# Tax Script 2.5 (BETA)(VX)
#----------------------------------------------------------------------------
# Originally made by Falcon for RMXP (see further info at bottom of this part)
# Edited by Delyemerald2 to fit the RMVX
#----------------------------------------------------------------------------
# This system adds something to shop status, but in the same process, copies
# Everything normally there.
# With this script, you can add taxes or discounts.
# In order to do so, use the command Script in an event and enter this:
# (For Taxes)
# $game_system.tax.percent = x
# Where x is a value above 0 (will be counted in percentages)
# $game_system.tax.direct = y
# Where y is a value above 0 (this will be added to the base prices)
# (For Discounts)
# $game_system.tax.percent = x
# Where x is a value below 0 (will be counted in percentages)
# $game_system.tax.direct = y
# Where y is a value below 0 (this will be added to the base prices)
#----------------------------------------------------------------------------
# Credits to:
# Falcon for the original script
# Blizard for the idea that triggered version 2.0 (Falcon's Credits)
# You, becuase you eat a cookie in your life =D
#----------------------------------------------------------------------------
# ORIGINAL INFO (RMXP Version)
#----------------------------------------------------------------------------
# By Falcon
# Thanks to Blizzard for the idea that triggered version 2.0
#----------------------------------------------------------------------------
# This system should be compatible with all shop systems, but the
# Shop Status window will only show the tax/discount rate for the default
#============================================================================

# setup the variable that will hold the tax rate
class Game_System::Tax
   Direct_First = true
   attr_accessor :percent
   attr_accessor :direct
   def initialize
     @percent = 0
     @direct = 0
   end
end

  
class Game_System
   attr_reader :tax
   alias_method :delyemerald2_tax_init, :initialize
   def initialize
     delyemerald2_tax_init
     @tax = Tax.new
   end
end
  
# increase the price of the following items by the tax rate
class RPG::Item
   def price
     return Integer(@price + $game_system.tax.direct + @price * $game_system.tax.percent / 100)
   end
end

class RPG::Weapon
   def price
     return Integer(@price + $game_system.tax.direct + @price * $game_system.tax.percent / 100)
   end
end

class RPG::Armor
   def price
     return Integer(@price + $game_system.tax.direct + @price * $game_system.tax.percent / 100)
   end
end

class Window_ShopStatus < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     x : window X coordinate
  #     y : window Y coordinate
  #--------------------------------------------------------------------------
  def initialize(x, y)
    super(x, y, 240, 304)
    @item = nil
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    if @item != nil
      number = $game_party.item_number(@item)
      self.contents.font.color = system_color
      self.contents.draw_text(4, 0, 200, WLH, Vocab::Possession)
      self.contents.font.color = normal_color
      self.contents.draw_text(4, 0, 200, WLH, number, 2)
# Here you can customize what there will stand when there's a tax. You can also
# edit the heights of the words and numbers. One warning: Don't make it to long
# or it will overlap the percentages.
      if $game_system.tax.percent > 0 # If there is tax
       self.contents.draw_text(4, 16, 200, WLH, "Current Tax")
       self.contents.font.color = normal_color
       self.contents.draw_text(100, 16, 104, WLH, $game_system.tax.percent.to_s + "%", 2)
     elsif 0 > $game_system.tax.percent # If there is a discount rate
       self.contents.draw_text(4, 16, 200, WLH, "Discount")
       self.contents.font.color = normal_color
       self.contents.draw_text(100, 16, 104, WLH, $game_system.tax.percent.to_s + "%", 2)
     end
      if $game_system.tax.direct > 0 # If there is tax
       self.contents.draw_text(4, 32, 200, WLH, "Tax (A)")
       self.contents.font.color = normal_color
       self.contents.draw_text(100, 32, 104, WLH, $game_system.tax.direct.to_s , 2)
     elsif 0 > $game_system.tax.direct # If there is a discount rate
       self.contents.draw_text(4, 32, 200, WLH, "Discount (A)")
       self.contents.font.color = normal_color
       self.contents.draw_text(100, 32, 104, WLH, $game_system.tax.direct.to_s , 2)
     end
      for actor in $game_party.members
        x = 4
        y = WLH * (2 + actor.index * 2)
        draw_actor_parameter_change(actor, x, y)
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Actor's Current Equipment and Parameters
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #--------------------------------------------------------------------------
  def draw_actor_parameter_change(actor, x, y)
    return if @item.is_a?(RPG::Item)
    enabled = actor.equippable?(@item)
    self.contents.font.color = normal_color
    self.contents.font.color.alpha = enabled ? 255 : 128
    self.contents.draw_text(x, y, 200, WLH, actor.name)
    if @item.is_a?(RPG::Weapon)
      item1 = weaker_weapon(actor)
    elsif actor.two_swords_style and @item.kind == 0
      item1 = nil
    else
      item1 = actor.equips[1 + @item.kind]
    end
    if enabled
      if @item.is_a?(RPG::Weapon)
        atk1 = item1 == nil ? 0 : item1.atk
        atk2 = @item == nil ? 0 : @item.atk
        change = atk2 - atk1
      else
        def1 = item1 == nil ? 0 : item1.def
        def2 = @item == nil ? 0 : @item.def
        change = def2 - def1
      end
      self.contents.draw_text(x, y, 200, WLH, sprintf("%+d", change), 2)
    end
    draw_item_name(item1, x, y + WLH, enabled)
  end
  #--------------------------------------------------------------------------
  # * Get Weaker Weapon Equipped by the Actor (for dual wielding)
  #     actor : actor
  #--------------------------------------------------------------------------
  def weaker_weapon(actor)
    if actor.two_swords_style
      weapon1 = actor.weapons[0]
      weapon2 = actor.weapons[1]
      if weapon1 == nil or weapon2 == nil
        return nil
      elsif weapon1.atk < weapon2.atk
        return weapon1
      else
        return weapon2
      end
    else
      return actor.weapons[0]
    end
  end
  #--------------------------------------------------------------------------
  # * Set Item
  #     item : new item
  #--------------------------------------------------------------------------
  def item=(item)
    if @item != item
      @item = item
      refresh
    end
  end
end

CODE
#============================================================================
# Tax Script 2.0 (VX)
#----------------------------------------------------------------------------
# Originally made by Falcon for RMXP (see further info at bottom of this part)
# Edited by Delyemerald2 to fit the RMVX
#----------------------------------------------------------------------------
# This system adds something to shop status, but in the same process, copies
# Everything normally there.
# With this script, you can add taxes or discounts.
# In order to do so, use the command Script in an event and enter this:
# (For Taxes)
# $game_system.taxrate = x
# Where x is a value above 0 (will be counted in percentages)
# $game_system.taxamount = y
# Where y is a value above 0 (this will be added to the base prices)
# (For Discounts)
# $game_system.taxrate = x
# Where x is a value below 0 (will be counted in percentages)
# $game_system.taxamount = y
# Where y is a value below 0 (this will be added to the base prices)
#----------------------------------------------------------------------------
# Credits to:
# Falcon for the original script
# Blizard for the idea that triggered version 2.0 (Falcon's Credits)
# You, becuase you eat a cookie in your life =D
#----------------------------------------------------------------------------
# ORIGINAL INFO (RMXP Version)
#----------------------------------------------------------------------------
# By Falcon
# Thanks to Blizzard for the idea that triggered version 2.0
#----------------------------------------------------------------------------
# This system should be compatible with all shop systems, but the
# Shop Status window will only show the tax/discount rate for the default
#============================================================================

# setup the variable that will hold the tax rate
class Game_System
  attr_accessor :taxrate
  attr_accessor :taxamount
  alias declaration initialize
  def initialize
    declaration
    @taxrate = 0
    @taxammount = 0
  end
end

# increase the price of the following items by the tax rate
class RPG::Item
  def price
    return Integer(@price + $game_system.taxamount + @price * $game_system.taxrate / 100)
  end
end

class RPG::Weapon
  def price
    return Integer(@price + $game_system.taxamount + @price * $game_system.taxrate / 100)
  end
end

class RPG::Armor
  def price
    return Integer(@price + $game_system.taxamount + @price * $game_system.taxrate / 100)
  end
end

class Window_ShopStatus < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     x : window X coordinate
  #     y : window Y coordinate
  #--------------------------------------------------------------------------
  def initialize(x, y)
    super(x, y, 240, 304)
    @item = nil
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    if @item != nil
      number = $game_party.item_number(@item)
      self.contents.font.color = system_color
      self.contents.draw_text(4, 0, 200, WLH, Vocab::Possession)
      self.contents.font.color = normal_color
      self.contents.draw_text(4, 0, 200, WLH, number, 2)
# Here you can customize what there will stand when there's a tax. You can also
# edit the heights of the words and numbers. One warning: Don't make it to long
# or it will overlap the percentages.
      if $game_system.taxrate > 0 # If there is tax
       self.contents.draw_text(4, 16, 200, WLH, "Current Tax")
       self.contents.font.color = normal_color
       self.contents.draw_text(100, 16, 104, WLH, $game_system.taxrate.to_s + "%", 2)
     elsif 0 > $game_system.taxrate # If there is a discount rate
       self.contents.draw_text(4, 16, 200, WLH, "Discount")
       self.contents.font.color = normal_color
       self.contents.draw_text(100, 16, 104, WLH, $game_system.taxrate.to_s + "%", 2)
     end
      if $game_system.taxamount > 0 # If there is tax
       self.contents.draw_text(4, 32, 200, WLH, "Tax (A)")
       self.contents.font.color = normal_color
       self.contents.draw_text(100, 32, 104, WLH, $game_system.taxamount.to_s , 2)
     elsif 0 > $game_system.taxamount # If there is a discount rate
       self.contents.draw_text(4, 32, 200, WLH, "Discount (A)")
       self.contents.font.color = normal_color
       self.contents.draw_text(100, 32, 104, WLH, $game_system.taxamount.to_s , 2)
     end
      for actor in $game_party.members
        x = 4
        y = WLH * (2 + actor.index * 2)
        draw_actor_parameter_change(actor, x, y)
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Actor's Current Equipment and Parameters
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #--------------------------------------------------------------------------
  def draw_actor_parameter_change(actor, x, y)
    return if @item.is_a?(RPG::Item)
    enabled = actor.equippable?(@item)
    self.contents.font.color = normal_color
    self.contents.font.color.alpha = enabled ? 255 : 128
    self.contents.draw_text(x, y, 200, WLH, actor.name)
    if @item.is_a?(RPG::Weapon)
      item1 = weaker_weapon(actor)
    elsif actor.two_swords_style and @item.kind == 0
      item1 = nil
    else
      item1 = actor.equips[1 + @item.kind]
    end
    if enabled
      if @item.is_a?(RPG::Weapon)
        atk1 = item1 == nil ? 0 : item1.atk
        atk2 = @item == nil ? 0 : @item.atk
        change = atk2 - atk1
      else
        def1 = item1 == nil ? 0 : item1.def
        def2 = @item == nil ? 0 : @item.def
        change = def2 - def1
      end
      self.contents.draw_text(x, y, 200, WLH, sprintf("%+d", change), 2)
    end
    draw_item_name(item1, x, y + WLH, enabled)
  end
  #--------------------------------------------------------------------------
  # * Get Weaker Weapon Equipped by the Actor (for dual wielding)
  #     actor : actor
  #--------------------------------------------------------------------------
  def weaker_weapon(actor)
    if actor.two_swords_style
      weapon1 = actor.weapons[0]
      weapon2 = actor.weapons[1]
      if weapon1 == nil or weapon2 == nil
        return nil
      elsif weapon1.atk < weapon2.atk
        return weapon1
      else
        return weapon2
      end
    else
      return actor.weapons[0]
    end
  end
  #--------------------------------------------------------------------------
  # * Set Item
  #     item : new item
  #--------------------------------------------------------------------------
  def item=(item)
    if @item != item
      @item = item
      refresh
    end
  end
end


Instructions
Paste above main, underneath ALL standard shop scripts.
Depending on the version you use:
(v2.0)Use the command Script in an event and enter this:
(For Taxes)
$game_system.taxrate = x
Where x is a value above 0 (will be counted in percentages)
$game_system.taxamount = y
Where y is a value above 0 (this will be added to the base prices)
(For Discounts)
$game_system.taxrate = x
Where x is a value below 0 (will be counted in percentages)
$game_system.taxamount = y
Where y is a value below 0 (this will be added to the base prices)
(v2.5)Use the command Script in an event and enter this:
(For Taxes)
$game_system.tax.percent = x
Where x is a value above 0 (will be counted in percentages)
$game_system.tax.direct = y
Where y is a value above 0 (this will be added to the base prices)
(For Discounts)
$game_system.tax.percent = x
Where x is a value below 0 (will be counted in percentages)
$game_system.tax.direct= y
Where y is a value below 0 (this will be added to the base prices)

Coming
Nothing coming yet.

Credits
Falcon for the original RMXP version
Sephirothspawn for giving me a small modified part of the script as start of v2.5
Frousteleous
This is really ingenious. I've always hated that item prices couldnt vary from shop to shop, but this script allows you to do just that.

I havnt tried it out yet, but i definitely will later.

If I have any problems, ill let you know, though there shouldnt be any, seeing as this is a very foreward script.
benbarrett
Hey, this works great. Thanks for posting. This will definitely add a bit more realism to games, especially if tax rates fluctuate as time goes by or differ from area to area.

Great job! smile.gif

-Ben
Delyemerald2
Thanks for both your comments. I also I think I'll get this script finished today.
Delyemerald2
UPDATE
I've added version 2.0
This version adds:
Taxes based on amounts.
Discounts based on amounts.
The possibility to give a price to items which are normally free.

Also, please review the instructions. I made some mistakes in the older version.
Last, I will accept some request to update this script with the requested functions (not to hard please, just a beginner =P).
pultilian
I ran into this error

Script ‘Taxes’ line 51: TypeError occurred
Nil can’t be coerced into fixnum.
Delyemerald2
My bad.
I misspelled amount everytime, and thought I had fixed that. But I forgot one. Go back to the script, and at line 44, remove a M from the "@taxammount = 0"
pultilian
QUOTE (Delyemerald2 @ Feb 16 2010, 10:37 AM) *
My bad.
I misspelled amount everytime, and thought I had fixed that. But I forgot one. Go back to the script, and at line 44, remove a M from the "@taxammount = 0"


Sorry, but it is still not working.
Delyemerald2
Oke, then tell me these things:

Did it happened while starting up the game?
If yes, where did you paste the script exactly and do you have any other custom shop scripts (or add-ons, it can be a compatibility issue)?

If no, please give me the event where the error occured in. (what you typed)
pultilian
QUOTE (Delyemerald2 @ Feb 16 2010, 10:56 AM) *
Oke, then tell me these things:

Did it happened while starting up the game?
If yes, where did you paste the script exactly and do you have any other custom shop scripts (or add-ons, it can be a compatibility issue)?

If no, please give me the event where the error occured in. (what you typed)

It happened while talking (using action key) to an event with shop processing and the script command $game_system.taxamount = 10
Delyemerald2
Did you use those []'s in the script also? They don't belong there.
Else, first try replacing that script at top of the materials, or right beneath the Window_ShopStatus script.
If that doesn't work, tell me what scripts you use that are related with the shopsystem.
pultilian
I did not use the [ ] and I have no other scripts that have any thing to do with it except [mabye] Enix_FFGlass Window v1.0 by Speed@.
It sometimes works if you put a tax and discount in the same event.
Delyemerald2
Weird, that shouldn't happen...
I will try to make an other version of the script. Try that one. If it doesn't work, then I think it's because this script is not compatible with that menu script. And if that is the case, I'll try to make it compatible.

EDIT
Try this:

CODE
#============================================================================
# Tax Script 2.5 (BETA)(VX)
#----------------------------------------------------------------------------
# Originally made by Falcon for RMXP (see further info at bottom of this part)
# Edited by Delyemerald2 to fit the RMVX
#----------------------------------------------------------------------------
# This system adds something to shop status, but in the same process, copies
# Everything normally there.
# With this script, you can add taxes or discounts.
# In order to do so, use the command Script in an event and enter this:
# (For Taxes)
# $game_system.tax.percent = x
# Where x is a value above 0 (will be counted in percentages)
# $game_system.tax.direct = y
# Where y is a value above 0 (this will be added to the base prices)
# (For Discounts)
# $game_system.tax.percent = x
# Where x is a value below 0 (will be counted in percentages)
# $game_system.tax.direct = y
# Where y is a value below 0 (this will be added to the base prices)
#----------------------------------------------------------------------------
# Credits to:
# Falcon for the original script
# Blizard for the idea that triggered version 2.0 (Falcon's Credits)
# You, becuase you eat a cookie in your life =D
#----------------------------------------------------------------------------
# ORIGINAL INFO (RMXP Version)
#----------------------------------------------------------------------------
# By Falcon
# Thanks to Blizzard for the idea that triggered version 2.0
#----------------------------------------------------------------------------
# This system should be compatible with all shop systems, but the
# Shop Status window will only show the tax/discount rate for the default
#============================================================================

# setup the variable that will hold the tax rate
class Game_System::Tax
   Direct_First = true
   attr_accessor :percent
   attr_accessor :direct
   def initialize
     @percent = 0
     @direct = 0
   end
end

  
class Game_System
   attr_reader :tax
   alias_method :delyemerald2_tax_init, :initialize
   def initialize
     delyemerald2_tax_init
     @tax = Tax.new
   end
end
  
# increase the price of the following items by the tax rate
class RPG::Item
   def price
     return Integer(@price + $game_system.tax.direct + @price * $game_system.tax.percent / 100)
   end
end

class RPG::Weapon
   def price
     return Integer(@price + $game_system.tax.direct + @price * $game_system.tax.percent / 100)
   end
end

class RPG::Armor
   def price
     return Integer(@price + $game_system.tax.direct + @price * $game_system.tax.percent / 100)
   end
end

class Window_ShopStatus < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     x : window X coordinate
  #     y : window Y coordinate
  #--------------------------------------------------------------------------
  def initialize(x, y)
    super(x, y, 240, 304)
    @item = nil
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    if @item != nil
      number = $game_party.item_number(@item)
      self.contents.font.color = system_color
      self.contents.draw_text(4, 0, 200, WLH, Vocab::Possession)
      self.contents.font.color = normal_color
      self.contents.draw_text(4, 0, 200, WLH, number, 2)
# Here you can customize what there will stand when there's a tax. You can also
# edit the heights of the words and numbers. One warning: Don't make it to long
# or it will overlap the percentages.
      if $game_system.tax.percent > 0 # If there is tax
       self.contents.draw_text(4, 16, 200, WLH, "Current Tax")
       self.contents.font.color = normal_color
       self.contents.draw_text(100, 16, 104, WLH, $game_system.tax.percent.to_s + "%", 2)
     elsif 0 > $game_system.tax.percent # If there is a discount rate
       self.contents.draw_text(4, 16, 200, WLH, "Discount")
       self.contents.font.color = normal_color
       self.contents.draw_text(100, 16, 104, WLH, $game_system.tax.percent.to_s + "%", 2)
     end
      if $game_system.tax.direct > 0 # If there is tax
       self.contents.draw_text(4, 32, 200, WLH, "Tax (A)")
       self.contents.font.color = normal_color
       self.contents.draw_text(100, 32, 104, WLH, $game_system.tax.direct.to_s , 2)
     elsif 0 > $game_system.tax.direct # If there is a discount rate
       self.contents.draw_text(4, 32, 200, WLH, "Discount (A)")
       self.contents.font.color = normal_color
       self.contents.draw_text(100, 32, 104, WLH, $game_system.tax.direct.to_s , 2)
     end
      for actor in $game_party.members
        x = 4
        y = WLH * (2 + actor.index * 2)
        draw_actor_parameter_change(actor, x, y)
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Actor's Current Equipment and Parameters
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #--------------------------------------------------------------------------
  def draw_actor_parameter_change(actor, x, y)
    return if @item.is_a?(RPG::Item)
    enabled = actor.equippable?(@item)
    self.contents.font.color = normal_color
    self.contents.font.color.alpha = enabled ? 255 : 128
    self.contents.draw_text(x, y, 200, WLH, actor.name)
    if @item.is_a?(RPG::Weapon)
      item1 = weaker_weapon(actor)
    elsif actor.two_swords_style and @item.kind == 0
      item1 = nil
    else
      item1 = actor.equips[1 + @item.kind]
    end
    if enabled
      if @item.is_a?(RPG::Weapon)
        atk1 = item1 == nil ? 0 : item1.atk
        atk2 = @item == nil ? 0 : @item.atk
        change = atk2 - atk1
      else
        def1 = item1 == nil ? 0 : item1.def
        def2 = @item == nil ? 0 : @item.def
        change = def2 - def1
      end
      self.contents.draw_text(x, y, 200, WLH, sprintf("%+d", change), 2)
    end
    draw_item_name(item1, x, y + WLH, enabled)
  end
  #--------------------------------------------------------------------------
  # * Get Weaker Weapon Equipped by the Actor (for dual wielding)
  #     actor : actor
  #--------------------------------------------------------------------------
  def weaker_weapon(actor)
    if actor.two_swords_style
      weapon1 = actor.weapons[0]
      weapon2 = actor.weapons[1]
      if weapon1 == nil or weapon2 == nil
        return nil
      elsif weapon1.atk < weapon2.atk
        return weapon1
      else
        return weapon2
      end
    else
      return actor.weapons[0]
    end
  end
  #--------------------------------------------------------------------------
  # * Set Item
  #     item : new item
  #--------------------------------------------------------------------------
  def item=(item)
    if @item != item
      @item = item
      refresh
    end
  end
end


Follow the new instructions, new commands are used.
pultilian
Thanks, works great now. By the way great script.
Delyemerald2
Thanks, and congratz wink.gif
Unclellama
Thanks for this, it's just what I needed and works perfectly for me! I am using it as a 'negotiation' skill, where leveling the skill up decreases the tax in 5% increments - just in case anybody wanted a bit of inspiration.
PlainWalker
I just used this script an I overall enjoy using it thanks for making it laugh.gif
DementedCashew
I feel like licking the script... oh this is going to be so good iluvff.gif
Mitsarugi
why the hell when i click on the "With Taxes" spoiler i see a photo of you and your Girlfriend?????
Supershadowmartin
QUOTE (Mitsarugi @ Aug 22 2011, 02:24 AM) *
why the hell when i click on the "With Taxes" spoiler i see a photo of you and your Girlfriend?????


I was thinking that too.
Adrien.
your second image........um....dont think thats what happens WITH taxes
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.