Display actions left in battle?!

Benji01

Veteran
Veteran
Joined
Jun 7, 2015
Messages
104
Reaction score
8
First Language
German
Primarily Uses
Hey,
So you know how an actor (or enemy) in standard MV battle system can have % more actions.
Like let's say my character has 2 x 100%+ actions, which means the actor is on 3 actions in total.

Can I somehow display how many actions my character has left? A little extra window or addition to default hud would do.
 

Magnus0808

Software Developer
Veteran
Joined
Feb 2, 2019
Messages
147
Reaction score
166
First Language
Danish
Primarily Uses
RMMV
I made a plugin that can do this. I didn't add any plugin parameters, however if there is something you would like to be able to change through these parameters let me know and I will add it.

Currently it shows a small window with the text "Actions left: X".

If you have any questions or requests for changes feel free to ask. :)

Code:
//=============================================================================
// ActionAmount.js
//=============================================================================

/*:
 * @plugindesc This plugin adds a window that shows how many actions an actor
 * has left on his/her turn.
 * @author Magnus0808
 *
 * @help Plug and play
 */
(function() {
    
    
    //-----------------------------------------------------------------------------
    // Window_Action
    //
    // The window for displaying the current actors actions left
    
    function Window_Action() {
        this.initialize.apply(this, arguments);
    }
    Window_Action.prototype = Object.create(Window_Base.prototype);
    Window_Action.prototype.constructor = Window_Action;
    
    Window_Action.prototype.initialize = function(x, y) {
        var width = this.windowWidth();
        var height = this.windowHeight();
        Window_Base.prototype.initialize.call(this, x, y, width, height);
        this.refresh();
    };
    
    Window_Action.prototype.windowWidth = function() {
        return 240;
    };

    Window_Action.prototype.windowHeight = function() {
        return this.fittingHeight(1);
    };
    
    Window_Action.prototype.refresh = function() {
        var x = this.textPadding();
        var width = this.contents.width - this.textPadding() * 2;
        this.contents.clear();
        this.drawActionValue(this.value(), x, 0, width);
    };
    
    Window_Action.prototype.value = function() {
        if (this.actor) {
            this.show();
            console.log(this.actor);
            if(this.actor._actCostInputs) { // Added compatibility to DoubleX RMMV Action Cost
                return this.actor.numActions() - (this.actor._actionInputIndex + this.actor._actCostInputs);
            } else {
                return this.actor.numActions() - this.actor._actionInputIndex;
            }
        } else {
            this.hide();
            return 0;
        }
    }
    
    Window_Action.prototype.setActor = function(actor) {
        this.actor = actor;
        this.refresh();
    }
    
    Window_Action.prototype.drawActionValue = function(value, x, y, width) {
        this.drawText("Actions left: " + value, x, y, width, 'left');
    }
    
    Window_Action.prototype.open = function() {
        this.refresh();
        Window_Base.prototype.open.call(this);
    };
    
    
    //-----------------------------------------------------------------------------
    // Scene_Battle
    //
    // Added the Windoe_Action to the scene.
    
    Scene_Battle.prototype.createAllWindows = function() {
        this.createLogWindow();
        this.createStatusWindow();
        this.createPartyCommandWindow();
        this.createActorCommandWindow();
        this.createHelpWindow();
        this.createSkillWindow();
        this.createItemWindow();
        this.createActorWindow();
        this.createEnemyWindow();
        this.createMessageWindow();
        this.createScrollTextWindow();
        this.createActionWindow();
    };
    
    Scene_Battle.prototype.createActionWindow = function() {
        this._actionWindow = new Window_Action(0, 0);
        this._actionWindow.y = this._actorWindow.y - this._actionWindow.height;
        this.addWindow(this._actionWindow);
    }
    
    Scene_Battle.prototype.selectPreviousCommand = function() {
        BattleManager.selectPreviousCommand();
        this._actionWindow.setActor(BattleManager.actor());
        this.changeInputWindow();
    };
    
    Scene_Battle.prototype.selectNextCommand = function() {
        BattleManager.selectNextCommand();
        this._actionWindow.setActor(BattleManager.actor());
        this.changeInputWindow();
    };
        

})();
 

Attachments

Last edited:

Benji01

Veteran
Veteran
Joined
Jun 7, 2015
Messages
104
Reaction score
8
First Language
German
Primarily Uses
Okay - so this is kind of emberassing and pretty much a noob mistake from me, I maybe should have mentioned I intended to use this feature together with another plugin.
First of all, thank you so much for taking the time and making this for me.

I was thinking I could maybe turn my combat in some sort of action-point system, using a plugin to display the actions left together with
https://forums.rpgmakerweb.com/index.php?threads/doublex-rmmv-action-cost.60556/#post-650318

This plugin, that makes it so that actions can cost more than 1 point per turn. So my theory was, that there wouldn't be any compatibility issues.
Well technically there aren't any, but I made an example project to test it out, and it doesn't decrease the number of actions by the number of actions the skill cost. So for example, Harold's Heal Magic cost 2 actions, and if I select it, it will display (3 actions left) (harold had 4 actions in the beginning), and then I use it again and it will start the turn, using Heal Magic 2 times, even tho it displayed 3 actions left last time I checked.

... is it a far stretch to combat this compatibility problem? :(
If not it's fine, and thanks still a lot!
 
Last edited:

Magnus0808

Software Developer
Veteran
Joined
Feb 2, 2019
Messages
147
Reaction score
166
First Language
Danish
Primarily Uses
RMMV
I added compatibility with DoubleX RMMV Action Cost to the plugin. Turned out it added a _actCostInputs value to the actor to keep track of how many "extra" actions he/she had taken. :)

I have edited my original reply with the changes.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

On my journey of character rework: I had this character, she was meant to be just a princess that joins your party. And at long term she was just uninteresting... So I tweaked her to be a rebel agaisn't the royalty before meeting up with the party.

Quick tip for any other ametuer pixel artists! When trying to create a colour palette, enabling Antialiasing can speed up the process of creating different shades! Just place your lightest colour and your darkest colour next to each other, select both pixels, and stretch it out!
Revolutionizing the JRPG Industry: Knocking on Doors.

Take that, murderhobos.
Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.

Forum statistics

Threads
106,054
Messages
1,018,580
Members
137,843
Latest member
Betwixt000
Top