I need help eventing or scripting this. I need a way to make a actor appear in party only if a designated item is in your inventory, so when you sell it or lose it, the actor is removed from party, help is much appreciated :)
what would actually also help, if this is easier to script is a way to restrict the sale of an item if you only have a quantity of 1
Whatever is easier to do :)
Actor in Party Reliant on Item in Inventory
● ARCHIVED · READ-ONLY
-
-
If you buy the item, do you want the actor to join your party automatically? How many ways can you obtain or lose the item?
If you're only adding/removing it via events, then you can do the add/remove actor in the same event. If you can buy or sell the item, you need to script it.
You can always make it so you can't sell it (don't have my engine in front of me - not sure if you do that by making it a Key Item, or just setting the price to 0). -
This is a small script I have written:
If you add an item to your inventory the actor corresponding to the item will also be added, and if you remove this item, the actor will also be removed, when you dont have this item anymore.
SpoilerCode:module EE module ActorAsItem #--------------------------------------------------------------------------- ACTORS = [ # Dont edit this line #--------------------------------------------------------------------------- #--------------------------------------------------------------------- # [item_type, item_id, actor_id], # item_type: :item, :weapon, or :armor #--------------------------------------------------------------------- [:weapon, 1, 5], [:item, 1, 3], #--------------------------------------------------------------------------- ] # Dont edit this line #--------------------------------------------------------------------------- def self.items return ACTORS.select{ |arr| arr.first == :item} end def self.weapons return ACTORS.select{ |arr| arr.first == :weapon} end def self.armors return ACTORS.select{ |arr| arr.first == :armor} end def self.get_items(item_class) return items if item_class == RPG::Item return weapons if item_class == RPG::Weapon return armors if item_class == RPG::Armor return [] end def self.get_actor_id(item_class, item_id) get_items(item_class).each do |arr| return arr[2] if arr[1] == item_id end return nil end endendclass Game_Party alias :e222_gp_gi_ias :gain_item def gain_item(item, amount, include_equip = false) e222_gp_gi_ias(item, amount, include_equip) container = item_container(item.class) return unless container actor_id = EE::ActorAsItem.get_actor_id(item.class, item.id) return unless actor_id if item_number(item) > 0 $game_party.add_actor(actor_id) else $game_party.remove_actor(actor_id) if $game_party.all_members.size > 1 end end def actors return @actors endendclass Game_Map alias :e222_gm_update_ias :update def update(update_main = false) e222_gm_update_ias(update_main) check_party_equip end def check_party_equip $game_party.all_members.each do |actor| actor.equips.each do |item| next unless item actor_id = EE::ActorAsItem.get_actor_id(item.class, item.id) next unless actor_id $game_party.add_actor(actor_id) unless $game_party.actors.include?(actor_id) end end endend -
That works beautifully! Thanks so much, I really think this script should get posted in the finished script page, because theres nothing like it out there, again thanks you!This is a small script I have written:
If you add an item to your inventory the actor corresponding to the item will also be added, and if you remove this item, the actor will also be removed, when you dont have this item anymore.
Spoilermodule EE module ActorAsItem #--------------------------------------------------------------------------- ACTORS = [ # Dont edit this line #--------------------------------------------------------------------------- #--------------------------------------------------------------------- # [item_type, item_id, actor_id], # item_type: :item, :weapon, or :armor #--------------------------------------------------------------------- [:weapon, 1, 5], [:item, 1, 3], #--------------------------------------------------------------------------- ] # Dont edit this line #--------------------------------------------------------------------------- def self.items return ACTORS.select{ |arr| arr.first == :item} end def self.weapons return ACTORS.select{ |arr| arr.first == :weapon} end def self.armors return ACTORS.select{ |arr| arr.first == :armor} end def self.get_items(item_class) return items if item_class == RPG::Item return weapons if item_class == RPG::Weapon return armors if item_class == RPG::Armor return [] end def self.get_actor_id(item_class, item_id) get_items(item_class).each do |arr| return arr[2] if arr[1] == item_id end return nil end endendclass Game_Party alias :e222_gp_gi_ias :gain_item def gain_item(item, amount, include_equip = false) e222_gp_gi_ias(item, amount, include_equip) container = item_container(item.class) return unless container actor_id = EE::ActorAsItem.get_actor_id(item.class, item.id) return unless actor_id if item_number(item) > 0 $game_party.add_actor(actor_id) else $game_party.remove_actor(actor_id) if $game_party.all_members.size > 1 end end def actors return @actors endendclass Game_Map alias :e222_gm_update_ias :update def update(update_main = false) e222_gm_update_ias(update_main) check_party_equip end def check_party_equip $game_party.all_members.each do |actor| actor.equips.each do |item| next unless item actor_id = EE::ActorAsItem.get_actor_id(item.class, item.id) next unless actor_id $game_party.add_actor(actor_id) unless $game_party.actors.include?(actor_id) end end endend -
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.