(help) Skill formula deals 0 on first use + enemy impervious to damage

Kchorrex2012

Villager
Member
Joined
May 26, 2017
Messages
18
Reaction score
1
First Language
Spanish
Primarily Uses
RMMV
Hi everyone!
I've been using RPG Maker MV for a couple months now and I have a problem with this formula, which I've tweaked several times and I haven't been able to get right (I'm kinda noob with formulas so I tend to stick with the generic ones).
Code:
v[21] === 0 ? a.atk * 4 - b.def * 2 : v[21] * a.atk * 4 - b.def * 2 ;
My goal for this skill is to be the normal attack for one of the characters. It should deal normal attack damage, however, the player can use another skill (let's call it "Focus") to increase variable 21, thus making this skill deal much more damage after a maximum of 3 charges. This attack also resets the number of charges by calling a common event that sets variable 21 to 0. The increased damage works just as I wanted, as well as the resetting event and the Focus skill. However, on the first use IN THE ENTIRE GAME this skill always deals 0 (unless it misses), regardless of enemy, enemy defense, weapon, or number of charges (same for battle tests). From the second onwards using it on any enemy it works like it's supposed to (even if the first try missed), dealing normal damage without charging and dealing increased damage according to the number of charges. I've tried several variations in the formula and I haven't been able to get rid of this annoyance, so any correction would be appreciated.

Since this only occurs on the first use ever of the skill I ignored it, but recently I added yanfly's damage core to my game and any enemy hit with this very first attack becomes impervious to any damage for the rest of the battle, that is, the game shows the damage being dealt, but it doesn't deduct anything from the enemy's HP (the first attack still deals 0), even if it comes from other attacks or other party members. At first I thought the enemy became immortal, but I installed Yanfly's Visual HP gauges and saw the gauge wouldn't decrease at all. Damage core's formulas are in the default settings, the only thing I've changed was setting both damage caps to 9999 (I do have a ton of other plugins, but this second problem only happens when damage core is on). I haven't tried the notetag style of formulas that damage core allows because I've yet to learn it properly (I'll be honest, I was only using the plugin for the damage caps).

Any help would be appreciated, thanks in advance!
 

Warpmind

Twisted Genius
Veteran
Joined
Mar 13, 2012
Messages
936
Reaction score
578
First Language
Norwegian
Primarily Uses
I can't be 100% sure this'll work, but try:
$gameVariables.value(21) = 0 ? a.atk * 4 - b.def * 2 : $gameVariables.value(21) * a.atk * 4 - b.def * 2 ; $gameVariables.setvalue(21) 0

That should zero the variable at the same time. Hope it fits. :p
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,959
First Language
English
Primarily Uses
RMMV
Pretty simple: v[21] is not quite the same thing as $gameVariables.value(21). In Game_Action's evalDamageFormula function, v is set to $gameVariables._data. Why is this significant? Well, to begin with, _data contains *nothing*, so the reason it's doing 0 damage the first time you use it is that v[21] isn't 0: it's *undefined*. You need to either use $gameVariables.value(21) instead or make it v[21] === 0 || v[21] === undefined for the conditional.

Warpmind: That won't quite work the way you're intending because of your syntax in the ternary if: using a single equals sign will try to assign the value 0 to $gameVariables.value(21), but because you can't assign a value to a function call, it'll cause an "invalid value in left-hand side in assignment" error and so the skill will do 0 damage.
 

Kchorrex2012

Villager
Member
Joined
May 26, 2017
Messages
18
Reaction score
1
First Language
Spanish
Primarily Uses
RMMV
I followed Trihan's advice and it worked like charm, it got rid of the invulnerability issue as well (didn't get why 'undefined' caused it, I understood the 0 damage part now though). The charged damage works as well.
Thanks a lot guys :D
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,049
Members
137,569
Latest member
Shtelsky
Top