Add an element to a state's damage

Hi Makers !

I'am using this state in my game thanks to Yanfly :
http://www.yanfly.moe/wiki/Thorn_Bind_Hostage_(MV_Plugin_Tips_&_Tricks)

To be quick, this state deals damage to the target when it receive an physical attack.
It works fine but I would like to add something more. I want this damage to have an element. Like Fire damage (element number one in my list).

Is it possible ?

Here is the original state from Yanfly :

<Custom Apply Effect>
// Sets the counter on the state to 5.
user.setStateCounter(stateId, 5);
// Determine the damage of the roots being cut.
user._thornBindDmg = origin.mat * 2;
// Determine the maximum cap of the damage.
user._thornBindDmg = Math.min(user._thornBindDmg, 1000);
</Custom Apply Effect>

<Custom Deselect Effect>
// Get the result of the target.
var result = target.result();
// Check if the target is hit, alive, the action is physical, and dealing damage.
if (result.isHit() && !target.isDead() && this.isPhysical() && this.isDamage()) {
// Play animation on target.
target.startAnimation(12);
// Get the amount of damage dealt.
var dmg = target._thornBindDmg || 1;
// Make the target lose HP.
target.gainHp(-dmg);
// Disable critical hit effects.
target.result().critical = false;
// Start the damage popup.
target.startDamagePopup();
// Clear the result.
target.clearResult();
// Change the counter on the state to drop by 1.
target.addStateCounter(stateId, -1);
// Check if the counter has reached 0.
if (target.getStateCounter(stateId) <= 0) {
// Remove the state.
target.removeState(stateId);
}
}
</Custom Deselect Effect>

Anyways, thank you guys !
When calculating the damage, you can multiply by the corresponding element rate. E.g. change this part:
Code:
// Get the amount of damage dealt.
var dmg = target._thornBindDmg || 1;
// Make the target lose HP.
target.gainHp(-dmg);
...to this:
Code:
// Get the amount of damage dealt.
var dmg = target._thornBindDmg || 1;
  // Multiply by target's fire element rate and round down to integer.
  dmg = Math.floor(dmg * target.elementRate(1));
// Make the target lose HP.
target.gainHp(-dmg);
When calculating the damage, you can multiply by the corresponding element rate. E.g. change this part:
Code:
// Get the amount of damage dealt.
var dmg = target._thornBindDmg || 1;
// Make the target lose HP.
target.gainHp(-dmg);
...to this:
Code:
// Get the amount of damage dealt.
var dmg = target._thornBindDmg || 1;
  // Multiply by target's fire element rate and round down to integer.
  dmg = Math.floor(dmg * target.elementRate(1));
// Make the target lose HP.
target.gainHp(-dmg);

Thanks you for your answer.

It would be perfect if my purpose was to change the damage of this state. But that isn't my objective.
I use a plugin that colored the pop-up according to the element. What I would like is that damage pop to follow this rule. That's why I need this damage to have an element. But I am not sure this is possible...
A link to the plugin that's creating these element coloured pop ups would be useful. It should be possible to use a method from it to create the correct popup.
A link to the plugin that's creating these element coloured pop ups would be useful. It should be possible to use a method from it to create the correct popup.


The plugin is this one :

https://forums.rpgmakerweb.com/index.php?threads/lgp-better-damage-popup.97679/page-4#post-1024752

But I change it to get the color pop up function. Now I would like to apply it to this specific state...
You should just be able to use something along these lines

Code:
target.result.itemElements = elementId

//replace elementId with element's ID
You should just be able to use something along these lines

Code:
target.result.itemElements = elementId

//replace elementId with element's ID

Hey !

I've tried

target.result.itemElements = 2;
and
target.result().itemElements = 2;

but both crash the game :s but the console is empty when I F8
I obviously jumped the gun and didn't look far enough into the code, itemElements appears to be an array so use this instead:

Code:
target.result().itemElements.push(2);
I obviously jumped the gun and didn't look far enough into the code, itemElements appears to be an array so use this instead:

Code:
target.result().itemElements.push(2);
Thanks Silva,

the games doesn't crash anymore but it seems that the damage pop up doesn't change.

I think it is because, to get the element of a skill or an item, I use the YEP function from his Elementcore plugin :

Code:
Game_Action.prototype.getItemElements = function() {
  if ($gameTemp._forcedElements !== undefined) {
    return $gameTemp._forcedElements.filter(Yanfly.Util.onlyUnique);
  }

And It may not works on state...

They may be an other way to check it. For now I use :

Code:
if (result.itemElements == 2) {
                    bitmap.textColor = LGP.Param.Fire;   
                    bitmap.outlineColor = LGP.Param.BDPcritOC;
\\If damage have element 2, then the damage popup will be orange

But maybe I can find something like :

Code:
if (Damage come grome that state) {
                    bitmap.textColor = LGP.Param.Fire;   
                    bitmap.outlineColor = LGP.Param.BDPcritOC;
\\If damage is due to the effect of this state, then the damage popup will be orange

But it starts to be to sofisticate for my skill.

Original thread: https://forums.rpgmakerweb.com/threads/add-an-element-to-a-states-damage.116309/