MV Yanfly T&T Death Nova Effect, trying to give it a specific damage type.


Hey all, so I'm using this effect in my game and would like it to be damage element type 10.
This is what Yanfly's code looks like with my game's specific state values etc.


JavaScript:
// Death Nova
<Custom Apply Effect>
// Get the Death Nova state's ID
var deathNovaId = 56;
// Check if the target is dead and is affected by the Death Nova state
if (target.isDead() && target.isStateAffected(deathNovaId)) {
  // Get the burn state
  var poisonId = 12;
  // Get the original caster for the Death Nova state
  var caster = target.stateOrigin(97);
  // Calculate the damage dealt
  var dmg = 500 + caster.mat * 12;
  // Get the dying unit's opponents
  var foes = target.opponentsUnit().aliveMembers();
  // Loop through the foes
  for (var i = 0; i < foes.length; ++i) {
    // Get the currently looped foe
    var foe = foes[i];
    // Check if the foe exists
    if (foe) {
      // Make the foe take damage.
      foe.gainHp(-dmg);
      // Add the burn state to the foe.
      foe.addState(12);
      // Show the damage popup.
      foe.startDamagePopup();
      // Check if the foe is dead
      if (foe.isDead()) {
        // If it is, collapse the foe
        foe.performCollapse();
      }
      // Clear the foe's results
      foe.clearResult();
    }
  }
  // Play an animation on the dying unit
  target.startAnimation(109);
  // Remove the Death Nova state
  target.removeState(56);
}
</Custom Apply Effect>
var poisonId = 12 can be removedas you dont use it as that
was used for "foe.addState(12)" where you put your ID in it.

as it can be done for the first line too, what do you mean by
element Type? default is 9, so you add some custom ones to it.

so you should add it to the dmg type of element 10.
as its a skill, the skill and set the dmg type to HP and select your element.
dmgType.png


so you can use that for it, so far I understand it?
var poisonId = 12 can be removedas you dont use it as that
was used for "foe.addState(12)" where you put your ID in it.

as it can be done for the first line too, what do you mean by
element Type? default is 9, so you add some custom ones to it.

so you should add it to the dmg type of element 10.
as its a skill, the skill and set the dmg type to HP and select your element.
View attachment 341564

so you can use that for it, so far I understand it?

This won't work, as the damage part of the Death Nova effect doesn't route through the formula-based part of the damage calculation.

After

JavaScript:
var dmg = 500 + caster.mat * 12;

put

JavaScript:
dmg = Math.floor(dmg * target.elementRate(10));
Doesn't seem to be affecting the damage done to this test dummy with 50% resist after putting in the
Code:
dmg = Math.floor(dmg * target.elementRate(10));

(I knew this one would be funky... doing damage from the knockout state notetag is weird lol)
depends if it has variance, and dmg is mostly between x and y
if formula has something like "a.atk* 4 - b.def * 2" so it has a range.

removing those *4 and *2 with just a.atk - b.def does fixed dmg.
depends if it has variance, and dmg is mostly between x and y
if formula has something like "a.atk* 4 - b.def * 2" so it has a range.

removing those *4 and *2 with just a.atk - b.def does fixed dmg.
There is no variance or difference based on defenses. The damage is done entirely through the knockout state notetag the skill itself just applies a state to the ally. Thanks to the lack of variance it's good for clearly seeing that it is doing the damage it should (except that the 50% resistance to a specific type is not being applied) I might add those things later but for now I want it to be easy to see if the element resistance is working.

(You might have to open the full image, the 476 is the damage done to the character being killed and isn't related to my problem, I probably could've cut it better but I just wanted to show it working on their death, my bad.)
I only skimmed this but isn't the target the one doing the exploding? If you wanna alter the damage with element rate, shouldn't you calculate the damage and check the rate for each 'foe' in that code? Like in the loop, above gainHp, put that:
dmg = Math.floor(dmg * foe.elementRate(10));

EDIT: Also like give the damage the original value before each foe in the loop, before the element rate modification
I only skimmed this but isn't the target the one doing the exploding? If you wanna alter the damage with element rate, shouldn't you calculate the damage and check the rate for each 'foe' in that code? Like in the loop, above gainHp, put that:
dmg = Math.floor(dmg * foe.elementRate(10));

EDIT: Also like give the damage the original value before each foe in the loop, before the element rate modification
I'll try this tomorrow thanks, off my work computer for the day.
Oh yeah, should be "foe" rather than "target", sorry!

Rather than resetting dmg each time, just do

JavaScript:
foe.gainHp(-Math.floor(dmg * foe.elementRate(10)));
Oh yeah, should be "foe" rather than "target", sorry!

Rather than resetting dmg each time, just do

JavaScript:
foe.gainHp(-Math.floor(dmg * foe.elementRate(10)));


Thank you! Got the 346 number I was looking for... also worked with element absorb.

Original thread: https://forums.rpgmakerweb.com/threads/yanfly-t-t-death-nova-effect-trying-to-give-it-a-specific-damage-type.177939/