查看: 7469|回复: 8

[已经解决] 求教敌人动态战斗插件的bug怎么弄

[复制链接]
梦石
0
星屑
50
在线时间
171 小时
注册时间
2013-8-6
回帖
91
发表于 2015-11-8 23:35:49 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 余烬之中 于 2015-11-24 12:40 编辑

鼠标选择不了敌人,只能键盘选择
不知道啥冲突

[fold=AnimatedSVEnemies.js][pre lang="javascript"]//=============================================================================
// AnimatedSVEnemies.js
// Version: 1.12.11 - Live and Reloaded
//=============================================================================

var Imported = Imported || {};
Imported.AnimatedSVEnemies = true;

var Rexal = Rexal || {};
Rexal.ASVE = Rexal.ASVE || {};
/*:
* @plugindesc Version: 1.12.11 - Live and Reloaded
* - Lets enemies be animated!
* @author Rexal
*

  * @param Debug
* @desc Log to the Console(F8)?
* @default true

* @param No Movement
* @desc Prevents enemies from moving whenever they perform an action.
* @default false

* @param Enemies Celebrate
* @desc Enemies will celebrate over your demise.
* @default true

  * @param SV Enemies Collapse
* @desc All SV Enemies will collapse after death.
* @default false

* @param Static Enemies Breathe
* @desc Static Enemies have a breathing effect
* @default true

* @param AGI Effects Breathing
* @desc Static Enemies with a higher AGI stat will breathe faster.
* @default true

* @param Scale Statics by Distance
* @desc Static Enemies will be smaller the further away they are in the background
* @default true

  * @param Damage Slows Down Breathing
* @desc Breathing slows down the more damage they take
* @default true

  * @help

--------------------------------------------------------------------------------
Notetags
================================================================================


---------------------------[SV Battlers]---------------------------------

[SV Animated]
- Sets the enemy to use the an SV Actor sprite. These are located in the sv_actors
folder. Make sure that there's a sprite in that folder that matches the name
of the enemy's image you used.

[Collapse]
- Lets the SV Enemy use collapse animations regardless of parameter settings.

[No Collapse]
- Prevents the SV Enemy from using collapse animations regardless of parameter settings.

SV Motion: motion
- Sets the enemy to use this motion when attacking. If you don't know what motions
you can use, refer to the motion list at the bottom of the help section.

  SV Weapon: id
- "Equips" the enemy with this weapon.

Ex: SV Weapon: 1


  ----------------------------[Static Battlers]---------------------------------

[Breathless]
-This enemy doesn't breathe. Useful for golems and evil walls.

[Float]
-Makes enemies have a floating effect similar to rm2k3's.

Breath Control: speedScale,xScale,yScale
-Sets the speed of the sine wave and how many times the size of the sprite it's
  allowed to go width-wise and height-wise.
  
  You'll have to play around with the values a bit until it looks right. The
  example below is the default settings.

Ex: Breath Control: 50,5,25


-----------------------------------[Both]---------------------------------------

Enemy Scale: amount

multiplies the size of the enemy by this amount.


--------------------------------------------------------------------------------
Version Log
================================================================================
  
v1 - Initial Version

v1.05 - Many fixes
- Fixed issue with enemies not playing the right animations when more than one
enemy is on the screen.
- Misc. Fixes that I've forgotten about.
- Added SV Weapon, which lets you play a weapon animation(currently backwards).
This is not yet compatible with my other script: Sprite Weapons Enhanced.
- Added a param that stops enemies from moving.

  v1.075 - Deep breaths
- Static enemies breathe now!
- Added a bunch of stuff to control the breathing. (notetags do not work!)

   v1.08 - Fixed Breathing
- The breathing notetags work now! Yay!
- Added [Float]

   v1.1 - Live and Reloaded
   
  -Breathing slows down the less hp an enemy has. (orignally they just breathed less)
  - Added an option that lets enemies scale down the further into the background they are.
  - Fixed the weapons!
  - Enemies can celebrate your demise.
  - Fixed the Flash Target bug.
  - SV Enemies can collapse.
  - SV Enemies will properly appear
  - Enemies have a proper escape animation.
  - Enemies are now properly positioned.
  - You can now scale the enemies however you want.
  
   v1.101 -
   
   - Added a parameter to prevent enemies from breathing slower the more damage they take.
   
   v1.11 -
   
   - Fixed the positioning. SORRY!
   
   v1.111 -
   - No comment.
      v1.113 -
   Fixed the weapons.
   
   v1.12 -
   - Completely rewrote crucial portions of the script.
   - Note tags are no longer case-sensitive.
   - Fixed the positioning officially.
   - Fixed the floating issue.
      
          v1.12.1 -
   - Made SV Battlers recognizable as enemies.
   - [SV] Overlays should be facing the right way now.
          v1.12.11
        -Fixed the weapon positions. AGAIN


--------------------------------------------------------------------------------
Motion List
================================================================================
walk - Ready Animation
wait - The Idle Animation
chant - Magic Ready animation
guard - The Guard Animation
damage - Damage Animation
evade - Miss! Animation
thrust - Stabbing Animation
swing - Swinging Animation
missile - Shooting Animation
skill - Physical Skill Use Animation
spell - Magical Skill Use Animation
item - Item Use Animation
escape - Escape Animation
victory - Victory Animation
dying - The "Danger" Animation
abnormal - The State Affected Animation
sleep - The Sleeping Animation
dead - The Dead Animation


*/

Rexal.ASVE.Parameters = PluginManager.parameters('animatedSVEnemies');
Rexal.ASVE.Debug = eval(String(Rexal.ASVE.Parameters['Debug']));
Rexal.ASVE.NoMovement = eval(String(Rexal.ASVE.Parameters['No Movement']));
  Rexal.ASVE.Breathe = eval(String(Rexal.ASVE.Parameters['Static Enemies Breathe']));
  Rexal.ASVE.AGIB = eval(String(Rexal.ASVE.Parameters['AGI Effects Breathing']));
  Rexal.ASVE.Celebration = eval(String(Rexal.ASVE.Parameters['Enemies Celebrate']));
   Rexal.ASVE.DoCollapse = eval(String(Rexal.ASVE.Parameters['SV Enemies Collapse']));
Rexal.ASVE.DamageSlow = eval(String(Rexal.ASVE.Parameters['Damage Slows Down Breathing']));
     Rexal.ASVE.ScaleStatics = eval(String(Rexal.ASVE.Parameters['Scale Statics by Distance']));  
  //-----------------------------------------------------------------------------
// BattleManager
//=============================================================================
  
  if(Rexal.ASVE.Celebration)
  {  

  BattleManager.processDefeat = function() {
    if(Rexal.ASVE.Celebration)$gameTroop.performVictory();
        this.displayDefeatMessage();
    this.playDefeatMe();
    if (this._canLose) {
        this.replayBgmAndBgs();
    } else {
        AudioManager.stopBgm();
    }
    this.endBattle(2);
};
  }
  
  //-----------------------------------------------------------------------------
// Game_Enemy
//=============================================================================

        Game_Enemy.prototype.performAttack = function() {
               
               
                        if(this._weaponId == 0){this.requestMotion(this._motion);
                        return;
                        }
               
     var weapon = $dataWeapons[this._weaponId];
    var wtypeId = weapon.wtypeId;
    var attackMotion = $dataSystem.attackMotions[wtypeId];
    if (attackMotion) {
        if (attackMotion.type === 0) {
            this.requestMotion('thrust');
        } else if (attackMotion.type === 1) {
            this.requestMotion('swing');
        } else if (attackMotion.type === 2) {
            this.requestMotion('missile');
        }
               
                if(this._motion != 'thrust')this.requestMotion(this._motion);
               
                this.startWeaponAnimation(attackMotion.weaponImageId);
    }
};


Game_Enemy.prototype.performAction = function(action) {
    Game_Battler.prototype.performAction.call(this, action);
    if (action.isAttack()) {
        this.performAttack();
    } else if (action.isGuard()) {
        this.requestMotion('guard');
    } else if (action.isMagicSkill()) {
        this.requestMotion('spell');
    } else if (action.isSkill()) {
        this.requestMotion('skill');
    } else if (action.isItem()) {
        this.requestMotion('item');
    }
};

Game_Enemy.prototype.performDamage = function() {
    Game_Battler.prototype.performDamage.call(this);
    if (this.isSpriteVisible()) {
        this.requestMotion('damage');
    } else {
        $gameScreen.startShake(5, 5, 10);
    }
    SoundManager.playActorDamage();
};

Game_Enemy.prototype.performEvasion = function() {
    Game_Battler.prototype.performEvasion.call(this);
    this.requestMotion('evade');
};

Game_Enemy.prototype.performMagicEvasion = function() {
    Game_Battler.prototype.performMagicEvasion.call(this);
    this.requestMotion('evade');
};

Game_Enemy.prototype.performCounter = function() {
    Game_Battler.prototype.performCounter.call(this);
    this.performAttack();
};

Game_Enemy.prototype.performVictory = function() {
    if (this.canMove()) {
        this.requestMotion('victory');
    }
};


Game_Enemy.prototype.makeActions = function() {
    Game_Battler.prototype.makeActions.call(this);
    if (this.numActions() > 0) {
        var actionList = this.enemy().actions.filter(function(a) {
            return this.isActionValid(a);
        }, this);
        if (actionList.length > 0) {
            this.selectAllActions(actionList);
        }
    }
this.setActionState('undecided');
};


Game_Enemy.prototype.performEscape = function() {
    if (this.canMove()) {
        this.requestMotion('escape');
    }
};

       
Game_Enemy.prototype.attackAnimationId = function() {

  if(this._weaponId!=0)  return $dataWeapons[this._weaponId].animationId;
  else
          return 1;
};

  //-----------------------------------------------------------------------------
// Game_Troop
//=============================================================================
Game_Troop.prototype.performVictory = function() {
    this.members().forEach(function(enemy) {
        enemy.performVictory();
    });
};
  //-----------------------------------------------------------------------------
// Sprite_Enemy
//=============================================================================

Sprite_Enemy.prototype.setBattler = function(battler) {
    Sprite_Battler.prototype.setBattler.call(this, battler);
    this._enemy = battler;
    this.setHome(battler.screenX(), battler.screenY());
    this._stateIconSprite.setup(battler);
};
       
Sprite_Enemy.prototype.updateBitmap = function() {

       


        if(!this._enemy._breathless && Rexal.ASVE.Breathe){

                var a = 1;
                if(Rexal.ASVE.AGIB) a = this._enemy.agi/100+1;
        var breathS = this._enemy._breath[0]/1000;
        if(Rexal.ASVE.DamageSlow) breathS *= (this._enemy.hp/this._enemy.mhp)+.1;
        var breathY = Math.cos(Graphics.frameCount*breathS*a)*(this._enemy._breath[2]/1000);
        var breathX = Math.cos(Graphics.frameCount*breathS)*(this._enemy._breath[1]/1000);
       
        if(Rexal.ASVE.DamageSlow)breathY *= (this._enemy.hp/this._enemy.mhp);
        var ss = Graphics.boxHeight/624+.1;
        if(Rexal.ASVE.ScaleStatics)var s = ss*(this._homeY/Graphics.boxHeight)*this._enemy._scale;
        else var s = this._enemy._scale;
       
       
        this.scale.y = s+breathY;
        this.scale.x = s+breathX;
       
        }
       
        if(this._enemy._floating && !this.isBusy)
        {
                var f = Math.cos(Graphics.frameCount/50)*20;
                this.setHome(this._enemy.screenX(),this._enemy.screenY()+f);
        }
       
            Sprite_Battler.prototype.updateBitmap.call(this);
    var name = this._enemy.battlerName();
    var hue = this._enemy.battlerHue();
    if (this._battlerName !== name || this._battlerHue !== hue) {
        this._battlerName = name;
        this._battlerHue = hue;
        this.loadBitmap(name, hue);
        this.initVisibility();
    }
};


Sprite_Enemy.prototype.stepForward = function() {
   if(!Rexal.ASVE.NoMovement) this.startMove(48, 0, 12);
};


       
                Sprite_Enemy.prototype.setHome = function(x,y) {
                       
                        var dX = Graphics.boxWidth/816;
                        var dY = Graphics.boxHeight/624;
                       
                        y*= dY;
                        x*= dX;
                       
                        this._homeX = x;
                        this._homeY = y + (Graphics.boxHeight - 624)/3;
                        this.updatePosition();
        };

  //-----------------------------------------------------------------------------
// Sprite_EnemyRex
//=============================================================================

function Sprite_EnemyRex() {
    this.initialize.apply(this, arguments);
}


Sprite_EnemyRex.prototype = Object.create(Sprite_Actor.prototype);
Sprite_EnemyRex.prototype.constructor = Sprite_EnemyRex;

Sprite_EnemyRex.prototype.createWeaponSprite = function() {
       
    this._weaponSprite = new Sprite_Weapon();

    this.addChild(this._weaponSprite);
};


Sprite_Actor.prototype.createStateSprite = function() {
    this._stateSprite = new Sprite_StateOverlay();
        this._stateSprite.scale.x  = -1;
    this.addChild(this._stateSprite);
};



Sprite_EnemyRex.prototype.updateSelectionEffect = function() {
       
            var target = this._effectTarget;
    if (this._battler.isSelected()) {
        this._selectionEffectCount++;
        if (this._selectionEffectCount % 30 < 15) {
            target.setBlendColor([255, 255, 255, 64]);
        } else {
            target.setBlendColor([0, 0, 0, 0]);
        }
    } else if (this._selectionEffectCount > 0) {
        this._selectionEffectCount = 0;
        target.setBlendColor([0, 0, 0, 0]);
    }
       
}

Sprite_EnemyRex.prototype = Object.create(Sprite_Actor.prototype);
Sprite_EnemyRex.prototype.constructor = Sprite_EnemyRex;

Sprite_EnemyRex.prototype.initialize = function(battler) {
    Sprite_Battler.prototype.initialize.call(this, battler);

};

Sprite_EnemyRex.prototype.loadBitmap = function(name, hue) {
    if ($gameSystem.isSideView()) {
        this.bitmap = ImageManager.loadSvActor(name,hue);
    } else {
        this.bitmap = ImageManager.loadEnemy(name, hue);
    }
};

Sprite_EnemyRex.prototype.setBattler = function(battler) {
    Sprite_Battler.prototype.setBattler.call(this, battler);
    var changed = (battler !== this._actor);
    if (changed) {
        this._actor = battler;
        if (battler) {
            this.setActorHome(battler);
        }
        this.startEntryMotion();
        this._stateSprite.setup(battler);
    }
};


Sprite_EnemyRex.prototype.updateBitmap = function() {
        this.updateEffect();
    Sprite_Battler.prototype.updateBitmap.call(this);
        var hue = this._actor.battlerHue();
    var name = this._actor.battlerName();
    if (this._battlerName !== name) {
        this._battlerName = name;
        this._mainSprite.bitmap = ImageManager.loadSvActor(name,hue);
                this._mainSprite.scale.x = -this._actor._scale;
                this._mainSprite.scale.y = this._actor._scale;
    }
};

Sprite_EnemyRex.prototype.setupWeaponAnimation = function() {
    if (this._actor.isWeaponAnimationRequested()) {
        this._weaponSprite.setup(this._actor.weaponImageId() );
                this._weaponSprite.scale.x = -this._actor._scale;
                this._weaponSprite.scale.y = this._actor._scale;
                this._weaponSprite.x = -this._weaponSprite.x;
        this._actor.clearWeaponAnimation();
    }

};

Sprite_EnemyRex.prototype.setActorHome = function(battler) {
                       
                        var dX = Graphics.boxWidth/816;
                        var dY = Graphics.boxHeight/624;
       
                        var x = battler.screenX()*dX;
                        var y = battler.screenY()*dY;
                       
                        this._homeX = x;
                        this._homeY = y + (Graphics.boxHeight - 624)/3;
                        this.updatePosition();
        };


Sprite_EnemyRex.prototype.damageOffsetX = function() {
    return 32;
};

Sprite_EnemyRex.prototype.stepForward = function() {
   if(!Rexal.ASVE.NoMovement) this.startMove(48, 0, 12);
};

Sprite_EnemyRex.prototype.stepBack = function() {
   if(!Rexal.ASVE.NoMovement) this.startMove(0, 0, 12);
};

Sprite_EnemyRex.prototype.retreat = function() {
    this.startMove(300, 0, 30);
};

Sprite_EnemyRex.prototype.initVisibility = function() {
    this._appeared = this._actor.isAlive();
    if (!this._appeared) {
        this.opacity = 0;
    }
};

Sprite_EnemyRex.prototype.setupEffect = function() {
               

    if (this._appeared && this._actor.isEffectRequested()) {
        this.startEffect(this._actor.effectType());
        this._actor.clearEffect();
    }
    if (!this._appeared && this._actor.isAlive()) {
        this.startEffect('appear');
    } else if (this._appeared && this._actor.isHidden()) {
        this.startEffect('disappear');
    }
};

Sprite_EnemyRex.prototype.startEffect = function(effectType) {
       
    this._effectType = effectType;
    switch (this._effectType) {
    case 'appear':
        this.startAppear();
        break;
    case 'disappear':
        this.startDisappear();
        break;
    case 'whiten':
        this.startWhiten();
        break;
    case 'blink':
        this.startBlink();
        break;
    case 'collapse':
     if(this._actor._collapse)   this.startCollapse();
        break;
    case 'bossCollapse':
        this.startBossCollapse();
        break;
    case 'instantCollapse':
        this.startInstantCollapse();
        break;
    }
    this.revertToNormal();
};

Sprite_EnemyRex.prototype.startAppear = function() {
    this._effectDuration = 16;
    this._appeared = true;
};

Sprite_EnemyRex.prototype.startDisappear = function() {
    this._effectDuration = 32;
    this._appeared = false;
};

Sprite_EnemyRex.prototype.startWhiten = function() {
    this._effectDuration = 16;
};

Sprite_EnemyRex.prototype.startBlink = function() {
    this._effectDuration = 20;
};

Sprite_EnemyRex.prototype.startCollapse = function() {
    this._effectDuration = 32;
    this._appeared = false;
};

Sprite_EnemyRex.prototype.startBossCollapse = function() {
    this._effectDuration = this._mainSprite.height;
    this._appeared = false;
};

Sprite_EnemyRex.prototype.startInstantCollapse = function() {
    this._effectDuration = 16;
    this._appeared = false;
};

Sprite_EnemyRex.prototype.updateEffect = function() {

       
    this.setupEffect();
    if (this._effectDuration > 0) {
        this._effectDuration--;
        switch (this._effectType) {
        case 'whiten':
            this.updateWhiten();
            break;
        case 'blink':
            this.updateBlink();
            break;
        case 'appear':
            this.updateAppear();
            break;
        case 'disappear':
            this.updateDisappear();
            break;
        case 'collapse':
       if(this._actor._collapse)     this.updateCollapse();
            break;
        case 'bossCollapse':
       if(this._actor._collapse)     this.updateBossCollapse();
            break;
        case 'instantCollapse':
      if(this._actor._collapse)      this.updateInstantCollapse();
            break;
        }
        if (this._effectDuration === 0) {
            this._effectType = null;
        }
    }
};


       
Sprite_EnemyRex.prototype.isEffecting = function() {
   if(this._actor._collapse) return this._effectType !== null;
};



Sprite_EnemyRex.prototype.revertToNormal = function() {
    this._shake = 0;
    this.blendMode = 0;
    this.opacity = 255;
    this.setBlendColor([0, 0, 0, 0]);
};

Sprite_EnemyRex.prototype.updateWhiten = function() {
    var alpha = 128 - (16 - this._effectDuration) * 10;
    this.setBlendColor([255, 255, 255, alpha]);
};

Sprite_EnemyRex.prototype.updateBlink = function() {
    this.opacity = (this._effectDuration % 10 < 5) ? 255 : 0;
};

Sprite_EnemyRex.prototype.updateAppear = function() {
            this.setHome(this._homeX,this._homeY);
                    this.opacity = (16 - this._effectDuration) * 16;
};

Sprite_EnemyRex.prototype.updateDisappear = function() {
            this.setHome(this._homeX-10,this._homeY);
    this.opacity = 256 - (32 - this._effectDuration) * 10;
};

Sprite_Enemy.prototype.updateAppear = function() {
            this.setHome(this._homeX,this._homeY);
                                    this.opacity = (16 - this._effectDuration) * 16;
};

Sprite_Enemy.prototype.updateDisappear = function() {
            this.setHome(this._homeX-10,this._homeY);
    this.opacity = 256 - (32 - this._effectDuration) * 10;
};

