[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,550
Reaction score
5,313
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,485
Reaction score
3,514
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,485
Reaction score
3,514
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,485
Reaction score
3,514
First Language
EN
Primarily Uses
RMMZ
Great! Happy RPG Making~
 

Latest Threads

Latest Posts

Latest Profile Posts

I made the mistake of using CCleaner. Now I have to hack every account I have xD
Having some issues with some esthetic scripts. Mind checking my threads and help?
I've been working on character sprites :), although not far in development, I wanted to start getting sprites done before my art style changes again.
62661208_w4addaU2hBczYcr.png
62661121_AGK5FiAt2QwWjYL.png
Grading exams makes me swing between being full of pride for my students and doubting everything I did this semester xD
Has it really been 50 streams? At this point it's just guilting me into pushing out a prototype. :kaoswt:



I should probably just bite the bullet and send it out, then go with my original plan to provide weekly updates.

Forum statistics

Threads
129,726
Messages
1,204,690
Members
170,812
Latest member
Dawsmead
Top