Looking for a script or snippet that would allow for items to be traded or switched between parties with separate inventories.
If any more details are needed I will do my best to post on time.
Are you using a script with separate inventories? Because I don't remember RMXP being able to do that by default.
EDIT: well, assuming you didn't have any scripts, this is what I would do:
class Game_Party
alias initialize_splititems_later initialize
def initialize
@items_split = {}
end
# switches to the items of the other party
def switch_items
tempitems = @items_split
@items_split = @items
@items = tempitems
end
# current: true if trading from the current party to the inactive party,
# false if trading from the inactive party to the current party.
# itemid: ID of item in database
# n: number of item to trade
def trade(current, item_id, n)
switch_items if !current
lose_item(item_id, n)
switch_items
gain_item(item_id, n)
switch_items if current
end
end
pasting this below the default scripts, you have two new script calls:
$game_party.switch_items, which switches the active inventory every time you switch from the first party to the second.
$game_party.trade(current, item_id, n), which trades items between the parties.
Thanks Winkio! And I had been using the game_party trick from the 'Blizzard's Little Tricks' tutorial.
Anyway, I'll get right to implementing this
If you want the trade method for the way it works in Blizzard's tricks:
class Game_Party
# var_from: id of variable with the party that the item is being taken from
# var_to: id of variable with the party that the item is being given to
# itemid: ID of item in database
# n: number of item to trade
def trade(var_from, var_to, item_id, n)
$game_variables[var_from].lose_item(item_id, n)
$game_variables[var_to].gain_item(item_id, n)
end
end
It doesn't matter which party is active as long as you are storing them in separate variables.
Oh alright thanks! You've really helped on making the scenes easier to manage. Im exceedingly grateful :)