06-29-2007, 01:00 PM
Shop Statistics
by Goldenshadow
ver 1
Jun 29 2007
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.
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.
by Goldenshadow
ver 1
Jun 29 2007
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.
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.
Script
Code:
#===============================================================================
# <> Shop Statistics Page, Ver 1.0
# ==> You can delete all the comments except the copyright and creator info.
# ==> Do not rip, repost or any other way of reproducing without proper credit.
# ShadowClan Technologies © 2007
#-------------------------------------------------------------------------------
# * WHAT IS IT?
# It keeps track of several things around the buying/selling functions.
# Like that # it keeps track of which items you have sold/bought,
# and how many of them, it even # keeps track of how many money you have
# spend, or gained... Sounds good, huh?
#
# * HOW IT WORKS
# You don't have to do anything. It does this by itself each time you do
# anything with the stores. To call up the screen to show all the info's,
# just type in, for example, Call Script command,
#
# = Scene_ShopStats.new
#
# And that'll show you a screen full of stuff. :D
# For those scripters; you can use this, too, obviously.
#
# * HOW TO SHOW INFO ON YOUR OWN WINDOWS
# Fairly easy, you may use the following commands.
#
# The below commands can only be used in the following manner:
# .xxx
# where 'xxx' is one of the commands below:
# Note: where 'kind', it can be either 0 or 1. Buying/Selling respectively.
#
# shopvisits // returns amount of visits to any shop
# buy // shows how many times buying took place
# sell // shows how many times selling took place
# add_xxx(id, amount, kind) // xxx : item, weapon or armor
# unique_xxx(kind) // xxx : items, weapons or armors
# unique_everything(kind) // altogether uniqe
# all_xxx(kind) // xxx : items, weapons or armors
# all_everything(kind) // altogether all
#
# That would be all for now.
#-------------------------------------------------------------------------------
# * Suggestions? ==> PM or email me. (kayashu@hotmail.co.jp)
# * Created by: GoldenShadow
#===============================================================================
class Shop_Stats
attr_accessor :bought_items
attr_accessor :bought_weapons
attr_accessor :bought_armors
attr_accessor :sold_items
attr_accessor :sold_weapons
attr_accessor :sold_armors
attr_accessor :money_made
attr_accessor :money_spent
attr_accessor :shop_visits
attr_accessor :buy
attr_accessor :sell
def initialize
@bought_items = {}
@bought_weapons = {}
@bought_armors = {}
@sold_items = {}
@sold_weapons = {}
@sold_armors = {}
@money_made = 0
@money_spent = 0
@shop_visits = 0
@buy = 0
@sell = 0
end
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 refresh
self.contents.clear
self.contents.font.color = knockout_color
self.contents.draw_text(300, 0, self.width-32, 32, "SHOP STATISTICS")
self.contents.font.color = system_color
self.contents.draw_text(4, 0, self.width-32, 32, "Shop visits")
self.contents.draw_text(4, 32, self.width-32, 32, "Selling actions")
self.contents.draw_text(300, 32, self.width-32, 32, "Buying actions")
self.contents.draw_text(4, 64, self.width-32, 32, "Money made")
self.contents.draw_text(300, 64, self.width-32, 32, "Money spent")
rect = Rect.new(0, 110, self.width, 2)
self.contents.fill_rect(rect, Color.new(255, 255, 255))
self.contents.draw_text(4, 128, self.width-32, 32, "Unique items sold")
self.contents.draw_text(300, 128, self.width-32, 32, "Unique items bought")
self.contents.draw_text(4, 160, self.width-32, 32, "Unique weapons sold")
self.contents.draw_text(300, 160, self.width-32, 32, "Unique weapons bought")
self.contents.draw_text(4, 192, self.width-32, 32, "Unique armors sold")
self.contents.draw_text(300, 192, self.width-32, 32, "Unique armors bought")
self.contents.draw_text(4, 224, self.width-32, 32, "Unique total sold")
self.contents.draw_text(300, 224, self.width-32, 32, "Unique total bought")
rect = Rect.new(0, 269, self.width, 2)
self.contents.fill_rect(rect, Color.new(255, 255, 255))
self.contents.draw_text(4, 288, self.width-32, 32, "Total items sold")
self.contents.draw_text(300, 288, self.width-32, 32, "Total items bought")
self.contents.draw_text(4, 320, self.width-32, 32, "Total weapons sold")
self.contents.draw_text(300, 320, self.width-32, 32, "Total weapons bought")
self.contents.draw_text(4, 352, self.width-32, 32, "Total armors sold")
self.contents.draw_text(300, 352, self.width-32, 32, "Total armors bought")
rect = Rect.new(0, 398, self.width, 2)
self.contents.fill_rect(rect, Color.new(255, 255, 255))
self.contents.draw_text(4, 416, self.width-32, 32, "Total sold")
self.contents.draw_text(300, 416, self.width-32, 32, "Total bought")
# First block - General information
self.contents.font.color = normal_color
self.contents.draw_text(200, 0, self.width-32, 32, $shopstats.shop_visits.to_s)
self.contents.draw_text(200, 32, self.width-32, 32, $shopstats.sell.to_s)
self.contents.draw_text(530, 32, self.width-32, 32, $shopstats.buy.to_s)
self.contents.draw_text(200, 64, self.width-32, 32, $shopstats.money_made.to_s)
self.contents.draw_text(530, 64, self.width-32, 32, $shopstats.money_spent.to_s)
# Second block, unique information
self.contents.draw_text(200, 128, self.width-32, 32, $shopstats.unique_items(1).to_s)
self.contents.draw_text(530, 128, self.width-32, 32, $shopstats.unique_items(0).to_s)
self.contents.draw_text(200, 160, self.width-32, 32, $shopstats.unique_weapons(1).to_s)
self.contents.draw_text(530, 160, self.width-32, 32, $shopstats.unique_weapons(0).to_s)
self.contents.draw_text(200, 192, self.width-32, 32, $shopstats.unique_armors(1).to_s)
self.contents.draw_text(530, 192, self.width-32, 32, $shopstats.unique_armors(0).to_s)
self.contents.draw_text(200, 224, self.width-32, 32, $shopstats.unique_everything(1).to_s)
self.contents.draw_text(530, 224, self.width-32, 32, $shopstats.unique_everything(0).to_s)
# Third block, non-unique information
self.contents.draw_text(200, 288, self.width-32, 32, $shopstats.all_items(1).to_s)
self.contents.draw_text(530, 288, self.width-32, 32, $shopstats.all_items(0).to_s)
self.contents.draw_text(200, 320, self.width-32, 32, $shopstats.all_weapons(1).to_s)
self.contents.draw_text(530, 320, self.width-32, 32, $shopstats.all_weapons(0).to_s)
self.contents.draw_text(200, 352, self.width-32, 32, $shopstats.all_armors(1).to_s)
self.contents.draw_text(530, 352, self.width-32, 32, $shopstats.all_armors(0).to_s)
# Fourth block, total information
self.contents.draw_text(200, 416, self.width-32, 32, $shopstats.all_everything(1).to_s)
self.contents.draw_text(530, 416, self.width-32, 32, $shopstats.all_everything(0).to_s)
end
end
class Scene_ShopStats
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.