RMMV Wondering about generalising substitute/guard effects

SunshineMoon

Itinerant Gadabout
Member
Joined
Jun 30, 2020
Messages
11
Reaction score
9
First Language
English
Primarily Uses
RMMV
Hi! So I've got a project going that's currently using this plugin, which is honestly great because MV's default 'Substitute' effect is pretty limited--


--but what I'm trying to do is rather than have a specific skill that temporarily lets one character guard another, as this plugin does, instead I just have that character A always guards for character B throughout the game (as long as they're in the party and not knocked out). So far I've been accomplishing this by having the skill that applies the subsitute state be automatically used at the start of the tutorial fight, and given the state no removal conditions so it stays for the rest of the game. However! The plugin, or possibly MV itself, seems to regard substituting (one character taking an attack in another's place) as an active thing that character does, and thus when the guarding character is hit with a state that inflicts "cannot move", they are unable to do this, and the guarded character can be hit normally.

So short of removing all "cannot move" states from the game, I figured the solution would be to go into the plugin code and find the bit that says "when character A has state X, character B takes damage instead of character A" and just chop it and all the options and bells and whistles out so I just have the bit that says "character B takes damage instead of character A" and make that a mini-plugin for this project. I haven't really coded before, but I'm familiar with the kind of logic it uses and was thinking I'd start to learn by making this project, so I figured I could probably find it...buuuuut of course that was overconfidence and my eyes are glazing over trying. Am I at all on the right track?

TLDR: Is there a bit of code in the above plugin I can yank out and slap in its own text file that just says "actor A guard actor B" and with no caveats have that active throughout? (Would still credit that plugin's creator ofc) Or is this not as simple as I'm hoping and I'd have to build my own plugin for real?
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
7,555
Reaction score
5,324
First Language
English
Primarily Uses
RMMV
You can do this by putting notetags from the TAA plugin into a Yanfly Auto Passive State, and leave the state on the character for the entire game.

You might still need help with a miniature plugin to allow them to substitute while under a Cannot Move effect, but that's true regardless.

You could also use passive states and notetags from Yanfly's Buffs & States to route all of player B's damage to player A, but that wouldn't graphically show them moving to substitute or anything.
 

SunshineMoon

Itinerant Gadabout
Member
Joined
Jun 30, 2020
Messages
11
Reaction score
9
First Language
English
Primarily Uses
RMMV
Aha, I see! Good points...I guess it'd take some figuring because the way knockout works in MV is that it is also a "cannot move" state, so I'd have to tell the guard state to differentiate between a cannot-move state that does prevent guarding (knockout) and one that doesn't (anything else).

That last idea honestly might work fine though, if I'm clear enough in the intro section that "this is just how this game works always". I wonder if that would account for knockout given the above, actually...I guess it would look something like, (in actor's notes) "Custom Select Effect/(code that stores the damage number)/(code that turns this damage to zero)/(code that retrieves the stored number and deals it as damage to the guard)". Though I guess that wouldn't transfer stuff like inflicted states. Maybe there's just a line of code that directly tells it "change attack target", actually. Sorry, you're getting the real newb questions here, haha.

Thanks for the pointers!
 
Last edited:

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
7,555
Reaction score
5,324
First Language
English
Primarily Uses
RMMV
If your end goal is simply that character B can never be targeted for attacks while A is alive, why don't you just use something like Yanfly's Taunt plugin?

Give A a passive state that Taunts all attack types, then as long as they're alive they're the only valid target.
 

SunshineMoon

Itinerant Gadabout
Member
Joined
Jun 30, 2020
Messages
11
Reaction score
9
First Language
English
Primarily Uses
RMMV
That's a good idea! It would be...slightly more restrictive, in the sense that...like, if later on in the game the party becomes A (guard), B (guarded), C (temporary ally who isn't really invested in their personal dynamic), then if it was taunt, either A would be tanking for both of them, or C would have taunt state as well and they would both block for B.

Whereas if it was a true substitute state like here, it could be the more nuanced situation (expressing the character dynamic via mechanics) in which A will block for B, but C won't, so it becomes "either A or C can be targetted, until A goes down, at which point either B or C can be targetted". (Which is why I haven't brought this up before, because substitute doesn't affect other actors than the two involved).

If it's too much trouble though, yeah, I might just not worry too much about that section of the game and use taunt.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
7,555
Reaction score
5,324
First Language
English
Primarily Uses
RMMV
I think you've way over-complicated things for yourself in your original post. You did all this stuff about trying to modify the plugin and make your own plugin and pull code out and...stuff.

All you want is to allow substitution when they have a Cannot Move state on, which has nothing to do with TAA's plugin. And then it wasn't clear that you had other party members, so every other idea thrown at you pulled you further away from your goal.

The only thing that needs doing is to remove one word from the base engine. Paste this into a .js file and include it as a plugin:
Code:
Game_BattlerBase.prototype.isSubstitute = function() {
    return this.specialFlag(Game_BattlerBase.FLAG_ID_SUBSTITUTE);
};
 

SunshineMoon

Itinerant Gadabout
Member
Joined
Jun 30, 2020
Messages
11
Reaction score
9
First Language
English
Primarily Uses
RMMV
Yeah, I was trying to detail out my thought process and show "ooh look I think I know the direction to go, ain't I proactive", but I guess just asking "how do" would've been simpler.

As mentioned, if it's just a flat "substitution allowed when Cannot Move is on", will that cause problems with how Knockout is also a Cannot Move state (i.e. I don't want a knocked out character on 0 health still tanking damage)?

I appreciate your patience with me, in any case.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
7,555
Reaction score
5,324
First Language
English
Primarily Uses
RMMV
will that cause problems with how Knockout is also a Cannot Move state
Death automatically wipes states off of battlers, so it shouldn't. If they're getting the Substitute from something else, or you're using a plugin to force states to persist through death, you can add && !this.isDead() before the semicolon.
 

SunshineMoon

Itinerant Gadabout
Member
Joined
Jun 30, 2020
Messages
11
Reaction score
9
First Language
English
Primarily Uses
RMMV
You're a lifesaver!
 

Latest Threads

Latest Posts

Latest Profile Posts

Been hard at work trying to make more tactical aspects of the game a reality, if all goes well the Player, depending on the faction they choose, will;
Suffer little to no penalty for escaping battle.
Be able to manually speed up resource gathering.
Steal Special projects from rival Factions.
Slowly but surely the game dev streams accomplish the goal.... actually finishing the game. :LZSexcite:



Going to start in about 15 minutes or so for anybody interested. And of course you know you are, well at least you know now because it's been stated that you are, and obviously anything randomly stated on the Internet must be true right? :LZSwink:
Rag-Tag Team Unite!!!
Fantast4.png

The questionable end result of a fun shared desing challenge together with @spillycat xD
9 days left for Harold Jam... hope it's not too late to start gam mak

Forum statistics

Threads
129,753
Messages
1,204,837
Members
170,840
Latest member
PeachyNCream
Top