Sprite_EnemyRex.prototype.updateCollapse = function() {
    this.blendMode = Graphics.BLEND_ADD;
    this.setBlendColor([255, 128, 128, 128]);
    this.opacity *= this._effectDuration / (this._effectDuration + 1);
};

Sprite_EnemyRex.prototype.updateBossCollapse = function() {
    this._shake = this._effectDuration % 2 * 4 - 2;
    this.blendMode = Graphics.BLEND_ADD;
    this.opacity *= this._effectDuration / (this._effectDuration + 1);
    this.setBlendColor([255, 255, 255, 255 - this.opacity]);
    if (this._effectDuration % 20 === 19) {
        SoundManager.playBossCollapse2();
    }
};

Sprite_EnemyRex.prototype.updateInstantCollapse = function() {
    this.opacity = 0;
};

Sprite_EnemyRex.prototype.damageOffsetX = function() {
    return 0;
};

Sprite_EnemyRex.prototype.damageOffsetY = function() {
    return -8;
};

  //-----------------------------------------------------------------------------
// Spriteset_Battle
//=============================================================================

Spriteset_Battle.prototype.createEnemies = function() {
    var enemies = $gameTroop.members();
    var sprites = [];
    for (var i = 0; i < enemies.length; i++) {
        var enemy = enemies;
        var baseEnemy = $dataEnemies[enemies.enemyId()];
       
        Rexal.ASVE.processEnemyNoteTag(baseEnemy);
        Rexal.ASVE.processEnemyData(enemy,baseEnemy);
       
    if(enemy._animated)  
        {
                sprites = new Sprite_EnemyRex(enemies);
                sprites._enemy = sprites._actor;
                sprites.opacity = 0;
        }
        else
                sprites = new Sprite_Enemy(enemies);
       
    }
       
    sprites.sort(this.compareEnemySprite.bind(this));
    for (var j = 0; j < sprites.length; j++) {
        this._battleField.addChild(sprites[j]);
    }
    this._enemySprites = sprites;
};


// Spriteset_Battle.prototype.updateActors = function() {
    // var members = $gameParty.battleMembers();
            // var enemies = $gameTroop.members();
               
                    // for (var i = 0; i < this._enemySprites.length; i++) {
        // this._enemySprites.setBattler(enemies);
    // }
               
    // for (var i = 0; i < this._actorSprites.length; i++) {
        // this._actorSprites.setBattler(members);
    // }
// };


  //-----------------------------------------------------------------------------
// Rex Functions
//=============================================================================

Object.defineProperties(Game_Enemy.prototype, {
  animated: { get: function() { return this._animated; }, configurable: true },
  motion: { get: function() { return this._motion; }, configurable: true },
  weaponid: { get: function() { return this._weaponId; }, configurable: true },
  breathless: { get: function() { return this._breathless; }, configurable: true },
  floating: { get: function() { return this._float; }, configurable: true },
  scale: { get: function() { return this._scale; }, configurable: true },
  collapse: { get: function() { return this._collapse; }, configurable: true },
  breath: { get: function() { return this._breath; }, configurable: true }
});

Rexal.log = function(message,type){
if(!Rexal.ASVE.Debug) return;
if(!type) type = 'log';

switch (type) {
       

        case 'log' :
        console.log(message);
        break;
       
        case 'info' :
        console.debug(message);
        break;
       
        case 'warn' :
        console.warn(message);
        break;
       
        case 'error' :
        console.error(message);
        break;
}

}

Rexal.ASVE.processEnemyData = function(obj,obj2) {
obj._breath = [];
obj._animated = obj2.animated;
obj._motion = obj2.motion;
obj._weaponId = obj2.weaponid;
obj._breathless = obj2.breathless;
obj._floating = obj2.floating;
obj._scale = obj2.scale;
obj._breath[0] = obj2.breath[0];
obj._breath[1] = obj2.breath[1];
obj._breath[2] = obj2.breath[2];
obj._collapse = obj2.collapse;
}

Rexal.ASVE.processEnemyNoteTag = function(obj) {

Rexal.log('reading ' + obj.name + '...');

obj.motion = 'thrust';
obj.weaponid = 0;
obj.collapse = Rexal.ASVE.DoCollapse;
obj.breath = [50,5,25];
obj.scale = 1.0;

if(obj == null)return;

                var notedata = obj.note.split(/[\r\n]+/);

                for (var i = 0; i < notedata.length; i++) {
                var line = notedata;
                var lines = line.split(': ');
               
                switch (lines[0].toLowerCase()) {
               
                case '[sv animated]' :
        obj.animated = true;
                Rexal.log(obj.name + ' is using SV Battler sprites','info');
                break;
               
                case 'sv motion' :
        obj.motion = lines[1].toLowerCase();
                Rexal.log(obj.name + "'s attack motion is:" + obj.motion,'info');
                break;
               
                case 'sv weapon' :
        obj.weaponid = parseInt(lines[1]);
                Rexal.log(obj.name + " has weapon " + $dataWeapons[obj.weaponid].name,'info');
                break;
               
                case '[breathless]' :
        obj.breathless = true;
                Rexal.log(obj.name + " is breathless.",'info');
                break;       
               
                case '[float]' :
                obj.floating = true;
                Rexal.log(obj.name + " floats.",'info');
                break;       
               
                case '[collapse]' :
                obj.collapse = true;
                Rexal.log(obj.name + " can collapse.",'info');               
                break;       
               
                case '[no collapse]' :
                obj.collapse = false;
                Rexal.log(obj.name + " cannot collapse.",'info');       
                break;
               
                case 'breath control' :
               
                var lines2 = lines[1].split(',');
                obj.breath[0] = parseInt(lines2[0]);
                obj.breath[1] = parseInt(lines2[1]);
                obj.breath[2] = parseInt(lines2[2]);
                Rexal.log(obj.name + "'s breath control: " + obj.breath,'info');
                break;
               
                case 'enemy scale' :
                obj.scale = parseFloat(lines[1]);
                Rexal.log(obj.name + " is " + obj.scale +"x bigger than normal.",'info');
                }
               
                       
                }
                return obj;
};[/pre][/fold]
梦石
0
星屑
80
在线时间
386 小时
注册时间
2007-7-27
回帖
4075

开拓者

发表于 2015-11-8 23:41:34 | 显示全部楼层
我用这插件没遇到这个bug,估计不是这个插件的问题


ps 如果你用了yep battle engine core 那还要用yep补丁https://raw.githubusercontent.co ... anflyEnginePatch.js

点评

老大,我传了我的整个包,帮忙看看吧,谢谢  发表于 2015-11-9 17:57
谢谢,我去试试看  发表于 2015-11-9 00:11
吸吸
回复

使用道具 举报

梦石
0
星屑
50
在线时间
171 小时
注册时间
2013-8-6
回帖
91
 楼主| 发表于 2015-11-9 00:18:47 | 显示全部楼层
本帖最后由 余烬之中 于 2015-11-24 12:42 编辑
trentswd 发表于 2015-11-8 23:41
我用这插件没遇到这个bug,估计不是这个插件的问题


还是不行,啥情况,郁闷了
我用的YEP_BattleEngineCore,是版本的问题?

[fold=YEP_BattleEngineCore.js][pre lang="javascript"]//=============================================================================
// Yanfly Engine Plugins - Battle Engine Core
// YEP_BattleEngineCore.js
//=============================================================================

var Imported = Imported || {};
Imported.YEP_BattleEngineCore = true;

var Yanfly = Yanfly || {};
Yanfly.BEC = Yanfly.BEC || {};

//=============================================================================
/*:
* @plugindesc v1.11 Have more control over the flow of the battle system
* with this plugin and alter various aspects to your liking.
* @author Yanfly Engine Plugins
*
* @param ---General---
* @default
*
* @param Action Speed
* @desc This is the formula used for an action's base speed.
* Default: agi + Math.randomInt(Math.floor(5 + agi / 4))
* @default agi
*
* @param Default System
* @desc This is the default battle system your game uses.
* Default: dtb
* @default dtb
*
* @param ---Escape---
* @default
*
* @param Escape Ratio
* @desc This is the formula used to determine escape success.
* Default: 0.5 * $gameParty.agility() / $gameTroop.agility()
* @default 0.5 * $gameParty.agility() / $gameTroop.agility()
*
* @param Fail Escape Boost
* @desc Each time the player fails escape, increase the success
* rate by this much. Default: 0.1
* @default 0.1
*
* @param ---Animation---
* @default
*
* @param Animation Base Delay
* @desc This sets the base delay in between animations.
* Default: 8
* @default 0
*
* @param Animation Next Delay
* @desc This sets the sequential delay in between animations.
* Default: 12
* @default 0
*
* @param Certain Hit Animation
* @desc Default animation to play for certain hit skills.
* Use 0 if you wish for no animation.
* @default 120
*
* @param Physical Animation
* @desc Default animation to play for physical skills.
* Use 0 if you wish for no animation.
* @default 52
*
* @param Magical Animation
* @desc Default animation to play for magical skills.
* Use 0 if you wish for no animation.
* @default 51
*
* @param Enemy Attack Animation
* @desc This is the default attack animation played by enemies.
* Default: 0
* @default 39
*
* @param Reflect Animation
* @desc The animation used when magic attacks are reflected.
* @default 42
*
* @param Motion Waiting
* @desc Play animations after performing an action or during?
* During - false     After - true     Default: false
* @default false
*
* @param ---Frontview---
* @default
*
* @param Front Position X
* @desc This formula determines the actor's home X position.
* Default: 0
* @default Graphics.boxWidth / 8 + Graphics.boxWidth / 4 * index
*
* @param Front Position Y
* @desc This formula determines the actor's home Y position.
* Default: 0
* @default Graphics.boxHeight - 180
*
* @param Front Actor Sprite
* @desc Show the actor battle sprite in frontview?
* NO - false     YES - true     Default - false
* @default false
*
* @param Front Sprite Priority
* @desc Give actor sprites the priority of always being on top?
* 0 - Normal   1 - Actors on Top   2 - Enemies on Top
* @default 1
*
* @param ---Sideview---
* @default
*
* @param Home Position X
* @desc This formula determines the actor's home X position.
* Default: 600 + index * 32
* @default Graphics.boxWidth - 216 + index * 32
*
* @param Home Position Y
* @desc This formula determines the actor's home Y position.
* Default: 280 + index * 48
* @default Graphics.boxHeight - 344 + index * 48
*
* @param Side Sprite Priority
* @desc Give actor sprites the priority of always being on top?
* 0 - Normal   1 - Actors on Top   2 - Enemies on Top
* @default 1
*
* @param ---Sprites---
* @default
*
* @param Default X Anchor
* @desc Default value used for your sprites's X Anchor.
* Default: 0.5
* @default 0.5
*
* @param Default Y Anchor
* @desc Default value used for your sprites's Y Anchor.
* Default: 1.0
* @default 1.0
*
* @param Step Distance
* @desc This is the distance a unit steps forward for actions.
* Default: 48
* @default 48
*
* @param Flinch Distance
* @desc In sideview, when a unit takes damage or dodges, it will
* flinch a certain distance in pixels.
* @default 12
*
* @param Show Shadows
* @desc Do you wish to have shadows appear under actors?
* NO - false     YES - true
* @default true
*
* @param ---Damage Popups---
* @default
*
* @param Popup Duration
* @desc Adjusts how many frames a popup will stay visible for.
* Default: 90
* @default 128
*
* @param Newest Popup Bottom
* @desc Places the newest popup at the bottom of a group.
* NO - false     YES - true
* @default true
*
* @param Popup Overlap Rate
* @desc When multiple damage popups appear, they cover each other.
* Use this to change the buffer rate amount for each sprite.
* @default 0.9
*
* @param Critical Popup
* @desc Adjusts the popup's flashing color for critical hits.
* Default: 255, 0, 0, 160
* @default 255, 0, 0, 160
*
* @param Critical Duration
* @desc How many frames the flashing will remain for a critical.
* Default: 60
* @default 60
*
* @param ---Tick-Settings---
* @default
*
* @param Timed States
* @desc If the battle system is Tick-based, use time instead of
* turns for states? NO - false   YES - true
* @default true
*
* @param Timed Buffs
* @desc If the battle system is Tick-based, use time instead of
* turns for buffs? NO - false   YES - true
* @default true
*
* @param Turn Time
* @desc How many ticks must past to equal 1 turn?
* @default 100
*
* @param ---Window Settings---
* @default
*
* @param Lower Windows
* @desc Places the skill and item windows at the screen's bottom.
* OFF - false     ON - true
* @default true
*
* @param Window Rows
* @desc For lower windows, how many rows of items do you wish for
* the windows to display?
* @default 4
*
* @param Command Window Rows
* @desc Sets the number of rows for each command window to display.
* Default: 4
* @default 4
*
* @param Command Alignment
* @desc Sets the text alignment for the Party/Actor Commands.
* Default: left
* @default center
*
* @param Start Actor Command
* @desc Starts turn with the Actor Command Window instead of Party.
* OFF - false     ON - true
* @default true
*
* @param ---Selection Help---
* @default
*
* @param Select Help Window
* @desc When selecting actors and enemies, show the help window?
* NO - false     YES - true
* @default true
*
* @param User Help Text
* @desc The singular form of 'User' used in a help window.
* @default User
*
* @param Ally Help Text
* @desc The singular form of 'Ally' used in a help window.
* @default Ally
*
* @param Allies Help Text
* @desc The plural form of 'Allies' used in a help window.
* @default Allies
*
* @param Enemy Help Text
* @desc The singular form of 'Enemy' used in a help window.
* @default Enemy
*
* @param Enemies Help Text
* @desc The plural form of 'Enemy' used in a help window.
* @default Enemies
*
* @param All Help Text
* @desc When selecting a entire group of targets.
* %1 - Target Group (Allies or Enemies)
* @default All %1
*
* @param Random Help Text
* @desc When selecting a random selection of targets.
* %1 - Target Group (Allies or Enemies)     %2 - Number
* @default %2 Random %1
*
* @param ---Enemy Select---
* @default
*
* @param Visual Enemy Select
* @desc Replaces the enemy selection screen with a more visual one.
* OFF - false     ON - true
* @default true
*
* @param Show Enemy Name
* @desc Show enemy names with Visual Enemy Select.
* OFF - false     ON - true
* @default true
*
* @param Enemy Font Size
* @desc Changes the font size used to display enemy names.
* Default: 28
* @default 20
*
* @param Enemy Auto Select
* @desc Changes what enemy is automatically selected at first.
* LEFT - 0     RIGHT - this.furthestRight()
* @default this.furthestRight()
*
* @param ---Actor Select---
* @default
*
* @param Visual Actor Select
* @desc Allows you to click the actor on screen to select it.
* OFF - false     ON - true
* @default true
*
* @param ---Battle Log---
* @default
*
* @param Show Emerge Text
* @desc Shows the battle start text for enemies appearing.
* OFF - false     ON - true
* @default false
*
* @param Show Pre-Emptive Text
* @desc Shows the text for getting a pre-emptive attack.
* OFF - false     ON - true
* @default true
*
* @param Show Surprise Text
* @desc Shows the text for getting a surprise attack.
* OFF - false     ON - true
* @default true
*
* @param Optimize Speed
* @desc Cuts log base line process to optimize the battle speed.
* OFF - false     ON - true
* @default true
*
* @param Show Action Text
* @desc Displays full action text or a simplified version of it.
* SIMPLE - false     FULL - true
* @default false
*
* @param Show State Text
* @desc Shows all text regarding states.
* OFF - false     ON - true
* @default false
*
* @param Show Buff Text
* @desc Shows all text regarding buffs.
* OFF - false     ON - true
* @default false
*
* @param Show Counter Text
* @desc Shows text regarding counter attacks.
* OFF - false     ON - true
* @default true
*
* @param Show Reflect Text
* @desc Shows text regarding reflected spells.
* OFF - false     ON - true
* @default true
*
* @param Show Substitute Text
* @desc Shows text regarding substituted damage.
* OFF - false     ON - true
* @default true
*
* @param Show Fail Text
* @desc Shows text regarding failed attacks.
* OFF - false     ON - true
* @default false
*
* @param Show Critical Text
* @desc Shows text regarding critical hits.
* OFF - false     ON - true
* @default false
*
* @param Show Miss Text
* @desc Shows text regarding missed attacks.
* OFF - false     ON - true
* @default false
*
* @param Show Evasion Text
* @desc Shows text regarding evaded attacks.
* OFF - false     ON - true
* @default false
*
* @param Show HP Text
* @desc Shows text regarding HP damage or heals.
* OFF - false     ON - true
* @default false
*
* @param Show MP Text
* @desc Shows text regarding MP damage or heals.
* OFF - false     ON - true
* @default false
*
* @param Show TP Text
* @desc Shows text regarding TP damage or heals.
* OFF - false     ON - true
* @default false
*
* @help
* ============================================================================
* Introduction
* ============================================================================
*
* This plugin alters the various aspects of the default battle system,
* allowing it to be more streamlined like most modern RPG's and less clunky
* like older RPG's. This ranges from choosing what text will appear in the
* battle log window at the top and how it will be displayed.
*
* ============================================================================
* Battle Messages
* ============================================================================
*
* When changing "Terms" and the "Messages" that appear in battle, inserting
* the following tag anywhere in the message will cause the message to center
* itself in the battle log.
*
*   <CENTER>
*   This tag must be all caps in order for the battle log window to recognize
*   it as an instruction to center the displayed battle text message.
*
* ============================================================================
* Battle Windows
* ============================================================================
*
* There's various options to adjust the window settings found in the battle
* system to make navigating the battle system more intuitive. Such options
* include starting the turns with the Actor Command Window instead of the
* Party Command Window (the Fight/Escape Window). The Party Command Window is
* still accessible but only by pressing cancel on the first actor's window.
*
* ============================================================================
* Battle Order
* ============================================================================
*
* The battle turn order is also fixed, too. This way, any battlers that Have
* their AGI value changed over the course of battle will reflect those changes
* during the current turn rather than the following turn. The action speed
* calculation can also be adjusted and finetuned to have the random factor of
* its speed calculation formula removed, too, making AGI actually worthwhile
* as a tactical parameter.
*
* ============================================================================
* Multiple Hits
* ============================================================================
*
* Multi-hit action will no longer end prematurely if the target dies midway
* through the action. This is done through toggling immortal states. To make
* use of feature, make sure your database has an Immortal State somewhere. If
* you do not wish to use this feature, set the Parameter for Immortal State ID
* to 0 instead.
*
* ============================================================================
* Popup Revamp
* ============================================================================
*
* Although the damage popups may still look the same as the default ones from
* MV, the process in which they're created is now different to streamline the
* damage popup process. Before, popups would only appear one a time with a
* frame's different at minimum in order for them to show. Now, any actions
* that occur at the same frame will now all show popups at the same frame,
* making for smoother and less clunky damage popups.
*
* ============================================================================
* Common Events
* ============================================================================
*
* Common Events will now occur at the end of each action regardless of whether
* or not the enemy party is still alive. With proper placing of the action
* sequence tags, you can make the skill's common event occur in the middle of
* an action, too. However, keep in mind if you force an action in the middle
* of another action, the remainder of the former action's sequence list will
* become null and void in favor of the new forced action.
*
* ============================================================================
* Casting Animations
* ============================================================================
*
* Casting Animations help provide visual hints for players either by letting
* them know which battler is going to perform an action or what type of skill
* that action will be. This plugin enables skills to have casting animations
* that can be modified universally or customized for each individual skill.
*
* Skill Notetag:
*   <Cast Animation: x>
*   Sets the skill's cast animation to animation ID x. Setting x to zero will
*   cause the skill to not have any animaton at all.
*
* ============================================================================
* Changing Battle Systems
* ============================================================================
*
* While the player is not in battle, you can change the battle system using a
* Plugin Command. With only this plugin, there is only one battle system
* included: the default battle system.
*
* Plugin Command:
*   setBattleSys DTB      Sets battle system to Default Turn Battle.
*
* Other future plugins may include other battle systems that may utilize the
* Battle Engine Core.
*
* ============================================================================
* Sideview Actions
* ============================================================================
*
* In RPG Maker MV's default battle system, both the sideview and the frontview
* settings do not display counterattacks, reflected magic attacks, nor any
* case of substituting for battle members. The Battle Engine Core provides
* games that are using the sideview settings small amounts of animations to
* relay information to the player in a more visual sense.
*
* Magic Reflection will also display a reflection animation to indicate the
* battler has reflection properties. This animation can be changed in the
* parameters, but certain actors, classes, enemies, weapons, armors, and
* states can display a unique kind of animation for reflection if desired.
*
* Actor, Class, Enemy, Weapon, Armor, and State Notetag:
*   <Reflect Animation ID: x>
*   Changes the user's reflect animation to x. This will take priority in the
*   following order: Actor, Class, Enemy, Weapon, Armor, State, Default.
*
* Sometimes, you don't want your enemies to be able to move. Or you don't want
* certain actors to be able to move. They're just stationary for whatever
* reason. To accomplish that, you can use this notetag to forbid the battler
* from moving.
*
* Actor, Class, Enemy, Weapon, Armor, and State Notetag:
*   <Sprite Cannot Move>
*   Prevents the battler's sprite from moving. This will take priority in the
*   following order: Actor, Class, Enemy, Weapon, Armor, and State. If an
*   enemy is unable to move when it performs an action, it will flash white as
*   if it normally does in front view.
*
* ============================================================================
* Custom Sideview Battler Anchor
* ============================================================================
*
* Sideview battlers are generally centered horizontally, and grounded at their
* feet. However, not all sideview battler spritesheets work this way. In the
* event you have a sideview battler that doesn't conform to those standards,
* you can 'anchor' them a different way.
*
* Actor Notetags:
*   <Anchor X: y.z>
*   <Anchor Y: y.z>
*   This sets the anchor location for the actor's sideview battler at y.z.
*   By default, the X anchor is 0.5 while the Y anchor is 1.0. If you want
*   the X anchor to be a bit more to the left, make it less than 0.5. Make it
*   more than 0.5 to make the X anchor more towards the right. To raise the
*   Y anchor, set the number value to less than 1.0. Keep adjusting until you
*   find that perfect anchor setting.
*
* ============================================================================
* Action Sequences
* ============================================================================
*
* The Yanfly Engine Plugins - Battle Engine Core includes the capability of
* using custom action sequences. Action sequences are basic instructions for
* the game to creating a customized skill both visually and mechanically.
* The Battle Engine Core, however, will only include the most basic of action
* sequences so the instructions on how to create a custom action sequence will
* be included in the Help file on future extension plugins for this plugin.
*
* ============================================================================
* Changelog
* ============================================================================
*
* Version 1.11:
* - Fixed a bug that didn't show HP/MP Regeneration.
*
* Version 1.10:
* - Removed immortal state dependancy. Immortality is now its own setting.
* - Added more abbreviated variables for action speed calculation.
* - Fixed a bug where all-scope attacks would reveal Appear-Halfway enemies.
* - Fixed a bug where the battle wouldn't end if the final enemy was killed
* by state damage.
*
* Version 1.09:
* - Fixed a undefined actor bug for refreshing the status window.
* - Added 'Show Shadows' parameter to the plugin settings.
* - Reworked the default action sequences so that forced actions do not appear
* on top of each other and party-heal animations occur simultaneously.
*
* Version 1.08:
* - Fixed a bug where battlers gaining HP/MP in the damage formula for
* themselves wouldn't trigger popups.
* - Fixed a bug where if the party failed to escape from battle, states that
* would be removed by battle still get removed. *Fixed by Emjenoeg*
* - Fixed a bug where instant death skills didn't work.
* - Changed Sprite Priority settings to decide whether actors, enemies, or
* neither would always be on top.
*
* Version 1.07:
* - Optimized status window to refresh at a minimum.
* - Set up frame work for future plugins:
* - Added 'Escape Ratio' and 'Fail Escape Boost' to parameters to allow users
* to set the escape ratio they want.
* - Added 'Front Sprite Priority' and 'Side Sprite Priority' to parameters to
* dictate if actor sprites are always on top.
* - Added 'Tick-Settings' category for tick-based battle systems.
*
* Version 1.06:
* - Fixed a bug that causes dead actors at the start of battle to not spawn.
* - Fixed a bug where the help window on an empty slot would show the
* previous skill's message.
*
* Version 1.05:
* - Added new target typing: Character X, which allows you to select
* specifically the actor with an actor ID of X if he/she/it is in the party.
* - Fixed a bug that prevented Miss and Evade popups from showing.
*
* Version 1.04:
* - Fixed a bug where popups didn't show under certain animation types.
* - Fixed certain battler motions from not refreshing correctly.
* - Actions with no scope will not trigger the confirmation selection window.
*
* Version 1.03:
* - Added 'Wait for Effect' action sequence.
* - Actions now wait for effects (such as collapsing) to be done before
* continuing on with battle or to end battle.
*
* Version 1.02:
* - Fixed a bug where the help window would retain descriptions on no skills.
* - Synched up weapons with actor sprites so they would occur simultaneously.
* - Fixed an issue where requesting certain motions from enemies that don't
* exist would cause them to crash.
*
* Version 1.01:
* - Skills and items that affect both HP and MP will now show popups for both.
*
* Version 1.00:
* - Finished plugin!
*/
//=============================================================================

