Silencher 0 Report post Posted September 26, 2011 (edited) Hey all, I'm currently using the following script because it allows me to lower/raise prices by a certain percentage. I want this because I have an item in my game that allows for 1/2 off at all shops. This script does that just fine, but I have a pet peeve about not being able to see the difference(good or bad) in what is currently equipped on my actors and what is for sale in a shop. I have a few other scripts installed, the most major being the AMS. I'm looking for 1 of 2 things: 1) A brand new script that would allow me/the player to see the difference in stats and armor plus would also enable me to keep my 1/2 off item, and otherwise raise or lower my shop prices by a percentile. 2) A modification to the script below that would show the differences in current/new equipment while in the shop menu. If you could help, that would be really great. As a side note, I'm currently learning to program Java and I would like to eventually move on to Ruby. If you are willing to help 'mentor' me as I learn Ruby, can you shoot me a PM? thanks a bunch guys, Silencher [code]#============================================================================== # ** MeisMe's Realistic Shop #------------------------------------------------------------------------------ # Created by MeisMe # Buxfix by Daniel # August 8, 2006 # Version 2 #============================================================================== class Game_Temp attr_accessor :buy_rate attr_accessor :sell_rate attr_accessor :discount attr_accessor :tax attr_accessor :cart_item attr_accessor :cart_weapon attr_accessor :cart_armor attr_accessor :shop_type alias mim_shop_old_initialize initialize def initialize mim_shop_old_initialize @buy_rate = 100 @sell_rate = 50 @discount = 0 @tax = 0 clear_cart @shop_type = 0 end def clear_cart @cart_item = {} @cart_weapon = {} @cart_armor = {} end def cart_cleared? if (@cart_item == {} && @cart_weapon == {} && @cart_armor == {}) return true end return false end def item_number(item_id) return @cart_item.include?(item_id) ? @cart_item[item_id] : 0 end def weapon_number(weapon_id) return @cart_weapon.include?(weapon_id) ? @cart_weapon[weapon_id] : 0 end def armor_number(armor_id) return @cart_armor.include?(armor_id) ? @cart_armor[armor_id] : 0 end def gain_item(item_id, n) if item_id > 0 @cart_item[item_id] = [[item_number(item_id) + n, 0].max, 99].min end end def gain_weapon(weapon_id, n) if weapon_id > 0 @cart_weapon[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, 99].min end end def gain_armor(armor_id, n) if armor_id > 0 @cart_armor[armor_id] = [[armor_number(armor_id) + n, 0].max, 99].min end end def gain_items for i in 1..$data_items.size if item_number(i) > 0 $game_party.gain_item(i, item_number(i)) end end for i in 1..$data_weapons.size if weapon_number(i) > 0 $game_party.gain_weapon(i, weapon_number(i)) end end for i in 1..$data_armors.size if armor_number(i) > 0 $game_party.gain_armor(i, armor_number(i)) end end end end #============================================================================== class Window_ShopCommand < Window_Selectable def initialize super(0, 64, 480, 64) self.contents = Bitmap.new(width - 32, height - 32) @item_max = 3 @column_max = 3 @commands = ["Buy", "Sell", "Exit"] refresh self.index = 0 end def refresh self.contents.clear if $game_temp.shop_type == 0 for i in 0...@item_max draw_item(i) end end if $game_temp.shop_type == 1 self.contents.draw_text(4, 0, 324, 32, "You can only buy at this shop.") self.index = -1 update_cursor_rect end if $game_temp.shop_type == 2 self.contents.draw_text(4, 0, 324, 32, "You can only sell at this shop.") self.index = -1 update_cursor_rect end end def draw_item(index) x = 4 + index * 160 self.contents.draw_text(x, 0, 128, 32, @commands[index]) end def update_cursor_rect if $game_temp.shop_type == 0 super end if $game_temp.shop_type == 1 || $game_temp.shop_type == 2 self.cursor_rect.empty end end end #============================================================================== class Window_ShopBuyBG < Window_Base def initialize super(0, 128, 320, 352) self.contents = Bitmap.new(width - 32, height - 32) refresh end def refresh self.contents.clear self.contents.font.color = system_color self.contents.draw_text(4, 0, 128, 32, 'Item Name') self.contents.draw_text(4, 0, 284, 32, 'Marked Price', 2) end end #============================================================================== class Window_ShopBuy < Window_Selectable def initialize(shop_goods) super(0, 160, 320, 320) @shop_goods = shop_goods refresh self.index = 0 self.opacity = 0 end def item return @data[self.index] end def refresh if self.contents != nil self.contents.dispose self.contents = nil end @data = [] for goods_item in @shop_goods case goods_item[0] when 0 item = $data_items[goods_item[1]] when 1 item = $data_weapons[goods_item[1]] when 2 item = $data_armors[goods_item[1]] end if item != nil @data.push(item) end end # If item count is not 0, make a bit map and draw all items @item_max = @data.size if @item_max > 0 self.contents = Bitmap.new(width - 32, row_max * 32) for i in 0...@item_max draw_item(i) end end end def draw_item(index) item = @data[index] case item when RPG::Item number = $game_party.item_number(item.id) + $game_temp.item_number(item.id) when RPG::Weapon number = $game_party.weapon_number(item.id) + $game_temp.weapon_number(item.id) when RPG::Armor number = $game_party.armor_number(item.id) + $game_temp.armor_number(item.id) end price = [[item.price * $game_temp.buy_rate / 100, 9999999].min, 0].max if number >= 99 self.contents.font.color = disabled_color else self.contents.font.color = normal_color end x = 4 y = index * 32 rect = Rect.new(x, y, self.width / @column_max - 32, 32) self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) bitmap = RPG::Cache.icon(item.icon_name) opacity = self.contents.font.color == normal_color ? 255 : 128 self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity) self.contents.draw_text(x + 28, y, 212, 32, item.name, 0) self.contents.draw_text(x + 192, y, 88, 32, price.to_s, 2) end end #============================================================================== class Window_ShopNumber < Window_Base #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize super(0, 128, 320, 352) self.contents = Bitmap.new(width - 32, height - 32) @item = nil @max = 1 @price = 0 @number = 1 end #-------------------------------------------------------------------------- # * Set Items, Max Quantity, and Price #-------------------------------------------------------------------------- def set(item, max, price) @item = item @max = max @price = price @number = 1 refresh end #-------------------------------------------------------------------------- # * Set Inputted Quantity #-------------------------------------------------------------------------- def number return @number end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh self.contents.clear draw_item_name(@item, 4, 96) self.contents.font.color = normal_color self.contents.draw_text(236, 96, 32, 32, "×") self.contents.draw_text(248, 96, 24, 32, @number.to_s, 2) self.cursor_rect.set(304, 96, 32, 32) # Draw total price and currency units domination = $data_system.words.gold cx = contents.text_size(domination).width total_price = @price * @number self.contents.font.color = normal_color self.contents.draw_text(0, 160, 288-cx-4, 32, total_price.to_s, 2) self.contents.font.color = system_color self.contents.draw_text(288-cx, 160, cx, 32, domination, 2) end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update super if self.active # Cursor right (+1) if Input.repeat?(Input::RIGHT) and @number < @max $game_system.se_play($data_system.cursor_se) @number += 1 refresh end # Cursor left (-1) if Input.repeat?(Input::LEFT) and @number > 1 $game_system.se_play($data_system.cursor_se) @number -= 1 refresh end # Cursor up (+10) if Input.repeat?(Input::UP) and @number < @max $game_system.se_play($data_system.cursor_se) @number = [@number + 10, @max].min refresh end # Cursor down (-10) if Input.repeat?(Input::DOWN) and @number > 1 $game_system.se_play($data_system.cursor_se) @number = [@number - 10, 1].max refresh end end end end #============================================================================== class Window_ShopNumber2 < Window_Base #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize super(0, 128, 320, 352) self.contents = Bitmap.new(width - 32, height - 32) @item = nil @max = 1 @number = 1 end #-------------------------------------------------------------------------- # * Set Items, Max Quantity, and Price #-------------------------------------------------------------------------- def set(item) @item = item @number = 1 refresh end #-------------------------------------------------------------------------- # * Set Inputted Quantity #-------------------------------------------------------------------------- def number return @number end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh self.contents.clear draw_item_name(@item, 4, 96) case @item when RPG::Item @max = $game_temp.item_number(@item.id) when RPG::Weapon @max = $game_temp.weapon_number(@item.id) when RPG::Armor @max = $game_temp.armor_number(@item.id) end self.contents.font.color = normal_color self.contents.draw_text(236, 96, 32, 32, "x-") self.contents.draw_text(248, 96, 24, 32, @number.to_s, 2) self.cursor_rect.set(304, 96, 32, 32) self.contents.draw_text(248, 128, 24, 32, "#{@max - @number}", 2) end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update super if self.active # Cursor right (+1) if Input.repeat?(Input::RIGHT) and @number < @max $game_system.se_play($data_system.cursor_se) @number += 1 refresh end # Cursor left (-1) if Input.repeat?(Input::LEFT) and @number > 1 $game_system.se_play($data_system.cursor_se) @number -= 1 refresh end # Cursor up (+10) if Input.repeat?(Input::UP) and @number < @max $game_system.se_play($data_system.cursor_se) @number = [@number + 10, @max].min refresh end # Cursor down (-10) if Input.repeat?(Input::DOWN) and @number > 1 $game_system.se_play($data_system.cursor_se) @number = [@number - 10, 1].max refresh end end end end #============================================================================== class Window_ShopFinalize < Window_Selectable attr_reader :final_price def initialize super(0, 128, 320, 352) self.contents = Bitmap.new(width - 32, height - 32) self.index = 0 self.active = false @item_max = 2 @final_price = 0 refresh end def refresh @final_price = 0 base_price = 0 for i in 1..$data_items.size if $game_temp.item_number(i) > 0 price = $game_temp.item_number(i) * $data_items[i].price base_price += [[price * $game_temp.buy_rate / 100, 9999999].min, 0].max end end for i in 1..$data_weapons.size if $game_temp.weapon_number(i) > 0 price = $game_temp.weapon_number(i) * $data_weapons[i].price base_price += [[price * $game_temp.buy_rate / 100, 9999999].min, 0].max end end for i in 1..$data_armors.size if $game_temp.armor_number(i) > 0 price = $game_temp.armor_number(i) * $data_armors[i].price base_price += [[price * $game_temp.buy_rate / 100, 9999999].min, 0].max end end total_price = base_price discount = 0 if $game_temp.discount != 0 discount = [[total_price * $game_temp.discount / 100, 9999999].min, 0].max total_price = total_price - discount end tax = 0 if $game_temp.tax != 0 tax = [[total_price * $game_temp.tax / 100, 9999999].min, 0].max end total_price = total_price + tax self.contents.clear word = $data_system.words.gold cx = contents.text_size(word).width self.contents.font.color = system_color self.contents.draw_text(4, 0, 288, 32, 'Finalize this purchase?', 1) self.contents.draw_text(4, 64, 128, 32, 'Price of Items:') self.contents.draw_text(4, 96, 128, 32, 'Sales Discount:') self.contents.draw_text(4, 128, 128, 32, 'Tax Added:') self.contents.fill_rect(4, 160, 280, 1, normal_color) self.contents.draw_text(4, 160, 128, 32, 'Grand Total:') self.contents.draw_text(0, 64, 288, 32, word, 2) self.contents.draw_text(0, 96, 288, 32, word, 2) self.contents.draw_text(0, 128, 288, 32, word, 2) self.contents.draw_text(0, 160, 288, 32, word, 2) self.contents.font.color = normal_color self.contents.draw_text(0, 64, 288-cx-2, 32, base_price.to_s, 2) self.contents.draw_text(0, 96, 288-cx-2, 32, discount.to_s, 2) self.contents.draw_text(0, 128, 288-cx-2, 32, tax.to_s, 2) self.contents.draw_text(0, 160, 288-cx-2, 32, total_price.to_s, 2) self.contents.draw_text(0, 256, 288, 32, 'No', 1) if total_price > $game_party.gold self.contents.font.color = disabled_color end self.contents.draw_text(0, 224, 288, 32, 'Yes', 1) @final_price = total_price end def update_cursor_rect if self.index == 0 cursor_rect.set(0, 224, 288, 32) else cursor_rect.set(0, 256, 288, 32) end end end #============================================================================== #============================================================================== # ** Window_ShopStatus #------------------------------------------------------------------------------ # This window displays number of items in possession and the actor's equipment # on the shop screen. #============================================================================== class Window_ShopStatus < Window_Selectable attr_reader :data #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize super(320, 128, 320, 352) refresh self.index = 0 self.active = false @data = [] end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh if self.contents != nil self.contents.dispose self.contents = nil end @data = [] # Add item for i in 1...$data_items.size if $game_temp.item_number(i) > 0 @data.push($data_items[i]) end end # Also add weapons and items if outside of battle for i in 1...$data_weapons.size if $game_temp.weapon_number(i) > 0 @data.push($data_weapons[i]) end end for i in 1...$data_armors.size if $game_temp.armor_number(i) > 0 @data.push($data_armors[i]) end end # If item count is not 0, make a bit map and draw all items @item_max = @data.size + 1 if @item_max > 0 self.contents = Bitmap.new(width - 32, row_max * 32) for i in 0...@item_max draw_item(i) end end end #-------------------------------------------------------------------------- # * Draw Item # index : item number #-------------------------------------------------------------------------- def draw_item(index) item = @data[index] if item != nil case item when RPG::Item number = $game_temp.item_number(item.id) when RPG::Weapon number = $game_temp.weapon_number(item.id) when RPG::Armor number = $game_temp.armor_number(item.id) end x = 4 y = index * 32 rect = Rect.new(x, y, self.width / @column_max - 32, 32) self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) bitmap = RPG::Cache.icon(item.icon_name) self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24)) self.contents.draw_text(x + 28, y, 212, 32, item.name, 0) self.contents.draw_text(x + 240, y, 16, 32, "x", 1) self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2) else x = 4 y = index * 32 self.contents.font.color = @data == [] ? disabled_color : normal_color self.contents.draw_text(x, y, 288, 32, 'Finalize Purchase', 1) end end def item return @data[self.index] end def update_help if item != nil @help_window.set_text(item.description) else @help_window.set_text('Purchase all the goods in your cart.') end end end #============================================================================== # ** Scene_Shop #------------------------------------------------------------------------------ # This class performs shop screen processing. #============================================================================== class Scene_Shop #-------------------------------------------------------------------------- # * Main Processing #-------------------------------------------------------------------------- def main # Make help window @help_window = Window_Help.new # Make command window @command_window = Window_ShopCommand.new # Make gold window @gold_window = Window_Gold.new @gold_window.x = 480 @gold_window.y = 64 # Make dummy window @dummy_window = Window_Base.new(0, 128, 640, 352) # Make buy window @buy_window = Window_ShopBuy.new($game_temp.shop_goods) @buy_window.active = false @buy_window.visible = false @buy_window.help_window = @help_window @buyBG = Window_ShopBuyBG.new @buyBG.visible = false # Make sell window @sell_window = Window_ShopSell.new @sell_window.active = false @sell_window.visible = false @sell_window.help_window = @help_window # Make quantity input window @number_window = Window_ShopNumber.new @number_window.active = false @number_window.visible = false @number_window2 = Window_ShopNumber2.new @number_window2.active = false @number_window2.visible = false # Make status window @status_window = Window_ShopStatus.new @status_window.visible = false @status_window.help_window = @help_window @finalize_window = Window_ShopFinalize.new @finalize_window.visible = false if $game_temp.shop_type == 1 @command_window.index = 0 @command_window.active = false @dummy_window.visible = false @buy_window.active = true @buy_window.visible = true @buyBG.visible = true @buy_window.refresh @status_window.visible = true end if $game_temp.shop_type == 2 @command_window.index = 1 @command_window.active = false @dummy_window.visible = false @sell_window.active = true @sell_window.visible = true @sell_window.refresh end # Execute transition Graphics.transition # Main loop loop do # Update game screen Graphics.update # Update input information Input.update # Frame update update # Abort loop if screen is changed if $scene != self break end end # Prepare for transition Graphics.freeze # Dispose of windows @help_window.dispose @command_window.dispose @gold_window.dispose @dummy_window.dispose @buy_window.dispose @buyBG.dispose @sell_window.dispose @number_window.dispose @number_window2.dispose @status_window.dispose @finalize_window.dispose $game_temp.clear_cart $game_temp.buy_rate = 100 $game_temp.sell_rate = 50 $game_temp.discount = 0 $game_temp.shop_type = 0 end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update # Update windows @help_window.update @command_window.update @gold_window.update @dummy_window.update @buy_window.update @buyBG.update @sell_window.update @number_window.update @number_window2.update @status_window.update @finalize_window.update # If command window is active: call update_command if @command_window.active update_command return # If buy window is active: call update_buy elsif @buy_window.active update_buy return # If sell window is active: call update_sell elsif @sell_window.active update_sell return # If quantity input window is active: call update_number elsif @number_window.active update_number return elsif @status_window.active update_status elsif @finalize_window.active update_finalize elsif @number_window2.active update_number2 end end #-------------------------------------------------------------------------- # * Frame Update (when command window is active) #-------------------------------------------------------------------------- def update_command # If B button was pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) # Switch to map screen $scene = Scene_Map.new return end # If C button was pressed if Input.trigger?(Input::C) # Branch by command window cursor position case @command_window.index when 0 # buy # Play decision SE $game_system.se_play($data_system.decision_se) # Change windows to buy mode @command_window.active = false @dummy_window.visible = false @buy_window.active = true @buy_window.visible = true @buy_window.refresh @buyBG.visible = true @status_window.visible = true when 1 # sell # Play decision SE $game_system.se_play($data_system.decision_se) # Change windows to sell mode @command_window.active = false @dummy_window.visible = false @sell_window.active = true @sell_window.visible = true @sell_window.refresh when 2 # quit # Play decision SE $game_system.se_play($data_system.decision_se) # Switch to map screen $scene = Scene_Map.new end return end end #-------------------------------------------------------------------------- # * Frame Update (when buy window is active) #-------------------------------------------------------------------------- def update_buy # If B button was pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) if $game_temp.shop_type == 1 $scene = Scene_Map.new return end # Change windows to initial mode @command_window.active = true @dummy_window.visible = true @buy_window.active = false @buy_window.visible = false @buyBG.visible = false @status_window.visible = false # Erase help text @help_window.set_text("") return end # If C button was pressed if Input.trigger?(Input::C) # Get item @item = @buy_window.item # Get items in possession count case @item when RPG::Item number = $game_party.item_number(@item.id) number2 = $game_temp.item_number(@item.id) when RPG::Weapon number = $game_party.weapon_number(@item.id) number2 = $game_temp.weapon_number(@item.id) when RPG::Armor number = $game_party.armor_number(@item.id) number2 = $game_temp.armor_number(@item.id) end # If 99 items are already in possession if number + number2 >= 99 # Play buzzer SE $game_system.se_play($data_system.buzzer_se) return end # Play decision SE $game_system.se_play($data_system.decision_se) # Calculate maximum amount possible to buy max = [99, 99 - number - number2].min # Change windows to quantity input mode @buy_window.active = false @buy_window.visible = false @buyBG.visible = false price = [[@item.price * $game_temp.buy_rate / 100, 9999999].min, 0].max @number_window.set(@item, max, price) @number_window.active = true @number_window.visible = true end # If RIGHT was pressed if Input.trigger?(Input::RIGHT) || Input.trigger?(Input::LEFT) $game_system.se_play($data_system.decision_se) @buy_window.active = false @status_window.active = true end end #-------------------------------------------------------------------------- # * Frame Update (when sell window is active) #-------------------------------------------------------------------------- def update_sell # If B button was pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) if $game_temp.shop_type == 2 $game_system.se_play($data_system.cancel_se) $scene = Scene_Map.new return end # Change windows to initial mode @command_window.active = true @dummy_window.visible = true @sell_window.active = false @sell_window.visible = false # Erase help text @help_window.set_text("") return end # If C button was pressed if Input.trigger?(Input::C) # Get item @item = @sell_window.item # If item is invalid, or item price is 0 (unable to sell) if @item == nil or @item.price == 0 # Play buzzer SE $game_system.se_play($data_system.buzzer_se) return end # Play decision SE $game_system.se_play($data_system.decision_se) # Get items in possession count case @item when RPG::Item number = $game_party.item_number(@item.id) when RPG::Weapon number = $game_party.weapon_number(@item.id) when RPG::Armor number = $game_party.armor_number(@item.id) end # Maximum quanitity to sell = number of items in possession max = number price = [[@item.price * $game_temp.sell_rate / 100, 9999999].min, 1].max # Change windows to quantity input mode @sell_window.active = false @sell_window.visible = false @number_window.set(@item, max, price) @number_window.active = true @number_window.visible = true @status_window.visible = true end end #-------------------------------------------------------------------------- # * Frame Update (when quantity input window is active) #-------------------------------------------------------------------------- def update_number # If B button was pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) # Set quantity input window to inactive / invisible @number_window.active = false @number_window.visible = false # Branch by command window cursor position case @command_window.index when 0 # buy # Change windows to buy mode @buy_window.active = true @buy_window.visible = true @buyBG.visible = true when 1 # sell # Change windows to sell mode @sell_window.active = true @sell_window.visible = true @status_window.visible = false end return end # If C button was pressed if Input.trigger?(Input::C) # Set quantity input window to inactive / invisible @number_window.active = false @number_window.visible = false # Branch by command window cursor position case @command_window.index when 0 # buy $game_system.se_play($data_system.equip_se) case @item when RPG::Item $game_temp.gain_item(@item.id, @number_window.number) when RPG::Weapon $game_temp.gain_weapon(@item.id, @number_window.number) when RPG::Armor $game_temp.gain_armor(@item.id, @number_window.number) end # Refresh each window @gold_window.refresh @buy_window.refresh @status_window.refresh # Change windows to buy mode @buy_window.active = true @buy_window.visible = true @buyBG.visible = true when 1 # sell $game_system.se_play($data_system.shop_se) # Sell process price = [[@item.price * $game_temp.sell_rate / 100, 9999999].min, 1].max $game_party.gain_gold(@number_window.number * (price)) case @item when RPG::Item $game_party.lose_item(@item.id, @number_window.number) when RPG::Weapon $game_party.lose_weapon(@item.id, @number_window.number) when RPG::Armor $game_party.lose_armor(@item.id, @number_window.number) end # Refresh each window @gold_window.refresh @sell_window.refresh @status_window.refresh # Change windows to sell mode @sell_window.active = true @sell_window.visible = true @status_window.visible = false end return end end def update_status if Input.trigger?(Input::RIGHT) || Input.trigger?(Input::LEFT) $game_system.se_play($data_system.decision_se) @buy_window.active = true @status_window.active = false end if Input.trigger?(Input::C) if @status_window.item == nil if @status_window.data != [] $game_system.se_play($data_system.decision_se) @buy_window.visible = false @buyBG.visible = false @finalize_window.visible = true @finalize_window.index = 0 @finalize_window.refresh @finalize_window.active = true @status_window.active = false return else $game_system.se_play($data_system.buzzer_se) return end else $game_system.se_play($data_system.decision_se) @status_window.active = false @buy_window.visible = false @buyBG.visible = false @number_window2.set(@status_window.item) @number_window2.visible = true @number_window2.active = true end end if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) if $game_temp.shop_type == 1 $scene = Scene_Map.new return end # Change windows to initial mode @command_window.active = true @dummy_window.visible = true @buy_window.visible = false @buyBG.visible = false @status_window.visible = false @status_window.active = false # Erase help text @help_window.set_text("") return end end def update_finalize if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) @buy_window.visible = true @buy_window.active = false @buyBG.visible = true @finalize_window.visible = false @finalize_window.active = false @status_window.active = true @buy_window.refresh end if Input.trigger?(Input::C) if @finalize_window.index == 0 if @finalize_window.final_price > $game_party.gold $game_system.se_play($data_system.buzzer_se) return end $game_system.se_play($data_system.shop_se) $game_party.lose_gold(@finalize_window.final_price) $game_temp.gain_items @gold_window.refresh @buy_window.visible = true @buy_window.active = true @buyBG.visible = true @finalize_window.visible = false @finalize_window.active = false @status_window.active = false $game_temp.clear_cart @status_window.index = 0 @status_window.refresh @buy_window.refresh return else $game_system.se_play($data_system.decision_se) @buy_window.visible = true @buyBG.visible = true @finalize_window.visible = false @finalize_window.active = false @status_window.active = true @buy_window.refresh return end end end def update_number2 if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) @buy_window.visible = true @buy_window.active = false @buyBG.visible = true @finalize_window.visible = false @finalize_window.active = false @status_window.active = true @number_window2.visible = false @number_window.active = false @status_window.refresh @buy_window.refresh return end if Input.trigger?(Input::C) $game_system.se_play($data_system.equip_se) case @status_window.item when RPG::Item $game_temp.gain_item(@status_window.item.id, -@number_window2.number) when RPG::Weapon $game_temp.gain_weapon(@status_window.item.id, -@number_window2.number) when RPG::Armor $game_temp.gain_armor(@status_window.item.id, -@number_window2.number) end @buy_window.visible = true @buy_window.active = false @buyBG.visible = true @finalize_window.visible = false @finalize_window.active = false @status_window.active = true @number_window2.visible = false @number_window.active = false @status_window.refresh @buy_window.refresh end end end [/code] Edited September 27, 2011 by Silencher Share this post Link to post Share on other sites
Dragon324 16 Report post Posted September 27, 2011 (edited) First of all I believe the default allows the player to see the difference. Secondly this can also possibly be evented. It largely depends on how much adjusting to prices you want, and how many coupon type things you will have in game to how long the event will be. So if your interested when I'm not busy I can probably try to whip one up for you.Again not to sound mean but kell is busy and idk when or if he could get around to it but its up to you, I'm just trying to help. Edited September 27, 2011 by Dragon324 Share this post Link to post Share on other sites
Silencher 0 Report post Posted September 27, 2011 First of all I believe the default allows the player to see the difference. Secondly this can also possibly be evented. It largely depends on how much adjusting to prices you want, and how many coupon type things you will have in game to how long the event will be. So if your interested when I'm not busy I can probably try to whip one up for you.Again not to sound mean but kell is busy and idk when or if he could get around to it but its up to you, I'm just trying to help. You're right, the default does allow you to see the difference. In my game I had it evented so that if the players shopped at one particular shop, it increased the prices for that shop by 50%. I thought about just raising the prices but I realized if I did that that they could still sell the items for 75% of the normal price, which while it is still a loss is a little irritating. The other thing is just at every shop I have a conditional branch on whether or not the 1/2 off item is in the inventory, if it is, I call the script to reduce prices by 50%, then raise them back to normal after shop processing is complete. If you could tell me how to allow both of those, I'll just go ahead and cut out the script I posted above and do it that way, it sounds like the easiest way. So to summarize, I'd need to know how to 1) raise the price by 50%. 2) lower the price by 50%) and then 3) return the price to normal, which I can just insert after each of the raising/lowerings. Could you help me with that? I'd appreciate it, for sure. Share this post Link to post Share on other sites
Dragon324 16 Report post Posted September 27, 2011 You're right, the default does allow you to see the difference. In my game I had it evented so that if the players shopped at one particular shop, it increased the prices for that shop by 50%. I thought about just raising the prices but I realized if I did that that they could still sell the items for 75% of the normal price, which while it is still a loss is a little irritating. The other thing is just at every shop I have a conditional branch on whether or not the 1/2 off item is in the inventory, if it is, I call the script to reduce prices by 50%, then raise them back to normal after shop processing is complete. If you could tell me how to allow both of those, I'll just go ahead and cut out the script I posted above and do it that way, it sounds like the easiest way. So to summarize, I'd need to know how to 1) raise the price by 50%. 2) lower the price by 50%) and then 3) return the price to normal, which I can just insert after each of the raising/lowerings. Could you help me with that? I'd appreciate it, for sure. Ok I think I get you the last thing I need to know is why the prices raise, such as the player has bought to many, or is it just at certain times prices are higher. Preferably the second one imo would be easier but the first would not be impossible but I will tell you this might get pretty lengthy. If you respond to that if I have time I'll start on it 2 nite when I get home if not I should be able to do it Wednesday. Share this post Link to post Share on other sites
Silencher 0 Report post Posted September 27, 2011 Ok I think I get you the last thing I need to know is why the prices raise, such as the player has bought to many, or is it just at certain times prices are higher. Preferably the second one imo would be easier but the first would not be impossible but I will tell you this might get pretty lengthy. If you respond to that if I have time I'll start on it 2 nite when I get home if not I should be able to do it Wednesday. The price just raises at one particular shop because it's the 'black market' so I wanted the prices to be higher. Basically it's a shop for getting mid-game eq at near the beginning of the game. The increase in price is just to mitigate that basically. So it affects the entire shops' prices and is independent of certain times or if the player buys too many items or anything like that. Share this post Link to post Share on other sites
kellessdee 48 Report post Posted September 28, 2011 You guys may or may not be over-complicating this... (being a scripter gives me an unfair advantage i guess) Use this with the default shop system. Change the price modification through a script call: $game_party.price_modifier = mod mod is a percentage represented as a decimal number. 100% = 1.0 50% = 0.5 so to make all the items in a shop cost 50% price rate $game_party.price_modifier = 0.5 There's the modification, then if you use the default shop, it will display the difference in changing equipment. This only affects buy price, did you need a mod on sale price as well? put above main as per usual class Game_Party attr_accessor :price_modifier alias :new_init_item_price :initialize unless method_defined?(:new_init_item_price) def initialize new_init_item_price @price_modifier = 1.0 end end class Window_ShopBuy < Window_Selectable alias :new_draw_item_price :draw_item unless method_defined?(:new_draw_item_price) def draw_item(index) new_draw_item_price(index) price = (@data[index].price * $game_party.price_modifier).to_i x, y = 4, index * 32 self.contents.fill_rect(x + 240, y, 88, 32, Color.new(0,0,0,0)) self.contents.draw_text(x + 240, y, 88, 32, price.to_s, 2) end def item item = @data[self.index].dup item.price = (item.price * $game_party.price_modifier).to_i return item end end Share this post Link to post Share on other sites
Silencher 0 Report post Posted September 28, 2011 This seems to work fine so long as I put in the call script everytime. But after putting in the full script after main, if I go to a shop where I don't call the script it gives me an error message: Script 'PriceModifier' line20: TypeError occurred. nil can't be coerced into Fixnum. The line it references seems to be this one, so I'm not sure what the issue is. price = (@data[index].price * $game_party.price_modifier).to_i Share this post Link to post Share on other sites
kellessdee 48 Report post Posted September 28, 2011 Hmm that's weird. That means either @data[index].price or $game_party.price_modifier is nil when the shop is being called.... which it shouldn't be. Do you change the price_modification after a shop is finished processing? I will try to recreate this error in like 5-10mins. I have to boot back to windows to try it out. BRB LOL EDIT: I hate to say things like this, but I can't recreate the error... You *MAY* be doing something funny with the $game_party.price_modifier value.......? (or it could be a compatibility issue...but I HIGHLY doubt that...you are using the default shop with this right?) If you could upload some pics of the event editor on the shop events that you tested to get this error; I may be able to figure out what's going on. Share this post Link to post Share on other sites
Silencher 0 Report post Posted September 28, 2011 Hmm that's weird. That means either @data[index].price or $game_party.price_modifier is nil when the shop is being called.... which it shouldn't be. Do you change the price_modification after a shop is finished processing? I will try to recreate this error in like 5-10mins. I have to boot back to windows to try it out. BRB LOL EDIT: I hate to say things like this, but I can't recreate the error... You *MAY* be doing something funny with the $game_party.price_modifier value.......? (or it could be a compatibility issue...but I HIGHLY doubt that...you are using the default shop with this right?) If you could upload some pics of the event editor on the shop events that you tested to get this error; I may be able to figure out what's going on. As far as I know I'm not doing anything, but to be on the safe side I just used a call script to set the price mod to 1 when the game first starts, that seems to fix it no problem, so thanks a lot =) Share this post Link to post Share on other sites
kellessdee 48 Report post Posted September 28, 2011 AROOO???? Well that means I found the issue, for some reason on your end the script isn't initializing the price_modifier... Did you include this part of the script? class Game_Party attr_accessor :price_modifier alias :new_init_item_price :initialize unless method_defined?(:new_init_item_price) def initialize new_init_item_price @price_modifier = 1.0 end end If you did, then there somehow must be some interference of scripts somewhere xD Eitherway, if it all works now then I guess it's all good, and I am glad :alright: ALSO, I forgot to mention: I am a total nerd and love talking all things computers/scripts/programming/etc. Also, java was my *technically* first language (i did briefly learn visual basic, but never really took it that far), so if you are looking to learn ruby as well, and have any questions feel free to drop me a PM EDIT: somehow i left my message in the code tags LOL fixed haha Share this post Link to post Share on other sites
Silencher 0 Report post Posted September 28, 2011 I did, I'll try re-copying and pasting it to see if that fixes it and yeah, definitely, I'll drop you a PM as stuff comes up. I'm actually trying to do a warp spell, I have it working fine with eventing, but the issue is that it could potentially spoil upcoming towns. I'll include it here if you want to take a look and maybe guide me through how I could fix it. Ideally I'd like the menu to be longer, and for the warp point names to be either blank or ???? until the town has been visited. It would also be nice to know how to gray out 'warp' when it isn't available, such as when I'm inside of dungeons, I turn off the enablewarp switch. Basically the 'warp' spell calls a common event that first checks via conditional branch(hearafter referred to as CB) if warp is enabled. If not, then the event spits out a message and cancels. If so, it brings up a text box and choices list: Choose a town to warp to (Choice box: Town1, Town2,Town3,next). Anytime they choose a town, it pulls up CB:Is(X)townfound? if so: CB:Is (X) town accessible? if either of those are false, it tells them they haven't found or can't warp to that town. If both CBs are true, it teleports them to that town via a Transfer Player event. So yeah, the drawbacks to this are that first of all they might waste precious MP trying to use it when they can't, for whatever reason; the event way of doing it doesn't look particularly nice/professional; it could potentially spoil what future towns there are(although I suppose I could just make more CBs to only display certain towns at certain times but it would require a lot of reworking of both the common event and the project itself, like adding switches, etc.) Share this post Link to post Share on other sites
kellessdee 48 Report post Posted September 28, 2011 Weird, I am wondering if maybe you are using a script that modifies the Game_Party class, but doesn't alias initialize and just overwrites it...Although, if my script is below that script, it still shouldn't be an issue. Did you place my script DIRECTLY above main? that may fix the issue (if you didn't put it DIRECTLY above main anyways...) As for the warp issue, to make it work the way YOU want it to, without extensive eventing/pictures/etc. It would need to be a script. Otherwise, to make the menu longer: you would need to use pictures for the names/menu/cursor/etc. then you would need to use loops/conditional branching to determine what's available, etc. I can go into more detail if you'd like. Although, this seems like a useful system I could make..but if I did, I would make it a public release..so if you are cool with me using your idea-I would make a script like this. Share this post Link to post Share on other sites
Silencher 0 Report post Posted September 28, 2011 Yeah I'd be cool with you making it public release, I'd just love to see get it to work, and I have your script above main and AMS, it's below everything else. I also sent you a PM about a probably less complicated script too. Share this post Link to post Share on other sites