Need help to position battle animation

Drac00nbeam

That will do...for now.
Member
Joined
Jul 31, 2017
Messages
28
Reaction score
2
First Language
German
Primarily Uses
RMMV
Is there a way to change the position of where a skill animation will play besides the default: Head, Center, Feet, Screen?

I would like my animation to change the x,y position, depending on what enemy it is being cast upon. The reason is i'm using various sizes of enemies and it's kinda exhausting to make so many animations of one type for so many enemies just to position it the right way. I'm currently using "yanfly's SV enemies" and "yami's sideviewbattler" plugins. I would be glad, if this could be solved, since i'm relatively new to javascript coding.

The animation id is the same, but the enemies have different sizes.
normal.png correct position.
small.png wrong position.
For the slime, the animation should be positioned a little lower to look realistic.
 
Last edited:

Low

Veteran
Veteran
Joined
Oct 29, 2015
Messages
147
Reaction score
157
First Language
english
Primarily Uses
Is this only happening on the animated enemies? Because I have been trying to figure out why the animations play on top of my animated enemies but not my party battlers.
 

Drac00nbeam

That will do...for now.
Member
Joined
Jul 31, 2017
Messages
28
Reaction score
2
First Language
German
Primarily Uses
RMMV
Not really, i guess it is the same issue with the party battlers, since they too may have different sprite sizes.
Well i searched the forum for similar threads and found this code within the rpg_sprites.js file:
Code:
Sprite_Animation.prototype.updatePosition = function() {
    if (this._animation.position === 3) {                  // for the screen tab
        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) {             // for the head tab
            this.y -= this._target.height;
        } else if (this._animation.position === 1) {      // for the center tab
            this.y -= this._target.height / 2;
        }
    }
};
The position number of the animations can also be found within the animation.json file of the data folder.

It can also be adjusted to specific animations with either by name or id:
Code:
if (this._animation.name === "Name of the animation")
if (this._animation.id === id)
But the position should be dependent on the enemy as well. Maybe it can be done by simply adding an if-statement with the enemy id, but it'd still be done within a plugin. Since i'm using action sequences it would be better to dynamically add code to the skills notetag.
 
Last edited:

Drac00nbeam

That will do...for now.
Member
Joined
Jul 31, 2017
Messages
28
Reaction score
2
First Language
German
Primarily Uses
RMMV
Bump. I really need to know how you can get the targeted enemy id of the database, because i'm creating a plugin to implement this condition and since there's no default script call to position the animation.
Code:
(function() {

var alias_updatePositionOrig = Sprite_Animation.prototype.updatePosition;
    Sprite_Animation.prototype.updatePosition = function() {
        alias_updatePositionOrig.call(this);
            if (this._animation.position === 1) {
                if (this._animation.id === 146) {
                    if (target.enemyID() === 1) {
                        this.y -= this._target.height / 2 + 200;
                        }
                        else if (target.enemyID() === 2) {
                        this.y -= this._target.height / 2 + 100;
                        }
                        else {
                        }
                }
                else if (this._animation.id === 147) {
                    if (target.enemyID() === 1) {
                        this.y -= this._target.height / 2 + 200;
                        }
                        else if (target.enemyID() === 2) {
                        this.y -= this._target.height / 2 + 100;
                        }
                        else {
                        }
                }
                
            }
                
    }

}());
This doesn't really work, so i suspect there must be some other code for the plugin to work. I would appreciate some help.
 

San

Villager
Member
Joined
Dec 22, 2017
Messages
10
Reaction score
14
First Language
english
Primarily Uses
RMMV
[Removed]
 
Last edited:

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
21,861
Reaction score
11,069
First Language
English
Primarily Uses
RMVXA
@San Please do not hijack someone else's thread with your own query, which actually does differ from that of the OP. Their question relates to having the choice of the same animation playing in different places depending on the enemy, and yours is having it always on the centre. I suggest you make your own thread in Javascript/Plugin Support.

[move]Javascript/Plugin Support[/move]
 

Drac00nbeam

That will do...for now.
Member
Joined
Jul 31, 2017
Messages
28
Reaction score
2
First Language
German
Primarily Uses
RMMV
That's a different animation.
Oh sorry if i was mistaken about that, but that's the only code segment i found.
If there's another code area where you can manipulate the position, could you share it?
Sorry for the bother and thanks for the reply.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,144
Reaction score
12,416
First Language
English
Primarily Uses
RMMV
That animation isn't in the default scripts. The OP is using Yanfly's systems. That is where the animation will be set up.
 