//=============================================================================
// Parameter Variables
//=============================================================================

Yanfly.Parameters = PluginManager.parameters('YEP_BattleEngineCore');
Yanfly.Param = Yanfly.Param || {};

Yanfly.Param.BECSystem = String(Yanfly.Parameters['Default System']);
Yanfly.Param.BECEscRatio = String(Yanfly.Parameters['Escape Ratio']);
Yanfly.Param.BECEscFail = String(Yanfly.Parameters['Fail Escape Boost']);
Yanfly.Param.CastCertHit = Number(Yanfly.Parameters['Certain Hit Animation']);
Yanfly.Param.CastPhysical = Number(Yanfly.Parameters['Physical Animation']);
Yanfly.Param.CastMagical = Number(Yanfly.Parameters['Magical Animation']);
Yanfly.Param.EnemyAtkAni = Number(Yanfly.Parameters['Enemy Attack Animation']);
Yanfly.Param.BECOptSpeed = String(Yanfly.Parameters['Optimize Speed']);
Yanfly.Param.BECEmergeText = String(Yanfly.Parameters['Show Emerge Text']);
Yanfly.Param.BECPreEmpText = String(Yanfly.Parameters['Show Pre-Emptive Text']);
Yanfly.Param.BECSurpText = String(Yanfly.Parameters['Show Surprise Text']);
Yanfly.Param.BECPopupOverlap = String(Yanfly.Parameters['Popup Overlap Rate']);
Yanfly.Param.BECNewPopBottom = String(Yanfly.Parameters['Newest Popup Bottom']);
Yanfly.Param.BECStartActCmd = String(Yanfly.Parameters['Start Actor Command']);
Yanfly.Param.BECSelectHelp = String(Yanfly.Parameters['Select Help Window']);
Yanfly.Param.BECHelpUserTx = String(Yanfly.Parameters['User Help Text']);
Yanfly.Param.BECHelpAllyTx = String(Yanfly.Parameters['Ally Help Text']);
Yanfly.Param.BECHelpAlliesTx = String(Yanfly.Parameters['Allies Help Text']);
Yanfly.Param.BECHelpEnemyTx = String(Yanfly.Parameters['Enemy Help Text']);
Yanfly.Param.BECHelpEnemiesTx = String(Yanfly.Parameters['Enemies Help Text']);
Yanfly.Param.BECHelpAllTx = String(Yanfly.Parameters['All Help Text']);
Yanfly.Param.BECHelpRandTx = String(Yanfly.Parameters['Random Help Text']);
Yanfly.Param.BECFrontPosX = String(Yanfly.Parameters['Front Position X']);
Yanfly.Param.BECFrontPosY = String(Yanfly.Parameters['Front Position Y']);
Yanfly.Param.BECFrontSprite = String(Yanfly.Parameters['Front Actor Sprite']);
Yanfly.Param.BECFrSpPrio = String(Yanfly.Parameters['Front Sprite Priority']);
Yanfly.Param.BECHomePosX = String(Yanfly.Parameters['Home Position X']);
Yanfly.Param.BECHomePosY = String(Yanfly.Parameters['Home Position Y']);
Yanfly.Param.BECSideSpPrio = String(Yanfly.Parameters['Side Sprite Priority']);
Yanfly.Param.BECAnchorX = Number(Yanfly.Parameters['Default X Anchor']);
Yanfly.Param.BECAnchorY = Number(Yanfly.Parameters['Default Y Anchor']);
Yanfly.Param.BECStepDist = Number(Yanfly.Parameters['Step Distance']);
Yanfly.Param.BECFlinchDist = Number(Yanfly.Parameters['Flinch Distance']);
Yanfly.Param.BECShowShadows = String(Yanfly.Parameters['Show Shadows']);
Yanfly.Param.BECPopupDur = String(Yanfly.Parameters['Popup Duration']);
Yanfly.Param.BECCritPopup = String(Yanfly.Parameters['Critical Popup']);
Yanfly.Param.BECCritDur = String(Yanfly.Parameters['Critical Duration']);
Yanfly.Param.BECActionSpeed = String(Yanfly.Parameters['Action Speed']);
Yanfly.Param.BECReflectAni = Number(Yanfly.Parameters['Reflect Animation']);
Yanfly.Param.BECMotionWait = String(Yanfly.Parameters['Motion Waiting']);
Yanfly.Param.BECTimeStates = String(Yanfly.Parameters['Timed States']);
Yanfly.Param.BECTimeBuffs = String(Yanfly.Parameters['Timed Buffs']);
Yanfly.Param.BECTurnTime = Number(Yanfly.Parameters['Turn Time']);
Yanfly.Param.BECLowerWindows = String(Yanfly.Parameters['Lower Windows']);
Yanfly.Param.BECEnemySelect = String(Yanfly.Parameters['Visual Enemy Select']);
Yanfly.Param.BECActorSelect = String(Yanfly.Parameters['Visual Actor Select']);
Yanfly.Param.BECWindowRows = String(Yanfly.Parameters['Window Rows']);
Yanfly.Param.BECEnemyFontSize = Number(Yanfly.Parameters['Enemy Font Size']);
Yanfly.Param.BECShowEnemyName = String(Yanfly.Parameters['Show Enemy Name']);
Yanfly.Param.BECEnemyAutoSel = String(Yanfly.Parameters['Enemy Auto Select']);
Yanfly.Param.BECCommandAlign = String(Yanfly.Parameters['Command Alignment']);
Yanfly.Param.BECCommandRows = String(Yanfly.Parameters['Command Window Rows']);
Yanfly.Param.BECAniBaseDel = String(Yanfly.Parameters['Animation Base Delay']);
Yanfly.Param.BECAniNextDel = String(Yanfly.Parameters['Animation Next Delay']);
Yanfly.Param.BECFullActText = String(Yanfly.Parameters['Show Action Text']);
Yanfly.Param.BECShowCntText = String(Yanfly.Parameters['Show Counter Text']);
Yanfly.Param.BECShowRflText = String(Yanfly.Parameters['Show Reflect Text']);
Yanfly.Param.BECShowSubText = String(Yanfly.Parameters['Show Substitute Text']);
Yanfly.Param.BECShowFailText = String(Yanfly.Parameters['Show Fail Text']);
Yanfly.Param.BECShowCritText = String(Yanfly.Parameters['Show Critical Text']);
Yanfly.Param.BECShowMissText = String(Yanfly.Parameters['Show Miss Text']);
Yanfly.Param.BECShowEvaText = String(Yanfly.Parameters['Show Evasion Text']);
Yanfly.Param.BECShowHpText = String(Yanfly.Parameters['Show HP Text']);
Yanfly.Param.BECShowMpText = String(Yanfly.Parameters['Show MP Text']);
Yanfly.Param.BECShowTpText = String(Yanfly.Parameters['Show TP Text']);
Yanfly.Param.BECShowStateText = String(Yanfly.Parameters['Show State Text']);
Yanfly.Param.BECShowBuffText = String(Yanfly.Parameters['Show Buff Text']);

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

Yanfly.BEC.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;
DataManager.isDatabaseLoaded = function() {
    if (!Yanfly.BEC.DataManager_isDatabaseLoaded.call(this)) return false;
                this.processMELODYNotetags($dataSkills);
                this.processMELODYNotetags($dataItems);
                this.processBECNotetags1($dataSkills);
                this.processBECNotetags2($dataSkills);
                this.processBECNotetags2($dataItems);
                this.processBECNotetags3($dataEnemies);
                this.processBECNotetags4($dataActors);
                this.processBECNotetags4($dataClasses);
                this.processBECNotetags4($dataWeapons);
                this.processBECNotetags4($dataArmors);
                this.processBECNotetags4($dataEnemies);
                this.processBECNotetags4($dataStates);
                this.processBECNotetags5($dataActors);
                return true;
};

DataManager.processMELODYNotetags = function(group) {
  for (var n = 1; n < group.length; n++) {
                var obj = group[n];
    if (obj.actionsMade) continue;
    obj.actionsMade = true;
    var notedata = obj.note.split(/[\r\n]+/);

    var actionType = 0;
                this.setDefaultActions(obj);

                for (var i = 0; i < notedata.length; i++) {
                        var line = notedata;
                        if (line.match(/<(?:SETUP ACTION|setup)>/i)) {
        actionType = 1;
        obj.setupActions = [];
                        } else if (line.match(/<\/(?:SETUP ACTION|setup)>/i)) {
        var actionType = 0;
      } else if (line.match(/<(?:WHOLE ACTION|whole)>/i)) {
        actionType = 2;
        obj.wholeActions = [];
      } else if (line.match(/<\/(?:WHOLE ACTION|whole)>/i)) {
        var actionType = 0;
      } else if (line.match(/<(?:TARGET ACTION|target)>/i)) {
        actionType = 3;
        obj.targetActions = [];
      } else if (line.match(/<\/(?:TARGET ACTION|target)>/i)) {
        var actionType = 0;
      } else if (line.match(/<(?:FOLLOW ACTION|follow)>/i)) {
        actionType = 4;
        obj.followActions = [];
      } else if (line.match(/<\/(?:FOLLOW ACTION|follow)>/i)) {
        var actionType = 0;
      } else if (line.match(/<(?:FINISH ACTION|finish)>/i)) {
        actionType = 5;
        obj.finishActions = [];
      } else if (line.match(/<\/(?:FINISH ACTION|finish)>/i)) {
        var actionType = 0;
      } else {
        this.convertSequenceLine(obj, line, actionType);
      }
                }
        }
};

Yanfly.BEC.DefaultActionSetup = [
    ['CLEAR BATTLE LOG'],
    ['DISPLAY ACTION'],
                ['IMMORTAL', ['TARGETS', 'TRUE']],
    ['PERFORM START'],
    ['WAIT FOR MOVEMENT'],
    ['CAST ANIMATION'],
    ['WAIT FOR ANIMATION']
];
Yanfly.BEC.DefaultActionWhole = [
                ['PERFORM ACTION'],
];
Yanfly.BEC.DefaultActionTarget = [
                ['PERFORM ACTION'],
];
if (eval(Yanfly.Param.BECMotionWait)) {
  Yanfly.BEC.DefaultActionWhole.push(['MOTION WAIT', ['USER']]);
  Yanfly.BEC.DefaultActionTarget.push(['MOTION WAIT', ['USER']]);
} else {
  Yanfly.BEC.DefaultActionWhole.push(['WAIT', [10]]);
  Yanfly.BEC.DefaultActionTarget.push(['WAIT', [10]]);
};
Yanfly.BEC.DefaultActionWhole.push(['ACTION ANIMATION']);
Yanfly.BEC.DefaultActionWhole.push(['WAIT FOR ANIMATION']);
Yanfly.BEC.DefaultActionTarget.push(['ACTION ANIMATION']);
Yanfly.BEC.DefaultActionTarget.push(['WAIT FOR ANIMATION']);
Yanfly.BEC.DefaultActionFollow = [
];
Yanfly.BEC.DefaultActionFinish = [
                ['IMMORTAL', ['TARGETS', 'FALSE']],
                ['WAIT FOR NEW LINE'],
                ['CLEAR BATTLE LOG'],
                ['PERFORM FINISH'],
    ['WAIT FOR MOVEMENT'],
    ['WAIT FOR EFFECT'],
                ['ACTION COMMON EVENT'],
];
DataManager.setDefaultActions = function(obj) {
                obj.setupActions = Yanfly.BEC.DefaultActionSetup.slice();
                if (this.isWholeAction(obj)) {
                        obj.wholeActions = Yanfly.BEC.DefaultActionWhole.slice();
                        this.addActionEffects(obj, obj.wholeActions);
      obj.targetActions = [];
                } else {
      obj.wholeActions = [];
                        obj.targetActions = Yanfly.BEC.DefaultActionTarget.slice();
                        this.addActionEffects(obj, obj.targetActions);
                }
                obj.followActions = Yanfly.BEC.DefaultActionFollow.slice();
                obj.finishActions = Yanfly.BEC.DefaultActionFinish.slice();
};

DataManager.isWholeAction = function(obj) {
        if (obj.animationId > 0 && $dataAnimations[obj.animationId]) {
                var animation = $dataAnimations[obj.animationId];
                if (animation.position === 3) return true;
                if (animation.position !== 3 && [2, 8, 10].contains(obj.scope)) return true;
        }
        return false;
};

DataManager.addActionEffects = function(obj, array) {
                for (;;) {
                        array[array.length] = ['ACTION EFFECT'];
                        array[array.length] = ['DEATH BREAK'];
                        obj.repeats -= 1;
                        if (obj.repeats <= 0) break;
                        array[array.length] = ['WAIT', [8]];
                }
                obj.repeats = 1;
};

Yanfly.BEC.SeqType6 =
        /[ ]*(.*):[ ](.*),[ ](.*),[ ](.*),[ ](.*),[ ](.*),[ ](.*)/i;
Yanfly.BEC.SeqType5 =
        /[ ]*(.*):[ ](.*),[ ](.*),[ ](.*),[ ](.*),[ ](.*)/i;
Yanfly.BEC.SeqType4 =
        /[ ]*(.*):[ ](.*),[ ](.*),[ ](.*),[ ](.*)/i;
Yanfly.BEC.SeqType3 =
        /[ ]*(.*):[ ](.*),[ ](.*),[ ](.*)/i;
Yanfly.BEC.SeqType2 =
        /[ ]*(.*):[ ](.*),[ ](.*)/i;
Yanfly.BEC.SeqType1 =
        /[ ]*(.*):[ ](.*)/i;
Yanfly.BEC.SeqType0 =
        /[ ]*(.*)/i;
DataManager.convertSequenceLine = function(obj, line, actionType) {
        if (actionType <= 0 || actionType > 5) return;
  Yanfly.BEC.SeqType;
  var seqArgs;
  if (line.match(Yanfly.BEC.SeqType6)) {
    Yanfly.BEC.SeqType = RegExp.$1;
    seqArgs =
                        [RegExp.$2, RegExp.$3, RegExp.$4, RegExp.$5, RegExp.$6, RegExp.$7];
  } else if (line.match(Yanfly.BEC.SeqType5)) {
    Yanfly.BEC.SeqType = RegExp.$1;
    seqArgs = [RegExp.$2, RegExp.$3, RegExp.$4, RegExp.$5, RegExp.$6];
  } else if (line.match(Yanfly.BEC.SeqType4)) {
    Yanfly.BEC.SeqType = RegExp.$1;
    seqArgs = [RegExp.$2, RegExp.$3, RegExp.$4, RegExp.$5];
  } else if (line.match(Yanfly.BEC.SeqType3)) {
    Yanfly.BEC.SeqType = RegExp.$1;
    seqArgs = [RegExp.$2, RegExp.$3, RegExp.$4];
  } else if (line.match(Yanfly.BEC.SeqType2)) {
    Yanfly.BEC.SeqType = RegExp.$1;
    seqArgs = [RegExp.$2, RegExp.$3];
  } else if (line.match(Yanfly.BEC.SeqType1)) {
    Yanfly.BEC.SeqType = RegExp.$1;
    seqArgs = [RegExp.$2];
  } else if (line.match(Yanfly.BEC.SeqType0)) {
    Yanfly.BEC.SeqType = RegExp.$1;
    seqArgs = [];
  } else {
    return;
  }
  var array = [Yanfly.BEC.SeqType, seqArgs];
  if (actionType === 1) obj.setupActions[obj.setupActions.length] = array;
  if (actionType === 2) obj.wholeActions[obj.wholeActions.length] = array;
  if (actionType === 3) obj.targetActions[obj.targetActions.length] = array;
  if (actionType === 4) obj.followActions[obj.followActions.length] = array;
  if (actionType === 5) obj.finishActions[obj.finishActions.length] = array;
};

