(Solved) (Yanfly Plugins) Can't remember how to check for a certain element on attack.

Servidion

Last Soul Keeper
Veteran
Joined
Mar 15, 2015
Messages
233
Reaction score
27
First Language
English
Primarily Uses
RMMV
Trying to add an effect based on if a certain element did damage, but I can't recall how that is done. This is what I have so far for my state:

<Custom Establish Effect>
if target.result().hpDamage > 0 && (Attack element of 13) {
user.addState(872);
}
</Custom Establish Effect>

Basically if I damage a target with the Holy element I will gain state 872. I just can't remember how to check for element type.

*Edit*
Solution by @emelian65

<Custom Respond Effect>
var element = 13;
if (this.item().damage.elementId === element) {
user.addState(872);
}
</Custom Respond Effect>

You can also see Emelian's work a few posts down where more detail is added.
 
Last edited:

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,959
First Language
English
Primarily Uses
RMMV
I don't really use Yanfly's plugins/scripts as I write my own, but from what I know of it I think you can do this with:

user.currentAction().item().damage.elementId === 13
 

Servidion

Last Soul Keeper
Veteran
Joined
Mar 15, 2015
Messages
233
Reaction score
27
First Language
English
Primarily Uses
RMMV
So I tried the following:

<Custom Establish Effect>
if target.result().hpDamage > 0 && user.currentAction().item().damage.elementId === 13 {
user.addState(872);
}
</Custom Establish Effect>

But it doesn't seem to have any effect.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,959
First Language
English
Primarily Uses
RMMV
Establish effect may be too late for it. Does the console show any errors?
 

Servidion

Last Soul Keeper
Veteran
Joined
Mar 15, 2015
Messages
233
Reaction score
27
First Language
English
Primarily Uses
RMMV
SyntaxError: Unexpected identifier {stack: (...), message: "Unexpected identifier"}
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,959
First Language
English
Primarily Uses
RMMV
Okay, it may be that the action has already been flushed when establish effect fires.

Do me a favour then: get into a battle, choose the holy ability you're testing with, then write

$gameParty.members()[index of user].currentAction().item().damage.elementId === 13

in the console, and tell me if that returns true.
 

Servidion

Last Soul Keeper
Veteran
Joined
Mar 15, 2015
Messages
233
Reaction score
27
First Language
English
Primarily Uses
RMMV
$gameParty.members()[index of user].currentAction().item().damage.elementId === 13
VM2306:2 Uncaught SyntaxError: Unexpected identifier
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,959
First Language
English
Primarily Uses
RMMV
Did you replace "index of user" with the actual index of the party member who took the action?
 

emelian65

Veteran
Veteran
Joined
Sep 13, 2015
Messages
190
Reaction score
50
First Language
Spanish
Primarily Uses
I have a question, do you want the state to react to a certain element?
In that case, something like this should work.
Code:
<Custom Respond Effect>
// Get the ID from the element you want to react
// where X is the element you want to react
var element = X;
// Check if the X element damage is dealt.
if (this.item().damage.elementId === element) {
// effect you want
} else {
// effect you want
}
</Custom Respond Effect>
 

Servidion

Last Soul Keeper
Veteran
Joined
Mar 15, 2015
Messages
233
Reaction score
27
First Language
English
Primarily Uses
RMMV
Had no idea I needed to. I can barely comprehend Java. lol

$gameParty.members()[1].currentAction().item().damage.elementId === 13
VM1808:2 Uncaught TypeError: Cannot read property 'currentAction' of undefined
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,959
First Language
English
Primarily Uses
RMMV
Are you doing that command in the console right after the party member chooses a target for the skill?

Edit: emelian's idea might work. I didn't realise the "this" scope for the lunatic tags was the current action.
 
Last edited:

Servidion

Last Soul Keeper
Veteran
Joined
Mar 15, 2015
Messages
233
Reaction score
27
First Language
English
Primarily Uses
RMMV
@emelian65 Not quite. The passive state is on me and I want it to give me another state if I damage the enemy with a specific element. Custom Respond is if I'm the one taking the damage. Your code DOES work if I change it to "Establish" from "Respond". Thank you for the help. :)

@Trihan And thank you for the help, as well. I may use a similar damage formula for some other skills in the future.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,959
First Language
English
Primarily Uses
RMMV
Yeah, I edited out the bit I edited in about being able to do it in the formula box after remembering you'd wanted to make sure it did damage first, but if you don't have that requirement for future skills it's easy to do.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c

Forum statistics

Threads
105,857
Messages
1,017,018
Members
137,563
Latest member
MinyakaAeon
Top