(front/back base) offset during action sequences (Yanfly's Plugins)

Status
Not open for further replies.

RPG_itch_Studio

Veteran
Veteran
Joined
Jan 20, 2018
Messages
83
Reaction score
16
First Language
English
Primarily Uses
RMMV
I am using non default sideview actor/enemy battlers and they have all different sizes. For this reason it is almost impossible to align every actor battler with every enemy battler during action sequences (battles with different actors and enemies). Most of the times the actor appears above/below the enemy.

When using the default notetag: MOVE target1: target2, FRONT BASE, (frames), (offset) , I am able to align only one actor with one enemy.

Is it possible to apply somehow another (offset) property to FRONT/BACK BASE property using actor/enemy notetags like this:

<Front Base Offset>
offset_x: value1
offset_y: value2
</Front Base Offset>
 
Last edited:

Yethwhinger

Veteran
Veteran
Joined
Jul 18, 2018
Messages
53
Reaction score
29
First Language
English
Primarily Uses
RMMV
The following plugin was made to allow adjustments to be made to FRONT BASE and BACK BASE user and target action destinations during the MOVE action when using YEP_X_ActSeqPack2. This plugin should go under YEP_X_ActSeqPack2 in the Plugin Manager. The syntax to be used in the actor and enemy note fields is of the form <offsetMovFBTY:30>, where "F" stands for "front," "B" stands for "base," "T" stands for "target," "Y" is for the vertical direction, and "30" is the number of pixels to adjust the destination by. The help section of the plugin lists the eight possible adjustments to the MOVE action that can be made for an enemy or actor using this plugin.
Code:
// AdjustMovPos.js
// Created on 8/6/2019
// Last modified on 8/6/2019 by Yethwhinger

var objYeth = objYeth || {};

/*:
* @plugindesc This plugin is meant to adjust the positions
* of battlers during action sequences.
* @author Yethwhinger
*
* @help This plugin is made for use with the YEP_X_ActSeqPack2
* plugin and should be placed under that plugin in the Plugin
* Manager. This plugin allows the offset of the MOVE action
* in the action sequence to be customized for different battlers.
* Specific offsets are set in the note fields of the Enemies
* and Actors sections of the database using the format
* <offsetMov[CODE]:number1>, where number1 is the pixel offset,
* and [CODE] is replaced with entries from the following table
* as desired.
*
* Property to Offset                            CODE
* ------------------                            ----
* x coordinate of FRONT BASE as action user     FBUX
* y coordinate of FRONT BASE as action user     FBUY
* x coordinate of BACK BASE as action user      BBUX
* y coordinate of BACK BASE as action user      BBUY
* x coordinate of FRONT BASE as action target   FBTX
* y coordinate of FRONT BASE as action target   FBTY
* x coordinate of BACK BASE as action target    BBTX
* y coordinate of BACK BASE as action target    BBTY
*
* For example, to adjust the MOVE action such that the user
* will go 25 pixels lower on the screen when moving to the
* FRONT BASE of a particular actor, that actor's note field
* can use the following entry: "<offsetMovFBTY:25>."
*/

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

objYeth.Game_Enemy_setup_OffsetMov = Game_Enemy.prototype.setup;
Game_Enemy.prototype.setup = function (enemyId, x, y) {
    var osMovFBUX = $dataEnemies[enemyId].meta.offsetMovFBUX;
    var osMovFBUY = $dataEnemies[enemyId].meta.offsetMovFBUY;
    var osMovBBUX = $dataEnemies[enemyId].meta.offsetMovBBUX;
    var osMovBBUY = $dataEnemies[enemyId].meta.offsetMovBBUY;
    var osMovFBTX = $dataEnemies[enemyId].meta.offsetMovFBTX;
    var osMovFBTY = $dataEnemies[enemyId].meta.offsetMovFBTY;
    var osMovBBTX = $dataEnemies[enemyId].meta.offsetMovBBTX;
    var osMovBBTY = $dataEnemies[enemyId].meta.offsetMovBBTY;
    objYeth.Game_Enemy_setup_OffsetMov.call(this, enemyId, x, y);
    this._offsetMovFBUX = 0;
    this._offsetMovFBUY = 0;
    this._offsetMovBBUX = 0;
    this._offsetMovBBUY = 0;
    this._offsetMovFBTX = 0;
    this._offsetMovFBTY = 0;
    this._offsetMovBBTX = 0;
    this._offsetMovBBTY = 0;
    if (osMovFBUX) {
        this._offsetMovFBUX = Number(osMovFBUX);
    }
    if (osMovFBUY) {
        this._offsetMovFBUY = Number(osMovFBUY);
    }
    if (osMovBBUX) {
        this._offsetMovBBUX = Number(osMovBBUX);
    }
    if (osMovBBUY) {
        this._offsetMovBBUY = Number(osMovBBUY);
    }
    if (osMovFBTX) {
        this._offsetMovFBTX = Number(osMovFBTX);
    }
    if (osMovFBTY) {
        this._offsetMovFBTY = Number(osMovFBTY);
    }
    if (osMovBBTX) {
        this._offsetMovBBTX = Number(osMovBBTX);
    }
    if (osMovBBTY) {
        this._offsetMovBBTY = Number(osMovBBTY);
    }
};

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

objYeth.Game_Actor_setup_OffsetMov = Game_Actor.prototype.setup;
Game_Actor.prototype.setup = function (actorId) {
    var osMovFBUX = $dataActors[actorId].meta.offsetMovFBUX;
    var osMovFBUY = $dataActors[actorId].meta.offsetMovFBUY;
    var osMovBBUX = $dataActors[actorId].meta.offsetMovBBUX;
    var osMovBBUY = $dataActors[actorId].meta.offsetMovBBUY;
    var osMovFBTX = $dataActors[actorId].meta.offsetMovFBTX;
    var osMovFBTY = $dataActors[actorId].meta.offsetMovFBTY;
    var osMovBBTX = $dataActors[actorId].meta.offsetMovBBTX;
    var osMovBBTY = $dataActors[actorId].meta.offsetMovBBTY;
    objYeth.Game_Actor_setup_OffsetMov.call(this, actorId);
    this._offsetMovFBUX = 0;
    this._offsetMovFBUY = 0;
    this._offsetMovBBUX = 0;
    this._offsetMovBBUY = 0;
    this._offsetMovFBTX = 0;
    this._offsetMovFBTY = 0;
    this._offsetMovBBTX = 0;
    this._offsetMovBBTY = 0;
    if (osMovFBUX) {
        this._offsetMovFBUX = Number(osMovFBUX);
    }
    if (osMovFBUY) {
        this._offsetMovFBUY = Number(osMovFBUY);
    }
    if (osMovBBUX) {
        this._offsetMovBBUX = Number(osMovBBUX);
    }
    if (osMovBBUY) {
        this._offsetMovBBUY = Number(osMovBBUY);
    }
    if (osMovFBTX) {
        this._offsetMovFBTX = Number(osMovFBTX);
    }
    if (osMovFBTY) {
        this._offsetMovFBTY = Number(osMovFBTY);
    }
    if (osMovBBTX) {
        this._offsetMovBBTX = Number(osMovBBTX);
    }
    if (osMovBBTY) {
        this._offsetMovBBTY = Number(osMovBBTY);
    }
};

//----------------------------
// Changes to BattleManager
//----------------------------

BattleManager.actionMove = function (name, actionArgs) {
    if (!$gameSystem.isSideView()) return true;
    var movers = this.makeActionTargets(name);
    if (movers.length < 1) return true;
    var cmd = actionArgs[0].toUpperCase();
    if (['HOME', 'ORIGIN'].contains(cmd)) {
        var frames = actionArgs[1] || 12;
        movers.forEach(function (mover) {
            mover.battler().startMove(0, 0, frames);
            mover.requestMotion('walk');
            mover.spriteFaceHome();
        });
    } else if (['RETURN'].contains(cmd)) {
        var frames = actionArgs[1] || 12;
        movers.forEach(function (mover) {
            mover.battler().startMove(0, 0, frames);
            mover.requestMotion('evade');
            mover.spriteFaceForward();
        });
    } else if (['FORWARD', 'FORWARDS', 'BACKWARD',
    'BACKWARDS'].contains(cmd)) {
        var distance = actionArgs[1] || Yanfly.Param.BECStepDist;
        if (['BACKWARD', 'BACKWARDS'].contains(cmd)) distance *= -1;
        var frames = actionArgs[2] || 12;
        movers.forEach(function (mover) {
            mover.battler().moveForward(distance, frames);
            mover.requestMotion('walk');
            if (['FORWARD', 'FORWARDS'].contains(cmd)) {
                mover.spriteFaceForward();
            } else {
                mover.spriteFaceBackward();
            }
        });
    } else if (['POINT', 'POSITION', 'COORDINATE', 'SCREEN', 'SCREEN POS',
    'COORDINATES'].contains(cmd)) {
        var destX = eval(actionArgs[1]) || 0;
        var destY = eval(actionArgs[2]) || 0;
        var frames = actionArgs[3] || 12;
        movers.forEach(function (mover) {
            var offsetX = BattleManager.actionMoveOffsetX(actionArgs, mover, mover);
            var offsetY = BattleManager.actionMoveOffsetY(actionArgs, mover, mover);
            mover.battler().moveToPoint(destX + offsetX, destY + offsetY, frames);
            mover.requestMotion('walk');
            mover.spriteFacePoint(destX, destY);
        });
    } else {
        var targets = this.makeActionTargets(actionArgs[0]);
        var frames = actionArgs[2] || 12;
        var type = actionArgs[1].toUpperCase();
        if (targets.length < 1) return false;
        for (var i = 0; i < movers.length; ++i) {
            var mover = movers[i];
            if (!mover) continue;
            if (['BASE', 'FOOT', 'FEET'].contains(type)) {
                var destX = this.actionMoveX(mover, targets, 'center');
                var destY = this.actionMoveY(mover, targets, 'foot');
            } else if (['CENTER', 'MIDDLE'].contains(type)) {
                var destX = this.actionMoveX(mover, targets, 'center');
                var destY = this.actionMoveY(mover, targets, 'center');
            } else if (['HEAD', 'TOP'].contains(type)) {
                var destX = this.actionMoveX(mover, targets, 'center');
                var destY = this.actionMoveY(mover, targets, 'head');
            } else if (['FRONT BASE', 'FRONT FOOT', 'FRONT FEET',
            'FRONT'].contains(type)) {
                var target = targets[0];
                var osTargetX = 0;
                var osTargetY = 0;
                if (target) {
                    osTargetX = target._offsetMovFBTX;
                    osTargetY = target._offsetMovFBTY;
                }
                var destX = this.actionMoveX(mover, targets, 'front') + mover._offsetMovFBUX + osTargetX;
                var destY = this.actionMoveY(mover, targets, 'foot') + mover._offsetMovFBUY + osTargetY;
            } else if (['BACK BASE', 'BACK FOOT', 'BACK FEET',
            'BACK'].contains(type)) {
                var target = targets[0];
                var osTargetX = 0;
                var osTargetY = 0;
                if (target) {
                    osTargetX = target._offsetMovBBTX;
                    osTargetY = target._offsetMovBBTY;
                }
                var destX = this.actionMoveX(mover, targets, 'back') + mover._offsetMovBBUX + osTargetX;
                var destY = this.actionMoveY(mover, targets, 'foot') + mover._offsetMovBBUY + osTargetY;
            } else if (['FRONT CENTER', 'FRONT MIDDLE'].contains(type)) {
                var destX = this.actionMoveX(mover, targets, 'front');
                var destY = this.actionMoveY(mover, targets, 'center');
            } else if (['BACK CENTER', 'BACK MIDDLE', ].contains(type)) {
                var destX = this.actionMoveX(mover, targets, 'back');
                var destY = this.actionMoveY(mover, targets, 'center');
            } else if (['FRONT HEAD', 'FRONT TOP'].contains(type)) {
                var destX = this.actionMoveX(mover, targets, 'front');
                var destY = this.actionMoveY(mover, targets, 'head');
            } else if (['BACK HEAD', 'BACK TOP'].contains(type)) {
                var destX = this.actionMoveX(mover, targets, 'back');
                var destY = this.actionMoveY(mover, targets, 'head');
            }
            var offsetX = this.actionMoveOffsetX(actionArgs, mover, targets[0]);
            var offsetY = this.actionMoveOffsetY(actionArgs, mover, targets[0]);
            mover.battler().moveToPoint(destX + offsetX, destY + offsetY, frames);
            mover.spriteFacePoint(destX, destY);
        }
    }
    return true;
};
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,714
First Language
English
Primarily Uses
RMVXA
[closed]IgnoreMe[/closed]
 
Status
Not open for further replies.

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

Latest Threads

Latest Profile Posts

My computer broke yesterday, so no RPG maker for at least a week until I can get it repaired. :(
Just wanted to share how my game won 1st place in a game jam for itch.io. Everyone else used Unreal, Unity, GMS2, Godot, etc but I used RPG Maker 2003 :guffaw: It just shows that you can create a good game and it doesn't matter which engine you use
Working on cutscenes~

if your game is the first (or ONLY) in a series and still has a colon in its title, you are a bad person and I hate you...... jk.

who could ever hate BETWEEN: TWO SOULS?

Forum statistics

Threads
107,405
Messages
1,029,444
Members
139,504
Latest member
lobsterknees
Top