MV Forcing a Critical Hit effect on hitting Elemental Weaknesses??

Hello! Wasnt sure if this warranted a thread or if this was the right place to post, but since Im stumped I figured Id reach out!! So, Ive been working on my game in RPG MV a lot lately and as Ive moved further and further into the design of the game, Ive steadily been overhauling Criticals to be more and more important. On top of draining the MP of an enemy, which Ive got implemented pretty well, one way Ive been considering was some kind of global passive effect to guarantee a Crit effect whenever you hit the enemy's elemental weakness, but Im not entirely sure how to get that implemented right?? If there are any plugins or if anyone could give me an idea about where to start with scripting such a thing, Id appreciate the input a lot!! Javascript definitely isnt my strong suit yet so any help here would be a godsend honestly

Using most of Yanfly's RPGMV plugin library and a number of other ones, so I was hoping to make something work with its Buffs/States Core and Auto Passive States plugins, always welcome to try out new things tho!!

P.S. just using the Default Battle System, if that helps any 🙂
Yanfly's skill rewards plugin has a thing for that
Firstly, please take these with a grain of salt, as I am a novice. -_-'

I think if you're going the auto-passive states route, you could do something like this (requires the YEP Buff/States Core) but just edit the coloured values to match your game's own values:

Spoiler: Script
<Custom React Effect>
var elementId = this.item().damage.elementId;
if (elementId < 0) {
var elements = this.subject().attackElements();
}
else {
var elements = [elementId];
}

for (var i = 0; i < elements.length; i++) {
var elementId = elements;
if (elementId > 0 && target.elementRate(elementId) >= 2.0) {
value *= 3.0;
target.result().critical = true;
}
}
</Custom React Effect>

Full disclosure: this code was adapted from one of the example skills in the Fallen Angel Olivia's OctoPack Battler Sample Project.

Essentially you're checking an incoming attack to see if it contains any elements which matches your weakness rate (the element weakness rate above is set to 200%), and if there is a match, it would then multiply the DMG by your critical multiplier (in the above example, it is set to 300%).

BUT I believe there might (?) be some issues if you have multiple elements interacting with one another, so you might have to adjust for that.


Alternatively if you don't have that many elemental skills, you could also just use YEP Critical Control formula, and put the following notetags in ALL (the main downside of this approach) your elemental skills while adjusting the coloured text accordingly:

Spoiler: Notetag
<Critical Rate Formula>
if ( target.elementRate(elementId) >= 2.0 ) {
rate = 1.00;
}
</Critical Rate Formula>

This will check the specified elemental rate of the target, and adjust the critical rate accordingly.
Hi thank you guys for getting back to me so soon! I got busy working on other parts of the game outside of combat and Ive been looking at good options to help me learn Javascript more, so I didnt have time to test either of your suggestions recently but just got going today!!!
Yanfly's skill rewards plugin has a thing for that
Ive been using this extensively, thats actually how I have Crits set up to gain MP back, among other things!! Very good plugin and Im glad more people are using it 🙂 Unfortunately so far it seems that the skill rewards plugin seems to only apply effects to the user, not the target themselves. Although I may not be using it to it's fullest or have something wrong so you may be right. Will look more into this. The plugin's "Rolling Criticals" effect is the closest thing to what Im hoping for, although for some reason, at best it's only guaranteeing the NEXT attack that hits an enemy's weakness is a Critical. Might just be a me problem tho LOL
Firstly, please take these with a grain of salt, as I am a novice. -_-'

I think if you're going the auto-passive states route, you could do something like this (requires the YEP Buff/States Core) but just edit the coloured values to match your game's own values:

Spoiler: Script
<Custom React Effect>
var elementId = this.item().damage.elementId;
if (elementId < 0) {
var elements = this.subject().attackElements();
}
else {
var elements = [elementId];
}

for (var i = 0; i < elements.length; i++) {
var elementId = elements;
if (elementId > 0 && target.elementRate(elementId) >= 2.0) {
value *= 3.0;
target.result().critical = true;
}
}
</Custom React Effect>

Full disclosure: this code was adapted from one of the example skills in the Fallen Angel Olivia's OctoPack Battler Sample Project.

Essentially you're checking an incoming attack to see if it contains any elements which matches your weakness rate (the element weakness rate above is set to 200%), and if there is a match, it would then multiply the DMG by your critical multiplier (in the above example, it is set to 300%).

BUT I believe there might (?) be some issues if you have multiple elements interacting with one another, so you might have to adjust for that.

Alternatively if you don't have that many elemental skills, you could also just use YEP Critical Control formula, and put the following notetags in ALL (the main downside of this approach) your elemental skills while adjusting the coloured text accordingly:

Spoiler: Notetag
<Critical Rate Formula>
if ( target.elementRate(elementId) >= 2.0 ) {
rate = 1.00;
}
</Critical Rate Formula>

This will check the specified elemental rate of the target, and adjust the critical rate accordingly.
Novice or not this definitely helped a lot!! I'm pretty god awful at Javascript right now so even getting closer to the solution and seeing how things interact more helps and you definitely seem to get this more than me :') Although neither of these approaches seemed to work right for me it definitely got me thinking and on a train of thought that Im gonna be following up on.

I successfully implemented a state a while ago that forces any damage the target takes to deal Critical damage (think it was copied from the "Critical Vulnerability" state that Yanfly had up on their Tips & Tricks page??? Been a while since i even looked at the state since it works with no problem tbh), so I think I need to cannibalize that and play around with the Custom React Effect script you built for me and see if those two things can play well together. Id actually been thinking about checking the OctoBattler stuff since i bought a number of Fallen Angel Olivia's plugins a while ago and there's definitely a lot going on to use there. Unfortunately I am, again, quite bad at scripting and have 3 separate Physical-type elements and 9 Elemental-type elements in play with a number of skills being multi-element skills, so that might be contributing to the calculations being kinda uh... messy LOL

But anyways thank you so much! Getting closer at all is great ahhh
You should be able to do this in Yanfly's Damage Core without having to type anything into any skills, enemies, or states. Just add a step before you set target.result().critical
You should be able to do this in Yanfly's Damage Core without having to type anything into any skills, enemies, or states. Just add a step before you set target.result().critical
Oooh thank you! Will definitely have to try that out!! That sounds really sound and weirdly simple, weirdly enough I hadnt really looked at the way damage is calculated within the Damage Core plugin itself much so thank you thank you 🙂

Also just realized there was another Yanfly plugin I was neglecting which was the "Lunatic Pack- Critical Sway" which has a bunch of options to calculate Critical Rate, including giving bonuses to crit chances depending on how high/low elemental resistances are, which sounds shockingly easy to make work for making sure hitting weaknesses creates criticals.

Gonna do some more testing and if any of this bears fruit this can probably be closed soon, thank all 3 of you so much!!!!! :3

Original thread: https://forums.rpgmakerweb.com/threads/forcing-a-critical-hit-effect-on-hitting-elemental-weaknesses.146086/