Guaranteed Critical if Affected with State

Shinma

Lurker
Veteran
Joined
Dec 29, 2012
Messages
756
Reaction score
341
First Language
English
Primarily Uses
RMMV
I want to add a guaranteed critical hit if a player/battler is affected by state.

I figure it will be in the damage formula for the Attack skill, and I have a rough idea of how it should look. Would anyone mind correcting the below? I imagine it would look something like this, but I know I am missing parts of the syntax.

If b.state = 11 then critical hit = 100% | a.atk * 4 - b.def *2

Thanks!!
 

JtheDuelist

Your Friendly Nieghborhood Stygian Zinogre
Veteran
Joined
Dec 9, 2017
Messages
1,185
Reaction score
1,440
First Language
English
Primarily Uses
Other
b.state would mean the target of the attack has the state, not the user. For the user to have the state in the calculation, use a.state.
 

Traveling Bard

The Bard
Veteran
Joined
Jul 4, 2012
Messages
565
Reaction score
491
First Language
English
Primarily Uses
I'm at work and can't test but something like this perhaps?

c = a.atk * 4 - b.def *2; a.isStateAffected(11) ? c*2 : c

edit:
a.isStateAffected(11) if you want to check the user of the skill for state 11
b.isStateAffected(11) if you want to check the target of the skill for state 11
 
Last edited:

Shinma

Lurker
Veteran
Joined
Dec 29, 2012
Messages
756
Reaction score
341
First Language
English
Primarily Uses
RMMV
@JtheDuelist That's correct. Essentially, if something has the sleep state on them, I want a physical attack to do a critical hit.

@Traveling Bard I'll check and let you know. Thanks!

Edit. Yeah, I corrected the target part to represent the enemy. It does extra damage, but it is not a critical hit.
 
Last edited:

Traveling Bard

The Bard
Veteran
Joined
Jul 4, 2012
Messages
565
Reaction score
491
First Language
English
Primarily Uses
b.isStateAffected(11) ? (a.atk * 4 - b.def *2 )*2 : a.atk * 4 - b.def *2


I've had to play around with damage formula logic a bit to get things you'd think should work to work. Likely my inexperience haha anywho, try the above. It's essentially the same thing just written out more. If that doesn't work, I'll give it a few spins when I get home in a few hours.
 

Shinma

Lurker
Veteran
Joined
Dec 29, 2012
Messages
756
Reaction score
341
First Language
English
Primarily Uses
RMMV
Yeah, that was essentially what I changed it to earlier. It does do the extra damage, it just doesn't register as a critical hit (changing the color of the text, etc.), so the player would see the additional damage, but not make the connection that it is a crit.
 

Traveling Bard

The Bard
Veteran
Joined
Jul 4, 2012
Messages
565
Reaction score
491
First Language
English
Primarily Uses
Oh, gotcha. Instead of what I have showed you so far just leverage this plugin from yanfly:

http://yanfly.moe/2015/11/08/yep-26-critical-control/

Put the appropriate notetag under the sleep state and just crank up the critical rate for your use cases up to 100%. You'll need his damage core plugin as well but that should get you what you are looking for here.
 

Shinma

Lurker
Veteran
Joined
Dec 29, 2012
Messages
756
Reaction score
341
First Language
English
Primarily Uses
RMMV
I looked at that, but I think it works as a buff and not a debuff. Meaning, if I set a notetag on sleep to set the critical rate at say 999% to ensure a critical, then I would need to be under the effect of asleep to get the change in critical rate.

I'll give it a try and see if I can adjust it.
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,624
Reaction score
5,104
First Language
English
Primarily Uses
RMVXA
I would avoid @Traveling Bard's approach because, while it's clever, it will either make it impossible to land a "normal" Crit (if you choose "Critical: No") or make it possible to land a "double Crit" that deals 600% damage (if you choose "Critical: Yes" and the normal Crit calculation also succeeds).

I believe that the "Critical" property of an action can actually be changed at any point before the attack's results are finalized, meaning that you could just set the Critical property to true as part of the damage formula if the user (a) or target (b) is affected by the given State. I've never played around with Action Result properties in MV before so I don't know the syntax - maybe someone can help provide this?

