[Short script] Calculation to increase Atk. Parameter

Hi,

So I'm working on creating a berzeker character. What I would like to do is to increase his attack stat when his HP are low.

Basically, the formula would go as this :

= ( [MaxHP] - [HP left] ) / 25

Then I put this as a script in a variable, and I add this to the stat through an event.
However, I don't know JavaScript. Could someone write the calculation script for me, please ?

Also, just to know : do I risk having an infinite increase of the attack stat ? Should I do this a different way ?
Also, just to know : do I risk having an infinite increase of the attack stat ? Should I do this a different way ?
Only if you call the event improperly/repeatedly.

I will suggest a more elegant solution to this using VisuStella's Skills and States and Core Engine plugins.

Make a state and use a notetag on your character to put it on them as a passive state.

Then, in its notes, put:
Code:
<JS Passive Condition>
condition=user.hpRate()<=.25;
</JS Passive Condition>

<JS ATK Plus: (user.mhp-user.hp)/25>

The first notetag makes the state active at 25% health, which corresponds to the dying motion in battle - change it as you like. Then the second one applies the variable parameter change.
My bad, I failed to explain correctly what the effect was supposed to be. x) I meant that the lower the HP were, the greater the addition would be to the Atk parameter. So I'm not sure if <JS Passive Condition> is necessary since I want the effect to be always active.

I succeeded in applying the state to my character, however the boost doesn't seem to take effect, since I have not seen any increase in my character's damages in battle, despite him loosing HP (since he is supposed to gain +1 physical damage every 25 HP lost).



A side question, regarding the forum : I may end up asking a lot of questions. It's already my 3rd thread. Wouldn't it be better for me to keep asking my questions in the same thread, so that I avoid creating threads over and over again ?
Are you using VisuStella Core Engine, like Turan suggested? It adds the <JS ATK Plus> notetag. If you want it to be a permanent effect, I think you can use that tag directly in the Note box of an actor (no state required):

<JS param Plus: code> - Used for: Actor, Class, Weapon, Armor, Enemy, State Notetags - Runs 'code' to change the 'param' plus value. - Replace 'param' with 'MaxHP', 'MaxMP', 'ATK', 'DEF', 'MAT', 'MDF', 'AGI', or 'LUK' to determine which parameter to modify. - Replace 'code' with JavaScript code to determine how much to change the plus amount for the parameter's total calculation. - This is used to calculate the 'plus' portion in the Parameter Settings => Basic Parameter => Formula.
Remember to save your project to apply Plugin Manager changes before testing.

You can check the exact ATK value in-game using event commands, e.g.
  • Make a troop event with Condition: Turn 1*X, Span: Turn. (Trigger every turn, once per turn.)
  • In that event:
    • Get the ATK value into a variable: Control Variables -> Game Data -> Actor -> ATK.
    • Show Text: "Berserker ATK is \v[123]". (Replace 123 with the ID of the variable.)

A side question, regarding the forum : I may end up asking a lot of questions. It's already my 3rd thread. Wouldn't it be better for me to keep asking my questions in the same thread, so that I avoid creating threads over and over again ?
I recommend starting a new thread for a new question. That helps keep things more organised and makes it easier for other people with a similar problem to find the answer. 👋
I do use this plugin : I have all of VS's free core plugins, including the core and the skills&states ones. So, just like you suggested, I put Turan's tag in my characters notes instead, and still nothing.
Ah, OK, I just did a quick test in the old version of the VisuStella sample project I have. Looks like it should be this, not user? Try this:

<JS ATK Plus: (this.mhp - this.hp) / 25>
By default this "plus" value applies before traits/buffs, i.e. (base + plus) * traitRate * buffRate. If you want it to apply after traits/buffs, replace Plus with Flat.
Perfect, now it works ! Thank you very much. ^^
Great! Happy RPG Making~

Original thread: https://forums.rpgmakerweb.com/threads/short-script-calculation-to-increase-atk-parameter.154739/