[Unsupported] Actor & Party's Self Switches XP
#1
Actor & Party's Self Switches XP
Version: 1

Introduction
This script is a tad similar to that of the built in feature: Self Switches. For those not familiar with Self Switches, Self Switches pretty much pertain to a specific event. Example: Treasure Chests.

Actor & Party Self Switches allows developers to set certain switches pertaining to a certain party member or actor.

Let's say, you set a switch to Party Member 1 (Aluxes) to true. In case you ever change party members, the switch will still be turned on for that member in the party (Aluxes).

Or how about if you want to set a certain switch for a specific actor instead of a member in the party. You can do that as well!

Features
  • Set party member's self switches via call script.
  • Get party member's self switches via call script.
  • Set actor's self switches via call script.
  • Get actor's self switches via call script.

Screenshots
I can't screencap this.

Demo
No demo.

Script
Code:
=begin
?????????????????????????????????????????????????????????????????????????????????
? Actor & Party Self Switches XP                                               ?
? Version 1.0                                                                  ?
? by PK8 & Kain Nobel                                                          ?
? 9/16/09                                                                      ?
? http://rmvxp.com                                                             ?
?????????????????????????????????????????????????????????????????????????????????
? ? Table of Contents                                                          ?
? ?? Author's Notes                - Line 18?22                                ?
? ?? Introduction & Description    - Line 24?37                                ?
? ?? Features                      - Line 39?43                                ?
? ?? How to Use                    - Line 45?90                                ?
? ?? This aliases the following... - Line 92,93                                ?
? ?? Thanks                        - Line 95?98                                ?
? ?? Changelog                     - Line 100,101                              ?
????????????????????????????????????????????????????????????????????????????????
? ? Author's Notes                                                             ?
? Lowell/Adalwulf mentioned creating a "Personal Variables" system which filled?
? my head in with ideas about variables and switches. One of these ideas being ?
? giving party members and actors their own self switches. I personally can't  ?
? think of any use to these but I'm sure someone can!                          ?
?????????????????????????????????????????????????????????????????????????????????
? ? Introduction & Description                                                 ?
? This script is a tad similar to that of the built in feature: Self Switches. ?
? For those not familiar with Self Switches, Self Switches pretty much pertain ?
? to a specific event. Example: Treasure Chests.                               ?
?                                                                              ?
? Actor & Party Self Switches allows developers to set certain switches        ?
? pertaining to a certain party member or actor.                               ?
?                                                                              ?
? Let's say, you set a switch to Party Member 1 (Aluxes) to true. In case you  ?
? ever change party members, the switch will still be turned on for that member?
? in the party (Aluxes).                                                       ?
?                                                                              ?
? Or how about if you want to set a certain switch for a specific actor instead?
? of a member in the party. You can do that as well!                           ?
?????????????????????????????????????????????????????????????????????????????????
? ? Features                                                                   ?
? ? Set party member's self switches via call script. (How to use is below)    ?
? ? Get party member's self switches via call script. (How to use is below)    ?
? ? Set actor's self switches via call script. (How to use is below)           ?
? ? Get actor's self switches via call script. (How to use is below)           ?
????????????????????????????????????????????????????????????????????????????????
? ? How to Use                                                                 ?
?                                                                              ?
? ? Setting up a party member's self switch:                                   ?
?   To set a self switch for a party member, you'll need to call this script:  ?
?     party_self_switch(member, id, bool)                                      ?
?       member: Party Member. (0, 1, 2, 3)                                     ?
?       id:     Party Member Self Switch Identification. Example: 'A', 'B'     ?
?       bool:   true or false.                                                 ?
?   Example: party_self_switch(0, 'A', true) sets whoever may be the 1st party ?
?            member's switch "A" to true.                                      ?
?                                                                              ?
? ? Getting a party member's self switch:                                      ?
?   To get a self switch of a party member, you can call this script.          ?
?     party_self_switch(member, id)                                            ?
?       member: Party Member. (0, 1, 2, 3)                                     ?
?       id:     Party Member Self Switch Identification. Example: 'A', 'B'     ?
?   Example: party_self_switch(0, 'A') gets switch "A" of whoever may be the   ?
?            1st party member.                                                 ?
?                                                                              ?
? ? Using party member's self switches in evented if conditions.               ?
?   You're probably wondering how, right? Alright. To do this, go to the       ?
?   conditional branch event command, click on the fourth tab, select Script   ?
?   and type either of these in the input form:                                ?
?       party_self_switch(member, id) == true                                  ?
?       party_self_switch(member, id) == false                                 ?
?                                                                              ?
? ? Setting up an actor's self switch:                                         ?
?   To set a self switch for an actor, you'll need to call this script:        ?
?     actor_self_switch(actor, id, bool)                                       ?
?       actor: Character ID from the database. (1, 2, 3, 4, 5, 6, 7, 8)        ?
?       id:    Party Member Self Switch Identification. Example: 'A', 'B'      ?
?       bool:  true or false.                                                  ?
?   Example: actor_self_switch(1, 'A', true) sets Actor 1's switch "A" to true.?
?                                                                              ?
? ? Getting an actor's self switch:                                            ?
?   To get a self switch of an actor, you can call this script.                ?
?     actor_self_switch(actor, id)                                             ?
?       actor: Character ID from the database. (1, 2, 3, 4, 5, 6, 7, 8)        ?
?       id:    Party Member Self Switch Identification. Example: 'A', 'B'      ?
?   Example: actor_self_switch(1, 'A') gets switch "A" of Actor 1.             ?
?                                                                              ?
? ? Using an actor's self switch in evented if conditions.                     ?
?   To do this, go to the conditional branch event command, click on the fourth?
?   tab, select Script and type either of these in the input form:             ?
?       actor_self_switch(actor, id) == true                                   ?
?       actor_self_switch(actor, id) == false                                  ?
????????????????????????????????????????????????????????????????????????????????
? ? This aliases the following...                                              ?
? initialize - Game_Party                                                      ?
????????????????????????????????????????????????????????????????????????????????
? ? Thanks                                                                     ?
? Lowell: He mentioned creating a personal variables system for his project    ?
?         which made me (PK8) catch "the scripting bug".                       ?
? Kain Nobel: He modified some of the code and made it a lot better.           ?
????????????????????????????????????????????????????????????????????????????????
? ? Changelog                                                                  ?
? Version 1.0 - 9/16/09: Initial Release                                       ?
?????????????????????????????????????????????????????????????????????????????????
=end

