MV Hit-Counter system and Hit-Chain combo System

Good evening

I need help with RPG Maker MV

I'm looking for a script or plugin compatible with yanfly's ATB, and allowing me to count the number of hits carried out by the team, and to add a mod (+0.1% additional damage for each additional hit in the chain) and which resets as soon as an enemy break the team's hit-chan by acting
Currently, the game I am building has 3 types of BattleSystem: 2 variants of the same BS (similar to the default BS of MakerMV) merged on one single script, and the ATB of Yanfly ( https://www.yanfly.moe/wiki/Battle_System_-_ATB_(YEP) )

For my try, i reworked yanfly's Combo Attack script (https://www.yanfly.moe/wiki/Combo_Attack_(MV_Plugin_Tips_&_Tricks)) to successfully create a combo system with individual count, like this:
I created a State 50 having in its notebox
Code:
<Custom Apply Effect>
user._comboStacks = user._comboStacks || 0;
var stacks = user._comboStacks.clamp(0, 1000);
user.setStateCounter(stateId, 'x' + stacks);
</Custom Apply Effect>

<Custom Remove Effect>
user._comboStacks = 0;
var stacks = user._comboStacks.clamp(1, 1);
user.setStateCounter(stateId, 'x' + stacks);
</Custom Remove Effect>

<Custom Confirm Effect>
if (this.isPhysical() && value > 0 && !this.item().name.match('Combo')) {
  user._comboStacks = user._comboStacks || 0;
  var stacks = user._comboStacks.clamp(0, 1000);
  var rate = 1.00 + stacks * 0.01;
  value = Math.ceil(value * rate);
  stacks += 1;
  stacks = stacks.clamp(0, 1000);
  user.setStateCounter(stateId, 'x' + stacks);
  user._comboStacks = stacks;
}
</Custom Confirm Effect>


Then, in my Troops, I created 2 events in my troops.
Event 1
Code:
> Conditions Turn0+1*X Range Turn
> Edit Hero states Fixed entire groups Add state 50


Event 2
Code:
> Conditions EndOfTour0+1*X Turn Range
> Edit Hero states Fixed entire groups Remove state 50

In the 2 BattleSystems similar to default MV BS , each character increases their own Hit-Count, and each hit increases their damage by 1%, and each hit-counter is reset at the end of each turn
However, what I did only works individually (each character benefits from their own counter, instead of everyone having a common counter) but above all, this solution does not work when I switch to Yanfly ATB.
( the record is to heavy for the forum, then i put it in drive ==> )

in order to try to "fix" this to achieve my goal, I therefore tried another approach:

Still keeping State50, I used the yanfly "PassiveState" plugin (https://www.yanfly.moe/wiki/Auto_Passive_States_(YEP)) to add <Passive State: 50> to my character.
Result, this time, the combo counter works with the ATB, the damage increases by 1% with each hit during the combo chain. BUT the counter no longer resets at all....not to mention that despite everything, this solution is also only individual to each character, and not a counter common to all the team

( the 2nd record is to heavy too for the forum, then i put it in drive ==> )


Noone can help me with this ?
Currently, the game I am building has 3 types of BattleSystem
This may be your downfall. I don't know what your design thoughts are such that your game needs three different (two only slightly different?) battle systems, but trying to code additional mechanics that will correctly fit all three of those may get very complicated.

However, what I did only works individually (each character benefits from their own counter, instead of everyone having a common counter)
Because that's how you made it.

You should be putting the state on the enemy, and doing all of the combo stacks on the target, not the user.

I don't get what you're doing in the remove effect. There's no point in clamping from 1 to 1, just set whatever you want...to 1. But I don't know why you want anything set to 1 anyway. You should just be deleting the comboStack and that's all the notetag needs.

I also don't see the point of the troop events. You make your attacks apply this state to the target, then you make your enemy's skills remove the state from themselves - thus clearing the stacks.
This may be your downfall. I don't know what your design thoughts are such that your game needs three different (two only slightly different?) battle systems, but trying to code additional mechanics that will correctly fit all three of those may get very complicated.


Because that's how you made it.

You should be putting the state on the enemy, and doing all of the combo stacks on the target, not the user.

I don't get what you're doing in the remove effect. There's no point in clamping from 1 to 1, just set whatever you want...to 1. But I don't know why you want anything set to 1 anyway. You should just be deleting the comboStack and that's all the notetag needs.

I also don't see the point of the troop events. You make your attacks apply this state to the target, then you make your enemy's skills remove the state from themselves - thus clearing the stacks.
To be very honest, I know absolutely nothing about coding or scripting, so I test things to see if it works


You should be putting the state on the enemy, and doing all of the combo stacks on the target, not the user.
Like this ?
JavaScript:
<Custom Apply Effect>
target._comboStacks = target._comboStacks || 0;
var stacks = target._comboStacks.clamp(0, 1000);
target.setStateCounter(stateId, 'x' + stacks);
</Custom Apply Effect>


<Custom Remove Effect>
target._comboStacks = 0;
var stacks = target._comboStacks.clamp(1, 1);
target.setStateCounter(stateId, 'x' + stacks);
</Custom Remove Effect>


<Custom Confirm Effect>
if (this.isPhysical() && value > 0 && !this.item().name.match('Combo')) {
  target._comboStacks = target._comboStacks || 0;
  var stacks = target._comboStacks.clamp(0, 1000);
  var rate = 1.00 + stacks * 0.01;
  value = Math.ceil(value * rate);
  stacks += 1;
  stacks = stacks.clamp(0, 1000);
  target.setStateCounter(stateId, 'x' + stacks);
  target._comboStacks = stacks;
}
</Custom Confirm Effect>
You don't need anything inside the Custom Remove Effect except
Code:
delete target._comboStacks;

You also don't want most of the stuff in that Custom Confirm Effect. If you have all your attacks adding the state, most of it will be done in the Custom Apply.

Code:
<Custom Confirm Effect>
if (this.isPhysical() && value > 0 && target._comboStacks)
    value *= 1 + target._comboStacks * .01;
</Custom Confirm Effect>

To be very honest, I know absolutely nothing about coding or scripting, so I test things to see if it works
My advice as someone who has learned to code and who is a professional teacher - that is going to get things wrong more often than right and waste your time 😉

Your time is better spent asking people for help in the first place or doing tutorials to learn what you're doing. Blindly trying things is the slowest way to progress.
You don't need anything inside the Custom Remove Effect except
Code:
delete target._comboStacks;

You also don't want most of the stuff in that Custom Confirm Effect. If you have all your attacks adding the state, most of it will be done in the Custom Apply.

Code:
<Custom Confirm Effect>
if (this.isPhysical() && value > 0 && target._comboStacks)
    value *= 1 + target._comboStacks * .01;
</Custom Confirm Effect>


My advice as someone who has learned to code and who is a professional teacher - that is going to get things wrong more often than right and waste your time 😉

Your time is better spent asking people for help in the first place or doing tutorials to learn what you're doing. Blindly trying things is the slowest way to progress.sorry for my

sorry for my late response, I had personal problems to deal with
Then, i created a State "HitCounter" (State ID 70) with the following code:

JavaScript:
<Custom Apply Effect>
target._comboStacks = target._comboStacks || 0;
var stacks = target._comboStacks.clamp(0, 1000);
target.setStateCounter(stateId, 'x' + stacks);
</Custom Apply Effect>


<Custom Remove Effect>
delete target._comboStacks;
</Custom Remove Effect>


<Custom Confirm Effect>
if (this.isPhysical() && value > 0 && target._comboStacks)
    value *= 1 + target._comboStacks * .01;
</Custom Confirm Effect>

After that, I applied State 70 to the enemies via the <Passive State: 70> command enabled by the yanfly auto passive-states plugin


as the record show it ( ) , the state is effective on ennemi, but doesn't work : the hitcounter dont increace with successive hits, and each hit isnt increased by 1% in the hit-chain
<Custom Confirm Effect>
confirm effects are triggered when the battler with the state takes action. if that state is on an enemy and youre trying to make it so that something happens when they get hit, your code isnt doing anything in that regard. if youre increasing the damage the affected battler takes and youre using their own _comboStacks property, you realistically should be using a react effect, not a confirm one.

the hitcounter dont increace with successive hits
you didnt tell it to. in your apply effect, you used setStateCounter() to set the state's counter. the counter only updates when you call it. if you want it to update after every hit, then you need to tell it to after every hit. that would go in the react effect, or you call the apply effect

and each hit isnt increased by 1%
youre not incrementing the _comboStacks property anywhere. you set the property when the state is applied, but you never said anywhere that it should increase after a hit. that too goes in the react effect, or the skill's own tags and then also update the counter

var stacks = target._comboStacks.clamp(0, 1000);
that only gets ran when the state is applied. unless the battler is getting the state applied to them numerous times while already active, your clamp isnt going to do anything.

if they didnt have the state before, then youve set it to 0. if you are applying the state to a battler that already has it, then the value is retained and will be clamped *only on application*. unless every hit they take applies the state (which then clamps the value), it makes more sense to me to move it to where the incrementing happens.
You're changing things from the Tips & Trick in terms of what states go on whom, but without reading the documentation and understanding what the notetags mean.

Code:
<Custom Apply Effect>
// Check whether target has any combo hits, or start at 0
    target._comboStacks = target._comboStacks || 0;
// ADD ONE TO THE COMBO HITS
    target._comboStacks++;
// Display the number of combo hits on the state icon
    target.setStateCounter(stateId, target._comboStacks);
</Custom Apply Effect>


<Custom Remove Effect>
// Remove the property to reset the combo
    delete target._comboStacks;
</Custom Remove Effect>

REACT Effect takes place when the battler is hit
<Custom React Effect>
// Physical attacks do 10% extra damage per stack
    if (this.isPhysical() && value > 0 && target._comboStacks)
        value *= 1 + target._comboStacks * .01;
</Custom React Effect>
Ok then what i need to do ? Im a little bit lost , here , its over
You're changing things from the Tips & Trick in terms of what states go on whom, but without reading the documentation and understanding what the notetags mean.

Code:
<Custom Apply Effect>
// Check whether target has any combo hits, or start at 0
    target._comboStacks = target._comboStacks || 0;
// ADD ONE TO THE COMBO HITS
    target._comboStacks++;
// Display the number of combo hits on the state icon
    target.setStateCounter(stateId, target._comboStacks);
</Custom Apply Effect>


<Custom Remove Effect>
// Remove the property to reset the combo
    delete target._comboStacks;
</Custom Remove Effect>

REACT Effect takes place when the battler is hit
<Custom React Effect>
// Physical attacks do 10% extra damage per stack
    if (this.isPhysical() && value > 0 && target._comboStacks)
        value *= 1 + target._comboStacks * .01;
</Custom React Effect>
A little bit more compregensive ( i think ..?)

"// Check whether target has any combo hits, or start at 0"
I Need to apply the state to ennemies (not on team) but ennemies are the user of the state ( they are the ones who got the stacks and who receive extradamage from successives hits)
Then the ennemi muqt be the target of this state "in game" but the user of the code ?...
So i need to apply on ennemies the following code :

JavaScript:
<Custom Apply Effect>
// Check whether user has any combo hits, or start at 0
    user._comboStacks = user._comboStacks || 0;
// ADD ONE TO THE COMBO HITS
    user._comboStacks++;
// Display the number of combo hits on the state icon
    user.setStateCounter(stateId, user._comboStacks);
</Custom Apply Effect>


<Custom Remove Effect>
// Remove the property to reset the combo
    delete user._comboStacks;
</Custom Remove Effect>


REACT Effect takes place when the battler is hit
<Custom React Effect>
// Physical attacks do 1% extra damage per stack
    if (this.isPhysical() && value > 0 && user._comboStacks)
        value *= 1 + user._comboStacks * .01;
</Custom React Effect>

?


Or im totaly wrong about this....and you must be thinking that im totally stupid cause i understand absolutely nothing about this and about coding/scripting, even if its some basics things :x T_T

confirm effects are triggered when the battler with the state takes action. if that state is on an enemy and youre trying to make it so that something happens when they get hit, your code isnt doing anything in that regard. if youre increasing the damage the affected battler takes and youre using their own _comboStacks property, you realistically should be using a react effect, not a confirm one.


you didnt tell it to. in your apply effect, you used setStateCounter() to set the state's counter. the counter only updates when you call it. if you want it to update after every hit, then you need to tell it to after every hit. that would go in the react effect, or you call the apply effect


youre not incrementing the _comboStacks property anywhere. you set the property when the state is applied, but you never said anywhere that it should increase after a hit. that too goes in the react effect, or the skill's own tags and then also update the counter


that only gets ran when the state is applied. unless the battler is getting the state applied to them numerous times while already active, your clamp isnt going to do anything.

if they didnt have the state before, then youve set it to 0. if you are applying the state to a battler that already has it, then the value is retained and will be clamped *only on application*. unless every hit they take applies the state (which then clamps the value), it makes more sense to me to move it to where the incrementing happens.

Im really sorry, i try to do my best to understand, even if I am forced to admit that I learn on my own and that I understand absolutely nothing, being extremely far away and outside my area of expertise (I know, I seem stupid. )
I Need to apply the state to ennemies
Applying a state when you hit with a skill is one of the basic settings in RPG Maker. You want to be familiar with all of these database settings and event commands before you try to do things with plugins and code.

1725924352441.png
but ennemies are the user of the state
Then the ennemi muqt be the target of this state "in game" but the user of the code
when youre working with the notetags provided by the buffs and states plugin, all of the notetags that fall under the category of "Custom Action Effects" use the action's perspective.

the user is whoever is using the skill and the target is who's getting the skill. so even if the state is on Battler A, "user" within the react effect will always mean some other battler unless Battler A is using a skill on themself.

in the "Custom Timing Effect" notetags like apply and remove, the user and the target are both whoever has the state on them and are interchangeable.
Applying a state when you hit with a skill is one of the basic settings in RPG Maker. You want to be familiar with all of these database settings and event commands before you try to do things with plugins and code.

View attachment 317362
Ok, i understood:
goal is not "my battler need to aplly the state" or "my ennemies need to receive the state" but "my skill need to apply the state by themselves to ennemies" ?

i modified my multihit skill to apply the state (without any passive skill, just by themself, with the "add state", as you tell me)

and for the state, i used your code:
JavaScript:
<Custom Apply Effect>
// Check whether target has any combo hits, or start at 0
    target._comboStacks = target._comboStacks || 0;
// ADD ONE TO THE COMBO HITS
    target._comboStacks++;
// Display the number of combo hits on the state icon
    target.setStateCounter(stateId, target._comboStacks);
</Custom Apply Effect>


<Custom Remove Effect>
// Remove the property to reset the combo
    delete target._comboStacks;
</Custom Remove Effect>

REACT Effect takes place when the battler is hit
<Custom React Effect>
// Physical attacks do 10% extra damage per stack
    if (this.isPhysical() && value > 0 && target._comboStacks)
        value *= 1 + target._comboStacks * .01;
</Custom React Effect>

it's working good : the hit counter his triggered on the ennemi, the hit counter increase for each each of the skill received by the ennemies.
I just modified my skill cause the state doesnt remove by himself, then i put an autoremoval timing 1-1 turn.

there is only one ..."weir" thing : some totally abnormal and incredibly high damage is inflicted on the enemy, as the next record show:



I suppose this is due to this part of the script ?
JavaScript:
REACT Effect takes place when the battler is hit
<Custom React Effect>
// Physical attacks do 10% extra damage per stack
    if (this.isPhysical() && value > 0 && target._comboStacks)
        value *= 1 + target._comboStacks * .01;
</Custom React Effect>

1% means 1/100, then 0.01. So the .01 is good (or maybe we need to write it "full", 0.01 ?)
or its the "value *= 1 +" part ?
there is only one ..."weir" thing : some totally abnormal and incredibly high damage is inflicted on the enemy, as the next record show:
its not high damage, the damage just isnt an integer. the MV damage popup sheet doesnt have a spot for a decimal point, but theres a small space for where it would be. if youve noticed, the first hit you did 62 damage, but every single hit that followed it had shown 2 separate numbers. you need to round the damage. damage calculated through a skill damage formula automatically does so, but additional damage from notetags like that need to be rounded.

value *= 1 + target._comboStacks * .01;

Code:
value += Math.ceil(value * target._comboStacks * .01);
@Robro33 is right, I typed that with late brain. It's not 10%, it's 1%, and I didn't round it.
i'm sorry, my gf got a car accident this week-end, then i was not able to answer before

Everything is fixed, thanks to both of you.

I created a State (70) HitCounter (Remove at BattleEnd, and Auto-removal Timing TurnEnd 1~1) with the following code in NoteBox:

JavaScript:
<Custom Apply Effect>
    target._comboStacks = target._comboStacks || 0;
    target._comboStacks++;
    target.setStateCounter(stateId, target._comboStacks);
</Custom Apply Effect>

<Custom Remove Effect>
    delete target._comboStacks;
</Custom Remove Effect>

<Custom React Effect>
    if (this.isPhysical() && value > 0 && target._comboStacks)
        value += Math.ceil(value * target._comboStacks * .01);
</Custom React Effect>

And i added the state(70) in my skills with the "Add State HitCounter 100%" EffectBox of the skills

HitCounter in ATB System :

HitCounter in LockedTeam System :

Original thread: https://forums.rpgmakerweb.com/threads/hit-counter-system-and-hit-chain-combo-system.171717/