DataManager.processBECNotetags1 = function(group) {
        var note1 = /<(?:CAST ANIMATION|cast ani):[ ](\d+)>/i;
        for (var n = 1; n < group.length; n++) {
                var obj = group[n];
                var notedata = obj.note.split(/[\r\n]+/);

    obj.castAnimation = 0;
    if (obj.hitType === 0) obj.castAnimation = Yanfly.Param.CastCertHit;
    if (obj.hitType === 1) obj.castAnimation = Yanfly.Param.CastPhysical;
    if (obj.hitType === 2) obj.castAnimation = Yanfly.Param.CastMagical;

                for (var i = 0; i < notedata.length; i++) {
                        var line = notedata;
                        if (line.match(note1)) {
                                obj.castAnimation = parseInt(RegExp.$1);
                        }
                }
        }
};

DataManager.processBECNotetags2 = function(group) {
        var note1 = /<(?:ACTION COPY):[ ](.*):[ ]*(\d+)>/i;
        for (var n = 1; n < group.length; n++) {
                var obj = group[n];
                var notedata = obj.note.split(/[\r\n]+/);

    for (var i = 0; i < notedata.length; i++) {
                        var line = notedata;
                        if (line.match(note1)) {
                                var text = String(RegExp.$1).toUpperCase();
                                var target;
                                if (['I', 'ITEM'].contains(text)) {
                                        target = $dataItems[parseInt(RegExp.$2)];
                                } else if (['S', 'SKILL'].contains(text)) {
                                        target = $dataSkills[parseInt(RegExp.$2)];
                                }
                                if (target) {
                                        obj.setupActions = target.setupActions.slice();
                                        obj.wholeActions = target.wholeActions.slice();
                                        obj.targetActions = target.targetActions.slice();
                                        obj.followActions = target.followActions.slice();
                                        obj.finishActions = target.finishActions.slice();
                                }
                        }
                }
        }
};

DataManager.processBECNotetags3 = function(group) {
        var note1 = /<(?:ATTACK ANIMATION|attack ani):[ ](\d+)>/i;
        for (var n = 1; n < group.length; n++) {
                var obj = group[n];
                var notedata = obj.note.split(/[\r\n]+/);

    obj.attackAnimationId = Yanfly.Param.EnemyAtkAni;

                for (var i = 0; i < notedata.length; i++) {
                        var line = notedata;
                        if (line.match(note1)) {
                                obj.attackAnimationId = parseInt(RegExp.$1);
                        }
                }
        }
};

DataManager.processBECNotetags4 = function(group) {
  var note1 = /<(?:REFLECT ANIMATION|reflect ani):[ ](\d+)>/i;
        for (var n = 1; n < group.length; n++) {
                var obj = group[n];
                var notedata = obj.note.split(/[\r\n]+/);

    obj.reflectAnimationId = 0;
                obj.spriteCannotMove = false;

                for (var i = 0; i < notedata.length; i++) {
                        var line = notedata;
                        if (line.match(note1)) {
        obj.reflectAnimationId = parseInt(RegExp.$1);
                        } else if (line.match(/<(?:SPRITE CANNOT MOVE)>/i)) {
                                obj.spriteCannotMove = true;
                        }
                }
        }
};

DataManager.processBECNotetags5 = function(group) {
        for (var n = 1; n < group.length; n++) {
                var obj = group[n];
                var notedata = obj.note.split(/[\r\n]+/);

    obj.anchorX = Yanfly.Param.BECAnchorX;
    obj.anchorY = Yanfly.Param.BECAnchorY;

                for (var i = 0; i < notedata.length; i++) {
                        var line = notedata;
                        if (line.match(/<(?:ANCHOR X):[ ](\d+)[.](\d+)>/i)) {
                                obj.anchorX = eval(String(RegExp.$1) + '.' + String(RegExp.$2));
                        } else if (line.match(/<(?:ANCHOR Y):[ ](\d+)[.](\d+)>/i)) {
                                obj.anchorY = eval(String(RegExp.$1) + '.' + String(RegExp.$2));
                        }
                }
        }
};

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

Yanfly.BEC.BattleManager_initMembers = BattleManager.initMembers;
BattleManager.initMembers = function() {
    Yanfly.BEC.BattleManager_initMembers.call(this);
    this._forceSelection = false;
    this._allSelection = false;
};

BattleManager.isBattleSystem = function(value) {
    return value.toLowerCase() === $gameSystem.getBattleSystem();
};

BattleManager.isDTB = function() {
    return this.isBattleSystem('dtb');
};

BattleManager.isTurnBased = function() {
    if (this.isDTB()) return true;
    return false;
};

BattleManager.isTickBased = function() {
    return !this.isTurnBased();
};

BattleManager.tickRate = function() {
    return 1;
};

BattleManager.forceSelection = function() {
    this._forceSelection = true;
};

BattleManager.isForceSelection = function() {
    return this._forceSelection;
};

BattleManager.resetSelection = function() {
    this._forceSelection = false;
};

BattleManager.startAllSelection = function() {
    this._allSelection = true;
};

BattleManager.isAllSelection = function() {
     return this._allSelection && BattleManager.isInputting();
};

BattleManager.stopAllSelection = function() {
    this._allSelection = false;
};

Yanfly.BEC.BattleManager_makeEscapeRatio = BattleManager.makeEscapeRatio;
BattleManager.makeEscapeRatio = function() {
    if (this.isDTB()) {
      this._escapeRatio = eval(Yanfly.Param.BECEscRatio);
      this._escapeFailBoost = eval(Yanfly.Param.BECEscFail);
    } else {
      this._escapeFailBoost = 0.1;
      Yanfly.BEC.BattleManager_makeEscapeRatio.call(this);
    }
};

BattleManager.timeBasedStates = function() {
                if (!$gameParty.inBattle()) return false;
                if (this.isTurnBased()) return false;
                if (this._timeBasedStates !== undefined) return this._timeBasedStates;
                this._timeBasedStates = eval(Yanfly.Param.BECTimeStates);
                return this._timeBasedStates;
};

BattleManager.timeBasedBuffs = function() {
                if (!$gameParty.inBattle()) return false;
                if (this.isTurnBased()) return false;
                if (this._timeBasedBuffs !== undefined) return this._timeBasedBuffs;
                this._timeBasedBuffs = eval(Yanfly.Param.BECTimeBuffs);
                return this._timeBasedBuffs;
};

BattleManager.displayStartMessages = function() {
    if (eval(Yanfly.Param.BECEmergeText)) {
      $gameTroop.enemyNames().forEach(function(name) {
          $gameMessage.add(TextManager.emerge.format(name));
      });
    }
    if (this._preemptive && eval(Yanfly.Param.BECPreEmpText)) {
        $gameMessage.add(TextManager.preemptive.format($gameParty.name()));
    } else if (this._surprise && eval(Yanfly.Param.BECSurpText)) {
        $gameMessage.add(TextManager.surprise.format($gameParty.name()));
    }
};

BattleManager.registerSprite = function(battler, sprite) {
  if (!this._registeredSprites) this._registeredSprites = {};
  if (battler.isActor()) var id = 100000 + battler.actorId();
  if (battler.isEnemy()) var id = 200000 + battler.index();
  this._registeredSprites[id] = sprite;
};

BattleManager.getSprite = function(battler) {
  if (!this._registeredSprites) this._registeredSprites = {};
  if (battler.isActor()) var id = 100000 + battler.actorId();
  if (battler.isEnemy()) var id = 200000 + battler.index();
  return this._registeredSprites[id];
};

BattleManager.setSpritePriority = function() {
    if ($gameSystem.isSideView()) {
      this._spritePriority = eval(Yanfly.Param.BECSideSpPrio);
    } else {
      this._spritePriority = eval(Yanfly.Param.BECFrontSprite);
    }
    if (this._spritePriority === false) this._spritePriority = 0;
    if (this._spritePriority === true) this._spritePriority = 1;
};

BattleManager.getSpritePriority = function() {
    if (!this._spritePriority) this.setSpritePriority();
    return this._spritePriority;
};

BattleManager.changeActor = function(newActorIndex, lastActorActionState) {
    var lastActor = this.actor();
    this._actorIndex = newActorIndex;
    var newActor = this.actor();
    if (lastActor) {
        lastActor.setActionState(lastActorActionState);
        lastActor.spriteReturnHome();
    }
    if (newActor) {
        newActor.setActionState('inputting');
        newActor.spriteStepForward();
    }
};

Yanfly.BEC.BattleManager_checkBattleEnd = BattleManager.checkBattleEnd;
BattleManager.checkBattleEnd = function() {
    if (this._phase === 'actionList' || this._phase === 'actionTargetList' ||
                        $gameTroop.isEventRunning()) return false;
    return Yanfly.BEC.BattleManager_checkBattleEnd.call(this);
};

Yanfly.BEC.BattleManager_processVictory = BattleManager.processVictory;
BattleManager.processVictory = function() {
    this._logWindow.clear();
                Yanfly.BEC.BattleManager_processVictory.call(this);
};

BattleManager.processEscape = function() {
    $gameParty.performEscape();
    SoundManager.playEscape();
    var success = this._preemptive ? true : (Math.random() < this._escapeRatio);
    if (success) {
        $gameParty.removeBattleStates();
        $gameParty.performEscapeSuccess();
        this.displayEscapeSuccessMessage();
        this._escaped = true;
        this.processAbort();
    } else {
        this.displayEscapeFailureMessage();
        this._escapeRatio += this._escapeFailBoost;
        $gameParty.clearActions();
        this.startTurn();
    }
    return success;
};

BattleManager.startTurn = function() {
    this._phase = 'turn';
    this.clearActor();
    $gameTroop.increaseTurn();
    $gameParty.onTurnStart();
    $gameTroop.onTurnStart();
    this._performedBattlers = [];
    this.makeActionOrders();
    $gameParty.requestMotionRefresh();
    this._logWindow.startTurn();
    this._subject = this.getNextSubject();
};

Yanfly.BEC.BattleManager_endTurn = BattleManager.endTurn;
BattleManager.endTurn = function() {
    if (this._spriteset.isPopupPlaying()) return;
    Yanfly.BEC.BattleManager_endTurn.call(this);
};

BattleManager.getNextSubject = function() {
    if ($gameTroop.turnCount() <= 0) return;
    this._performedBattlers = this._performedBattlers || [];
    this.makeActionOrders();
    for (;;) {
        var battlerArray = [];
        for (var i = 0; i < this._actionBattlers.length; ++i) {
          var obj = this._actionBattlers;
          if (!this._performedBattlers.contains(obj)) battlerArray.push(obj);
        }
        this._actionBattlers = battlerArray;
        var battler = this._actionBattlers.shift();
        if (!battler) return null;
        if (battler.isBattleMember() && battler.isAlive()) {
            this._performedBattlers.push(battler);
            return battler;
        }
    }
};

BattleManager.update = function() {
    if (!this.isBusy() && !this.updateEvent()) {
        switch (this._phase) {
        case 'start':
            this.startInput();
            break;
        case 'turn':
            this.updateTurn();
            break;
        case 'action':
            this.updateAction();
            break;
                                case 'phaseChange':
                                                this.updatePhase();
                                                break;
                                case 'actionList':
                                                this.updateActionList()
                                                break;
        case 'actionTargetList':
                                                this.updateActionTargetList()
                                                break;
        case 'turnEnd':
            this.updateTurnEnd();
            break;
        case 'battleEnd':
            this.updateBattleEnd();
            break;
        }
    }
};

BattleManager.updateEvent = function() {
    if (this._processingForcedAction) return false;
    switch (this._phase) {
    case 'start':
    case 'turn':
    case 'turnEnd':
    case 'actionList':
    case 'actionTargetList':
      if (this.isActionForced()) {
        this.processForcedAction();
        return true;
      } else {
        return this.updateEventMain();
      }
    }
    return this.checkAbort();
};

Yanfly.BEC.BattleManager_processForcedAction =
    BattleManager.processForcedAction;
BattleManager.processForcedAction = function() {
    if (this._actionForcedBattler) this._processingForcedAction = true;
    Yanfly.BEC.BattleManager_processForcedAction.call(this);
};

BattleManager.updateAction = function() {
    var target = this._targets.shift();
    if (target) {
        this.invokeAction(this._subject, target);
    } else {
        if (this._returnPhase === 'target') {
          this._targets = [this._individualTargets[0]];
          this._phase = 'actionTargetList';
        } else {
          this._targets = this._allTargets.slice();
          this._phase = 'actionList';
        }
    }
};

BattleManager.invokeAction = function(subject, target) {
    if (!eval(Yanfly.Param.BECOptSpeed))        this._logWindow.push('pushBaseLine');
    if (Math.random() < this._action.itemCnt(target)) {
        this.invokeCounterAttack(subject, target);
    } else if (Math.random() < this._action.itemMrf(target)) {
        this.invokeMagicReflection(subject, target);
    } else {
        this.invokeNormalAction(subject, target);
    }
    subject.setLastTarget(target);
    if (!eval(Yanfly.Param.BECOptSpeed)) this._logWindow.push('popBaseLine');
};

BattleManager.invokeCounterAttack = function(subject, target) {
    var action = new Game_Action(target);
    this._logWindow.displayCounter(target);
                action.setAttack();
    action.apply(subject);
    this._logWindow.displayActionResults(subject, subject);
    if (subject.isDead()) subject.performCollapse();
};

Yanfly.BEC.BattleManager_invokeMagicReflection =
    BattleManager.invokeMagicReflection;
BattleManager.invokeMagicReflection = function(subject, target) {
    Yanfly.BEC.BattleManager_invokeMagicReflection.call(this, subject, target);
    if (subject.isDead()) subject.performCollapse();
};

BattleManager.updatePhase = function() {
    var phase = this._phaseSteps.shift();
                if (phase) this.createPhaseChanges();
                switch (phase) {
                case 'setup':
                        this.createSetupActions();
                        break;
                case 'whole':
                        this.createWholeActions();
                        break;
                case 'target':
                        this.createTargetActions();
                        break;
                case 'follow':
                        this.createFollowActions();
                        break;
                case 'finish':
                        this.createFinishActions();
                        break;
                default:
      this.endAction();
                        break;
                }
};

BattleManager.createPhaseChanges = function() {
                this._phase = 'actionList';
                this._targets = this._allTargets.slice();
                this._conditionFlags = [];
                this._trueFlags = [];
};

BattleManager.createSetupActions = function() {
                $gameTemp.clearActionSequenceSettings();
                this._returnPhase = 'setup';
                this._actionList = this._action.item().setupActions.slice();
};

BattleManager.createWholeActions = function() {
                this._returnPhase = 'whole';
                this._actionList = this._action.item().wholeActions.slice();
};

BattleManager.createTargetActions = function() {
                this._returnPhase = 'target';
                this._phase = 'actionTargetList';
                this._targets = [this._individualTargets[0]];
                this._actionList = this._action.item().targetActions.slice();
};

BattleManager.createFollowActions = function() {
                this._returnPhase = 'follow';
                this._actionList = this._action.item().followActions.slice();
};

BattleManager.createFinishActions = function() {
                this._returnPhase = 'finish';
                this._actionList = this._action.item().finishActions.slice();
};

Yanfly.BEC.BattleManager_endAction = BattleManager.endAction;
BattleManager.endAction = function() {
    this._processingForcedAction = false;
    Yanfly.BEC.BattleManager_endAction.call(this);
};

BattleManager.updateActionList = function() {
                for (;;) {
      this._actSeq = this._actionList.shift();
                  if (this._actSeq) {
                                if (!this.actionConditionsMet(this._actSeq)) continue;
                                var seqName = this._actSeq[0].toUpperCase();
                          if (!this.processActionSequence(seqName, this._actSeq[1])) {
          break;
        }
                  } else {
                          this._phase = 'phaseChange';
        break;
                  }
    }
};

BattleManager.updateActionTargetList = function() {
                for (;;) {
      this._actSeq = this._actionList.shift();
                  if (this._actSeq) {
        if (!this.actionConditionsMet(this._actSeq)) continue;
                                var seqName = this._actSeq[0].toUpperCase();
                                if (!this.processActionSequence(seqName, this._actSeq[1])) {
          break;
        }
      } else if (this._individualTargets.length > 0) {
        this._individualTargets.shift();
        if (this._individualTargets.length > 0) {
          this._targets = [this._individualTargets[0]];
          this._actionList = this._action.item().targetActions.slice();
        } else {
          this._phase = 'phaseChange';
          break;
        }
                  } else {
        this._phase = 'phaseChange';
        break;
                  }
    }
};

BattleManager.startAction = function() {
    var subject = this._subject;
    subject.onAllActionsEnd();
    var action = subject.currentAction();
    this._action = action;
                var targets = action.makeTargets();
    this._targets = targets;
                this._allTargets = targets.slice();
    this._individualTargets = targets.slice();
                this._phase = 'phaseChange';
                this._phaseSteps = ['setup', 'whole', 'target', 'follow', 'finish'];
                this._returnPhase = '';
                this._actionList = [];
    subject.useItem(this._action.item());
    this._action.applyGlobal();
    this._logWindow.startAction(this._subject, this._action, this._targets);
};

BattleManager.processActionSequence = function(actionName, actionArgs) {
                // NO ACTION
                if (actionName === '') {
                        return true;
                }
    // ACTION ANIMATION
                if (actionName === 'ACTION ANIMATION') {
                        return this.actionActionAnimation(actionArgs);
                }
    // ACTION EFFECT
                if (actionName === 'ACTION COMMON EVENT') {
      return this.actionActionCommonEvent();
                }
    // ACTION EFFECT
                if (actionName === 'ACTION EFFECT') {
      return this.actionActionEffect(actionArgs);
                }
                // ANI WAIT: frames
          if (['ANI WAIT', 'ANIWAIT', 'ANIMATION WAIT'].contains(actionName)) {
            return this.actionAniWait(actionArgs[0]);
          }
    // CAST ANIMATION
                if (actionName === 'CAST ANIMATION') {
                        return this.actionCastAnimation();
                }
                // CLEAR BATTLE LOG
                if (actionName === 'CLEAR BATTLE LOG') {
                        return this.actionClearBattleLog();
                }
    // DEATH BREAK
                if (actionName === 'DEATH BREAK') {
                        return this.actionDeathBreak();
                }
                // DISPLAY ACTION
                if (actionName === 'DISPLAY ACTION') {
                        return this.actionDisplayAction();
                }
                // IF condition
                if (actionName.match(/IF[ ](.*)/i)) {
                        return this.actionIfConditions(actionName, actionArgs);
                }
    // IMMORTAL: targets, true/false
                if (actionName === 'IMMORTAL') {
                        return this.actionImmortal(actionArgs);
                }
                // MOTION WAIT
                if (actionName === 'MOTION WAIT') {
      return this.actionMotionWait(actionArgs);
                }
    // PERFORM ACTION
                if (actionName === 'PERFORM ACTION') {
                        return this.actionPerformAction();
                }
                // PERFORM FINISH
                if (actionName === 'PERFORM FINISH') {
                        return this.actionPerformFinish();
                }
                // PERFORM START
                if (actionName === 'PERFORM START') {
                        return this.actionPerformStart();
                }
                // WAIT: frames
          if (actionName === 'WAIT') {
            return this.actionWait(actionArgs[0]);
          }
    // WAIT FOR ANIMATION
                if (actionName === 'WAIT FOR ANIMATION') {
                        return this.actionWaitForAnimation();
                }
    // WAIT FOR EFFECT
                if (actionName === 'WAIT FOR EFFECT') {
                        return this.actionWaitForEffect();
                }
                // WAIT FOR MOVEMENT
                if (actionName === 'WAIT FOR MOVEMENT') {
                        return this.actionWaitForMovement();
                }
                // WAIT FOR NEW LINE
                if (actionName === 'WAIT FOR NEW LINE') {
                        return this.actionWaitForNewLine();
                }
    // WAIT FOR POPUPS
                if (actionName === 'WAIT FOR POPUPS') {
                        return this.actionWaitForPopups();
                }
                return false;
};

