MV Making an (actually fun) timing/rhythm-based parry mechanic

So; here's a predicament I've been having:

I don't like not being given the option to avoid attacks. One of my favorite things about games like Undertale, Deltarune, The Mario RPGs, etc. is the ability to Dodge attacks and be more in control of the battle instead of letting RNG decide.

I had been struggling to come up with a good dodge/parry mechanic for my game for awhile, until I thought up something really interesting:

"what if i made it like Taiko/Muse Dash/Unbeatable? A couple lanes and 2 main note types."

Spoiler: A rough mockup of what i imagine Enemy is not depicted)

Basically, You have the 2 lanes, Regular notes, Hold notes, Bash notes (which means you have to mash both keys), Binded notes (Notes that require you to press both keys) and possibly heal notes for if you mess up and SP/MP up notes to heal SP. The charts for the battles would be done with a plugin I'd (probably) have to make myself that can read BPM and know how to change the track of the song from not defending to actively defending (My other idea was adaptive music)

So... i thought this would be a fun idea, right?

well, here's where today's overthinking-induced problem comes in:

To give an example of a game that could use this system, My game is planned to have a variety of battle songs, but I also, at the same time, am worried about how long it will take to MAKE all these songs and make the charts. (I personally would never rely on AI for those things, so let's keep that out of the conversation.)

Then there's the problems that apply to both me and someone who may be making a game with less music. (If I cut back on the battle songs for my game, this could apply to me too.)
What if people get BORED of the Songs and/or charts? There's only so many you can put in, and for a longer game it could get boring.

The only compromise I can think of is making it exclusive to bosses and minibosses, since those are important and thus usually have their own original songs.

Soooo... Do you guys have any better ideas? Am I overthinking the problems? Is this a fun concept? Am I just young and overambitious and need to go back to the drawing board?

Please let me know what you think.


Thanks, Derek "Spacialrended" Bunmore
I'd ask myself first how I plan on executing this plan on a technical level before considering how to handle it on a creative level.

Not to sound like a certain festive cat that prowls the forum, but I'm not entirely sure RPG Maker is a viable route for handling this. Other engines would likely be more suited for this type of gameplay.

Of course, if you have a deep understanding of JS then Bob's your uncle, but without the pockets to pay someone to make this or the knowledge of knowing how you probably want to scale back the idea.
This concept sounds very fun and plenty of other games have also used this concept (look at every rhythm based battle game). In fact, there's already several plugins that make rhythm minigames :
But, there's only been three plugins that I would consider actually "of quality" to use that I've seen.


But this story changes drastically if you want to make your OWN plugin or you can't afford 10$ like me. IMO this would be very VERY hard to implement with rpg maker. I wouldn't say I'm the best person to ask advice from as, self-admittedly, we know rhythm games are possible with plugins yet I couldn't even come close to implementing one. But, from what I know, you would encounter at least 2 large problems making a music rhythm based game with rpg maker.
  1. RPG maker mz and mv runs on their own game time, 60 frames per second. Which means whatever music charts you have on screen could become off-sync with the AudioManager which runs independently from the game logic when the music is playing which is especially bad if you're planning to make a beat map several minutes long and on repeat. I've came up with a solution to this with my plugin: MusicEventTimers, by setting a timestamp in the BGM and having an alarm activate at that point. But it's very rough and buggy and I would suggest you just look at my code and Frankenstein it to a beat map if you're serious about this.
  2. Javascript, what rpg maker runs on, is single threaded, which means that it can only run code line one by one. Most rhythm games are programmed on c# or other multithreaded languages (correct me if I'm wrong). So the best way to try to implement audio tracking would to multithread a process that runs independently from the game logic, so it be less slowed down by any potential lag or issues. But the closest thing in Javascript to multithreading are web workers, promises, and probably some other stuff I'm not aware of. The problem here is that any documented help around that stuff specifically on rpg maker is bare bones and no one actually talks about how to implement it code-wise.
Here's the resources I found that might help you:
Again I'm not the best person to ask but I'm just here to give my two cents on the matter.

As for the actual implementation of battle songs. I would say to go for quality over quantity. It's better to have one memorable song than multiple flops. And I would also suggest to not even attempt something this big if you're not passionate about music making. Passion is something easily sensed by players and they will know if you skimped out on something. Plus, you should study on music theory and the structure and melodies on songs you do like. It's not necessary but it will marginally make up for any lack of experience you may have.
Okay so I've been thinking about this the entire time I've been in the shower because I felt like my entire answer prior earlier was just "haha it's hard good luck."

Instead of trying to overcomplicate anything with asynchronous stuff we just go along with the 60 frames per second game logic Occam's razor style. Every frame we check the AudioManager._bgmBuffer using .seek(). The bgmBuffer holds the object for the current bgm playing and using the .seek() method would tell us the time the bgm is currently at. So we can set loose a "hit" sprite as I'm gonna call it once .seek() reaches a certain point. By checking the bgmBuffer instead of using "wait x frames" we no longer run out of sync of the actual song.

JavaScript:
BattleManager.initMembers = function() {
    this._phase = "";
    this._inputting = false;
    this._canEscape = false;
    this._canLose = false;
    this._battleTest = false;
    this._eventCallback = null;
    this._preemptive = false;
    this._surprise = false;
    this._currentActor = null;
    this._actionForcedBattler = null;
    this._mapBgm = null;
    this._mapBgs = null;
    this._bgmTime = null; //<-- Adds variable to battle manager
    this._isBeatMap = false //<-- Adds bool to battle manager
    this._beatMap = []; //<-- To hold the actual beatMap
    this._actionBattlers = [];
    this._subject = null;
    this._action = null;
    this._targets = [];
    this._logWindow = null;
    this._spriteset = null;
    this._escapeRatio = 0;
    this._escaped = false;
    this._rewards = {};
    this._tpbNeedsPartyCommand = true;
};

const _BattleManager_update = BattleManager.update = function;
BattleManager.update = function(timeActive) { //This update happens EVERY frame
    if (this._isBeatMap) { //If isBeatMap it won't allow anyone to attack...probably
        this._bgmTime = AudioManager._bgmBuffer.seek(); //Updates time with bgm
    } else {_BattleManager_update.call(this, timeActive);}
};

At this point you would probably need to create a JSON file to hold in all your beat map information, like the id of the song, bpm, amount of hits, time of hits, types of hits, etc.

Then you would create a child sprite class that inherits the Sprite_Button class since it already has a method to process button presses.

JavaScript:
function Sprite_Beat() {
    this.initialize(...arguments);
}

Sprite_Beat.prototype = Object.create(Sprite_Button.prototype);
Sprite_Beat.prototype.constructor = Sprite_Beat;
//Since the button class inherits from the clickable class you're gonna have to deal with that
Sprite_Beat.prototype.initialize = function(JSON_Info) {
    Sprite_Button.prototype.initialize.call(this);
    this.beatType = JSON_Info[0];
    this.bpmTime = JSON_Info[1];
    this.row = JSON_Info[2];
    this._clickHandler = JSON_Info[3];
    this._holdHandler = JSON_Info[4];
    this.visible = false;
    this.velocity = 0; //Probably some more stuff to put ngl
    this.distanceToDestination = 0;
};

Sprite_Beat.prototype.buttonData = function() { //I'm not sure if this is the proper way
    const buttonTable = {                       //to overwrite a parent method
        cancel: { x: 0, w: 2 },
        pageup: { x: 2, w: 1 },
        pagedown: { x: 3, w: 1 },
        down: { x: 4, w: 1 },
        up: { x: 5, w: 1 },
        down2: { x: 6, w: 1 },
        up2: { x: 7, w: 1 },
        ok: { x: 8, w: 2 },
        menu: { x: 10, w: 1 }
    };
    return buttonTable[this._beatType];
}; //Stuff inherited from Sprite_Button, you should change it up

Sprite_Beat.prototype.holdHandler = function() {//You need to make this yourself
        this.holdHandler = method;
}

Sprite_Beat.prototype.onClick = function() { //Stuff that happens when the beat is clicked
    if (this._clickHandler && this.beatType === "click") {
        this._clickHandler();
    } else if (this._clickHandler && this.beatType === "hold") { //Added this to handle hold notes
         this.holdHandler();
    } else {
        Input.virtualClick(this._buttonType);
    }
};

Sprite_Beat.prototype.draw = function(x, y, width, height, color) {
        //Draw the actual sprite but idk what to put here
}

At that point you would revisit the BattleManager to create a new method that turns isBeatMap on, parses the JSON file, creates a bunch of Sprite_Beats. And call it when the battle starts or somehow find a way to call it midbattle if you want.

JavaScript:
let beatMapTroops = [1, 2, 3] //<-- Put all the troop ids you intend to put a beat map in

const _BattleManager_startBattle = BattleManager.startBattle;
BattleManager.startBattle = function() {
    _BattleManager_startBattle.call(this);
    if (beatMapTroops.include($gameTroop._troopId)) {//Checks the current troop to the array
        let JSON_Info = null;
        switch case($gameTroop._troopId) {
            case 1:
                JSON_Info = JSON_song1; //You need some sort of parsing method here
                break;
            case...
        }
        this._isBeatMap = true;
        for (let i = 0; i > JSON_Info.length; i++) { //Creates all the sprites for the beat map
            this._beatMap.push(new Sprite_Beat(JSON_Info[i]));}
    }
};

From this point you have to actually animate the sprites to the speed of the bgm most likely through matching velocity with .seek(). But after that I actually have no clue, knowledge, or experience on animation.

ADDITIONALLY, a lot AND I MEAN ALOT of this code is kinda wrong and janky and it's 3 AM. It's only really meant to get the point and intention across 'cause I really don't have that much knowledge on object inheritance, game logic, and ESPECIALLY on how to access JSON file information. I'd say I made some easy to mildly complex plugins, most taking around 30ish hours to make, but this easily crosses into the 50-150 hour territory unless you want to make some glorified QTE plugin. The only reason I'm able to spend so much time on plugins is because I truly enjoy creating something with my own hands. But you first have to learn a lot about programming but then you have to learn about how RPG Maker runs and then code and debug A LOT. This ain't the for the faint of heart and I wish you the best of luck. And if you do end up making it... you mind hooking a homie up with a free plugin??? I lowkey kinda need this too lol.

Edit: Btw I'm on mz so the code might be different from yours.
Okay so I've been thinking about this the entire time I've been in the shower because I felt like my entire answer prior earlier was just "haha it's hard good luck."

Instead of trying to overcomplicate anything with asynchronous stuff we just go along with the 60 frames per second game logic Occam's razor style. Every frame we check the AudioManager._bgmBuffer using .seek(). The bgmBuffer holds the object for the current bgm playing and using the .seek() method would tell us the time the bgm is currently at. So we can set loose a "hit" sprite as I'm gonna call it once .seek() reaches a certain point. By checking the bgmBuffer instead of using "wait x frames" we no longer run out of sync of the actual song.

JavaScript:
BattleManager.initMembers = function() {
    this._phase = "";
    this._inputting = false;
    this._canEscape = false;
    this._canLose = false;
    this._battleTest = false;
    this._eventCallback = null;
    this._preemptive = false;
    this._surprise = false;
    this._currentActor = null;
    this._actionForcedBattler = null;
    this._mapBgm = null;
    this._mapBgs = null;
    this._bgmTime = null; //<-- Adds variable to battle manager
    this._isBeatMap = false //<-- Adds bool to battle manager
    this._beatMap = []; //<-- To hold the actual beatMap
    this._actionBattlers = [];
    this._subject = null;
    this._action = null;
    this._targets = [];
    this._logWindow = null;
    this._spriteset = null;
    this._escapeRatio = 0;
    this._escaped = false;
    this._rewards = {};
    this._tpbNeedsPartyCommand = true;
};

const _BattleManager_update = BattleManager.update = function;
BattleManager.update = function(timeActive) { //This update happens EVERY frame
    if (this._isBeatMap) { //If isBeatMap it won't allow anyone to attack...probably
        this._bgmTime = AudioManager._bgmBuffer.seek(); //Updates time with bgm
    } else {_BattleManager_update.call(this, timeActive);}
};

At this point you would probably need to create a JSON file to hold in all your beat map information, like the id of the song, bpm, amount of hits, time of hits, types of hits, etc.

Then you would create a child sprite class that inherits the Sprite_Button class since it already has a method to process button presses.

JavaScript:
function Sprite_Beat() {
    this.initialize(...arguments);
}

Sprite_Beat.prototype = Object.create(Sprite_Button.prototype);
Sprite_Beat.prototype.constructor = Sprite_Beat;
//Since the button class inherits from the clickable class you're gonna have to deal with that
Sprite_Beat.prototype.initialize = function(JSON_Info) {
    Sprite_Button.prototype.initialize.call(this);
    this.beatType = JSON_Info[0];
    this.bpmTime = JSON_Info[1];
    this.row = JSON_Info[2];
    this._clickHandler = JSON_Info[3];
    this._holdHandler = JSON_Info[4];
    this.visible = false;
    this.velocity = 0; //Probably some more stuff to put ngl
    this.distanceToDestination = 0;
};

Sprite_Beat.prototype.buttonData = function() { //I'm not sure if this is the proper way
    const buttonTable = {                       //to overwrite a parent method
        cancel: { x: 0, w: 2 },
        pageup: { x: 2, w: 1 },
        pagedown: { x: 3, w: 1 },
        down: { x: 4, w: 1 },
        up: { x: 5, w: 1 },
        down2: { x: 6, w: 1 },
        up2: { x: 7, w: 1 },
        ok: { x: 8, w: 2 },
        menu: { x: 10, w: 1 }
    };
    return buttonTable[this._beatType];
}; //Stuff inherited from Sprite_Button, you should change it up

Sprite_Beat.prototype.holdHandler = function() {//You need to make this yourself
        this.holdHandler = method;
}

Sprite_Beat.prototype.onClick = function() { //Stuff that happens when the beat is clicked
    if (this._clickHandler && this.beatType === "click") {
        this._clickHandler();
    } else if (this._clickHandler && this.beatType === "hold") { //Added this to handle hold notes
         this.holdHandler();
    } else {
        Input.virtualClick(this._buttonType);
    }
};

Sprite_Beat.prototype.draw = function(x, y, width, height, color) {
        //Draw the actual sprite but idk what to put here
}

At that point you would revisit the BattleManager to create a new method that turns isBeatMap on, parses the JSON file, creates a bunch of Sprite_Beats. And call it when the battle starts or somehow find a way to call it midbattle if you want.

JavaScript:
let beatMapTroops = [1, 2, 3] //<-- Put all the troop ids you intend to put a beat map in

const _BattleManager_startBattle = BattleManager.startBattle;
BattleManager.startBattle = function() {
    _BattleManager_startBattle.call(this);
    if (beatMapTroops.include($gameTroop._troopId)) {//Checks the current troop to the array
        let JSON_Info = null;
        switch case($gameTroop._troopId) {
            case 1:
                JSON_Info = JSON_song1; //You need some sort of parsing method here
                break;
            case...
        }
        this._isBeatMap = true;
        for (let i = 0; i > JSON_Info.length; i++) { //Creates all the sprites for the beat map
            this._beatMap.push(new Sprite_Beat(JSON_Info[i]));}
    }
};

From this point you have to actually animate the sprites to the speed of the bgm most likely through matching velocity with .seek(). But after that I actually have no clue, knowledge, or experience on animation.

ADDITIONALLY, a lot AND I MEAN ALOT of this code is kinda wrong and janky and it's 3 AM. It's only really meant to get the point and intention across 'cause I really don't have that much knowledge on object inheritance, game logic, and ESPECIALLY on how to access JSON file information. I'd say I made some easy to mildly complex plugins, most taking around 30ish hours to make, but this easily crosses into the 50-150 hour territory unless you want to make some glorified QTE plugin. The only reason I'm able to spend so much time on plugins is because I truly enjoy creating something with my own hands. But you first have to learn a lot about programming but then you have to learn about how RPG Maker runs and then code and debug A LOT. This ain't the for the faint of heart and I wish you the best of luck. And if you do end up making it... you mind hooking a homie up with a free plugin??? I lowkey kinda need this too lol.

Edit: Btw I'm on mz so the code might be different from yours.
thank you so much! I might either come back to this in a while when I’m more knowledgeable of js or just scrap it for something else, honestly, but I really appreciate your assistance in showing that it’s possible! The framerate is definitely a massive issue not just in rpgmaker but any rhythm game, and I want the experience to be enjoyable ^^’ if I do end up making it I’ll definitely let you know! I might take js classes over summer.
RPGs generally have bosses with high hp and no healing, while players have fairly low max hp but tons of healing. Sometimes it's so abysmally low that you need dedicated hp gear just to take 1 hit, and sometimes healing sucks. This is highly incompatible with skill-based damage mitigation.

You create 2 hard issues when combining these together: 1 is a hard skill requirement for how consistently successful a player has to be to even be worthy of surviving more than 1 round. The other is a direct and exponential difference in turn economy between perfect play and bad play. If you need to spend nearly all your actions every round healing the damage you take, then you'll take 20 times longer than someone who completely ignores healing and parries everything.

At least when used as bonus damage on bosses, it's easier to avoid softlocks. There's a guaranteed minimum damage, and there won't be completely useless rounds.

What I recommend is generating resources that changes depending on the song, and only playing short segments of the chart that depends on when the minigame was activated in the song. And these resources could potentially be used by the enemy as well.

Original thread: https://forums.rpgmakerweb.com/threads/making-an-actually-fun-timing-rhythm-based-parry-mechanic.182499/