[SOLVED]Multiple conditions Damage Formula, and dual effect in Formula (Damage + add state)

Status
Not open for further replies.

MonsieurClayton

Villager
Hello
First of all, sorry for broken english, I'll try to make as less gramatical errors as possible.

I'm working on a skill, but I'm not even sure I can manage to do it with skill formulas.

This spell, let's call it "Arcane Shock", deals damage depending on specific states ("Arcane Stain") applied to the target and applies those specific states if they are not already applied. There are two levels to those states ("Arcane Stain I & Arcane Stain II).

Here is how I'd like it to go :
> Player Character casts "Arcane Shock"
> Check if "Arcane Stain II" is applied to the enemy, if it is : deals 125% damage, refresh "Arcane Stain II"
> If not, check if "Arcane Stain I" is applied to the enemy, if it is : deals 100% damage, applies "Arcane Stain II", removes "Arcane Stain I"
> If not, deals 75% damage, applies "Arcane Stain I"
I tried this formula :
b.isStateAffected(39) ? a.mat * 1.25 : b.isStateAffcted(31) ? a.mat ; b.addState(39) : a.mat * 0.75 ; b.addState(31)
State 31 is "Arcane Stain I" and State 39 is "Arcane Stain II"

I have it specified in "Arcane Stain II" Notes that "Arcane Stain I" is removed when "Arcane Stain II" is applied thanks to Yanfly's Buff & State Core.
I also have <State 39 Turns: +1> in the Skill Note, in order to refresh "Arcane Stain II".

I have two issues with my formula :

Multi-conditions does not seems to work, at least not written like this, as the skill does 0 damage 100% of the time.
Meaning, this, alone, does not work :
b.isStateAffected(40) ? a.mat * 1.25 : b.isStateAffcted(31) ? a.mat : a.mat * 0.75
I don't know how I can deal damage AND add a state at the same time (with formula command) Even with a simple
It should deal 100 damage and add state X to the enemy, right ? But it does not work, I guess I just do not know how I should write it.

What should I write in my damage formula for my skill to work as intended ?

Thanks in advance to anyone who could help in any way

EDIT : I know I could workaround the damage buff of the spell by making the spell one specific Element and the States changing the weakness to this Element but as I'm learning to do whatever I can with formulas, I'd be happy to find a way to do this with formulas
Also, I've no idea yet how to deal with the "Stack" mechanic without formulas (Adding "Arcane Stain I" if no state is already applied and "Arcane Stain II" if "Arcane Stain I" is already applied).

EDIT 2: Yeah, of course I noticed the Thread about formulas 10 minutes after creating this one...Sorry, Maths hurt my brain.

Last edited:

Solar_Flare

Veteran
Multi-conditions does not seems to work, at least not written like this, as the skill does 0 damage 100% of the time.
Meaning, this, alone, does not work :

Code:
``b.isStateAffected(40) ? a.mat * 1.25 : b.isStateAffcted(31) ? a.mat : a.mat * 0.75``
This is correct syntax, but you have a typo there - missing an e in isStateAffected. That's why it's not working.

This might be a place where if statements are easier to understand than if expressions, though. Something like this (I've split it into multiple lines so you can see what's happening, obviously you'd need to put it all on one line for the damage formula box though):

JavaScript:
``````var r = 1;
if(b.isStateAffected(39)) {
r = 1.25;
} else if(b.isStateAffected(31)) {
b.removeState(31);
} else {
r = 0.75;
}
a.mat * r``````

MonsieurClayton

Villager
Omg that stupid typo... I was persuaded my syntax was wrong.
Thank you very much

And thanks a lot for the more complex code, I can do way more with that !

I'm novice in Java (and simply coding), so I learn through this kind of things.

Thank you again

HumanNinjaToo

The Cheerful Pessimist
I was just going to add that
won't work because the damage has to go last, so it needs to be

Also, not sure if just a typo in your post, but you gotta check your caps, your state was not capitalized.

Solar_Flare

Veteran
This is JavaScript, not Java, for the record. They are two completely different programming languages.

MonsieurClayton

Villager
Hmm I tried with both caps and without, I think. But I must have made a typo somewhere else, I guess.

I'm happy that my understanding of the syntax was correct, tho. I have to be more careful with those pesky little mistakes.

JavaScript, not Java. Noted. As I said, 100% novice

Thank you all again

Trihan

Speedy Scripter
Rather than using different states, if you have Buffs & States Core you could use state counters instead to just stack the one state.

MonsieurClayton

Villager
Oh I didn't know you could do that.
Anyway, the result is almost the same, right ?

I also have a skill that lenghtens the duration of "Arcane Stain II", I guess that if I did what you said I could extend the duration of the skill, and keep the extended duration when stacking more...
At this point it's more of a balancing issue, but I already have a solution if I have to do that, then

Thank you.

Trihan

Speedy Scripter
Yeah, if you already have it working by no means reinvent the wheel here, just pointing out an alternative for future development reference.

Solar_Flare

Veteran
There is also a HimeWorks plugin that does something similar to what you wanted - it would allow you to set it up so that applying stain I if it's already applied automatically upgrades it to stain II. I think it was called Placeholder States but I can't quite remember, there are two or three plugins that could be the one I'm thinking of.

But yeah, if you've got it working, no need to reinvent the wheel.

slimmmeiske2

Little Red Riding Hood

Status
Not open for further replies.

Latest Profile Posts

Streaming now!
I just like this website:
lol
I streamed Moonfall on 9/25/20
and have started a page to showcase my vids/stream

Please subscribe and follow, it's free, it's quick and one sub means so much to me, it would really make my day~

And now to face my worst enemy... adding color