Kain Nobel
Member
Shop : Don't Sell Certain Goods
Version: 3.5
By: Kain Nobel
Introduction
This system allows you to specify certain goods to be unsellable in shops, either permanently or temporarily. Alternatively, you can specify that a shop isn't to sell certain good types such as not selling items, armors and/or weapons altogether.
Features
Screenshots
I'd post one but it probably wouldn't help...
Script
Instructions
Place Above Main, Below Scene_Debug (and Below SDK, only if using). Please see the FAQ as far as usage and how the system works.
FAQ
Compatibility
Credit & Thanks
Thanks to mining gast and Goody Two-Shoes for pointing out a bug I overlooked
Terms and Conditions
Another "Free to use in commercial and non-commercial games" script, so long as you credit yours truely!
Version: 3.5
By: Kain Nobel
Introduction
This system allows you to specify certain goods to be unsellable in shops, either permanently or temporarily. Alternatively, you can specify that a shop isn't to sell certain good types such as not selling items, armors and/or weapons altogether.
Features
- Items, armors and weapons can be dubbed permanently unsellable
- Items, armors and weapons can be dubbed temporarily unsellable
- Easily make shops that don't buy Item goods
- Easily make shops that don't buy Armor goods
- Easily make shops that don't buy Weapon goods
- Not to mention, easy to use =P
Screenshots
I'd post one but it probably wouldn't help...
Script
Code:
#===============================================================================
# ** Shop : Don't Sell Certain Goods
#===============================================================================
#-------------------------------------------------------------------------------
# * SDK Log
#-------------------------------------------------------------------------------
if Object.const_defined?(:SDK)
SDK.log('Shop.Don\'tSellCertainGoods', 'Kain Nobel ©', 3.5, '2009.06.17')
end
#===============================================================================
# ** Game_Temp
#===============================================================================
class Game_Temp
#-----------------------------------------------------------------------------
# * Place IDs of permanently unsellable Items here
#-----------------------------------------------------------------------------
Unsellable_Items = []
#-----------------------------------------------------------------------------
# * Place IDs of permanently unsellable Armors here
#-----------------------------------------------------------------------------
Unsellable_Armors = []
#-----------------------------------------------------------------------------
# * Place IDs of permanently unsellable Weapons here
#-----------------------------------------------------------------------------
Unsellable_Weapons = []
#-----------------------------------------------------------------------------
# * Public Instance Variables
#-----------------------------------------------------------------------------
attr_accessor :nosell_items # Array of IDs for unsellable items
attr_accessor :nosell_armors # Array of IDs for unsellable armors
attr_accessor :nosell_weapons # Array of IDs for unsellable weapons
attr_accessor :cant_sell_items # Flag meaning all Items are unsellable
attr_accessor :cant_sell_armors # Flag meaning all Armors are unsellable
attr_accessor :cant_sell_weapons # Flag meaning all Weapons are unsellable
attr_accessor :stored_nosell_i # Hash of prices for unsellable Items
attr_accessor :stored_nosell_a # Hash of prices for unsellable Armors
attr_accessor :stored_nosell_w # Hash of prices for unsellable Weapons
#-----------------------------------------------------------------------------
# * Alias Listings
#-----------------------------------------------------------------------------
alias_method :nosell_gmtemp_initialize, :initialize
#-----------------------------------------------------------------------------
# * Object Initialization
#-----------------------------------------------------------------------------
def initialize
nosell_gmtemp_initialize
reset_unsellables
end
#-----------------------------------------------------------------------------
# * Reset Unsellables
#-----------------------------------------------------------------------------
def reset_unsellables
@nosell_items = Unsellable_Items.dup
@nosell_armors = Unsellable_Armors.dup
@nosell_weapons = Unsellable_Weapons.dup
@cant_sell_items = false
@cant_sell_armors = false
@cant_sell_weapons = false
end
#-----------------------------------------------------------------------------
# * Reset Unsellable Inventory
#-----------------------------------------------------------------------------
def reset_unsellable_inventory(to_nil = false)
@stored_nosell_i = (to_nil ? nil : Hash.new)
@stored_nosell_a = (to_nil ? nil : Hash.new)
@stored_nosell_w = (to_nil ? nil : Hash.new)
end
end
#===============================================================================
# ** Game_Party
#===============================================================================
class Game_Party
#-----------------------------------------------------------------------------
# * Public Instance Variables
#-----------------------------------------------------------------------------
attr_reader :show_unsellables
#-----------------------------------------------------------------------------
# * Show Unsellables = (boolean)
#-----------------------------------------------------------------------------
def show_unsellables=(boolean)
@show_unsellables = (boolean == true)
case boolean
when true then reset_unsellables
when false then store_unsellables
end
end
#-----------------------------------------------------------------------------
# * Store Unsellables
#-----------------------------------------------------------------------------
def store_unsellables
$game_temp.stored_nosell_i = Hash.new
$game_temp.stored_nosell_a = Hash.new
$game_temp.stored_nosell_w = Hash.new
@items.each do |id, value|
unless $game_temp.cant_sell_items
next unless $game_temp.nosell_items.include?(id)
end
$game_temp.stored_nosell_i[id] = $data_items[id].price
$data_items[id].price = 0
end
@armors.each do |id, value|
unless $game_temp.cant_sell_armors
next unless $game_temp.nosell_armors.include?(id)
end
$game_temp.stored_nosell_a[id] = $data_armors[id].price
$data_armors[id].price = 0
end
@weapons.each do |id, value|
unless $game_temp.cant_sell_weapons
next unless $game_temp.nosell_weapons.include?(id)
end
$game_temp.stored_nosell_w[id] = $data_weapons[id].price
$data_weapons[id].price = 0
end
end
#-----------------------------------------------------------------------------
# * Reset Unsellables
#-----------------------------------------------------------------------------
def reset_unsellables(reset_temp = false, to_nil = false)
$game_temp.reset_unsellables if reset_temp
$game_temp.stored_nosell_i.each {|id, value| $data_items[id].price = value}
$game_temp.stored_nosell_a.each {|id, value| $data_armors[id].price = value}
$game_temp.stored_nosell_w.each {|id, value| $data_weapons[id].price = value}
$game_temp.reset_unsellable_inventory(to_nil)
end
end
#===============================================================================
# ** Interpreter
#===============================================================================
class Interpreter
#-----------------------------------------------------------------------------
# * Can't Sell Items
#-----------------------------------------------------------------------------
def cant_sell_items
$game_temp.cant_sell_items = true
end
#-----------------------------------------------------------------------------
# * Can't Sell Armors
#-----------------------------------------------------------------------------
def cant_sell_armors
$game_temp.cant_sell_armors = true
end
#-----------------------------------------------------------------------------
# * Can't Sell Weapons
#-----------------------------------------------------------------------------
def cant_sell_weapons
$game_temp.cant_sell_weapons = true
end
#-----------------------------------------------------------------------------
# * No Sell Items
#-----------------------------------------------------------------------------
def nsI(*item_ids)
item_ids.each do |id|
next if $game_temp.nosell_items.include?(id)
$game_temp.nosell_items << id
end
end
#-----------------------------------------------------------------------------
# * No Sell Armors
#-----------------------------------------------------------------------------
def nsA(*armor_ids)
armor_ids.each do |id|
next if $game_temp.nosell_armors.include?(id)
$game_temp.nosell_armors << id
end
end
#-----------------------------------------------------------------------------
# * No Sell Weapons
#-----------------------------------------------------------------------------
def nsW(*weapon_ids)
weapon_ids.each do |id|
next if $game_temp.nosell_weapons.include?(id)
$game_temp.nosell_weapons << id
end
end
end
#===============================================================================
# ** Scene_Shop
#===============================================================================
class Scene_Shop
#-----------------------------------------------------------------------------
# * Alias Listings
#-----------------------------------------------------------------------------
alias_method :nosell_snshop_main, :main
alias_method :nosell_snshop_updc, :update_command
#-----------------------------------------------------------------------------
# * Main
#-----------------------------------------------------------------------------
def main
$game_party.store_unsellables
nosell_snshop_main
$game_party.reset_unsellables(true, true)
end
<span style="color:#000080; font-style:italic;">=begin
<span style="color:#000080; font-style:italic;">
<span style="color:#000080; font-style:italic;"> # Use this version if you're using SDK, and your command order differs from
<span style="color:#000080; font-style:italic;"> # the standard "Buy", "Sell", "Exit" command order, instead of the other
<span style="color:#000080; font-style:italic;"> # update_command method. Otherwise the other method works for both SDK and non
<span style="color:#000080; font-style:italic;">
<span style="color:#000080; font-style:italic;"> #-----------------------------------------------------------------------------
<span style="color:#000080; font-style:italic;"> # * Update Command
<span style="color:#000080; font-style:italic;"> #-----------------------------------------------------------------------------
<span style="color:#000080; font-style:italic;"> def update_command
<span style="color:#000080; font-style:italic;"> case @command_window.command
<span style="color:#000080; font-style:italic;"> when SDK::Scene_Commands::Scene_Shop::Buy
<span style="color:#000080; font-style:italic;"> unless $game_party.show_unsellables
<span style="color:#000080; font-style:italic;"> $game_party.show_unsellables = true
<span style="color:#000080; font-style:italic;"> @buy_window.refresh
<span style="color:#000080; font-style:italic;"> end
<span style="color:#000080; font-style:italic;"> when SDK::Scene_Commands::Scene_Shop::Sell
<span style="color:#000080; font-style:italic;"> if $game_party.show_unsellables
<span style="color:#000080; font-style:italic;"> $game_party.show_unsellables = false
<span style="color:#000080; font-style:italic;"> @sell_window.refresh
<span style="color:#000080; font-style:italic;"> end
<span style="color:#000080; font-style:italic;"> end
<span style="color:#000080; font-style:italic;"> nosell_snshop_updc
<span style="color:#000080; font-style:italic;"> end
<span style="color:#000080; font-style:italic;">
<span style="color:#000080; font-style:italic;">=end
#-----------------------------------------------------------------------------
# * Update Command
#-----------------------------------------------------------------------------
def update_command
case @command_window.index
when 0
unless $game_party.show_unsellables
$game_party.show_unsellables = true
@buy_window.refresh
end
when 1
if $game_party.show_unsellables
$game_party.show_unsellables = false
@sell_window.refresh
end
end
nosell_snshop_updc
end
end
Instructions
Place Above Main, Below Scene_Debug (and Below SDK, only if using). Please see the FAQ as far as usage and how the system works.
FAQ
Permanently unsellable goods can be placed in the Unsellable_<type> constants within Game_Temp class. What you do is place the item, armor or weapons' IDs as specified in your database in the appropriate arrays. Please refer to the following Game_Temp constants, their headers explain it...
Unsellable_Items
Unsellable_Armors
Unsellable_Weapons
When you specify IDs in these constants, that means you'll never be able to sell those items and you won't have to call the ID when specifying the otherwise temporary unsellables.
Unsellable_Items
Unsellable_Armors
Unsellable_Weapons
When you specify IDs in these constants, that means you'll never be able to sell those items and you won't have to call the ID when specifying the otherwise temporary unsellables.
There are two ways to set temporarily unsellable goods, and their IDs are stacked along with the Permanent unsellable goods, so you don't have to specify the same IDs all the time. Anyways, to do it, you simply open up your Call Script box right before your shop is called and do...
You can also do this (but its not recommended for a Call Script box), please note its the same as doing what I showed you above...
Code:
# nsI : Stands for "No Sell Items"
nsI(1, 2, 3, 4, 5)
# nsA : Stands for "No Sell Armors"
nsA(1, 2, 3, 4, 5)
# nsW : Stands for "No Sell Weapons"
nsW(1, 2, 3, 4, 5)
You can also do this (but its not recommended for a Call Script box), please note its the same as doing what I showed you above...
Code:
$game_temp.nosell_items += [1, 2, 3, 4, 5]
$game_temp.nosell_armors += [1, 2, 3, 4, 5]
$game_temp.nosell_weapons += [1, 2, 3, 4, 5]
You don't want your Weapon shop to buy Items? You don't want your Armor shop to buy Weapons? Easy enough, one of the 3 following methods can be called and it'll make all Items, Armors and/or Weapons unsellable. All you have to do is put whatever appropriate method calls in the Call Script box before your shop is opened through the event...
cant_sell_items
cant_sell_armors
cant_sell_weapons
...and thats it!
cant_sell_items
cant_sell_armors
cant_sell_weapons
...and thats it!
In accordance to default shop system, you can't sell goods which have the price of 0. So, in the case that you're on the Sell window, prices of all unsellable goods are set to 0 which (by normal shop system standards) will dub the goods in question to be unsellable. However, when you revisit the Buy window, these prices will be set back to their *real* prices. Please read Compatibility notes...
Also, you never have to manually reset the temp or anything when your close your shop, because it is automatically reset when you exit the shop scene.
Also, you never have to manually reset the temp or anything when your close your shop, because it is automatically reset when you exit the shop scene.
Compatibility
This is SDK compatible but not required at all!! Most likely compatible with 99% of custom shop systems, so long as they still use the instances of @window_buy and @window_sell within the Scene_Shop scene.
Also important to note, I made it according to how the default shop system works; if an item has a price of 0, then it is dubbed 'unsellable'. If you're using a custom shop which allows you to sell items with 0 as their price, this script probably won't work with that particular system, I'll write a different version in this case if needed.
Compatible with the latest version of my Shop : Change Prices script. If you're using a version with a date older than "2009.09.01" (Sept 1, 2009), please replace the script with the latest version or you're likely to encounter pricing problems.
Also compatible with my Custom Shop System from my CMS, which I don't think has been posted publically yet since the current SDK version is too low.
Also important to note, I made it according to how the default shop system works; if an item has a price of 0, then it is dubbed 'unsellable'. If you're using a custom shop which allows you to sell items with 0 as their price, this script probably won't work with that particular system, I'll write a different version in this case if needed.
Compatible with the latest version of my Shop : Change Prices script. If you're using a version with a date older than "2009.09.01" (Sept 1, 2009), please replace the script with the latest version or you're likely to encounter pricing problems.
Also compatible with my Custom Shop System from my CMS, which I don't think has been posted publically yet since the current SDK version is too low.
Game_Temp.initialize
Scene_Shop.main
Scene_Shop.update_command
Scene_Shop.main
Scene_Shop.update_command
Credit & Thanks
Thanks to mining gast and Goody Two-Shoes for pointing out a bug I overlooked
Terms and Conditions
Another "Free to use in commercial and non-commercial games" script, so long as you credit yours truely!