Origin Not Working?

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,168
Reaction score
872
First Language
English
Primarily Uses
RMMV
So I'm trying to make a skill/state that reduces the target's DEF by the caster's ATK value. This is what I have set up, but for some reason, it's reducing DEF by the target's ATK and not the caster's ATK.
<Custom Apply Effect>
sunder = origin.atk;
target._paramPlus[3] -= sunder;
</Custom Apply Effect>
<Custom Remove Effect>
target._paramPlus[3] += sunder;
</Custom Remove Effect>

Why is "origin" not working? Shouldn't "origin.atk" use the ATK value of the caster?
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,966
Reaction score
13,603
First Language
English
Primarily Uses
RMMV
uh - what plugin? Generally we like a link to it, but at least the name would help.

Shouldn't it be user rather than origin?
And you might need to define sunder in both blocks?
 

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,168
Reaction score
872
First Language
English
Primarily Uses
RMMV
Oh right, the <Custom Apply Effect> notetag is Yanfly's BuffStatesCore. I just figured Yanfly plugins were mainstream enough to be easily recognizable, sry about that. I tried "user" as well, same effect. I want this skill to apply a state. This state would decrease the target's (unit with the state) DEF by an amount equal to the caster's (unit that used the skill that applied this state) ATK.

I know the "var sunder" is getting through to both blocks because the DEF is being lowered, but it's being lowered by an amount equal to the state holder's ATK and not the caster of the skill's ATK.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,966
Reaction score
13,603
First Language
English
Primarily Uses
RMMV
Because sunder may be from an old calculation. Humour me and pop it into the second one too, and see if it makes a difference.

I'm not really familiar with Yanfly's plugins, so just having a few guesses.
 

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,168
Reaction score
872
First Language
English
Primarily Uses
RMMV
Because sunder may be from an old calculation. Humour me and pop it into the second one too, and see if it makes a difference.

I'm not really familiar with Yanfly's plugins, so just having a few guesses.
K, just tried it...same result, which makes sense since the 2nd block is only for when the state leaves the unit. User, Target, & Origin shouldn't be a Yanfly only thing. They're universal for MV in general, aren't they?
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,839
First Language
English
The only thing MV has is "a" for user, "b" for target.
 

Ossra

Formerly Exhydra
Veteran
Joined
Aug 21, 2013
Messages
1,076
Reaction score
847
First Language
English
Primarily Uses
RMMV
'a' for user of the item/skill, 'b' for the target, 'item' for the used item/skill object, and 'v' for game variables. But Yanfly's code may be eval'd elsewhere, so the default variables usable in damage formulas may not be present.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,966
Reaction score
13,603
First Language
English
Primarily Uses
RMMV
okay, had a look at the code. The custom effects all use the target's stats. Seems that's the way it's meant to work.

