This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.
Well, I was bored as hell, and thought why not just do something for RMXP for once in a long time, and I came up
with this. It doesn't use any fancy coding or whatever, and any beginning scripter can see right through it, so
without further trouble, I present to you; Shop Statistics!
All the information is in the first block of comments, so read that before you ask questions.
def add_item(id, amount, kind)
case kind
when 0
if @bought_items[$data_items[id].name] != nil
@bought_items[$data_items[id].name] += amount
else
@bought_items[$data_items[id].name] = amount
end
when 1
if @sold_items[$data_items[id].name] != nil
@sold_items[$data_items[id].name] += amount
else
@sold_items[$data_items[id].name] = amount
end
end
end
def add_weapon(id, amount, kind)
case kind
when 0
if @bought_weapons[$data_weapons[id].name] != nil
@bought_weapons[$data_weapons[id].name] += amount
else
@bought_weapons[$data_weapons[id].name] = amount
end
when 1
if @sold_weapons[$data_weapons[id].name] != nil
@sold_weapons[$data_weapons[id].name] += amount
else
@sold_weapons[$data_weapons[id].name] = amount
end
end
end
def add_armor(id, amount, kind)
case kind
when 0
if @bought_armors[$data_armors[id].name] != nil
@bought_armors[$data_armors[id].name] += amount
else
@bought_armors[$data_armors[id].name] = amount
end
when 1
if @sold_armors[$data_armors[id].name] != nil
@sold_armors[$data_armors[id].name] += amount
else
@sold_armors[$data_armors[id].name] = amount
end
end
end
def unique_everything(kind)
case kind
when 0
return @bought_items.size + @bought_weapons.size + @bought_armors.size
when 1
return @sold_items.size + @sold_weapons.size + @sold_armors.size
end
end
def unique_items(kind)
case kind
when 0
return @bought_items.size
when 1
return @sold_items.size
end
end
def unique_weapons(kind)
case kind
when 0
return @bought_weapons.size
when 1
return @sold_weapons.size
end
end
def unique_armors(kind)
case kind
when 0
return @bought_armors.size
when 1
return @sold_armors.size
end
end
def all_everything(kind)
@tmp = 0
case kind
when 0
for id in 1...$data_items.size
if @bought_items[$data_items[id].name] != nil
@tmp += @bought_items[$data_items[id].name]
end
end
for id in 1...$data_weapons.size
if @bought_weapons[$data_weapons[id].name] != nil
@tmp += @bought_weapons[$data_weapons[id].name]
end
end
for id in 1...$data_armors.size
if @bought_armors[$data_armors[id].name] != nil
@tmp += @bought_armors[$data_armors[id].name]
end
end
when 1
for id in 1...$data_items.size
if @sold_items[$data_items[id].name] != nil
@tmp += @sold_items[$data_items[id].name]
end
end
for id in 1...$data_weapons.size
if @sold_weapons[$data_weapons[id].name] != nil
@tmp += @sold_weapons[$data_weapons[id].name]
end
end
for id in 1...$data_armors.size
if @sold_armors[$data_armors[id].name] != nil
@tmp += @sold_armors[$data_armors[id].name]
end
end
end
return @tmp
end
def all_items(kind)
@tmp = 0
case kind
when 0
for id in 1...$data_items.size
if @bought_items[$data_items[id].name] != nil
@tmp += @bought_items[$data_items[id].name]
end
end
when 1
for id in 1...$data_items.size
if @sold_items[$data_items[id].name] != nil
@tmp += @sold_items[$data_items[id].name]
end
end
end
return @tmp
end
def all_weapons(kind)
@tmp = 0
case kind
when 0
for id in 1...$data_weapons.size
if @bought_weapons[$data_weapons[id].name] != nil
@tmp += @bought_weapons[$data_weapons[id].name]
end
end
when 1
for id in 1...$data_weapons.size
if @sold_weapons[$data_weapons[id].name] != nil
@tmp += @sold_weapons[$data_weapons[id].name]
end
end
end
return @tmp
end
def all_armors(kind)
@tmp = 0
case kind
when 0
for id in 1...$data_armors.size
if @bought_armors[$data_armors[id].name] != nil
@tmp += @bought_armors[$data_armors[id].name]
end
end
when 1
for id in 1...$data_armors.size
if @sold_armors[$data_armors[id].name] != nil
@tmp += @sold_armors[$data_armors[id].name]
end
end
end
return @tmp
end
end
# The below chunk of code is just Scene_Shop taken from the default
# scripts and modified using alias methods. If your script modifies any
# of the below, I'm not going to fix this for you. Tough luck!
class Scene_Shop
alias gs_shopnumber_number update_number
alias gs_shopmain_main main
alias gs_shopcommand_update update_command
def main
if $shopstats == nil
$shopstats = Shop_Stats.new
end
$shopstats.shop_visits += 1
gs_shopmain_main
end
def update_command
if $shopstats == nil
$shopstats = Shop_Stats.new
end
gs_shopcommand_update
if Input.trigger?(Input::C)
case @command_window.index
when 0 # buy
$shopstats.buy += 1
when 1 # sell
$shopstats.sell += 1
end
return
end
end
def update_number
gs_shopnumber_number
if Input.trigger?(Input::C)
$game_system.se_play($data_system.shop_se)
case @command_window.index
when 0
$shopstats.money_spent += @number_window.number * @item.price
case @item
when RPG::Item
$shopstats.add_item(@item.id, @number_window.number, 0)
when RPG::Weapon
$shopstats.add_weapon(@item.id, @number_window.number, 0)
when RPG::Armor
$shopstats.add_armor(@item.id, @number_window.number, 0)
end
when 1
$shopstats.money_made += @number_window.number * (@item.price / 2)
case @item
when RPG::Item
$shopstats.add_item(@item.id, @number_window.number, 1)
when RPG::Weapon
$shopstats.add_weapon(@item.id, @number_window.number, 1)
when RPG::Armor
$shopstats.add_armor(@item.id, @number_window.number, 1)
end
end
return
end
end
end
class Window_ShopStats < Window_Base
def initialize
super(0, 0, 640, 480)
self.contents = Bitmap.new(width - 32, height - 32)
if $shopstats == nil
$shopstats = Shop_Stats.new
end
refresh
end
def main
@shopstats_window = Window_ShopStats.new
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@shopstats_window.dispose
end
def update
@shopstats_window.update
if Input.trigger?(Input::B) # Cancel button returns to Map
$scene = Scene_Map.new
end
end
end
# FINAL UPDATE: 29 June 2007 @ 23:10 CET
Screenshot
I haven't found any bugs during my own betatests, but if you find one, feel free to message me so I can fix
them asap.
For questions about this script, you can post here and I'll try to answer them.
Enjoy
PS: You are free to edit this script of it's content, regarding the use of words in specific.