查看: 669|回复: 0

[有事请教] 请教VE_CooperationSkills 合作技插件的错误如何修复

[复制链接]
梦石
0
星屑
7800
在线时间
868 小时
注册时间
2021-8-28
回帖
93
发表于 2022-1-26 23:45:27 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
本帖最后由 Rose_shadows 于 2022-1-27 07:24 编辑

插件在此:

这是前置插件:
[pre lang="javascript"]/*
* ==============================================================================
* ** Victor Engine MV - Basic Module
* ------------------------------------------------------------------------------
*  VE_BasicModule.js
* ==============================================================================
*/

var Imported = Imported || {};
Imported['VE - Basic Module'] = '1.23';

var VictorEngine = VictorEngine || {};
VictorEngine.BasicModule = VictorEngine.BasicModule || {};

(function() {

    VictorEngine.BasicModule.loadDatabase = DataManager.loadDatabase;
    DataManager.loadDatabase = function() {
        VictorEngine.BasicModule.loadDatabase.call(this);
        PluginManager.requiredPlugin.call(PluginManager, 'VE - Basic Module');
    };

    PluginManager.requiredPlugin = function(name, required, version) {
        VictorEngine.BasicModule.checkPlugins(name, required, version);
    };

})();

/*:
* ==============================================================================
* @plugindesc v1.23 - Plugin with base code required for all Victor Engine plugins.
* @author Victor Sant
*
* @param == Trait Names ==
*
* @param Hit Rate Name
* @desc 'Hit Rate' Ex-Parameter name shown on windows.
* @default Hit
*
* @param Evasion Rate Name
* @desc 'Evasion Rate' Ex-Parameter name shown on windows.
* @default Evasion
*
* @param Critical Rate Name
* @desc 'Critical Rate' Ex-Parameter name shown on windows.
* @default Critical
*
* @param Critical Evasion Name
* @desc 'Critical Evasion' Ex-Parameter name shown on windows.
* @default C. Evasion
*
* @param Magic Evasion Name
* @desc 'Magic Evasion' Ex-Parameter name shown on windows.
* @default M. Evasion
*
* @param Magic Reflection Name
* @desc 'Magic Reflection' Ex-Parameter name shown on windows.
* @default M. Reflection
*
* @param Counter Attack Name
* @desc 'Counter Attack' Ex-Parameter name shown on windows.
* @default Counter
*
* @param HP Regeneration Name
* @desc 'HP Regeneration' Ex-Parameter name shown on windows.
* @default HP Regen
*
* @param MP Regeneration Name
* @desc 'MP Regeneration' Ex-Parameter name shown on windows.
* @default MP Regen
*
* @param TP Regeneration Name
* @desc 'TP Regeneration' Ex-Parameter name shown on windows.
* @default TP Regen
*
* @param Target Rate Name
* @desc 'Target Rate' Sp-Parameter name shown on windows.
* @default Target Rate
*
* @param Guard Rate Name
* @desc 'Guard Rate' Sp-Parameter name shown on windows.
* @default Guard Rate
*
* @param Recovery Effect Name
* @desc 'Recovery Effect' Sp-Parameter name shown on windows.
* @default Recovery
*
* @param Pharmacology Name
* @desc 'Pharmacology' Sp-Parameter name shown on windows.
* @default Pharmacology
*
* @param MP Cost Rate Name
* @desc 'MP Cost Rate' Sp-Parameter name shown on windows.
* @default MP Cost
*
* @param TP Charge Rate Name
* @desc 'TP Charge Rate' Sp-Parameter name shown on windows.
* @default TP Charge
*
* @param Physical Damage Name
* @desc 'Physical Damage' Sp-Parameter name shown on windows.
* @default Physical Damage
*
* @param Magical Damage Name
* @desc 'Magical Damage' Sp-Parameter name shown on windows.
* @default Magical Damage
*
* @param Floor Damage Name
* @desc 'Floor Damage' Sp-Parameter name shown on windows.
* @default Floor Damage
*
* @param Experience Rate Name
* @desc 'Experience Rate' Sp-Parameter name shown on windows.
* @default Exp. Rate
*
* ==============================================================================
* @help
* ==============================================================================
* Install this plugin above any other Victor Engine plugin.
* ==============================================================================
*
* ==============================================================================
*  Version History:
* ------------------------------------------------------------------------------
*  v 1.00 - 2015.11.26 > First release.
*  v 1.01 - 2015.11.29 > Added function to get database objects.
*  v 1.02 - 2015.12.07 > Added function to get multiples elements.
*                      > Added check for plugin correct order.
*  v 1.03 - 2015.12.13 > Added function to get page comments.
*  v 1.04 - 2015.12.21 > Added function to check only relevant objects.
*  v 1.05 - 2015.12.25 > Added check to wait bitmap loading.
*  v 1.06 - 2015.12.31 > Added rgb to hex and hex to rgb functions.
*                      > Added function to get plugins parameters.     
*  v 1.07 - 2016.01.07 > Fixed issue with plugin order checks.
*  v 1.08 - 2016.01.17 > Added function to get BattleLog method index.
*                      > Added function to insert methods on BattleLog.
*  v 1.09 - 2016.01.24 > Added function to set wait for animations.
*  v 1.10 - 2016.02.05 > Added function to get values from regex.
*  v 1.11 - 2016.02.10 > Added function to capitalize texts.
*                      > Added Plugin Parameter to set trait display names.
*  v 1.12 - 2016.02.18 > Added function to get parameter names.
*  v 1.13 - 2016.02.26 > Added functions to setup battler direction.
*  v 1.14 - 2016.03.15 > Added functions to check opponents.
*  v 1.15 - 2016.03.18 > Added function for compatibility with YEP.
*  v 1.16 - 2016.03.23 > Added function to replace mathods.
*                        Added functions for dynamic motions.
*  v 1.17 - 2016.04.01 > Fixed issue with battler sprite check.
*  v 1.18 - 2016.04.21 > Fixed issue with damage popup on action user.
*  v 1.19 - 2016.04.30 > Added function to get evaluated font color.
*  v 1.20 - 2016.05.12 > Added function to get width of text with escape codes.
*  v 1.21 - 2016.05.31 > Improved method stack for dynamic motions.
*                      > Added functions for compatibility with Battle Motions.
*  v 1.22 - 2016.06.26 > Added functions for escape command.
*  v 1.23 - 2017.05.25 > Added functions for damage formula.
* ===============================================================================
*/

