[YEP_BuffStatesCore]"Origin.param" returns the wrong actor's parameter

Hello!
I'm making a State that regenerates an Actor's health every turn based on the Luk parameter of the actor that afflicted it to him. To do this i'm using a few of Yanfly's plugins, such as the BuffStatesCore.

This is the code written for the State:
Code:
<Custom Apply Effect>
// Calculate the damage to be dealt by the formula.
target._Guidato = Math.floor((origin.param(7) - 10) / 2);
</Custom Apply Effect>

<Custom Remove Effect>
// Remove the damage effect.
target._Guidato = undefined;
</Custom Remove Effect>

<Custom Regenerate Effect>
// Default the DoT formula.
target._Guidato = target._Guidato || Math.floor((origin.param(7) - 10) / 2);
// Increases the target's HP
target.gainHp(target._Guidato);
// Start the damage popup.
target.startDamagePopup();
// Clear the target's results.
target.clearResult();
</Custom Regenerate Effect>

In theory, this code should take the Luk parameter of the actor that applied the skill, and use it as a base for the Health Regeneration effect. Apparently it doesn't work that way, and instead uses the Luk parameter of the actor that receives the State. I remember that "origin" served the exact purpose that i need, but perhaps it works differently?
EDIT: I should add, the skill that applies this State works outside of battle as well. Maybe it has something to do with that?
It works fine for me, even with a state that isn't removed at battle end.

FYI you can use .luk rather than .param(7).
It works fine for me, even with a state that isn't removed at battle end.

FYI you can use .luk rather than .param(7).
Yeah i put "param(7)" just to see if that was the issue.
Do you perhaps know if "origin" doesn't work if you're outside of battle?
I'm not 100% sure as Custom Regenerate Effects don't seem to trigger outside of battle anyway, but it looks like origin on the map is considered to be the actor with the state rather than the one who applied it to begin with.
I'm not 100% sure as Custom Regenerate Effects don't seem to trigger outside of battle anyway, but it looks like origin on the map is considered to be the actor with the state rather than the one who applied it to begin with.
I see. I think i can circumvent this by assigning the value of the caster to an external variable with the Action Sequence plugin. I'll see if it works.
That should work, yeah.
Aight, now i'm having another problem ^^"
I made this action sequence for the skill that applies the State:

Code:
<setup action>
display action
wait: 40
clear battle log
change variable 2 = user.luk
</setup action>
<finish action>
</finish action>

But apparently when the state is applied the game reads the variable like it's equal to 0. Does perhaps the state application happen before the variable is set with the parameter?

EDIT: It would be more helpful if I showed the changed State's code too:
Code:
<Custom Apply Effect>
// Calculate the damage to be dealt by the formula.
console.log($gameVariables.value(2));
var guide = Math.floor(($gameVariables.value(2) - 10) / 2);
target._Guidato = guide;
</Custom Apply Effect>

<Custom Remove Effect>
// Remove the damage effect.
target._Guidato = undefined;
</Custom Remove Effect>

<Custom Regenerate Effect>
// Default the DoT formula.
target._Guidato = target._Guidato || Math.floor((origin.param(7) - 10) / 2);
// Increases the target's HP
target.gainHp(target._Guidato);
// Start the damage popup.
target.startDamagePopup();
// Clear the target's results.
target.clearResult();
</Custom Regenerate Effect>
Quite possibly, yeah.
Quite possibly, yeah.
It doesn't seem like the case tho. I tried returning Var 2's value from the Console after using the attack. and it returns me zero. It seems that there's something else that is wrong here.
I don't have the time at the moment to properly delve into this, but if I get a chance I'll see if I can figure out what's going on.
I don't have the time at the moment to properly delve into this, but if I get a chance I'll see if I can figure out what's going on.
Thanks!
EDIT: Just that i'm sure: Do action effects work outside of battle?
EDIT2: No they don't. I think i'm a bit lost here.
Have you tried setting the variable in the skill note tag using <Before Eval> ?

edit: sorry, you would need Yanfly skill core for this, not sure if you utilize that plugin as well
Have you tried setting the variable in the skill note tag using <Before Eval> ?

edit: sorry, you would need Yanfly skill core for this, not sure if you utilize that plugin as well
YES! It worked!
I put this code in the <Before Eval> tag:


Code:
<Before Eval>
if(!$gameParty.inBattle())
{
   $gameVariables.setValue(2, user.luk);
}
</Before Eval>

So it takes the luk value of the user only if not in battle.
Then there's this code for the State:


Code:
<Custom Apply Effect>
var luk = 0;
if(!$gameParty.inBattle())
{
   luk = $gameVariables.value(2);
}
else
{
   luk = origin.luk;
}
// Calculate the damage to be dealt by the formula.
target._Guidato = Math.max(Math.floor((luk - 10) / 2), 1);
</Custom Apply Effect>

Which uses var2 as the luk value if, again, outside battle.
Thank you so much!

EDIT: Then again, it is pointless to use "origin" in this case if i can use <Before Eval>.

Spoiler
Code:
<Before Eval>
$gameVariables.setValue(2, user.luk);
</Before Eval>

Code:
<Custom Apply Effect>
var luk = $gameVariables.value(2);
// Calculate the damage to be dealt by the formula.
target._Guidato = Math.max(Math.floor((luk - 10) / 2), 1);
</Custom Apply Effect>

Original thread: https://forums.rpgmakerweb.com/threads/yep_buffstatescore-origin-param-returns-the-wrong-actors-parameter.124096/