Code:
    var a = this;
    var user = this;
    var target = this;
    var origin = this.stateOrigin(stateId);
    var s = $gameSwitches._data;
    var v = $gameVariables._data;
    var code = state.customEffectEval[type];
    try {
      eval(code);
 

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,168
Reaction score
872
First Language
English
Primarily Uses
RMMV
Strange...various tips and tricks videos suggest "origin" is definitely different than "target" or "user".

In any case, how would I get my skill's effect working correctly?

In Yanfly's code for Unstable Affliction we see "origin" used to get the caster's MAT value:
<Custom Regenerate Effect>
// Get the Darkness element.
var elementId = 10;
// Damage set to equal the origin's MAT.
var damage = origin.mat;

// Damage multiplier for weakness/resistance to Darkness element.
damage *= user.elementRate(elementId);
// Round down the damage.
damage = Math.floor(damage);
// Inflict damage to the user.
user.gainHp(-damage);
</Custom Regenerate Effect>
 
Last edited:

Soulrender

Jack Of All Trades
Veteran
Joined
Jan 12, 2019
Messages
792
Reaction score
428
First Language
Poland
Primarily Uses
RMMV
I have similar state in my game, but I think you need temporary store atk value of caster in game variable
so I guess this notetag should work for you:
Code:
<Custom Apply Effect>
$gameVariables.setValue(1, user.atk); //this is most important part
this.addParam(3, -$gameVariables.value(1));
</Custom Apply Effect>

<Custom Remove Effect>
this.addParam(3, $gameVariables.value(1));
</Custom Remove Effect>
Correct me If Im wrong, because I don't remember how to refer to enemy, when state is applied.
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
1,940
Reaction score
1,392
First Language
EN
Primarily Uses
RMMZ
I'd suggest storing the value on the affected battler:
Code:
<Custom Apply Effect>
user._sunder = origin.atk;
user.addParam(3, -user._sunder);
</Custom Apply Effect>

<Custom Remove Effect>
user.addParam(3, user._sunder);
delete user._sunder;
</Custom Remove Effect>
Note that there are some caveats with Buffs & States stuff: the notetags only process when in battle, and the remove effect will not run if the state is removed via State Resist. (There may be other cases, too.)

origin should work for referencing the caster, I'll go do some tests...
Edit: yep, looks OK for me! :kaojoy:
 

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,168
Reaction score
872
First Language
English
Primarily Uses
RMMV
I'd suggest storing the value on the affected battler:
Code:
<Custom Apply Effect>
user._sunder = origin.atk;
user.addParam(3, -user._sunder);
</Custom Apply Effect>

<Custom Remove Effect>
user.addParam(3, user._sunder);
delete user._sunder;
</Custom Remove Effect>
Note that there are some caveats with Buffs & States stuff: the notetags only process when in battle, and the remove effect will not run if the state is removed via State Resist. (There may be other cases, too.)

origin should work for referencing the caster, I'll go do some tests...
Edit: yep, looks OK for me! :kaojoy:
Looks like LTBS is breaking stuff again...sigh:kaosigh:

I just noticed a bug where states aren't ticking at all. Like the turns remaining stay the same as when they're applied...

I might just have to start the project over and slowly import stuff since I have no idea what's the root cause of this.

Edit: Omg, I found the issue... In the YEP_BattleEngineCore.js settings, I had it set to stb (what I was using before installing LTBS) and never changed it back to dtb when I removed YEP_X_BattleSysSTB.js.

I only found out cuz I was partway through redoing my entire project from scratch! No wonder I was experiencing so many bugs...

I'd suggest storing the value on the affected battler:
Code:
<Custom Apply Effect>
user._sunder = origin.atk;
user.addParam(3, -user._sunder);
</Custom Apply Effect>

<Custom Remove Effect>
user.addParam(3, user._sunder);
delete user._sunder;
</Custom Remove Effect>
Note that there are some caveats with Buffs & States stuff: the notetags only process when in battle, and the remove effect will not run if the state is removed via State Resist. (There may be other cases, too.)

origin should work for referencing the caster, I'll go do some tests...
Edit: yep, looks OK for me! :kaojoy:
Wait when you tested it, did origin actually use the caster's stats? Cuz I just copy-pasted Yanfly's Unstable Affliction spell and the damage dealt is using the target's MAT and not the caster's MAT...

This whole issue with "origin" not working seems to be related to LTBS as a whole...
 
Last edited:

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,168
Reaction score
872
First Language
English
Primarily Uses
RMMV
I have similar state in my game, but I think you need temporary store atk value of caster in game variable
so I guess this notetag should work for you:
Code:
<Custom Apply Effect>
$gameVariables.setValue(1, user.atk); //this is most important part
this.addParam(3, -$gameVariables.value(1));
</Custom Apply Effect>

<Custom Remove Effect>
this.addParam(3, $gameVariables.value(1));
</Custom Remove Effect>
Correct me If Im wrong, because I don't remember how to refer to enemy, when state is applied.
I tried this but it's still using the stateholder's ATK value instead of the caster's ATK value...
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
1,940
Reaction score
1,392
First Language
EN
Primarily Uses
RMMZ
Wait when you tested it, did origin actually use the caster's stats? Cuz I just copy-pasted Yanfly's Unstable Affliction spell and the damage dealt is using the target's MAT and not the caster's MAT...
Yes. I tested with only Buffs & States Core, and used this notetag on my state:
Code:
<Custom Apply Effect>
alert("caster's atk is " + origin.atk);
</Custom Apply Effect>
In a fight between 3 actors with 26 ATK and two enemies with 50 ATK, when the enemies applied the state the quoted value was 50; when the actors applied the state it was 26.

It doesn't surprise me that LTBS is incompatible with this sort of thing. For complex stuff like this it's generally much easier to design your own system rather than integrate new code into the existing system. I imagine it simply bypasses the part of the code where Yanfly put this Buffs & States stuff. .-.
 

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,168
Reaction score
872
First Language
English
Primarily Uses
RMMV
It doesn't surprise me that LTBS is incompatible with this sort of thing. For complex stuff like this it's generally much easier to design your own system rather than integrate new code into the existing system. I imagine it simply bypasses the part of the code where Yanfly put this Buffs & States stuff. .-.
Yea, I even considered switching engines to SRPG or something, but after taking a look at it, it's just too different than what I'm aiming for. Maybe I can use a variable to hold the caster's stat info... But I still need something to reference the caster in the 1st place and idk what that would be...
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

I think in the pursuit of making the game look and sound custom, we never really start making a game. Finish the game first using all necessary plugins (with placeholder assets), then replace it with the real ones.

I haven't finished a game, but I try this method. Progress seems to be faster. :D
Every now and then I think about all the things I need in my project, and get overwhelmed. Just focus on your tilesets, me. You can't build your maps without 'em!
If a picture speaks 1000 words, how many pictures does a video speak??
I don't really get the "Pass Interference" Flag in (American) Football. Aren't you SUPPOSED to interfere with passes in Defense?? What exactly is the threshold that warrants a Flag?
TS Zeta.. blow your ass east... I cant take a round 3.

Forum statistics

Threads
104,435
Messages
1,006,328
Members
135,957
Latest member
parttimerpgmaker
Top