Mirror Battlers

Milena

The woman of many questions
Veteran
Joined
Jan 26, 2014
Messages
1,281
Reaction score
106
First Language
Irish
Primarily Uses
N/A
I just want to ask something. Is there a way or in what way can an enemy or actor sprite (in Sideview Battle) be mirrored? For example, I tag the actor with <mirror>, when I go inside the battle, the SV_Battler is mirrored instead of the standard battler facing left?
 
Joined
Aug 16, 2012
Messages
70
Reaction score
9
First Language
English
Primarily Uses
Would be nice, wouldn't it?


But I do not think so, not without a script or a plugin.
 

Milena

The woman of many questions
Veteran
Joined
Jan 26, 2014
Messages
1,281
Reaction score
106
First Language
Irish
Primarily Uses
N/A
Would be nice, wouldn't it?


But I do not think so, not without a script or a plugin.


Yes, that is why I am asking for the plugin snippet on how to do it on this section.
 

DreamX

Veteran
Veteran
Joined
May 30, 2015
Messages
816
Reaction score
826
First Language
English
Primarily Uses
Tag enemy/actor with <mirror:1>

Code:
    Sprite_Battler.prototype.shouldMirror = function () {
        // store the this._battler member as a variable named battler
        var battler = this._battler;

        // if the battler variable member has not been stored yet, return false
        if (!battler)
            return false;

        // if an actor, get the actor from the database. if not get the enemy 
        // from the database.
        var dataBattler = battler.isActor() ? battler.actor() : battler.enemy();
        
        // store the meta data into a variable.
        var meta = dataBattler.meta;
        
        // if the meta data doesn't have a notetag with the name mirror, return
        // fales
        if (!meta.mirror)
            return false;
        
        // if we've gotten to this point, meta does have a notetag with the 
        // name mirror so we can return true
        return true;
    };

    // alias the Sprite_Actor.prototype.updateBitmap function
    alias_Sprite_Actor_updateBitmap = Sprite_Actor.prototype.updateBitmap;
    Sprite_Actor.prototype.updateBitmap = function () {
        // call the original function we are aliasing
        alias_Sprite_Actor_updateBitmap.call(this);
        // check if we didn't already mirror.
        // check if we should mirror.
        if (!this._mirroredX && this.shouldMirror() === true) {

            // mirror the sprite by multiplying the scale x by -1
            this._mainSprite.scale.x *= -1.0;
            // mark that we mirrored
            this._mirroredX = true;
        }
    };

    // alias the Sprite_Enemy.prototype.loadBitmap function
    alias_Sprite_Enemy_loadBitmap = Sprite_Enemy.prototype.loadBitmap;
    Sprite_Enemy.prototype.loadBitmap = function (name, hue) {
        // call the original function we are aliasing
        alias_Sprite_Enemy_loadBitmap.call(this, name, hue);
        // check if we already mirrored. 
        // check if we should mirror.
        if (!this._mirroredX && this.shouldMirror() === true) {
            // mirror the sprite by multiplying the scale x by -1
            this.scale.x *= -1.0;
            // mark that we mirrored
            this._mirroredX = true;
        }
    };
 

Victor Sant

Veteran
Veteran
Joined
Mar 17, 2012
Messages
1,694
Reaction score
1,452
First Language
Portuguese
Primarily Uses
Tag enemy/actor with <mirror:1>
Just one thing DreamX, i noticed that you use <meta:1> when you want the notetag to return true/false, but you actually don't need to add the :1, if you use <meta> the maker will recognize it as a true/false metatag.
 

DreamX

Veteran
Veteran
Joined
May 30, 2015
Messages
816
Reaction score
826
First Language
English
Primarily Uses
Just one thing DreamX, i noticed that you use <meta:1> when you want the notetag to return true/false, but you actually don't need to add the :1, if you use <meta> the maker will recognize it as a true/false metatag.
Good point. I started using meta:1 type notetags when I just started coding for MV and it became habit.
 

Milena

The woman of many questions
Veteran
Joined
Jan 26, 2014
Messages
1,281
Reaction score
106
First Language
Irish
Primarily Uses
N/A
Thanks for this DreamX, works perfectly!


Consider this problem closed.
 

str8studios

Villager
Member
Joined
Mar 2, 2016
Messages
14
Reaction score
2
First Language
english
Primarily Uses
DreamX that's a lovely little script, but when i use it, when i first attack the enemy battlers, they spin back around. Any idea what might cause this?
 

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,862
Messages
1,017,050
Members
137,571
Latest member
grr
Top