# Eval returns different data

#### Roninator2

##### Gamer
Good day scripters,

I've been working all day on trying to make a few scripts. One is done and posted for another member, a second I'm thinking about for myself. I mention this in this way because both scripts are very similar.
I have everything working, except there is one part that I can't figure out where it is going wrong.
Setup...
attack skill is at the default formula with 0 variance
In my code I have copied the Game_Battler -> def make_damage_value.
renamed it and took out the last four lines.
So it has the first five lines and then I return the value.
Problem...
The issue is that the value returned is not the correct value. The damage to the enemy is 132 but the value I get is 102.
Looking into this I have no idea where it is getting it's information, because it's not properly doing the calculation where
(a.atk * 4 = 140) - (b.def * 2 = 8) == 132
The actor atk is 20, the weapon is 15. calling p(user.atk) gets me 35 so that is correct.
calling p(item.damage.formula) gets me "a.atk * 4 - b.def * 2", so that is also correct.
but then calling p(value) right after `value = item.damage.eval(user, self, \$game_variables)` gets me 102.
If I run that backwards I get 110 / 4 = 27.5 for the user attack. which kind of implies the weapon value is cut in half.
But if I raise it to 20, then the value is 122. 122 + 8 = 130 / 4 = 32.5 yet user.atk + weapon.atk = 40

Thoughts?

#### KK20

##### Just some XP Scripter
There is nothing is blatantly wrong from what you said. You sure you shared everything that you did? Absolutely sure this is a clean project? You also seem pretty confident that b.def is returning 4 as well (you don't make any mention of it, at least).

#### Shaz

##### Global Moderators
critical damage maybe?

If you put this:
Code:
``````p item.damage.eval(user, self, \$game_variables)
value = item.damage.eval(user, self, \$game_variables)
p value``````

does it print the same value twice?

#### Andar

##### Veteran
can you give screenshots of the skill, the enemy, the actor and the class?
as already mentioned above I think it highly likely that you simply missed an effect in the data somewhere - there are a lot of settings that influence the results of the damage formula.

#### Shaz

##### Global Moderators
critical damage maybe?

If you put this:
Code:
``````p item.damage.eval(user, self, \$game_variables)
value = item.damage.eval(user, self, \$game_variables)
p value``````

does it print the same value twice?

Is this a pure vanilla project except for your one and only script you're working on? Or could you have other scripts that have altered some of the existing functionality?

#### Roninator2

##### Gamer
p item.damage.eval(user, self, \$game_variables) value = item.damage.eval(user, self, \$game_variables) p value
Yes the same value.
sure this is a clean project?
Only this one script I'm working on.
can you give screenshots of the skill, the enemy, the actor and the class?
as already mentioned above I think it highly likely that you simply missed an effect in the data somewhere - there are a lot of settings that influence the results of the damage formula.
Adding screen shots, and yes missed something, just don't know what.

Is this a pure vanilla project except for your one and only script you're working on?
I can make a new project and except for the variance it is the same. Output is 102.

I just tried printing the values from the default code Game_Battler -> def make_damage_value
and the result is 132 as it should be.

Last edited:

#### Andar

##### Veteran
OK, I admit that is strange. so we have to systematically check everything.

1) can you add another p value directly before line 141 (return value)? That part should change nothing based on the screenshots, but to make sure

2) where is that function called? just to make sure there is nothing outside that function that may change the value

#### Roninator2

##### Gamer
systematically check everything.
I may be gathering the wrong data.
When I put a `p user` in the default code I get game_enemy
I was trying to pass in Game_Actor.

Solved*
I tested and moved some data around.
Passing enemy and user and item into the find damage value then switching the values passed into item.damage.eval I was able to find that the system processes the information in a way I didn't expect. Plus I was also obtaining \$data_actors & \$data_enemies where it wants \$game_actor & \$game_enemy.

So I was using item.damage.eval(user, self, \$game_variables) which is actor, actor, item
Since I'm only looking to get the value when the actor attacks, I changed the method to include the enemy.
Now item.damage.eval(user, enemy, \$game_variables) gives me the correct result.

*Update

Still working on it. I found I also had the wrong value passed for item.
I fixed that but now the only thing that seems to be remaining is that it does not account for the enemy weakness to elements.

*Fixed
Added a few more lines to find the element id and multiple the rate.
Looks like it's working except it does not work in my project. Probably because I have animated battlers so something is different. But I'll post this anyways.
Found this to be because of the position of the text. The script was working otherwise.

*edit
Just as I said that there is one more issue
The skill is not updating if changing skills after selecting the first skill.
Almost good, just a bit more tweeking.

AND Done. It was a bit of code I put in to stop checking because I was getting a ton of console output.

Last edited:

#### KK20

##### Just some XP Scripter
You also seem pretty confident that b.def is returning 4 as well
So I was using item.damage.eval(user, self, \$game_variables) which is actor, actor, item
So uh... I was right?

#### Roninator2

##### Gamer
So uh... I was right?
lol, yes. I was following the format and not trying to adjust much as that could easily break things.
But it seems it was necessary.

### Latest Profile Posts

Turning a specific vibe into reality is incredibly difficult. For instance, this song is one of the ones I listen to when working on my post apocalyptic project, and getting it's "feeling" into the game has been a real challenge.

I don't just wanna regurgitate the numbers I see, I wanna actually understand the calculations I'm making so I'm probably gonna make a post later with some calculations and what I THINK they mean to get some advice and corrections.

Edit: All (Most) of these will be tested in game prior. I just wanna make sure I understand what's going on under the hood if you will.
my girlfriend calls all my little chibi art cute lol... funny considering that wasn't the original art style of the game.
100 problems in RMMZ 100 more problems take one down pass it around 101 Problems in RMMZ
Made some progress on my game, mostly mapping. Learned quite a bit in the process!.