(function() {

    //=============================================================================
    // Parameters
    //=============================================================================

    VictorEngine.getPluginParameters = function() {
        var script = document.currentScript || (function() {
            var scripts = document.getElementsByTagName('script');
            return scripts[scripts.length - 1];
        })();
        var start = script.src.lastIndexOf('/') + 1;
        var end = script.src.indexOf('.js');
        return PluginManager.parameters(script.src.substring(start, end));
    }

    var parameters = VictorEngine.getPluginParameters();
    VictorEngine.Parameters = VictorEngine.Parameters || {};
    VictorEngine.Parameters.BasicModule = {};
    VictorEngine.Parameters.BasicModule.hit = String(parameters["Hit Rate Name"]).trim();
    VictorEngine.Parameters.BasicModule.eva = String(parameters["Evasion Rate Name"]).trim();
    VictorEngine.Parameters.BasicModule.cri = String(parameters["Critical Rate Name"]).trim();
    VictorEngine.Parameters.BasicModule.cev = String(parameters["Critical Evasion Name"]).trim();
    VictorEngine.Parameters.BasicModule.hev = String(parameters["Magic Evasion Name"]).trim();
    VictorEngine.Parameters.BasicModule.mrf = String(parameters["Magic Reflection Name"]).trim();
    VictorEngine.Parameters.BasicModule.cnt = String(parameters["Counter Attack Name"]).trim();
    VictorEngine.Parameters.BasicModule.hrg = String(parameters["HP Regeneration Name"]).trim();
    VictorEngine.Parameters.BasicModule.mrg = String(parameters["MP Regeneration Name"]).trim();
    VictorEngine.Parameters.BasicModule.trg = String(parameters["TP Regeneration Name"]).trim();
    VictorEngine.Parameters.BasicModule.tgr = String(parameters["Target Rate Name"]).trim();
    VictorEngine.Parameters.BasicModule.grd = String(parameters["Guard Rate Name"]).trim();
    VictorEngine.Parameters.BasicModule.rec = String(parameters["Recovery Effect Name"]).trim();
    VictorEngine.Parameters.BasicModule.pha = String(parameters["Pharmacology Name"]).trim();
    VictorEngine.Parameters.BasicModule.mcr = String(parameters["MP Cost Rate Name"]).trim();
    VictorEngine.Parameters.BasicModule.tcr = String(parameters["TP Charge Rate Name"]).trim();
    VictorEngine.Parameters.BasicModule.pdr = String(parameters["Physical Damage Name"]).trim();
    VictorEngine.Parameters.BasicModule.mdr = String(parameters["Magical Damage Name"]).trim();
    VictorEngine.Parameters.BasicModule.fdr = String(parameters["Floor Damage"]).trim();
    VictorEngine.Parameters.BasicModule.ext = String(parameters["Experience"]).trim();

    //=============================================================================
    // DataManager
    //=============================================================================

    VictorEngine.BasicModule.isDatabaseLoaded = DataManager.isDatabaseLoaded;
    DataManager.isDatabaseLoaded = function() {
        if (!VictorEngine.BasicModule.isDatabaseLoaded.call(this)) return false;
        VictorEngine.loadParameters();
        VictorEngine.loadNotetags();
        return ImageManager.isReady();
    };

    //=============================================================================
    // VictorEngine
    //=============================================================================

    VictorEngine.BasicModule.checkPlugins = function(name, req, ver) {
        var msg = '';
        this.loadedPlugins = this.loadedPlugins || {};
        if (ver && req && (!Imported[req] || Number(Imported[req]) < Number(ver))) {
            msg += 'The plugin ' + name + ' requires the plugin ' + req;
            msg += ' v' + ver + ' or higher installed to work properly'
            if (Number(Imported[req]) < Number(ver)) {
                msg += '. Your current version is v' + Imported[req];
            }
            msg += '. Go to http://victorenginescripts.wordpress.com/'
            msg += ' to download the updated plugin.';
            throw msg;
        } else if (!ver && req && this.loadedPlugins[req] === true) {
            msg += 'The plugin ' + name + ' requires the plugin ' + req;
            msg += ' to be placed bellow it. Open the Plugin Manager and place';
            msg += ' the plugins in the correct order.';
            throw msg;
        } else if (req && Imported['VE - Basic Module'] && !this.loadedPlugins['VE - Basic Module']) {
            msg += 'The plugin ' + name + ' must be placed bellow the plugin ' + req;
            msg += '. Open the Plugin Manager and place';
            msg += ' the plugins in the correct order.';
            throw msg;
        } else {
            this.loadedPlugins[name] = true
        }
    };

    VictorEngine.loadNotetags = function() {
        if (VictorEngine.BasicModule.loaded) return;
        VictorEngine.BasicModule.loaded = true;
        var list = [$dataActors, $dataClasses, $dataSkills, $dataItems, $dataWeapons,
            $dataArmors, $dataEnemies, $dataStates
        ];
        list.forEach(function(objects, index) {
            this.processNotetags(objects, index)
        }, this);
    };

    VictorEngine.processNotetags = function(objects, index) {
        objects.forEach(function(data) {
            if (data) {
                this.loadNotetagsValues(data, index);
            }
        }, this);
    };

    VictorEngine.objectSelection = function(index, list) {
        var objects = ['actor', 'class', 'skill', 'item', 'weapon', 'armor', 'enemy', 'state'];
        return list.contains(objects[index]);
    };

    VictorEngine.loadNotetagsValues = function(data, index) {};

    VictorEngine.loadParameters = function() {};

    VictorEngine.getNotesValues = function(value1, value2) {
        value2 = value2 || value1;
        return new RegExp('<' + value1 + '>([\\s\\S]*?)<\\/' + value2 + '>', 'gi');
    };

    VictorEngine.getPageNotes = function(event) {
        var result = (event instanceof Game_CommonEvent) || event.page();
        if (!result || !event.list()) {
            return "";
        }
        return event.list().reduce(function(r, cmd) {
            var valid = (cmd.code === 108 || cmd.code === 408);
            var comment = valid ? cmd.parameters[0] + "\r\n" : "";
            return r + comment;
        }, "");
    };

    VictorEngine.getAllElements = function(subject, action) {
        if (action.item().damage.elementId < 0) {
            return subject.attackElements();
        } else {
            return [action.item().damage.elementId];
        }
    };

    VictorEngine.getAllStates = function(subject, item) {
        var result;
        return item.effects.reduce(function(r, effect) {
            if (effect.code === 21) {
                if (effect.dataId === 0) {
                    result = subject.attackStates();
                } else {
                    result = [effect.dataId];
                };
            } else {
                result = [];
            };
            return r.concat(result);
        }, []);
    };

    VictorEngine.getDamageFormula = function(action) {
                return action.item().damage.formula;
    };

    VictorEngine.getNumberValue = function(match, type, base) {
        var regex = new RegExp(type + '[ ]*:[ ]*([+-.\\d]+)', 'gi');
        var value = regex.exec(match);
        return value ? Number(value[1]) : base;
    };

    VictorEngine.getStringValue = function(match, type, base) {
        var regex = new RegExp(type + "[ ]*:[ ]*([\\w ]+)", 'gi');
        var value = regex.exec(match);
        return value ? value[1].trim() : base;
    };

    VictorEngine.getAnyValue = function(match, type, base) {
        var regex = new RegExp(type + "[ ]*:[ ]*('[^\']+'|\"[^\"]+\")", 'gi');
        var value = regex.exec(match);
        return value ? value[1].slice(1, -1) : base;
    };

    VictorEngine.getNumberValues = function(match, type) {
        var regex = new RegExp(type + '[ ]*:[ ]*((?:[+-.\\d]+[ ]*,?[ ]*)+)', 'gi');
        var value = regex.exec(match);
        var result = value ? value[1].match(/\d+/gi) : [];
        return result.map(function(id) {
            return Number(id)
        });
    };

    VictorEngine.getStringValues = function(match, type) {
        var regex = new RegExp(type + '[ ]*:[ ]*((?:[\\w ]+[ ]*,?[ ]*)+)', 'gi');
        var value = regex.exec(match);
        var result = value ? value[1].match(/\d+/gi) : [];
        return result.map(function(id) {
            return value[1].trim()
        });
    };

    VictorEngine.captalizeText = function(text) {
        return text.replace(/(?:^|\s)\S/g, function(a) {
            return a.toUpperCase();
        });
    };

    VictorEngine.replaceZeros = function(text, value) {
        value = value || '';
        return text.replace(/\b(0(?!\b))+/g, function(a) {
            return a.replace(/0/g, value);
        });
    };

    VictorEngine.rgbToHex = function(r, g, b) {
        r = Math.floor(r).toString(16).padZero(2);
        g = Math.floor(g).toString(16).padZero(2);
        b = Math.floor(b).toString(16).padZero(2);
        return '#' + r + g + b;
    }

    VictorEngine.hexToRgb = function(hex) {
        var r = parseInt(hex[1] + hex[2], 16);
        var g = parseInt(hex[3] + hex[4], 16);
        var b = parseInt(hex[5] + hex[6], 16);
        return [r, g, b];
    }

    VictorEngine.methodIndex = function(methods, name) {
        for (var i = 0; i < methods.length; i++) {
            if (methods && methods.name === name) {
                return i;
            }
        }
        return null;
    }

    VictorEngine.removeMethod = function(methods, name) {
        var index = this.methodIndex(methods, name);
        if (index || index === 0) {
            methods.splice(index, 1);
        }
    }

    VictorEngine.insertMethod = function(methods, index, name, params) {
        if (index || index === 0) {
            methods.splice(index, 0, {
                name: name,
                params: params
            });
        }
    }

    VictorEngine.replaceMethod = function(methods, index, name, params) {
        if (index || index === 0) {
            methods.splice(index, 1, {
                name: name,
                params: params
            });
        }
    }

    VictorEngine.waitAnimation = function(animationId) {
        var animation = $dataAnimations[animationId];
        return animation ? animation.frames.length * 4 + 1 : 0;
    };

    VictorEngine.params = function() {
        return ['hp', 'mp', 'atk', 'def', 'mat', 'mdf', 'agi', 'luk'];
    };

    VictorEngine.xparams = function() {
        return ['hit', 'eva', 'cri', 'cev', 'mev', 'mrf', 'cnt', 'hrg', 'mrg', 'trg'];
    };

    VictorEngine.sparams = function() {
        return ['tgr', 'grd', 'rec', 'pha', 'mcr', 'tcr', 'prd', 'mrd', 'frd', 'exr'];
    };

    VictorEngine.allParams = function() {
        return this.params().concat(this.xparams(), this.sparams())
    };

    VictorEngine.paramName = function(paramId) {
        return this.params()[paramId];
    };

    VictorEngine.xparamName = function(xparamId) {
        return this.xparams()[xparamId];
    };

    VictorEngine.sparamName = function(sparamId) {
        return this.sparams()[sparamId];
    };

    VictorEngine.paramId = function(paramName) {
        return this.params().indexOf(paramName.toLowerCase());
    };

    VictorEngine.paramText = function(name) {
        switch (name.toLowerCase()) {
            case 'hit':
            case 'eva':
            case 'cri':
            case 'cev':
            case 'mev':
            case 'mrf':
            case 'cnt':
            case 'hrg':
            case 'mrg':
            case 'trg':
            case 'tgr':
            case 'grd':
            case 'rec':
            case 'pha':
            case 'mcr':
            case 'tcr':
            case 'pdr':
            case 'mdr':
            case 'fdr':
            case 'ext':
                return this.Parameters.BasicModule[name.toLowerCase()];
            case 'hp':
            case 'atk':
            case 'def':
            case 'agi':
            case 'mp':
            case 'mat':
            case 'mdf':
            case 'luk':
                var paramId = this.params().indexOf(name.toLowerCase());
                return TextManager.param(paramId)
            default:
                return this.captalizeText(name.toLowerCase());
        }
    };

    VictorEngine.battlerIndex = function(battler) {
        if (battler && battler.isActor() && $gameParty.members().contains(battler)) {
            return 1 + $gameParty.members().indexOf(battler);
        } else if (battler && battler.isEnemy() && $gameTroop.members().contains(battler)) {
            return 1 + $gameParty.maxBattleMembers() + $gameTroop.members().indexOf(battler);
        } else {
            return 0;
        }
    };

    VictorEngine.battleSprites = function(spriteId) {
        return this._battleSprites[spriteId];
    };

    VictorEngine.addBattleSprite = function(spriteId, sprite) {
        this._battleSprites = this._battleSprites || {};
        this._battleSprites[spriteId] = sprite;
    };

    //=============================================================================
    // BattleManager
    //=============================================================================

    BattleManager.updateStackAction = function(index, subject, target) {
        this._logWindow.saveMethodsStack(index);
        this.clearTargets(target);
        this.invokeAction(subject, target);
        this._logWindow.restoreMethodsStack(index);
    };

    BattleManager.clearTargets = function(target) {
        for (var i = 0; i < this._targets.length; i++) {
            if (this._targets === target) {
                this._targets.splice(i, 1);
                i--;
            }
        }
    };

    BattleManager.clearActionTargets = function() {
        this._targets = [];
    };

    BattleManager.prepareAction = function(subject, action, targets, skip) {
        this._phase = 'action';
        this._subject = subject;
        this._action = action;
        this._targets = targets;
        if (skip) {
            subject.useItem(action.item());
        }
        this._action.applyGlobal();
        this.refreshStatus();
    };

    BattleManager.startCounterAction = function(subject, target, targets, action) {
        if (targets.length > 0) {
            this._isCounterAttack = true;
            this._counterSubject = subject;
            this._counterTarget = target;
            this.prepareAction(subject, action, targets);
            this._logWindow.startCounterAction(subject, action, targets);
        }
    };

    BattleManager.averageTargetsPositions = function(targets) {
        var x = targets.reduce(function(r, member) {
            return r + member.screenX();
        }, 0) / targets.length;
        var y = targets.reduce(function(r, member) {
            return r + member.screenX();
        }, 0) / targets.length;
        return {
            x: x,
            y: y
        };
    };

    BattleManager.isSurprise = function() {
        return this._surprise;
    };

    BattleManager.isPreemptive = function() {
        return this._preemptive;
    };

    //=============================================================================
    // SceneManager
    //=============================================================================

    SceneManager.sceneSpriteset = function() {
        return this._scene ? this._scene._spriteset : null;
    };

    //=============================================================================
    // Window_Base
    //=============================================================================

    Window_Base.prototype.getFontColor = function(color) {
        if (color.match(/^\#[abcdef\d]{6}/i)) {
            return '"' + color + '"';
        } else {
            return color;
        }
    };

    //=============================================================================
    // Game_Action
    //=============================================================================

    Game_Action.prototype.setEscape = function() {
        var action = {
            name: TextManager.escape,
            speed: 9999,
            escape: true
        };
        this._escapeAction = action;
    };

    Game_Action.prototype.isEscape = function() {
        return !!this._escapeAction;
    };

    //=============================================================================
    // Game_Unit
    //=============================================================================

    Game_Unit.prototype.averageX = function() {
        return this.aliveMembers().reduce(function(r, member) {
            return r + member.screenX();
        }, 0) / this.aliveMembers().length;
    };

    Game_Unit.prototype.averageY = function() {
        return this.aliveMembers().reduce(function(r, member) {
            return r + member.screenY();
        }, 0) / this.aliveMembers().length;
    };

    //=============================================================================
    // Game_Player
    //=============================================================================

    Game_Player.prototype.follower = function(index) {
        return index === 0 ? this : this.followers().follower(index - 1);
    };

    //=============================================================================
    // Game_BattlerBase
    //=============================================================================

    Game_BattlerBase.prototype.screenX = function() {
        return this.spriteScreenX() || this._screenX || 0;
    };

    Game_BattlerBase.prototype.screenY = function() {
        return this.spriteScreenY() || this._screenY || 0;
    };

    Game_BattlerBase.prototype.homeX = function() {
        return this.battleSprite() ? this.battleSprite().homeX() : 0;
    };

    Game_BattlerBase.prototype.homeY = function() {
        return this.battleSprite() ? this.battleSprite().homeY() : 0;
    };

    Game_BattlerBase.prototype.spriteScreenX = function() {
        return this.battleSprite() ? this.battleSprite().screenX() : 0;
    };

    Game_BattlerBase.prototype.spriteScreenY = function() {
        return this.battleSprite() ? this.battleSprite().screenY() : 0;
    };

    Game_BattlerBase.prototype.mainSprite = function() {
        return this.battleSprite() ? this.battleSprite().mainSprite() : null;
    };

    Game_BattlerBase.prototype.friends = function() {
        return this.isActor() ? $gameParty : $gameTroop;
    };

    Game_BattlerBase.prototype.opponents = function() {
        return this.isEnemy() ? $gameParty : $gameTroop;
    };

    Game_BattlerBase.prototype.isOpponent = function(battler) {
        return this.isEnemy() === !battler.isEnemy();
    };

    Game_BattlerBase.prototype.idleMotions = function() {
        return ['wait', 'idle', 'dying', 'abnormal', 'guard', 'chant', 'sleep', 'victory', 'dead'];
    };

    Game_BattlerBase.prototype.isIdleMotion = function(motionType) {
        return this.idleMotions().contains(motionType);
    };

    Game_BattlerBase.prototype.isFacingDown = function() {
        return this.battlerDirection() === 'down';
    };

    Game_BattlerBase.prototype.isFacingLeft = function() {
        return this.battlerDirection() === 'left';
    };

    Game_BattlerBase.prototype.isFacingRight = function() {
        return this.battlerDirection() === 'right';
    };

    Game_BattlerBase.prototype.isFacingUp = function() {
        return this.battlerDirection() === 'up';
    };

    Game_BattlerBase.prototype.isFacingHorizontal = function() {
        return this.isFacingLeft() || this.isFacingRight();
    };

    Game_BattlerBase.prototype.isFacingVertical = function() {
        return this.isFacingDown() || this.isFacingUp();
    };

    Game_BattlerBase.prototype.turnDown = function() {
        this._battlerDirection = 'down';
    };

    Game_BattlerBase.prototype.turnLeft = function() {
        this._battlerDirection = 'left';
    };

    Game_BattlerBase.prototype.turnRight = function() {
        this._battlerDirection = 'right';
    };

    Game_BattlerBase.prototype.turnUp = function() {
        this._battlerDirection = 'up';
    };

    Game_BattlerBase.prototype.turnBack = function() {
        if (this.isFacingLeft()) {
            this.turnRight();
        } else if (this.isFacingRight()) {
            this.turnLeft();
        }
    };

    Game_BattlerBase.prototype.turnTowardCenter = function() {
        this.turnTowardPosition(Graphics.boxWidth / 2, Graphics.boxHeight / 2);
    };

    Game_BattlerBase.prototype.turnAwayFromCenter = function() {
        this.turnAwayFromPosition(Graphics.boxWidth / 2, Graphics.boxHeight / 2);
    };

    Game_BattlerBase.prototype.turnTowardOpponents = function() {
        this.turnTowardPosition(this.opponents().averageX(), this.opponents().averageY());
    };

    Game_BattlerBase.prototype.turnAwayFromOpponents = function() {
        this.turnAwayFromPosition(this.opponents().averageX(), this.opponents().averageY);
    };

    Game_BattlerBase.prototype.turnTowardTargets = function(targets) {
        var position = BattleManager.averageTargetsPositions(targets);
        this.turnTowardPosition(position.x, position.y);
    };

    Game_BattlerBase.prototype.turnAwayFromTargets = function(targets) {
        var position = BattleManager.averageTargetsPositions(targets);
        this.turnAwayFromPosition(position.x, position);
    };

    Game_BattlerBase.prototype.turnTowardPosition = function(positionX, positionY) {
        if (this.screenX() < positionX) {
            this.turnRight();
        } else if (this.screenX() > positionX) {
            this.turnLeft();
        }
    };

    Game_BattlerBase.prototype.turnAwayFromPosition = function(positionX, positionY) {
        if (this.screenX() < positionX) {
            this.turnLeft();
        } else if (this.screenX() > positionX) {
            this.turnRight();
        }
    };

    Game_BattlerBase.prototype.isBehind = function(target) {
        return (target.isFacingRight() && this.screenX() < target.screenX()) ||
            (target.isFacingLeft() && this.screenX() > target.screenX());
    };

    Game_BattlerBase.prototype.isSpriteEffecting = function() {
        return this.battleSprite() && this.battleSprite().isEffecting();
    };

    Game_BattlerBase.prototype.isSpriteMoving = function() {
        return this.battleSprite() && this.battleSprite().isMoving();
    };

    Game_BattlerBase.prototype.isSpriteAnimation = function() {
        return this.battleSprite() && this.battleSprite().isAnimationPlaying();
    };

    Game_BattlerBase.prototype.isAnimatedBattler = function() {
        return this.battleSprite() && this.battleSprite().isAnimatedBattler();
    };

    Game_BattlerBase.prototype.isStaticBattler = function() {
        return this.battleSprite() && this.battleSprite().isStaticBattler();
    };

    Game_BattlerBase.prototype.inHomePosition = function() {
        return this.battleSprite() && this.battleSprite().inHomePosition();
    };

    Game_BattlerBase.prototype.notIinHomePosition = function() {
        return !this.inHomePosition();
    };

    Game_BattlerBase.prototype.isCounterAttack = function() {
        return this._counterAttack;
    };

    Game_BattlerBase.prototype.startCounterAttack = function() {
        this._counterAttack = true;
    };

    Game_BattlerBase.prototype.endCounterAttack = function() {
        this._counterAttack = false;
    };

    Game_BattlerBase.prototype.battleSprite = function() {
        return VictorEngine.battleSprites(this.spriteId());
    };

    Game_BattlerBase.prototype.setBattleSprite = function(sprite) {
        VictorEngine.addBattleSprite(this.spriteId(), sprite);
    };

    Game_BattlerBase.prototype.clearBattleSprite = function() {
        VictorEngine.addBattleSprite(this.spriteId(), null);
    };

    Game_BattlerBase.prototype.addNewAction = function(action) {
        this._actions.unshift(action);
    };

    Game_BattlerBase.prototype.startEscapeCommand = function() {
        this._isEscapeCommand = true;
    };
    Game_BattlerBase.prototype.endEscapeCommand = function() {
        this._isEscapeCommand = false;
    };
    Game_BattlerBase.prototype.isEscapeCommand = function() {
        return this._isEscapeCommand;
    };

    //=============================================================================
    // Game_Battler
    //=============================================================================

    VictorEngine.BasicModule.onBattleEnd = Game_Battler.prototype.onBattleEnd;
    Game_Battler.prototype.onBattleEnd = function() {
        VictorEngine.BasicModule.onBattleEnd.call(this);
        this.clearBattleSprite();
    };

    //=============================================================================
    // Game_Actor
    //=============================================================================

    Game_Actor.prototype.battlerDirection = function() {
        return this._battlerDirection || 'left';
    };

    Game_Actor.prototype.spriteId = function() {
        return 'actor ' + String(this.actorId());
    };

    //=============================================================================
    // Game_Enemy
    //=============================================================================

    Game_Enemy.prototype.battlerDirection = function() {
        return this._battlerDirection || ($gameSystem.isSideView() ? 'right' : 'left');
    };

    Game_Enemy.prototype.attackAnimationId1 = function() {
        return 0;
    };

    Game_Enemy.prototype.attackAnimationId2 = function() {
        return 0;
    };

    Game_Enemy.prototype.spriteId = function() {
        return 'enemy ' + String(this.index());
    };

    //=============================================================================
    // Sprite_Battler
    //=============================================================================

    Object.defineProperties(Sprite_Battler.prototype, {
        z: {
            get: function() {
                return 3;
            },
            configurable: true
        },
        h: {
            get: function() {
                return this.spriteZ();
            },
            configurable: true
        }
    });

    Sprite_Battler.prototype.isEnemy = function() {
        return this._battler && this._battler.isEnemy();
    };

    Sprite_Battler.prototype.isVisible = function() {
        return this.visible && this.opacity > 0;
    };

    Sprite_Battler.prototype.isDamagePopup = function() {
        return this._damages.length > 0;
    };

    Sprite_Battler.prototype.isDisabledMotion = function() {
        var motion = Sprite_Actor.MOTIONS;
        return this._motion === motion['dead'] || this._motion === motion['sleep'];
    };

    Sprite_Battler.prototype.isAnimatedBattler = function() {
        return false;
    };

    Sprite_Battler.prototype.isStaticBattler = function() {
        return false;
    };

    Sprite_Battler.prototype.spriteZ = function() {
        return this.screenY();
    };

    Sprite_Battler.prototype.screenX = function() {
        return this._homeX + this._offsetX;
    };

    Sprite_Battler.prototype.screenY = function() {
        return this._homeY + this._offsetY;
    };

    Sprite_Battler.prototype.homeX = function() {
        return this._homeX;
    };

    Sprite_Battler.prototype.homeY = function() {
        return this._homeY;
    };

    Sprite_Battler.prototype.mainSprite = function() {
        return this._mainSprite;
    };

    Sprite_Battler.prototype.noEntryMove = function() {
        return this._battler && !this._battler.canMove();
    };

    Sprite_Battler.prototype.center = function() {
        var sprite = this._mainSprite ? this._mainSprite : this;
        var x = sprite._frame.width / 2 || 0;
        var y = sprite._frame.height / 2 || 0;
        return {
            x: x,
            y: y
        };
    };

    //=============================================================================
    // Sprite_Actor
    //=============================================================================

    Sprite_Actor.prototype.updateBattlerDirection = function() {
        if (this._battler && !this.isDisabledMotion()) {
            if ((this._battler.isFacingLeft() && this.scale.x < 0) ||
                (this._battler.isFacingRight() && this.scale.x > 0)) {
                this.scale.x *= -1;
            }
        }
    };

    //=============================================================================
    // Sprite_Enemy
    //=============================================================================

    Sprite_Enemy.prototype.updateBattlerDirection = function() {
        if (this._battler && !this.isDisabledMotion()) {
            if ((this._battler.isFacingLeft() && this.scale.x > 0) ||
                (this._battler.isFacingRight() && this.scale.x < 0)) {
                this.scale.x *= -1;
            }
        }
    };

    Sprite_Enemy.prototype.isStaticBattler = function() {
        return true;
    };

    //=============================================================================
    // Sprite_Damage
    //=============================================================================

    Object.defineProperties(Sprite_Damage.prototype, {
        z: {
            get: function() {
                return 10;
            },
            configurable: true
        }
    });

    //=============================================================================
    // Spriteset_Battle
    //=============================================================================

    VictorEngine.BasicModule.setBattler = Sprite_Battler.prototype.setBattler;
    Sprite_Battler.prototype.setBattler = function(battler) {
        VictorEngine.BasicModule.setBattler.call(this, battler);
        if (battler) {
            battler.setBattleSprite(this);
        }
    };

    Spriteset_Battle.prototype.sortBattleSprites = function() {
        if (this._sortChildrenFrame !== Graphics.frameCount) {
            this._battleField.children.sort(this.compareBattleSprites.bind(this));
            this._sortChildrenFrame = Graphics.frameCount;
        }
    };

    Spriteset_Battle.prototype.compareBattleSprites = function(a, b) {
        if ((a.z || 0) !== (b.z || 0)) {
            return (a.z || 0) - (b.z || 0);
        } else if ((a.h || 0) !== (b.h || 0)) {
            return (a.h || 0) - (b.h || 0);
        } else if ((a.y || 0) !== (b.y || 0)) {
            return (a.y || 0) - (b.y || 0);
        } else {
            return a.spriteId - b.spriteId;
        }
    };

    //=============================================================================
    // Window_Base
    //=============================================================================

    Window_Base.prototype.textWidthEx = function(text) {
        if (text) {
            var state = {
                index: 0,
                x: 0
            };
            state.text = this.convertEscapeCharacters(text);
            while (state.index < state.text.length) {
                this.processCharacter(state)
            };
            return state.x;
        } else {
            return 0;
        }
    };

    //=============================================================================
    // Window_BattleLog
    //=============================================================================

    Window_BattleLog.prototype.waitForBattleAnimation = function(animationId, speed) {
        var speed = Math.max(speed, 1) || 1;
        this.waitForTime(VictorEngine.waitAnimation(animationId) / speed);
    };

    Window_BattleLog.prototype.startCounterAction = function(subject, action, targets) {
        this.push('addText', TextManager.counterAttack.format(subject.name()));
        this.startAction(subject, action, targets);
    };

    Window_BattleLog.prototype.waitForTime = function(time) {
        this._waitCount = time;
    };

    Window_BattleLog.prototype.setupStartAction = function(subject, action, targets) {
        if (this._setupStartActionFrame !== Graphics.frameCount) {
            VictorEngine.removeMethod(this._methods, 'showAnimation');
            VictorEngine.removeMethod(this._methods, 'waitForBattleAnimation');
            this.push('prepareAction', subject, action, targets);
            this._setupStartActionFrame = Graphics.frameCount;
        }
    };

    Window_BattleLog.prototype.initializeMethodsStack = function() {
        this._stackWaitCount = [];
        this._stackWaitMode = [];
        this._methodsStack = [];
        this._stackIndex = 0;
    };

    Window_BattleLog.prototype.prepareAction = function(subject, action, targets) {
        this.uniqueTargets(targets).forEach(function(unique) {
            this._stackIndex = VictorEngine.battlerIndex(unique.target);
            this.prepareUniqueAction(subject, action, unique.target, unique.repeat)
        }, this)
        this._stackIndex = 0;
    };

    Window_BattleLog.prototype.prepareUniqueAction = function(subject, action, target, repeat) {
        this.prepareUniqueActionStep1(subject, action, target, repeat);
        this.prepareUniqueActionStep2(subject, action, target, repeat);
        this.prepareUniqueActionStep3(subject, action, target, repeat);
    };

    Window_BattleLog.prototype.prepareUniqueActionStep1 = function(subject, action, target, repeat) {
        var item = action.item();
        this.push('showAnimation', subject, [target], item.animationId);
    };

    Window_BattleLog.prototype.prepareUniqueActionStep2 = function(subject, action, target, repeat) {
        var item = action.item();
        var animId = this.uniqueActionAnimationId(subject, item)
        this.push('waitForBattleAnimation', animId);
    };

    Window_BattleLog.prototype.prepareUniqueActionStep3 = function(subject, action, target, repeat) {
        for (var i = 0; i < repeat; i++) {
            if (i > 0) {
                this.push('waitForTime', 1);
            }
            this.push('updateStackAction', this._stackIndex, subject, target);
        }
    };

    Window_BattleLog.prototype.uniqueActionAnimationId = function(subject, item) {
        if (item.animationId < 0) {
            return subject.attackAnimationId1();
        } else {
            return item.animationId;
        }
    }

    Window_BattleLog.prototype.uniqueTargets = function(targets) {
        var repeats = [];
        targets.forEach(function(target, i) {
            var index = targets.indexOf(target);
            if (index === i) {
                repeats[index] = {
                    target: target,
                    repeat: 1
                };
            } else {
                repeats[index].repeat++;
            }
        })
        return repeats.filter(function(repeat) {
            return !!repeat
        });
    }

    Window_BattleLog.prototype.updateMethodsStack = function() {
        var methods = this._methodsStack;
        for (var i = 0; i < methods.length; i++) {
            if (methods && methods.length > 0) {
                while (methods.length > 0 && !this.updateStackWait(i)) {
                    this.callNextStackMethod(i);
                }
            }
        }
        if (this.isStackEmpty()) {
            this._methodsStack = [];
        }
    };

    Window_BattleLog.prototype.isStackEmpty = function() {
        return this._methodsStack.every(function(methods) {
            return !methods || methods.length === 0;
        })
    };

    Window_BattleLog.prototype.stackBattler = function(index) {
        if (index > 0) {
            var max = $gameParty.maxBattleMembers();
            if (index > max) {
                return $gameTroop.members()[index - max - 1];
            } else {
                return $gameParty.members()[index - 1];
            }
        } else {
            return null;
        }
    };

    Window_BattleLog.prototype.callNextStackMethod = function(index) {
        var method = this._methodsStack[index].shift();
        if (method.name && this[method.name]) {
            this[method.name].apply(this, method.params);
        } else {
            throw new Error('Method not found: ' + method.name);
        }
    };

    Window_BattleLog.prototype.saveMethodsStack = function(index) {
        this._saveStackIndex = this._stackIndex;
        this._saveMethodsStack = this._methodsStack[index].clone();
        this._stackIndex = index;
        this._methodsStack[index] = [];
    };

    Window_BattleLog.prototype.restoreMethodsStack = function(index) {
        this._methodsStack[index] = this._methodsStack[index].concat(this._saveMethodsStack);
        this._stackIndex = this._saveStackIndex;
    };

    Window_BattleLog.prototype.methodStackActive = function() {
        return this._methodsStack.length > 0;
    };

    Window_BattleLog.prototype.updateStackAction = function(index, subject, target) {
        BattleManager.updateStackAction(index, subject, target);
    };

    Window_BattleLog.prototype.pushMethodsStack = function(methodName) {
        var index = this._stackIndex || 0;
        var methodArgs = Array.prototype.slice.call(arguments, 1);
        if (methodName === 'wait') {
            methodName = 'stackWait';
            methodArgs.unshift(index);
        } else if (methodName === 'waitForTime') {
            methodName = 'stackWaitForTime';
            methodArgs.unshift(index);
        } else if (methodName === 'waitForBattleAnimation') {
            methodName = 'stackWaitFoAnimation';
            methodArgs.unshift(index);
        } else if (methodName === 'updateWaitMode') {
            methodName = 'updateStackWaitMode';
            methodArgs.unshift(index);
        } else if (methodName === 'setWaitMode') {
            methodName = 'setStackWaitMode';
            methodArgs.unshift(index);
        }
        this._methodsStack[index] = this._methodsStack[index] || [];
        this._methodsStack[index].push({
            name: methodName,
            params: methodArgs
        });
    };

    Window_BattleLog.prototype.updateStackWait = function(index) {
        return this.updateStackWaitCount(index) || this.updateStackWaitMode(index);
    };

    Window_BattleLog.prototype.updateStackWaitCount = function(index) {
        if (this._stackWaitCount[index] && this._stackWaitCount[index] > 0) {
            this._stackWaitCount[index]--;
            return true;
        }
        return false;
    };

    Window_BattleLog.prototype.stackWait = function(index) {
        this.stackWaitForTime(index, this.messageSpeed());
    };

    Window_BattleLog.prototype.stackWaitFoAnimation = function(index, animationId, speed) {
        var speed = Math.max(speed, 1) || 1;
        this.stackWaitForTime(index, VictorEngine.waitAnimation(animationId) / speed);
    };

    Window_BattleLog.prototype.stackWaitForTime = function(index, time) {
        this._stackWaitCount[index] = time;
    };

    Window_BattleLog.prototype.updateStackWaitMode = function(index) {
        var battler = this.stackBattler(index);
        var waitMode = this._stackWaitMode[index] || [];
        if (waitMode.contains('effect')) {
            var waiting = battler ? battler.isSpriteEffecting() : this._spriteset.isEffecting();
            if (waiting) {
                return true;
            } else {
                this.removeWaitMode(index, 'effect');
            }
        }
        if (waitMode.contains('movement')) {
            var waiting = battler ? battler.isSpriteMoving() : this._spriteset.isAnyoneMoving();
            if (waiting) {
                return true;
            } else {
                this.removeWaitMode(index, 'movement');
            }
        }
        this._stackWaitMode[index] = [];
        return false;
    };

    Window_BattleLog.prototype.setStackWaitMode = function(index, waitMode) {
        this._stackWaitMode[index] = this._stackWaitMode[index] || [];
        if (!this._stackWaitMode[index].contains(waitMode)) {
            this._stackWaitMode[index].push(waitMode);
        }
    };

    Window_BattleLog.prototype.removeWaitMode = function(index, waitMode) {
        this._stackWaitMode[index] = this._stackWaitMode[index] || [];
        var waitIndex = this._stackWaitMode[index].indexOf(waitMode);
        this._stackWaitMode[index].splice(waitIndex, 1);
    };

    Window_BattleLog.prototype.startEscape = function(subject, action) {
        subject._isEscapeCommand = true;
    };

    Window_BattleLog.prototype.performEscape = function(subject) {
        $gameParty._skipClear = true;
        BattleManager.processEscape();
        $gameParty._skipClear = false;
    };

    Window_BattleLog.prototype.setupCurrentAction = function(subject, action, targets) {};

})();[/pre]

这是本体插件:(我自己稍微汉化了一下)
[pre lang="javascript"]/*
/*
* ==============================================================================
* ** Victor Engine MV - Cooperation Skills
* ------------------------------------------------------------------------------
*  CooperationSkills.js
* ==============================================================================
*/

var Imported = Imported || {};
Imported['VE - Cooperation Skills'] = '1.00';

var VictorEngine = VictorEngine || {};
VictorEngine.CooperationSkills = VictorEngine.CooperationSkills || {};

(function() {

    VictorEngine.CooperationSkills.loadDatabase = DataManager.loadDatabase;
    DataManager.loadDatabase = function() {
        VictorEngine.CooperationSkills.loadDatabase.call(this);
        PluginManager.requiredPlugin.call(PluginManager, 'VE - Cooperation Skills', 'VE - Basic Module', '1.22');
        PluginManager.requiredPlugin.call(PluginManager, 'VE - Cooperation Skills', 'VE - Skip Battle Log');
    };

    VictorEngine.CooperationSkills.requiredPlugin = PluginManager.requiredPlugin;
    PluginManager.requiredPlugin = function(name, required, version) {
        if (!VictorEngine.BasicModule) {
            var msg = '插件 ' + name + ' 需要基础插件 ' + required;
            msg += ' 版本' + version + ' 或以上才能生效。';
            msg += ' 去 http://victorenginescripts.wordpress.com/ 下载插件。';
            throw new Error(msg);
        } else if (Imported.YEP_BattleEngineCore) {
            var msg = '插件 ' + name + " 与";
            msg += ' 插件 YEP Battle Engine Core不兼容。';
            throw new Error(msg);
        } else {
            VictorEngine.CooperationSkills.requiredPlugin.call(this, name, required, version);
        };
    };

})();

/*:
* ==============================================================================
* @plugindesc v1.00 - 合作技
* 战斗者可以一同做出行动。
* @author Victor Sant
*
* ==============================================================================
* @help
* ==============================================================================
* 角色、职业、敌人、武器、防具和状态注释:
* ==============================================================================
*
* ==============================================================================
*  联合技(技能注释)
* ------------------------------------------------------------------------------
*  <unite skill: X[, X...]>
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*  特定的角色一同发动该技能。
*    x: 角色ID
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*  例.: <unite skill: 1, 2>
*       <unite skill: 3, 6, 4>
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*  注:
*  - 你放置id的顺序与伤害公式相关,如果你使用插件'VE -战斗动作'的动
*    作序列。
* ==============================================================================
*
* ==============================================================================
*  融合技 (技能注释)
* ------------------------------------------------------------------------------
*  <fusion skill: X[, X...]>
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*  当战斗人员使用同一回合列出的特定技能时,他们将加入执行该技能。
*    x : 技能ID
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*  例: <fusion skill: 10, 12>
*       <fusion skill: 8, 8, 8>
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*  NOTES:
*  - 你放置id的顺序与伤害公式相关,如果你使用插件'VE -战斗动作'的动
*    作序列。
*  - 多次使用相同的id意味着不止一名战士必须使用相同的技能。
* ==============================================================================
*
* ==============================================================================
*  组合技 (技能注释)
* ------------------------------------------------------------------------------
*  <combination skill: X>
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*  要执行此技能,必须有多个战士在同一回合使用此技能。
*    x : 所需的战斗者数量
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*  例.: <combination skill: 3>
* ==============================================================================
*
* ==============================================================================
* 另外的信息:
* ------------------------------------------------------------------------------
*  
*  合作技设置是在回合开始时完成的,即在所有输入完成之后。所以,如
*  果作为组合的一部分的战斗人员无法使用该技能,那么该组合就会失败,
*  所有参与其中的战斗人员都将失去该回合。
*
*  组合行动的时间是基于最慢的战斗者所涉及的速度。
*
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*
*  - 联合技
*  “联合类型”要求所有角色都有技能学习和可用。当您为第一个角色选择技
*  能时,所需的所有其他角色将自动选择相同的技能。统一技能只适用于角
*  色。
*
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*
*  - 融合技
*  “融合类型”是基于所使用的技能,如果所有所需的技能都被选中,使用这
*  些技能的战斗人员的行动将被融合技能取代。动作是在所有命令被选择后
*  ,在回合开始前设置的。战斗人员不需要学习技能就能使用。
*
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*
*  - 组合技
*  “组合类型”是基于使用该技能的战斗人员的数量。如果达到了所需的战斗
*  人员数量,就会使用该技能。不同于联合技能,每个战士单独选择技能。
*
* ==============================================================================
*
* ==============================================================================
*  合作技和伤害公式:
* ------------------------------------------------------------------------------
*  当使用动作时,只会考虑当前激活的战斗者(即调用合作技时激活的战斗
*  者)的参数。若想在伤害公式中使用其他战斗者的参数,你可以使用 cp[X]
*  来引用参数,其中X是合作注释中战斗者的位置(对于联合技来说基于
*  角色的ID,对于融合技来说基于战斗者所使用的技能ID,对于组合技来
*  说基于选择动作的顺序)
*
*  例如,设置了以下注释:
*  <unite skill: 3, 6, 4>
*  - 使用cp[1]来引用第一个角色(角色#3)
*  - 使用cp[2]来引用第二个角色(角色#6)
*  - 使用cp[3]来引用第二个角色(角色#4)
*  
*  例如,伤害公式可以这样写:
*  (cp[1].atk + cp[2].atk + cp[3].atk) * 4 - b.def * 2
*  
* ==============================================================================
*
* ===============================================================================
*  合作技与即时战斗:
* -------------------------------------------------------------------------------
*  如果使用插件'VE - Active Time Battle',只有联合类型的合作技会
*  生效。还要注意的是,所有必要的战斗都必须让ATB栏是满的,如
*  果你使用“满等待”和“半等待”的更新模式,可能会更难设置组合,
*  因为在选择动作时ATB会被冻结。因此,建议只使用“半激活”和
*  “完全激活”模式。

* ==============================================================================
*
* ===============================================================================
*  合作技和战斗动作:
* -------------------------------------------------------------------------------
*  If using the plugin 'VE - Battle Motions', you can use new [subject] values
*  of the motions for cooperation skills.
*
* ------------------------------------------------------------------------------
*  Here are all possible [subjects] values:
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*   cooperation X   : the Xth battler participating on the cooperation skill.
*   all cooperation : all battlers participating on the cooperation skill.
* ------------------------------------------------------------------------------
*
* -----------------------------------------------------------------------------
*  - Motion Subjects: Combination X
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*  This subject value will choose one of the combination battlers, based on the
*  type of cooperation and the order of the values on the notetag (similar to
*  how the damage formula choose the battlers)
*  
*  For example. you have the following notetag:
*  <unite skill: 3, 6, 4>
*  if you use motion 'move: cooperation 2, close to target, 12, 80;'
*  the second cooperation member (the actor Id 6) will move close to the target
* ==============================================================================
*
* ==============================================================================
* 兼容性:
* ------------------------------------------------------------------------------
* To be used together with this plugin, the following plugins must be placed
* bellow this plugin:
*    VE - Skip Battle Log
* ==============================================================================
*
* ==============================================================================
*  版本历史:
* ------------------------------------------------------------------------------
*  v 1.00 - 2016.07.20 > First release.
* ==============================================================================
*/

(function() {

    //=============================================================================
    // Parameters
    //=============================================================================

    if (Imported['VE - Basic Module']) {
        var parameters = VictorEngine.getPluginParameters();
        VictorEngine.Parameters = VictorEngine.Parameters || {};
        VictorEngine.Parameters.CooperationSkills = {};
        VictorEngine.Parameters.CooperationSkills.PluginParameter = Number(parameters["Plugin Parameter"]) || 0;
        VictorEngine.Parameters.CooperationSkills.PluginParameter = String(parameters["Plugin Parameter"]).trim();
        VictorEngine.Parameters.CooperationSkills.PluginParameter = eval(parameters["Plugin Parameter"]);
    }

    //=============================================================================
    // VictorEngine
    //=============================================================================

    VictorEngine.CooperationSkills.loadNotetagsValues = VictorEngine.loadNotetagsValues;
    VictorEngine.loadNotetagsValues = function(data, index) {
        VictorEngine.CooperationSkills.loadNotetagsValues.call(this, data, index);
        if (this.objectSelection(index, ['skill'])) {
            VictorEngine.CooperationSkills.loadNotes(data);
        }
    };

    VictorEngine.CooperationSkills.loadNotes = function(data) {
        data.cooperationSkill = data.cooperationSkill || {};
        this.processNotes(data);
    };

    VictorEngine.CooperationSkills.processNotes = function(data, type) {
        var match;
        var regex1 = new RegExp('<unite skill:[ ]*((?:\\d+[ ]*,?[ ]*)+)[ ]*>', 'gi');
        var regex2 = new RegExp('<fusion skill:[ ]*((?:\\d+[ ]*,?[ ]*)+)[ ]*>', 'gi');
        var regex3 = new RegExp('<combination skill:[ ]*(\\d+)[ ]*>', 'gi');
        while (match = regex1.exec(data.note)) {
            data.cooperationSkill.unite = this.processValues(data, match);
        };
        while (match = regex2.exec(data.note)) {
            data.cooperationSkill.fusion = this.processValues(data, match);
        };
        while (match = regex3.exec(data.note)) {
            data.cooperationSkill.combination = Number(match[1]);
        };
        var skill = data.cooperationSkill;
        var isUnite = skill.unite && skill.unite.length > 1;
        var isFusion = skill.fusion && skill.fusion.length > 1;
        var isCombination = skill.combination && skill.combination > 1;
        data.isCooperation = isUnite || isFusion || isCombination;
    };

    VictorEngine.CooperationSkills.processValues = function(data, match) {
        return match[1].split(/[ ]*,[ ]*/gi).map(function(value) {
            return Number(value);
        });
    };

    //=============================================================================
    // BattleManager
    //=============================================================================

    VictorEngine.CooperationSkills.startTurn = BattleManager.startTurn;
    BattleManager.startTurn = function() {
        if (!Imported['VE - Active Time Battle']) {
            this.prepareCombinationActions();
        }
        VictorEngine.CooperationSkills.startTurn.call(this);
    };

    VictorEngine.CooperationSkills.startAction = BattleManager.startAction;
    BattleManager.startAction = function() {
        if (Imported['VE - Active Time Battle']) {
            this.setupUnionSkills();
        }
        VictorEngine.CooperationSkills.startAction.call(this);
    };

    BattleManager.prepareCombinationActions = function() {
        this.setupUnionSkills();
        this.setupFusionSkills();
        this.setupCombinationSkills();
    };

    BattleManager.setupUnionSkills = function() {
        $gameParty.members().forEach(function(member) {
            if (member.uniteLeaderSkill()) {
                member.setupUniteBaltters();
            }
        });
    };

    BattleManager.setupFusionSkills = function() {
        for (var i = 1; i < $dataSkills.length; i++) {
            var skill = $dataSkills
            if (skill.cooperationSkill.fusion) {
                this.setupFusionBattlers(skill, $gameParty.members());
                this.setupFusionBattlers(skill, $gameTroop.members());
            }
        };
        this.allBattleMembers().forEach(function(member) {
            if (member.fusionLeaderSkill()) {
                member.setupFusionBaltters();
            }
        });
    };

    BattleManager.setupCombinationSkills = function() {
        for (var i = 1; i < $dataSkills.length; i++) {
            var skill = $dataSkills
            if (skill.cooperationSkill.combination) {
                this.setupCombinationBattlers(skill, $gameParty.members());
                this.setupCombinationBattlers(skill, $gameTroop.members());
            }
        };
        this.allBattleMembers().forEach(function(member) {
            if (member.combinationLeaderSkill()) {
                member.setupCombinationBaltters();
            }
        });
    };

    BattleManager.setupFusionBattlers = function(skill, members) {
        for (var i = 0; i < members.length; i++) {
            var fusion = this.getFusionList(skill, members);
            if (fusion.length === skill.cooperationSkill.fusion.length) {
                fusion[0].member.setFusionLeader(skill, fusion[0].id);
                for (var j = 1; j < fusion.length; j++) {
                    fusion[j].member.setFusionMember(fusion[0].member, fusion[j].id);
                };
            }
        }
    };

    BattleManager.getFusionList = function(skill, members) {
        var fusion = [];
        var skills = skill.cooperationSkill.fusion;
        for (var i = 0; i < skills.length; i++) {
            var id = skills;
            var member = this.getFusionMember(members, fusion, id);
            if (member) {
                fusion.push({
                    member: member,
                    id: id
                });
            }
        };
        return fusion;
    };

    BattleManager.getFusionMember = function(members, fusion, id) {
        for (var i = 0; i < members.length; i++) {
            var member = members;
            if (this.notFusionMember(fusion, member) && member.isUsingFusion(id)) {
                return member;
            }
        };
        return null;
    };

    BattleManager.notFusionMember = function(fusions, member) {
        return fusions.every(function(fusion) {
            return fusion.member !== member;
        })
    };

    BattleManager.setupCombinationBattlers = function(skill, members) {
        for (var i = 0; i < members.length; i++) {
            var combination = this.getCombinationList(skill, members);
            if (combination.length === skill.cooperationSkill.combination) {
                combination[0].setCombinationLeader(skill);
                for (var j = 1; j < combination.length; j++) {
                    combination[j].setCombinationMember(combination[0]);
                };
            }
        };
    };

    BattleManager.getCombinationList = function(skill, members) {
        var combination = [];
        var skills = skill.cooperationSkill.combination;
        for (var i = 0; i < skills; i++) {
            var member = this.getCombinationMember(members, combination, skill.id);
            if (member) {
                combination.push(member);
            }
        };
        return combination;
    };

    BattleManager.getCombinationMember = function(members, combination, id) {
        for (var i = 0; i < members.length; i++) {
            var member = members;
            if (!combination.contains(member) && member.isUsingCombination(id)) {
                return member;
            }
        };
        return null;
    };

    //=============================================================================
    // Game_Action
    //=============================================================================

    /* Overwritten function */
    Game_Action.prototype.evalDamageFormula = function(target) {
        try {
            var item = this.item();
            var a = this.subject();
            var b = target;
            var v = $gameVariables._data;
            var cp = this.cooperationBattlersFormula();
            var formula = VictorEngine.getDamageFormula(this);
            var sign = ([3, 4].contains(item.damage.type) ? -1 : 1);
            return (Math.max(eval(formula), 0) * sign) || 0;
        } catch (e) {
            return 0;
        }
    };

    VictorEngine.CooperationSkills.isValid = Game_Action.prototype.isValid;
    Game_Action.prototype.isValid = function() {
        return VictorEngine.CooperationSkills.isValid.call(this) && !this.subject().cooperationMember() &&
            this.isCombinationOk();
    };

    Game_Action.prototype.setCooperationBattlers = function() {
        this._cooperationBattlers = this.cooperationActionBattlers();
    };

    Game_Action.prototype.cooperationBattlers = function() {
        return this._cooperationBattlers || [];
    };

    Game_Action.prototype.cooperationBattlersFormula = function() {
        return this.isCooperation() ? [{}].concat(this.cooperationBattlers()) : [];
    };

    Game_Action.prototype.isCooperation = function() {
        return this.item() && this.item().isCooperation;
    };

    Game_Action.prototype.isUniteAction = function() {
        return this.isCooperation() && this.item().cooperationSkill.unite;
    };

    Game_Action.prototype.isFusionAction = function() {
        return this.isCooperation() && this.item().cooperationSkill.fusion;
    };

    Game_Action.prototype.isCombinationAction = function() {
        return this.isCooperation() && this.item().cooperationSkill.combination;
    };

    Game_Action.prototype.cooperationActionBattlers = function() {
        if (this.isUniteAction()) {
            return this.uniteActionBattlers();
        } else if (this.isFusionAction()) {
            return this.fusionActionBattlers();
        } else if (this.isCombinationAction()) {
            return this.combinationActionBattlers();
        }
        return [];
    };

    Game_Action.prototype.cooperationLength = function() {
        if (this.isUniteAction()) {
            return this.item().cooperationSkill.unite.length;
        } else if (this.isFusionAction()) {
            return this.item().cooperationSkill.fusion.length;
        } else if (this.isCombinationAction()) {
            return this.item().cooperationSkill.combination;
        }
        return 0;
    };

    Game_Action.prototype.uniteActionBattlers = function() {
        return this.item().cooperationSkill.unite.map(function(id) {
            return $gameActors.actor(id);
        });
    };

    Game_Action.prototype.fusionActionBattlers = function() {
        var object = this;
        var leader = this.subject();
        var skills = this.item().cooperationSkill.fusion;
        var fusion = [leader];
        for (var i = 1; i < skills.length; i++) {
            var id = skills;
            var member = this.getFusionBattler(leader, id, fusion);
            if (member) {
                fusion.push(member);
            }
        }
        return fusion;
    };

    Game_Action.prototype.getFusionBattler = function(leader, id, fusion) {
        var members = BattleManager.allBattleMembers();
        for (var i = 0; i < members.length; i++) {
            var member = members;
            if (member.isOriginalFusionSkill(id) && member.fusionLeader() === leader &&
                !fusion.contains(member)) {
                return member;
            }
        }
        return null;
    };

    Game_Action.prototype.combinationActionBattlers = function() {
        var object = this;
        var leader = this.subject();
        var combination = [leader];
        for (var i = 1; i < this.item().cooperationSkill.combination; i++) {
            var member = this.getCombinationBattler(leader, combination);
            if (member) {
                combination.push(member);
            }
        }
        return combination;
    };

    Game_Action.prototype.getCombinationBattler = function(leader, combination) {
        var members = BattleManager.allBattleMembers();
        for (var i = 0; i < members.length; i++) {
            var member = members;
            if (member.combinationLeader() === leader && !combination.contains(member)) {
                return member;
            }
        }
        return null;
    };

    Game_Action.prototype.isCombinationOk = function() {
        if (this.isCombinationAction()) {
            if (this.subject().combinationLeaderSkill()) {
                return this.combinationMembersOk();
            } else {
                return false;
            }
        } else {
            return true;
        };
    };

    Game_Action.prototype.combinationMembersOk = function() {
        var skill = this.item();
        return this.cooperationBattlers().every(function(member) {
            return member.canUse(skill);
        })
    };

    //=============================================================================
    // Game_BattlerBase
    //=============================================================================

    VictorEngine.CooperationSkills.paySkillCost = Game_BattlerBase.prototype.paySkillCost;
    Game_BattlerBase.prototype.paySkillCost = function(skill) {
        VictorEngine.CooperationSkills.paySkillCost.call(this, skill);
        if (skill.isCooperation && this.isCooperationSkill(skill)) {
            var user = this;
            this.cooperationBattlers(skill).forEach(function(battler) {
                if (battler !== user) {
                    battler.payCooperationSkillCost(skill);
                }
            });
        }
    };

    VictorEngine.CooperationSkills.canInput = Game_BattlerBase.prototype.canInput;
    Game_BattlerBase.prototype.canInput = function() {
        return VictorEngine.CooperationSkills.canInput.call(this) && !this.uniteLeader();
    };

    VictorEngine.CooperationSkills.meetsSkillConditions = Game_BattlerBase.prototype.meetsSkillConditions;
    Game_BattlerBase.prototype.meetsSkillConditions = function(skill) {
        return (VictorEngine.CooperationSkills.meetsSkillConditions.call(this, skill) &&
            this.isSkillCooperationOk(skill));
    };

    Game_BattlerBase.prototype.isSkillCooperationOk = function(skill) {
        return !skill.isCooperation || this.isCooperationOk(skill);
    };

    Game_BattlerBase.prototype.isCooperationOk = function(skill) {
        return this.isUniteOk(skill) || this.isFusionOk(skill) || this.isCombinationOk(skill);
    };

    Game_BattlerBase.prototype.isUniteOk = function(skill) {
        if (this.isEnemy() || !skill.cooperationSkill.unite) {
            return false;
        }
        return this.uniteBattlers(skill).every(function(actor) {
            return actor.isUniteMemberOk(skill) && !actor.isUsingNonUnite() &&
                (!Imported['VE - Active Time Battle'] || actor.atbFull());
        });
    };

    Game_BattlerBase.prototype.isFusionOk = function(skill) {
        if (!$gameParty.inBattle() || !skill.cooperationSkill.fusion) {
            return false;
        }
        return this.fusionBattlers(skill).every(function(actor) {
            return actor.isFusionMemberOk(actor.originalFusionSkill());
        });
    };

    Game_BattlerBase.prototype.isCombinationOk = function(skill) {
        if (!$gameParty.inBattle() || !skill.cooperationSkill.combination) {
            return false;
        } else {
            return true;
        }
    };

    Game_BattlerBase.prototype.isUniteMemberOk = function(skill) {
        return $gameParty.members().contains(this) && this.hasSkill(skill.id) &&
            VictorEngine.CooperationSkills.meetsSkillConditions.call(this, skill);
    };

    Game_BattlerBase.prototype.isFusionMemberOk = function(skill) {
        return VictorEngine.CooperationSkills.meetsSkillConditions.call(this, skill);
    };

    Game_BattlerBase.prototype.cooperationBattlers = function(skill) {
        if (skill.cooperationSkill.unite) {
            return this.uniteBattlers(skill);
        } else if (skill.cooperationSkill.fusion) {
            return this.fusionBattlers(skill);
        } else if (skill.cooperationSkill.combination) {
            return this.combinationBattlers(skill);
        }
        return [];
    };

    Game_BattlerBase.prototype.uniteBattlers = function(skill) {
        return skill.cooperationSkill.unite.map(function(id) {
            return $gameActors.actor(id);
        });
    };

    Game_BattlerBase.prototype.fusionBattlers = function(skill) {
        if (this.fusionLeaderSkill() === skill) {
            return this.fusionMembersList(this);
        } else if (this.fusionLeader() && this.fusionLeader().fusionLeaderSkill() === skill) {
            return this.fusionMembersList(this.fusionLeader());
        } else {
            return [];
        }
    };

    Game_BattlerBase.prototype.combinationBattlers = function(skill) {
        if (this.combinationLeaderSkill() === skill) {
            return this.combinationMembersList(this);
        } else if (this.combinationLeader() && this.combinationLeader().combinationLeaderSkill() === skill) {
            return this.combinationMembersList(this.combinationLeader());
        } else {
            return [];
        }
    };

    Game_BattlerBase.prototype.fusionMembersList = function(leader) {
        return BattleManager.allBattleMembers().filter(function(member) {
            return member.fusionLeader() === leader || member === leader;
        });
    };

    Game_BattlerBase.prototype.combinationMembersList = function(leader) {
        return BattleManager.allBattleMembers().filter(function(member) {
            return member.combinationLeader() === leader || member === leader;
        });
    };

    Game_BattlerBase.prototype.cooperationMember = function() {
        return this._uniteLeader || this._fusionLeader;
    };

    Game_BattlerBase.prototype.cooperationLeader = function(skill) {
        if (skill.cooperationSkill.unite) {
            return this.uniteLeader();
        } else if (skill.cooperationSkill.fusion) {
            return this.fusionLeader();
        } else if (skill.cooperationSkill.combination) {
            return this.combinationLeader();
        } else {
            return null;
        };
    };

    Game_BattlerBase.prototype.isCooperationSkill = function(skill) {
        return skill.cooperationSkill.unite || skill.cooperationSkill.fusion || skill.cooperationSkill.combination;
    };

    Game_BattlerBase.prototype.payCooperationSkillCost = function(skill) {
        if (skill.cooperationSkill.fusion) {
            if (this.originalFusionSkill()) {
                VictorEngine.CooperationSkills.paySkillCost.call(this, this.originalFusionSkill());
            }
        } else {
            VictorEngine.CooperationSkills.paySkillCost.call(this, skill);
        }
    };

    Game_BattlerBase.prototype.cooperationName = function(skill) {
        var text = ''
        var names = this.cooperationBattlers(skill).map(function(battler) {
            return battler.name();
        });
        for (var i = 0; i < names.length; i++) {
            var name = names
            if (i === 0) {
                text = name;
            } else if (i > 0 && i < names.length - 1) {
                text += ', ' + name;
            } else if (i === names.length - 1) {
                text += ' and ' + name;
            }
        }
        return text;
    };

    Game_BattlerBase.prototype.uniteLeader = function() {
        return this._uniteLeader;
    };

    Game_BattlerBase.prototype.uniteLeaderSkill = function() {
        return this._uniteLeaderSkill;
    };

    Game_BattlerBase.prototype.isUsingNonUnite = function() {
        return this._isUsingNonUnite;
    };

    Game_BattlerBase.prototype.setUniteLeader = function(leader) {
        this._uniteLeader = leader;
    };

    Game_BattlerBase.prototype.setUniteLeaderSkill = function(skill) {
        this._uniteLeaderSkill = skill;
    };

    Game_BattlerBase.prototype.setUsingNonUnite = function() {
        if (this.notUsingUnite()) {
            this._isUsingNonUnite = true;
        }
    };

    Game_BattlerBase.prototype.clearUniteSetup = function() {
        this._uniteLeader = null;
        this._uniteLeaderSkill = null;
        this._isUsingNonUnite = false;
    };

    Game_BattlerBase.prototype.notUsingUnite = function() {
        return this._actions.every(function(action) {
            return !action.isUniteAction();
        })
    };

    Game_BattlerBase.prototype.setupUniteBaltters = function() {
        this._actions.forEach(function(action) {
            if (action.isUniteAction()) {
                action.setCooperationBattlers();
            }
        })
    };

    /* FUSION */
    Game_BattlerBase.prototype.isUsingFusion = function(id) {
        var battler = this;
        return this._actions.some(function(action) {
            return action.item() && action.isSkill() && action.item().id === id && !battler.originalFusionSkill();
        })
    };

    Game_BattlerBase.prototype.fusionLeader = function() {
        return this._fusionLeader;
    };

    Game_BattlerBase.prototype.fusionLeaderSkill = function() {
        return this._fusionLeaderSkill;
    };

    Game_BattlerBase.prototype.originalFusionSkill = function() {
        return this._originalFusionSkill;
    };

    Game_BattlerBase.prototype.isOriginalFusionSkill = function(id) {
        return this._originalFusionSkill && this._originalFusionSkill.id === id;
    };

    Game_BattlerBase.prototype.clearFusionSetup = function() {
        this._fusionLeader = null;
        this._fusionLeaderSkill = null;
        this._originalFusionSkill = null;
    };

    Game_BattlerBase.prototype.setFusionLeader = function(skill, id) {
        this._fusionLeaderSkill = skill;
        this.setFusionAction(skill, id);
    };

    Game_BattlerBase.prototype.setFusionMember = function(leader, id) {
        this._fusionLeader = leader;
        this.setFusionAction(leader.fusionLeaderSkill(), id);
    };

    Game_BattlerBase.prototype.setFusionAction = function(skill, id) {
        var index = this.setFusionActionIndex(id);
        var action = new Game_Action(this);
        action.setSkill(skill.id);
        action.setTarget(this._actions[index]._targetIndex);
        this._actions.splice(index, 1, action);
        this._originalFusionSkill = $dataSkills[id];
    };

    Game_BattlerBase.prototype.setFusionActionIndex = function(id) {
        for (var i = 1; i < this._actions.length; i++) {
            var action = this._actions;
            if (action.item() && action.isSkill() && action.item().id === id) {
                return i;
            }
        }
        return 0;
    };

    Game_BattlerBase.prototype.setupFusionBaltters = function() {
        this._actions.forEach(function(action) {
            if (action.isFusionAction()) {
                action.setCooperationBattlers();
            }
        })
    };

    /* Combination */
    Game_BattlerBase.prototype.isUsingCombination = function(id) {
        var battler = this;
        return this._actions.some(function(action) {
            return action.item() && action.isSkill() && action.item().id === id && !battler.isCombinationSkill();
        })
    };

    Game_BattlerBase.prototype.combinationLeader = function() {
        return this._combinationLeader;
    };

    Game_BattlerBase.prototype.combinationLeaderSkill = function() {
        return this._combinationLeaderSkill;
    };

    Game_BattlerBase.prototype.isCombinationSkill = function() {
        return this.combinationLeader() || this.combinationLeaderSkill();
    };

    Game_BattlerBase.prototype.clearCombinationSetup = function() {
        this._combinationLeader = null;
        this._combinationLeaderSkill = null;
    };

    Game_BattlerBase.prototype.setCombinationLeader = function(skill) {
        this._combinationLeaderSkill = skill;
    };

    Game_BattlerBase.prototype.setCombinationMember = function(leader) {
        this._combinationLeader = leader;
    };

    Game_BattlerBase.prototype.setupCombinationBaltters = function() {
        this._actions.forEach(function(action) {
            if (action.isCombinationAction()) {
                action.setCooperationBattlers();
            }
        })
    };

    //=============================================================================
    // Game_Battler
    //=============================================================================

    VictorEngine.CooperationSkills.performActionStart = Game_Battler.prototype.performActionStart;
    Game_Battler.prototype.performActionStart = function(action) {
        if (this.uniteLeaderSkill()) {
            this.clearUniteAction();
        }
        if (this.fusionLeaderSkill()) {
            this.clearFusionAction();
        }
        if (this.combinationLeaderSkill()) {
            this.clearCombinationAction();
        }
        VictorEngine.CooperationSkills.performActionStart.call(this, action);
    };

    VictorEngine.CooperationSkills.onAllActionsEnd = Game_Battler.prototype.onAllActionsEnd;
    Game_Battler.prototype.onAllActionsEnd = function() {
        VictorEngine.CooperationSkills.onAllActionsEnd.call(this);
        if (this.uniteLeaderSkill()) {
            if (Imported['VE - Active Time Battle']) {
                this.resetAtbUnion();
            }
            this.resetUniteAction(true);
        }
        if (this.fusionLeaderSkill()) {
            this.resetFusionAction(true);
        }
        if (this.combinationLeaderSkill()) {
            this.resetCombinationAction(true);
        }
    };

    VictorEngine.CooperationSkills.speed = Game_Battler.prototype.speed;
    Game_Battler.prototype.speed = function() {
        var battlers = this.allCooperationBattlers()
        if (this.uniteLeaderSkill() || this.fusionLeaderSkill() && battlers.length > 0) {
            return this.cooperationActionSpeed(battlers);
        } else if (this.uniteLeader() || this.fusionLeader()) {
            return -9999;
        } else {
            return VictorEngine.CooperationSkills.speed.call(this);
        }
    };

    Game_Battler.prototype.cooperationActionSpeed = function(battlers) {
        return Math.min.apply(null, battlers.map(function(member) {
            return VictorEngine.CooperationSkills.speed.call(member);
        })) || 0;
    };

    Game_Battler.prototype.allCooperationBattlers = function() {
        var battlers = []
        this._actions.forEach(function(action) {
            if (action.isCooperation()) {
                battlers = battlers.concat(action.cooperationBattlers());
            }
        })
        return battlers;
    };

    Game_Battler.prototype.resetUniteAction = function(turnEnd) {
        var leader = this;
        this.clearUniteSetup();
        $gameParty.members().forEach(function(member) {
            if (member.uniteLeader() === leader) {
                member.makeActions();
                member.clearUniteSetup();
            }
        })
    };

    Game_Battler.prototype.resetFusionAction = function(turnEnd) {
        var leader = this;
        this.clearFusionSetup();
        BattleManager.allBattleMembers().forEach(function(member) {
            if (member.fusionLeader() === leader) {
                member.makeActions();
                member.clearFusionSetup();
            }
        })
    };

    Game_Battler.prototype.resetCombinationAction = function(turnEnd) {
        var leader = this;
        this.clearCombinationSetup();
        BattleManager.allBattleMembers().forEach(function(member) {
            if (member.combinationLeader() === leader) {
                member.makeActions();
                member.clearCombinationSetup();
            }
        })
    };

    Game_Battler.prototype.clearUniteAction = function() {
        var leader = this;
        BattleManager.allBattleMembers().forEach(function(member) {
            if (member.uniteLeader() === leader) {
                member.clearActions();
                member.setActionState('acting');
            }
        })
    };

    Game_Battler.prototype.clearFusionAction = function() {
        var leader = this;
        BattleManager.allBattleMembers().forEach(function(member) {
            if (member.fusionLeader() === leader) {
                member.clearActions();
                member.setActionState('acting');
            }
        })
    };

    Game_Battler.prototype.clearCombinationAction = function() {
        var leader = this;
        BattleManager.allBattleMembers().forEach(function(member) {
            if (member.combinationLeader() === leader) {
                member.clearActions();
                member.setActionState('acting');
            }
        })
    };

    VictorEngine.CooperationSkills.onBattleStart = Game_Battler.prototype.onBattleStart;
    Game_Battler.prototype.onBattleStart = function() {
        VictorEngine.CooperationSkills.onBattleStart.call(this);
        this.clearUniteSetup();
        this.clearFusionSetup();
        this.clearCombinationSetup();
    };

    VictorEngine.CooperationSkills.onTurnEnd = Game_Battler.prototype.onTurnEnd;
    Game_Battler.prototype.onTurnEnd = function() {
        VictorEngine.CooperationSkills.onTurnEnd.call(this);
        this.clearUniteSetup();
        this.clearFusionSetup();
    };

    VictorEngine.CooperationSkills.onBattleEnd = Game_Battler.prototype.onBattleEnd;
    Game_Battler.prototype.onBattleEnd = function() {
        VictorEngine.CooperationSkills.onBattleEnd.call(this);
        this.clearUniteSetup();
        this.clearFusionSetup();
        this.clearCombinationSetup();
    };

    Game_Battler.prototype.resetAtbUnion = function() {
        var leader = this;
        $gameParty.members().forEach(function(member) {
            if (member.uniteLeader() === leader) {
                member.clearAtb();
            }
        })
    };

    //=============================================================================
    // Scene_Battle
    //=============================================================================

    VictorEngine.CooperationSkills.onSelectAction = Scene_Battle.prototype.onSelectAction;
    Scene_Battle.prototype.onSelectAction = function() {
        var action = BattleManager.inputtingAction();
        VictorEngine.CooperationSkills.onSelectAction.call(this);
        if (!action.needsSelection()) {
            this.setUniteSkill();
        }
    };

    VictorEngine.CooperationSkills.onActorOk = Scene_Battle.prototype.onActorOk;
    Scene_Battle.prototype.onActorOk = function() {
        this.setUniteSkill();
        VictorEngine.CooperationSkills.onActorOk.call(this);
    };

    VictorEngine.CooperationSkills.onEnemyOk = Scene_Battle.prototype.onEnemyOk;
    Scene_Battle.prototype.onEnemyOk = function() {
        this.setUniteSkill();
        VictorEngine.CooperationSkills.onEnemyOk.call(this);
    };

    VictorEngine.CooperationSkills.startActorCommandSelection = Scene_Battle.prototype.startActorCommandSelection;
    Scene_Battle.prototype.startActorCommandSelection = function() {
        var actor = BattleManager.actor();
        actor.resetUniteAction();
        VictorEngine.CooperationSkills.startActorCommandSelection.call(this);
    };

    Scene_Battle.prototype.setUniteSkill = function() {
        var actor = BattleManager.actor();
        if (actor && this._actorCommandWindow.currentSymbol() === 'skill') {
            var skill = this._skillWindow.item();
            if (skill.cooperationSkill.unite) {
                this.setUniteLeader(skill);
            } else {
                actor.setUsingNonUnite();
            }
        } else {
            if (actor) {
                actor.setUsingNonUnite();
            }
        }
    };

    Scene_Battle.prototype.setUniteLeader = function(skill) {
        var leader = BattleManager.actor();
        var current = BattleManager.inputtingAction();
        return skill.cooperationSkill.unite.forEach(function(id) {
            var actor = $gameActors.actor(id);
            if (actor === leader) {
                actor.setUniteLeaderSkill(skill);
            } else {
                var action = new Game_Action(actor);
                action.setSkill(skill.id);
                action.setTarget(current._targetIndex);
                actor._actions.push(action);
                actor.setUniteLeader(leader);
            }
        });
    };

    //=============================================================================
    // Window_BattleLog
    //=============================================================================

    VictorEngine.CooperationSkills.startActionWindowBattleLog = Window_BattleLog.prototype.startAction;
    Window_BattleLog.prototype.startAction = function(subject, action, targets) {
        this._cooperationSkill = action;
        VictorEngine.CooperationSkills.startActionWindowBattleLog.call(this, subject, action, targets);
    };

    VictorEngine.CooperationSkills.performActionStartWindowBattleLog = Window_BattleLog.prototype.performActionStart;
    Window_BattleLog.prototype.performActionStart = function(subject, action) {
        VictorEngine.CooperationSkills.performActionStartWindowBattleLog.call(this, subject, action);
        if (this.isCooperationSkill(subject)) {
            this.performActionStartCooperation(subject, action);
        }
    };

    VictorEngine.CooperationSkills.performAction = Window_BattleLog.prototype.performAction;
    Window_BattleLog.prototype.performAction = function(subject, action, targets) {
        VictorEngine.CooperationSkills.performAction.call(this, subject, action, targets);
        if (this.isCooperationSkill(subject)) {
            this.performActionCooperation(subject, action, targets);
        }
    };

    VictorEngine.CooperationSkills.performActionEnd = Window_BattleLog.prototype.performActionEnd;
    Window_BattleLog.prototype.performActionEnd = function(subject, action) {
        VictorEngine.CooperationSkills.performActionEnd.call(this, subject, action);
        if (this.isCooperationSkill(subject)) {
            this.performActionEndCooperation(subject, this._cooperationSkill);
        }
    };

    VictorEngine.CooperationSkills.displayAction = Window_BattleLog.prototype.displayAction;
    Window_BattleLog.prototype.displayAction = function(subject, item) {
        if (DataManager.isSkill(item) && item.isCooperation) {
            var numMethods = this._methods.length;
            if (DataManager.isSkill(item)) {
                if (item.message1) {
                    this.push('addText', subject.cooperationName(item) + item.message1.format(item.name));
                }
                if (item.message2) {
                    this.push('addText', item.message2.format(item.name));
                }
            }
            if (this._methods.length === numMethods) {
                this.push('wait');
            }
        } else {
            VictorEngine.CooperationSkills.displayAction.call(this, subject, item);
        }
    };

    VictorEngine.CooperationSkills.performActionAnimation = Window_BattleLog.prototype.performActionAnimation;
    Window_BattleLog.prototype.performActionAnimation = function(subject, animationId) {
        VictorEngine.CooperationSkills.performActionAnimation.call(this, subject, animationId);
        if (this.isCooperationSkill(subject)) {
            this.performActionAnimationCooperation(subject, animationId, this._cooperationSkill);
        }
    };

    VictorEngine.CooperationSkills.performCastAnimation = Window_BattleLog.prototype.performCastAnimation;
    Window_BattleLog.prototype.performCastAnimation = function(subject, animationId) {
        VictorEngine.CooperationSkills.performCastAnimation.call(this, subject, animationId);
        if (this.isCooperationSkill(subject)) {
            this.performCastAnimationCooperation(subject, animationId, this._cooperationSkill);
        }
    };

    Window_BattleLog.prototype.isCooperationSkill = function(subject) {
        return (!Imported['VE - Battle Motions'] && this._cooperationSkill &&
            subject.isCooperationSkill(this._cooperationSkill.item()));
    };

    Window_BattleLog.prototype.performActionStartCooperation = function(subject, action) {
        var object = this;
        BattleManager.allBattleMembers().forEach(function(member) {
            if (member.cooperationLeader(action.item()) === subject) {
                VictorEngine.CooperationSkills.performActionStartWindowBattleLog.call(object, member, action);
            }
        })
    };

    Window_BattleLog.prototype.performActionCooperation = function(subject, action, targets) {
        var object = this;
        BattleManager.allBattleMembers().forEach(function(member) {
            if (member.cooperationLeader(action.item()) === subject) {
                VictorEngine.CooperationSkills.performAction.call(object, member, action, targets);
            }
        })
    };

    Window_BattleLog.prototype.performActionEndCooperation = function(subject, action) {
        var object = this;
        BattleManager.allBattleMembers().forEach(function(member) {
            if (member.cooperationLeader(action.item()) === subject) {
                VictorEngine.CooperationSkills.performActionEndWindowBattleLog.call(object, member, action);
            }
        })
    };

    Window_BattleLog.prototype.performActionAnimationCooperation = function(subject, animationId, action) {
        var object = this;
        BattleManager.allBattleMembers().forEach(function(member) {
            if (member.cooperationLeader(action.item()) === subject) {
                VictorEngine.CooperationSkills.performActionAnimation.call(object, member, animationId);
            }
        })
    };

    Window_BattleLog.prototype.performCastAnimationCooperation = function(subject, animationId, action) {
        var object = this;
        BattleManager.allBattleMembers().forEach(function(member) {
            if (member.cooperationLeader(action.item()) === subject) {
                VictorEngine.CooperationSkills.performCastAnimation.call(object, member, animationId);
            }
        })
    };

    VictorEngine.CooperationSkills.defaultMotionMovement = Window_BattleLog.prototype.defaultMotionMovement;
    Window_BattleLog.prototype.defaultMotionMovement = function(subject, action) {
        if (action.isCooperation()) {
            var motion = '';
            if (action && !action.isGuard()) {
                for (var i = 0; i < action.cooperationLength(); i++) {
                    if (action.isStepForward()) {
                        motion += 'motion: cooperation ' + String(i + 1) + ', walk;';
                        motion += 'move: cooperation ' + String(i + 1) + ', forward, 30, 48;';
                    } else {
                        motion += 'direction: cooperation ' + String(i + 1) + ', targets;';
                        motion += 'motion: cooperation ' + String(i + 1) + ', walk;';
                        motion += 'move: cooperation ' + String(i + 1) + ', close to target, 12, 80;';
                    }
                }
                for (var i = 0; i < action.cooperationLength(); i++) {
                    motion += 'wait: cooperation ' + String(i + 1) + ', move;';
                    motion += 'motion: cooperation ' + String(i + 1) + ', reset;';
                }
            }
            return motion;
        } else {
            return VictorEngine.CooperationSkills.defaultMotionMovement.call(this, subject, action);
        }
    };

    VictorEngine.CooperationSkills.defaultMotionExecute = Window_BattleLog.prototype.defaultMotionExecute;
    Window_BattleLog.prototype.defaultMotionExecute = function(subject, action) {
        if (action.isCooperation()) {
            var motion = '';
            motion += 'wait: all cooperation, move;';
            for (var i = 0; i < action.cooperationLength(); i++) {
                motion += 'motion: cooperation ' + String(i + 1) + ', action;';
            }
            for (var i = 0; i < action.cooperationLength(); i++) {
                motion += 'wait: cooperation ' + String(i + 1) + ', 8;';
            }
            motion += 'action: all targets, effect;';
            motion += 'wait: all targets, action;';
            return motion;
        } else {
            return VictorEngine.CooperationSkills.defaultMotionExecute.call(this, subject, action);
        }
    };

    VictorEngine.CooperationSkills.defaultMotionReturn = Window_BattleLog.prototype.defaultMotionReturn;
    Window_BattleLog.prototype.defaultMotionReturn = function(subject, action) {
        if (action.isCooperation()) {
            var motion = '';
            for (var i = 0; i < action.cooperationLength(); i++) {
                motion += 'motion: cooperation ' + String(i + 1) + ', return;';
                motion += 'move: cooperation ' + String(i + 1) + ', to home, 12;';
            }
            for (var i = 0; i < action.cooperationLength(); i++) {
                motion += 'wait: cooperation ' + String(i + 1) + ', move;';
                motion += 'motion: cooperation ' + String(i + 1) + ', reset;';
            }
            motion += 'wait: all cooperation, move;';
            return motion;
        } else {
            return VictorEngine.CooperationSkills.defaultMotionReturn.call(this, subject, action);
        }
    };

    VictorEngine.CooperationSkills.getMotionSubjects = Window_BattleLog.prototype.getMotionSubjects;
    Window_BattleLog.prototype.getMotionSubjects = function(type, user, targets, target, index) {
        if (this.isCooperation()) {
            type = type.toLowerCase().trim();
            var battlers = this._currentAction.action.cooperationBattlers();
            if (type === 'all cooperation') {
                return battlers;
            }
            var match = (/cooperation[ ]*(\d+)/gi).exec(type);
            if (match) {
                var battler = battlers[Number(match[1]) - 1]
                return battler ? [battler] : [];
            }
        }
        return VictorEngine.CooperationSkills.getMotionSubjects.call(this, type, user, targets, target, index);
    }

    Window_BattleLog.prototype.isCooperation = function() {
        return this._currentAction && this._currentAction.action && this._currentAction.action.isCooperation();
    }

})();
[/pre]


在工程中,当执行完合作技后,出现了以下错误:
TypeError : Cannot read property 'call' of undefined

我在工程中只用了这两个插件,但还是得到了这个错误。我的版本是1.6.1。

(不知道为什么发不了图片和附件,见谅)

我是脚本小白,望各位大神不吝赐教,提前先谢谢各位了!!!
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部