Jump to content
Sign in to follow this  
nickfitzgerald3

Actor in Party Reliant on Item in Inventory

Recommended Posts

I need help eventing or scripting this. I 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 :)

Share this post


Link to post
Share on other sites

for Armors:

 

 

# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Actor Adding Armor
# Version 1.0
# Author: Soulpour777
# Web URL: infinitytears.wordpress.com
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Description:
# This script allows an armor check where if the main character / leader
# owns and equips a certain weapon, a member of the party is added, else,
# that member of the party is automatically removed.
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
module Soulpour
  module ActorArmor
    # What armor ID / Number in the database do you want to be checked?
    Unique_Item_ID = 9
    # Who among the actors (based on ID) do you want to add?
    Actor_Added = 2 # in this case, Natalie
    # Who is your main character?
    Main_Character = 0 #in this case, the leader of your party.
  end
end

#==============================================================================
# ** Game_System
#------------------------------------------------------------------------------
#  This class handles system data. It saves the disable state of saving and 
# menus. Instances of this class are referenced by $game_system.
#==============================================================================
class Game_System
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------  
  attr_accessor :actor_added
  
  #--------------------------------------------------------------------------
  # * Object Initialization (Aliased)
  #--------------------------------------------------------------------------  
  alias change_equip_add_actor_int initialize
  def initialize
    change_equip_add_actor_int
   @actor_added = false 
  end
  
  #--------------------------------------------------------------------------
  # * Change Value for Actor Added
  #--------------------------------------------------------------------------  
  def change_actor_added(args)
    @actor_added = args
  end
  
end

#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
#  This class performs the map screen processing.
#==============================================================================

class Scene_Map < Scene_Base
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------  
  alias change_equip_add_actor_update update
  #--------------------------------------------------------------------------
  # * Frame Update (Aliased)
  #--------------------------------------------------------------------------
  def update
    change_equip_add_actor_update
    detect_equipment
  end
  
  #--------------------------------------------------------------------------
  # * Detect Equipment
  #--------------------------------------------------------------------------  
  def detect_equipment
    if $game_party.members[Soulpour::ActorArmor::Main_Character].armor_equipped?(Soulpour::ActorArmor::Unique_Item_ID)
      if $game_system.actor_added == false
        $game_party.add_actor(Soulpour::ActorArmor::Actor_Added)
        $game_system.change_actor_added(true)
      end
    else
      $game_party.remove_actor(Soulpour::ActorArmor::Actor_Added)
      $game_system.change_actor_added(false)
    end
    
  end
  
end

#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
#  This class handles actors. It is used within the Game_Actors class
# ($game_actors) and is also referenced from the Game_Party class ($game_party).
#==============================================================================
class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # * Armor Equipped Command
  #--------------------------------------------------------------------------  
  def armor_equipped?(armor_id)
    armors.any? {|armor| armor.id == armor_id }
  end
end 

 

 

Share this post


Link to post
Share on other sites

for Armors:

 

 

# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Actor Adding Armor
# Version 1.0
# Author: Soulpour777
# Web URL: infinitytears.wordpress.com
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Description:
# This script allows an armor check where if the main character / leader
# owns and equips a certain weapon, a member of the party is added, else,
# that member of the party is automatically removed.
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
module Soulpour
  module ActorArmor
    # What armor ID / Number in the database do you want to be checked?
    Unique_Item_ID = 9
    # Who among the actors (based on ID) do you want to add?
    Actor_Added = 2 # in this case, Natalie
    # Who is your main character?
    Main_Character = 0 #in this case, the leader of your party.
  end
end

#==============================================================================
# ** Game_System
#------------------------------------------------------------------------------
#  This class handles system data. It saves the disable state of saving and 
# menus. Instances of this class are referenced by $game_system.
#==============================================================================
class Game_System
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------  
  attr_accessor :actor_added
  
  #--------------------------------------------------------------------------
  # * Object Initialization (Aliased)
  #--------------------------------------------------------------------------  
  alias change_equip_add_actor_int initialize
  def initialize
    change_equip_add_actor_int
   @actor_added = false 
  end
  
  #--------------------------------------------------------------------------
  # * Change Value for Actor Added
  #--------------------------------------------------------------------------  
  def change_actor_added(args)
    @actor_added = args
  end
  
end

#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
#  This class performs the map screen processing.
#==============================================================================

