Actor & Party's Self Variables XP
#1
Actor & Party's Self Variables 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 Variables allows developers to set certain variables pertaining to a certain party member or actor.

Let's say, you set a variable to Party Member 1 (Aluxes) to 5. In case you ever change party members, the variable will still be 5 for that member in the party (Aluxes).                                                          Or how about if you want to set a certain variable for a specific actor instead of a member in the party. You can do that as well!

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

Screenshots
I can't screencap this!

Demo
No demo.

Script
Code:
=begin
?????????????????????????????????????????????????????????????????????????????????
? Actor & Party Self Variables 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 variables. I could think of a ?
? few uses for them. How about an actor's Reputation or Alignment?             ?
?????????????????????????????????????????????????????????????????????????????????
? ? 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 Variables allows developers to set certain variables      ?
? pertaining to a certain party member or actor.                               ?
?                                                                              ?
? Let's say, you set a variable to Party Member 1 (Aluxes) to 5. In case you   ?
? ever change party members, the variable will still be 5 for that member in   ?
? the party (Aluxes).                                                          ?
?                                                                              ?
? Or how about if you want to set a certain variable for a specific actor      ?
? instead of a member in the party. You can do that as well!                   ?
?????????????????????????????????????????????????????????????????????????????????
? ? Features                                                                   ?
? ? Set party member's self variables via call script. (How to use is below)   ?
? ? Get party member's self variables via call script. (How to use is below)   ?
? ? Set actor's self variables via call script. (How to use is below)          ?
? ? Get actor's self variables via call script. (How to use is below)          ?
????????????????????????????????????????????????????????????????????????????????
? ? How to Use                                                                 ?
?                                                                              ?
? ? Setting up a party member's self variable:                                 ?
?   To set a self variable for a party member, you'll need to call this script:?
?     party_self_variable(member, id, value, oper)                             ?
?       member: Party Member. (0, 1, 2, 3)                                     ?
?       id:     Party Member Self Variable Identification. Example: 'A', 'B'   ?
?       value:  Give it a value.                                               ?
?       oper:   0: Set, 1: Add, 2: Sub, 3: Mul, 4: Div, 5: Mod                 ?
?   Example: party_self_variable(0, 'A', 5, 0) sets whoever may be the 1st     ?
?            party member's variable "A" to 5.                                 ?
?                                                                              ?
? ? Getting a party member's self variable:                                    ?
?   To get a self variable of a party member, you can call this script.        ?
?     party_self_variable(member, id)                                          ?
?       member: Party Member. (0, 1, 2, 3)                                     ?
?       id:     Party Member Self Variable Identification. Example: 'A', 'B'   ?
?   Example: party_self_variable(0, 'A') gets variable "A" of whoever may be   ?
?            the 1st party member.                                             ?
?                                                                              ?
? ? Using party member's self variables 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_variable(member, id) == value   <- Equal to.                  ?
?     party_self_variable(member, id) >= value   <- Greater than or Equal to.  ?
?     party_self_variable(member, id) <= value   <- Less than or Equal to.     ?
?     party_self_variable(member, id) > value    <- Greater than.              ?
?     party_self_variable(member, id) < value    <- Less than.                 ?
?     party_self_variable(member, id) != value   <- Not Equal to.              ?
?                                                                              ?
? ? Setting up an actor's self variable:                                       ?
?   To set a self variable for an actor, you'll need to call this script:      ?
?     actor_self_variable(actor, id, value, oper)                              ?
?       actor: Character ID from the database. (1, 2, 3, 4, 5, 6, 7, 8)        ?
?       id:    Party Member Self Variable Identification. Example: 'A', 'B'    ?
?       value:  Give it a value.                                               ?
?       oper:   0: Set, 1: Add, 2: Sub, 3: Mul, 4: Div, 5: Mod                 ?
?   Example: actor_self_variable(1, 'A', 5, 0) sets Actor 1's variable "A" to 5?
?                                                                              ?
? ? Getting an actor's self variable:                                          ?
?   To get a self variable of an actor, you can call this script.              ?
?     actor_self_variable(actor, id)                                           ?
?       actor: Character ID from the database. (1, 2, 3, 4, 5, 6, 7, 8)        ?
?       id:    Party Member Self Variable Identification. Example: 'A', 'B'    ?
?   Example: actor_self_variable(1, 'A') gets variable "A" of Actor 1.         ?
?                                                                              ?
? ? Using an actor's self variables 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_variable(member, id) == value   <- Equal to.                  ?
?     actor_self_variable(member, id) >= value   <- Greater than or Equal to.  ?
?     actor_self_variable(member, id) <= value   <- Less than or Equal to.     ?
?     actor_self_variable(member, id) > value    <- Greater than.              ?
?     actor_self_variable(member, id) < value    <- Less than.                 ?
?     actor_self_variable(member, id) != value   <- Not Equal to.              ?
????????????????????????????????????????????????????????????????????????????????
? ? 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_variables
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias_method :partyselfvariables_gmparty_initialize, :initialize
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(*args)
    partyselfvariables_gmparty_initialize(*args)
    @self_variables = Game_Party::SelfVariables.new
  end
