For my RPG, I am using ICF-Soft's custom parameters and a bunch of Yanfly plugins, and I need help implementing an idea I had.
One of the custom stats I added is Intellect, which I want to do two things. First, I want it to govern how powerful items are. Second- and more to the point- I want it to affect how much damage is done when an elemental weakness or resistance is involved.
Here's how I want it to work:
Instead of working on a multiplier, there will instead be a fixed bonus/penalty. If the spell hits for an elemental weakness, the damage will be increased by the attacker's Intellect x their Level. However, if it's not a spell, but rather an elemental affinity affixed to their weapon, this number is halved. Then, if the enemy is extremely weak to that element, this bonus is multiplied by 2.
However, if the enemy is resistant to that element, the damage is reduced by the DEFENDER'S Intellect x DEFENDER'S Level, with the same multiplier based on how resilient they are. If they absorb that element (say, an Ice elemental taking ice damage), the formula wouldn't apply and they'd just absorb HP the normal damage.
I need a plugin that will not override the normal Yanfly element plugin, but instead just add another thing alongside it (so I can give them 0% damage from one element but add the custom formula for another element as a notetag)
So a few things, Assuming ElementRate is actually the in game Element Rate,it should be pretty easy.
<damage formula>
var attack = (your_attack_formula_here);
ElementRate = user.elementRate(<elementId>); \\you'll need to specify each element rate separately.
if (ElementRate >= 100) \\check the element rate of the attack against your threshold
{
attack = attack + (ElementRate-100)*(a.int * a.dlv); \\modifies your attack value by the element rate.
}
if (ElementRate < 100)
{
attack = attack + (ElementRate+50)*(b.int * b.dlv); \\modifies your attack value by the element rate.
}
value = attack; \\sets the damage to the attack value.
</damage formula>
if ElementRate is something like a game variable you have stored somewhere, you'll need to call it. This would get super complicated to refresh for each battler, but I guess possible.
<damage formula>
var attack = (your_attack_formula_here);
var ElementRate = $gameVariables.value(X); \\set X to whatever variable you're using
if (ElementRate >= 100) \\check the element rate of the attack against your threshold
{
attack = attack + (ElementRate-100)*(a.int * a.dlv); \\modifies your attack value by the element rate.
}
if (ElementRate < 100)
{
attack = attack + (ElementRate+50)*(b.int * b.dlv); \\modifies your attack value by the element rate.
}
value = attack; \\sets the damage to the attack value.
</damage formula>
**I am a terrible javascript coder, so this is going to require more than a little debugging and I haven't tried it in the system yet.
Just thinking about simplifying things a bit:
<damage formula>
var attack = (your_attack_formula_here);
if (user.elementRate(<elementId>) >= 100) \\check the element rate of the attack against your threshold
{
attack = attack + (user.elementRate(<elementId>)-100)*(a.int * a.dlv); \\modifies your attack value by the element rate.
}
if (user.elementRate(<elementId>) < 100)
{
attack = attack + (user.elementRate(<elementId>)+50)*(b.int * b.dlv); \\modifies your attack value by the element rate.
}
value = attack; \\sets the damage to the attack value.
</damage formula>
Then just repeat that If statement 9 times, and replace the <elementID> with your element numbers.
All right, I managed to get the game to stop crashing. However, I can't seem to get it to work.
Here's what I got for the formula:
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). 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.
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.
Okay, you might have already resolved this, but do your enemies have "dlv" established as a custom variable for them?
There may also be an issue with the enemy battlers and the "this" function, I forget if that plays nicely with damage core or not. I personally do not use it, but I have horrible spaghetti code.