# RMMVCan someone check if my code has any errors? (Not Long)

#### Mieyn-the-ScriptWriter

##### Villager
I'm trying to recreate an ability called Underdog.

Here's a description of the skill.
Underdog: Increases damage dealt to an enemy in proportion to how much higher the enemy's level is.

And here is how I want mine to function.

Underdog: Increases the actor's stats in proportion to how much higher the enemies stats are.

So I don't know any Java at all, but from my basic understanding of C++, a couple of RpgMaker Java expressions/functions and some help from Reddit. I think I know how to recreate the ability... As a passive state.

I'm not sure if I need integers, but I'm going to put it here just in case.

int EneBST = 0;
int UrBST = 0;
int BSTBoost = 0;

EneBST = (b.mhp + b.mmp + b.atk + b.mat + b.def + b.mdf + b.agi + b.luk);

UrBST = (a.mhp + a.mmp + a.atk + a.mat + a.def + a.mdf + a.agi + a.luk);

if (EneBST > UrBST)
{
EneBST - UrBST = BSTBoost;
}

I'm not sure if code can work in a state's notebox, if it does, then I'd run into a new problem of how I get the BST of multiple enemies.

#### ATT_Turan

##### Forewarner of the Black Wind
A lot of that is invalid code. Note that RPG Maker MV uses JavaScript, not Java. There's no such thing as declaring variables by type (int).

The first thing you need to do is determine when and how your code will run. If it's a passive state, when does it happen? Every time the actor with the state takes an action against an enemy?
int EneBST = 0;
int UrBST = 0;
int BSTBoost = 0;
You can't declare variables by type in JavaScript. You declare them by scope - `let` or `var` would work for you.
EneBST = (b.mhp + b.mmp + b.atk + b.mat + b.def + b.mdf + b.agi + b.luk);
Syntax-wise, this works. The parentheses are meaningless. The reference to `b` will only function depending on what plugin is making this code run. If you're using one of Yanfly's Buffs & States notetags, with it being a passive state, then you would use `target` instead.

What is this supposed to mean? You have the word BSTBoost just floating there - that can't do anything, whether you're going off of JavaScript, Java or C++.

That's like saying "Turn left, walk straight down the hallway *4!!!*, open the door, *92!!!*, walk through the doorway..."

Again, `a` is probably invalid, depending on the plugin you use to execute this code.
I'm not sure if code can work in a state's notebox
Not unless you're using a plugin that makes it do so. Notes are exactly what the word means, something you can type for your own reference.

if it does, then I'd run into a new problem of how I get the BST of multiple enemies.
Why? You're never interacting with multiple enemies - even with a skill that affects more than one, each hit is processed separately. The engine's code can't actually do more than one thing at the same time.

People here will be happy to help you clean up your code to do what you want, but it sounds like you need to clarify in your mind exactly what you want, how this skill is supposed to work, and describe that clearly.

Do you learn the skill, it gives you a passive state, and that has an effect on every other skill you use? Something else?

#### Mieyn-the-ScriptWriter

##### Villager
You declare them by scope - `let` or `var` would work for you.
Thx for the feedback

What is this supposed to mean? You have the word BSTBoost just floating there - that can't do anything, whether you're going off of JavaScript, Java or C++.
I only put BSTBoost cause of this post...

Here's a quote:

Originally, I interpreted this...
as, add b.def*10 buff to the actor's Max HP for 3 turns.
Granted this was for attack formulas and not actor buffs. Plus I don't know how to really add buffs to an actor.

Additionally, I want to apply a boost the actor's stats by the outcome of variable BSTBoost. And if its a boost to the actor's stats, then I need to take all the of the enemy's BST into account.

#### ATT_Turan

##### Forewarner of the Black Wind
I only put BSTBoost cause of this post...
That thread is about how to use JavaScript in damage formulae. You are not interacting with a damage formula, so you have to read and determine which parts are relevant to you.

Originally, I interpreted this...
as, add b.def*10 buff to the actor's Max HP for 3 turns.
If you read the instructions further up in that post, it explains:
But only last number in the formula deals damage. If you had 2 lines of formula. (semicolon ; tells where line ends for the program)
E.g. a.atk; a.atk*2
Only a.atk*2 would be calculated for damage.

Plus I don't know how to really add buffs to an actor.
That is also explained in the first post of the thread you linked to:
What about buffs? Can we buff and debuff battlers?

Yes!

Additionally, I want to apply a boost the actor's stats by the outcome of variable BSTBoost.
You can't natively do that, buffs in RPG Maker augment parameters by a predetermined amount. You'll have to use a plugin to let a buff or state affect parameters by a number you choose.

And if its a boost to the actor's stats, then I need to take all the of the enemy's BST into account.
Okay? You still haven't explained exactly how this skill works. No one can tell you exactly what plugins you need or how to write the code until you clearly define that.

I offered one interpretation at the end of my previous post - is that correct, and describes how you want the skill to work? If not, how is it different?

#### Mieyn-the-ScriptWriter

##### Villager
Do you learn the skill, it gives you a passive state, and that has an effect on every other skill you use? Something else?
It would just be a passive state the actor starts off with, and the passive state would boost the actor's stats. But your way essetially works the same.

#### ATT_Turan

##### Forewarner of the Black Wind
It would just be a passive state the actor starts off with, and the passive state would boost the actor's stats.
1 - Going back and reading my example of how to explain something.

2 - Thinking about when you play a game like this, how skills function.

I don't see how what you just said is different from what I said - but you say it is, so please explain the difference.

When does the state boost the actor's parameters? I've listed that several times as being critical information, and you still haven't explained your intent in that regard.