end

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

class Game_Party::SelfVariables
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    @data = {}
  end
  #--------------------------------------------------------------------------
  # * Get Self Variable of Actor
  #     key : key
  #--------------------------------------------------------------------------
  def [](key)
    if @data[key] == nil
      return 0
    else
      return @data[key]
    end
  end
  #--------------------------------------------------------------------------
  # * Set Self Variable of Actor
  #     key   : key
  #     value : value
  #--------------------------------------------------------------------------
  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 Variable
  #--------------------------------------------------------------------------
  def party_self_variable(member, id, value = nil, oper = nil)
    key = [$game_party.actors[member].id, id]
    if value != nil
      case oper
      when nil, 0, 'equal', 'set', '='                     # Setting
        $game_party.self_variables[key] = value
      when 1, 'add', '+'                                   # Adding
        $game_party.self_variables[key] += value
      when 2, 'sub', 'subtract', '-'                       # Subtracting
        $game_party.self_variables[key] -= value
      when 3, 'mul', 'multiply', 'x', '*'                  # Multiplying
        $game_party.self_variables[key] *= value
      when 4, 'div', 'divide', '/'                         # Dividing
        $game_party.self_variables[key] /= value if value != 0
      when 5, 'mod', 'modular', '%'                        # Modulating
        $game_party.self_variables[key] %= value if value != 0
      end
    else
      return $game_party.self_variables[key]
    end
    $game_map.need_refresh = true
    return true
  end
 
  #--------------------------------------------------------------------------
  # * Control Actor Self Variable
  #--------------------------------------------------------------------------
  def actor_self_variable(actor, id, value = nil, oper = nil)
    key = [$game_actors[actor].id, id]
    if value != nil
      case oper
      when nil, 0, 'equal', 'set', '='                     # Setting
        $game_party.self_variables[key] = value
      when 1, 'add', '+'                                   # Adding
        $game_party.self_variables[key] += value
      when 2, 'sub', 'subtract', '-'                       # Subtracting
        $game_party.self_variables[key] -= value
      when 3, 'mul', 'multiply', 'x', '*'                  # Multiplying
        $game_party.self_variables[key] *= value
      when 4, 'div', 'divide', '/'                         # Dividing
        $game_party.self_variables[key] /= value if value != 0
      when 5, 'mod', 'modular', '%'                        # Modulating
        $game_party.self_variables[key] %= value if value != 0
      end
    else
      return $game_party.self_variables[key]
    end
    $game_map.need_refresh = true
    return true
  end
end

Instructions
How to use is in the script.

FAQ
If you're having any trouble, feel free to ask.

Compatibility
Aliases Game_Party's initialize method.

Credits and 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.

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 variables. I could think of a few uses for them. How about an actor's Reputation or Alignment?

Terms and Conditions
Possibly exclusive to RMVXP.
Reply }


Possibly Related Threads…
Thread Author Replies Views Last Post
   ATOA CBS Equipment Set Variables Patch kyonides 0 278 10-14-2024, 12:47 AM
Last Post: kyonides
   DerVV's Actor Stat Points Distributor DerVVulfman 0 635 07-16-2024, 04:46 AM
Last Post: DerVVulfman
   Party Thievery DerVVulfman 1 1,170 07-20-2023, 03:13 AM
Last Post: DerVVulfman
   Actor Battle Items DerVVulfman 4 6,245 11-08-2020, 12:36 PM
Last Post: Mel
   Party Splitting RPG Advocate 7 17,234 04-14-2013, 09:13 PM
Last Post: DerVVulfman
   Master Party-Leader Substitution DerVVulfman 0 5,429 01-24-2013, 05:26 PM
Last Post: DerVVulfman
   [Unsupported] PK8's Self Variables XP PK8 4 10,573 03-08-2012, 01:54 PM
Last Post: LilyKnight
   Xenres Single Actor Escape Kirito 0 6,193 10-24-2010, 05:28 AM
Last Post: Kirito
   Party Changer Dargor 7 19,595 06-10-2010, 05:02 AM
Last Post: Meegz0
   Actor Cloning System by Charlie Fleed Charlie Fleed 5 11,315 02-09-2010, 04:38 PM
Last Post: desbrina



Users browsing this thread: 1 Guest(s)