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

Status
Not open for further replies.

MonsieurClayton

Villager
Member
Joined
Sep 18, 2015
Messages
6
Reaction score
1
First Language
French
Primarily Uses
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
100; b.addstate(X)
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 :D

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
Veteran
Joined
Jun 6, 2020
Messages
488
Reaction score
212
First Language
English
Primarily Uses
RMMV
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);
    b.addState(39);
} else {
    b.addState(31);
    r = 0.75;
}
a.mat * r
 

MonsieurClayton

Villager
Member
Joined
Sep 18, 2015
Messages
6
Reaction score
1
First Language
French
Primarily Uses
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 :D
 

HumanNinjaToo

The Cheerful Pessimist
Veteran
Joined
Apr 18, 2013
Messages
1,113
Reaction score
517
First Language
English
Primarily Uses
RMMV
I was just going to add that
100; b.addstate(X)
won't work because the damage has to go last, so it needs to be
b.addState(Id); 100

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

Solar_Flare

Veteran
Veteran
Joined
Jun 6, 2020
Messages
488
Reaction score
212
First Language
English
Primarily Uses
RMMV
This is JavaScript, not Java, for the record. They are two completely different programming languages.
 

MonsieurClayton

Villager
Member
Joined
Sep 18, 2015
Messages
6
Reaction score
1
First Language
French
Primarily Uses
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 :p

Thank you all again :D
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,373
Reaction score
1,548
First Language
English
Primarily Uses
RMMV
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
Member
Joined
Sep 18, 2015
Messages
6
Reaction score
1
First Language
French
Primarily Uses
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
Veteran
Joined
Apr 12, 2012
Messages
2,373
Reaction score
1,548
First Language
English
Primarily Uses
RMMV
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
Veteran
Joined
Jun 6, 2020
Messages
488
Reaction score
212
First Language
English
Primarily Uses
RMMV
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
Global Mod
Joined
Sep 6, 2012
Messages
7,003
Reaction score
4,744
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

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

Latest Threads

Latest Profile Posts

So I just spent the weekend...playing my own game. The one I released last year. Yep you heard that right.
Goal for MZ? None... I'm still curious how to finish my VXA project and how it looks like when it actually finished. Which will take at least another two years. Coming late again to the party.
Finding it amusing that people are posting support questions in new threads for an engine that isn't even released yet. Touch and Archeia are the only ones authorised to say anything, and there's only one active thread where they'll be answering questions.
I think my goal for MZ ... is to actually release a game and not have twenty technical demos and debugging projects. Let's see if I can manage that. ;o
I am starting to enjoy writing. I never thought I would enjoy it since my dyslexia was holding me back so much.
Thanks to the community here :)
For those interested chapter 2 and 3 are available to read here:

Forum statistics

Threads
100,652
Messages
978,096
Members
132,261
Latest member
DarthNinjus
Top