Is it every time the actor attacks an enemy? Is it at the beginning of each battle? Is it when a pig flies out of their ear? Without clearly defined information, you can't get an answer that will do what you want.

#### Mieyn-the-ScriptWriter

##### Villager
When does the state boost the actor's parameters? I've listed that several times as being critical information, and you still haven't explained your intent in that regard.
It would activate when the enemies stat total exceeds that of the actor, or it could always run in the background.

it gives you a passive state, and that has an effect on every other skill you use? Something else?
This also works as well.

Sorry for not being too helpful.

Last edited:

#### ATT_Turan

##### Forewarner of the Black Wind
It would activate when the enemies stat total exceeds that of the actor
That is not a when. That's a condition (the enemies' total exceeds the actor's) but it's not a time. I even gave you several examples of timing (at the beginning of battle, every action, end of the turn, when an enemy dies) and you didn't reference any.

or it could always run in the background.
That wouldn't make much sense because most of the time you're not in combat. When you're walking around the map, there aren't any enemies to reference nor is there a point to boosting your parameters.

Since we don't seem to be getting anywhere, I'll just throw this at you. If it does what you want, awesome. If it doesn't, maybe you can make edits once you have the correct foundation, or maybe someone else can get the information needed to produce what you're looking for.

This will run at the beginning of battle and give your actor a boost to all of their parameters equal to the difference between the sum of their parameters and the sum of the parameters of all the enemies in the troop.

You said this ability is always on a specific actor, so I don't see any reason you need a passive state. You will need:
-Quasi's Param Plus
-An Underdog state in your database (referred to as stateId)
-A variable in your database (referred to as varId)
-The actor this applies to (referred to as actorId)

Go to your troop and make an event with the Condition of Turn 0 and the Span of Battle.

Enter an event command of Script (tab 3) and put:
Code:
``````var actor=\$gameActors.actor(actorId);
var enemySum=0; \$gameTroop.members().forEach(enemy => enemySum+=enemy.mhp + enemy.mmp + enemy.atk + enemy.mat + enemy.def + enemy.mdf + enemy.agi + enemy.luk);
enemySum-=actor.mhp + actor.mmp + actor.atk + actor.mat + actor.def + actor.mdf + actor.agi + actor.luk;
\$gameVariables.setValue(varId, (enemySum>0 ? enemySum : 0));
if (enemySum>0)
replace varId, stateId, actorId with the appropriate numbers (no leading zeros).

Then, in your Underdog state, set it up with however you want the state to behave, choose the icon, set the duration in turns or actions or damage or whatever.

In its notes field, put:
Code:
``````<params>
MHP: \$gameVariables.value(varId);
MMP: \$gameVariables.value(varId);
ATK: \$gameVariables.value(varId);
DEF: \$gameVariables.value(varId);
MAT: \$gameVariables.value(varId);
MDF: \$gameVariables.value(varId);
AGI: \$gameVariables.value(varId);
LUK: \$gameVariables.value(varId);
</params>``````
again, replacing varId with the appropriate number.

#### Mieyn-the-ScriptWriter

##### Villager
That is not a when. That's a condition (the enemies' total exceeds the actor's) but it's not a time. I even gave you several examples of timing (at the beginning of battle, every action, end of the turn, when an enemy dies) and you didn't reference any.

That wouldn't make much sense because most of the time you're not in combat. When you're walking around the map, there aren't any enemies to reference nor is there a point to boosting your parameters.

Since we don't seem to be getting anywhere, I'll just throw this at you. If it does what you want, awesome. If it doesn't, maybe you can make edits once you have the correct foundation, or maybe someone else can get the information needed to produce what you're looking for.

This will run at the beginning of battle and give your actor a boost to all of their parameters equal to the difference between the sum of their parameters and the sum of the parameters of all the enemies in the troop.

You said this ability is always on a specific actor, so I don't see any reason you need a passive state. You will need:
-Quasi's Param Plus
-An Underdog state in your database (referred to as stateId)
-A variable in your database (referred to as varId)
-The actor this applies to (referred to as actorId)

Go to your troop and make an event with the Condition of Turn 0 and the Span of Battle.

Enter an event command of Script (tab 3) and put:
Code:
``````var actor=\$gameActors.actor(actorId);
var enemySum=0; \$gameTroop.members().forEach(enemy => enemySum+=enemy.mhp + enemy.mmp + enemy.atk + enemy.mat + enemy.def + enemy.mdf + enemy.agi + enemy.luk);
enemySum-=actor.mhp + actor.mmp + actor.atk + actor.mat + actor.def + actor.mdf + actor.agi + actor.luk;
\$gameVariables.setValue(varId, (enemySum>0 ? enemySum : 0));
if (enemySum>0)
replace varId, stateId, actorId with the appropriate numbers (no leading zeros).

Then, in your Underdog state, set it up with however you want the state to behave, choose the icon, set the duration in turns or actions or damage or whatever.

In its notes field, put:
Code:
``````<params>
MHP: \$gameVariables.value(varId);
MMP: \$gameVariables.value(varId);
ATK: \$gameVariables.value(varId);
DEF: \$gameVariables.value(varId);
MAT: \$gameVariables.value(varId);
MDF: \$gameVariables.value(varId);
AGI: \$gameVariables.value(varId);
LUK: \$gameVariables.value(varId);
</params>``````
again, replacing varId with the appropriate number.

I am so sorry for being so difficult, this helped a lot thx.

### Latest Profile Posts

finally finished all the sprites for my friend's Comic book OC that I put in my game.

I plan to have a total of 20 different BATTLE-bot cards you can find & collect.

I reached 100 followers on my new twitter! It's not much but it's honest work