#==============================================================================
# ** Game_Party
#------------------------------------------------------------------------------
#  This class handles the party. It includes information on amount of gold
# and items. The instance of this class is referenced by $game_party.
#==============================================================================

class Game_Party
  attr_accessor :self_switches
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias_method :partyselfswitches_gmparty_initialize, :initialize
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(*args)
    partyselfswitches_gmparty_initialize(*args)
    @self_switches = Game_Party::SelfSwitches.new
  end
end

#==============================================================================
# ** Game_Party::SelfSwitches
#------------------------------------------------------------------------------
#  This handles self switches. It's a wrapper for the built-in class "Array."
# The instance of this class is referenced by $game_party.self_switches.
#==============================================================================

class Game_Party::SelfSwitches
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    @data = {}
  end
  #--------------------------------------------------------------------------
  # * Get Self Switch of Actor
  #     key : key
  #--------------------------------------------------------------------------
  def [](key)
    return @data[key] == true ? true : false
  end
  #--------------------------------------------------------------------------
  # * Set Self Switch of Actor
  #     key   : key
  #     value : ON (true) / OFF (false)
  #--------------------------------------------------------------------------
  def []=(key, value)
    @data[key] = value
  end
end

#==============================================================================
# ** Interpreter
#------------------------------------------------------------------------------
#  This interpreter runs event commands. This class is used within the
#  Game_System class and the Game_Event class.
#==============================================================================

class Interpreter
  #--------------------------------------------------------------------------
  # * Control Party Self Switch
  #--------------------------------------------------------------------------
  def party_self_switch(member, id, bool = nil)
    key = [$game_party.actors[member].id, id]
    if bool != nil
      $game_party.self_switches[key] = bool
    else
      return $game_party.self_switches[key]
    end
    $game_map.need_refresh = true
    return true
  end
  
  #--------------------------------------------------------------------------
  # * Control Actor Self Switch
  #--------------------------------------------------------------------------
  def actor_self_switch(actor, id, bool = nil)
    key = [$game_actors[actor].id, id]
    if bool != nil
      $game_party.self_switches[key] = bool
    else
      return $game_party.self_switches[key]
    end
    $game_map.need_refresh = true
    return true
  end
end

Instructions
How to use is in the script.

FAQ
Feel free to ask.

Compatibility
Aliases initialize of Game_Party.

Credits and Thanks
Lowell: He mentioned creating a personal variables system for his project which made me catch "the scripting bug".
Kain Nobel: He modified some of the code and made it a lot better.

Author's Notes
Lowell/Adalwulf mentioned creating a "Personal Variables" system which filled my head in with ideas about variables and switches. One of these ideas being giving party members and actors their own self switches. I personally can't think of any use to these but I'm sure someone can!

Terms and Conditions
Exclusive to RMVXP?
Reply }
#2
If this does what I think it does.... My tents will be much more manageable. Can the switches automatically switch to true if the actor is in the party and when they aren't automatically switch to false?
Reply }
#3
That is correct.

example:
Aluxes is in party, is first member.
party_self_switch(0, 'A', true) - sets first member Aluxes' switch 'A' to true.
party_self_switch(0, 'A') - gets first member Aluxes' switch 'A', returns true.
Aluxes is no longer in party, replaced by Felix who is now the first member in the party.
party_self_switch(0, 'A') - gets first member Felix's switch 'A', returns false.
Aluxes is now the third party member.
party_self_switch(2, 'A') - gets third member Aluxes's switch 'A' which is still set to true.
Reply }
#4
What if I have a reserve party, they are not in the main party, but I still want their switch flipped to true.
Reply }


Possibly Related Threads…
Thread Author Replies Views Last Post
   DerVV's Actor Stat Points Distributor DerVVulfman 0 571 07-16-2024, 04:46 AM
Last Post: DerVVulfman
   Party Thievery DerVVulfman 1 1,120 07-20-2023, 03:13 AM
Last Post: DerVVulfman
   Actor Battle Items DerVVulfman 4 6,119 11-08-2020, 12:36 PM
Last Post: Mel
   Troop : Self-Switches Kain Nobel 0 4,468 06-03-2016, 09:40 AM
Last Post: Kain Nobel
   Party Splitting RPG Advocate 7 17,013 04-14-2013, 09:13 PM
Last Post: DerVVulfman
   Troop : Self Switches Kain Nobel 1 5,867 02-02-2013, 01:07 PM
Last Post: yamina-chan
   Master Party-Leader Substitution DerVVulfman 0 5,339 01-24-2013, 05:26 PM
Last Post: DerVVulfman
   [Unsupported] PK8's Self Variables XP PK8 4 10,435 03-08-2012, 01:54 PM
Last Post: LilyKnight
   Xenres Single Actor Escape Kirito 0 6,127 10-24-2010, 05:28 AM
Last Post: Kirito
   Party Changer Dargor 7 19,397 06-10-2010, 05:02 AM
Last Post: Meegz0



Users browsing this thread: 1 Guest(s)