Drac00nbeam

That will do...for now.
Member
Joined
Jul 31, 2017
Messages
28
Reaction score
2
First Language
German
Primarily Uses
RMMV
That animation isn't in the default scripts. The OP is using Yanfly's systems. That is where the animation will be set up.
Ah ok, i guess it has been aliased in YEP_X_AnimatedSVEnemies plugin:
Code:
Yanfly.SVE.Sprite_Animation_updatePosition =
  Sprite_Animation.prototype.updatePosition;
Sprite_Animation.prototype.updatePosition = function() {
  Yanfly.SVE.Sprite_Animation_updatePosition.call(this);
  this.updateSvePosition();
};

Sprite_Animation.prototype.updateSvePosition = function() {
  if (typeof this._target.parent._battler != 'undefined'){
    if (this._animation.position !== 3) {
      if (this._animation.position === 0) {
        if (this._target.parent._battler.isEnemy()) {
          this.y -= this._target.parent._texture.height;
        };
      } else if (this._animation.position === 1) {
        if (this._target.parent._battler.isEnemy()) {
          this.y -= this._target.parent._texture.height / 2;
        };
      }
    }
  }
};
But i'm not sure how to implement the above conditions in a plugin. The important part is to get the targeted enemy id from the database.
 
Last edited:

Coopziana

Veteran
Veteran
Joined
Jan 18, 2016
Messages
115
Reaction score
50
First Language
English
Did anyone ever find a solution to this, I'm having the same issue, have been fiddling around with the script and I just can't seem to make it work globally for all enemy sizes. I realise the issue is down to the Spritesheet having a lot of empty space vertically. But what I did find was that when using the notetag for <Sprite Height: x> it repositions the location of the state Icons.

I figured I could try and reference this.sideviewHeight; in the "this.y" section so that I can manually add in a notetag for all enemy Heights and then the script would work out the position of the animation based on that notetag... However, if I add it in, the animation doesn't seem visible at all. I don't get any error messages. I just get the sound effects and screen/target flashes. So I get the feeling the animation is playing but somewhere off screen... so, i'm at a loss now.

Does anyone have a working solution?

EDIT: I figured it out!

Turns out the script that was there was the reference to Sideview Height... Go Figure. So I simply added in an IF Statement to figure out if the enemy is small or large and reposition the animation based on that. Here is the script change:
Yanfly.SVE.Sprite_Animation_updatePosition =
Sprite_Animation.prototype.updatePosition;
Sprite_Animation.prototype.updatePosition = function() {
Yanfly.SVE.Sprite_Animation_updatePosition.call(this);
this.updateSvePosition();
};

Sprite_Animation.prototype.updateSvePosition = function() {
if (typeof this._target.parent._battler != 'undefined'){
if (this._animation.position !== 3) {
if (this._animation.position === 0) {
if (this._target.parent._battler.isEnemy()) {
this.y += this._target.parent._texture.height;
};
} else if (this._animation.position === 1) {
if (this._target.parent._battler.isEnemy()) {
if (this._target.parent._texture.height <=63) {
this.y += 100; }
else { this.y += this._target.parent._texture.height /4; }
};
}
}
}
};
 
Last edited:

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

Latest Threads

Latest Profile Posts

In the strangest turn of events, my animations now live in the characters folder, and my character images now live in the pictures folder. It's a complicated world, but weirdly a more resource efficient one. :LZSexcite:
Did you know that we use robotic spy animals to learn about how different species behave in the wild? We're only a step away from robotic spy humans, and then Terminator. :p
Not being able to do a commission/request after all and having to give back the money is so heartbreaking.

Sometimes I'm just way too eager to help people out and suddenly find myself in a very deep hole because I'm not gonna be able to finish it. I really hope I don't come across as unprofessional to these people and in general. =n="
Learning Action Sequences!
ANY FEEDBACK APPRECIATED!

Online Platformer TEST DEMO 0.1 - 4 simple Maps. Just jumping test. (I still have 2 minor problems to fix).

Forum statistics

Threads
98,045
Messages
948,806
Members
129,310
Latest member
eillajones309
Top