RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
DoubleX RMMV Linked Battlers

0 Members and 1 Guest are viewing this topic.

***
Scripter
Rep:
Level 36
Changelog
Code: [Select]
*      v1.00d(GMT 1500 29-1-2016):                                           
 *      1. Fixed undefined g in Proto[func[0]] bug                           
 *      2. Fixed passing getter instead of its name to linkedBattlersStateId 
 *      3. Fixed calling getter via this[getter] instead of this.getter       
 *      4. Fixed state.linkedBattlers instead of state.meta.linkedBattlers bug
 *      5. Fixed adding 2 Arrays instead of concatenating them bug           
 *      6. Fixed undefined battler isStateAdded bug                           
 *      7. Fixed linked battlers' stats being possible to be non-integer bug 
 *      8. Only the target will collapse when some others die at the same time
 *      v1.00c(GMT 1400 31-12-2015):                                         
 *      1. Fixed writing getter contents directly instead of using String bug
 *      v1.00b(GMT 1100 28-12-2015):                                         
 *      1. Fixed unintentionally declaring global variable in strict mode bug
 *      2. Fixed using new Function and class instead of eval and prototype   
 *      v1.00a(GMT 1400 23-12-2015):                                         
 *      1. 1st version of this plugin finished                               

Authors
DoubleX

Credits
DoubleX(Optional)

Purpose
Lets users set some states to let their owners share some stats

Games using this script
None so far

Notetags
Code: [Select]
*    # State Notetags:                                                       
 *      1. <linked battlers: LBCX, LBSX, LBWX>                               
 *         - Sets all owners of this state meeting LBCX to share stats       
 *           included in LBSX with weight LBWX applied to each of them when   
 *           any included stat of any included battler changes               
 *         - Only the 1st applicable notetag of the state with the highest   
 *           priority will be applied to the stat change of the linked battler
 *         - If a linked battler can't take all of that battler's share of the
 *           original stat change due to hitting the min/max stat value, thost
 *           not being taken by that battler will be shared by the rest of the
 *           linked battlers also                                             
 *         - The battler originally having a stat to be changed is the last   
 *           linked battler taking the change not shared by any other ones   
 *         - LBCX can be set in Linked Battler Condition Functions           
 *         - LBSX can be set in Linked Battler Stat Functions                 
 *         - LBWX can be set in Linked Battler Weight Functions               

Plugin Calls
Code: [Select]
*    # Configuration manipulations                                           
 *      1. DoubleX_RMMV.Linked_Battlers.prop                                 
 *         - Returns the property prop under DoubleX_RMMV.Linked_Battlers     
 *      2. DoubleX_RMMV.Linked_Battlers.prop = function                       
 *         - Sets the property prop under DoubleX_RMMV.Linked_Battlers as     
 *           function which will be bound to the battler upon use             
 *         - No DoubleX_RMMV.Linked_Battlers.prop change will be saved       
 *    # State manipulations                                                   
 *      All meta.linkedBattlers changes can be saved if                       
 *      DoubleX RMMV Dynamic Data is used                                     
 *      1. meta.linkedBattlers                                               
 *         - Returns an Array of all LBCX-LBSX-LBWX triples, each in the form
 *           of [LBCX, LBSX, LBWX]                                           
 *      2. meta.linkedBattlers = [[LBCX, LBSX, LBWX], [LBCX, LBSX, LBWX], ...]
 *         - Resets the Array of all LBCX-LBSX-LBWX triples, each in the form
 *           of [LBCX, LBSX, LBWX], stored sequentially in that Array         
 *      3. meta.linkedBattlers[i] = [LBCX, LBSX, LBWX]                       
 *         - Sets the (i + 1)th LBCX-LBSX-LBWX triple as LBCX-LBSX-LBWX       

