I'm trying to use Yanfly's Damage Core to make a custom damage formula for my rpg, utilizing 2 custom stats: Intellect, and a hidden stat called dlv. Intellect is meant to determine the effectiveness of items and (more to the point) the degree to which elemental weaknesses deal extra damage, and how much damage is mitigated through elemental resistances. dlv, meanwhile, is used for calculating defense and magical defense damage reduction. It's used to stand in for moves based on a character's level, since enemies don't get actual levels, and for a party member it's set equal to their level.
Most of the damage formula is unchanged, but I just want to replace the element rate step. Here's what I got for the formula so far, but it doesn't seem to be working:
if (this.calcElementRate(target) >= 1)
{
baseDamage += ((this.calcElementRate(target)-1)*(a.int * a.dlv));
}
if (this.calcElementRate(target) < 1)
{
baseDamage -= ((this.calcElementRate(target)+1)*(b.int * b.dlv));
}
value = baseDamage;
However, this isn't working. Here's what's going on with my tests.
I'm testing this by setting the main mage of this game, Charon, against an enemy, with the spells temporarily set to have 0 variance. The enemy has an element rate of 200% for Fire and 0% for Ice.
Both Charon and the enemy have had their dlv and int both set to 7.
Because it has no special resistance or weakness top Thunder, I use the Volt spell as the control (these 3 spells have the same damage formula, by the way, and other than the element the only difference is their variance). It does 96 damage.
When I cast Pyre, the fire spell, it deals 159 damage. The damage algorithm I want is:
BaseDamage + (ElementRate - 1)(a.int * a.dlv)
so the damage SHOULD be:
96 + 1(49) = 145
I have no idea where it got 159.
Now let's try casting Frost. This spell dealt 47 damage. Since this is an elemental resistance, the damage algorithm I want is:
BaseDamage - (ElementRate + 1)(b.int * b.dlv)
the damage should be:
96 - 1(49) = 47
So logically, we can infer that this part of the damage formula is working properly for some reason.
But the worst part is that during the enemy's turn, it uses a normal physical attack that does NOTHING.
Just to make sure I didn't make a mistake with the stats, I disabled the damage formula and tried again. Note that because the only part of the Damage Core I changed pertained to the element rate portion, normal physical damage would be unchanged. And the physical damage it dealt per attack was indeed in the ballpark of 28, as it should be.
So, to sum up:
-The elemental resistance formula is working like a charm.
-The elemental weakness formula almost works, but pulls some random number out of thin air.
-When the enemy attacks me, I always take 0 damage.
Working on a hunch, I decided to give the enemy spells to see what happened. After giving him Pyre and making sure his and Charon's stats were identical (in everything used to calculate magic damage- Magic Atk, Magic Def, and dlv- it dealt 78 damage to Charon, even though the two spells should have been identical in damage.
It would appear that when the game calculates the enemy's int and dlv, it works fine. But when it calculates the player's stats, that's when everything seems to go wonky.
If there's an expert at javascript who knows what's going on, could you tell me please? I don't want to start seriously working on the game until I get the main mechanics completely ironed out.
Most of the damage formula is unchanged, but I just want to replace the element rate step. Here's what I got for the formula so far, but it doesn't seem to be working:
if (this.calcElementRate(target) >= 1)
{
baseDamage += ((this.calcElementRate(target)-1)*(a.int * a.dlv));
}
if (this.calcElementRate(target) < 1)
{
baseDamage -= ((this.calcElementRate(target)+1)*(b.int * b.dlv));
}
value = baseDamage;
However, this isn't working. Here's what's going on with my tests.
I'm testing this by setting the main mage of this game, Charon, against an enemy, with the spells temporarily set to have 0 variance. The enemy has an element rate of 200% for Fire and 0% for Ice.
Both Charon and the enemy have had their dlv and int both set to 7.
Because it has no special resistance or weakness top Thunder, I use the Volt spell as the control (these 3 spells have the same damage formula, by the way, and other than the element the only difference is their variance). It does 96 damage.
When I cast Pyre, the fire spell, it deals 159 damage. The damage algorithm I want is:
BaseDamage + (ElementRate - 1)(a.int * a.dlv)
so the damage SHOULD be:
96 + 1(49) = 145
I have no idea where it got 159.
Now let's try casting Frost. This spell dealt 47 damage. Since this is an elemental resistance, the damage algorithm I want is:
BaseDamage - (ElementRate + 1)(b.int * b.dlv)
the damage should be:
96 - 1(49) = 47
So logically, we can infer that this part of the damage formula is working properly for some reason.
But the worst part is that during the enemy's turn, it uses a normal physical attack that does NOTHING.
Just to make sure I didn't make a mistake with the stats, I disabled the damage formula and tried again. Note that because the only part of the Damage Core I changed pertained to the element rate portion, normal physical damage would be unchanged. And the physical damage it dealt per attack was indeed in the ballpark of 28, as it should be.
So, to sum up:
-The elemental resistance formula is working like a charm.
-The elemental weakness formula almost works, but pulls some random number out of thin air.
-When the enemy attacks me, I always take 0 damage.
Working on a hunch, I decided to give the enemy spells to see what happened. After giving him Pyre and making sure his and Charon's stats were identical (in everything used to calculate magic damage- Magic Atk, Magic Def, and dlv- it dealt 78 damage to Charon, even though the two spells should have been identical in damage.
It would appear that when the game calculates the enemy's int and dlv, it works fine. But when it calculates the player's stats, that's when everything seems to go wonky.
If there's an expert at javascript who knows what's going on, could you tell me please? I don't want to start seriously working on the game until I get the main mechanics completely ironed out.