Alternatively, a relatively simple change to the code base to always score the Crit. In the function Game_Action.prototype.itemCri (rpg_objects.js) the chance of a skill landing a Crit is determined (by default this is the same for any skill that can crit). You can change this method to automatically return a 1 (or even higher, like 9999) if the target is asleep and the skill is something that will crit whenever the target is asleep.
 

Traveling Bard

The Bard
Veteran
Joined
Jul 4, 2012
Messages
565
Reaction score
491
First Language
English
Primarily Uses
Thanks, @Wavelength! You gave me an idea with that critical property being set in the damage formula part.

I'm now emotionally invested in solving this with a damage formula!

Try this: if (b.isStateAffected(11)) b.result().critical = true; a.atk * 4 - b.def *2
 

Shinma

Lurker
Veteran
Joined
Dec 29, 2012
Messages
756
Reaction score
341
First Language
English
Primarily Uses
RMMV
We are so close!

I get the critical hit in regards to it changing the color, but it only does normal damage.

Edit*

I understand the basic concepts of programming, so I understand that ?: is the equivalent of an if/then statement. I think that ; ends a statement and starts a new one?

I am not 100% sure of where the critical gets it's value. I know that the critical damage is * 3.

Maybe it derives it's value from the dmg formula so we should set it first?

Sidenote, in case anyone is testing it. The state is actually 10, I incorrectly set it as 11 in the first post.
 
Last edited:

Traveling Bard

The Bard
Veteran
Joined
Jul 4, 2012
Messages
565
Reaction score
491
First Language
English
Primarily Uses
Ok... this is going to sound crazy... but try this:

c = (a.atk * 4 - b.def *2); if (b.isStateAffected(10)){ b.result().critical = true; c*=3;} c

That should mimic a critical which I believe is 300% normal damage. Just change what c is multiplying by if you want to tweak that...

@Wavelength, would doing this give the possibility for double critical too? I guess it can be tested by setting a piece of equipment to 100% critical rate and swinging a few times.

You know, couldn't you also just set the sleep state to have a negative critical evasion parameter/trait?
 

Shinma

Lurker
Veteran
Joined
Dec 29, 2012
Messages
756
Reaction score
341
First Language
English
Primarily Uses
RMMV
That did indeed work!

I did think about the negative critical evasion, but I think that skill is set to dodge critical hits.

Edit* I tested it by setting CEV to - 999% on the Sleep state and every hit was still a normal hit.

BUT that gave me an idea. I went back and used your formula that was providing the color change but still doing base damage, and added 300% physical damage to the Sleep state. By doing so I was able to get the red text, deal 300% damage and ensure as not to get double criticals!

I really appreciate both of you helping me solve this issue!!
 
Last edited:

Junane

Veteran
Veteran
Joined
Feb 10, 2018
Messages
86
Reaction score
10
First Language
English
Primarily Uses
RMMV
If you have the action sequence and critical control plugins from Yanfly (the latter requires the Damage Core), there's an action sequence command to "force critical". Using "if target.isStateAffected(10)" (10 is the default ID for Sleep) before it will check for your target to have the sleep state then guarantee a critical hit.
 

Shinma

Lurker
Veteran
Joined
Dec 29, 2012
Messages
756
Reaction score
341
First Language
English
Primarily Uses
RMMV

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,591
Reaction score
1,168
First Language
English
Primarily Uses
RMMV
Sorry for the bump, but I was just wrestling w/ this problem myself today and figured out a simple solution that also resolves the double critical issue.
It requires Yanfly's Critical Control plugin, which of course also requires his Damage Core plugin. Here's the code:

<Critical Rate Formula>
if (target.isStateAffected(73)) {
rate = 1;
}
</Critical Rate Formula>

My state ID was 73, you should obviously change it to w/e suits your needs.
 
Last edited:

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

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,849
Messages
1,016,981
Members
137,563
Latest member
cexojow
Top