MV - Battle sprites face a specific way!

● ARCHIVED · READ-ONLY
Started by ArtisticChaos 20 posts View original ↗
  1. Yo! im looking for a plugin that makes the battle sprites always face the middle. No matter who is where in the party there battle sprite would always flip towards the middle.
    I dont think theres much more to say its prettty straight forward i think but if theres a plugin i can do this with or a plugin that does exactly this then please tell me cause i really need this :kaosigh:
    Heres an example:
    1681791742127.png
  2. bump
  3. How are you positioning the battlers? With the included ActorPositions plugin, or something else?

    This has options for different formations and appears to do the facing automatically.
    Battle Formation (ver. 1.7)
  4. ATT_Turan said:
    How are you positioning the battlers? With the included ActorPositions plugin, or something else?

    This has options for different formations and appears to do the facing automatically.
    Battle Formation (ver. 1.7)
    This is greate the only problem is that so far that ive looked i cant reporition the battlers to for example be at the bottom of the screen while in for example pincer mode, ill trie ask there but if you have alternatives that would be greate

    And im using Fogomax sv battler position extended to reposition my battlers but MPP seems to override that
  5. Bump!
  6. Bump.
  7. Speaking for myself, I haven't had anything else to say because your last post said you were using a specific plugin to determine the actor position; but it didn't include a link to the plugin, and Googling the name you typed doesn't come up with a place to obtain said plugin.

    We can't modify code that we can't see.
  8. ATT_Turan said:
    Speaking for myself, I haven't had anything else to say because your last post said you were using a specific plugin to determine the actor position; but it didn't include a link to the plugin, and Googling the name you typed doesn't come up with a place to obtain said plugin.

    We can't modify code that we can't see.
    Ahah my apolegies
    THIS is the plugin i use
  9. Continuing this from another thread:
    caethyril said:
    plugin code
    JavaScript:
    /*:
     * @target MV MZ
     * @plugindesc Mirror actor battlers who are in the right-hand half of the screen.
     * @author Caethyril
     * @url https://forums.rpgmakerweb.com/threads/106255/
     * @help Free to use and/or modify for any project, no credit required.
     */
    void (function(alias) {
        Sprite_Actor.prototype.updateMain = function() {
            alias.apply(this, arguments);
            if (this._homeX > Graphics.boxWidth / 2 && this.scale.x > 0)
                this.scale.x *= -1;
        };
    })(Sprite_Actor.prototype.updateMain);
    However, there are probably better ways to do it and I don't know how that would behave with stuff like YEP Action Sequences. :kaoslp:
    Sweetmayham said:
    This works perfectly! the only and literally only problem im having is the fact that there facing the wrong ways when positions have bin changed? soooo actor 1 when on the left side faces to the left while there supposed to flip away from there
    Ah, so it flips if they go to the right, but doesn't "unflip" if they go back to the left? This might work better (untested):
    plugin code v2
    JavaScript:
    /*:
     * @target MV MZ
     * @plugindesc v2 - mirror actor battlers when they are in the right-hand half of the screen.
     * @author Caethyril
     * @url https://forums.rpgmakerweb.com/threads/156765/
     * @help Free to use and/or modify for any project, no credit required.
     */
    void (function(alias) {
    'use strict';
      Sprite_Actor.prototype.updateMain = function() {
        alias.apply(this, arguments);
        const isOnRight = this._homeX > Graphics.boxWidth / 2;
        if (isOnRight === !this._flippedX) {
          this.scale.x *= -1;
          this._flippedX = !this._flippedX;
        }
      };
    })(Sprite_Actor.prototype.updateMain);
    Otherwise it may help if you show screenshot(s) of your Plugin Manager so we can see all plugins you're using. (I know you linked the actor position one, but you may be using other relevant plugins.)
  10. caethyril said:
    JavaScript:
    Code:
    /*:
     * @target MV MZ
     * @plugindesc v2 - mirror actor battlers when they are in the right-hand half of the screen.
     * @author Caethyril
     * @url https://forums.rpgmakerweb.com/threads/156765/
     * @help Free to use and/or modify for any project, no credit required.
     */
    void (function(alias) {
    'use strict';
      Sprite_Actor.prototype.updateMain = function() {
        alias.apply(this, arguments);
        const isOnRight = this._homeX > Graphics.boxWidth / 2;
        if (isOnRight === !this._flippedX) {
          this.scale.x *= -1;
          this._flippedX = !this._flippedX;
        }
      };
    })(Sprite_Actor.prototype.updateMain);
    Okay so i tried it out but this time it changed nothing at all but this time it completely overrides the Fogomax plugin! the actors are facing the right way at the moment but i cannot check to see if it would stay that way if there X positions would be different (see image)1682952970772.png
    As for the plugins im using in this test project would be: Sprite_Actor is the plugin you just gave me 1682953077194.png
    Now if id have to give a more detailed description it would be that the all actors are facing the right way i just need to be able to change there x and y positions or that actor 1 and 2 switch places with actor 3 and 4 but still facing the right way! so actor 1 and 2 on the "Left side" facing the right end of the screen and actor 3 and 4 on the right side of the screen facing the left side
  11. Whoops, my mistake. They should actually be flipped when they're on the left. My suggestion does completely the opposite. Third time lucky? :kaoswt:
    plugin code v3
    JavaScript:
    /*:
     * @target MV MZ
     * @plugindesc v3 - mirror actor battlers when they are in the left-hand half of the screen.
     * @author Caethyril
     * @url https://forums.rpgmakerweb.com/threads/156765/
     * @help Free to use and/or modify for any project, no credit required.
     */
    void (function(alias) {
    'use strict';
      Sprite_Actor.prototype.updateMain = function() {
        alias.apply(this, arguments);
        const isOnLeft = this._homeX < Graphics.boxWidth / 2;
        if (isOnLeft === !this._flippedX) {
          this.scale.x *= -1;
          this._flippedX = !this._flippedX;
        }
      };
    })(Sprite_Actor.prototype.updateMain);

    About the positions: Cae_BattleStepY has actor home X/Y formulae in its parameters: that's overriding the positions. The default value for the X parameter is reverse order by mistake and I haven't got around to fixing that. Here are a couple of alternatives I outlined for someone else:
    caethyril said:
    • For fixed positions I'd suggest something like this:
      Code:
      [408, 100, 600, 100, 600][index]
      This will return 408 for the party leader (index 0), 100 for the next actor (index 1), 600 for the next (index 2), etc.

    • Default x-position formula in reverse order (swap index for $gameParty.battleMembers().length - 1 - index and simplify):
      Code:
      Graphics.boxWidth / 2 + 96 * (index + 0.5 - $gameParty.battleMembers().length / 2)
      ...I don't know why I originally had them ordered right-to-left. :kaoswt2:
    If you prefer the Fogomax plugin's setup, try loading it after BattleStepY. You can click+drag to rearrange the load order, just remember to save your project to apply changes before testing. :kaohi:
  12. caethyril said:
    Whoops, my mistake. They should actually be flipped when they're on the left. My suggestion does completely the opposite. Third time lucky? :kaoswt:
    Yes! this one works perfectly! and knowing about the loading order i managed to fix the fogomax plugin aswel! thank you youve bin a huge help! i appreciate it
  13. Sweetmayham said:
    Yes! this one works perfectly! and knowing about the loading order i managed to fix the fogomax plugin aswel! thank you youve bin a huge help! i appreciate it
    AAAAAAAAAAAAACtoully, after putting it in my other game the official one i noticed that the battelers flip back after the first "turn" im checking to see wich plugin seems to cause that problem since i dont have that in the other testing game
    So it apears to be Yanfly's battle engine core
  14. Ah, yeah, I'd guess it's related to the action sequence stuff. I had a quick look at the code of YEP Battle Engine Core and I'd guess it's related to the spriteFaceForward/spriteFaceBackward methods. This might work?
    plugin code v4 - YEP BEC compatibility
    JavaScript:
    /*:
     * @target MV MZ
     * @plugindesc v4 - mirror actor battlers when they are in the left-hand half of the screen.
     * @author Caethyril
     * @url https://forums.rpgmakerweb.com/threads/156765/
     * @orderAfter YEP_BattleEngineCore
     * @help If using YEP_BattleEngineCore, load this plugin after Yanfly's.
     * 
     * Free to use and/or modify for any project, no credit required.
     */
    void (function() {
    'use strict';
    
      /**
       * @param {Sprite_Actor} sprite reference actor sprite.
       * @returns {boolean} `true` iff this plugin should flip `sprite`.
       */
      const shouldActorBeFlipped = function(sprite) {
        const faceFront = !sprite._faceBack;
        const isOnLeft  = sprite._homeX < Graphics.boxWidth / 2;
        return faceFront === isOnLeft;
      };
    
      // Flip sprites when appropriate.
      void (function() {
        const alias = Sprite_Actor.prototype.updateMain;
        Sprite_Actor.prototype.updateMain = function() {
          alias.apply(this, arguments);
          if (shouldActorBeFlipped(this) === !this._flippedX) {
            this.scale.x *= -1;
            this._flippedX = !this._flippedX;
          }
        };
      })();
    
      // YEP Battle Engine Core compatibility.
      void (function() { if (!Imported.YEP_BattleEngineCore) return;
        const alias_f = Game_Battler.prototype.spriteFaceForward;
        Game_Battler.prototype.spriteFaceForward = function() {
          alias_f.apply(this, arguments);
          delete this.battler()._faceBack;
        };
        const alias_b = Game_Battler.prototype.spriteFaceBackward;
        Game_Battler.prototype.spriteFaceBackward = function() {
          alias_b.apply(this, arguments);
          this.battler()._faceBack = true;
        };
      })();
    
    })();
  15. caethyril said:
    Ah, yeah, I'd guess it's related to the action sequence stuff. I had a quick look at the code of YEP Battle Engine Core and I'd guess it's related to the spriteFaceForward/spriteFaceBackward methods. This might work?
    plugin code v4 - YEP BEC compatibility
    JavaScript:
    /*:
     * @target MV MZ
     * @plugindesc v4 - mirror actor battlers when they are in the left-hand half of the screen.
     * @author Caethyril
     * @url https://forums.rpgmakerweb.com/threads/156765/
     * @orderAfter YEP_BattleEngineCore
     * @help If using YEP_BattleEngineCore, load this plugin after Yanfly's.
     *
     * Free to use and/or modify for any project, no credit required.
     */
    void (function() {
    'use strict';
    
      /**
       * @param {Sprite_Actor} sprite reference actor sprite.
       * @returns {boolean} `true` iff this plugin should flip `sprite`.
       */
      const shouldActorBeFlipped = function(sprite) {
        const faceFront = !sprite._faceBack;
        const isOnLeft  = sprite._homeX < Graphics.boxWidth / 2;
        return faceFront === isOnLeft;
      };
    
      // Flip sprites when appropriate.
      void (function() {
        const alias = Sprite_Actor.prototype.updateMain;
        Sprite_Actor.prototype.updateMain = function() {
          alias.apply(this, arguments);
          if (shouldActorBeFlipped(this) === !this._flippedX) {
            this.scale.x *= -1;
            this._flippedX = !this._flippedX;
          }
        };
      })();
    
      // YEP Battle Engine Core compatibility.
      void (function() { if (!Imported.YEP_BattleEngineCore) return;
        const alias_f = Game_Battler.prototype.spriteFaceForward;
        Game_Battler.prototype.spriteFaceForward = function() {
          alias_f.apply(this, arguments);
          delete this.battler()._faceBack;
        };
        const alias_b = Game_Battler.prototype.spriteFaceBackward;
        Game_Battler.prototype.spriteFaceBackward = function() {
          alias_b.apply(this, arguments);
          this.battler()._faceBack = true;
        };
      })();
    
    })();
    this dosnt seem to work at all, like its not changing anything?
  16. Sweetmayham said:
    this dosnt seem to know anything as far as im seeing

    Sweetmayham said:
    this dosnt seem to work at all, like its not changing anything?
    Also just took the time to turn on and off every single plugin i had and your plugin only dosnt work if i turn on Yep Battle engine core so im certain that thats the main problem here
  17. Sweetmayham said:
    Also just took the time to turn on and off every single plugin i had and your plugin only dosnt work if i turn on Yep Battle engine core so im certain that thats the main problem here
    She wrote that code specifically to accommodate the Battle Engine Core. It's possible there's a mistake, but are you sure you have her snippet correctly positioned beneath Yanfly's in your plugin manager?
  18. Sorry, my mistake. Yanfly's plugin makes them face forward/backward based on their current X scale, so it basically counters my suggestion. :kaoslp:

    I actually set up a test project this time, and this seems to work for me based on a quick test:
    v5 plugin code - YEP BEC only
    JavaScript:
    /*:
     * @target MV MZ
     * @plugindesc v5 - mirror actor battlers when they are in the left-hand half of the screen.
     * @author Caethyril
     * @url https://forums.rpgmakerweb.com/threads/156765/
     * @orderAfter YEP_BattleEngineCore
     * @help Should be loaded after YEP_BattleEngineCore.
     * 
     * Free to use and/or modify for any project, no credit required.
     */
    void (function() {
    'use strict';
    
      // Require YEP Battle Engine Core.
      if (!Imported.YEP_BattleEngineCore)
        throw new Error(
          "This plugin should be loaded after YEP_BattleEngineCore.\nPress F12 for details."
        );
    
      // Anti-mirror when on left.
      void (function() {
        const alias = Game_Battler.prototype.setMirror;
        Game_Actor.prototype.setMirror = function(value) {
          alias.call(this, value !== this.battler()._homeX < Graphics.boxWidth / 2);
        };
      })();
    
      // Face "forward" on battle start.
      void (function() {
        const alias = Game_Battler.prototype.onBattleStart;
        Game_Actor.prototype.onBattleStart = function() {
          this.spriteFaceForward();
          alias.apply(this, arguments);
        };
      })();
    
    })();
  19. caethyril said:
    Sorry, my mistake. Yanfly's plugin makes them face forward/backward based on their current X scale, so it basically counters my suggestion. :kaoslp:

    I actually set up a test project this time, and this seems to work for me based on a quick test:
    v5 plugin code - YEP BEC only
    JavaScript:
    /*:
     * @target MV MZ
     * @plugindesc v5 - mirror actor battlers when they are in the left-hand half of the screen.
     * @author Caethyril
     * @url https://forums.rpgmakerweb.com/threads/156765/
     * @orderAfter YEP_BattleEngineCore
     * @help Should be loaded after YEP_BattleEngineCore.
     *
     * Free to use and/or modify for any project, no credit required.
     */
    void (function() {
    'use strict';
    
      // Require YEP Battle Engine Core.
      if (!Imported.YEP_BattleEngineCore)
        throw new Error(
          "This plugin should be loaded after YEP_BattleEngineCore.\nPress F12 for details."
        );
    
      // Anti-mirror when on left.
      void (function() {
        const alias = Game_Battler.prototype.setMirror;
        Game_Actor.prototype.setMirror = function(value) {
          alias.call(this, value !== this.battler()._homeX < Graphics.boxWidth / 2);
        };
      })();
    
      // Face "forward" on battle start.
      void (function() {
        const alias = Game_Battler.prototype.onBattleStart;
        Game_Actor.prototype.onBattleStart = function() {
          this.spriteFaceForward();
          alias.apply(this, arguments);
        };
      })();
    
    })();
    YES! this seems to do the job! thank you very much for your help this is greate! :D:rock-right:
  20. Woo! Got there in the end~ :kaophew: