[Review]DoubleX RMVXA Linked Battlers

Purpose
Lets users set some states to make their owners share some stats together

Notetag
  1. #  * State Notetags:                                                           |
  2. #    1. <linked battlers: lbcx, lbsx, lbwx>                                    |
  3. #       - Sets the owners of this state meeting lbcx to share stats included in|
  4. #         lbsx with weight lbwx applied to each of them when any included stat |
  5. #         of any included battler changes                                      |
  6. #       - Only the 1st applicable notetag of the state with the highest        |
  7. #         priority will be applied to the stat change of the linked battler    |
  8. #       - If a linked battler can't take all of that battler's share due to    |
  9. #         hitting the minimum or maximum stat value, thost not being taken by  |
  10. #         that battler will be shared by the rest of the linked battlers also  |
  11. #       - The battler having a stat to be changed is the last linked battler   |
  12. #         taking that battler's share                                          |
  13. #       - lbcx can be set in Linked Battler Condition Notetag Values           |
  14. #       - lbsx can be set in Linked Battler Stat Notetag Values                |
  15. #       - lbwx can be set in Linked Battler Weight Notetag Values              |
Expand to see the code.

  1.    #--------------------------------------------------------------------------|
  2.     #  Linked Battler Condition Notetag Values                                 |
  3.     #  - Setups lbcx used by <linked battlers: lbcx, lbsx, lbwx>               |
  4.     #--------------------------------------------------------------------------|
  5.     # lbcx are read at:
  6.     # 1. RPG::State
  7.     #    - @linked_battlers << [$1.downcase.to_sym, $2.downcase.to_sym,
  8.     #      $3.downcase.to_sym] in load_linked_battlers_notes
  9.     # lbcx are used at:
  10.     # 1. Game_BattlerBase
  11.     #    - mem.state?(state_id) && lb.send(cond, mem, self) in
  12.     #      get_linked_battlers
  13.     # lbcx are strings of names of methods under DoubleX_RMVXA::Linked_Battlers
  14.     # lbcx names can only use alphanumeric characters and can't use uppercase
  15.     # letters
  16.     # The battler having a stat to be changed can be referenced by target
  17.     # Each of the rest of the linked battlers can be referenced by battler
  18.     # The below lbcx are examples added to help you set your lbcx
  19.     # You can freely use, rewrite and/or delete these examples
  20.  
  21.     # Sets the linked battler condition to include all linked battlers
  22.     def self.lbc1(battler, target)
  23.       true
  24.     end
  25.  
  26.     # Sets the linked battler condition to include all and no linked battlers if
  27.     # switch with id x is on and off respectively
  28.     def self.lbc2(battler, target)
  29.       $game_switches[x]
  30.     end
  31.  
  32.     # Sets the linked battler condition to include all linked battlers that are
  33.     # opponents of the battler having a stat to be changed
  34.     def self.lbc3(battler, target)
  35.       target.opposite?(battler)
  36.     end
  37.  
  38.     # Adds new lbcx here
  39.    
  40.  
  41.     #--------------------------------------------------------------------------|
  42.     #  Linked Battler Stat Notetag Values                                      |
  43.     #  - Setups lbsx used by <linked battlers: lbcx, lbsx, lbwx>               |
  44.     #--------------------------------------------------------------------------|
  45.     # lbsx are read at:
  46.     # 1. RPG::State
  47.     #    - @linked_battlers << [$1.downcase.to_sym, $2.downcase.to_sym,
  48.     #      $3.downcase.to_sym] in load_linked_battlers_notes
  49.     # lbsx are used at:
  50.     # 1. Game_BattlerBase
  51.     #    - return [l_b, state_id] if lb.send(l_b[1], self).include?(stat) in
  52.     #      linked_battler_state_id
  53.     # lbsx are strings of names of methods under DoubleX_RMVXA::Linked_Battlers
  54.     # lbsx names can only use alphanumeric characters and can't use uppercase
  55.     # letters
  56.     # The battler having a stat to be changed can be referenced by battler
  57.     # It must return an array, which should include strings of a getter method
  58.     # of each stat to be included
  59.     # The below lbsx are examples added to help you set your lbsx
  60.     # You can freely use, rewrite and/or delete these examples
  61.  
  62.     # Sets the linked battler stat to include hp, mp and tp
  63.     def self.lbs1(battler)
  64.       ["hp", "mp", "tp"]
  65.     end
  66.  
  67.     # Sets the linked battler stat to always include hp and mp, and include tp
  68.     # only if it's displayed in battle
  69.     def self.lbs2(battler)
  70.       ["hp", "mp", $data_system.opt_display_tp ? "tp" : nil]
  71.     end
  72.  
  73.     # Sets the linked battler stat to include nothing
  74.     def self.lbs3(battler)
  75.       []
  76.     end
  77.  
  78.     # Adds new lbsx here
  79.    
  80.  
  81.     #--------------------------------------------------------------------------|
  82.     #  Linked Battler Weight Notetag Values                                    |
  83.     #  - Setups lbwx used by <linked battlers: lbcx, lbsx, lbwx>               |
  84.     #--------------------------------------------------------------------------|
  85.     # lbwx are read at:
  86.     # 1. RPG::State
  87.     #    - @linked_battlers << [$1.downcase.to_sym, $2.downcase.to_sym,
  88.     #      $3.downcase.to_sym] in load_linked_battlers_notes
  89.     # lbwx are used in methods included in LINKED_STAT
  90.     # lbwx are strings of names of methods under DoubleX_RMVXA::Linked_Battlers
  91.     # lbwx names can only use alphanumeric characters and can't use uppercase
  92.     # letters
  93.     # It must return a real number
  94.     # The battler having a stat to be changed can be referenced by target
  95.     # Each of the rest of the linked battlers can be referenced by battler
  96.     # The below lbwx are examples added to help you set your lbwx
  97.     # You can freely use, rewrite and/or delete these examples
  98.  
  99.     # Sets the linked battler weight to be the same for all linked battlers
  100.     def self.lbw1(battler, target)
  101.       1
  102.     end
  103.  
  104.     # Sets the linked battler weight to be multiplied by x if the linked battler
  105.     # is the one having a stat to be changed
  106.     def self.lbw2(battler, target)
  107.       battler == target ? x : 1
  108.     end
  109.  
  110.     # Sets the linked battler weight to be 0 for all linked battlers
  111.     def self.lbw3(battler, target)
  112.       0
  113.     end
  114.  
  115.     # Adds new lbwx here
  116.    
  117.  
  118.     # Sets the battler methods to be used by linked battlers
  119.     # Its keys must be the battler stat getter method string
  120.     # Its values must be an array containing the battler stat setter method,
  121.     # its argument list, the one being modified, and the minimum and maximum
  122.     # value of that battler stat of each linked battler
  123.     # The methods returning those minimum and maximum values must be referenced
  124.     # by battler
  125.     # Methods with name method_name will be aliased to
  126.     # linked_battlers_method_name
  127.     LINKED_STATS = {
  128.  
  129.       # General form:
  130.       # [:def_class, :super_class] => {
  131.       #   "getter" => ["setter", "args", "mod arg", "stat_min", "stat_max"]
  132.       # }
  133.  
  134.       [:Game_BattlerBase] => {
  135.         # General form:
  136.         # "getter" => ["setter", "args", "mod arg", "stat_min", "stat_max"]
  137.         "hp" => ["hp=", "hp", "hp", "0", "battler.mhp"],
  138.         "mp" => ["mp=", "mp", "mp", "0", "battler.mmp"],
  139.         "tp" => ["tp=", "tp", "tp", "0", "battler.max_tp"]
  140.         # Adds new methods here
  141.        
  142.       }
  143.  
  144.       # Adds new classes here
  145.      
  146.  
  147.     }
Expand to see the code.


Games Using This Script
None so far

Prerequisites
Abilities:
1. Some RGSS3 scripting proficiency to fully utilize this script

Terms Of Use
You shall keep this script's Script Info part's contents intact
You shalln't claim that this script is written by anyone other than DoubleX or his aliases
None of the above applies to DoubleX or his aliases

Instructions
1. Open the script editor and put this script into an open slot between Materials and Main, save to take effect.

Authors
DoubleX

Changelog
  1. #    v1.00b(GMT 0400 8-11-2015):                                               |
  2. #    1. Notetag values are now symbols of methods in the configuration regions |
  3. #    2. This script doesn't need DoubleX RMVXA Linked Battlers Compatibility to|
  4. #       be compatible with all its addressed scripts                           |
  5. #    3. Further improved this script's compatibility, efficiency and simplicity|
  6. #    v1.00a(GMT 1500 7-8-2015):                                                |
  7. #    1. 1st version of this script finished                                    |
Expand to see the code.


Download Link
http://pastebin.com/bfCuAkKT

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=78859