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?
Mirror Battlers
Learning JavascriptWould be nice, wouldn't it?
But I do not think so, not without a script or a plugin.
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.
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;
}
};
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.
Thanks for this DreamX, works perfectly!
Consider this problem closed.
Consider this problem closed.
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?
Original thread: https://forums.rpgmakerweb.com/threads/mirror-battlers.60899/