Zaeran

Dreamer
Veteran
Joined
Feb 9, 2015
Messages
30
Reaction score
6
First Language
English
Primarily Uses
RMMV
In my game, I am utilizing Fallen Angel Olivia's Boost Point System with some effects from Yanfly's Skill Core.

Namely, if an attack hits an enemy's weakness or scores a critical hit, you gain a boost point. This has worked so far with normal skills using the following scripting for a basic fire skill:
Code:
<Post-Damage Eval>
if (target.elementRate(2) > 1) {
  user.gainStoredBP(1);
} else if (target.elementRate(7) > 1) {
  user.gainStoredBP(1);
}
</Post-Damage Eval>
Where FIRE is the 7th element in the database, and MAGIC is 2nd (using Multiple elements from YEP)

And this basic slash-type skill:
Code:
<Post-Damage Eval>
if (target.result().critical) {
  user.gainStoredBP(1);
} else if (target.elementRate(3) > 1) {
  user.gainStoredBP(1);
}
</Post-Damage Eval>

Where SLASH is the 3rd element in the DB.

So my issue is coming in where I am trying to set basic attacks to also trigger this effect by
1st: Getting the type of weapon the user has equipped
2nd Running the same if else, add BP code

The 1st part is supposed to be achieved by applying a state on the actor that has equipped a weapon type (i.e element 50= slashweapon, 51 = Crushweapon state etc.), which is working. After assessing the state, I subtract the equip state element stored in a variable called atkTyp by 47 to equal the element weakness (50-47=3, 3 = Slash Element etc.)

