[Short script] Calculation to increase Atk. Parameter

UmeNeko

Villager
Member
Joined
Jan 31, 2023
Messages
16
Reaction score
1
First Language
French
Primarily Uses
RMMZ
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 ?
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
7,629
Reaction score
5,394
First Language
English
Primarily Uses
RMMV
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.
 

UmeNeko

Villager
Member
Joined
Jan 31, 2023
Messages
16
Reaction score
1
First Language
French
Primarily Uses
RMMZ
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 ?
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
4,493
Reaction score
3,526
First Language
EN
Primarily Uses
RMMZ
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. :kaohi:
 

UmeNeko

Villager
Member
Joined
Jan 31, 2023
Messages
16
Reaction score
1
First Language
French
Primarily Uses
RMMZ
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.
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
4,493
Reaction score
3,526
First Language
EN
Primarily Uses
RMMZ
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.
 

UmeNeko

Villager
Member
Joined
Jan 31, 2023
Messages
16
Reaction score
1
First Language
French
Primarily Uses
RMMZ
Perfect, now it works ! Thank you very much. ^^
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
4,493
Reaction score
3,526
First Language
EN
Primarily Uses
RMMZ
Great! Happy RPG Making~
 

Latest Threads

Latest Profile Posts

If anyone knows any C# programmers, please send them my way.
Chilling at night in a tavern.
ChillingAtTavern.png

After 'multiple breakdowns', it's finally over. 10/10 will do this again.
Ever notice that villains can reform and become better people, but heroes can only ever die... or live long enough to see themselves become villains?

Isn't that interesting?
xabileug wrote on Kaelan's profile.
Will you be back?


got inspired by Tekken 5's character select screen and made some new music today for my character select screen.

Forum statistics

Threads
129,842
Messages
1,205,649
Members
170,995
Latest member
RamiroWhitehead
Top