BattleManager.makeActionTargets = function(string) {
                var targets = []
    string = string.toUpperCase()
    if (['SUBJECT', 'USER'].contains(string)) {
      return [this._subject];
    }
    if (['TARGET', 'TARGETS'].contains(string)) {
      var group = this._targets;
      for (var i = 0; i < group.length; ++i) {
        var target = group;
        if (target) targets.push(target);
      }
      return targets;
    }
    if (['ACTORS', 'EXISTING ACTORS', 'ALIVE ACTORS'].contains(string)) {
      var group = $gameParty.aliveMembers();
      for (var i = 0; i < group.length; ++i) {
        var target = group;
        if (target) targets.push(target);
      }
      return targets;
    }
    if (['ACTORS ALL', 'ALL ACTORS', 'PARTY'].contains(string)) {
      var group = $gameParty.battleMembers();
      for (var i = 0; i < group.length; ++i) {
        var target = group;
        if (target) targets.push(target);
      }
      return targets;
    }
    if (['DEAD ACTORS', 'DEAD ACTOR'].contains(string)) {
      var group = $gameParty.deadMembers();
      for (var i = 0; i < group.length; ++i) {
        var target = group;
        if (target) targets.push(target);
      }
      return targets;
    }
    if (['ACTORS NOT USER', 'ACTORS NOT SUBJECT'].contains(string)) {
      var group = $gameParty.aliveMembers();
      for (var i = 0; i < group.length; ++i) {
        var target = group;
        if (target && target !== this._subject) targets.push(target);
      }
      return targets;
    }
    if (['ENEMIES', 'EXISTING ENEMIES', 'ALIVE ENEMIES', 'TROOP',
    'TROOPS'].contains(string)) {
      var group = $gameTroop.aliveMembers();
      for (var i = 0; i < group.length; ++i) {
        var target = group;
        if (target) targets.push(target);
      }
      return targets;
    }
    if (['ENEMIES ALL', 'ALL ENEMIES'].contains(string)) {
      var group = $gameTroop.members();
      for (var i = 0; i < group.length; ++i) {
        var target = group;
        if (target) targets.push(target);
      }
      return targets;
    }
    if (['DEAD ENEMIES', 'DEAD ENEMY'].contains(string)) {
      var group = $gameTroop.deadMembers();
      for (var i = 0; i < group.length; ++i) {
        var target = group;
        if (target) targets.push(target);
      }
      return targets;
    }
    if (['ENEMIES NOT USER', 'ENEMIES NOT SUBJECT', 'TROOP NOT USER',
    'TROOP NOT SUBJECT'].contains(string)) {
      var group = $gameTroop.aliveMembers();
      for (var i = 0; i < group.length; ++i) {
        var target = group;
        if (target && target !== this._subject) targets.push(target);
      }
      return targets;
    }
    if (string.match(/ACTOR[ ](\d+)/i)) {
      var target = $gameParty.battleMembers()[parseInt(RegExp.$1)];
      if (target) return [target];
    }
    if (string.match(/ENEMY[ ](\d+)/i)) {
      var target = $gameTroop.members()[parseInt(RegExp.$1)];
      if (target) return [target];
    }
    if (['FRIEND', 'FRIENDS', 'ALLIES'].contains(string)) {
      var group = this._action.friendsUnit().aliveMembers();
      for (var i = 0; i < group.length; ++i) {
        var target = group;
        if (target) targets.push(target);
      }
      return targets;
    }
    if (['ALL FRIENDS', 'ALL ALLIES'].contains(string)) {
      var group = this._action.friendsUnit().members();
      for (var i = 0; i < group.length; ++i) {
        var target = group;
        if (target) targets.push(target);
      }
      return targets;
    }
    if (['DEAD FRIEND', 'DEAD FRIENDS', 'DEAD ALLIES'].contains(string)) {
      var group = this._action.friendsUnit().deadMembers();
      for (var i = 0; i < group.length; ++i) {
        var target = group;
        if (target) targets.push(target);
      }
      return targets;
    }
    if (['OPPONENT', 'OPPONENTS', 'RIVALS', 'FOES'].contains(string)) {
      var group = this._action.opponentsUnit().aliveMembers();
      for (var i = 0; i < group.length; ++i) {
        var target = group;
        if (target) targets.push(target);
      }
      return targets;
    }
    if (['ALL OPPONENTS', 'ALL RIVALS', 'ALL FOES'].contains(string)) {
      var group = this._action.opponentsUnit().members();
      for (var i = 0; i < group.length; ++i) {
        var target = group;
        if (target) targets.push(target);
      }
      return targets;
    }
    if (['DEAD OPPONENT', 'DEAD OPPONENTS', 'DEAD RIVALS',
    'DEAD FOES'].contains(string)) {
      var group = this._action.opponentsUnit().deadMembers();
      for (var i = 0; i < group.length; ++i) {
        var target = group;
        if (target) targets.push(target);
      }
      return targets;
    }
    if (['FRIENDS NOT USER', 'ALLIES NOT USER'].contains(string)) {
      var group = this._action.friendsUnit().aliveMembers();
      for (var i = 0; i < group.length; ++i) {
        var target = group;
        if (target && target !== this._subject) targets.push(target);
      }
      return targets;
    }
    if (string.match(/(?:FRIEND|ALLY)[ ](\d+)/i)) {
      var target = this._action.friendsUnit().members()[parseInt(RegExp.$1)];
      if (target) return [target];
    }
    if (string.match(/(?:OPPONENT|FOE|RIVAL)[ ](\d+)/i)) {
      var target = this._action.opponentsUnit().members()[parseInt(RegExp.$1)]
      if (target) return [target];
    }
    if (['ALL ALIVE'].contains(string)) {
      var group = this._action.friendsUnit().aliveMembers();
      group = group.concat(this._action.opponentsUnit().aliveMembers());
      for (var i = 0; i < group.length; ++i) {
        var target = group;
        if (target) targets.push(target);
      }
      return targets;
    }
    if (['ALL MEMBERS'].contains(string)) {
      var group = this._action.friendsUnit().members();
      group = group.concat(this._action.opponentsUnit().members());
      for (var i = 0; i < group.length; ++i) {
        var target = group;
        if (target) targets.push(target);
      }
      return targets;
    }
    if (['ALL DEAD'].contains(string)) {
      var group = this._action.friendsUnit().deadMembers();
      group = group.concat(this._action.opponentsUnit().deadMembers());
      for (var i = 0; i < group.length; ++i) {
        var target = group;
        if (target) targets.push(target);
      }
      return targets;
    }
    if (['ALL NOT USER'].contains(string)) {
      var group = this._action.friendsUnit().aliveMembers();
      group = group.concat(this._action.opponentsUnit().aliveMembers());
      for (var i = 0; i < group.length; ++i) {
        var target = group;
        if (target && target !== this._subject) targets.push(target);
      }
      return targets;
    }
    if (['FOCUS', 'PARTICIPANTS'].contains(string)) {
      var group = this._targets;
      for (var i = 0; i < group.length; ++i) {
        var target = group;
        if (target) targets.push(target);
      }
      if (!targets.contains(this._subject)) targets.push(this._subject);
      return targets;
    }
    if (['NOT FOCUS', 'NONPARTICIPANTS'].contains(string)) {
      var group = this._action.friendsUnit().aliveMembers();
      group = group.concat(this._action.opponentsUnit().aliveMembers());
      for (var i = 0; i < group.length; ++i) {
        var target = group;
        if (target) {
          if (target === this._subject) continue;
          if (this._targets.contains(target)) continue;
          targets.push(target);
        }
      }
      return targets;
    }
    if (string.match(/(?:CHAR|CHARA|CHARACTER)[ ](\d+)/i)) {
      var actorId = parseInt(RegExp.$1);
      var actor = $gameActors.actor(actorId);
      if (actor && $gameParty.battleMembers().contains(actor)) {
        return [actor];
      }
    }
                return targets;
};

BattleManager.actionConditionsMet = function(actSeq) {
    var ci = this._conditionFlags.length - 1;
    var actionName = actSeq[0];
    var actionArgs = actSeq[1];
    var subject = this._subject;
    var user = this._subject;
    var target = this._targets[0];
                var targets = this._targets;
    var action = this._action;
    var item = this._action.item();
    if (actionName.match(/ELSE[ ]*(.*)/i)) {
      if (this._conditionFlags.length <= 0) return false;
      if (this._conditionFlags[ci]) {
        this._conditionFlags[ci] = false;
        this._trueFlags[ci] = true;
      } else if (!this._conditionFlags[ci] && !this._trueFlags[ci]) {
        this._conditionFlags[ci] = true;
        this._trueFlags[ci] = true;
      }
      return false;
    } else if (actionName.match(/ELSE[ ]IF[ ](.*)/i)) {
      if (this._conditionFlags.length <= 0) return false;
      if (this._conditionFlags[ci]) {
        this._conditionFlags[ci] = false;
        this._trueFlags[ci] = true;
      } else if (!this._conditionFlags[ci] && !this._trueFlags[ci]) {
        var text = String(RegExp.$1);
        this._conditionFlags[ci] = eval('(' + text + ')');
        this._trueFlags[ci] = eval('(' + text + ')');
      }
      return false;
    } else if (actionName.toUpperCase() === 'END') {
      if (this._conditionFlags.length <= 0) return false;
      this._conditionFlags.pop();
      this._trueFlags.pop();
      return false;
    }
    if (this._conditionFlags.length > 0) return this._conditionFlags[ci];
    return true
};

BattleManager.actionActionAnimation = function(actionArgs) {
    if (actionArgs && actionArgs[0]) {
      var targets = this.makeActionTargets(actionArgs[0]);
    } else {
      var targets = this._targets;
    }
    var mirror = false;
    if (actionArgs && actionArgs[1]) {
      if (actionArgs[1].toUpperCase() === 'MIRROR') mirror = true;
    }
    var subject = this._subject;
    var group = targets.filter(Yanfly.Util.onlyUnique);
    var aniId = this._action.item().animationId;
    if (aniId < 0) {
      if (mirror) {
        this._logWindow.showActorAtkAniMirror(subject, group);
      } else {
        this._logWindow.showAttackAnimation(subject, group);
      }
    } else {
      this._logWindow.showNormalAnimation(group, aniId, mirror);
    }
    return true;
};

BattleManager.actionActionCommonEvent = function() {
    this._action.item().effects.forEach(function(effect) {
        if (effect.code === Game_Action.EFFECT_COMMON_EVENT) {
            $gameTemp.reserveCommonEvent(effect.dataId);
        }
    }, this);
    return false;
};

BattleManager.actionActionEffect = function(actionArgs) {
    if (actionArgs && actionArgs[0]) {
      var targets = this.makeActionTargets(actionArgs[0]);
    } else {
      var targets = this._targets;
    }
    targets.forEach(function(target) {
      if (target !== undefined) {
        var alreadyDead = target.isDead();
        this.invokeAction(this._subject, target);
        if (target.isDead() && !alreadyDead) {
            target.performCollapse();
        }
      }
    }, this);
    return true;
};

BattleManager.actionAniWait = function(frames) {
    frames *= Yanfly.Param.AnimationRate || 4;
    this._logWindow._waitCount = parseInt(frames);
    return false;
};

BattleManager.actionCastAnimation = function() {
  if (!$gameSystem.isSideView() && this._subject.isActor()) return true;
        if (!this._action.isAttack() && !this._action.isGuard() &&
        this._action.isSkill()) {
    if (this._action.item().castAnimation > 0) {
      var ani = $dataAnimations[this._action.item().castAnimation]
                        this._logWindow.showAnimation(this._subject, [this._subject],
        this._action.item().castAnimation);
    }
  }
  return true;
};


BattleManager.actionClearBattleLog = function() {
    this._logWindow.clear();
    return false;
};

BattleManager.actionDeathBreak = function() {
    if (this._subject.isDead() || this._subject.hp <= 0) {
      this._targets = [];
      this._actionList = [];
      this._individualTargets = [];
      this._phase = 'phaseChange';
      return false;
    }
    return true;
};

BattleManager.actionDisplayAction = function() {
    this._logWindow.displayAction(this._subject, this._action.item());
    return false;
};

BattleManager.actionIfConditions = function(actionName, actionArgs) {
  var subject = this._subject;
  var user = this._subject;
  var target = this._targets[0];
        var targets = this._targets;
  var action = this._action;
  var item = this._action.item();
  var actionName = this._actSeq[0];
  if (actionName.match(/IF[ ](.*)/i)) {
    var text = String(RegExp.$1);
    this._conditionFlags.push(eval(text));
    this._trueFlags.push(false);
    var ci = this._conditionFlags.length;
  }
  return true;
};

BattleManager.actionImmortal = function(actionArgs) {
                var targets =
                        this.makeActionTargets(actionArgs[0]).filter(Yanfly.Util.onlyUnique);
                var value = eval(String(actionArgs[1]).toLowerCase());
                targets.forEach(function (target) {
                        if (value) {
                                target.addImmortal();
                        } else {
        var alreadyDead = target.isDead();
        target.removeImmortal();
                        }
                }, this);
    return true;
};

BattleManager.actionMotionWait = function(actionArgs) {
    var targets = this.makeActionTargets(actionArgs[0]);
                if (targets[0].isActor() && targets[0].isSpriteVisible()) {
                        this._logWindow._waitCount += 12;
                        return false;
                }
    return true;
};

BattleManager.actionPerformAction = function() {
    this._logWindow.performAction(this._subject, this._action);
                if (this._subject.isActor() && this._subject.isSpriteVisible) {
                        this._logWindow._waitCount += 20;
                        return false;
                }
    return true;
};

BattleManager.actionPerformFinish = function() {
    this._logWindow.performActionEnd(this._subject);
    $gameParty.aliveMembers().forEach(function(member) {
      member.spriteReturnHome();
    });
    $gameTroop.aliveMembers().forEach(function(member) {
      member.spriteReturnHome();
    });
    return true;
};

BattleManager.actionPerformStart = function() {
    this._logWindow.performActionStart(this._subject, this._action);
    return true;
};

BattleManager.actionWait = function(frames) {
    this._logWindow._waitCount = parseInt(frames);
    return false;
};

BattleManager.actionWaitForAnimation = function() {
    this._logWindow.waitForAnimation();
    return false;
};

BattleManager.actionWaitForEffect = function() {
    this._logWindow.waitForEffect();
    return false;
};

BattleManager.actionWaitForMovement = function() {
    this._logWindow.waitForMovement();
    return false;
};

BattleManager.actionWaitForNewLine = function() {
    this._logWindow.waitForNewLine();
    return false;
};

BattleManager.actionWaitForPopups = function() {
    this._logWindow.waitForPopups();
    return false;
};

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

Yanfly.BEC.Sprite_Battler_initMembers = Sprite_Battler.prototype.initMembers;
Sprite_Battler.prototype.initMembers = function() {
    Yanfly.BEC.Sprite_Battler_initMembers.call(this);
                this.adjustAnchor();
                this.setZ();
};

Sprite_Battler.prototype.adjustAnchor = function() {
    this.anchor.x = 0.5;
    this.anchor.y = 1.0;
};

Sprite_Battler.prototype.setZ = function() {
    this.z = 1;
};

Sprite_Battler.prototype.setupDamagePopup = function() {
    if (this._battler.isDamagePopupRequested()) {
        if (this._battler.isSpriteVisible()) {
            var sprite = new Sprite_Damage();
            sprite.x = this.x + this.damageOffsetX();
            sprite.y = this.y + this.damageOffsetY();
            sprite.setup(this._battler);
            this.pushDamageSprite(sprite);
                                                BattleManager._spriteset.addChild(sprite);
        }
    } else {
      this._battler.clearDamagePopup();
      this._battler.clearResult();
    }
};

Sprite_Battler.prototype.pushDamageSprite = function(sprite) {
    var heightBuffer = eval(Yanfly.Param.BECPopupOverlap);
                if (eval(Yanfly.Param.BECNewPopBottom)) {
                        this._damages.push(sprite);
      this._damages.forEach(function(spr) {
        for (var i = 0; i < spr.children.length; i++) {
                                        childSprite = spr.children;
                                        childSprite.anchor.y += heightBuffer;
                                }
                        }, this);
                } else {
                        this._damages.push(sprite);
                        heightBuffer *= this._damages.length
                        for (var i = 0; i < sprite.children.length; i++) {
                                childSprite = sprite.children;
                                childSprite.anchor.y += heightBuffer;
                        }
                }
};

Yanfly.BEC.Sprite_Battler_setBattler = Sprite_Battler.prototype.setBattler;
Sprite_Battler.prototype.setBattler = function(battler) {
    Yanfly.BEC.Sprite_Battler_setBattler.call(this, battler);
    if (battler) battler.setBattler(this);
};

Yanfly.BEC.Sprite_Battler_startMove = Sprite_Battler.prototype.startMove;
Sprite_Battler.prototype.startMove = function(x, y, duration) {
    if (this._battler && !this._battler.spriteCanMove()) return;
                Yanfly.BEC.Sprite_Battler_startMove.call(this, x, y, duration);
};

Sprite_Battler.prototype.stepForward = function() {
    this.startMove(Yanfly.Param.BECStepDist, 0, 12);
};

Sprite_Battler.prototype.stepBack = function() {
    this.startMove(0, 0, 12);
};

Sprite_Battler.prototype.stepFlinch = function() {
    var flinchX = this.x - this._homeX - Yanfly.Param.BECFlinchDist;
                this.startMove(flinchX, 0, 6);
};

Sprite_Battler.prototype.stepSubBack = function() {
                var backX = -1 * this.width / 2;
                this.startMove(backX, 0, 6);
};

Sprite_Battler.prototype.stepToSubstitute = function(focus) {
    var target = focus.battler();
                var targetX = (this.x - this._homeX) + (target._homeX - this._homeX);
                var targetY = (this.y - this._homeY) + (target._homeY - this._homeY);;
                if (focus.isActor()) targetX -= this._mainSprite.width / 2;
                if (focus.isEnemy()) targetX += this.width / 2;
                this.startMove(targetX, targetY, 1);
};

Sprite_Battler.prototype.startMotion = function(motionType) {
};

Sprite_Battler.prototype.forceMotion = function(motionType) {
};

Sprite_Battler.prototype.refreshMotion = function() {
};

Sprite_Battler.prototype.startActionMotion = function() {
};

Sprite_Battler.prototype.moveForward = function(distance, frames) {
    if (this._battler.isActor()) distance *= -1;
    var moveX = this.x - this._homeX + distance;
    var moveY = this.y - this._homeY;
    this.startMove(moveX, moveY, frames);
};

Sprite_Battler.prototype.moveToPoint = function(pointX, pointY, frames) {
                var targetX = pointX - this._homeX;
    var targetY = pointY - this._homeY;
    this.startMove(targetX, targetY, frames);
};

Sprite_Battler.prototype.setMirror = function(value) {
    if (this.scale.x > 0 && value) this.scale.x *= -1;
    if (this.scale.x < 0 && !value) this.scale.x *= -1;
};

Sprite_Battler.prototype.isPopupPlaying = function() {
    if (this._damages.length > 0) {
      for (var i = 0; i < this._damages.length; ++i) {
        return this._damages.isPlaying();
      }
    }
    return false;
};

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

Sprite_Actor.prototype.initialize = function(battler) {
    Sprite_Battler.prototype.initialize.call(this, battler);
};

Yanfly.BEC.Sprite_Actor_updateShadow = Sprite_Actor.prototype.updateShadow;
Sprite_Actor.prototype.updateShadow = function() {
    if (this._hideShadows === undefined) {
      this._hideShadows = eval(Yanfly.Param.BECShowShadows);
    }
    if (!this._hideShadows) return this._shadowSprite.visible = false;
    Yanfly.BEC.Sprite_Actor_updateShadow.call(this);
};

Sprite_Actor.prototype.setActorHome = function(index) {
    if ($gameSystem.isSideView()) {
      var homeX = eval(Yanfly.Param.BECHomePosX);
                  var homeY = eval(Yanfly.Param.BECHomePosY);
    } else {
      var homeX = eval(Yanfly.Param.BECFrontPosX);
                  var homeY = eval(Yanfly.Param.BECFrontPosY);
    }
    this._checkAliveStatus = false;
    if ($gameParty.battleMembers()[index]) {
      var actor = $gameParty.battleMembers()[index];
      if (actor.isAlive()) this._checkAliveStatus = true;
    }
                this.setHome(homeX, homeY);
    this.moveToStartPosition();
};

Sprite_Actor.prototype.moveToStartPosition = function() {
    if ($gameSystem.isSideView() && this._checkAliveStatus) {
      this.startMove(300, 0, 0);
    }
};

Sprite_Actor.prototype.setupMotion = function() {
};

Sprite_Actor.prototype.forceMotion = function(motionType) {
    var newMotion = Sprite_Actor.MOTIONS[motionType];
    this._motion = newMotion;
    this._motionCount = 0;
    this._pattern = 0;
};

Sprite_Actor.prototype.updateTargetPosition = function() {
};

Sprite_Actor.prototype.updateMotion = function() {
    this.updateMotionCount();
};

Sprite_Actor.prototype.onMoveEnd = function() {
    Sprite_Battler.prototype.onMoveEnd.call(this);
};

Sprite_Actor.prototype.stepForward = function() {
    this.startMove(-Yanfly.Param.BECStepDist, 0, 12);
};

Sprite_Actor.prototype.stepFlinch = function() {
                var flinchX = this.x - this._homeX + Yanfly.Param.BECFlinchDist;
                this.startMove(flinchX, 0, 6);
};

