kellessdee 48 Report post Posted March 24, 2011 Hey everyone I was bored and since I was planning to set up a trading system to replace the standard currency for a game I have in planning, I decided to just sit down and git er done. And so I did, and figured I'd share it as well in case anyone would like something similar as well! It doesn't actually replace the standard currency, you can use it as a secondary shop system or something if you want. Using it is simple, just add the script above main It uses a trade module where at the beginning of the script you define what items the trader carries at the "trading post" format: TRADER[x] = [[y, z], [y, z], [y, z] ...] x is the shop id (set id) y would be item type (0 = item, 1 = weapon, 2 = armor) z is the corresponding item id for the item type ex. [0, 1] would be potion by default (if you left the item database alone) the shops can have as many items as you like TO CALL THE SCRIPT: Just set up the event that you want to activate the trading script, and choose "call script" and type: $scene = Scene_Trading.new(x) x is one of shop id's you defined in the Trade::TRADER module and presto once the even activates the trade shop will open. If you want you can even put in a choice "Would you like to Trade?" [YES]then call script ... [NO] do nothing... etc... CONTROLS: first you select "make offer" where then you will be sent to the Trade Goods section, you can add as many items as you like L/R (Q/W on the keyboard) switches between your items and the traders items while in one of the item menus. LEFT arrow key will send you to either "Your Offer" section (left while on your items) or to "Target" section (left while on trade goods) while in either of these menus you can remove items you've chosen. once you have made up your mind (and when your offered value is >= the target value, the menu will display DEAL! over the values) you simply press cancel button (X or esc) to return to the trade menu and select "Trade" then confirm and voila you now have the new items. SCREENSHOTS CODE =begin ============================================================================== ***** TRADING POST DATA ****************************************************** * This module contains trading post item availability * The data is contained in an array of arrays, * the format is as follows: * TRADER[x] = [[item_type, item_id], [item_type, item_id], ...] * item_type being 0 = item, 1 = weapon, 2 = armor * item_id is the corresponding item number in the database * to call the trading screen, set up an event that when * activated it calls a script, and that script would be * $scene = Scene_Trading.new(trader_id) * trader_id being the corresponding trader data as defined in this module * script by kellessdee ****************************************************************************** =end module Trade # Trader array TRADER = [] # Enter trader data here: TRADER[0] = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [1, 6], [1, 7]] TRADER[1] = [[1, 5], [1, 6], [1, 8], [1, 9], [2, 0], [2, 3], [2, 4], [2, 7]] end #============================================================================== # ** Window_TradeHelp #------------------------------------------------------------------------------ # This window shows skill and item explanations along with actor status. #============================================================================== class Window_TradeHelp < Window_Base #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize super(0, 0, 640, 64) self.contents = Bitmap.new(self.width - 32, self.height - 32) end #-------------------------------------------------------------------------- # * Set Text # text : text string displayed in window # qty : quantity in inventory of current item #-------------------------------------------------------------------------- def set_text(text, qty) # If at least one part of text and alignment differ from last time if text != @text or qty != @qty # Redraw text self.contents.clear self.contents.font.color = normal_color self.contents.draw_text(4, 0, self.width - 40, 32, text) if qty > 0 self.contents.draw_text(4, 0, self.width - 40, 32, 'In Possession: ' + qty.to_s, 2) end @text = text @qty = qty end self.visible = true end end #============================================================================= # ** Window_Title #----------------------------------------------------------------------------- # Draws Titles on headers #============================================================================= class Window_Title < Window_Base #--------------------------------------------------------------------------- # * Object Initialization #--------------------------------------------------------------------------- def initialize(x, y, title) super(x, y - 16, 160, 64) self.contents = Bitmap.new(self.width - 32, self.height - 32) self.opacity = 0 set_title(title) end #--------------------------------------------------------------------------- # * Set title #--------------------------------------------------------------------------- def set_title(title) self.contents.clear self.contents.draw_text(4, 0, self.width - 40, 32, title) end end #============================================================================= # ** Window_Header #----------------------------------------------------------------------------- # Draws headers on trading windows #============================================================================= class Window_Header < Window_Base #--------------------------------------------------------------------------- # * Object Initialization #--------------------------------------------------------------------------- def initialize(x, y) super(x, y, 160, 32) end end #============================================================================= # ** Window_Options #----------------------------------------------------------------------------- # Handles trading confirmation #============================================================================= class Window_Options < Window_Command #--------------------------------------------------------------------------- # * Object Initialization #--------------------------------------------------------------------------- def initialize(commands) super(200, commands) self.x = 16 self.y = 112 self.z += 100 end end #============================================================================= # ** Window_TradeCommands #----------------------------------------------------------------------------- # Handles main trading options #============================================================================= class Window_TradeCommands < Window_Selectable #--------------------------------------------------------------------------- # * Object Initialization #--------------------------------------------------------------------------- def initialize super(0, 64, 640, 64) self.contents = Bitmap.new(self.width - 32, self.height - 32) @column_max = 3 @item_max = 3 self.index = 0 self.active = true refresh(false) end #--------------------------------------------------------------------------- # * Refresh frame #--------------------------------------------------------------------------- def refresh(deal) self.contents.clear self.contents.font.color = normal_color self.contents.draw_text(0, 0, 176, 32, 'Make Offer', 1) self.contents.draw_text(408, 0, 204, 32, 'Cancel', 1) self.contents.font.color = disabled_color unless deal self.contents.draw_text(200, 0, 200, 32, 'Trade', 1) end #-------------------------------------------------------------------------- # * Update Help Window #-------------------------------------------------------------------------- def update_help case self.index when 0 # Make Offer text = 'Select items to bargain for' when 1 # Trade text = 'Confirm deal and trade items' when 2 # Cancel text = 'Leave trading post' end self.help_window.set_text(text, 0) end end #============================================================================= # ** Window_Deal #----------------------------------------------------------------------------- # This window displays total values for offer and target #============================================================================= class Window_Deal < Window_Base #--------------------------------------------------------------------------- # * Object Initialization #--------------------------------------------------------------------------- def initialize super(0, 128, 320, 96) @offer = 0 @target = 0 self.contents = Bitmap.new(self.width - 32, self.height - 32) refresh(@offer, @target) end #--------------------------------------------------------------------------- # * Refresh Contents # offer : Player's offer value # target : Trading target value #--------------------------------------------------------------------------- def refresh(offer, target) @offer, @target = offer, target self.contents.clear self.contents.font.color = system_color self.contents.draw_text(4, 0, 284, 32, 'Current Offer Value:') self.contents.draw_text(4, 32, 284, 32, 'Current Target Value:') self.contents.font.color = normal_color self.contents.draw_text(4, 0, 284, 32, offer.to_s, 2) self.contents.draw_text(4, 32, 284, 32, target.to_s, 2) if deal? && offer > 0 && target > 0 font_size = self.contents.font.size self.contents.font.size = 36 self.contents.font.color = text_color(3) self.contents.draw_text(4, 16, 284, 32, 'DEAL!', 2) self.contents.font.size = font_size end end #--------------------------------------------------------------------------- # * Deal? #--------------------------------------------------------------------------- def deal? return @offer >= @target end end #============================================================================= # ** Window_Target #----------------------------------------------------------------------------- # This window handles the items player wishes to trade for #============================================================================= class Window_TradeTarget < Window_Selectable #--------------------------------------------------------------------------- # * Public Instance Variables #--------------------------------------------------------------------------- attr_reader :value # Total target value #--------------------------------------------------------------------------- # * Object Initialization #--------------------------------------------------------------------------- def initialize super(0, 352, 320, 128) @items = [] @value = 0 refresh self.active = false self.index = -1 end #--------------------------------------------------------------------------- # * Get current item #--------------------------------------------------------------------------- def item return @data[self.index] end #--------------------------------------------------------------------------- # * Clear Window #--------------------------------------------------------------------------- def clear @items.clear @value = 0 refresh end #--------------------------------------------------------------------------- # * Add Item #--------------------------------------------------------------------------- def add(item) @items.push(item) end #--------------------------------------------------------------------------- # * Remove Item #--------------------------------------------------------------------------- def rem(item) for i in 0...@items.size if @items[i] == item @items.delete_at(i) return end end end #--------------------------------------------------------------------------- # * Refresh Contents #--------------------------------------------------------------------------- def refresh # Clear contents if self.contents != nil self.contents.clear self.contents = nil end # reset value @value = 0 # Add current items if any have been offered if @items != nil @data = [] for i in 0...@items.size @data.push(@items[i]) @value += @items[i].price end end @item_max = @data.size # Draw items if @item_max > 0 self.contents = Bitmap.new(self.width - 32, @item_max * 32) for i in 0...@item_max draw_item(i) end end end #--------------------------------------------------------------------------- # * Draw Item #--------------------------------------------------------------------------- def draw_item(index) # get item data item = @data[index] # draw items number = item.price.to_s bitmap = RPG::Cache.icon(item.icon_name) x = 4 y = index * 32 self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24)) self.contents.draw_text(x + 28, y, 200, 32, item.name) self.contents.draw_text(x, y, 280, 32, number, 2) end #-------------------------------------------------------------------------- # * Gain Items #-------------------------------------------------------------------------- def gain_items for i in 0...@items.size case @items[i] when RPG::Item $game_party.gain_item(@items[i].id, 1) when RPG::Weapon $game_party.gain_weapon(@items[i].id, 1) when RPG::Armor $game_party.gain_armor(@items[i].id, 1) end end end #-------------------------------------------------------------------------- # * Help Text Update #-------------------------------------------------------------------------- def update_help item = self.item if item == nil text = '' qty = 0 else case item when RPG::Item qty = $game_party.item_number(item.id) when RPG::Weapon qty = $game_party.weapon_number(item.id) when RPG::Armor qty = $game_party.armor_number(item.id) end text = item.description end self.help_window.set_text(text, qty) end end #============================================================================= # ** Window_Offer #----------------------------------------------------------------------------- # This window handles player's items they wish to trade #============================================================================= class Window_Offer < Window_Selectable #--------------------------------------------------------------------------- # * Public Instance Variables #--------------------------------------------------------------------------- attr_reader :value # Total offer value attr_reader :item_max # Total items in list #--------------------------------------------------------------------------- # * Object Initialization #--------------------------------------------------------------------------- def initialize super(0, 224, 320, 128) @items = [] @value = 0 refresh self.active = false self.index = -1 end #--------------------------------------------------------------------------- # * Get current item #--------------------------------------------------------------------------- def item return @data[self.index] end #--------------------------------------------------------------------------- # * Clear Window #--------------------------------------------------------------------------- def clear @items.clear @value = 0 refresh end #--------------------------------------------------------------------------- # * Add Item #--------------------------------------------------------------------------- def add(item) @items.push(item) end #--------------------------------------------------------------------------- # * Remove Item #--------------------------------------------------------------------------- def rem(item) for i in 0...@items.size if @items[i] == item @items.delete_at(i) return end end end #--------------------------------------------------------------------------- # * Refresh Contents #--------------------------------------------------------------------------- def refresh # Clear contents if self.contents != nil self.contents.clear self.contents = nil end # reset value @value = 0 # Add current items if any have been offered if @items != nil @data = [] for i in 0...@items.size @data.push(@items[i]) @value += @items[i].price end end @item_max = @data.size # Draw items if @item_max > 0 self.contents = Bitmap.new(self.width - 32, @item_max * 32) for i in 0...@item_max draw_item(i) end end end #--------------------------------------------------------------------------- # * Draw Item #--------------------------------------------------------------------------- def draw_item(index) # get item data item = @data[index] # draw items number = item.price.to_s bitmap = RPG::Cache.icon(item.icon_name) x = 4 y = index * 32 self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24)) self.contents.draw_text(x + 28, y, 200, 32, item.name) self.contents.draw_text(x, y, 280, 32, number, 2) end #-------------------------------------------------------------------------- # * Help Text Update #-------------------------------------------------------------------------- def update_help item = self.item if item == nil text = '' qty = 0 else case item when RPG::Item qty = $game_party.item_number(item.id) when RPG::Weapon qty = $game_party.weapon_number(item.id) when RPG::Armor qty = $game_party.armor_number(item.id) end text = item.description end self.help_window.set_text(text, qty) end end #============================================================================= # ** Window_TradeGoods #----------------------------------------------------------------------------- # This window displays items trader has for trade #============================================================================= class Window_TradeGoods < Window_Selectable #--------------------------------------------------------------------------- # * Object Initialization # trader_id : refers to trader index as defined in Trade module #--------------------------------------------------------------------------- def initialize(trader_id) super(320, 128, 320, 352) @trade_data = Trade::TRADER[trader_id] refresh self.active = false self.index = -1 self.visible = true end #--------------------------------------------------------------------------- # * Get current item #--------------------------------------------------------------------------- def item return @data[self.index] end #--------------------------------------------------------------------------- # * Refresh contents #--------------------------------------------------------------------------- def refresh # Clear contents if self.contents != nil self.contents.clear self.contents = nil end # Add item data @data = [] for i in 0...@trade_data.size case @trade_data[i][0] when 0 # Item @data.push($data_items[@trade_data[i][1]]) when 1 # Weapon @data.push($data_weapons[@trade_data[i][1]]) when 2 # Armor @data.push($data_armors[@trade_data[i][1]]) end end @item_max = @data.size # Draw items if @item_max > 0 self.contents = Bitmap.new(self.width - 32, @item_max * 32) for i in 0...@item_max draw_item(i) end end end #--------------------------------------------------------------------------- # * Draw Item #--------------------------------------------------------------------------- def draw_item(index) # Get item data item = @data[index] # Get item value number = item.price.to_s # Draw items x = 4 y = index * 32 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) self.contents.draw_text(x, y, 280, 32, number, 2) end #--------------------------------------------------------------------------- # * Get item value #--------------------------------------------------------------------------- def price return self.item.price end #-------------------------------------------------------------------------- # * Help Text Update #-------------------------------------------------------------------------- def update_help item = self.item if item == nil text = '' qty = 0 else case item when RPG::Item qty = $game_party.item_number(item.id) when RPG::Weapon qty = $game_party.weapon_number(item.id) when RPG::Armor qty = $game_party.armor_number(item.id) end text = item.description end self.help_window.set_text(text, qty) end end #============================================================================= # ** Window_PartyItems #----------------------------------------------------------------------------- # This window displays party items available for trade #============================================================================= class Window_PartyItems < Window_Selectable #--------------------------------------------------------------------------- # * Object Initialization #--------------------------------------------------------------------------- def initialize super(320, 128, 320, 352) refresh self.active = false self.index = -1 end #--------------------------------------------------------------------------- # * Get current item #--------------------------------------------------------------------------- def item return @data[self.index] end #--------------------------------------------------------------------------- # * Refresh Contents #--------------------------------------------------------------------------- def refresh # Clear contents if self.contents != nil self.contents.clear self.contents = nil end # Get Item data @data = [] # Add Items for i in 0...$data_items.size if $game_party.item_number(i) > 0 @data.push($data_items[i]) end end # Add Weapons for i in 0...$data_weapons.size if $game_party.weapon_number(i) > 0 @data.push($data_weapons[i]) end end # Add Armors for i in 0...$data_armors.size if $game_party.armor_number(i) > 0 @data.push($data_armors[i]) end end @item_max = @data.size # If more than one item is possessed if @item_max > 0 # Create bitmap self.contents = Bitmap.new(self.width - 32, @item_max * 32) # Draw items for i in 0...@item_max draw_item(i) end end end #-------------------------------------------------------------------------- # * Draw Item #-------------------------------------------------------------------------- def draw_item(index) # Get item data item = @data[index] # Get value number = item.price.to_s # Draw items x = 4 y = index * 32 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) self.contents.draw_text(x, y, 280, 32, number, 2) end #-------------------------------------------------------------------------- # * Get Item price of current item #-------------------------------------------------------------------------- def price return self.item.price end #-------------------------------------------------------------------------- # * Help Text Update #-------------------------------------------------------------------------- def update_help item = self.item if item == nil text = '' qty = 0 else case item when RPG::Item qty = $game_party.item_number(item.id) when RPG::Weapon qty = $game_party.weapon_number(item.id) when RPG::Armor qty = $game_party.armor_number(item.id) end text = item.description end self.help_window.set_text(text, qty) end end #============================================================================ # ** Scene_Trading #---------------------------------------------------------------------------- # This scene handles the trading screen #============================================================================ class Scene_Trading #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize(trader_id=0) @trader_id = trader_id end #-------------------------------------------------------------------------- # * Main Processing #-------------------------------------------------------------------------- def main # Draw Windows @trade_goods = Window_TradeGoods.new(@trader_id) @party_items = Window_PartyItems.new @party_items.visible = false @offer_window = Window_Offer.new @target_window = Window_TradeTarget.new @deal_window = Window_Deal.new @trade_commands = Window_TradeCommands.new @help_window = Window_TradeHelp.new # Associate help window @trade_goods.help_window = @help_window @party_items.help_window = @help_window @offer_window.help_window = @help_window @target_window.help_window = @help_window @trade_commands.help_window = @help_window # Draw Window Headers items_header = Window_Header.new(320, 112) @items_title = Window_Title.new(items_header.x, items_header.y, 'Trade Goods') offer_header = Window_Header.new(0, 208) offer_title = Window_Title.new(offer_header.x, offer_header.y, 'Your Offer') target_header = Window_Header.new(0, 336) target_title = Window_Title.new(target_header.x, target_header.y, 'Target') # Excecute Transition Graphics.transition # main loop loop do # Update Graphics Graphics.update # Update Input Input.update # Update frame update # if scene has changed if $scene != self break end end # Prepare Transition Graphics.freeze # Dispose windows @trade_goods.dispose @party_items.dispose @offer_window.dispose @target_window.dispose @deal_window.dispose @trade_commands.dispose @help_window.dispose items_header.dispose offer_header.dispose target_header.dispose target_title.dispose offer_title.dispose @items_title.dispose end #--------------------------------------------------------------------------- # * Update Frame #--------------------------------------------------------------------------- def update # Update active windows if @trade_goods.visible @items_title.set_title('Trade Goods') else @items_title.set_title('Your Items') end @items_title.update @help_window.update if @trade_commands.active @trade_commands.update update_main return elsif @trade_goods.active @trade_goods.update update_trade_goods return elsif @party_items.active @party_items.update update_party_items return elsif @offer_window.active @offer_window.update update_offer_window return elsif @target_window.active @target_window.update update_target_window return end end #--------------------------------------------------------------------------- # * Update Trade Commands #--------------------------------------------------------------------------- def update_main # If b button is pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) # Return to map $scene = Scene_Map.new return end # if c button is pressed if Input.trigger?(Input::C) case @trade_commands.index when 0 # Make offer # Play decision SE $game_system.se_play($data_system.decision_se) # Switch to Trade goods/Party Item @trade_commands.active = false @trade_commands.index = -1 if @trade_goods.visible == true @trade_goods.index = 0 @trade_goods.active = true return else @party_items.index = 0 @party_items.active = true return end when 1 # Trade if @offer_window.value > 0 && @target_window.value > 0 && @deal_window.deal? # Play decision SE $game_system.se_play($data_system.decision_se) # Confirm trade confirm_trade return else # Play buzzer SE $game_system.se_play($data_system.buzzer_se) return end when 2 # Cancel # Play decision SE $game_system.se_play($data_system.decision_se) # Return to map $scene = Scene_Map.new return end end end #-------------------------------------------------------------------------- # * Update Trade Goods #-------------------------------------------------------------------------- def update_trade_goods # if b button is pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) # return to trade commands @trade_goods.active = false @trade_goods.index = -1 @trade_commands.active = true @trade_commands.index = @deal_window.deal? && @offer_window.value > 0 && @target_window.value > 0 ? 1 : 0 return end # if c button is pressed if Input.trigger?(Input::C) # Play decision SE $game_system.se_play($data_system.cancel_se) # Confirm Addition confirm_item(@trade_goods.item, 'Add', 'Cancel') return end # if L or R button is pressed if Input.trigger?(Input::L) || Input.trigger?(Input::R) # Play cursor SE $game_system.se_play($data_system.cursor_se) # Switch to party items @trade_goods.active = false @trade_goods.index = -1 @trade_goods.visible = false @party_items.active = true @party_items.index = 0 @party_items.visible = true return end # if Left Button is pressed if Input.trigger?(Input::LEFT) # Play cursor SE $game_system.se_play($data_system.cursor_se) # Switch to target window @trade_goods.active = false @trade_goods.index = -1 @target_window.active = true @target_window.index = 0 return end end #-------------------------------------------------------------------------- # * Update Party Items #-------------------------------------------------------------------------- def update_party_items # if b button is pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) # switch to trade commands @party_items.active = false @party_items.index = -1 @trade_commands.active = true @trade_commands.index = @deal_window.deal? && @offer_window.value > 0 && @target_window.value > 0 ? 1 : 0 return end # if c button is pressed if Input.trigger?(Input::C) # Play decision SE $game_system.se_play($data_system.decision_se) # Confirm addition confirm_item(@party_items.item, 'Add', 'Cancel') return end # if L or R button is pressed if Input.trigger?(Input::L) || Input.trigger?(Input::R) # Play cursor SE $game_system.se_play($data_system.cursor_se) # Switch to trade goods @party_items.active = false @party_items.index = -1 @party_items.visible = false @trade_goods.active = true @trade_goods.index = 0 @trade_goods.visible = true return end # if Left button is pressed if Input.trigger?(Input::LEFT) # Play cursor SE $game_system.se_play($data_system.cursor_se) # Switch to offer window @party_items.active = false @party_items.index = -1 @offer_window.index = 0 @offer_window.active = true return end end #-------------------------------------------------------------------------- # * Update Offer Window #-------------------------------------------------------------------------- def update_offer_window # if B button is pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) # switch to trade commands @offer_window.active = false @offer_window.index = -1 @trade_commands.active = true @trade_commands.index = @deal_window.deal? && @offer_window.value > 0 && @target_window.value > 0 ? 1 : 0 return end # if C button is pressed if Input.trigger?(Input::C) # Play decision SE $game_system.se_play($data_system.decision_se) # confirm offer removal confirm_item(@offer_window.item, 'Remove', 'Cancel') return end # if Right button is pressed if Input.trigger?(Input::RIGHT) # Play cursor SE $game_system.se_play($data_system.cursor_se) # switch to party items screen @offer_window.index = -1 @offer_window.active = false @party_items.index = 0 @party_items.active = true return end # if L or R buttons are pressed if Input.trigger?(Input::L) || Input.trigger?(Input::R) # Play cursor SE $game_system.se_play($data_system.cursor_se) # switch to target window and redisplay trade goods @offer_window.index = -1 @offer_window.active = false @party_items.visible = false @trade_goods.visible = true @target_window.active = true @target_window.index = 0 return end end #-------------------------------------------------------------------------- # * Update Target Window #-------------------------------------------------------------------------- def update_target_window # if B button is pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) # switch to trade commands @target_window.active = false @target_window.index = -1 @trade_commands.active = true @trade_commands.index = @deal_window.deal? && @offer_window.value > 0 && @target_window.value > 0 ? 1 : 0 return end # if C button is pressed if Input.trigger?(Input::C) # Play decision SE $game_system.se_play($data_system.decision_se) # confirm remove target item confirm_item(@target_window.item, 'Remove', 'Cancel') return end # if RIGHT Button is pressed if Input.trigger?(Input::RIGHT) # Play cursor SE $game_system.se_play($data_system.cursor_se) # switch to trade goods @target_window.index = -1 @target_window.active = false @trade_goods.index = 0 @trade_goods.active = true return end # if L or R button is pressed if Input.trigger?(Input::L) || Input.trigger?(Input::R) # Play cursor SE $game_system.se_play($data_system.cursor_se) # switch to offer window and redisplay party items @target_window.active = false @target_window.index = -1 @trade_goods.visible = false @party_items.visible = true @offer_window.index = 0 @offer_window.active = true return end end #-------------------------------------------------------------------------- # * Confirm Trade #-------------------------------------------------------------------------- def confirm_trade option = Window_Options.new(['Confirm', 'Cancel']) # Confirmation loop loop do # Update Graphics Graphics.update # Update input Input.update # update options option.update # if B button is pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) # dispose option window option.dispose return end # if C button is pressed if Input.trigger?(Input::C) # Play Equip SE $game_system.se_play($data_system.equip_se) # Add items @target_window.gain_items # clear target and offer @offer_window.clear @target_window.clear # refresh @deal_window.refresh(0, 0) @trade_commands.refresh(false) @party_items.refresh # dispose option window option.dispose return end end end #-------------------------------------------------------------------------- # * Confirm Item add/remove #-------------------------------------------------------------------------- def confirm_item(item, c1, c2) if item == nil # Play buzzer SE $game_system.se_play($data_system.buzzer_se) return end option = Window_Options.new([c1, c2]) # confirmation loop loop do # Update Graphics Graphics.update # Update Input Input.update # update options option.update # if B button is pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) # dispose option window option.dispose return end # if C button is pressed if Input.trigger?(Input::C) case option.index when 0 # Add/Remove if @trade_goods.active # Play equip SE $game_system.se_play($data_system.equip_se) # Add item to target @target_window.add(item) # Refresh windows @target_window.refresh @deal_window.refresh(@offer_window.value, @target_window.value) if @offer_window.value > 0 && @target_window.value > 0 && @deal_window.deal? @trade_commands.refresh(true) else @trade_commands.refresh(false) end # dispose option window option.dispose return elsif @party_items.active # Play equip SE $game_system.se_play($data_system.equip_se) # Add item to offer @offer_window.add(item) # Remove item from inventory case item when RPG::Item $game_party.lose_item(item.id, 1) when RPG::Weapon $game_party.lose_weapon(item.id, 1) when RPG::Armor $game_party.lose_armor(item.id, 1) end # Refresh windows @party_items.refresh @offer_window.refresh @deal_window.refresh(@offer_window.value, @target_window.value) if @offer_window.value > 0 && @target_window.value > 0 && @deal_window.deal? @trade_commands.refresh(true) else @trade_commands.refresh(false) end # dispose option window option.dispose return elsif @offer_window.active # Play equip SE $game_system.se_play($data_system.equip_se) # Remove item from offer @offer_window.rem(item) # Add item to inventory case item when RPG::Item $game_party.gain_item(item.id, 1) when RPG::Weapon $game_party.gain_weapon(item.id, 1) when RPG::Armor $game_party.gain_armor(item.id, 1) end # Refresh windows @party_items.refresh @offer_window.index = 0 @offer_window.refresh @deal_window.refresh(@offer_window.value, @target_window.value) if @offer_window.value > 0 && @target_window.value > 0 && @deal_window.deal? @trade_commands.refresh(true) else @trade_commands.refresh(false) end # dispose option window option.dispose return elsif @target_window.active # Play equip SE $game_system.se_play($data_system.equip_se) # remove item from target @target_window.rem(item) # Refresh windows @target_window.index = 0 @target_window.refresh @deal_window.refresh(@offer_window.value, @target_window.value) if @offer_window.value > 0 && @target_window.value > 0 && @deal_window.deal? @trade_commands.refresh(true) else @trade_commands.refresh(false) end # dispose option window option.dispose return end when 1 # Cancel # Play decision SE $game_system.se_play($data_system.decision_se) option.dispose return end end end end end Demo: http://www.megaupload.com/?d=TBNKDUAP *NOTE* This should be compatible with any other scripts *as long* as you haven't modified the original windows, game party, etc...scripts too much (well really as long as you haven't REMOVED anything from these scripts, adding things SHOULD not cause any interference) Share this post Link to post Share on other sites