Plugin that adjusts the animation position of a battler!

● ARCHIVED · READ-ONLY
Started by RPG_itch_Studio 4 posts View original ↗
  1. Looking for a plugin where you can offset the animations being played on a specific monster/actor battler. So if the animation is drawing too far up on your battler you could add a notetag to have that animation draw lower. Can this be done without creating animation problems on the other battlers?
  2. Feel free to try the plugin below. It uses <offsetAniX:number1> and <offsetAniY:number2> in the note fields of the Enemies and Actors sections of the database to adjust the positions of animations on those enemies and actors.
    Code:
    // AdjustAniPos.js
    // Created on 9/24/2018
    // Last modified on 9/25/2018 by Yethwhinger
    
    var objYeth = objYeth || {};
    
    /*:
    * @plugindesc This plugin is meant to adjust the position
    * of animations on battlers.
    * @author Yethwhinger
    *
    * @help This plugin adjusts the position of animations
    * over a battler by moving it using <offsetAniX:number1>
    * and <offsetAniY: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.
    */
    
    //----------------------------
    // Changes to Game_Enemy
    //----------------------------
    
    objYeth.Game_Enemy_setup_OffsetAni = Game_Enemy.prototype.setup;
    Game_Enemy.prototype.setup = function (enemyId, x, y) {
        var osAniX = $dataEnemies[enemyId].meta.offsetAniX;
        var osAniY = $dataEnemies[enemyId].meta.offsetAniY;
        objYeth.Game_Enemy_setup_OffsetAni.call(this, enemyId, x, y);
        this._offsetAniX = 0;
        this._offsetAniY = 0;
        if (osAniX) {
            this._offsetAniX = Number(osAniX);
        }
        if (osAniY) {
            this._offsetAniY = Number(osAniY);
        }
    };
    
    //----------------------------
    // Changes to Game_Actor
    //----------------------------
    
    objYeth.Game_Actor_setup_OffsetAni = Game_Actor.prototype.setup;
    Game_Actor.prototype.setup = function (actorId) {
        var osAniX = $dataActors[actorId].meta.offsetAniX;
        var osAniY = $dataActors[actorId].meta.offsetAniY;
        objYeth.Game_Actor_setup_OffsetAni.call(this, actorId);
        this._offsetAniX = 0;
        this._offsetAniY = 0;
        if (osAniX) {
            this._offsetAniX = Number(osAniX);
        }
        if (osAniY) {
            this._offsetAniY = Number(osAniY);
        }
    };
    
    //----------------------------
    // Changes to Sprite_Animation
    //----------------------------
    
    Sprite_Animation.prototype.updatePosition = function () {
        if (this._animation.position === 3) {
            this.x = this.parent.width / 2;
            this.y = this.parent.height / 2;
        } else {
            var parent = this._target.parent;
            var grandparent = parent ? parent.parent : null;
            this.x = this._target.x;
            this.y = this._target.y;
            if (this.parent === grandparent) {
                this.x += parent.x;
                this.y += parent.y;
            }
            if (this._animation.position === 0) {
                this.y -= this._target.height;
            } else if (this._animation.position === 1) {
                this.y -= this._target.height / 2;
            }
            var battler = this._target._battler;
            if (!battler) {
                battler = this._target.parent._battler;
            }
            if (battler) {
                this.x += battler._offsetAniX;
                this.y += battler._offsetAniY;
            }
        }
    };
  3. It worked perfectly. Again, thank you for your hard work!:):thumbsup-left:
  4. This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.