Sprite_Actor.prototype.stepSubBack = function() {
    var backX = this._mainSprite.width / 2;
                this.startMove(backX, 0, 6);
};

Yanfly.BEC.Sprite_Actor_updateBitmap = Sprite_Actor.prototype.updateBitmap;
Sprite_Actor.prototype.updateBitmap = function() {
    var name = this._actor.battlerName();
    var needUpdate = false;
    if (this._battlerName !== name) needUpdate = true;
    Yanfly.BEC.Sprite_Actor_updateBitmap.call(this);
    if (needUpdate) this.adjustAnchor();
};

Sprite_Actor.prototype.adjustAnchor = function() {
    if (!this._mainSprite) return;
                this._mainSprite.anchor.x = this._actor.anchorX();
    this._mainSprite.anchor.y = this._actor.anchorY();
};

//=============================================================================
// Sprite_Weapon
//=============================================================================

Yanfly.BEC.Sprite_Weapon_setup = Sprite_Weapon.prototype.setup;
Sprite_Weapon.prototype.setup = function(weaponImageId) {
    Yanfly.BEC.Sprite_Weapon_setup.call(this, weaponImageId);
    this._animationCount -= 1; // Synch with sprite
};

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

Yanfly.BEC.Sprite_Damage_initialize = Sprite_Damage.prototype.initialize;
Sprite_Damage.prototype.initialize = function() {
    Yanfly.BEC.Sprite_Damage_initialize.call(this);
    this._duration = eval(Yanfly.Param.BECPopupDur);
};

Sprite_Damage.prototype.setup = function(target) {
    var result = target.shiftDamagePopup();
    if (result.missed || result.evaded) {
      this.createMiss();
    } else if (result.hpAffected) {
      this.createDigits(0, result.hpDamage);
    } else if (target.isAlive() && result.mpDamage !== 0) {
      this.createDigits(2, result.mpDamage);
    }
    if (result.critical) {
      this.setupCriticalEffect();
    }
};

Sprite_Damage.prototype.setupCriticalEffect = function() {
    this._flashColor = eval('[' + Yanfly.Param.BECCritPopup + ']');
    this._flashDuration = eval(Yanfly.Param.BECCritDur);
};

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

Spriteset_Battle.prototype.isBusy = function() {
    return false;
};

Yanfly.BEC.Spriteset_Battle_update = Spriteset_Battle.prototype.update;
Spriteset_Battle.prototype.update = function() {
    Yanfly.BEC.Spriteset_Battle_update.call(this);
    this.updateZCoordinates();
};

Spriteset_Battle.prototype.updateZCoordinates = function() {
    this._battleField.children.sort(this.battleFieldDepthCompare);
};

Spriteset_Battle.prototype.battleFieldDepthCompare = function(a, b) {
    var priority = BattleManager.getSpritePriority();
    if (a._battler && b._battler && priority !== 0) {
      if (priority === 1) {
        if (a._battler.isActor() && b._battler.isEnemy()) return 1;
        if (a._battler.isEnemy() && b._battler.isActor()) return -1;
      } else if (priority === 2) {
        if (a._battler.isActor() && b._battler.isEnemy()) return -1;
        if (a._battler.isEnemy() && b._battler.isActor()) return 1;
      }
    }
    if (a.z < b.z) return -1;
    if (a.z > b.z) return 1;
    if (a.y < b.y) return -1;
    if (a.y > b.y) return 1;
    return 0;
};

Spriteset_Battle.prototype.isPopupPlaying = function() {
    return this.battlerSprites().some(function(sprite) {
        return sprite.isPopupPlaying();
    });
};

//=============================================================================
// Game_Temp
//=============================================================================

Game_Temp.prototype.clearActionSequenceSettings = function() {
};

//=============================================================================
// Game_System
//=============================================================================

Yanfly.BEC.Game_System_initialize = Game_System.prototype.initialize;
Game_System.prototype.initialize = function() {
    Yanfly.BEC.Game_System_initialize.call(this);
    this.initBattleSystem();
};

Game_System.prototype.initBattleSystem = function() {
    this._battleSystem = Yanfly.Param.BECSystem.toLowerCase();
};

Game_System.prototype.getBattleSystem = function() {
    if (this._battleSystem === undefined) this.initBattleSystem();
    return this._battleSystem;
};

Game_System.prototype.setBattleSystem = function(type) {
    this._battleSystem = type.toLowerCase();
};

//=============================================================================
// Game_Interpreter
//=============================================================================

Yanfly.BEC.Game_Interpreter_pluginCommand =
    Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
    Yanfly.BEC.Game_Interpreter_pluginCommand.call(this, command, args);
    if (command === 'setBattleSys' && !$gameParty.inBattle()) {
      this.setBattleSystem(args[0]);
    }
};

Game_Interpreter.prototype.setBattleSystem = function(value) {
    $gameSystem.setBattleSystem(value);
};

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

Game_Action.prototype.speed = function() {
    var user = this.subject(); var a = user;
    var maxhp = user.mhp; var mhp = user.mhp; var hp = user.hp;
    var maxmp = user.mmp; var mmp = user.mmp; var mp = user.mp;
    var maxtp = user.maxTp(); var mtp = user.maxTp(); var tp = user.tp;
    var atk = user.atk; var def = user.def; var mat = user.mat;
    var int = user.mat; var mdf = user.mdf; var res = user.res;
    var agi = user.agi; var luk = user.luk;
    var speed = eval(Yanfly.Param.BECActionSpeed);
    if (this.item()) speed += this.item().speed;
    if (this.isAttack()) speed += this.subject().attackSpeed();
    return speed;
};

Yanfly.BEC.Game_Action_apply = Game_Action.prototype.apply;
Game_Action.prototype.apply = function(target) {
    target._result = null;
    target._result = new Game_ActionResult();
    this.subject()._result = null;
    this.subject()._result = new Game_ActionResult();
    Yanfly.BEC.Game_Action_apply.call(this, target);
    if ($gameParty.inBattle()) {
      target.startDamagePopup();
      target.performResultEffects();
      if (target !== this.subject()) this.subject().startDamagePopup();
    }
};

Game_Action.prototype.itemEffectAddNormalState = function(target, effect) {
    var stateId = effect.dataId;
    var chance = effect.value1;
    if (!this.isCertainHit()) {
      chance *= target.stateRate(stateId);
      chance *= this.lukEffectRate(target);
    }
    if (Math.random() < chance) {
      if (stateId === target.deathStateId()) {
        if (target.isImmortal()) target.removeImmortal();
      }
      target.addState(stateId);
      this.makeSuccess(target);
    }
};

Yanfly.BEC.Game_Action_applyGlobal = Game_Action.prototype.applyGlobal;
Game_Action.prototype.applyGlobal = function() {
    if ($gameParty.inBattle()) return;
    Yanfly.BEC.Game_Action_applyGlobal.call(this);
};

Yanfly.BEC.Game_Action_needsSelection = Game_Action.prototype.needsSelection;
Game_Action.prototype.needsSelection = function() {
    if ($gameParty.inBattle() && this.item().scope === 0) return false;
    if ($gameParty.inBattle() && BattleManager.isForceSelection()) return true;
    return Yanfly.BEC.Game_Action_needsSelection.call(this);
};

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

Game_BattlerBase.prototype.requestStatusRefresh = function() {
    this._statusRefreshRequested = true;
};

Game_BattlerBase.prototype.isStatusRefreshRequested = function() {
    return this._statusRefreshRequested;
};

Game_BattlerBase.prototype.completetStatusRefreshRequest = function() {
    this._statusRefreshRequested = false;
};

Game_BattlerBase.prototype.updateStateTicks = function() {
    for (var i = 0; i < this._states.length; ++i) {
      var stateId = this._states;
      var state = $dataStates[stateId];
      if (!state) continue;
      if (state.autoRemovalTiming === 0) continue;
      if (!this._stateTurns[stateId]) continue;
      var value = BattleManager.tickRate() / Yanfly.Param.BECTurnTime;
      this._stateTurns[stateId] -= value;
      if (this._stateTurns[stateId] <= 0) this.removeState(stateId);
    }
};

Game_BattlerBase.prototype.updateBuffTicks = function() {
    for (var i = 0; i < this._buffTurns.length; i++) {
      if (this._buffTurns <= 0) continue;
      var value = BattleManager.tickRate() / Yanfly.Param.BECTurnTime;
      this._buffTurns -= value;
      if (this._buffTurns <= 0) this.removeBuff(i);
    }
};

Game_BattlerBase.prototype.timedTick = function() {
    return 1 * BattleManager.tickRate();
};

Yanfly.BEC.Game_BattlerBase_isStateResist =
    Game_BattlerBase.prototype.isStateResist;
Game_BattlerBase.prototype.isStateResist = function(stateId) {
    if (stateId === this.deathStateId() && this.isImmortal()) return true;
    return Yanfly.BEC.Game_BattlerBase_isStateResist.call(this, stateId);
};

Game_BattlerBase.prototype.isImmortal = function() {
    return this._immortalState;
};

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

Yanfly.BEC.Game_Battler_onBattleStart = Game_Battler.prototype.onBattleStart;
Game_Battler.prototype.onBattleStart = function() {
    Yanfly.BEC.Game_Battler_onBattleStart.call(this);
    this._immortalState = false;
};

Yanfly.BEC.Game_Battler_onBattleEnd = Game_Battler.prototype.onBattleEnd;
Game_Battler.prototype.onBattleEnd = function() {
    Yanfly.BEC.Game_Battler_onBattleEnd.call(this);
    this._immortalState = false;
};

Yanfly.BEC.Game_Battler_isSelected = Game_Battler.prototype.isSelected;
Game_Battler.prototype.isSelected = function() {
    if ($gameParty.inBattle() && BattleManager.isAllSelection()) {
      if (!this.isAppeared()) return false;
      var action = BattleManager.inputtingAction();
      if (action && action.item()) {
        if (this.isDead() && this.isEnemy()) return false;
        if (this.isDead() && this.isActor()) return action.isForDeadFriend();
        if (action.isForFriend() && this.isActor()) return true;
        if (action.isForOpponent() && this.isEnemy()) return true;
      }
    }
    return Yanfly.BEC.Game_Battler_isSelected.call(this);
};

Yanfly.BEC.Game_Battler_regenerateAll = Game_Battler.prototype.regenerateAll;
Game_Battler.prototype.regenerateAll = function() {
    var lifeState = this.isAlive();
    Yanfly.BEC.Game_Battler_regenerateAll.call(this);
    if (this.isDead() && lifeState === true) {
      this.performCollapse();
    }
    if ($gameParty.inBattle()) this.startDamagePopup();
};

Game_Battler.prototype.addImmortal = function() {
    this._immortalState = true;
};

Game_Battler.prototype.removeImmortal = function() {
    var alreadyDead = this.isDead();
    this._immortalState = false;
    this.refresh();
    if (this.isDead() && !alreadyDead) this.performCollapse();
};

Game_Battler.prototype.clearDamagePopup = function() {
    this._damagePopup = [];
};

Game_Battler.prototype.isDamagePopupRequested = function() {
    if (!this._damagePopup) this.clearDamagePopup();
    return this._damagePopup.length > 0;
};

Game_Battler.prototype.startDamagePopup = function() {
    var result = this.result();
    if (result.missed || result.evaded) {
      var copyResult = JsonEx.makeDeepCopy(result);
      copyResult.hpAffected = false;
      copyResult.mpDamage = 0;
      this._damagePopup.push(copyResult);
    }
    if (result.hpAffected) {
      var copyResult = JsonEx.makeDeepCopy(result);
      copyResult.mpDamage = 0;
      this._damagePopup.push(copyResult);
    }
    if (result.mpDamage !== 0) {
      var copyResult = JsonEx.makeDeepCopy(result);
      copyResult.hpAffected = false;
      this._damagePopup.push(copyResult);
    }
};

Game_Battler.prototype.shiftDamagePopup = function() {
    if (!this._damagePopup) this.clearDamagePopup();
    return this._damagePopup.shift();
};

Yanfly.BEC.Game_Battler_performCollapse =
    Game_Battler.prototype.performCollapse;
Game_Battler.prototype.performCollapse = function() {
    Yanfly.BEC.Game_Battler_performCollapse.call(this);
    if ($gameParty.inBattle()) this.forceMotion('dead');
};

Game_Battler.prototype.performResultEffects = function() {
    var result = this.result();
    if (result.missed && result.physical) this.performMiss();
    if (result.evaded) {
      if (result.physical) {
        this.performEvasion();
      } else {
        this.performMagicEvasion();
      }
    }
    if (result.hpAffected) {
      if (result.hpDamage > 0 && !result.drain) {
        this.performDamage();
      }
      if (result.hpDamage < 0) {
        this.performRecovery();
      }
    }
    if (this.isAlive() && result.mpDamage !== 0 && result.mpDamage < 0) {
      this.performRecovery();
    }
    if (this.isAlive() && result.tpDamage !== 0 && result.tpDamage < 0) {
      this.performRecovery();
    }
};

Yanfly.BEC.Game_Battler_performDamage =
        Game_Battler.prototype.performDamage;
Game_Battler.prototype.performDamage = function() {
                Yanfly.BEC.Game_Battler_performDamage.call(this);
                this.performFlinch();
};

Yanfly.BEC.Game_Battler_performMiss = Game_Battler.prototype.performMiss;
Game_Battler.prototype.performMiss = function() {
    Yanfly.BEC.Game_Battler_performMiss.call(this);
                this.performFlinch();
};

Yanfly.BEC.Game_Battler_performEvasion =
                Game_Battler.prototype.performEvasion;
Game_Battler.prototype.performEvasion = function() {
    Yanfly.BEC.Game_Battler_performEvasion.call(this);
                this.performFlinch();
};

Yanfly.BEC.Game_Battler_performMagicEvasion =
                Game_Battler.prototype.performMagicEvasion;
Game_Battler.prototype.performMagicEvasion = function() {
    Yanfly.BEC.Game_Battler_performMagicEvasion.call(this);
                this.performFlinch();
};

Game_Battler.prototype.performFlinch = function() {
                if (this._flinched || !$gameSystem.isSideView()) return;
                this._flinched = true;
                this.spriteStepFlinch();
};

Yanfly.BEC.Game_Battler_performReflection =
                Game_Battler.prototype.performReflection;
Game_Battler.prototype.performReflection = function() {
    Yanfly.BEC.Game_Battler_performReflection.call(this);
                if (!$gameSystem.isSideView() && this.isActor()) return;
                var animationId = this.reflectAnimationId();
                var mirror = this.isActor();
                this.startAnimation(animationId, mirror, 0);
};

Yanfly.BEC.Game_Battler_performSubstitute =
                Game_Battler.prototype.performSubstitute;
Game_Battler.prototype.performSubstitute = function(target) {
                Yanfly.BEC.Game_Battler_performSubstitute.call(this, target);
                if (!$gameSystem.isSideView()) return;
                this._flinched = true;
                if (BattleManager._action.isForAll()) {
                        this.spriteStepForward();
                        target.spriteStepSubBack();
                } else {
                        this.spriteStepToSubstitute(target);
                        target.spriteStepSubBack();
                }
};

Game_Battler.prototype.setBattler = function(sprite) {
    BattleManager.registerSprite(this, sprite);
};

Game_Battler.prototype.battler = function() {
    return BattleManager.getSprite(this);
};

Game_Battler.prototype.requestMotion = function(motionType) {
    this._motionType = motionType;
    if (this.battler()) {
      this.battler().startMotion(motionType);
    }
};

Game_Battler.prototype.forceMotion = function(motionType) {
    this._motionType = motionType;
    if (this.battler()) {
      this.battler().forceMotion(motionType);
    }
};

Game_Battler.prototype.startWeaponAnimation = function(weaponImageId) {
    this._weaponImageId = weaponImageId;
    if (this.battler()) {
      this.battler().setupWeaponAnimation();
    }
};

Game_Battler.prototype.performActionStart = function(action) {
    if (!action.isGuard()) {
        this.setActionState('acting');
        this.spriteStepForward();
    }
};

Yanfly.BEC.Game_Battler_performActionEnd =
    Game_Battler.prototype.performActionEnd;
Game_Battler.prototype.performActionEnd = function() {
    Yanfly.BEC.Game_Battler_performActionEnd.call(this);
    this.spriteReturnHome();
};

Game_Battler.prototype.spriteStepForward = function() {
    if ($gameSystem.isSideView() && this.battler()) {
      this.battler().stepForward();
    }
};

Game_Battler.prototype.spriteStepBack = function() {
    if ($gameSystem.isSideView() && this.battler()) {
      this.battler().stepBack();
    }
};

Game_Battler.prototype.spriteStepSubBack = function() {
    if ($gameSystem.isSideView() && this.battler()) {
                        this.battler().stepSubBack();
    }
};

Game_Battler.prototype.spriteStepToSubstitute = function(target) {
    if ($gameSystem.isSideView() && this.battler()) {
      this.battler().stepToSubstitute(target);
    }
};

Game_Battler.prototype.spriteStepFlinch = function() {
    if ($gameSystem.isSideView() && this.battler()) {
      this.battler().stepFlinch();
    }
};

Game_Battler.prototype.spriteReturnHome = function() {
    if ($gameSystem.isSideView() && this.battler()) {
      this._flinched = false;
                        this.spriteFaceForward();
                        this.battler().stepBack();
      if (this.numActions() <= 0) {
        this.setActionState('undecided');
      }
      this.battler().refreshMotion();
    }
};

Game_Battler.prototype.reflectAnimationId = function() {
                for (var i = 0; i < this.states().length; ++i) {
                        var state = this.states();
                        if (state.reflectAnimationId > 0) return state.reflectAnimationId;
                }
                return Yanfly.Param.BECReflectAni;
};

Game_Battler.prototype.spriteCanMove = function() {
    if (!$gameSystem.isSideView()) return false;
                for (var i = 0; i < this.states().length; ++i) {
                        var state = this.states();
                        if (state.spriteCannotMove) return false;
                }
                return this.canMove();
};

Game_Battler.prototype.spritePosX = function() {
    if ($gameSystem.isSideView() && this.battler()) {
                        return this.battler().x;
                } else if (this.battler()) {
                        return this.battler().x;
                } else {
                        return 0;
                }
};

Game_Battler.prototype.spritePosY = function() {
    if ($gameSystem.isSideView() && this.battler()) {
                        return this.battler().y;
                } else if (this.battler()) {
                        return this.battler().y;
                } else {
                        return 0;
                }
};

Game_Battler.prototype.spriteWidth = function() {
    if ($gameSystem.isSideView() && this.battler()) {
                        return this.battler().width;
                } else if (this.battler()) {
                        return this.battler().width;
                } else {
                        return 1;
                }
};

Game_Battler.prototype.spriteHeight = function() {
    if ($gameSystem.isSideView() && this.battler()) {
                        return this.battler().height;
                } else if (this.battler()) {
                        return this.battler().height;
                } else {
                        return 1;
                }
};

Game_Battler.prototype.anchorX = function() {
    return Yanfly.Param.BECAnchorX;
};

Game_Battler.prototype.anchorY = function() {
    return Yanfly.Param.BECAnchorY;
};

Game_Battler.prototype.spriteHomeX = function() {
                if ($gameSystem.isSideView() && this.battler()) {
                        return this.battler()._homeX;
                } else {
                        return 0;
                }
};

Game_Battler.prototype.spriteHomeY = function() {
                if ($gameSystem.isSideView() && this.battler()) {
                        return this.battler()._homeY;
                } else {
                        return 0;
                }
};

Game_Battler.prototype.setMirror = function(value) {
    if ($gameSystem.isSideView() && this.battler() && this.spriteCanMove()) {
      this.battler().setMirror(value);
    }
};

Game_Battler.prototype.spriteFaceForward = function() {
    this.setMirror(false);
};

Game_Battler.prototype.spriteFaceBackward = function() {
    this.setMirror(true);
};

Game_Battler.prototype.spriteFacePoint = function(pointX, pointY) {
    if (this.spritePosX() > pointX) {
      this.spriteFaceBackward();
    } else {
      this.spriteFaceForward();
    }
};

Game_Battler.prototype.spriteFaceAwayPoint = function(pointX, pointY) {
    if (this.spritePosX() > pointX) {
      this.spriteFaceForward();
    } else {
      this.spriteFaceBackward();
    }
};

Game_Battler.prototype.spriteFaceTarget = function(target) {
    if (!target) return;
    var pointX = target.spritePosX();
    var pointY = target.spritePosY();
    this.spriteFacePoint(pointX, pointY);
};

Game_Battler.prototype.spriteFaceAwayTarget = function(target) {
    if (!target) return;
    var pointX = target.spritePosX();
    var pointY = target.spritePosY();
    this.spriteFaceAwayPoint(pointX, pointY);
};

