Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
3,141
Reaction score
709
First Language
English
Primarily Uses
RMVXA
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
Veteran
Joined
Oct 11, 2018
Messages
368
Reaction score
141
First Language
English
Primarily Uses
RMXP
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
Global Mod
Joined
Mar 2, 2012
Messages
42,522
Reaction score
14,846
First Language
English
Primarily Uses
RMMV
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
Veteran
Joined
Mar 5, 2013
Messages
32,920
Reaction score
8,255
First Language
German
Primarily Uses
RMMV
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
Global Mod
Joined
Mar 2, 2012
Messages
42,522
Reaction score
14,846
First Language
English
Primarily Uses
RMMV
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
Veteran
Joined
May 22, 2016
Messages
3,141
Reaction score
709
First Language
English
Primarily Uses
RMVXA
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.
1620908430235.png
1620908459003.png
1620908479162.png
1620908514609.png
1620908596482.png1620908637255.png
1620908731429.png
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
Veteran
Joined
Mar 5, 2013
Messages
32,920
Reaction score
8,255
First Language
German
Primarily Uses
RMMV
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
Veteran
Joined
May 22, 2016
Messages
3,141
Reaction score
709
First Language
English
Primarily Uses
RMVXA
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:

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
3,141
Reaction score
709
First Language
English
Primarily Uses
RMVXA
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 Threads

Latest Posts

Latest Profile Posts

For a long time I always consider XP soundtracks as the best one.
Just listened to some of MZ tracks from the free version.
It's... Quite mindblowing. xD
Only listened to the battles, towns, and fields.
But I'm sure the rest are equally good. :D
What do you guys want to see for the new Jump into Javascript? A continuation of the rpg_objects, or would you prefer a "lesson 0" where I go back to the absolute basics of Javascript and cover the fundamentals of the language and its construction?
Hey RPG members!!

How do you finish projects? Some new game developers start off strong but end up losing momentum. What keeps you motivated while working on new projects?
Feeling wee sleepy.. ZzzZ
So many threads to move to the right place. My post count is awesome, but 95% of it is due to moving things.

Forum statistics

Threads
112,452
Messages
1,068,383
Members
146,107
Latest member
kenjum
Top