Configurations
Code: [Select]
    /*------------------------------------------------------------------------
     *    Linked Battler Condition Functions                                 
     *    - Setups LBCX used by <linked battlers: LBCX, LBSX, LBWX>           
     *------------------------------------------------------------------------*/
    /* LBCX are used in functions included in LINKED_STATS
     * LBCX are functions that will be bound to battler calling them upon use
     * LBCX names can only use alphanumeric characters
     * Each linked battler besides the caller can be referenced by battler
     * The caller will always pass LBCX even when it's supposed to fail
     * The below LBCX are examples added to help you set your LBCX
     * You can freely use, rewrite and/or delete these examples
     */

    // Sets the linked battler condition to include all linked battlers
    LBC1: function(battler) { return true; },

    /* Sets the linked battler condition to include all and no linked battlers
     * if switch with id x is on and off respectively
     */
    LBC2: function(battler) { return $gameSwitches.value(x); },

    // Adds new LBCX here
   

    /*------------------------------------------------------------------------
     *    Linked Battler Stat Functions                                       
     *    - Setups LBSX used by <linked battlers: LBCX, LBSX, LBWX>           
     *------------------------------------------------------------------------*/
    /* LBSX are used in functions included in LINKED_STATS
     * LBSX are functions that will be bound to battlers upon use
     * LBSX names can only use alphanumeric characters
     * It must return an Array, which should include all strings of getter
     * functions of each stat to be included
     * The below LBSX are examples added to help you set your LBSX
     * You can freely use, rewrite and/or delete these examples
     */

    // Sets the linked battler stat to include hp, mp and tp
    LBS1: function() { return ["hp", "mp", "tp"]; },

    // Sets the linked battler stat to include nothing
    LBS2: function() { return []; },

    // Adds new LBSX here
   

    /*------------------------------------------------------------------------
     *    Linked Battler Weight Functions                                     
     *    - Setups LBWX used by <linked battlers: LBCX, LBSX, LBWX>           
     *------------------------------------------------------------------------*/
    /* LBWX are used in functions included in LINKED_STATS
     * LBWX are functions that will be bound to battlers upon use
     * LBWX names can only use alphanumeric characters
     * It must return a Number
     * No stat change will take place for any linked battler if the sum of all
     * weights of all linked battlers is 0
     * Each linked battler besides the caller can be referenced by battler
     * The below LBWX are examples added to help you set your LBWX
     * You can freely use, rewrite and/or delete these examples
     */

    // Sets the linked battler weight to be the same for all linked battlers
    LBW1: function(battler) { return 1; },

    /* Sets the linked battler weight to be multiplied by x if the linked
     * battler is the one having a stat to be changed
     */
    LBW2:  function(battler) { return battler === this ? x : 1; },

    // Adds new LBWX here
   

    /* Sets the battler functions to be used by linked battlers
     * Its property names must be the battler stat getter function names
     * Its values must be Arrays, each containing the battler stat setter
     * function name, the index of the argument as the original new stat value
     * in the stat setter function argument list, and each linked battler's
     * min/max stat value
     * All battler functions as min/max stat value must be referenced by this
     * All the included battler stat getter functions will be extended
     */
    LINKED_STATS: {

      /* General form:
       * FunctionClass: {
       *     getter: ["setter", statArgIndex, "statMin", "statMax"]
       * }
       */

      Game_BattlerBase: {
        /* General form:
         * getter: ["setter", statArgIndex, "statMin", "statMax"]
         */
        hp: ["setHp", 0, "0", "this.mhp"],
        mp: ["setMp", 0, "0", "this.mmp"],
        tp: ["setTp", 0, "0", "this.maxTp()"]
        // Adds new functions here
       
      }

      // Adds new classes here
     

    }

Prerequisites
Abilities:
1. Some Javascript coding proficiency to fully utilize this plugin

Terms Of Use
You shall keep this plugin's Plugin Info part's contents intact
You shalln't claim that this plugin's written by anyone other than DoubleX or his aliases
None of the above applies to DoubleX or his/her aliases
« Last Edit: January 29, 2016, 03:17:45 PM by DoubleX »

***
Scripter
Rep:
Level 36
Updates
Code: [Select]
*      v1.00b(GMT 1100 28-12-2015):                                         
 *      1. Fixed unintentionally declaring global variable in strict mode bug
 *      2. Fixed using new Function and class instead of eval and prototype   
« Last Edit: December 28, 2015, 12:17:31 PM by DoubleX »

*
A-pow 2015
Rep:
Level 81
2014 Best RPG Maker User - GraphicsFor frequently finding and reporting spam and spam bots2013 Most Unsung MemberSecret Santa 2013 ParticipantFor taking arms in the name of your breakfast.How can I help you? :Da^2 + b^2 = c^2Secret Santa 2012 ParticipantSilver - GIAW 10Silver - GIAW 9Bronze - GIAW HalloweenGold - Game In A Week VII
Do you think you could explain what this does a bit more? I don't get it. :x

***
Scripter
Rep:
Level 36
Do you think you could explain what this does a bit more? I don't get it. :x
Let's say there are some battlers having the same mhp/mmp/max tp, and you want them to always have the same hp/mp/tp as well.
With this plugin, you can use this notetag:
<linked battlers: LBC1, LBS1, LBW1>
Where LBC1, LBS1 and LBW1 are:
LBC1: function(battler) { return true; },
LBS1: function() { return ["hp", "mp", "tp"]; },
LBW1: function(battler) { return 1; },
Now for all battlers having states with the above notetag, whenever any of their hp/mp/tp changes, the change will always be equally distributed to all those battlers, because:
1. LBC1 always returns true
2. LBS1 includes hp/mp/tp
3. All battlers have the same weight, 1, in LBW1

***
Scripter
Rep:
Level 36
Updates
Code: [Select]
*      v1.00c(GMT 1400 31-12-2015):                                         
 *      1. Fixed writing getter contents directly instead of using String bug

***
Scripter
Rep:
Level 36
Updates
 *      v1.00d(GMT 1500 29-1-2016):                                           
 *      1. Fixed undefined g in Proto[func[0]] bug                           
 *      2. Fixed passing getter instead of its name to linkedBattlersStateId 
 *      3. Fixed calling getter via this[getter] instead of this.getter       
 *      4. Fixed state.linkedBattlers instead of state.meta.linkedBattlers bug
 *      5. Fixed adding 2 Arrays instead of concatenating them bug           
 *      6. Fixed undefined battler isStateAdded bug                           
 *      7. Fixed linked battlers' stats being possible to be non-integer bug 
 *      8. Only the target will collapse when some others die at the same time