Game_Battler.prototype.spriteFaceHome = function() {
    var pointX = this.spriteHomeX();
    var pointY = this.spriteHomeY();
    this.spriteFacePoint(pointX, pointY);
};

Game_Battler.prototype.spriteFaceAwayHome = function() {
    var pointX = target.spriteHomeX();
    var pointY = target.spriteHomeY();
    this.spriteFaceAwayPoint(pointX, pointY);
};

Game_Battler.prototype.attackMotion = function() {
    return 'thrust';
};

Game_Battler.prototype.performAttack = function() {
};

Game_Battler.prototype.requestMotionRefresh = function() {
    if (this.isDead() && this._motionType !== 'dead') {
      this.requestMotion('dead');
    }
    if (this.isDead() && this._motionType === 'dead') return;
    if (this._motionType === 'victory') return;
    if (this._motionType === 'escape' && !BattleManager.isInputting()) return;
    if (this._motionType === 'guard' && !BattleManager.isInputting()) return;
    this.clearMotion();
    if (this.battler() && BattleManager.isInputting()) {
      this.battler().refreshMotion();
    }
};

Game_Battler.prototype.onTurnStart = function() {
};

Game_Battler.prototype.onTurnEnd = function() {
    this.clearResult();
    this.regenerateAll();
    if (!BattleManager.timeBasedStates()) this.updateStateTurns();
    if (!BattleManager.timeBasedBuffs()) this.updateBuffTurns();
    this.removeStatesAuto(2);
};

Game_Battler.prototype.updateTick = function() {
    if (BattleManager.timeBasedStates()) this.updateStateTicks();
    if (BattleManager.timeBasedBuffs()) this.updateBuffTicks();
};

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

Yanfly.BEC.Game_Actor_refresh = Game_Actor.prototype.refresh;
Game_Actor.prototype.refresh = function() {
    Yanfly.BEC.Game_Actor_refresh.call(this);
    if ($gameParty.inBattle()) this.requestStatusRefresh();
};

Game_Actor.prototype.isSpriteVisible = function() {
    if ($gameSystem.isSideView()) return true;
    return eval(Yanfly.Param.BECFrontSprite);
};

Game_Actor.prototype.reflectAnimationId = function() {
                if (this.actor().reflectAnimationId > 0) {
                        return this.actor().reflectAnimationId;
                }
                if (this.currentClass().reflectAnimationId > 0) {
                        return this.currentClass().reflectAnimationId;
                }
                for (var i = 0; i < this.equips().length; ++i) {
                        var equip = this.equips();
                        if (equip && equip.reflectAnimationId > 0) {
                                return equip.reflectAnimationId;
                        }
                }
                return Game_Battler.prototype.reflectAnimationId.call(this);
};

Game_Actor.prototype.spriteCanMove = function() {
                if (this.actor().spriteCannotMove) return false;
                if (this.currentClass().spriteCannotMove) return false;
                for (var i = 0; i < this.equips().length; ++i) {
                        var equip = this.equips();
                        if (equip && equip.spriteCannotMove) return false;
                }
                return Game_Battler.prototype.spriteCanMove.call(this);
};

Game_Actor.prototype.spriteWidth = function() {
    if ($gameSystem.isSideView() && this.battler()) {
                        return this.battler()._mainSprite.width;
                } else {
                        return 1;
                }
};

Game_Actor.prototype.spriteHeight = function() {
    if ($gameSystem.isSideView() && this.battler()) {
                        return this.battler()._mainSprite.height;
                } else {
                        return 1;
                }
};

Game_Actor.prototype.anchorX = function() {
    return this.actor().anchorX;
};

Game_Actor.prototype.anchorY = function() {
    return this.actor().anchorY;
};

Game_Actor.prototype.spriteFacePoint = function(pointX, pointY) {
    if (this.spritePosX() > pointX) {
      this.spriteFaceForward();
    } else {
      this.spriteFaceBackward();
    }
};

Game_Actor.prototype.spriteFaceAwayPoint = function(pointX, pointY) {
    if (this.spritePosX() > pointX) {
      this.spriteFaceBackward();
    } else {
      this.spriteFaceForward();
    }
};

Game_Actor.prototype.performAttack = function() {
    var weapons = this.weapons();
    var wtypeId = weapons[0] ? weapons[0].wtypeId : 0;
    var attackMotion = $dataSystem.attackMotions[wtypeId];
    if (attackMotion) {
      if (attackMotion.type === 0) {
        this.forceMotion('thrust');
      } else if (attackMotion.type === 1) {
        this.forceMotion('swing');
      } else if (attackMotion.type === 2) {
        this.forceMotion('missile');
      }
      this.startWeaponAnimation(attackMotion.weaponImageId);
    }
};

Game_Actor.prototype.attackMotion = function() {
    var weapons = this.weapons();
    var wtypeId = weapons[0] ? weapons[0].wtypeId : 0;
    var attackMotion = $dataSystem.attackMotions[wtypeId];
    if (attackMotion) {
      if (attackMotion.type === 0) {
        return 'thrust';
      } else if (attackMotion.type === 1) {
        return 'swing';
      } else if (attackMotion.type === 2) {
        return 'missile';
      }
    };
    return 'thrust';
};

Game_Actor.prototype.performEscapeSuccess = function() {
    if (this.battler()) {
      this.performEscape();
      this.battler().startMove(300, 0, 60);
    }
};

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

Game_Enemy.prototype.performActionStart = function(action) {
    Game_Battler.prototype.performActionStart.call(this, action);
    if (!$gameSystem.isSideView() || !this.spriteCanMove()) {
      this.requestEffect('whiten');
    }
};

Yanfly.BEC.Game_Enemy_performDamage = Game_Enemy.prototype.performDamage;
Game_Enemy.prototype.performDamage = function() {
    if ($gameSystem.isSideView()) {
                        Game_Battler.prototype.performDamage.call(this);
                        SoundManager.playEnemyDamage();
                } else {
                        Yanfly.BEC.Game_Enemy_performDamage.call(this);
                }
};

Game_Enemy.prototype.attackAnimationId = function() {
    return this.enemy().attackAnimationId;
};

Game_Enemy.prototype.reflectAnimationId = function() {
                if (this.enemy().reflectAnimationId > 0) {
                        return this.enemy().reflectAnimationId;
                }
                return Game_Battler.prototype.reflectAnimationId.call(this);
};

Game_Enemy.prototype.spriteCanMove = function() {
                if (this.enemy().spriteCannotMove) return false;
                return Game_Battler.prototype.spriteCanMove.call(this);
};

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

Game_Unit.prototype.requestMotionRefresh = function() {
    for (var i = 0; i < this.members().length; ++i) {
      var member = this.members();
      if (member) member.requestMotionRefresh();
    }
};

Game_Unit.prototype.onTurnStart = function() {
    for (var i = 0; i < this.members().length; ++i) {
      var member = this.members();
      if (member) member.onTurnStart();
    }
};

Game_Unit.prototype.updateTick = function() {
    for (var i = 0; i < this.members().length; ++i) {
      var member = this.members();
      if (member) member.updateTick();
    }
};

//=============================================================================
// Game_Party
//=============================================================================

Game_Party.prototype.performEscapeSuccess = function() {
    for (var i = 0; i < this.members().length; ++i) {
      var member = this.members();
      if (member) member.performEscapeSuccess();
    }
};

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

Yanfly.BEC.Scene_Battle_update = Scene_Battle.prototype.update;
Scene_Battle.prototype.update = function() {
    Yanfly.BEC.Scene_Battle_update.call(this);
    this.updateStatusWindowRequests();
};

Scene_Battle.prototype.updateStatusWindowRequests = function() {
    if (!this._statusWindow) return;
    if (this._statusWindow.isClosed()) return;
    this._statusWindow.updateStatusRequests();
};

Yanfly.BEC.Scene_Battle_createSkillWindow =
    Scene_Battle.prototype.createSkillWindow;
Scene_Battle.prototype.createSkillWindow = function() {
    Yanfly.BEC.Scene_Battle_createSkillWindow.call(this);
    if (eval(Yanfly.Param.BECLowerWindows)) {
                        this.adjustLowerWindow(this._skillWindow);
                }
};

Yanfly.BEC.Scene_Battle_createItemWindow =
    Scene_Battle.prototype.createItemWindow;
Scene_Battle.prototype.createItemWindow = function() {
    Yanfly.BEC.Scene_Battle_createItemWindow.call(this);
    if (eval(Yanfly.Param.BECLowerWindows)) {
                        this.adjustLowerWindow(this._itemWindow);
                }
};

Yanfly.BEC.Scene_Battle_createActorWindow =
                Scene_Battle.prototype.createActorWindow;
Scene_Battle.prototype.createActorWindow = function() {
    Yanfly.BEC.Scene_Battle_createActorWindow.call(this);
    this._actorWindow.x = Graphics.boxWidth - this._actorWindow.width;
    if (eval(Yanfly.Param.BECSelectHelp)) {
      this._actorWindow.setHelpWindow(this._helpWindow);
    }
};

Yanfly.BEC.Scene_Battle_createEnemyWindow =
    Scene_Battle.prototype.createEnemyWindow;
Scene_Battle.prototype.createEnemyWindow = function() {
    Yanfly.BEC.Scene_Battle_createEnemyWindow.call(this);
    if (eval(Yanfly.Param.BECSelectHelp)) {
      this._enemyWindow.setHelpWindow(this._helpWindow);
    }
};

Scene_Battle.prototype.adjustLowerWindow = function(win) {
    win.height = win.fittingHeight(eval(Yanfly.Param.BECWindowRows));
    win.y = Graphics.boxHeight - win.height;
};

Yanfly.BEC.Scene_Battle_startPartyCommandSelection =
    Scene_Battle.prototype.startPartyCommandSelection;
Scene_Battle.prototype.startPartyCommandSelection = function() {
    if (this.isStartActorCommand()) {
      this.selectNextCommand();
    } else {
      Yanfly.BEC.Scene_Battle_startPartyCommandSelection.call(this);
    }
};

Scene_Battle.prototype.isStartActorCommand = function() {
    if (this._isStartActorCommand === undefined) {
      this._isStartActorCommand = eval(Yanfly.Param.BECStartActCmd)
    }
    return this._isStartActorCommand;
};

Yanfly.BEC.Scene_Battle_selectPreviousCommand =
    Scene_Battle.prototype.selectPreviousCommand;
Scene_Battle.prototype.selectPreviousCommand = function() {
    if (this.isStartActorCommand()) {
      BattleManager.selectPreviousCommand();
      if (BattleManager.isInputting() && BattleManager.actor()) {
        this.startActorCommandSelection();
      } else {
        Yanfly.BEC.Scene_Battle_startPartyCommandSelection.call(this);
      }
    } else {
      Yanfly.BEC.Scene_Battle_selectPreviousCommand.call(this);
    }
};

Yanfly.BEC.Scene_Battle_selectNextCommand =
    Scene_Battle.prototype.selectNextCommand;
Scene_Battle.prototype.selectNextCommand = function() {
    Yanfly.BEC.Scene_Battle_selectNextCommand.call(this);
    this._helpWindow.clear();
    BattleManager.stopAllSelection();
};

Yanfly.BEC.Scene_Battle_commandSkill = Scene_Battle.prototype.commandSkill;
Scene_Battle.prototype.commandSkill = function() {
    this._helpWindow.clear();
    Yanfly.BEC.Scene_Battle_commandSkill.call(this);
};

Yanfly.BEC.Scene_Battle_commandItem = Scene_Battle.prototype.commandItem;
Scene_Battle.prototype.commandItem = function() {
    this._helpWindow.clear();
    Yanfly.BEC.Scene_Battle_commandItem.call(this);
};

Yanfly.BEC.Scene_Battle_startActorCommandSelection =
                Scene_Battle.prototype.startActorCommandSelection;
Scene_Battle.prototype.startActorCommandSelection = function() {
    Yanfly.BEC.Scene_Battle_startActorCommandSelection.call(this);
                this._statusWindow.refresh();
};

Yanfly.BEC.Scene_Battle_selectActorSelection =
    Scene_Battle.prototype.selectActorSelection;
Scene_Battle.prototype.selectActorSelection = function() {
    if (eval(Yanfly.Param.BECSelectHelp)) this._helpWindow.show();
    this._helpWindow.clear();
    Yanfly.BEC.Scene_Battle_selectActorSelection.call(this);
    this._actorWindow.autoSelect();
};

Yanfly.BEC.Scene_Battle_onActorCancel = Scene_Battle.prototype.onActorCancel;
Scene_Battle.prototype.onActorCancel = function() {
    if (eval(Yanfly.Param.BECSelectHelp)) this._helpWindow.hide();
    this._helpWindow.clear();
    Yanfly.BEC.Scene_Battle_onActorCancel.call(this);
    BattleManager.stopAllSelection();
};

Yanfly.BEC.Scene_Battle_selectEnemySelection =
    Scene_Battle.prototype.selectEnemySelection;
Scene_Battle.prototype.selectEnemySelection = function() {
    if (eval(Yanfly.Param.BECSelectHelp)) this._helpWindow.show();
    this._helpWindow.clear();
    Yanfly.BEC.Scene_Battle_selectEnemySelection.call(this);
    this._enemyWindow.autoSelect();
};

Yanfly.BEC.Scene_Battle_onEnemyCancel = Scene_Battle.prototype.onEnemyCancel;
Scene_Battle.prototype.onEnemyCancel = function() {
    if (eval(Yanfly.Param.BECSelectHelp)) this._helpWindow.hide();
    this._helpWindow.clear();
    Yanfly.BEC.Scene_Battle_onEnemyCancel.call(this);
    BattleManager.stopAllSelection();
};

Yanfly.BEC.Scene_Battle_onSelectAction = Scene_Battle.prototype.onSelectAction;
Scene_Battle.prototype.onSelectAction = function() {
    if (eval(Yanfly.Param.BECSelectHelp)) BattleManager.forceSelection();
    this._helpWindow.clear();
    Yanfly.BEC.Scene_Battle_onSelectAction.call(this);
    if (eval(Yanfly.Param.BECSelectHelp)) BattleManager.resetSelection();
};

Yanfly.BEC.Scene_Battle_onSkillOk =
    Scene_Battle.prototype.onSkillOk;
Scene_Battle.prototype.onSkillOk = function() {
    this._helpWindow.clear();
    Yanfly.BEC.Scene_Battle_onSkillOk.call(this);
};

Yanfly.BEC.Scene_Battle_onSkillCancel =
    Scene_Battle.prototype.onSkillCancel;
Scene_Battle.prototype.onSkillCancel = function() {
    this._helpWindow.clear();
    Yanfly.BEC.Scene_Battle_onSkillCancel.call(this);
};

Yanfly.BEC.Scene_Battle_onItemOk =
    Scene_Battle.prototype.onItemOk;
Scene_Battle.prototype.onItemOk = function() {
    this._helpWindow.clear();
    Yanfly.BEC.Scene_Battle_onItemOk.call(this);
};

Yanfly.BEC.Scene_Battle_onItemCancel =
    Scene_Battle.prototype.onItemCancel;
Scene_Battle.prototype.onItemCancel = function() {
    this._helpWindow.clear();
    Yanfly.BEC.Scene_Battle_onItemCancel.call(this);
};

//=============================================================================
// Window_Help
//=============================================================================

Yanfly.BEC.Window_Help_clear = Window_Help.prototype.clear;
Window_Help.prototype.clear = function() {
    Yanfly.BEC.Window_Help_clear.call(this);
    this.contents.clear();
};

//=============================================================================
// Window_Selectable
//=============================================================================

Yanfly.BEC.Window_Selectable_isCursorMovable =
    Window_Selectable.prototype.isCursorMovable;
Window_Selectable.prototype.isCursorMovable = function() {
    if (this._inputLock) return false;
    return Yanfly.BEC.Window_Selectable_isCursorMovable.call(this);
};

//=============================================================================
// Window_Help
//=============================================================================

Window_Help.prototype.setBattler = function(battler) {
    this.contents.clear();
    this.clear();
    if (!$gameParty.inBattle()) return;
    if (!battler) return;
    var action = BattleManager.inputtingAction();
    if (this.specialSelectionText(action)) {
      this.drawSpecialSelectionText(action);
    } else {
      this.drawBattler(battler);
    }
};

Window_Help.prototype.specialSelectionText = function(action) {
    BattleManager.resetSelection();
    if (!action) return false;
    return !action.needsSelection();
};

Window_Help.prototype.drawBattler = function(battler) {
    var text = battler.name();
    var wx = 0;
    var wy = (this.contents.height - this.lineHeight()) / 2;
    this.drawText(text, wx, wy, this.contents.width, 'center');
};

Window_Help.prototype.drawSpecialSelectionText = function(action) {
    var wx = 0;
    var wy = (this.contents.height - this.lineHeight()) / 2;
    var text = '';
    if (action.isForUser()) {
      text = Yanfly.Param.BECHelpUserTx;
    } else if (action.isForRandom()) {
      BattleManager.startAllSelection();
      var fmt = Yanfly.Param.BECHelpRandTx;
      if (action.isForOpponent() && action.numTargets() !== 1) {
        var target = Yanfly.Param.BECHelpEnemiesTx;
      } else if (action.isForOpponent() && action.numTargets() === 1) {
        var target = Yanfly.Param.BECHelpEnemyTx;
      } else if (action.isForFriend() && action.numTargets() !== 1) {
        var target = Yanfly.Param.BECHelpAlliesTx;
      } else {
        var target = Yanfly.Param.BECHelpAllyTx;
      }
      text = fmt.format(target, Yanfly.Util.toGroup(action.numTargets()));
    } else if (action.isForAll()) {
      BattleManager.startAllSelection();
      var fmt = Yanfly.Param.BECHelpAllTx;
      if (action.isForOpponent()) {
        var target = Yanfly.Param.BECHelpEnemiesTx;
      } else {
        var target = Yanfly.Param.BECHelpAlliesTx;
      }
      text = fmt.format(target);
    }
    this.drawText(text, wx, wy, this.contents.width, 'center');
};

//=============================================================================
// Window_BattleActor
//=============================================================================

Window_BattleActor.prototype.autoSelect = function() {
    var action = BattleManager.inputtingAction();
    if (!action) return;
    this._inputLock = false;
    this._selectDead = false;
    if (action.isForUser()) {
      this.select(BattleManager.actor().index());
      this._inputLock = true;
    } else if (action.isForDeadFriend()) {
      this._selectDead = true;
    }
};

Window_BattleActor.prototype.isOkEnabled = function() {
    if (this._selectDead) return this.actor().isDead();
    return Window_Selectable.prototype.isOkEnabled.call(this);
};

Window_BattleActor.prototype.updateHelp = function() {
    if (!this._helpWindow) return;
    this._helpWindow.setBattler(this.actor());
};

Yanfly.BEC.Window_BattleActor_processTouch =
    Window_BattleActor.prototype.processTouch;
Window_BattleActor.prototype.processTouch = function() {
    if (eval(Yanfly.Param.BECActorSelect) && this.isOpenAndActive()) {
      if (TouchInput.isTriggered() && !this.isTouchedInsideFrame()) {
        if (this.getClickedActor() >= 0) {
          var index = this.getClickedActor();
          if (this.index() === index) {
            return this.processOk();
          } else {
            SoundManager.playCursor();
            return this.select(index);
          }
        }
      }
      if (TouchInput.isPressed() && !this.isTouchedInsideFrame()) {
        if (this.getClickedActor() >= 0) {
          var index = this.getClickedActor();
          if (this.index() !== index) {
            SoundManager.playCursor();
            return this.select(index);
          }
        }
      }
    }
    Yanfly.BEC.Window_BattleActor_processTouch.call(this);
};

Window_BattleActor.prototype.getClickedActor = function() {
    for (var i = 0; i < $gameParty.battleMembers().length; ++i) {
      var actor = $gameParty.battleMembers().reverse();
      if (!actor) continue;
      if (this.isClickedActor(actor)) {
        if (this._selectDead && !actor.isDead()) continue;
        if (this._inputLock && actor.index() !== this.index()) continue;
        return actor.index();
      }
    }
    return -1;
};

Window_BattleActor.prototype.isClickedActor = function(actor) {
    if (!actor) return false;
    if (!actor.isSpriteVisible()) return false;
    var x = TouchInput.x;
    var y = TouchInput.y;
    var rect = new Rectangle();
    rect.width = actor.spriteWidth();
    rect.height = actor.spriteHeight();
    rect.x = actor.spritePosX() - rect.width / 2;
    rect.y = actor.spritePosY() - rect.height;
    return (x >= rect.x && y >= rect.y && x < rect.x + rect.width &&
      rect.y + rect.height);
};