But anytime I use this script:
Code:
<Post-Damage Eval>
if (user.isStateAffected(50) {
  var atkTyp = 50;
  var atkTyp = atkTyp - 47;
} else if (user.isStateAffected(51) {
   var atkTyp = 51;
   var atkTyp = atkTyp - 47;
} else if (user.isStateAffected(52) {
     var atkTyp = 52;
     var atkTyp = atkTyp - 47;
} else if (user.isStateAffected(53) {
     var atkTyp = 53;
     var atkTyp = atkTyp - 47;
}

if (target.result().critical) {
  user.gainStoredBP(1);
} else if (target.elementRate(atkTyp) > 1) {
  user.gainStoredBP(1);
}
</Post-Damage Eval>

No BP is generated, even on scoring a critical hit.

Are the if else statements at the beginning interfering with the last statements?

Any ideas/ help?
 

ShadowDragon

Veteran
Veteran
Joined
Oct 8, 2018
Messages
3,581
Reaction score
1,347
First Language
Dutch
Primarily Uses
RMMV
there is a miscalculation on this code
Code:
<Post-Damage Eval>
if (user.isStateAffected(50) {
  var atkTyp = 50;
  var atkTyp = atkTyp - 47;
} else if (user.isStateAffected(51) {
   var atkTyp = 51;
   var atkTyp = atkTyp - 47;
} else if (user.isStateAffected(52) {
     var atkTyp = 52;
     var atkTyp = atkTyp - 47;
} else if (user.isStateAffected(53) {
     var atkTyp = 53;
     var atkTyp = atkTyp - 47;
}

if (user.StateAffected(50) { where is the other ")"?
because you miss 4 in total in each, so you need to close it as well.
unless I am missing the closing ")"...

otherwise, it should work?
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
670
Reaction score
353
First Language
English
Primarily Uses
RMMV
But anytime I use this script:
Code:
<Post-Damage Eval>
if (user.isStateAffected(50) {
  var atkTyp = 50;
  var atkTyp = atkTyp - 47;
} else if (user.isStateAffected(51) {
   var atkTyp = 51;
   var atkTyp = atkTyp - 47;
} else if (user.isStateAffected(52) {
     var atkTyp = 52;
     var atkTyp = atkTyp - 47;
} else if (user.isStateAffected(53) {
     var atkTyp = 53;
     var atkTyp = atkTyp - 47;
}

if (target.result().critical) {
  user.gainStoredBP(1);
} else if (target.elementRate(atkTyp) > 1) {
  user.gainStoredBP(1);
}
</Post-Damage Eval>

No BP is generated, even on scoring a critical hit.
That whole stretch of code looks weird.

1 - as ShadowDragon said, every if check is missing a close parentheses at the end before the curly brace.

2 - The actual code inside every if check is kind of pointless.
var atkTyp = 50; var atkTyp = atkTyp - 47;
For one thing, you don't need to type "var" a second time. For another, why are those two lines of code? You set atkTyp to 50, then subtract 47 from it, so it will always equal 3 - why not just replace it with a single line:
var atkTyp = 3;
What are you trying to achieve?

The same is true inside every if statement, you're never referencing any kind of variable value so they're always going to be the same value, why set it and then subtract a number?

Finally, your last check is
target.elementRate(atkTyp) > 1
That would return true if the enemy is resistant to your element, has an element rate of over 100%. If you want it to trigger when you hit a vulnerability, you'd want it to be <1.
 
Last edited:

Zaeran

Dreamer
Veteran
Joined
Feb 9, 2015
Messages
30
Reaction score
6
First Language
English
Primarily Uses
RMMV
THE CLOSING PARENTHESIS! I was staring at it for the longest time, I feel like an idiot. Thanks you two!

2 - The actual code inside every if check is kind of pointless.
var atkTyp = 50; var atkTyp = atkTyp - 47;
For one thing, you don't need to type "var" a second time. For another, why are those two lines of code? You set atkTyp to 50, then subtract 47 from it, so it will always equal 3 - why not just replace it with a single line:
var atkTyp = 3;
What are you trying to achieve?

The same is true inside every if statement, you're never referencing any kind of variable value so they're always going to be the same value, why set it and then subtract a number?

Finally, your last check is
target.elementRate(atkTyp) > 1
That would return true if the enemy is resistant to your element, has an element rate of over 100%. If you want it to trigger when you hit a vulnerability, you'd want it to be <1.
Good point. I actually tried to explain this in the original post. 50-53 are physical damage states in the database in a certain order (Slash=50, Crush=51, Pierce=52, Shot=53).

The corresponding elements are in the same order in the Element "Types" in the database (DB), listed from 3-6.

So if an actor is attacking with a normal attack skill (whose elemental properties are based on the weapon an actor has equipped) I needed to connect those two things with a variable, since all actors will be using the "Attack" skill and I wanted it to utilize the same "crit-weakness-exploit mechanic"

So I get the weapon damage-type using atkTyp. I plan on using it in future code for these skills to help reference other parts of the database as well.

If there is an easier way to do this (a user.attackElement function perhaps?) I would be open to change it up to make it simpler, but I don't know it currently. This is admittedly due to a lack of understanding what functions are available.

3.

As for the target.elementRate Rates above 100% equal weakness, below equals resistance. The element rate is multiplied by the damage of skills or attacks of that element to determine effectiveness. (I.E. Element rate in db 135% will multiply damage of that element by 1.35)

So you want target.elementRate > 1 to indicate weakness. target.elementRate < 1 would mean they are resistent.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
670
Reaction score
353
First Language
English
Primarily Uses
RMMV
So I get the weapon damage-type using atkTyp. I plan on using it in future code for these skills to help reference other parts of the database as well.

If there is an easier way to do this (a user.attackElement function perhaps?) I would be open to change it up to make it simpler, but I don't know it currently. This is admittedly due to a lack of understanding what functions are available.
I feel like you're missing the point. It has nothing to do with creating a function, it has to do with all those lines of code that don't do anything. If the result of the math is the same every time, why are you doing math?
if (user.isStateAffected(50) { var atkTyp = 3; } else if (user.isStateAffected(51) { var atkTyp = 4; }
etc. It is possible to do that using fewer, more advanced lines of code, but that's just a very basic step.
As for the target.elementRate Rates above 100% equal weakness, below equals resistance.
You're correct, that was my mistake.
 

oooNUKEooo

Veteran
Veteran
Joined
Sep 22, 2020
Messages
49
Reaction score
10
First Language
br portuguese
Primarily Uses
RMMV
why you both doing math? you can go directly with
Code:
this.getItemElements().contains(X)
where X is the element ID.
 

Zaeran

Dreamer
Veteran
Joined
Feb 9, 2015
Messages
30
Reaction score
6
First Language
English
Primarily Uses
RMMV
why you both doing math? you can go directly with
Code:
this.getItemElements().contains(X)
where X is the element ID.
Again, had no idea! So this gets elements of the current weapon?
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
670
Reaction score
353
First Language
English
Primarily Uses
RMMV
why you both doing math? you can go directly with
Code:
this.getItemElements().contains(X)
where X is the element ID.
I wasn't doing math, as you might notice the lack of any operands ;) But I was avoiding loops to keep the code at Zaeran's comfort level.
Again, had no idea! So this gets elements of the current weapon?
No...it's a boolean function that tells you whether the item has that specified element. So it's only useful if you made your entire script a bit more complicated, thusly:
Code:
if (target.result().critical) 
  user.gainStoredBP(1);
else 
{
    for (var i=3; i<=6; i++)
    {
        if (this.getItemElements().contains(i) && target.elementRate(i) > 1) 
          user.gainStoredBP(1);
    }
}

Was that what you had in mind, Mr. Nuke?
 

Zaeran

Dreamer
Veteran
Joined
Feb 9, 2015
Messages
30
Reaction score
6
First Language
English
Primarily Uses
RMMV
So it's only useful if you made your entire script a bit more complicated, thusly:

I'm not concerned with the complication of code. (Simple in my previous post was meant to mean more efficient). I'm always open to more advanced lines of code. If I don't know, I will learn it.

Thanks for the insight and feedback.

I believe this has resolved my issue and then some, so this can be closed.
 

Latest Threads

Latest Posts

Latest Profile Posts

Doing RPG Maker News for 10th April, 2021. :LZScheeze: (Improving on the thumbnails, by using assets from the day's news.)
Just discovering the forum.
Since Final Fantasy VII has been trending today, decided to make a series of my favorite bars in the OG game! Check it out:

At 2021, we are now farther from the 1980's than they were from the 1950's. Consider that the next time you long for a 1980's song, when you thought your grandpa's taste for 1950's music was "outdated".
no, not my duct tape, anything but my duct tape!

Forum statistics

Threads
110,293
Messages
1,052,035
Members
143,323
Latest member
earthium
Top