#===============================================================================
# FLIPELYFLIP CREATIONS
#-------------------------------------------------------------------------------
#
# Extended Shop Prices v1.0
# by FlipelyFlip
#
#-------------------------------------------------------------------------------
# What does this script do?
# -------------------------
# This script allows you to define automaticly while the game is running.
# It dyes the name in the defined colors if it's more expensive or cheaper
# than the standard price.
#
# How to use?
# -----------
# The script itself is plug and play. To use it without any problems,
# define with the first item in the shop selection the ID of the shop.
# This is done through the "Specify"-option. This is used to prevent
# from pushing the standard price down by entering multiple times the
# same shop.
#
# Terms of Use?
# -------------
# If you use this script for your non-commercial project then only credits
# needed to give to me. FlipelyFlip is my name.
# If you want to use this script in your commercial project then please write
# me an mail to flipely@hotmail.com or write me a pm.
#===============================================================================
#===============================================================================
# ** Module Flip
#-------------------------------------------------------------------------------
# * Used to define needed variables and includes the main method for the script
#===============================================================================
module Flip
# COUNTER is used to set the countdown for the price, when it will turn to the
# standard-price. The counter will count every time one step down, if the
# item ID and price match. Else it would add it to the hash.
COUNTER = 5
# EXPENSIVE_COLOR is used to set the color for the items which are more
# expensive then the standard-price.
# Color.new(r,g,b)
EXPENSIVE_COLOR = Color.new(255,100,100)
# CHEAPER_COLOR is the same like EXPENSIVE_COLOR but it will be aplied when
# the item is cheaper than the standard-price
# Color.new(r,g,b)
CHEAPER_COLOR = Color.new(100,255,100)
# USE_LOW_RANGE: if true then it will use a different color if the prices are
# in a certain range. if false then it only will aply the colors defined above
USE_LOW_RANGE = true
# EXPENSIVE_RANGE is the range to whom the EXPENSIVE_MID_RANGE_COLOR will be
# aplied.
EXPENSIVE_RANGE = 20 # value is given as per cent
# CHEAPER_RANGE is the range to whom the CHEAPER_MID_RANGE_COLOR will be
# aplied.
CHEAPER_RANGE = 20 # value is given as per cent
# EXPENSIVE_LOW_RANGE is the range to whom the EXPENSIVE_LOW_RANGE_COLOR will
# be aplied.
EXPENSIVE_LOW_RANGE = 10 # value is given as per cent
# CHEAPER_LOW_RANGE is the range to whom the CHEAPER_LOW_RANGE_COLOR will
# be aplied.
CHEAPER_LOW_RANGE = 10 # value is given as per cent
# EXPENSIVE_MID_RANGE_COLOR is used to set the color to the defined amount if
# the price is between EXPENSIVE_LOW_RANGE and EXPENSIVE_MID_RANGE.
# Color.new(r,g,b)
EXPENSIVE_MID_RANGE_COLOR = Color.new(255,160,160)
# CHEAPER_MID_RANGE_COLOR is used to set the color to the defined amount if
# the price is between CHEAPER_LOW_RANGE and CHEAPER_MID_RANGE.
# Color.new(r,g,b)
CHEAPER_MID_RANGE_COLOR = Color.new(180,255,180)
# EXPENSIVE_LOW_RANGE_COLOR is used to set the color to the defined amount if
# the price is in the EXPENSIVE_LOW_RANGE.
# Color.new(r,g,b)
EXPENSIVE_LOW_RANGE_COLOR = Color.new(255,220,220)
# CHEAPER_LOW_RANGE_COLOR is used to set the color to the defined amount if
# the price is in the CHEAPER_LOW_RANGE.
# Color.new(r,g,b)
CHEAPER_LOW_RANGE_COLOR = Color.new(220,255,220)
################################################################################
# #
# ONLY EDIT BELOW THIS LINE IF YOU KNOW WHAT ARE YOU DOING!! #
# #
################################################################################
ITEM_COSTS = {} # do not edit
ARMOR_COSTS = {} # do not edit
WEAPON_COSTS = {} # do not edit
ITEM_STANDARD_COST = {} # do not edit
ARMOR_STANDARD_COST = {} # do not edit
WEAPON_STANDARD_COST = {} # do not edit
#-----------------------------------------------------------------------------
# * Pass the costs Away
# goodies = shop goods
#-----------------------
# This is used to get the standard-price and count down the counter for the
# new prices.
#-----------------------------------------------------------------------------
def self.pass_the_costs_away(goodies)
$new_shop_id = goodies[0][3]
goodies.delete_at(0)
if $old_shop_id != $new_shop_id
for goods in goodies
case goods[0]
when 0 # Item
item = $data_items[goods[1]]
price = goods[3]
price = item.price if goods[2] == 0
if !ITEM_STANDARD_COST.include?(item.id)
ITEM_STANDARD_COST[item.id] = price
else
if price != ITEM_STANDARD_COST[item.id]
if ITEM_COSTS.include?([item.id,price])
ITEM_COSTS[[item.id,price]] -= 1
if ITEM_COSTS[[item.id,price]] <= 0
ITEM_STANDARD_COST[item.id] = price
ITEM_COSTS[[item.id,price]] = COUNTER
ITEM_COSTS.each_key { |item_id|
if item_id[0] == item.id
ITEM_COSTS[item_id] = COUNTER
end
}
end
else
ITEM_COSTS[[item.id,price]] = COUNTER
end
end
end
when 1 # Weapon
item = $data_weapons[goods[1]]
price = goods[3]
price = item.price if goods[2] == 0
if !WEAPON_STANDARD_COST.include?(item.id)
WEAPON_STANDARD_COST[item.id] = price
else
if price != WEAPON_STANDARD_COST[item.id]
if WEAPON_COSTS.include?([item.id,price])
WEAPON_COSTS[[item.id,price]] -= 1
if WEAPON_COSTS[[item.id,price]] <= 0
WEAPON_STANDARD_COST[item.id] = price
WEAPON_COSTS[[item.id,price]] = COUNTER
WEAPON_COSTS.each_key { |item_id|
if item_id[0] == item.id
WEAPON_COSTS[item_id] = COUNTER
end
}
end
else
WEAPON_COSTS[[item.id,price]] = COUNTER
end
end
end
when 2 # Armor
item = $data_armors[goods[1]]
price = goods[3]
price = item.price if goods[2] == 0
if !ARMOR_STANDARD_COST.include?(item.id)
ARMOR_STANDARD_COST[item.id] = price
else
if price != ARMOR_STANDARD_COST[item.id]
if ARMOR_COSTS.include?([item.id,price])
ARMOR_COSTS[[item.id,price]] -= 1
if ARMOR_COSTS[[item.id,price]] <= 0
ARMOR_STANDARD_COST[item.id] = price
ARMOR_COSTS[[item.id,price]] = COUNTER
ARMOR_COSTS.each_key { |item_id|
if item_id[0] == item.id
ARMOR_COSTS[item_id] = COUNTER
end
}
end
else
ARMOR_COSTS[[item.id,price]] = COUNTER
end
end
end
end
end
$old_shop_id = $new_shop_id
end
end
#--------------------------------------------------------------------------
# * Create Filename
# index : File Index
#--------------------------------------------------------------------------
def self.filename(index)
sprintf("Data/Shop_Prices%02d.rvdata2", index + 1)
end
def self.do_save(index)
ary = []
ary = [ITEM_COSTS,WEAPON_COSTS,ARMOR_COSTS,ITEM_STANDARD_COST,
WEAPON_STANDARD_COST,ARMOR_STANDARD_COST,$old_shop_id]
File.open(filename(index), "wb") { |file|
Marshal.dump(ary,file)
}
end
def self.do_load(index)
File.open(filename(index), "rb") { |file|
stuff = Marshal.load(file)
const_set(ITEM_COSTS,stuff[0])
const_set(WEAPON_COSTS,stuff[1])
const_set(ARMOR_COSTS,stuff[2])
const_set(ITEM_STANDARD_COST,stuff[3])
const_set(WEAPON_STANDARD_COST,stuff[4])
const_set(ARMOR_STANDARD_COST,stuff[5])
$old_shop_id = stuff[6]
}
end
end
#==============================================================================
# ** Scene_Save
#------------------------------------------------------------------------------
# This class performs save screen processing.
#==============================================================================
class Scene_Save < Scene_File
#--------------------------------------------------------------------------
# * Confirm Save File
#--------------------------------------------------------------------------
def on_savefile_ok
super
if DataManager.save_game(@index)
on_save_success
Flip.do_save(@index)
else
Sound.play_buzzer
end
end
end
#==============================================================================
# ** Scene_Load
#------------------------------------------------------------------------------
# This class performs load screen processing.
#==============================================================================
class Scene_Load < Scene_File
#--------------------------------------------------------------------------
# * Confirm Save File
#--------------------------------------------------------------------------
def on_savefile_ok
super
if DataManager.load_game(@index)
on_load_success
Flip.do_load(@index)
else
Sound.play_buzzer
end
end
end
#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
# This is a super class of all windows within the game.
#==============================================================================
class Window_Base < Window
def expensive_color; Flip::EXPENSIVE_COLOR ; end; # Color for more expensive Items
def cheaper_color; Flip::CHEAPER_COLOR ; end; # Color for cheaper Items
def expensive_low_range_color; Flip::EXPENSIVE_LOW_RANGE_COLOR ; end; # Color for low expensive Items
def cheaper_low_range_color; Flip::CHEAPER_LOW_RANGE_COLOR ; end; # Color for low cheaper Items
def expensive_mid_range_color; Flip::EXPENSIVE_MID_RANGE_COLOR ; end; # Color for mid expensive Items
def cheaper_mid_range_color; Flip::CHEAPER_MID_RANGE_COLOR ; end; # Color for mid cheaper Items
#--------------------------------------------------------------------------
# * Draw Shop Text
# Same as draw_text but modified for this script (:
# rect = x,y,width,height of the text
# text = text which would be written
# pos = position of the text
# item = the Item which will be drawn for this time.
#--------------------------------------------------------------------------
def draw_shop_text(rect,text,pos,item)
pricing_color(item)
contents.draw_text(rect.x,rect.y,rect.width,rect.height,text,pos)
end
#--------------------------------------------------------------------------
# * Draw Item Name
# enabled : Enabled flag. When false, draw semi-transparently.
#--------------------------------------------------------------------------
def draw_item_buy_name(item, x, y, enabled = true, width = 172)
return unless item
draw_icon(item.icon_index, x, y, enabled)
pricing_color(item)
draw_text(x + 24, y, width, line_height, item.name)
end
#--------------------------------------------------------------------------
# * Pricing Color
# Checks for the right colors to use.
#--------------------------------------------------------------------------
def pricing_color(item)
if item.is_a?(RPG::Item)
costing = Flip::ITEM_STANDARD_COST[item.id]
elsif item.is_a?(RPG::Armor)
costing = Flip::ARMOR_STANDARD_COST[item.id]
elsif item.is_a?(RPG::Weapon)
costing = Flip::WEAPON_STANDARD_COST[item.id]
end
if price(item) > costing
pricey = costing * Flip::EXPENSIVE_RANGE / 100 + costing
low_pricey = costing * Flip::EXPENSIVE_LOW_RANGE / 100 + costing
if price(item) >= pricey
change_color(expensive_color,enable?(item))
elsif Flip::USE_LOW_RANGE
if price(item) >= low_pricey && price(item) <= pricey
change_color(expensive_mid_range_color,enable?(item))
elsif price(item) <= low_pricey
change_color(expensive_low_range_color,enable?(item))
end
end
elsif price(item) < costing
pricey = costing - (costing * Flip::CHEAPER_RANGE / 100)
low_pricey = costing - (costing * Flip::CHEAPER_LOW_RANGE / 100)
if price(item) <= pricey
change_color(cheaper_color,enable?(item))
elsif Flip::USE_LOW_RANGE
if price(item) >= pricey && price(item) <= low_pricey
change_color(cheaper_mid_range_color,enable?(item))
elsif price(item) >= low_pricey
change_color(cheaper_low_range_color,enable?(item))
end
end
else
change_color(normal_color,enable?(item))
end
end
end
#==============================================================================
# ** Window_ShopCommand
#------------------------------------------------------------------------------
# This window is for selecting buy/sell on the shop screen.
#==============================================================================
class Window_ShopCommand < Window_HorzCommand
#--------------------------------------------------------------------------
# * Get Digit Count
#--------------------------------------------------------------------------
def col_max
return 3 if !@purchase_only
return 2 if @purchase_only
end
#--------------------------------------------------------------------------
# * Create Command List
#--------------------------------------------------------------------------
def make_command_list
add_command(Vocab::ShopBuy, :buy)
add_command(Vocab::ShopSell, :sell) if !@purchase_only
add_command(Vocab::ShopCancel, :cancel)
end
end
#==============================================================================
# ** Window_ShopBuy
#------------------------------------------------------------------------------
# This window displays a list of buyable goods on the shop screen.
#==============================================================================
class Window_ShopBuy < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias flipitialize initialize
def initialize(x, y, height, shop_goods)
Flip.pass_the_costs_away(shop_goods)
flipitialize(x, y, height, shop_goods)
end
#--------------------------------------------------------------------------
# * Draw Item
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
rect = item_rect(index)
draw_item_buy_name(item, rect.x, rect.y, enable?(item))
rect.width -= 4
draw_shop_text(rect, price(item), 2, item)
end
end
#==============================================================================
# ** Scene_Shop
#------------------------------------------------------------------------------
# This class performs shop screen processing.
#==============================================================================
class Scene_Shop < Scene_MenuBase
#--------------------------------------------------------------------------
# * Get Sale Price
#--------------------------------------------------------------------------
def selling_price
@buy_window.price(@item) / 2
end
end
################################################################################
# #
# END OF SCRIPT #
# #
################################################################################