class Scene_Map < Scene_Base
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------  
  alias change_equip_add_actor_update update
  #--------------------------------------------------------------------------
  # * Frame Update (Aliased)
  #--------------------------------------------------------------------------
  def update
    change_equip_add_actor_update
    detect_equipment
  end
  
  #--------------------------------------------------------------------------
  # * Detect Equipment
  #--------------------------------------------------------------------------  
  def detect_equipment
    if $game_party.members[Soulpour::ActorArmor::Main_Character].armor_equipped?(Soulpour::ActorArmor::Unique_Item_ID)
      if $game_system.actor_added == false
        $game_party.add_actor(Soulpour::ActorArmor::Actor_Added)
        $game_system.change_actor_added(true)
      end
    else
      $game_party.remove_actor(Soulpour::ActorArmor::Actor_Added)
      $game_system.change_actor_added(false)
    end
    
  end
  
end

#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
#  This class handles actors. It is used within the Game_Actors class
# ($game_actors) and is also referenced from the Game_Party class ($game_party).
#==============================================================================
class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # * Armor Equipped Command
  #--------------------------------------------------------------------------  
  def armor_equipped?(armor_id)
    armors.any? {|armor| armor.id == armor_id }
  end
end 

 

 

That script works well, but It doesnt really work for my situation, I need it to add the actor just by being present in your inventory, and removes actor when you sell it, the need to equip conflicts with my current set up

Share this post


Link to post
Share on other sites

If you don't mind about having a parallel process running this can be achieved very easily with a Conditional Branch (if Item X is in inventory add actor X / else remove it).

Share this post


Link to post
Share on other sites

for Armors:

 

 

# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Actor Adding Armor
# Version 1.0
# Author: Soulpour777
# Web URL: infinitytears.wordpress.com
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Description:
# This script allows an armor check where if the main character / leader
# owns and equips a certain weapon, a member of the party is added, else,
# that member of the party is automatically removed.
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
module Soulpour
  module ActorArmor
    # What armor ID / Number in the database do you want to be checked?
    Unique_Item_ID = 9
    # Who among the actors (based on ID) do you want to add?
    Actor_Added = 2 # in this case, Natalie
    # Who is your main character?
    Main_Character = 0 #in this case, the leader of your party.
  end
end

#==============================================================================
# ** Game_System
#------------------------------------------------------------------------------
#  This class handles system data. It saves the disable state of saving and 
# menus. Instances of this class are referenced by $game_system.
#==============================================================================
class Game_System
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------  
  attr_accessor :actor_added
  
  #--------------------------------------------------------------------------
  # * Object Initialization (Aliased)
  #--------------------------------------------------------------------------  
  alias change_equip_add_actor_int initialize
  def initialize
    change_equip_add_actor_int
   @actor_added = false 
  end
  
  #--------------------------------------------------------------------------
  # * Change Value for Actor Added
  #--------------------------------------------------------------------------  
  def change_actor_added(args)
    @actor_added = args
  end
  
end

#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
#  This class performs the map screen processing.
#==============================================================================

class Scene_Map < Scene_Base
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------  
  alias change_equip_add_actor_update update
  #--------------------------------------------------------------------------
  # * Frame Update (Aliased)
  #--------------------------------------------------------------------------
  def update
    change_equip_add_actor_update
    detect_equipment
  end
  
  #--------------------------------------------------------------------------
  # * Detect Equipment
  #--------------------------------------------------------------------------  
  def detect_equipment
    if $game_party.members[Soulpour::ActorArmor::Main_Character].armor_equipped?(Soulpour::ActorArmor::Unique_Item_ID)
      if $game_system.actor_added == false
        $game_party.add_actor(Soulpour::ActorArmor::Actor_Added)
        $game_system.change_actor_added(true)
      end
    else
      $game_party.remove_actor(Soulpour::ActorArmor::Actor_Added)
      $game_system.change_actor_added(false)
    end
    
  end
  
end

#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
#  This class handles actors. It is used within the Game_Actors class
# ($game_actors) and is also referenced from the Game_Party class ($game_party).
#==============================================================================
class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # * Armor Equipped Command
  #--------------------------------------------------------------------------  
  def armor_equipped?(armor_id)
    armors.any? {|armor| armor.id == armor_id }
  end
end 

 

 

hey so this does work but I found now that for whatever reason your script gives me this error only when I try to run a Battle Test

 

Script 'Cache' line 88 :NoMethodError occured

 

Undefined method `empty?' for nil:NilClass

 

If you don't mind about having a parallel process running this can be achieved very easily with a Conditional Branch (if Item X is in inventory add actor X / else remove it).

 
Wow, I prefered to script it but since i ran into that problem, The parralel process works a lot better, never thought to do that
Edited by nickfitzgerald3

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted