Snippet Code AdjustStatePositions error with Yanfly's Animated Battlers

zerobeat032

Cloaked Wanderer...
Veteran
Joined
Mar 28, 2014
Messages
299
Reaction score
335
First Language
English
Primarily Uses
RMMV
So I was having an issue with custom battlers and the state icons appearing way above them or too far to a certain side. I was looking around for a solution and stumbled across a small plugin that corrects the issue, but it seems to cause another with Yanfly's animated battlers... which it shouldn't? at least judging from the original post I found the plugin in. the person who originally requested this wasn't having any issues. I don't either, until a battle ends. It would seem between this new plugin and Yanfly's, the game doesn't know where to put the icons on enemies as far as updating them at the end of a battle? I could be completely wrong tho.

I only have Yanfly's Core, Battle Core, the 3 action sequences, this plugin AdjustStatePositions, and animated battlers on and I get the following error...

ERR ROOR.PNG

Code:
// AdjustStatePositions.js
// Created on 9/18/2018
// Last modified on 1/28/2019 by Yethwhinger

var objYeth = objYeth || {};

/*:
* @plugindesc This plugin is meant to adjust the positions of the
* state displays over battlers.
* @author Yethwhinger
*
* @help This plugin adjusts the position of the state icon or
* overlay over a battler by moving it using <stateX:number1>
* and <stateY:number2> entries in the note fields of the Enemies
* and Actors sections of the database. number1 and number2
* represent pixel adjustments in the x and y directions.
*
* If the plugin is used with YEP_X_ActSeqPack2, the state icon
* or overlay positions can be adjusted in the y direction
* a different amount for each actor's individual battle motions
* by using notes of the format <stateY_motion:number>. For example,
* a note of <stateY_guard:50> in an actor's note field in the
* database will lower that actor's state icon or overlay by 50
* pixels when that actor's sprite is in the guard motion.
*
* This version is made to work with up to 9 looping custom motions
* named "cloop1" through "cloop9" and 9 single-play custom motions
* named "csing1" through "csing9" when used with YEP_X_ActSeqPack2
* and YED_SideviewBattler.
*/

//----------------------------
// Changes to Game_Enemy
//----------------------------

objYeth.Game_Enemy_setup = Game_Enemy.prototype.setup;
Game_Enemy.prototype.setup = function (enemyId, x, y) {
    var tempX = $dataEnemies[enemyId].meta.stateX;
    var tempY = $dataEnemies[enemyId].meta.stateY;
    objYeth.Game_Enemy_setup.call(this, enemyId, x, y);
    this._stateX = 0;
    this._stateY = 0;
    if (tempX) {
        this._stateX = Number(tempX);
    }
    if (tempY) {
        this._stateY = Number(tempY);
    }
};

//----------------------------
// Changes to Game_Actor
//----------------------------

objYeth.addCustomMotions = function () {
    var saMot = Sprite_Actor.MOTIONS;
    var i;
    var nCustom = 9;
    var nStandard = 18;
    var nTotal = nStandard + nCustom;
    var motionName;
    var nameStem = 'cloop';
    for (i = 0; i < nCustom; i++) {
        motionName = nameStem + (i + 1);
        saMot[motionName] = { index: i + nStandard, loop: true };
    }
    nameStem = 'csing';
    for (i = 0; i < nCustom; i++) {
        motionName = nameStem + (i + 1);
        saMot[motionName] = { index: i + nStandard + nCustom, loop: false };
    }
};

objYeth.Game_Actor_setup = Game_Actor.prototype.setup;
Game_Actor.prototype.setup = function (actorId) {
    var tempX = $dataActors[actorId].meta.stateX;
    var tempY = $dataActors[actorId].meta.stateY;
    var metadata = $dataActors[actorId].meta;
    var saMot;
    var i;
    var nCustom = 9;
    var motionName, paramName;
    var nameStem = 'cloop';
    var nMotions;
    var tempMotionY;
    objYeth.Game_Actor_setup.call(this, actorId);
    this._stateX = 0;
    this._stateY = 0;
    if (tempX) {
        this._stateX = Number(tempX);
    }
    if (tempY) {
        this._stateY = Number(tempY);
    }
    objYeth.addCustomMotions();
    saMot = Sprite_Actor.MOTIONS;
    this._stateMotionY = [];
    this._stateMotionY[saMot.walk.index] = metadata.stateY_walk || 0;
    this._stateMotionY[saMot.wait.index] = metadata.stateY_wait || 0;
    this._stateMotionY[saMot.chant.index] = metadata.stateY_chant || 0;
    this._stateMotionY[saMot.guard.index] = metadata.stateY_guard || 0;
    this._stateMotionY[saMot.damage.index] = metadata.stateY_damage || 0;
    this._stateMotionY[saMot.evade.index] = metadata.stateY_evade || 0;
    this._stateMotionY[saMot.thrust.index] = metadata.stateY_thrust || 0;
    this._stateMotionY[saMot.swing.index] = metadata.stateY_swing || 0;
    this._stateMotionY[saMot.missile.index] = metadata.stateY_missile || 0;
    this._stateMotionY[saMot.skill.index] = metadata.stateY_skill || 0;
    this._stateMotionY[saMot.spell.index] = metadata.stateY_spell || 0;
    this._stateMotionY[saMot.item.index] = metadata.stateY_item || 0;
    this._stateMotionY[saMot.escape.index] = metadata.stateY_escape || 0;
    this._stateMotionY[saMot.victory.index] = metadata.stateY_victory || 0;
    this._stateMotionY[saMot.dying.index] = metadata.stateY_dying || 0;
    this._stateMotionY[saMot.abnormal.index] = metadata.stateY_abnormal || 0;
    this._stateMotionY[saMot.sleep.index] = metadata.stateY_sleep || 0;
    this._stateMotionY[saMot.dead.index] = metadata.stateY_dead || 0;
    for (i = 0; i < nCustom; i++) {
        motionName = nameStem + (i + 1);
        paramName = `stateY_${motionName}`;
        this._stateMotionY[saMot[motionName].index] = metadata[paramName] || 0;
    }
    nameStem = 'csing';
    for (i = 0; i < nCustom; i++) {
        motionName = nameStem + (i + 1);
        paramName = `stateY_${motionName}`;
        this._stateMotionY[saMot[motionName].index] = metadata[paramName] || 0;
    }
    nMotions = this._stateMotionY.length;
    for (i = 0; i < nMotions; i++) {
        tempMotionY = this._stateMotionY[i];
        if (tempMotionY) {
            this._stateMotionY[i] = Number(tempMotionY);
        }
    }
};

//-----------------------------
// Changes to Sprite_StateIcon
//-----------------------------

objYeth.Sprite_StateIcon_setup = Sprite_StateIcon.prototype.setup;
Sprite_StateIcon.prototype.setup = function (battler) {
    objYeth.Sprite_StateIcon_setup.call(this, battler);
    this.x = battler._stateX;
    if (battler.isActor()) {
        this.y = battler._stateY;
    }
};

//--------------------------------
// Changes to Sprite_StateOverlay
//--------------------------------

objYeth.Sprite_StateOverlay_setup = Sprite_StateOverlay.prototype.setup;
Sprite_StateOverlay.prototype.setup = function (battler) {
    objYeth.Sprite_StateOverlay_setup.call(this, battler);
    this.x = battler._stateX;
    this.y = battler._stateY;
};

//----------------------------
// Changes to Sprite_Battler
//----------------------------

objYeth.Sprite_Battler_updateStateSpritesAdjPos = Sprite_Battler.prototype.updateStateSprites;
Sprite_Battler.prototype.updateStateSprites = function () {
    var battler = this._battler;
    var stateY = battler._stateY;
    var motion = this._motion;
    var motionName = this._motionName || "";
    var saMot = Sprite_Actor.MOTIONS;
    objYeth.Sprite_Battler_updateStateSpritesAdjPos.call(this);
    if (this._stateIconSprite) {
        this._stateIconSprite.y += stateY;
        if (motion) {
            this._stateIconSprite.y += battler._stateMotionY[motion.index];
        }
        else if (motionName) {
            this._stateIconSprite.y += battler._stateMotionY[saMot[motionName].index];
        }
    }
    if (this._stateSprite) {
        this._stateSprite.y += stateY;
        if (motion) {
            this._stateSprite.y += battler._stateMotionY[motion.index];
        }
        else if (motionName) {
            this._stateSprite.y += battler._stateMotionY[saMot[motionName].index];
        }
    }
};

//----------------------------
// Changes to Sprite_Enemy
//----------------------------

Sprite_Enemy.prototype.updateStateSprite = function () {
    this._stateIconSprite.y = -Math.round((this.bitmap.height + 40) * 0.9) + this._battler._stateY;
    if (this._stateIconSprite.y < 20 - this.y) {
        this._stateIconSprite.y = 20 - this.y;
    }
};
 

zerobeat032

Cloaked Wanderer...
Veteran
Joined
Mar 28, 2014
Messages
299
Reaction score
335
First Language
English
Primarily Uses
RMMV
bump.... I actually just found out that this plugin was released officially under the name of SimpleMsgSideView... I tried using that version as I figured it being offical, it might be more updated, but I still received the same error for some reason.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,864
Messages
1,017,056
Members
137,573
Latest member
nikisknight
Top