Tie Attack Times to Stat?

In my RPG I want to implement a mechanic where the Attack Times trait is associated with a particular stat. In this case, Luck.

Here's how I want it to work: For each point of Luck, there's a 2% chance you'll make an extra attack. This keeps increasing until the stat hits 50, at which point it's guaranteed to hit twice, and every point above 50 is a 2% chance you'll make a third attack. Any idea how I can get this mechanic to work? I'm good at basically everything about MV except using Javascript, so any help would be appreciated. If there's a plugin that does this already I haven't found it yet.
This would be fairly difficult without using plugins. There is a parameter called Action Times +, but it applies to both double and triple actions (so a 50% means a 50% chance of a second attack and a 25% of a third attack).

If you're okay with that functionality, you could use Yanfly's Auto Passive States, although I don't know how to set Action Times + through a script call. If you aren't okay with that functionality, I'm not sure how else to approach that unless you use Yanfly's Instant Cast, but you'd have to take all actions consecutively, and this can really mess with combat flow.

If you aren't attached to the core battle system, Olivia's Battle System can accomplish this quite easily, although it does cost money.
you need battle seqPacks 1, 2, 3, than run on lunatic notetag.

0.02 = 2% where 1 = 100%, 0.5 = 50%.

so it is possible what you want to do, but I dont know any lunatic code.
I dont know if there is a snippet of a second attack of the tip and trick list
of yanfly how to approach it, unsure if you need autopassive state though.
as it is more based on the battle than the state you use.
There is a parameter called Action Times +
I'm pretty sure that's not the same thing. I haven't used it in my own project, but my understanding is that Action Times will make it the actor's turn again and allow them to select another action, which is not what the OP wanted (to change the number of hits within one action).

I suppose you could try combining it with applying a state that sealed all skills except the one you want the player to use again, as well as apply Auto-Battle so they don't actually see the selection. But I think that might still look janky from a player interface perspective, as you might see the actor moving back and forth and see the name of the skill in the battle log again, etc.

In any case, ShadowDragon's suggestion of Action Sequences is also what I'd do.

Inside of the target action, you could do something like:
Code:
if (Math.randomInt(50)<user.luk)
    action effect
end
if (user.luk>50 && Math.randomInt(50)<user.luk-50)
    action effect
end

And, of course, where it says action effect you would put all of the stuff you want to happen again.
I'm pretty sure that's not the same thing. I haven't used it in my own project, but my understanding is that Action Times will make it the actor's turn again and allow them to select another action, which is not what the OP wanted (to change the number of hits within one action).

I suppose you could try combining it with applying a state that sealed all skills except the one you want the player to use again, as well as apply Auto-Battle so they don't actually see the selection. But I think that might still look janky from a player interface perspective, as you might see the actor moving back and forth and see the name of the skill in the battle log again, etc.

In any case, ShadowDragon's suggestion of Action Sequences is also what I'd do.

Inside of the target action, you could do something like:
Code:
if (Math.randomInt(50)<user.luk)
    action effect
end
if (user.luk>50 && Math.randomInt(50)<user.luk-50)
    action effect
end

And, of course, where it says action effect you would put all of the stuff you want to happen again.
Oh, in that case a duplicate "Normal Attack" skill could be made without the code, and the "action effect" could just be that skill.
Oh, in that case a duplicate "Normal Attack" skill could be made without the code, and the "action effect" could just be that skill.

If you're talking about calling a second skill from inside the action sequence of the first one, I don't see why that would be desirable instead of just typing, for example,
Code:
action attack: user
action animation
wait for animation
action effect
or whatever the OP wants to be repeated per hit.

That would be getting back into what I was talking about before where you get the undesired results of using multiple skills - the actor stepping back and forth, seeing the skill display in the battle log again, etc.

But I think there's probably sufficient information for the OP to get the desired effect, so however one goes about it.
Good news! I finally got the action sequence to work. The only issue is that the character will step back after the first attack and stay back for the next attack or two, but I'll figure that out eventually, I'm sure. Here's what it looks like currently.

<Target Action> motion swing: user perform action motion wait: user action animation: target wait for animation action effect: target death break perform finish if (Math.randomInt(50)<user.luk) motion swing: user perform action motion wait: user action animation: target wait for animation action effect: target death break perform finish if (Math.randomInt(50)<user.luk-50) motion swing: user perform action motion wait: user action animation: target wait for animation action effect: target death break perform finish </Target Action> end

EDIT: I discovered another annoying side-effect. Now, the player characters no longer flinch/show their "taking damage" animation when hit.
The only issue is that the character will step back after the first attack
Because you're telling them to:
Code:
perform finish


EDIT: I discovered another annoying side-effect. Now, the player characters no longer flinch/show their "taking damage" animation when hit.
Well, I think you're gumming up the works. Why do you have both motion swing and perform action? You're telling the actor to perform two motions simultaneously. And does the skill require you to use a weapon that uses the swing motion?

The flinch should be a part of the action effect, so I'd try getting rid of some of the extra commands in there and see if it helps.
Because you're telling them to:




Well, I think you're gumming up the works. Why do you have both motion swing and perform action? You're telling the actor to perform two motions simultaneously. And does the skill require you to use a weapon that uses the swing motion?

The flinch should be a part of the action effect, so I'd try getting rid of some of the extra commands in there and see if it helps.
Sorry, it’s kinda late where I am and I wasn’t paying close enough attention while I set it up. As for the Swing, I did test it with a Bow and it still works fine as far as I can tell. Thanks for the help, sorry I keep screwing this up
As for the Swing, I did test it with a Bow and it still works fine as far as I can tell.
Well, it's going to "work" in that the game isn't going to crash or anything. But if you're specifically saying motion swing, then that's the battler motion that's going to be used, and you can see it doesn't line up with the weapon animation if you look closely.

If the skill can be used with more than one weapon type, I just don't see why you wouldn't use the generic motion attack
Alright, I got everything working more or less pretty smoothly now. Thank you guys so much!

Original thread: https://forums.rpgmakerweb.com/threads/tie-attack-times-to-stat.151283/