//=============================================================================
// Window_BattleEnemy
//=============================================================================

Yanfly.DisableWebGLMask = false;

Yanfly.BEC.Window_BattleEnemy_initialize =
    Window_BattleEnemy.prototype.initialize;
Window_BattleEnemy.prototype.initialize = function(x, y) {
    if (eval(Yanfly.Param.BECEnemySelect)) {
      x = y = -500;
      this._ignoreMask = true;
    };
    Yanfly.BEC.Window_BattleEnemy_initialize.call(this, x, y);
    if (eval(Yanfly.Param.BECEnemySelect)) this.opacity = 0;
};

Yanfly.BEC.Window_BattleEnemy_windowWidth =
    Window_BattleEnemy.prototype.windowWidth;
Window_BattleEnemy.prototype.windowWidth = function() {
    if (eval(Yanfly.Param.BECEnemySelect)) return Graphics.boxWidth + 500;
    return Yanfly.BEC.Window_BattleEnemy_windowWidth.call(this);
};

Yanfly.BEC.Window_BattleEnemy_windowHeight =
    Window_BattleEnemy.prototype.windowHeight;
Window_BattleEnemy.prototype.windowHeight = function() {
  if (eval(Yanfly.Param.BECEnemySelect)) return Graphics.boxHeight + 500;
  return Yanfly.BEC.Window_BattleEnemy_windowHeight.call(this);
};

Yanfly.BEC.WindowLayer_webglMaskWindow =
                WindowLayer.prototype._webglMaskWindow;
WindowLayer.prototype._webglMaskWindow = function(renderSession, win) {
    if (win._ignoreMask) return;
    Yanfly.BEC.WindowLayer_webglMaskWindow.call(this, renderSession, win);
};

Yanfly.BEC.Window_BattleEnemy_maxCols =
    Window_BattleEnemy.prototype.maxCols;
Window_BattleEnemy.prototype.maxCols = function() {
    if (eval(Yanfly.Param.BECEnemySelect)) return this.allowedTargets().length;
    return Yanfly.BEC.Window_BattleEnemy_maxCols.call(this);
};

Window_BattleEnemy.prototype.allowedTargets = function() {
    var targets = [];
    targets = targets.concat($gameTroop.aliveMembers());
    return targets;
};

Window_BattleEnemy.prototype.refresh = function() {
    this._enemies = $gameTroop.aliveMembers();
    this.sortTargets();
    Window_Selectable.prototype.refresh.call(this);
};

Window_BattleEnemy.prototype.sortTargets = function() {
                this._enemies.sort(function(a, b) {
                                if (a.spritePosX() == b.spritePosX()) {
                                        return a.spritePosY() - b.spritePosY();
                                }
                                return a.spritePosX() - b.spritePosX();
                });
};

Window_BattleEnemy.prototype.drawItem = function(index) {
    this.resetTextColor();
    var name = this._enemies[index].name();
    if (eval(Yanfly.Param.BECEnemySelect)) {
      var rect = this.nameRect(index);
      var align = 'center';
    } else {
      var rect = this.itemRectForText(index);
      var align = 'left';
    }
    this.contents.fontSize = Yanfly.Param.BECEnemyFontSize;
    this.drawText(name, rect.x, rect.y, rect.width, align);
                this.resetFontSettings();
};

Window_BattleEnemy.prototype.itemRect = function(index) {
    if (eval(Yanfly.Param.BECEnemySelect)) {
      var rect = new Rectangle();
                  var enemy = this._enemies[index];
                  var maxCols = this.maxCols();
      rect.width = enemy.spriteWidth();
      rect.height = enemy.spriteHeight();
                  var pad = this.standardPadding();
      rect.x = enemy.spritePosX() - rect.width / 2 - pad + 500;
      rect.y = enemy.spritePosY() - rect.height - pad + 500;
                  return rect;
    }
    return Window_Selectable.prototype.itemRect.call(this, index);
};

Window_BattleEnemy.prototype.nameRect = function(index) {
                var rect = new Rectangle();
    if (!eval(Yanfly.Param.BECShowEnemyName)) return rect;
                var enemy = this._enemies[index];
                var maxCols = this.maxCols();
    this.contents.fontSize = Yanfly.Param.BECEnemyFontSize;
    var textSize = this.textWidth(' ' + enemy.name() + ' ');
                rect.width = Math.max(enemy.spriteWidth(), textSize);
                rect.height = this.lineHeight();
                var pad = this.standardPadding();
                rect.x = enemy.spritePosX() - rect.width / 2 - pad + 500;
                rect.y = enemy.spritePosY() - enemy.spriteHeight() - pad + 500;
                rect.y += enemy.spriteHeight() - this.lineHeight() -
                        this.standardPadding();
                return rect;
};

Window_BattleEnemy.prototype.updateCursor = function() {
    if (eval(Yanfly.Param.BECEnemySelect)) {
      if (this._cursorAll) {
                            var allRowsHeight = this.maxRows() * this.itemHeight();
                            this.setCursorRect(0, 0, this.contents.width, allRowsHeight);
                            this.setTopRow(0);
            } else if (this.index() < 0) {
                            this.setCursorRect(0, 0, 0, 0);
            } else {
                            this.ensureCursorVisible();
                            var rect = this.nameRect(this.index());
                            this.setCursorRect(rect.x, rect.y, rect.width, rect.height);
            }
    } else {
      Window_Selectable.prototype.updateCursor.call(this);
    }
};

Window_BattleEnemy.prototype.autoSelect = function() {
    var selectIndex = eval(Yanfly.Param.BECEnemyAutoSel);
    this.select(selectIndex);
};

Window_BattleEnemy.prototype.furthestRight = function() {
                return this.maxItems() - 1;
};

Window_BattleEnemy.prototype.updateHelp = function() {
    if (!this._helpWindow) return;
    this._helpWindow.setBattler(this.enemy());
};

//=============================================================================
// Window_PartyCommand
//=============================================================================

Window_PartyCommand.prototype.itemTextAlign = function() {
    return Yanfly.Param.BECCommandAlign;
};

Window_PartyCommand.prototype.numVisibleRows = function() {
    return eval(Yanfly.Param.BECCommandRows);
};

//=============================================================================
// Window_ActorCommand
//=============================================================================

Window_ActorCommand.prototype.itemTextAlign = function() {
    return Yanfly.Param.BECCommandAlign;
};

Window_ActorCommand.prototype.numVisibleRows = function() {
    return eval(Yanfly.Param.BECCommandRows);
};

//=============================================================================
// Window_BattleStatus
//=============================================================================

Window_BattleStatus.prototype.numVisibleRows = function() {
    return eval(Yanfly.Param.BECCommandRows);
};

Window_BattleStatus.prototype.updateStatusRequests = function() {
    for (var i = 0; i < $gameParty.battleMembers().length; ++i) {
      var actor = $gameParty.battleMembers();
      if (!actor) continue;
      if (actor.isStatusRefreshRequested()) this.processStatusRefresh(i);
    }
};

Window_BattleStatus.prototype.processStatusRefresh = function(index) {
    var actor = $gameParty.battleMembers()[index];
    if (!actor) return;
    var rect = this.itemRect(index);
    this.contents.clearRect(rect.x, rect.y, rect.width, rect.height);
    this.drawItem(index);
    actor.completetStatusRefreshRequest();
};

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

Yanfly.BEC.Window_BattleLog_isFastForward =
                Window_BattleLog.prototype.isFastForward;
Window_BattleLog.prototype.isFastForward = function() {
    if (eval(Yanfly.Param.BECOptSpeed)) return true;
                return Yanfly.BEC.Window_BattleLog_isFastForward.call(this);
};

Window_BattleLog.prototype.updateWaitCount = function() {
    if (this._waitCount > 0) {
        this._waitCount -= 1;
        if (this._waitCount < 0) {
            this._waitCount = 0;
        }
        return true;
    }
    return false;
};

Window_BattleLog.prototype.animationBaseDelay = function() {
    return eval(Yanfly.Param.BECAniBaseDel);
};

Window_BattleLog.prototype.animationNextDelay = function() {
    return eval(Yanfly.Param.BECAniNextDel);
};

Window_BattleLog.prototype.updateWaitMode = function() {
    var waiting = false;
    switch (this._waitMode) {
    case 'effect':
        waiting = this._spriteset.isEffecting();
        break;
    case 'movement':
        waiting = this._spriteset.isAnyoneMoving();
        break;
    case 'animation':
        waiting = this._spriteset.isAnimationPlaying();
        break;
    case 'popups':
        waiting = this._spriteset.isPopupPlaying();
        break;
    }
    if (!waiting) {
        this._waitMode = '';
    }
    return waiting;
};

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

Window_BattleLog.prototype.endAction = function(subject) {
};

Window_BattleLog.prototype.waitForAnimation = function() {
    this.setWaitMode('animation');
};

Window_BattleLog.prototype.waitForEffect = function() {
    this.setWaitMode('effect');
};

Window_BattleLog.prototype.waitForPopups = function() {
    this.setWaitMode('popups');
};

Yanfly.BEC.Window_BattleLog_displayAction =
    Window_BattleLog.prototype.displayAction;
Window_BattleLog.prototype.displayAction = function(subject, item) {
    if (eval(Yanfly.Param.BECFullActText)) {
      Yanfly.BEC.Window_BattleLog_displayAction.call(this, subject, item);
    } else {
      this._actionIcon = item.iconIndex;
      this.push('addText', '<SIMPLE>' + item.name);
      if (item.message2) {
        this.push('addText', '<CENTER>' + item.message2.format(item.name));
      }
    }
};

Yanfly.BEC.Window_BattleLog_displayActionResults =
                Window_BattleLog.prototype.displayActionResults;
Window_BattleLog.prototype.displayActionResults = function(subject, target) {
    if (eval(Yanfly.Param.BECOptSpeed)) {
                        if (target.result().used) {
                this.displayCritical(target);
                                        this.displayDamage(target);
                                        this.displayAffectedStatus(target);
                                        this.displayFailure(target);
            }
                } else {
                        Yanfly.BEC.Window_BattleLog_displayActionResults.call(this, subject,
                                        target);
                }
    if (target.isDead()) target.performCollapse();
};

Yanfly.BEC.Window_BattleLog_drawLineText =
    Window_BattleLog.prototype.drawLineText;
Window_BattleLog.prototype.drawLineText = function(index) {
    if (this._lines[index].match('<CENTER>')) {
      this.drawCenterLine(index);
    } else if (this._lines[index].match('<SIMPLE>')) {
      this.drawSimpleActionLine(index);
    } else {
      Yanfly.BEC.Window_BattleLog_drawLineText.call(this, index);
    }
};

Window_BattleLog.prototype.drawCenterLine = function(index) {
    var text = this._lines[index].replace('<CENTER>', '');
    var rect = this.itemRectForText(index);
    this.contents.clearRect(rect.x, rect.y, rect.width, rect.height);
    this.drawText(text, rect.x, rect.y, Graphics.boxWidth, 'center');
};

Window_BattleLog.prototype.drawSimpleActionLine = function(index) {
    var text = this._lines[index].replace('<SIMPLE>', '');
    var rect = this.itemRectForText(index);
    this.contents.clearRect(rect.x, rect.y, rect.width, rect.height);
    if (this._actionIcon) {
      var tw = this.textWidth(text);
      var ix = (rect.width - tw) / 2 - 4;
      this.drawIcon(this._actionIcon, ix, rect.y + 2);
    }
    this.drawText(text, rect.x, rect.y, Graphics.boxWidth, 'center');
};

Window_BattleLog.prototype.displayCounter = function(target) {
    if (eval(Yanfly.Param.BECShowCntText)) {
                        this.addText(TextManager.counterAttack.format(target.name()));
                }
                target.performCounter();
                this.showAttackAnimation(target, [BattleManager._subject]);
                this.waitForAnimation();
};

Window_BattleLog.prototype.displayReflection = function(target) {
    if (eval(Yanfly.Param.BECShowRflText)) {
                        this.addText(TextManager.magicReflection.format(target.name()));
                }
                target.performReflection();
                var animationId = BattleManager._action.item().animationId;
                this.showNormalAnimation([BattleManager._subject], animationId);
                this.waitForAnimation();
};

Window_BattleLog.prototype.displaySubstitute = function(substitute, target) {
    if (eval(Yanfly.Param.BECShowSubText)) {
                        var substName = substitute.name();
                        this.addText(TextManager.substitute.format(substName, target.name()));
                }
                substitute.performSubstitute(target);
};

Yanfly.BEC.Window_BattleLog_displayFailure =
    Window_BattleLog.prototype.displayFailure;
Window_BattleLog.prototype.displayFailure = function(target) {
    if (!eval(Yanfly.Param.BECShowFailText)) return;
    Yanfly.BEC.Window_BattleLog_displayFailure.call(this, target);
};

Yanfly.BEC.Window_BattleLog_displayCritical =
    Window_BattleLog.prototype.displayCritical;
Window_BattleLog.prototype.displayCritical = function(target) {
    if (!eval(Yanfly.Param.BECShowCritText)) return;
    Yanfly.BEC.Window_BattleLog_displayCritical.call(this, target);
};

Yanfly.BEC.Window_BattleLog_displayMiss =
    Window_BattleLog.prototype.displayMiss;
Window_BattleLog.prototype.displayMiss = function(target) {
    if (!eval(Yanfly.Param.BECShowMissText)) return;
    Yanfly.BEC.Window_BattleLog_displayMiss.call(this, target);
};

Yanfly.BEC.Window_BattleLog_displayEvasion =
    Window_BattleLog.prototype.displayEvasion;
Window_BattleLog.prototype.displayEvasion = function(target) {
    if (!eval(Yanfly.Param.BECShowEvaText)) return;
    Yanfly.BEC.Window_BattleLog_displayEvasion.call(this, target);
};

Yanfly.BEC.Window_BattleLog_displayHpDamage =
    Window_BattleLog.prototype.displayHpDamage;
Window_BattleLog.prototype.displayHpDamage = function(target) {
    if (!eval(Yanfly.Param.BECShowHpText)) return;
    Yanfly.BEC.Window_BattleLog_displayHpDamage.call(this, target);
};

Yanfly.BEC.Window_BattleLog_displayMpDamage =
    Window_BattleLog.prototype.displayMpDamage;
Window_BattleLog.prototype.displayMpDamage = function(target) {
    if (!eval(Yanfly.Param.BECShowMpText)) return;
    Yanfly.BEC.Window_BattleLog_displayMpDamage.call(this, target);
};

Yanfly.BEC.Window_BattleLog_displayTpDamage =
    Window_BattleLog.prototype.displayTpDamage;
Window_BattleLog.prototype.displayTpDamage = function(target) {
    if (!eval(Yanfly.Param.BECShowTpText)) return;
    Yanfly.BEC.Window_BattleLog_displayTpDamage.call(this, target);
};

Yanfly.BEC.Window_BattleLog_displayCurrentState =
    Window_BattleLog.prototype.displayCurrentState;
Window_BattleLog.prototype.displayCurrentState = function(subject) {
    if (!eval(Yanfly.Param.BECShowStateText)) return;
    Yanfly.BEC.Window_BattleLog_displayCurrentState.call(this, subject);
};

Yanfly.BEC.Window_BattleLog_displayAddedStates =
    Window_BattleLog.prototype.displayAddedStates;
Window_BattleLog.prototype.displayAddedStates = function(target) {
    if (!eval(Yanfly.Param.BECShowStateText)) return;
    Yanfly.BEC.Window_BattleLog_displayAddedStates.call(this, target);
};

Yanfly.BEC.Window_BattleLog_displayRemovedStates =
    Window_BattleLog.prototype.displayRemovedStates;
Window_BattleLog.prototype.displayRemovedStates = function(target) {
    if (!eval(Yanfly.Param.BECShowStateText)) return;
    Yanfly.BEC.Window_BattleLog_displayRemovedStates.call(this, target);
};

Yanfly.BEC.Window_BattleLog_displayChangedBuffs =
    Window_BattleLog.prototype.displayChangedBuffs;
Window_BattleLog.prototype.displayChangedBuffs = function(target) {
    if (!eval(Yanfly.Param.BECShowBuffText)) return;
    Yanfly.BEC.Window_BattleLog_displayChangedBuffs.call(this, target);
};

Window_BattleLog.prototype.popupDamage = function(target) {
};

Yanfly.BEC.Window_BattleLog_showEnemyAttackAnimation =
                Window_BattleLog.prototype.showEnemyAttackAnimation;
Window_BattleLog.prototype.showEnemyAttackAnimation =
function(subject, targets) {
                if ($gameSystem.isSideView()) {
                        this.showNormalAnimation(targets, subject.attackAnimationId(), false);
                } else {
      this.showNormalAnimation(targets, subject.attackAnimationId(), false);
                        Yanfly.BEC.Window_BattleLog_showEnemyAttackAnimation.call(this, subject,
                                        targets);
                }
};

Window_BattleLog.prototype.showActorAtkAniMirror = function(subject, targets) {
    this.showNormalAnimation(targets, subject.attackAnimationId1(), true);
    this.showNormalAnimation(targets, subject.attackAnimationId2(), false);
};

//=============================================================================
// New Function
//=============================================================================

Yanfly.Util = Yanfly.Util || {};

if (!Yanfly.Util.toGroup) {
                Yanfly.Util.toGroup = function(inVal) {
                                return inVal;
                }
};

Yanfly.Util.getRange = function(n, m) {
    var result = [];
    for (var i = n; i <= m; ++i) result.push(i);
    return result;
};

Yanfly.Util.onlyUnique = function(value, index, self) {
    return self.indexOf(value) === index;
};

//=============================================================================
// End of File
//=============================================================================[/pre][/fold]
回复

使用道具 举报

世界坑化协会

梦石
0
星屑
9565
在线时间
1592 小时
注册时间
2007-3-13
回帖
5263

极短26参与极短25参与极短23参与极短21参与开拓者贵宾第一届化妆舞会最佳服饰奖

发表于 2015-11-9 12:52:53 | 显示全部楼层
我用了LZ脚本产生了一个JS错误, undefined is not a function
忍卷NINMAKI游戏DEMO上线了~♪  点我下载  ☚
回复

使用道具 举报

梦石
0
星屑
50
在线时间
171 小时
注册时间
2013-8-6
回帖
91
 楼主| 发表于 2015-11-9 17:55:02 | 显示全部楼层
v2sam 发表于 2015-11-9 12:52
我用了LZ脚本产生了一个JS错误, undefined is not a function

我用的11月6号的包,帮忙看看哪里冲突了,谢谢

Yanfly Engine Plugins (English) 2015年11月06日.zip

177.97 KB, 下载次数: 79

点评

与程序猿无关  发表于 2015-11-9 23:16
我不是程序猿……  发表于 2015-11-9 18:05
回复

使用道具 举报

梦石
0
星屑
80
在线时间
386 小时
注册时间
2007-7-27
回帖
4075

开拓者

发表于 2015-11-9 20:53:59 | 显示全部楼层

点评

翻不了墙,能上传一个atb么,谢谢老大  发表于 2015-11-9 23:15
吸吸
回复

使用道具 举报

梦石
0
星屑
80
在线时间
386 小时
注册时间
2007-7-27
回帖
4075

开拓者

发表于 2015-11-9 23:23:26 | 显示全部楼层
所有的yep包

- YEP English -(5).rar

179.21 KB, 下载次数: 109

点评

用这个包还是有bug,咋回事?敌人用动态不显示受伤害的数值,用静态敌人攻击时直接undefined is not a function。我是按上面范例做的  发表于 2015-11-11 18:12
谢谢~  发表于 2015-11-10 05:55

评分

参与人数 2星屑 +30 梦石 +1 收起 理由
余烬之中 + 1 楼主真难伺候..
longshili + 30 塞糖

查看全部评分

回复

使用道具 举报

梦石
0
星屑
50
在线时间
171 小时
注册时间
2013-8-6
回帖
91
 楼主| 发表于 2015-11-11 15:45:12 | 显示全部楼层
trentswd 发表于 2015-11-9 23:23
所有的yep包

用这个包,发现个bug,就是敌方受到伤害不显示数值了,为啥?
回复

使用道具 举报

梦石
0
星屑
50
在线时间
171 小时
注册时间
2013-8-6
回帖
91
 楼主| 发表于 2015-11-11 18:57:33 | 显示全部楼层
trentswd 发表于 2015-11-9 23:23
所有的yep包

自己搞定了,去范例网站下了最新版覆盖就好了,修复了先前的bug
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

在本版发帖返回顶部